From 992a23d7134554afe13ee68ccda28ca80394b27c Mon Sep 17 00:00:00 2001 From: INeedBots Date: Sat, 14 Nov 2020 02:58:05 -0600 Subject: [PATCH] [Bots] Added helper functions --- src/Components/Modules/Bots.cpp | 21 +++++++++++++++++++++ src/Components/Modules/Bots.hpp | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index 20d6f18c..824f8235 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -69,6 +69,20 @@ namespace Components { "9", 33554432 }, }; + unsigned int Bots::GetClientNum(Game::client_s* cl) + { + unsigned int num; + + num = ((byte*)cl - (byte*)Game::svs_clients) / sizeof(Game::client_s); + + return num; + } + + bool Bots::IsValidClientNum(unsigned int cNum) + { + return (cNum >= 0) && (cNum < sizeof(g_botai) / sizeof(BotMovementInfo_t)); + } + void Bots::BuildConnectString(char* buffer, const char* connectString, int num, int, int protocol, int checksum, int statVer, int statStuff, int port) { static int botId = 0; @@ -135,6 +149,11 @@ namespace Components } } + void Bots::AddMethods() + { + + } + Bots::Bots() { // Replace connect string @@ -172,6 +191,8 @@ namespace Components Bots::Spawn(count); }); + + Bots::AddMethods(); } Bots::~Bots() diff --git a/src/Components/Modules/Bots.hpp b/src/Components/Modules/Bots.hpp index d79f51e2..ee8381aa 100644 --- a/src/Components/Modules/Bots.hpp +++ b/src/Components/Modules/Bots.hpp @@ -7,6 +7,8 @@ namespace Components public: Bots(); ~Bots(); + static unsigned int GetClientNum(Game::client_s*); + static bool IsValidClientNum(unsigned int); private: static std::vector BotNames; @@ -14,5 +16,7 @@ namespace Components static void BuildConnectString(char* buffer, const char* connectString, int num, int, int protocol, int checksum, int statVer, int statStuff, int port); static void Spawn(unsigned int count); + + static void AddMethods(); }; }