From 73f1f752fd58c84c98c7a47c61ea614838b23a8c Mon Sep 17 00:00:00 2001 From: Edo Date: Sat, 18 Mar 2023 22:43:24 +0000 Subject: [PATCH] [Bots]: Update (#852) --- src/Components/Modules/Bots.cpp | 56 --------------------------------- src/Components/Modules/Bots.hpp | 4 --- 2 files changed, 60 deletions(-) diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index d6e2d2dc..05a57951 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -1,8 +1,6 @@ #include -#include #include "Bots.hpp" -#include "ServerList.hpp" #include "GSC/Script.hpp" @@ -14,8 +12,6 @@ namespace Components { std::vector Bots::BotNames; - Dvar::Var Bots::SVClanName; - struct BotMovementInfo { std::int32_t buttons; // Actions @@ -52,26 +48,6 @@ namespace Components { "activate", Game::CMD_BUTTON_ACTIVATE }, }; - void Bots::RandomizeBotNames() - { - std::random_device rd; - std::mt19937 gen(rd()); - std::ranges::shuffle(BotNames, gen); - } - - void Bots::UpdateBotNames() - { - const auto masterPort = (*Game::com_masterPort)->current.integer; - const auto* masterServerName = (*Game::com_masterServerName)->current.string; - - Game::netadr_t master; - if (ServerList::GetMasterServer(masterServerName, masterPort, master)) - { - Logger::Print("Getting bots...\n"); - Network::Send(master, "getbots"); - } - } - void Bots::LoadBotNames() { FileSystem::File bots("bots.txt"); @@ -111,8 +87,6 @@ namespace Components BotNames.emplace_back(entry, clanAbbrev); } - - RandomizeBotNames(); } int Bots::BuildConnectString(char* buffer, const char* connectString, int num, int, int protocol, int checksum, int statVer, int statStuff, int port) @@ -141,11 +115,6 @@ namespace Components clanName = "BOT"s; } - if (const auto svClanName = SVClanName.get(); !svClanName.empty()) - { - clanName = svClanName; - } - return _snprintf_s(buffer, 0x400, _TRUNCATE, connectString, num, botName.data(), clanName.data(), protocol, checksum, statVer, statStuff, port); } @@ -382,31 +351,6 @@ namespace Components Utils::Hook(0x441B80, G_SelectWeaponIndex_Hk, HOOK_JUMP).install()->quick(); - Events::OnDvarInit([] - { - SVClanName = Dvar::Register("sv_clanName", "", Game::DVAR_NONE, "The clan name for test clients"); - }); - - Scheduler::OnGameInitialized(UpdateBotNames, Scheduler::Pipeline::MAIN); - - Network::OnClientPacket("getbotsResponse", [](const Network::Address& address, const std::string& data) - { - const auto masterPort = (*Game::com_masterPort)->current.integer; - const auto* masterServerName = (*Game::com_masterServerName)->current.string; - - Network::Address master(Utils::String::VA("%s:%u", masterServerName, masterPort)); - if (master == address) - { - auto botNames = Utils::String::Split(data, '\n'); - for (const auto& entry : botNames) - { - BotNames.emplace_back(std::make_pair(entry, "BOT")); - } - - RandomizeBotNames(); - } - }); - // Reset BotMovementInfo.active when client is dropped Events::OnClientDisconnect([](const int clientNum) { diff --git a/src/Components/Modules/Bots.hpp b/src/Components/Modules/Bots.hpp index cc2629bc..2136016f 100644 --- a/src/Components/Modules/Bots.hpp +++ b/src/Components/Modules/Bots.hpp @@ -11,10 +11,6 @@ namespace Components using botData = std::pair< std::string, std::string>; static std::vector BotNames; - static Dvar::Var SVClanName; - - static void RandomizeBotNames(); - static void UpdateBotNames(); static void LoadBotNames(); static int BuildConnectString(char* buffer, const char* connectString, int num, int, int protocol, int checksum, int statVer, int statStuff, int port);