aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDLL/shared/exploit_fixes/ns_limits.cpp')
-rw-r--r--NorthstarDLL/shared/exploit_fixes/ns_limits.cpp56
1 files changed, 28 insertions, 28 deletions
diff --git a/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp b/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp
index c9085cb0..bd855ee4 100644
--- a/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp
+++ b/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp
@@ -19,47 +19,47 @@ void ServerLimitsManager::RunFrame(double flCurrentTime, float flFrameTime)
if (Cvar_sv_antispeedhack_enable->GetBool())
{
// for each player, set their usercmd processing budget for the frame to the last frametime for the server
- for (int i = 0; i < R2::g_pGlobals->m_nMaxClients; i++)
+ for (int i = 0; i < g_pGlobals->m_nMaxClients; i++)
{
- R2::CBaseClient* player = &R2::g_pClientArray[i];
+ CBaseClient* player = &g_pClientArray[i];
if (m_PlayerLimitData.find(player) != m_PlayerLimitData.end())
{
PlayerLimitData* pLimitData = &g_pServerLimits->m_PlayerLimitData[player];
- if (pLimitData->flFrameUserCmdBudget < R2::g_pGlobals->m_flTickInterval * Cvar_sv_antispeedhack_maxtickbudget->GetFloat())
+ if (pLimitData->flFrameUserCmdBudget < g_pGlobals->m_flTickInterval * Cvar_sv_antispeedhack_maxtickbudget->GetFloat())
{
pLimitData->flFrameUserCmdBudget += g_pServerLimits->Cvar_sv_antispeedhack_budgetincreasemultiplier->GetFloat() *
- fmax(flFrameTime, R2::g_pGlobals->m_flFrameTime * CEngineServer__GetTimescale());
+ fmax(flFrameTime, g_pGlobals->m_flFrameTime * CEngineServer__GetTimescale());
}
}
}
}
}
-void ServerLimitsManager::AddPlayer(R2::CBaseClient* player)
+void ServerLimitsManager::AddPlayer(CBaseClient* player)
{
PlayerLimitData limitData;
limitData.flFrameUserCmdBudget =
- R2::g_pGlobals->m_flTickInterval * CEngineServer__GetTimescale() * Cvar_sv_antispeedhack_maxtickbudget->GetFloat();
+ g_pGlobals->m_flTickInterval * CEngineServer__GetTimescale() * Cvar_sv_antispeedhack_maxtickbudget->GetFloat();
m_PlayerLimitData.insert(std::make_pair(player, limitData));
}
-void ServerLimitsManager::RemovePlayer(R2::CBaseClient* player)
+void ServerLimitsManager::RemovePlayer(CBaseClient* player)
{
if (m_PlayerLimitData.find(player) != m_PlayerLimitData.end())
m_PlayerLimitData.erase(player);
}
-bool ServerLimitsManager::CheckStringCommandLimits(R2::CBaseClient* player)
+bool ServerLimitsManager::CheckStringCommandLimits(CBaseClient* player)
{
if (CVar_sv_quota_stringcmdspersecond->GetInt() != -1)
{
// note: this isn't super perfect, legit clients can trigger it in lobby if they try, mostly good enough tho imo
- if (Tier0::Plat_FloatTime() - m_PlayerLimitData[player].lastClientCommandQuotaStart >= 1.0)
+ if (Plat_FloatTime() - m_PlayerLimitData[player].lastClientCommandQuotaStart >= 1.0)
{
// reset quota
- m_PlayerLimitData[player].lastClientCommandQuotaStart = Tier0::Plat_FloatTime();
+ m_PlayerLimitData[player].lastClientCommandQuotaStart = Plat_FloatTime();
m_PlayerLimitData[player].numClientCommandsInQuota = 0;
}
@@ -74,11 +74,11 @@ bool ServerLimitsManager::CheckStringCommandLimits(R2::CBaseClient* player)
return true;
}
-bool ServerLimitsManager::CheckChatLimits(R2::CBaseClient* player)
+bool ServerLimitsManager::CheckChatLimits(CBaseClient* player)
{
- if (Tier0::Plat_FloatTime() - m_PlayerLimitData[player].lastSayTextLimitStart >= 1.0)
+ if (Plat_FloatTime() - m_PlayerLimitData[player].lastSayTextLimitStart >= 1.0)
{
- m_PlayerLimitData[player].lastSayTextLimitStart = Tier0::Plat_FloatTime();
+ m_PlayerLimitData[player].lastSayTextLimitStart = Plat_FloatTime();
m_PlayerLimitData[player].sayTextLimitCount = 0;
}
@@ -100,14 +100,14 @@ char, __fastcall, (void* self, void* buf))
NETCHANLIMIT_KICK
};
- double startTime = Tier0::Plat_FloatTime();
+ double startTime = Plat_FloatTime();
char ret = CNetChan__ProcessMessages(self, buf);
// check processing limits, unless we're in a level transition
- if (R2::g_pHostState->m_iCurrentState == R2::HostState_t::HS_RUN && Tier0::ThreadInServerFrameThread())
+ if (g_pHostState->m_iCurrentState == HostState_t::HS_RUN && ThreadInServerFrameThread())
{
// player that sent the message
- R2::CBaseClient* sender = *(R2::CBaseClient**)((char*)self + 368);
+ CBaseClient* sender = *(CBaseClient**)((char*)self + 368);
// if no sender, return
// relatively certain this is fine?
@@ -121,7 +121,7 @@ char, __fastcall, (void* self, void* buf))
g_pServerLimits->m_PlayerLimitData[sender].lastNetChanProcessingLimitStart = startTime;
g_pServerLimits->m_PlayerLimitData[sender].netChanProcessingLimitTime = 0.0;
}
- g_pServerLimits->m_PlayerLimitData[sender].netChanProcessingLimitTime += (Tier0::Plat_FloatTime() * 1000) - (startTime * 1000);
+ g_pServerLimits->m_PlayerLimitData[sender].netChanProcessingLimitTime += (Plat_FloatTime() * 1000) - (startTime * 1000);
if (g_pServerLimits->m_PlayerLimitData[sender].netChanProcessingLimitTime >=
g_pServerLimits->Cvar_net_chan_limit_msec_per_sec->GetInt())
@@ -133,9 +133,9 @@ char, __fastcall, (void* self, void* buf))
g_pServerLimits->Cvar_net_chan_limit_msec_per_sec->GetInt());
// never kick local player
- if (g_pServerLimits->Cvar_net_chan_limit_mode->GetInt() != NETCHANLIMIT_WARN && strcmp(R2::g_pLocalPlayerUserID, sender->m_UID))
+ if (g_pServerLimits->Cvar_net_chan_limit_mode->GetInt() != NETCHANLIMIT_WARN && strcmp(g_pLocalPlayerUserID, sender->m_UID))
{
- R2::CBaseClient__Disconnect(sender, 1, "Exceeded net channel processing limit");
+ CBaseClient__Disconnect(sender, 1, "Exceeded net channel processing limit");
return false;
}
}
@@ -144,12 +144,12 @@ char, __fastcall, (void* self, void* buf))
return ret;
}
-bool ServerLimitsManager::CheckConnectionlessPacketLimits(R2::netpacket_t* packet)
+bool ServerLimitsManager::CheckConnectionlessPacketLimits(netpacket_t* packet)
{
- static const ConVar* Cvar_net_data_block_enabled = R2::g_pCVar->FindVar("net_data_block_enabled");
+ static const ConVar* Cvar_net_data_block_enabled = 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 &&
+ if (packet->adr.type == NA_IP &&
(!(packet->data[4] == 'N' && Cvar_net_data_block_enabled->GetBool()) || !Cvar_net_data_block_enabled->GetBool()))
{
// bad lookup: optimise later tm
@@ -169,12 +169,12 @@ bool ServerLimitsManager::CheckConnectionlessPacketLimits(R2::netpacket_t* packe
memcpy(sendData->ip, packet->adr.ip, 16);
}
- if (Tier0::Plat_FloatTime() < sendData->timeoutEnd)
+ if (Plat_FloatTime() < sendData->timeoutEnd)
return false;
- if (Tier0::Plat_FloatTime() - sendData->lastQuotaStart >= 1.0)
+ if (Plat_FloatTime() - sendData->lastQuotaStart >= 1.0)
{
- sendData->lastQuotaStart = Tier0::Plat_FloatTime();
+ sendData->lastQuotaStart = Plat_FloatTime();
sendData->packetCount = 0;
}
@@ -188,7 +188,7 @@ bool ServerLimitsManager::CheckConnectionlessPacketLimits(R2::netpacket_t* packe
packet->data[4]);
// timeout for a minute
- sendData->timeoutEnd = Tier0::Plat_FloatTime() + 60.0;
+ sendData->timeoutEnd = Plat_FloatTime() + 60.0;
return false;
}
}
@@ -232,12 +232,12 @@ struct alignas(4) SV_CUserCmd
// clang-format off
AUTOHOOK(CPlayerMove__RunCommand, server.dll + 0x5B8100,
-void, __fastcall, (void* self, R2::CBasePlayer* player, SV_CUserCmd* pUserCmd, uint64_t a4))
+void, __fastcall, (void* self, CBasePlayer* player, SV_CUserCmd* pUserCmd, uint64_t a4))
// clang-format on
{
if (g_pServerLimits->Cvar_sv_antispeedhack_enable->GetBool())
{
- R2::CBaseClient* pClient = &R2::g_pClientArray[player->m_nPlayerIndex - 1];
+ CBaseClient* pClient = &g_pClientArray[player->m_nPlayerIndex - 1];
if (g_pServerLimits->m_PlayerLimitData.find(pClient) != g_pServerLimits->m_PlayerLimitData.end())
{