[Dvar]: Use _stricmp for case comparision (#824)

This commit is contained in:
Edo 2023-03-10 15:00:58 +00:00 committed by GitHub
parent d6c23efe68
commit be259519d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 28 deletions

View File

@ -173,4 +173,37 @@ namespace Components
itr->second(&params); itr->second(&params);
} }
} }
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
}
} }

View File

@ -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);
}; };
} }

View File

@ -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;

View File

@ -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);

View File

@ -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);
}; };
} }