From: Samual Date: Sun, 24 Jul 2011 00:03:45 +0000 (-0400) Subject: Add floodcheck, plus use strtolower for most command comparisons (including in gameco... X-Git-Tag: xonotic-v0.6.0~188^2~28^2~281 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0817ac3136dc197b7d11943e5fc4ca81975a4fdd;p=xonotic%2Fxonotic-data.pk3dir.git Add floodcheck, plus use strtolower for most command comparisons (including in gamecommand.qc) --- diff --git a/qcsrc/server/clientcommands.qc b/qcsrc/server/clientcommands.qc index d6f20b3b2..a14371950 100644 --- a/qcsrc/server/clientcommands.qc +++ b/qcsrc/server/clientcommands.qc @@ -7,12 +7,18 @@ #define CC_REQUEST_COMMAND 2 #define CC_REQUEST_USAGE 3 -float readyrestart_happened; entity nagger; + +.float cmd_floodtime; +.float cmd_floodcount; +float readyrestart_happened; float readycount; -void ReadyCount(); + string MapVote_Suggest(string m); +void ReadyCount(); + + // ============================ // Misc. Supporting Functions // ============================ @@ -321,11 +327,45 @@ void ClientCommand_autoswitch(float request, entity client, float argc) // ====================================== // If this function exists, server game code parses clientcommand before the engine code gets it. +float SV_ParseClientCommand_floodcheck() +{ + if (timeoutStatus != 2) + { + if(time == self.cmd_floodtime) + { + self.cmd_floodcount += 1; + if(self.cmd_floodcount > 8) + return FALSE; // too much spam, halt + } + else + { + self.cmd_floodtime = time; + self.cmd_floodcount = 1; + } + } + return TRUE; // continue, as we're not flooding yet +} void SV_ParseClientCommand(string command) { float search_request_type; float argc = tokenize_console(command); + // for floodcheck + switch(strtolower(argv(0))) + { + case "begin": break; // handled by engine in host_cmd.c + case "pause": break; // handled by engine in host_cmd.c + case "prespawn": break; // handled by engine in host_cmd.c + case "reportcvar": break; // handled by server in this file + case "sentcvar": break; // handled by server in this file + case "spawn": break; // handled by engine in host_cmd.c + default: + if(SV_ParseClientCommand_floodcheck()) + break; // "TRUE": continue, as we're not flooding yet + else + return; // "FALSE": not allowed to continue, halt + } + search_request_type = CC_REQUEST_COMMAND; // for now, we're not going to be sending /*if(argv(0) == "help") @@ -357,7 +397,7 @@ void SV_ParseClientCommand(string command) */ // ((argv(0) == "help") ? argv(1) : argv(0)) - switch(argv(0)) // if first argument is help, then search for the second argument. Else, search for first. + switch(strtolower(argv(0))) // if first argument is help, then search for the second argument. Else, search for first. { // Do not hard code aliases for these, instead create them in defaultXonotic.cfg // also: keep in alphabetical order, please ;) diff --git a/qcsrc/server/gamecommand.qc b/qcsrc/server/gamecommand.qc index 7b3277480..4dda518de 100644 --- a/qcsrc/server/gamecommand.qc +++ b/qcsrc/server/gamecommand.qc @@ -2106,7 +2106,7 @@ void GameCommand(string command) float search_request_type; float argc = tokenize_console(command); - if(argv(0) == "help") + if(strtolower(argv(0)) == "help") { if(argc == 1) { @@ -2172,7 +2172,7 @@ void GameCommand(string command) else search_request_type = GC_REQUEST_COMMAND; // continue as usual and scan for normal commands - switch( ((argv(0) == "help") ? argv(1) : argv(0)) ) // if first argument is help, then search for the second argument. Else, search for first. + switch(strtolower( ((strtolower(argv(0)) == "help") ? argv(1) : argv(0)) )) // if first argument is help, then search for the second argument. Else, search for first. { // Do not hard code aliases for these, instead create them in defaultXonotic.cfg // also: keep in alphabetical order, please ;)