aboutsummaryrefslogtreecommitdiff
path: root/primedev/shared/exploit_fixes/ns_limits.h
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2023-12-27 00:32:01 +0000
committerGitHub <noreply@github.com>2023-12-27 01:32:01 +0100
commitf5ab6fb5e8be7b73e6003d4145081d5e0c0ce287 (patch)
tree90f2c6a4885dbd181799e2325cf33588697674e1 /primedev/shared/exploit_fixes/ns_limits.h
parentbb8ed59f6891b1196c5f5bbe7346cd171c8215fa (diff)
downloadNorthstarLauncher-1.21.2.tar.gz
NorthstarLauncher-1.21.2.zip
Folder restructuring from primedev (#624)v1.21.2-rc3v1.21.2
Copies of over the primedev folder structure for easier cherry-picking of further changes Co-authored-by: F1F7Y <filip.bartos07@proton.me>
Diffstat (limited to 'primedev/shared/exploit_fixes/ns_limits.h')
-rw-r--r--primedev/shared/exploit_fixes/ns_limits.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/primedev/shared/exploit_fixes/ns_limits.h b/primedev/shared/exploit_fixes/ns_limits.h
new file mode 100644
index 00000000..546fec6f
--- /dev/null
+++ b/primedev/shared/exploit_fixes/ns_limits.h
@@ -0,0 +1,52 @@
+#pragma once
+#include "engine/r2engine.h"
+#include "core/convar/convar.h"
+#include <unordered_map>
+
+struct PlayerLimitData
+{
+ double lastClientCommandQuotaStart = -1.0;
+ int numClientCommandsInQuota = 0;
+
+ double lastNetChanProcessingLimitStart = -1.0;
+ double netChanProcessingLimitTime = 0.0;
+
+ double lastSayTextLimitStart = -1.0;
+ int sayTextLimitCount = 0;
+
+ float flFrameUserCmdBudget = 0.0;
+};
+
+struct UnconnectedPlayerLimitData
+{
+ char ip[16];
+ double lastQuotaStart = 0.0;
+ int packetCount = 0;
+ double timeoutEnd = -1.0;
+};
+
+class ServerLimitsManager
+{
+public:
+ ConVar* CVar_sv_quota_stringcmdspersecond;
+ ConVar* Cvar_net_chan_limit_mode;
+ ConVar* Cvar_net_chan_limit_msec_per_sec;
+ ConVar* Cvar_sv_querylimit_per_sec;
+ ConVar* Cvar_sv_max_chat_messages_per_sec;
+ ConVar* Cvar_sv_antispeedhack_enable;
+ ConVar* Cvar_sv_antispeedhack_maxtickbudget;
+ ConVar* Cvar_sv_antispeedhack_budgetincreasemultiplier;
+
+ std::unordered_map<CBaseClient*, PlayerLimitData> m_PlayerLimitData;
+ std::vector<UnconnectedPlayerLimitData> m_UnconnectedPlayerLimitData;
+
+public:
+ void RunFrame(double flCurrentTime, float flFrameTime);
+ void AddPlayer(CBaseClient* player);
+ void RemovePlayer(CBaseClient* player);
+ bool CheckStringCommandLimits(CBaseClient* player);
+ bool CheckChatLimits(CBaseClient* player);
+ bool CheckConnectionlessPacketLimits(netpacket_t* packet);
+};
+
+extern ServerLimitsManager* g_pServerLimits;