[Dvar]: Use _stricmp for case comparision (#824)
This commit is contained in:
parent
d6c23efe68
commit
be259519d5
@ -173,4 +173,37 @@ namespace Components
|
|||||||
itr->second(¶ms);
|
itr->second(¶ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Command::CL_ShouldSendNotify_Hk(const char* cmd)
|
||||||
|
{
|
||||||
|
if (!cmd)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::array exceptions =
|
||||||
|
{
|
||||||
|
"cmd",
|
||||||
|
"exec",
|
||||||
|
"map",
|
||||||
|
"vstr",
|
||||||
|
"wait",
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const auto& entry : exceptions)
|
||||||
|
{
|
||||||
|
if (!_stricmp(cmd, entry))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Command::Command()
|
||||||
|
{
|
||||||
|
// Protect players from invasive servers
|
||||||
|
Utils::Hook(0x434BD4, CL_ShouldSendNotify_Hk, HOOK_CALL).install()->quick(); // CL_CheckNotify
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ namespace Components
|
|||||||
int nesting_;
|
int nesting_;
|
||||||
};
|
};
|
||||||
|
|
||||||
Command() = default;
|
Command();
|
||||||
|
|
||||||
static Game::cmd_function_s* Allocate();
|
static Game::cmd_function_s* Allocate();
|
||||||
|
|
||||||
@ -72,5 +72,7 @@ namespace Components
|
|||||||
|
|
||||||
static void MainCallback();
|
static void MainCallback();
|
||||||
static void MainCallbackSV();
|
static void MainCallbackSV();
|
||||||
|
|
||||||
|
static bool CL_ShouldSendNotify_Hk(const char* cmd);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ namespace Components
|
|||||||
|
|
||||||
for (const auto& entry : exceptions)
|
for (const auto& entry : exceptions)
|
||||||
{
|
{
|
||||||
if (Utils::String::Compare(dvarName, entry))
|
if (!_stricmp(dvarName, entry))
|
||||||
{
|
{
|
||||||
Game::Dvar_SetFromStringByNameFromSource(dvarName, string, Game::DVAR_SOURCE_INTERNAL);
|
Game::Dvar_SetFromStringByNameFromSource(dvarName, string, Game::DVAR_SOURCE_INTERNAL);
|
||||||
return;
|
return;
|
||||||
|
@ -281,27 +281,6 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QuickPatch::CL_ShouldSendNotify_Hk(const char* cmd)
|
|
||||||
{
|
|
||||||
if (!cmd)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::vector<std::string> exceptions =
|
|
||||||
{
|
|
||||||
"vstr",
|
|
||||||
"wait",
|
|
||||||
};
|
|
||||||
|
|
||||||
if (std::ranges::find(exceptions, cmd) != exceptions.end())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Utils::Hook::Call<bool(const char*)>(0x47A640)(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
Game::dvar_t* QuickPatch::Dvar_RegisterConMinicon(const char* dvarName, [[maybe_unused]] bool value, unsigned __int16 flags, const char* description)
|
Game::dvar_t* QuickPatch::Dvar_RegisterConMinicon(const char* dvarName, [[maybe_unused]] bool value, unsigned __int16 flags, const char* description)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@ -368,9 +347,6 @@ namespace Components
|
|||||||
|
|
||||||
Utils::Hook::Set<const char*>(0x4876C6, "Successfully read stats data\n");
|
Utils::Hook::Set<const char*>(0x4876C6, "Successfully read stats data\n");
|
||||||
|
|
||||||
// Protect players from invasive servers
|
|
||||||
Utils::Hook(0x434BD4, CL_ShouldSendNotify_Hk, HOOK_CALL).install()->quick(); // CL_CheckNotify
|
|
||||||
|
|
||||||
// Numerical ping (cg_scoreboardPingText 1)
|
// Numerical ping (cg_scoreboardPingText 1)
|
||||||
Utils::Hook::Set<BYTE>(0x45888E, 1);
|
Utils::Hook::Set<BYTE>(0x45888E, 1);
|
||||||
Utils::Hook::Set<BYTE>(0x45888C, Game::DVAR_CHEAT);
|
Utils::Hook::Set<BYTE>(0x45888C, Game::DVAR_CHEAT);
|
||||||
|
@ -34,8 +34,6 @@ namespace Components
|
|||||||
|
|
||||||
static void SND_GetAliasOffset_Stub();
|
static void SND_GetAliasOffset_Stub();
|
||||||
|
|
||||||
static bool CL_ShouldSendNotify_Hk(const char* cmd);
|
|
||||||
|
|
||||||
static Game::dvar_t* Dvar_RegisterConMinicon(const char* dvarName, bool value, unsigned __int16 flags, const char* description);
|
static Game::dvar_t* Dvar_RegisterConMinicon(const char* dvarName, bool value, unsigned __int16 flags, const char* description);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user