diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-01-02 04:07:42 +0000 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-01-02 04:07:42 +0000 |
commit | 49acb6d831919022745b68f474b65c19f4e62bcd (patch) | |
tree | 5d81281e36b2c5cf9f3e7ccbbf0701f86940dfe5 /NorthstarDedicatedTest | |
parent | ed0f27914710b75a246645380e167dad071adaa7 (diff) | |
download | NorthstarLauncher-49acb6d831919022745b68f474b65c19f4e62bcd.tar.gz NorthstarLauncher-49acb6d831919022745b68f474b65c19f4e62bcd.zip |
add unban command
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r-- | NorthstarDedicatedTest/bansystem.cpp | 24 | ||||
-rw-r--r-- | NorthstarDedicatedTest/bansystem.h | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/bansystem.cpp b/NorthstarDedicatedTest/bansystem.cpp index 40813f17..182506e8 100644 --- a/NorthstarDedicatedTest/bansystem.cpp +++ b/NorthstarDedicatedTest/bansystem.cpp @@ -32,6 +32,19 @@ void ServerBanSystem::BanUID(uint64_t uid) { m_vBannedUids.push_back(uid); m_sBanlistStream << std::to_string(uid) << std::endl; + spdlog::info("{} was banned", uid); +} + +void ServerBanSystem::UnbanUID(uint64_t uid) +{ + auto findResult = std::find(m_vBannedUids.begin(), m_vBannedUids.end(), uid); + if (findResult == m_vBannedUids.end()) + return; + + m_vBannedUids.erase(findResult); + spdlog::info("{} was unbanned", uid); + // todo: this needs to erase from the banlist file + // atm unsure how to do this aside from just clearing and fully rewriting the file } bool ServerBanSystem::IsUIDAllowed(uint64_t uid) @@ -44,6 +57,7 @@ void BanPlayerCommand(const CCommand& args) if (args.ArgC() < 2) return; + // assuming maxplayers 32 for (int i = 0; i < 32; i++) { void* player = GetPlayerByIndex(i); @@ -57,10 +71,20 @@ void BanPlayerCommand(const CCommand& args) } } +void UnbanPlayerCommand(const CCommand& args) +{ + if (args.ArgC() < 2) + return; + + // assumedly the player being unbanned here wasn't already connected, so don't need to iterate over players or anything + g_ServerBanSystem->UnbanUID(strtoll(args.Arg(1), nullptr, 10)); +} + void InitialiseBanSystem(HMODULE baseAddress) { g_ServerBanSystem = new ServerBanSystem; g_ServerBanSystem->OpenBanlist(); RegisterConCommand("ban", BanPlayerCommand, "bans a given player by uid or name", FCVAR_GAMEDLL); + RegisterConCommand("unban", UnbanPlayerCommand, "unbans a given player by uid", FCVAR_NONE); }
\ No newline at end of file diff --git a/NorthstarDedicatedTest/bansystem.h b/NorthstarDedicatedTest/bansystem.h index b316fc6f..a1646356 100644 --- a/NorthstarDedicatedTest/bansystem.h +++ b/NorthstarDedicatedTest/bansystem.h @@ -10,6 +10,7 @@ private: public: void OpenBanlist(); void BanUID(uint64_t uid); + void UnbanUID(uint64_t uid); bool IsUIDAllowed(uint64_t uid); }; |