A2S_Rules fix: Only change host_rules_show if patching was successful (#1459)
If lookup of the patch location failed, don't turn on responding to A2S_Rules queries. Otherwise we'll see the log getting spammed with too large packet sizes again. #1447
This commit is contained in:
parent
2b1cc43355
commit
1fbe5e1daa
@ -46,21 +46,21 @@ RulesFix::RulesFix() :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetMTUMax(int iValue)
|
bool SetMTUMax(int iValue)
|
||||||
{
|
{
|
||||||
static int iOriginalValue = -1;
|
static int iOriginalValue = -1;
|
||||||
static int *m_pMaxMTU = nullptr;
|
static int *m_pMaxMTU = nullptr;
|
||||||
|
|
||||||
//If we never changed skip resetting
|
//If we never changed skip resetting
|
||||||
if (iOriginalValue == -1 && iValue == -1)
|
if (iOriginalValue == -1 && iValue == -1)
|
||||||
return;
|
return true;
|
||||||
|
|
||||||
if (m_pMaxMTU == nullptr)
|
if (m_pMaxMTU == nullptr)
|
||||||
{
|
{
|
||||||
if (!g_pGameConf->GetAddress("MaxMTU", (void **)&m_pMaxMTU))
|
if (!g_pGameConf->GetAddress("MaxMTU", (void **)&m_pMaxMTU))
|
||||||
{
|
{
|
||||||
g_pSM->LogMessage(myself, "[CStrike] Failed to locate NET_SendPacket signature.");
|
g_pSM->LogMessage(myself, "[CStrike] Failed to locate NET_SendPacket signature.");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceHook::SetMemAccess(m_pMaxMTU, sizeof(int), SH_MEM_READ | SH_MEM_WRITE | SH_MEM_EXEC);
|
SourceHook::SetMemAccess(m_pMaxMTU, sizeof(int), SH_MEM_READ | SH_MEM_WRITE | SH_MEM_EXEC);
|
||||||
@ -72,19 +72,21 @@ void SetMTUMax(int iValue)
|
|||||||
*m_pMaxMTU = iOriginalValue;
|
*m_pMaxMTU = iOriginalValue;
|
||||||
else
|
else
|
||||||
*m_pMaxMTU = iValue;
|
*m_pMaxMTU = iValue;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RulesFix::OnLoad()
|
void RulesFix::OnLoad()
|
||||||
{
|
{
|
||||||
host_rules_show = g_pCVar->FindVar("host_rules_show");
|
host_rules_show = g_pCVar->FindVar("host_rules_show");
|
||||||
if (host_rules_show)
|
if (host_rules_show)
|
||||||
|
{
|
||||||
|
if (SetMTUMax(5000))
|
||||||
{
|
{
|
||||||
// Default to enabled. Explicit disable via cfg will still be obeyed.
|
// Default to enabled. Explicit disable via cfg will still be obeyed.
|
||||||
host_rules_show->SetValue(true);
|
host_rules_show->SetValue(true);
|
||||||
|
|
||||||
SetMTUMax(5000);
|
|
||||||
bPatched = true;
|
bPatched = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SH_ADD_HOOK(IServerGameDLL, GameServerSteamAPIActivated, gamedll, SH_MEMBER(this, &RulesFix::Hook_GameServerSteamAPIActivated), true);
|
SH_ADD_HOOK(IServerGameDLL, GameServerSteamAPIActivated, gamedll, SH_MEMBER(this, &RulesFix::Hook_GameServerSteamAPIActivated), true);
|
||||||
}
|
}
|
||||||
@ -122,16 +124,18 @@ static void OnConVarChanged(IConVar *var, const char *pOldValue, float flOldValu
|
|||||||
{
|
{
|
||||||
if (!bPatched)
|
if (!bPatched)
|
||||||
{
|
{
|
||||||
SetMTUMax(5000);
|
if (SetMTUMax(5000))
|
||||||
|
{
|
||||||
bPatched = true;
|
bPatched = true;
|
||||||
NotifyAllCVars();
|
NotifyAllCVars();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (bPatched)
|
if (bPatched)
|
||||||
{
|
{
|
||||||
SetMTUMax(-1);
|
if (SetMTUMax(-1))
|
||||||
bPatched = false;
|
bPatched = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user