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 Auth());
Loader::Register(new Bans());
Loader::Register(new Dvar());
Loader::Register(new Maps());
Loader::Register(new News());

View File

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

View File

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

View File

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

View File

@ -5,7 +5,11 @@ namespace Components
public:
Auth();
~Auth();
const char* GetName() { return "Auth"; };
#ifdef DEBUG
const char* GetName() { return "Auth"; };
#endif
bool UnitTest();
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

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

View File

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

View File

@ -3,8 +3,11 @@ namespace Components
class ConnectProtocol : public Component
{
public:
ConnectProtocol();
ConnectProtocol();
#ifdef DEBUG
const char* GetName() { return "ConnectProtocol"; };
#endif
static bool Evaluated();
static bool Used();

View File

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

View File

@ -3,8 +3,11 @@ namespace Components
class D3D9Ex : public Component
{
public:
D3D9Ex();
D3D9Ex();
#ifdef DEBUG
const char* GetName() { return "D3D9Ex"; };
#endif
private:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -37,8 +37,11 @@ namespace Components
void Close();
};
FileSystem();
FileSystem();
#ifdef DEBUG
const char* GetName() { return "FileSystem"; };
#endif
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);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,8 +6,11 @@ namespace Components
typedef void(*Callback)();
Playlist();
~Playlist();
~Playlist();
#ifdef DEBUG
const char* GetName() { return "Playlist"; };
#endif
static void LoadPlaylist();

View File

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

View File

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

View File

@ -3,8 +3,11 @@ namespace Components
class RawFiles : public Component
{
public:
RawFiles();
RawFiles();
#ifdef DEBUG
const char* GetName() { return "RawFiles"; };
#endif
static void* RawFiles::LoadModdableRawfileFunc(const char* filename);
};

View File

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

View File

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

View File

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

View File

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

View File

@ -3,8 +3,11 @@ namespace Components
class Singleton : public Component
{
public:
Singleton();
Singleton();
#ifdef DEBUG
const char* GetName() { return "Singleton"; };
#endif
static bool IsFirstInstance();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,8 +3,11 @@ namespace Components
class Window : public Component
{
public:
Window();
Window();
#ifdef DEBUG
const char* GetName() { return "Window"; };
#endif
static int Width();
static int Height();

View File

@ -71,8 +71,11 @@ namespace Components
Game::RawFile Branding;
};
ZoneBuilder();
ZoneBuilder();
#ifdef DEBUG
const char* GetName() { return "ZoneBuilder"; };
#endif
static bool IsEnabled();