aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/bansystem.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-01-02 03:06:04 +0000
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-01-02 03:06:04 +0000
commit5514ff036dbdbf7f4000934223a0d21bf0b9085d (patch)
treef0320ef7f2ccd029bc04339d6f4b63e4ffdab7e8 /NorthstarDedicatedTest/bansystem.cpp
parent4ad3342f6ce8ac4e9976f5eab5410c58b420a6a4 (diff)
downloadNorthstarLauncher-5514ff036dbdbf7f4000934223a0d21bf0b9085d.tar.gz
NorthstarLauncher-5514ff036dbdbf7f4000934223a0d21bf0b9085d.zip
initial work for ban system
Diffstat (limited to 'NorthstarDedicatedTest/bansystem.cpp')
-rw-r--r--NorthstarDedicatedTest/bansystem.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/bansystem.cpp b/NorthstarDedicatedTest/bansystem.cpp
new file mode 100644
index 00000000..16c25b6b
--- /dev/null
+++ b/NorthstarDedicatedTest/bansystem.cpp
@@ -0,0 +1,58 @@
+#pragma once
+#include "pch.h"
+#include "bansystem.h"
+#include "serverauthentication.h"
+#include "concommand.h"
+#include <filesystem>
+
+const char* BANLIST_PATH = "R2Northstar/banlist.txt";
+
+ServerBanSystem* g_ServerBanSystem;
+
+void ServerBanSystem::OpenBanlist()
+{
+ std::filesystem::create_directories(BANLIST_PATH);
+
+ std::ifstream enabledModsStream(BANLIST_PATH);
+ std::stringstream enabledModsStringStream;
+
+ if (!enabledModsStream.fail())
+ {
+ std::string line;
+ while (std::getline(enabledModsStream, line))
+ m_vBannedUids.push_back(strtoll(line.c_str(), nullptr, 10));
+
+ enabledModsStream.close();
+ }
+
+ // open write stream for banlist
+ m_sBanlistStream.open(BANLIST_PATH, std::ios::in | std::ios::binary);
+}
+
+void ServerBanSystem::BanUID(uint64_t uid)
+{
+ m_vBannedUids.push_back(uid);
+
+ m_sBanlistStream << std::to_string(uid) << std::endl;
+}
+
+bool ServerBanSystem::IsUIDAllowed(uint64_t uid)
+{
+ return std::find(m_vBannedUids.begin(), m_vBannedUids.end(), uid) == m_vBannedUids.end();
+}
+
+void BanPlayerCommand(const CCommand& args)
+{
+ if (args.ArgC() < 2)
+ return;
+
+
+}
+
+void InitialiseBanSystem(HMODULE baseAddress)
+{
+ g_ServerBanSystem = new ServerBanSystem;
+ g_ServerBanSystem->OpenBanlist();
+
+ RegisterConCommand("ban", BanPlayerCommand, "bans a given player by uid or name", FCVAR_GAMEDLL);
+} \ No newline at end of file