diff --git a/src/client/component/dvar_cheats.cpp b/src/client/component/dvar_cheats.cpp index 2fa74332..384d7667 100644 --- a/src/client/component/dvar_cheats.cpp +++ b/src/client/component/dvar_cheats.cpp @@ -25,7 +25,7 @@ namespace dvar_cheats } // if sv_cheats was enabled and it changes to disabled, we need to reset all cheat dvars - else if (dvar->current.enabled && !value->enabled) + /*else if (dvar->current.enabled && !value->enabled) { for (auto i = 0; i < *game::dvarCount; ++i) { @@ -35,7 +35,7 @@ namespace dvar_cheats game::Dvar_Reset(var, game::DvarSetSource::DVAR_SOURCE_INTERNAL); } } - } + }*/ // resets the r_hudOutline dvars, which are cheat dvars for some reason. } } @@ -61,20 +61,20 @@ namespace dvar_cheats if (source == game::DvarSetSource::DVAR_SOURCE_EXTERNAL) { const auto cl_ingame = game::CL_IsGameClientActive(0); - const auto sv_running = game::Dvar_FindVar("sv_running"); + const auto sv_running = game::SV_Loaded(); - if ((dvar->flags & game::DvarFlags::DVAR_FLAG_REPLICATED) && (cl_ingame) && (sv_running && !sv_running->current.enabled)) + if ((dvar->flags & game::DvarFlags::DVAR_FLAG_REPLICATED) && cl_ingame && !sv_running) { console::error("%s can only be changed by the server\n", dvars::dvar_get_name(dvar).data()); return false; } const auto sv_cheats = game::Dvar_FindVar("sv_cheats"); - if ((dvar->flags & game::DvarFlags::DVAR_FLAG_CHEAT) && (sv_cheats && !sv_cheats->current.enabled)) + if ((dvar->flags & game::DvarFlags::DVAR_FLAG_CHEAT) && ((sv_cheats && !sv_cheats->current.enabled) && *game::isCheatOverride)) { -#ifdef DEBUG +//#ifdef DEBUG console::error("%s is cheat protected\n", dvars::dvar_get_name(dvar).data()); -#endif +//#endif return false; } } diff --git a/src/client/component/patches.cpp b/src/client/component/patches.cpp index 37fb719f..ab717eb6 100644 --- a/src/client/component/patches.cpp +++ b/src/client/component/patches.cpp @@ -208,6 +208,13 @@ namespace patches return game::DB_ReadRawFile(filename, buf, size); } + void cbuf_execute_buffer_internal_stub(int local_client_num, int controller_index, char* buffer, [[maybe_unused]]void* callback) + { + game::Dvar_OverrideCheatProtection(0); + game::Cbuf_ExecuteBufferInternal(local_client_num, controller_index, buffer, game::Cmd_ExecuteSingleCommand); + game::Dvar_OverrideCheatProtection(1); + } + void init_network_dvars_stub(game::dvar_t* dvar) { //init_network_dvars_hook.invoke(dvar); @@ -250,6 +257,8 @@ namespace patches // Allow executing custom cfg files with the "exec" command utils::hook::call(0xB7CEF9_b, db_read_raw_file_stub); + // Add cheat override to exec + utils::hook::call(0xB7CF11_b, cbuf_execute_buffer_internal_stub); // don't reset our fov utils::hook::set(0x8A6160_b, 0xC3); diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index a5414c48..8b30df2c 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -98,6 +98,7 @@ namespace game WEAK symbol Dvar_Reset{ 0xCEC490 }; WEAK symbol Dvar_GenerateChecksum{ 0xCEA520 }; WEAK symbol Dvar_SetInt{ 0xCED3D0 }; + WEAK symbol Dvar_OverrideCheatProtection{ 0XCEB250 }; WEAK symbol<__int64(const char* qpath, char** buffer)> FS_ReadFile{ 0xCDE200 }; WEAK symbol FS_FreeFile{ 0xCDE1F0 }; @@ -197,6 +198,8 @@ namespace game WEAK symbol dvarCount{ 0x7595E54 }; WEAK symbol dvarPool{ 0x7595E60 }; + WEAK symbol isCheatOverride{ 0x1BBEF28 }; + WEAK symbol g_entities{ 0x3D22610 }; WEAK symbol svs_numclients{ 0x6B229E0 };