From c4fed4ce9d32100628f2ce288f8daa28b997e7f7 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Fri, 30 Dec 2022 13:57:46 +0100 Subject: [PATCH] maint(test_clients): fix some code --- src/game/dvars.cpp | 17 +++++++++++++++++ src/game/dvars.hpp | 10 ++++++++++ src/game/game.cpp | 3 +++ src/module/patches.cpp | 6 ++++++ src/module/test_clients.cpp | 5 +++-- 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/game/dvars.cpp create mode 100644 src/game/dvars.hpp diff --git a/src/game/dvars.cpp b/src/game/dvars.cpp new file mode 100644 index 0000000..3d35623 --- /dev/null +++ b/src/game/dvars.cpp @@ -0,0 +1,17 @@ +#include +#include "game.hpp" +#include "dvars.hpp" + +namespace dvars +{ + const game::native::dvar_t** com_sv_running; + + const game::native::dvar_t** sv_maxclients; + + void initialize() + { + com_sv_running = reinterpret_cast(SELECT_VALUE(0x1769F50, 0x1CEF588)); + + sv_maxclients = reinterpret_cast(SELECT_VALUE(0x0, 0x21223C0)); + } +} diff --git a/src/game/dvars.hpp b/src/game/dvars.hpp new file mode 100644 index 0000000..4cc5a94 --- /dev/null +++ b/src/game/dvars.hpp @@ -0,0 +1,10 @@ +#pragma once + +namespace dvars +{ + extern const game::native::dvar_t** com_sv_running; + + extern const game::native::dvar_t** sv_maxclients; + + void initialize(); +} diff --git a/src/game/game.cpp b/src/game/game.cpp index 2d469b7..3390526 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -1,5 +1,6 @@ #include #include "game.hpp" +#include "dvars.hpp" namespace game { @@ -685,6 +686,8 @@ namespace game { mode = _mode; + dvars::initialize(); + native::Cmd_AddCommand = native::Cmd_AddCommand_t(SELECT_VALUE(0x558820, 0x545DF0)); native::Cmd_RemoveCommand = native::Cmd_RemoveCommand_t(SELECT_VALUE(0x443A30, 0x545E20)); diff --git a/src/module/patches.cpp b/src/module/patches.cpp index 633c94f..47a672f 100644 --- a/src/module/patches.cpp +++ b/src/module/patches.cpp @@ -41,6 +41,9 @@ private: utils::hook::set(0x4296F9, game::native::DVAR_ARCHIVE); utils::hook(0x44C640, &live_get_local_client_name_stub, HOOK_JUMP).install()->quick(); + + // Some whitelist + utils::hook::nop(0x605F3C, 2); } void patch_mp() const @@ -59,6 +62,9 @@ private: // Allow any IWD file to be loaded utils::hook::nop(0x5B090F, 6); utils::hook::nop(0x5B092C, 6); + + // Some whitelist + utils::hook::nop(0x54641D, 2); } void patch_dedi() const diff --git a/src/module/test_clients.cpp b/src/module/test_clients.cpp index 3383095..788052d 100644 --- a/src/module/test_clients.cpp +++ b/src/module/test_clients.cpp @@ -1,6 +1,7 @@ #include #include #include "game/game.hpp" +#include "game/dvars.hpp" #include #include @@ -34,8 +35,8 @@ game::native::gentity_s* test_clients::sv_add_test_client() return nullptr; } - assert(game::native::Dvar_FindVar("sv_running")->current.enabled); - assert(game::native::Dvar_FindVar("sv_maxclients")->current.integer <= *game::native::svs_clientCount); + assert((*dvars::com_sv_running)->current.enabled); + assert((*dvars::sv_maxclients)->current.integer <= *game::native::svs_clientCount); static auto bot_port = 0; char user_info[1024] = {0};