From 1364045cb0a1e351d5ec446da2d060c95ff617da Mon Sep 17 00:00:00 2001
From: terencehill <piuntn@gmail.com>
Date: Fri, 9 Aug 2024 23:27:28 +0200
Subject: [PATCH] Remove cruft of an outdated system against cmd name spam (not
 functional because .nickspamtime is never set).

cmd name is already protected by spam by the sv_clientcommand_antispam system anyway

Also remove unused floodcontrol_voice* fields
---
 qcsrc/common/physics/player.qc  | 22 ----------------------
 qcsrc/common/physics/player.qh  |  4 ----
 qcsrc/ecs/systems/sv_physics.qc |  1 -
 qcsrc/server/chat.qh            |  2 --
 qcsrc/server/client.qh          |  4 ----
 qcsrc/server/command/common.qc  |  4 +---
 6 files changed, 1 insertion(+), 36 deletions(-)

diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc
index 670aa8549..b007afaf1 100644
--- a/qcsrc/common/physics/player.qc
+++ b/qcsrc/common/physics/player.qc
@@ -602,28 +602,6 @@ bool PM_check_specialcommand(entity this, int buttons)
 	return false;
 }
 
-void PM_check_nickspam(entity this)
-{
-#ifdef SVQC
-	if (time >= this.nickspamtime)
-		return;
-	if (this.nickspamcount >= autocvar_g_nick_flood_penalty_yellow)
-	{
-		// slight annoyance for nick change scripts
-		PHYS_CS(this).movement = -1 * PHYS_CS(this).movement;
-		PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_JUMP(this) = PHYS_INPUT_BUTTON_ATCK2(this) = PHYS_INPUT_BUTTON_ZOOM(this) = PHYS_INPUT_BUTTON_CROUCH(this) = PHYS_INPUT_BUTTON_HOOK(this) = PHYS_INPUT_BUTTON_USE(this) = false;
-
-		if (this.nickspamcount >= autocvar_g_nick_flood_penalty_red) // if you are persistent and the slight annoyance above does not stop you, I'll show you!
-		{
-			this.v_angle_x = random() * 360;
-			this.v_angle_y = random() * 360;
-			// at least I'm not forcing retardedview by also assigning to angles_z
-			this.fixangle = true;
-		}
-	}
-#endif
-}
-
 void PM_check_punch(entity this, float dt)
 {
 #ifdef SVQC
diff --git a/qcsrc/common/physics/player.qh b/qcsrc/common/physics/player.qh
index 4bd214929..ea827f4fe 100644
--- a/qcsrc/common/physics/player.qh
+++ b/qcsrc/common/physics/player.qh
@@ -36,10 +36,6 @@ bool autocvar_g_physics_clientselect;
 float autocvar_g_maxspeed;
 float autocvar_g_movement_highspeed = 1;
 bool autocvar_g_movement_highspeed_q3_compat = 0;
-//float autocvar_g_nick_flood_penalty;
-int autocvar_g_nick_flood_penalty_red;
-int autocvar_g_nick_flood_penalty_yellow;
-//float autocvar_g_nick_flood_timeout;
 bool autocvar_speedmeter;
 string autocvar_sv_jumpspeedcap_max;
 float autocvar_sv_jumpspeedcap_max_disable_on_ramps;
diff --git a/qcsrc/ecs/systems/sv_physics.qc b/qcsrc/ecs/systems/sv_physics.qc
index 1454d0049..2d00a4d21 100644
--- a/qcsrc/ecs/systems/sv_physics.qc
+++ b/qcsrc/ecs/systems/sv_physics.qc
@@ -31,7 +31,6 @@ void sys_phys_monitor(entity this, float dt)
 		    || CS(this).movement != CS(this).movement_old
 		    || this.v_angle != CS(this).v_angle_old) { CS(this).parm_idlesince = time; }
 	}
-	PM_check_nickspam(this);
 	PM_check_punch(this, dt);
 }
 
diff --git a/qcsrc/server/chat.qh b/qcsrc/server/chat.qh
index 7d7a730f4..1b2f970b4 100644
--- a/qcsrc/server/chat.qh
+++ b/qcsrc/server/chat.qh
@@ -26,8 +26,6 @@ float nearest_length[NUM_NEAREST_ENTITIES];
 .float floodcontrol_chat;
 .float floodcontrol_chatteam;
 .float floodcontrol_chattell;
-.float floodcontrol_voice;
-.float floodcontrol_voiceteam;
 
 #define CHAT_NOSPECTATORS() ((autocvar_g_chat_nospectators == 1) || (autocvar_g_chat_nospectators == 2 && !warmup_stage))
 
diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh
index d7fb94837..815e26390 100644
--- a/qcsrc/server/client.qh
+++ b/qcsrc/server/client.qh
@@ -316,10 +316,6 @@ bool independent_players;
 
 .int killcount;
 
-//flood fields
-.float nickspamtime; // time of last nick change
-.float nickspamcount;
-
 void SendWelcomeMessage(entity this, int msg_type);
 
 // respawning
diff --git a/qcsrc/server/command/common.qc b/qcsrc/server/command/common.qc
index 6138bd8b5..c446664ec 100644
--- a/qcsrc/server/command/common.qc
+++ b/qcsrc/server/command/common.qc
@@ -246,9 +246,7 @@ void timeout_handler_think(entity this)
 
 				// reset all the flood variables
 				FOREACH_CLIENT(true, {
-					it.nickspamcount = it.nickspamtime = it.floodcontrol_chat =
-						it.floodcontrol_chatteam = it.floodcontrol_chattell =
-							it.floodcontrol_voice = it.floodcontrol_voiceteam = 0;
+					it.floodcontrol_chat = it.floodcontrol_chatteam = it.floodcontrol_chattell = 0;
 				});
 
 				// copy .v_angle to .lastV_angle for every player in order to fix their view during pause (see PlayerPreThink)
-- 
2.39.5