[Bots]: sv_replaceTestClients dvar (#930)
This commit is contained in:
parent
d53fc404b2
commit
c9b1566e38
@ -4,6 +4,7 @@
|
|||||||
#include <proto/auth.pb.h>
|
#include <proto/auth.pb.h>
|
||||||
|
|
||||||
#include "Bans.hpp"
|
#include "Bans.hpp"
|
||||||
|
#include "Bots.hpp"
|
||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
@ -270,6 +271,9 @@ namespace Components
|
|||||||
|
|
||||||
HasAccessToReservedSlot = std::strcmp((*Game::sv_privatePassword)->current.string, value) == 0;
|
HasAccessToReservedSlot = std::strcmp((*Game::sv_privatePassword)->current.string, value) == 0;
|
||||||
|
|
||||||
|
// This stubs runs right before the 'server is full check' so we can call this here
|
||||||
|
Bots::SV_DirectConnect_Full_Check();
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,8 @@ namespace Components
|
|||||||
|
|
||||||
std::vector<Bots::botData> Bots::BotNames;
|
std::vector<Bots::botData> Bots::BotNames;
|
||||||
|
|
||||||
Dvar::Var Bots::SVRandomBotNames;
|
const Game::dvar_t* Bots::sv_randomBotNames;
|
||||||
|
const Game::dvar_t* Bots::sv_replaceBots;
|
||||||
|
|
||||||
struct BotMovementInfo
|
struct BotMovementInfo
|
||||||
{
|
{
|
||||||
@ -113,7 +114,7 @@ namespace Components
|
|||||||
BotNames.emplace_back(entry, clanAbbrev);
|
BotNames.emplace_back(entry, clanAbbrev);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SVRandomBotNames.get<bool>())
|
if (sv_randomBotNames->current.enabled)
|
||||||
{
|
{
|
||||||
RandomizeBotNames();
|
RandomizeBotNames();
|
||||||
}
|
}
|
||||||
@ -378,6 +379,24 @@ namespace Components
|
|||||||
return Game::svs_clients[clientNum].ping;
|
return Game::svs_clients[clientNum].ping;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bots::SV_DirectConnect_Full_Check()
|
||||||
|
{
|
||||||
|
if (!sv_replaceBots->current.enabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto i = 0; i < (*Game::sv_maxclients)->current.integer; ++i)
|
||||||
|
{
|
||||||
|
auto* cl = &Game::svs_clients[i];
|
||||||
|
if (cl->bIsTestClient)
|
||||||
|
{
|
||||||
|
Game::SV_DropClient(cl, "EXE_DISCONNECTED", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Bots::Bots()
|
Bots::Bots()
|
||||||
{
|
{
|
||||||
AssertOffset(Game::client_t, bIsTestClient, 0x41AF0);
|
AssertOffset(Game::client_t, bIsTestClient, 0x41AF0);
|
||||||
@ -397,7 +416,8 @@ namespace Components
|
|||||||
|
|
||||||
Utils::Hook(0x459654, SV_GetClientPing_Hk, HOOK_CALL).install()->quick();
|
Utils::Hook(0x459654, SV_GetClientPing_Hk, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
SVRandomBotNames = Dvar::Register<bool>("sv_randomBotNames", false, Game::DVAR_NONE, "Randomize the bots' names");
|
sv_randomBotNames = Game::Dvar_RegisterBool("sv_randomBotNames", false, Game::DVAR_NONE, "Randomize the bots' names");
|
||||||
|
sv_replaceBots = Game::Dvar_RegisterBool("sv_replaceBots", false, Game::DVAR_NONE, "Test clients will be replaced by connecting players when the server is full.");
|
||||||
|
|
||||||
// Reset BotMovementInfo.active when client is dropped
|
// Reset BotMovementInfo.active when client is dropped
|
||||||
Events::OnClientDisconnect([](const int clientNum) -> void
|
Events::OnClientDisconnect([](const int clientNum) -> void
|
||||||
|
@ -7,11 +7,14 @@ namespace Components
|
|||||||
public:
|
public:
|
||||||
Bots();
|
Bots();
|
||||||
|
|
||||||
|
static void SV_DirectConnect_Full_Check();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using botData = std::pair< std::string, std::string>;
|
using botData = std::pair< std::string, std::string>;
|
||||||
static std::vector<botData> BotNames;
|
static std::vector<botData> BotNames;
|
||||||
|
|
||||||
static Dvar::Var SVRandomBotNames;
|
static const Game::dvar_t* sv_randomBotNames;
|
||||||
|
static const Game::dvar_t* sv_replaceBots;
|
||||||
|
|
||||||
static void RandomizeBotNames();
|
static void RandomizeBotNames();
|
||||||
static std::string TruncBotString(const std::string& input, std::size_t length);
|
static std::string TruncBotString(const std::string& input, std::size_t length);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user