Merge pull request #248 from Lierrmm/main

feat: handle addtestclient when not host
This commit is contained in:
Maurice Heumann 2023-02-27 15:07:33 +01:00 committed by GitHub
commit c0f24a89e4
3 changed files with 18 additions and 0 deletions

View File

@ -8,6 +8,7 @@
#include <utils/string.hpp> #include <utils/string.hpp>
#include <game/game.hpp> #include <game/game.hpp>
#include "getinfo.hpp"
namespace bots namespace bots
{ {
@ -126,6 +127,11 @@ namespace bots
command::add("spawnBot", [](const command::params& params) command::add("spawnBot", [](const command::params& params)
{ {
if (!getinfo::is_host())
{
return;
}
size_t count = 1; size_t count = 1;
if (params.size() > 1) if (params.size() > 1)
{ {

View File

@ -78,6 +78,17 @@ namespace getinfo
return (rand() % 2) + 1; return (rand() % 2) + 1;
} }
bool is_host()
{
if (game::is_server())
{
return true;
}
const auto client_states = *reinterpret_cast<uint64_t*>(0x1576FB318_g);
return client_states == 0;
}
struct component final : generic_component struct component final : generic_component
{ {
void post_unpack() override void post_unpack() override

View File

@ -5,4 +5,5 @@ namespace getinfo
int get_max_client_count(); int get_max_client_count();
int get_client_count(); int get_client_count();
int get_bot_count(); int get_bot_count();
bool is_host();
} }