diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-01-02 03:52:39 +0000 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-01-02 03:52:39 +0000 |
commit | ed0f27914710b75a246645380e167dad071adaa7 (patch) | |
tree | 5e5d14ece2ba07f5fe480cfae222a74a8a1a1746 /NorthstarDedicatedTest/bansystem.cpp | |
parent | 89d16c9a8a65e3b4872947c58df1ffd97fc63a4b (diff) | |
download | NorthstarLauncher-ed0f27914710b75a246645380e167dad071adaa7.tar.gz NorthstarLauncher-ed0f27914710b75a246645380e167dad071adaa7.zip |
add disconnects to ban system
Diffstat (limited to 'NorthstarDedicatedTest/bansystem.cpp')
-rw-r--r-- | NorthstarDedicatedTest/bansystem.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/NorthstarDedicatedTest/bansystem.cpp b/NorthstarDedicatedTest/bansystem.cpp index 16c25b6b..40813f17 100644 --- a/NorthstarDedicatedTest/bansystem.cpp +++ b/NorthstarDedicatedTest/bansystem.cpp @@ -3,6 +3,7 @@ #include "bansystem.h" #include "serverauthentication.h" #include "concommand.h" +#include "miscserverscript.h" #include <filesystem> const char* BANLIST_PATH = "R2Northstar/banlist.txt"; @@ -11,8 +12,6 @@ ServerBanSystem* g_ServerBanSystem; void ServerBanSystem::OpenBanlist() { - std::filesystem::create_directories(BANLIST_PATH); - std::ifstream enabledModsStream(BANLIST_PATH); std::stringstream enabledModsStringStream; @@ -26,13 +25,12 @@ void ServerBanSystem::OpenBanlist() } // open write stream for banlist - m_sBanlistStream.open(BANLIST_PATH, std::ios::in | std::ios::binary); + m_sBanlistStream.open(BANLIST_PATH, std::ofstream::out | std::ofstream::binary | std::ofstream::app); } void ServerBanSystem::BanUID(uint64_t uid) { m_vBannedUids.push_back(uid); - m_sBanlistStream << std::to_string(uid) << std::endl; } @@ -46,7 +44,17 @@ void BanPlayerCommand(const CCommand& args) if (args.ArgC() < 2) return; + for (int i = 0; i < 32; i++) + { + void* player = GetPlayerByIndex(i); + if (!strcmp((char*)player + 0x16, args.Arg(1)) || strcmp((char*)player + 0xF500, args.Arg(1))) + { + g_ServerBanSystem->BanUID(strtoll((char*)player + 0xF500, nullptr, 10)); + CBaseClient__Disconnect(player, 1, "Banned from server"); + break; + } + } } void InitialiseBanSystem(HMODULE baseAddress) |