From c48aa14325078e5d2972847666b1747dfad6585e Mon Sep 17 00:00:00 2001 From: div0 Date: Tue, 28 Apr 2009 13:50:52 +0000 Subject: [PATCH] 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. git-svn-id: svn://svn.icculus.org/nexuiz/trunk@6603 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/defaultNexuiz.cfg | 4 ++++ data/qcsrc/server/cl_physics.qc | 16 ++++++++++++++++ data/qcsrc/server/clientcommands.qc | 12 ++++++++++++ data/qcsrc/server/defs.qh | 3 +++ 4 files changed, 35 insertions(+) diff --git a/data/defaultNexuiz.cfg b/data/defaultNexuiz.cfg index 5b5a369b8..17801503f 100644 --- a/data/defaultNexuiz.cfg +++ b/data/defaultNexuiz.cfg @@ -1080,6 +1080,10 @@ set g_chat_flood_notify_flooder 1 "when 0, the flooder still can see his own mes 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 diff --git a/data/qcsrc/server/cl_physics.qc b/data/qcsrc/server/cl_physics.qc index 38e320c14..fc75f7c18 100644 --- a/data/qcsrc/server/cl_physics.qc +++ b/data/qcsrc/server/cl_physics.qc @@ -370,6 +370,22 @@ void SV_PlayerPhysics() 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) diff --git a/data/qcsrc/server/clientcommands.qc b/data/qcsrc/server/clientcommands.qc index 504d269ca..15885af1b 100644 --- a/data/qcsrc/server/clientcommands.qc +++ b/data/qcsrc/server/clientcommands.qc @@ -370,6 +370,18 @@ void SV_ParseClientCommand(string s) { 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); } } diff --git a/data/qcsrc/server/defs.qh b/data/qcsrc/server/defs.qh index bf8fd5f73..794cd0014 100644 --- a/data/qcsrc/server/defs.qh +++ b/data/qcsrc/server/defs.qh @@ -568,3 +568,6 @@ void Drag_MoveDrag(entity from, entity to); .float ammo_fuel; .vector prevorigin; + +.float nickspamtime; // time of last nick change +.float nickspamcount; -- 2.39.2