Beginning of a banclient command

This commit is contained in:
momo5502 2016-08-15 16:40:30 +02:00
parent 84422b0fc0
commit 1b71afcc21
50 changed files with 250 additions and 46 deletions

View File

@ -10,6 +10,7 @@ namespace Components
Loader::Register(new Singleton()); Loader::Register(new Singleton());
Loader::Register(new Auth()); Loader::Register(new Auth());
Loader::Register(new Bans());
Loader::Register(new Dvar()); Loader::Register(new Dvar());
Loader::Register(new Maps()); Loader::Register(new Maps());
Loader::Register(new News()); Loader::Register(new News());

View File

@ -5,7 +5,11 @@ namespace Components
public: public:
Component() {}; Component() {};
virtual ~Component() {}; virtual ~Component() {};
#ifdef DEBUG
virtual const char* GetName() { return "Unknown"; }; virtual const char* GetName() { return "Unknown"; };
#endif
virtual bool UnitTest() { return true; }; // Unit testing entry virtual bool UnitTest() { return true; }; // Unit testing entry
}; };
@ -24,6 +28,7 @@ namespace Components
} }
#include "Modules\Auth.hpp" #include "Modules\Auth.hpp"
#include "Modules\Bans.hpp"
#include "Modules\Dvar.hpp" #include "Modules\Dvar.hpp"
#include "Modules\Maps.hpp" #include "Modules\Maps.hpp"
#include "Modules\News.hpp" #include "Modules\News.hpp"

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
AntiCheat(); AntiCheat();
~AntiCheat(); ~AntiCheat();
const char* GetName() { return "Component"; }; // Wrong name :P
#ifdef DEBUG
const char* GetName() { return "AntiCheat"; };
#endif
static void CrashClient(); static void CrashClient();
static void EmptyHash(); static void EmptyHash();

View File

@ -19,7 +19,10 @@ namespace Components
AssetHandler(); AssetHandler();
~AssetHandler(); ~AssetHandler();
#ifdef DEBUG
const char* GetName() { return "AssetHandler"; }; const char* GetName() { return "AssetHandler"; };
#endif
static void OnFind(Game::XAssetType type, Callback* callback); static void OnFind(Game::XAssetType type, Callback* callback);
static void OnLoad(RestrictCallback* callback); static void OnLoad(RestrictCallback* callback);

View File

@ -5,7 +5,11 @@ namespace Components
public: public:
Auth(); Auth();
~Auth(); ~Auth();
#ifdef DEBUG
const char* GetName() { return "Auth"; }; const char* GetName() { return "Auth"; };
#endif
bool UnitTest(); bool UnitTest();
static void StoreKey(); static void StoreKey();

View File

@ -0,0 +1,43 @@
#include "STDInclude.hpp"
namespace Components
{
void Bans::BanClientNum(int num, std::string reason)
{
if (!Dvar::Var("sv_running").Get<bool>())
{
Logger::Print("Server is not running.\n");
return;
}
if (*Game::svs_numclients <= num)
{
Logger::Print("Player %d is not on the server\n", num);
return;
}
Game::client_t* client = &Game::svs_clients[num];
// TODO: Write player info into a ban database
SV_KickClientError(client, reason);
}
Bans::Bans()
{
Command::Add("banclient", [] (Command::Params params)
{
if (params.Length() < 2) return;
std::string reason = "EXE_ERR_BANNED_PERM";
if (params.Length() >= 3) reason = params[2];
Bans::BanClientNum(atoi(params[1]), reason);
});
}
Bans::~Bans()
{
}
}

View File

@ -0,0 +1,15 @@
namespace Components
{
class Bans : public Component
{
public:
Bans();
~Bans();
#ifdef DEBUG
const char* GetName() { return "Bans"; };
#endif
static void BanClientNum(int num, std::string reason);
};
}

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
Colors(); Colors();
~Colors(); ~Colors();
#ifdef DEBUG
const char* GetName() { return "Colors"; }; const char* GetName() { return "Colors"; };
#endif
static void Strip(const char* in, char* out, int max); static void Strip(const char* in, char* out, int max);
static std::string Strip(std::string in); static std::string Strip(std::string in);

View File

@ -25,7 +25,10 @@ namespace Components
Command(); Command();
~Command(); ~Command();
#ifdef DEBUG
const char* GetName() { return "Command"; }; const char* GetName() { return "Command"; };
#endif
static void Add(const char* name, Callback* callback); static void Add(const char* name, Callback* callback);
static void AddSV(const char* name, Callback* callback); static void AddSV(const char* name, Callback* callback);

View File

