From c3386b52583648a52be436a04fe6751f14dfbcf6 Mon Sep 17 00:00:00 2001 From: Lierrmm Date: Mon, 27 Feb 2023 11:32:29 +0000 Subject: [PATCH] feat: add is_host check to getinfo --- src/client/component/bots.cpp | 9 +++------ src/client/component/getinfo.cpp | 16 ++++++++++++++++ src/client/component/getinfo.hpp | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/client/component/bots.cpp b/src/client/component/bots.cpp index 43f2a6e7..23ca2bc5 100644 --- a/src/client/component/bots.cpp +++ b/src/client/component/bots.cpp @@ -8,6 +8,7 @@ #include #include +#include "getinfo.hpp" namespace bots { @@ -126,13 +127,9 @@ namespace bots command::add("spawnBot", [](const command::params& params) { - if (!game::is_server()) + if (!getinfo::is_host()) { - const auto client_states = *reinterpret_cast(0x1576FB318_g); - if (!client_states) - { - return; - } + return; } size_t count = 1; diff --git a/src/client/component/getinfo.cpp b/src/client/component/getinfo.cpp index 0a8d92fb..fbbaebce 100644 --- a/src/client/component/getinfo.cpp +++ b/src/client/component/getinfo.cpp @@ -78,6 +78,22 @@ namespace getinfo return (rand() % 2) + 1; } + bool is_host() + { + if (game::is_server()) + { + return true; + } + + const auto client_states = *reinterpret_cast(0x1576FB318_g); + if (!client_states) + { + return false; + } + + return true; + } + struct component final : generic_component { void post_unpack() override diff --git a/src/client/component/getinfo.hpp b/src/client/component/getinfo.hpp index 7d016ffa..5d9d14be 100644 --- a/src/client/component/getinfo.hpp +++ b/src/client/component/getinfo.hpp @@ -5,4 +5,5 @@ namespace getinfo int get_max_client_count(); int get_client_count(); int get_bot_count(); + bool is_host(); }