A2S_Rules fix: Move MTU patch value to gamedata (#1829)

* A2S_Rules fix: Move MTU patch value to gamedata and increase it

* Revert MTU value back to 5k
This commit is contained in:
Vauff 2023-04-19 11:28:40 -04:00 committed by GitHub
parent 426c1a090f
commit 2e1235a585
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -36,6 +36,7 @@
// Grab the convar ref // Grab the convar ref
ConVar *host_rules_show = nullptr; ConVar *host_rules_show = nullptr;
bool bPatched = false; bool bPatched = false;
int iPatchSize = -1;
RulesFix rulesfix; RulesFix rulesfix;
@ -53,7 +54,7 @@ bool SetMTUMax(int iValue)
//If we never changed skip resetting //If we never changed skip resetting
if (iOriginalValue == -1 && iValue == -1) if (iOriginalValue == -1 && iValue == -1)
return true; return false;
if (m_pMaxMTU == nullptr) if (m_pMaxMTU == nullptr)
{ {
@ -77,10 +78,16 @@ bool SetMTUMax(int iValue)
void RulesFix::OnLoad() void RulesFix::OnLoad()
{ {
const char *patchSize = g_pGameConf->GetKeyValue("MTUPatchSize");
if (patchSize != NULL)
{
iPatchSize = atoi(patchSize);
}
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)) if (SetMTUMax(iPatchSize))
{ {
// 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);
@ -124,7 +131,7 @@ static void OnConVarChanged(IConVar *var, const char *pOldValue, float flOldValu
{ {
if (!bPatched) if (!bPatched)
{ {
if (SetMTUMax(5000)) if (SetMTUMax(iPatchSize))
{ {
bPatched = true; bPatched = true;
NotifyAllCVars(); NotifyAllCVars();

View File

@ -267,6 +267,10 @@
"#default" "#default"
{ {
"Keys"
{
"MTUPatchSize" "5000"
}
"Addresses" "Addresses"
{ {
// Offset from NET_SendPacket sig to MTU // Offset from NET_SendPacket sig to MTU