[nexuiz-commits] r6603 - in trunk/data: . qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Tue Apr 28 09:50:52 EDT 2009


Author: div0
Date: 2009-04-28 09:50:52 -0400 (Tue, 28 Apr 2009)
New Revision: 6603

Modified:
   trunk/data/defaultNexuiz.cfg
   trunk/data/qcsrc/server/cl_physics.qc
   trunk/data/qcsrc/server/clientcommands.qc
   trunk/data/qcsrc/server/defs.qh
Log:
Nick flood protection. Death to nick changing scripts!

Punishment level 1: invert movement for 0.5 seconds (after 3 changes in rapid succession)
Punishment level 2: randomize view angles (after 10 changes in rapid succession)

I wish it didn't have to come to this.


Modified: trunk/data/defaultNexuiz.cfg
===================================================================
--- trunk/data/defaultNexuiz.cfg	2009-04-28 02:03:54 UTC (rev 6602)
+++ trunk/data/defaultNexuiz.cfg	2009-04-28 13:50:52 UTC (rev 6603)
@@ -1080,6 +1080,10 @@
 set g_chat_teamcolors 0	"colorize nicknames in team color for chat"
 set g_voice_flood_spv 4	"normal voices: seconds between voices to not count as flooding"
 set g_voice_flood_spv_team 2	"team voices: seconds between voices to not count as flooding"
+set g_nick_flood_timeout 120 "time after which nick flood protection resets"
+set g_nick_flood_penalty 0.5 "duration of the nick flood penalty"
+set g_nick_flood_penalty_yellow 3 "number of changes to allow before warning and movement blocking"
+set g_nick_flood_penalty_red 10 "number of changes to allow before totally disorienting the player"
 
 set g_waypointsprite_normdistance 512
 set g_waypointsprite_minscale 1

Modified: trunk/data/qcsrc/server/cl_physics.qc
===================================================================
--- trunk/data/qcsrc/server/cl_physics.qc	2009-04-28 02:03:54 UTC (rev 6602)
+++ trunk/data/qcsrc/server/cl_physics.qc	2009-04-28 13:50:52 UTC (rev 6603)
@@ -370,6 +370,22 @@
 	self.movement_old = self.movement;
 	self.v_angle_old = self.v_angle;
 
+	if(time < self.nickspamtime)
+	if(self.nickspamcount >= cvar("g_nick_flood_penalty_yellow"))
+	{
+		// slight annoyance for nick change scripts
+		self.movement = -1 * self.movement;
+		self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = self.BUTTON_ZOOM = self.BUTTON_CROUCH = self.BUTTON_HOOK = self.BUTTON_USE = 0;
+
+		if(self.nickspamcount >= cvar("g_nick_flood_penalty_red")) // if you are persistent and the slight annoyance above does not stop you, I'll show you!
+		{
+			self.angles_x = random() * 360;
+			self.angles_y = random() * 360;
+			// at least I'm not forcing retardedview by also assigning to angles_z
+			self.fixangle = 1;
+		}
+	}
+
 	if(time > self.shtest_next)
 	{
 		if(self.shtest_next > 0)

Modified: trunk/data/qcsrc/server/clientcommands.qc
===================================================================
--- trunk/data/qcsrc/server/clientcommands.qc	2009-04-28 02:03:54 UTC (rev 6602)
+++ trunk/data/qcsrc/server/clientcommands.qc	2009-04-28 13:50:52 UTC (rev 6603)
@@ -370,6 +370,18 @@
 			print("WARNING: Invalid clientcommand by ", self.netname, ": ", s, "\n");
 			return;
 		}
+
+		if(self.jointime > 0 && time > self.jointime + 10 && time > self.nickspamtime) // allow any changes in the first 10 seconds since joining
+		if(cmd == "name" || cmd == "playermodel") // TODO also playerskin and color?
+		{
+			if(self.nickspamtime == 0 || time > self.nickspamtime + cvar("g_nick_flood_timeout"))
+				// good, no serious flood
+				self.nickspamcount = 1;
+			else
+				self.nickspamcount += 1;
+			self.nickspamtime = time + cvar("g_nick_flood_penalty");
+		}
+
 		clientcommand(self,s);
 	}
 }

Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh	2009-04-28 02:03:54 UTC (rev 6602)
+++ trunk/data/qcsrc/server/defs.qh	2009-04-28 13:50:52 UTC (rev 6603)
@@ -568,3 +568,6 @@
 .float ammo_fuel;
 
 .vector prevorigin;
+
+.float nickspamtime; // time of last nick change
+.float nickspamcount;



More information about the nexuiz-commits mailing list