@ -4,7 +4,10 @@ namespace Components
{ {
public: public:
ConnectProtocol(); ConnectProtocol();
#ifdef DEBUG
const char* GetName() { return "ConnectProtocol"; }; const char* GetName() { return "ConnectProtocol"; };
#endif
static bool Evaluated(); static bool Evaluated();
static bool Used(); static bool Used();

View File

@ -8,7 +8,10 @@ namespace Components
public: public:
Console(); Console();
~Console(); ~Console();
#ifdef DEBUG
const char* GetName() { return "Console"; }; const char* GetName() { return "Console"; };
#endif
private: private:
static void ToggleConsole(); static void ToggleConsole();

View File

@ -4,7 +4,10 @@ namespace Components
{ {
public: public:
D3D9Ex(); D3D9Ex();
#ifdef DEBUG
const char* GetName() { return "D3D9Ex"; }; const char* GetName() { return "D3D9Ex"; };
#endif
private: private:

View File

@ -7,7 +7,10 @@ namespace Components
Dedicated(); Dedicated();
~Dedicated(); ~Dedicated();
#ifdef DEBUG
const char* GetName() { return "Dedicated"; }; const char* GetName() { return "Dedicated"; };
#endif
static bool IsEnabled(); static bool IsEnabled();

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
Discovery(); Discovery();
~Discovery(); ~Discovery();
#ifdef DEBUG
const char* GetName() { return "Discovery"; }; const char* GetName() { return "Discovery"; };
#endif
static void Perform(); static void Perform();

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
Download(); Download();
~Download(); ~Download();
#ifdef DEBUG
const char* GetName() { return "Download"; }; const char* GetName() { return "Download"; };
#endif
private: private:
static mg_mgr Mgr; static mg_mgr Mgr;

View File

@ -41,7 +41,10 @@ namespace Components
Dvar(); Dvar();
~Dvar(); ~Dvar();
#ifdef DEBUG
const char* GetName() { return "Dvar"; }; const char* GetName() { return "Dvar"; };
#endif
static void OnInit(Callback* callback); static void OnInit(Callback* callback);

View File

@ -6,7 +6,10 @@ namespace Components
{ {
public: public:
Exception(); Exception();
#ifdef DEBUG
const char* GetName() { return "Exception"; }; const char* GetName() { return "Exception"; };
#endif
private: private:
static LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS ExceptionInfo); static LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS ExceptionInfo);

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
FastFiles(); FastFiles();
~FastFiles(); ~FastFiles();
#ifdef DEBUG
const char* GetName() { return "FastFiles"; }; const char* GetName() { return "FastFiles"; };
#endif
static void AddZonePath(std::string path); static void AddZonePath(std::string path);
static std::string Current(); static std::string Current();

View File

@ -38,7 +38,10 @@ namespace Components
}; };
FileSystem(); FileSystem();
#ifdef DEBUG
const char* GetName() { return "FileSystem"; }; const char* GetName() { return "FileSystem"; };
#endif
static std::vector<std::string> GetFileList(std::string path, std::string extension); static std::vector<std::string> GetFileList(std::string path, std::string extension);
static std::vector<std::string> GetSysFileList(std::string path, std::string extension, bool folders = false); static std::vector<std::string> GetSysFileList(std::string path, std::string extension, bool folders = false);

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
Flags(); Flags();
~Flags(); ~Flags();
#ifdef DEBUG
const char* GetName() { return "Flags"; }; const char* GetName() { return "Flags"; };
#endif
static bool HasFlag(std::string flag); static bool HasFlag(std::string flag);

View File

@ -62,7 +62,10 @@ namespace Components
public: public:
IPCPipe(); IPCPipe();
~IPCPipe(); ~IPCPipe();
#ifdef DEBUG
const char* GetName() { return "IPCPipe"; }; const char* GetName() { return "IPCPipe"; };
#endif
static bool Write(std::string command, std::string data); static bool Write(std::string command, std::string data);
static void On(std::string command, Pipe::PacketCallback callback); static void On(std::string command, Pipe::PacketCallback callback);

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
Localization(); Localization();
~Localization(); ~Localization();
#ifdef DEBUG
const char* GetName() { return "Localization"; }; const char* GetName() { return "Localization"; };
#endif
static void Set(std::string key, std::string value); static void Set(std::string key, std::string value);
static const char* Get(const char* key); static const char* Get(const char* key);

View File

@ -5,8 +5,10 @@ namespace Components
public: public:
Logger(); Logger();
~Logger(); ~Logger();
const char* GetName() { return "Logger"; };
#ifdef DEBUG
const char* GetName() { return "Logger"; };
#endif
static void MessagePrint(int channel, std::string message); static void MessagePrint(int channel, std::string message);
static void Print(int channel, const char* message, ...); static void Print(int channel, const char* message, ...);

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
Maps(); Maps();
~Maps(); ~Maps();
#ifdef DEBUG
const char* GetName() { return "Maps"; }; const char* GetName() { return "Maps"; };
#endif
static void AddDependency(std::string expression, std::string zone); static void AddDependency(std::string expression, std::string zone);

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
Materials(); Materials();
~Materials(); ~Materials();
#ifdef DEBUG
const char* GetName() { return "Materials"; }; const char* GetName() { return "Materials"; };
#endif
private: private:
static Utils::Hook ImageVersionCheckHook; static Utils::Hook ImageVersionCheckHook;

View File

@ -8,7 +8,10 @@ namespace Components
public: public:
Menus(); Menus();
~Menus(); ~Menus();
#ifdef DEBUG
const char* GetName() { return "Menus"; }; const char* GetName() { return "Menus"; };
#endif
static void FreeEverything(); static void FreeEverything();

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
ModList(); ModList();
~ModList(); ~ModList();
#ifdef DEBUG
const char* GetName() { return "ModList"; }; const char* GetName() { return "ModList"; };
#endif
static void RunMod(std::string mod); static void RunMod(std::string mod);

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
MusicalTalent(); MusicalTalent();
~MusicalTalent(); ~MusicalTalent();
#ifdef DEBUG
const char* GetName() { return "MusicalTalent"; }; const char* GetName() { return "MusicalTalent"; };
#endif
static void Replace(std::string sound, const char* file); static void Replace(std::string sound, const char* file);

View File

@ -55,7 +55,10 @@ namespace Components
Network(); Network();
~Network(); ~Network();
#ifdef DEBUG
const char* GetName() { return "Network"; }; const char* GetName() { return "Network"; };
#endif
static void Handle(std::string packet, Callback* callback); static void Handle(std::string packet, Callback* callback);
static void OnStart(CallbackRaw* callback); static void OnStart(CallbackRaw* callback);

View File

@ -5,7 +5,11 @@ namespace Components
public: public:
News(); News();
~News(); ~News();
#ifdef DEBUG
const char* GetName() { return "News"; }; const char* GetName() { return "News"; };
#endif
bool UnitTest(); bool UnitTest();
private: private:

View File

@ -16,7 +16,11 @@ namespace Components
public: public:
Node(); Node();
~Node(); ~Node();
#ifdef DEBUG
const char* GetName() { return "Node"; }; const char* GetName() { return "Node"; };
#endif
bool UnitTest(); bool UnitTest();
static void SyncNodeList(); static void SyncNodeList();

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
Party(); Party();
~Party(); ~Party();
#ifdef DEBUG
const char* GetName() { return "Party"; }; const char* GetName() { return "Party"; };
#endif
static Network::Address Target(); static Network::Address Target();
static void Connect(Network::Address target); static void Connect(Network::Address target);

View File

@ -7,7 +7,10 @@ namespace Components
Playlist(); Playlist();
~Playlist(); ~Playlist();
#ifdef DEBUG
const char* GetName() { return "Playlist"; }; const char* GetName() { return "Playlist"; };
#endif
static void LoadPlaylist(); static void LoadPlaylist();

View File

@ -7,7 +7,10 @@ namespace Components
QuickPatch(); QuickPatch();
~QuickPatch(); ~QuickPatch();
#ifdef DEBUG
const char* GetName() { return "QuickPatch"; }; const char* GetName() { return "QuickPatch"; };
#endif
static void UnlockStats(); static void UnlockStats();
static void OnShutdown(Callback* callback); static void OnShutdown(Callback* callback);

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
RCon(); RCon();
~RCon(); ~RCon();
#ifdef DEBUG
const char* GetName() { return "RCon"; }; const char* GetName() { return "RCon"; };
#endif
private: private:
class Container class Container

View File

@ -4,7 +4,10 @@ namespace Components
{ {
public: public:
RawFiles(); RawFiles();
#ifdef DEBUG
const char* GetName() { return "RawFiles"; }; const char* GetName() { return "RawFiles"; };
#endif
static void* RawFiles::LoadModdableRawfileFunc(const char* filename); static void* RawFiles::LoadModdableRawfileFunc(const char* filename);
}; };

View File

@ -8,7 +8,10 @@ namespace Components
Renderer(); Renderer();
~Renderer(); ~Renderer();
#ifdef DEBUG
const char* GetName() { return "Renderer"; }; const char* GetName() { return "Renderer"; };
#endif
static int Width(); static int Width();
static int Height(); static int Height();

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
Script(); Script();
~Script(); ~Script();
#ifdef DEBUG
const char* GetName() { return "Script"; }; const char* GetName() { return "Script"; };
#endif
static int LoadScriptAndLabel(std::string script, std::string label); static int LoadScriptAndLabel(std::string script, std::string label);

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
ServerInfo(); ServerInfo();
~ServerInfo(); ~ServerInfo();
#ifdef DEBUG
const char* GetName() { return "ServerInfo"; }; const char* GetName() { return "ServerInfo"; };
#endif
static Utils::InfoString GetInfo(); static Utils::InfoString GetInfo();

View File

@ -26,7 +26,10 @@ namespace Components
ServerList(); ServerList();
~ServerList(); ~ServerList();
#ifdef DEBUG
const char* GetName() { return "ServerList"; }; const char* GetName() { return "ServerList"; };
#endif
static void Refresh(); static void Refresh();
static void RefreshVisibleList(); static void RefreshVisibleList();

View File

@ -4,7 +4,10 @@ namespace Components
{ {
public: public:
Singleton(); Singleton();
#ifdef DEBUG
const char* GetName() { return "Singleton"; }; const char* GetName() { return "Singleton"; };
#endif
static bool IsFirstInstance(); static bool IsFirstInstance();

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
StringTable(); StringTable();
~StringTable(); ~StringTable();
#ifdef DEBUG
const char* GetName() { return "StringTable"; }; const char* GetName() { return "StringTable"; };
#endif
private: private:
static Utils::Memory::Allocator MemAllocator; static Utils::Memory::Allocator MemAllocator;

View File

@ -23,7 +23,10 @@ namespace Components
StructuredData(); StructuredData();
~StructuredData(); ~StructuredData();
#ifdef DEBUG
const char* GetName() { return "StructuredData"; }; const char* GetName() { return "StructuredData"; };
#endif
private: private:
static void PatchPlayerDataEnum(Game::StructuredDataDef* data, PlayerDataType type, std::vector<std::string>& entries); static void PatchPlayerDataEnum(Game::StructuredDataDef* data, PlayerDataType type, std::vector<std::string>& entries);

View File

@ -4,7 +4,10 @@ namespace Components
{ {
public: public:
Theatre(); Theatre();
#ifdef DEBUG
const char* GetName() { return "Theatre"; }; const char* GetName() { return "Theatre"; };
#endif
private: private:
class Container class Container

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
Toast(); Toast();
~Toast(); ~Toast();
#ifdef DEBUG
const char* GetName() { return "Toast"; }; const char* GetName() { return "Toast"; };
#endif
static void Show(std::string image, std::string title, std::string description, int length); static void Show(std::string image, std::string title, std::string description, int length);

View File

@ -16,7 +16,10 @@ namespace Components
UIFeeder(); UIFeeder();
~UIFeeder(); ~UIFeeder();
#ifdef DEBUG
const char* GetName() { return "UIFeeder"; }; const char* GetName() { return "UIFeeder"; };
#endif
static void Add(float feeder, GetItemCount_t itemCountCb, GetItemText_t itemTextCb, Select_t selectCb); static void Add(float feeder, GetItemCount_t itemCountCb, GetItemText_t itemTextCb, Select_t selectCb);

View File

@ -5,7 +5,10 @@ namespace Components
public: public:
UIScript(); UIScript();
~UIScript(); ~UIScript();
#ifdef DEBUG
const char* GetName() { return "UIScript"; }; const char* GetName() { return "UIScript"; };
#endif
class Token class Token
{ {

View File

@ -4,7 +4,10 @@ namespace Components
{ {
public: public:
Weapon(); Weapon();
#ifdef DEBUG
const char* GetName() { return "Weapon"; }; const char* GetName() { return "Weapon"; };
#endif
private: private:
static Game::XAssetHeader WeaponFileLoad(Game::XAssetType type, std::string filename); static Game::XAssetHeader WeaponFileLoad(Game::XAssetType type, std::string filename);

View File

@ -4,7 +4,10 @@ namespace Components
{ {
public: public:
Window(); Window();
#ifdef DEBUG
const char* GetName() { return "Window"; }; const char* GetName() { return "Window"; };
#endif
static int Width(); static int Width();
static int Height(); static int Height();

View File

@ -72,7 +72,10 @@ namespace Components
}; };
ZoneBuilder(); ZoneBuilder();
#ifdef DEBUG
const char* GetName() { return "ZoneBuilder"; }; const char* GetName() { return "ZoneBuilder"; };
#endif
static bool IsEnabled(); static bool IsEnabled();