From bbe9c2c1eb188a726c135aefa945551d4c000231 Mon Sep 17 00:00:00 2001 From: Louvenarde Date: Tue, 25 Jul 2023 12:51:16 +0200 Subject: [PATCH] Fixed a hack into a better hack, but it should still be removed when we have a chance to --- src/Components/Modules/ZoneBuilder.cpp | 7 ++++++- src/Game/Functions.cpp | 2 ++ src/Game/Functions.hpp | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index 15bc2932..3bce1cb6 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -1213,15 +1213,20 @@ namespace Components Utils::Hook::Set(0x64A057, 0x38400000); // change FS_GameDirDomainFunc + // NOTE: THIS IS A VERY BAD HACK ⚠ + // The domain func of fs_game should NOT be used to set the value itself! + // Hook should be moved further!! Utils::Hook::Set(0x643203, [](Game::dvar_t* dvar, Game::DvarValue value) { + // Call original FS_GameDirDomainFunc int result = Utils::Hook::Call(0x642FC0)(dvar, value); if (result) { if (std::strcmp(value.string, dvar->current.string) != 0) { - dvar->current.string = value.string; + // CopyStringInternal + dvar->current.string = Game::CopyStringInternal(value.string); Game::FS_Restart(0, 0); } } diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 05b1efca..92048912 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -10,6 +10,8 @@ namespace Game Cbuf_InsertText_t Cbuf_InsertText = Cbuf_InsertText_t(0x4940B0); Cbuf_Execute_t Cbuf_Execute = Cbuf_Execute_t(0x4E2C80); + CopyStringInternal_t CopyStringInternal = CopyStringInternal_t(0x4F3C80); + CG_DrawDisconnect_t CG_DrawDisconnect = CG_DrawDisconnect_t(0x454A70); CG_NextWeapon_f_t CG_NextWeapon_f = CG_NextWeapon_f_t(0x449DE0); CG_GetClientNum_t CG_GetClientNum = CG_GetClientNum_t(0x433700); diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 843bc7f5..090d669c 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -18,6 +18,9 @@ namespace Game typedef void(*Cbuf_Execute_t)(int localClientNum, int controllerIndex); extern Cbuf_Execute_t Cbuf_Execute; + typedef const char* (*CopyStringInternal_t)(const char* str); + extern CopyStringInternal_t CopyStringInternal; + typedef void(*CG_DrawDisconnect_t)(int localClientNum); extern CG_DrawDisconnect_t CG_DrawDisconnect;