[Dvar] Disallow setting cheat dvars via menus
This commit is contained in:
parent
c20bb07f39
commit
ccb7c48587
@ -178,6 +178,11 @@ namespace Components
|
||||
return Dvar::Register<const char*>(name, username.data(), Dvar::Flag(flag | Game::dvar_flag::DVAR_FLAG_SAVED).val, description).get<Game::dvar_t*>();
|
||||
}
|
||||
|
||||
Game::dvar_t* Dvar::SetFromStringByNameExternal(const char* dvar, const char* value)
|
||||
{
|
||||
return Game::Dvar_SetFromStringByNameFromSource(dvar, value, Game::DvarSetSource::DVAR_SOURCE_EXTERNAL);
|
||||
}
|
||||
|
||||
Dvar::Dvar()
|
||||
{
|
||||
// set flags of cg_drawFPS to archive
|
||||
@ -211,6 +216,15 @@ namespace Components
|
||||
|
||||
// Hook dvar 'name' registration
|
||||
Utils::Hook(0x40531C, Dvar::RegisterName, HOOK_CALL).install()->quick();
|
||||
|
||||
// Don't allow setting cheat protected dvars via menus
|
||||
Utils::Hook(0x63C897, Dvar::SetFromStringByNameExternal, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x63CA96, Dvar::SetFromStringByNameExternal, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x63CDB5, Dvar::SetFromStringByNameExternal, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x635E47, Dvar::SetFromStringByNameExternal, HOOK_CALL).install()->quick();
|
||||
|
||||
// Entirely block setting cheat dvars internally without sv_cheats
|
||||
//Utils::Hook(0x4F52EC, Dvar::SetFromStringByNameExternal, HOOK_CALL).install()->quick();
|
||||
}
|
||||
|
||||
Dvar::~Dvar()
|
||||
|
@ -58,5 +58,7 @@ namespace Components
|
||||
static Utils::Signal<Callback> RegistrationSignal;
|
||||
|
||||
static Game::dvar_t* RegisterName(const char* name, const char* defaultVal, Game::dvar_flag flag, const char* description);
|
||||
|
||||
static Game::dvar_t* SetFromStringByNameExternal(const char* dvar, const char* value);
|
||||
};
|
||||
}
|
||||
|
@ -215,6 +215,8 @@ namespace Game
|
||||
|
||||
SEH_StringEd_GetString_t SEH_StringEd_GetString = SEH_StringEd_GetString_t(0x44BB30);
|
||||
|
||||
Dvar_SetFromStringByName_t Dvar_SetFromStringByName = Dvar_SetFromStringByName_t(0x4F52E0);
|
||||
Dvar_SetFromStringByNameFromSource_t Dvar_SetFromStringByNameFromSource = Dvar_SetFromStringByNameFromSource_t(0x4FC770);
|
||||
Dvar_SetStringByName_t Dvar_SetStringByName = Dvar_SetStringByName_t(0x44F060);
|
||||
|
||||
SL_ConvertToString_t SL_ConvertToString = SL_ConvertToString_t(0x4EC1D0);
|
||||
|
@ -194,6 +194,12 @@ namespace Game
|
||||
typedef dvar_t* (__cdecl * Dvar_RegisterColor_t)(const char* name, float r, float g, float b, float a, int flags, const char* description);
|
||||
extern Dvar_RegisterColor_t Dvar_RegisterColor;
|
||||
|
||||
typedef dvar_t*(__cdecl * Dvar_SetFromStringByName_t)(const char* cvar, const char* value);
|
||||
extern Dvar_SetFromStringByName_t Dvar_SetFromStringByName;
|
||||
|
||||
typedef dvar_t*(__cdecl * Dvar_SetFromStringByNameFromSource_t)(const char* cvar, const char* value, DvarSetSource source);
|
||||
extern Dvar_SetFromStringByNameFromSource_t Dvar_SetFromStringByNameFromSource;
|
||||
|
||||
typedef void(__cdecl * Dvar_SetStringByName_t)(const char* cvar, const char* value);
|
||||
extern Dvar_SetStringByName_t Dvar_SetStringByName;
|
||||
|
||||
|
@ -87,6 +87,14 @@ namespace Game
|
||||
DVAR_FLAG_NONEXISTENT = 0xFFFFFFFF //no such dvar
|
||||
} dvar_flag;
|
||||
|
||||
enum DvarSetSource
|
||||
{
|
||||
DVAR_SOURCE_INTERNAL = 0x0,
|
||||
DVAR_SOURCE_EXTERNAL = 0x1,
|
||||
DVAR_SOURCE_SCRIPT = 0x2,
|
||||
DVAR_SOURCE_DEVGUI = 0x3,
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DVAR_TYPE_BOOL = 0,
|
||||
|
Loading…
Reference in New Issue
Block a user