]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add floodcheck, plus use strtolower for most command comparisons (including in gameco...
authorSamual <samual@xonotic.org>
Sun, 24 Jul 2011 00:03:45 +0000 (20:03 -0400)
committerSamual <samual@xonotic.org>
Sun, 24 Jul 2011 00:03:45 +0000 (20:03 -0400)
qcsrc/server/clientcommands.qc
qcsrc/server/gamecommand.qc

index d6f20b3b29d319179aa87bbe76eb7102e550f6d8..a1437195022da04077ad2fdac61b419d040459d9 100644 (file)
@@ -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 ;)
index 7b3277480d6886cbc6383e1245d563316d919660..4dda518def09fb2302922120adaea8b270813d54 100644 (file)
@@ -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 ;)