From f233b4b75b974ade00aa94436bd39c9b3f9321bd Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Sun, 23 Oct 2022 18:02:55 +0100 Subject: fix reading of cvar net_data_block_enabled (#302) --- NorthstarDLL/limits.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'NorthstarDLL') diff --git a/NorthstarDLL/limits.cpp b/NorthstarDLL/limits.cpp index fd635136..c254de52 100644 --- a/NorthstarDLL/limits.cpp +++ b/NorthstarDLL/limits.cpp @@ -13,8 +13,6 @@ AUTOHOOK_INIT() ServerLimitsManager* g_pServerLimits; -ConVar* Cvar_net_datablock_enabled; - // todo: make this work on higher timescales, also possibly disable when sv_cheats is set void ServerLimitsManager::RunFrame(double flCurrentTime, float flFrameTime) { @@ -148,8 +146,11 @@ AUTOHOOK(ProcessConnectionlessPacket, engine.dll + 0x117800, bool, , (void* a1, R2::netpacket_t* packet)) // clang-format on { + static const ConVar* Cvar_net_data_block_enabled = R2::g_pCVar->FindVar("net_data_block_enabled"); + + // don't ratelimit datablock packets as long as datablock is enabled if (packet->adr.type == R2::NA_IP && - (!(packet->data[4] == 'N' && Cvar_net_datablock_enabled->GetBool()) || !Cvar_net_datablock_enabled->GetBool())) + (!(packet->data[4] == 'N' && Cvar_net_data_block_enabled->GetBool()) || !Cvar_net_data_block_enabled->GetBool())) { // bad lookup: optimise later tm UnconnectedPlayerLimitData* sendData = nullptr; @@ -289,8 +290,6 @@ ON_DLL_LOAD_RELIESON("engine.dll", ServerLimits, ConVar, (CModule module)) "1.2", FCVAR_GAMEDLL, "Increase usercmd processing budget by tickinterval * value per tick"); - - Cvar_net_datablock_enabled = R2::g_pCVar->FindVar("net_datablock_enabled"); } ON_DLL_LOAD("server.dll", ServerLimitsServer, (CModule module)) -- cgit v1.2.3