maint(test_clients): fix some code

This commit is contained in:
Diavolo 2022-12-30 13:57:46 +01:00
parent 384b4d9c8a
commit c4fed4ce9d
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
5 changed files with 39 additions and 2 deletions

17
src/game/dvars.cpp Normal file
View File

@ -0,0 +1,17 @@
#include <std_include.hpp>
#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<const game::native::dvar_t**>(SELECT_VALUE(0x1769F50, 0x1CEF588));
sv_maxclients = reinterpret_cast<const game::native::dvar_t**>(SELECT_VALUE(0x0, 0x21223C0));
}
}

10
src/game/dvars.hpp Normal file
View File

@ -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();
}

View File

@ -1,5 +1,6 @@
#include <std_include.hpp>
#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));

View File

@ -41,6 +41,9 @@ private:
utils::hook::set<std::uint8_t>(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

View File

@ -1,6 +1,7 @@
#include <std_include.hpp>
#include <loader/module_loader.hpp>
#include "game/game.hpp"
#include "game/dvars.hpp"
#include <utils/hook.hpp>
#include <utils/string.hpp>
@ -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};