Cleanup say and tell commands

This commit is contained in:
Maurice Heumann 2023-03-22 18:43:47 +01:00
parent 9f1bea45d4
commit b8751df584
2 changed files with 18 additions and 15 deletions

View File

@ -81,7 +81,8 @@ namespace chat
client_command::add("chat", cmd_chat_f); client_command::add("chat", cmd_chat_f);
command::add("say", [](const command::params& params) // Overwrite say command
utils::hook::jump(0x14052A6C0_g, +[]
{ {
if (!game::get_dvar_bool("sv_running")) if (!game::get_dvar_bool("sv_running"))
{ {
@ -89,13 +90,17 @@ namespace chat
return; return;
} }
const command::params params{};
const auto text = params.join(1); const auto text = params.join(1);
const auto* format = reinterpret_cast<const char*>(0x140E25180_g); const auto* format = reinterpret_cast<const char*>(0x140E25180_g);
const auto* message = utils::string::va(format, 'O', text.data()); const auto* message = utils::string::va(format, 'O', text.data());
reinterpret_cast<void(*)(int64_t, uint64_t, const char*)>(0x140532CA0_g)(-1, 0, message);
game::SV_GameSendServerCommand(-1, game::SV_CMD_CAN_IGNORE_0, message);
}); });
command::add("tell", [](const command::params& params) // Overwrite tell command
utils::hook::jump(0x14052A7E0_g, +[]
{ {
if (!game::get_dvar_bool("sv_running")) if (!game::get_dvar_bool("sv_running"))
{ {
@ -103,26 +108,23 @@ namespace chat
return; return;
} }
const command::params params{};
if (params.size() < 2) if (params.size() < 2)
{ {
return; return;
} }
const auto client = atoi(params[1]); const auto client = atoi(params[1]);
const auto text = params.join(2); const auto text = params.join(2);
const auto* format = reinterpret_cast<const char*>(0x140E25180_g); const auto* format = reinterpret_cast<const char*>(0x140E25180_g);
const auto* message = utils::string::va(format, 'O', text.data()); const auto* message = utils::string::va(format, 'O', text.data());
reinterpret_cast<void(*)(int64_t, uint64_t, const char*)>(0x140532CA0_g)(client, 0, message);
game::SV_GameSendServerCommand(client, game::SV_CMD_CAN_IGNORE_0, message);
}); });
// Kill say and tell commands // Kill say fallback
utils::hook::nop(0x1405299FB_g, 5); utils::hook::set<uint8_t>(0x1402FF987_g, 0xEB);
utils::hook::nop(0x140529A21_g, 5);
utils::hook::nop(0x140529A3B_g, 5);
utils::hook::nop(0x140529A07_g, 5);
utils::hook::nop(0x140529A55_g, 5);
utils::hook::nop(0x140529A6F_g, 5);
} }
else else
{ {

View File

@ -133,7 +133,7 @@ namespace game
WEAK symbol<void()> UI_CoD_Shutdown{0x141F32E10, 0x0}; WEAK symbol<void()> UI_CoD_Shutdown{0x141F32E10, 0x0};
WEAK symbol<void(const char*, const char*, int, game::hks::lua_State*)> UI_AddMenu{0x1427018F0, 0x0}; WEAK symbol<void(const char*, const char*, int, game::hks::lua_State*)> UI_AddMenu{0x1427018F0, 0x0};
WEAK symbol<const char*(int)> UI_CoD_GetRootNameForController{0x141F28940, 0x0}; WEAK symbol<const char*(int)> UI_CoD_GetRootNameForController{0x141F28940, 0x0};
WEAK symbol<void(game::hks::lua_State*, const char*)> Lua_CoD_LoadLuaFile{0x141F11A20, 0x0}; WEAK symbol<void(hks::lua_State*, const char*)> Lua_CoD_LoadLuaFile{0x141F11A20, 0x0};
WEAK symbol<void(int localClientNum)> CG_LUIHUDRestart{0x140F7E970}; WEAK symbol<void(int localClientNum)> CG_LUIHUDRestart{0x140F7E970};
WEAK symbol<void(int localClientNum)> CL_CheckKeepDrawingConnectScreen{0x1413CCAE0}; WEAK symbol<void(int localClientNum)> CL_CheckKeepDrawingConnectScreen{0x1413CCAE0};
@ -159,6 +159,7 @@ namespace game
// SV // SV
WEAK symbol<bool()> SV_Loaded{0x142252250, 0x140535460}; WEAK symbol<bool()> SV_Loaded{0x142252250, 0x140535460};
WEAK symbol<void*()> SV_AddTestClient{0x142248F40, 0x14052E3E0}; WEAK symbol<void*()> SV_AddTestClient{0x142248F40, 0x14052E3E0};
WEAK symbol<void(int clientNum, svscmd_type type, const char* text)> SV_GameSendServerCommand{0x0, 0x140532CA0};
WEAK symbol<void(client_s* cl_0, svscmd_type type, const char* fmt, ...)> SV_SendServerCommand{0x0, 0x140537F10}; WEAK symbol<void(client_s* cl_0, svscmd_type type, const char* fmt, ...)> SV_SendServerCommand{0x0, 0x140537F10};
WEAK symbol<bool(int clientNum)> SV_IsTestClient{0x14224AB60, 0x14052FF40}; WEAK symbol<bool(int clientNum)> SV_IsTestClient{0x14224AB60, 0x14052FF40};
WEAK symbol<void(int controllerIndex, const char* server, MapPreload preload, bool savegame)> SV_SpawnServer{ WEAK symbol<void(int controllerIndex, const char* server, MapPreload preload, bool savegame)> SV_SpawnServer{