[Bots] Added helper functions

This commit is contained in:
INeedBots 2020-11-14 02:58:05 -06:00
parent b92ee0880e
commit 992a23d713
2 changed files with 25 additions and 0 deletions

View File

@ -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()

View File

@ -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<std::string> 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();
};
}