Fixed a hack into a better hack, but it should still be removed when we have a chance to

This commit is contained in:
Louvenarde 2023-07-25 12:51:16 +02:00
parent 99cf31514a
commit bbe9c2c1eb
3 changed files with 11 additions and 1 deletions

View File

@ -1213,15 +1213,20 @@ namespace Components
Utils::Hook::Set<DWORD>(0x64A057, 0x38400000); Utils::Hook::Set<DWORD>(0x64A057, 0x38400000);
// change FS_GameDirDomainFunc // 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<int(*)(Game::dvar_t*, Game::DvarValue)>(0x643203, [](Game::dvar_t* dvar, Game::DvarValue value) Utils::Hook::Set<int(*)(Game::dvar_t*, Game::DvarValue)>(0x643203, [](Game::dvar_t* dvar, Game::DvarValue value)
{ {
// Call original FS_GameDirDomainFunc
int result = Utils::Hook::Call<int(Game::dvar_t*, Game::DvarValue)>(0x642FC0)(dvar, value); int result = Utils::Hook::Call<int(Game::dvar_t*, Game::DvarValue)>(0x642FC0)(dvar, value);
if (result) if (result)
{ {
if (std::strcmp(value.string, dvar->current.string) != 0) 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); Game::FS_Restart(0, 0);
} }
} }

View File

@ -10,6 +10,8 @@ namespace Game
Cbuf_InsertText_t Cbuf_InsertText = Cbuf_InsertText_t(0x4940B0); Cbuf_InsertText_t Cbuf_InsertText = Cbuf_InsertText_t(0x4940B0);
Cbuf_Execute_t Cbuf_Execute = Cbuf_Execute_t(0x4E2C80); 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_DrawDisconnect_t CG_DrawDisconnect = CG_DrawDisconnect_t(0x454A70);
CG_NextWeapon_f_t CG_NextWeapon_f = CG_NextWeapon_f_t(0x449DE0); CG_NextWeapon_f_t CG_NextWeapon_f = CG_NextWeapon_f_t(0x449DE0);
CG_GetClientNum_t CG_GetClientNum = CG_GetClientNum_t(0x433700); CG_GetClientNum_t CG_GetClientNum = CG_GetClientNum_t(0x433700);

View File

@ -18,6 +18,9 @@ namespace Game
typedef void(*Cbuf_Execute_t)(int localClientNum, int controllerIndex); typedef void(*Cbuf_Execute_t)(int localClientNum, int controllerIndex);
extern Cbuf_Execute_t Cbuf_Execute; 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); typedef void(*CG_DrawDisconnect_t)(int localClientNum);
extern CG_DrawDisconnect_t CG_DrawDisconnect; extern CG_DrawDisconnect_t CG_DrawDisconnect;