]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Lots and lots and lots of todo's being hammered away :D
authorSamual <samual@xonotic.org>
Mon, 19 Dec 2011 20:50:13 +0000 (15:50 -0500)
committerSamual <samual@xonotic.org>
Mon, 19 Dec 2011 20:50:13 +0000 (15:50 -0500)
qcsrc/server/command/common.qc
qcsrc/server/command/common.qh
qcsrc/server/command/sv_cmd.qc

index affad72a6e540b6321512a7e3c31c9042a00bfb6..93672bc0d3a9f170731e4af10b4aeb01e9bff8af 100644 (file)
@@ -22,14 +22,14 @@ string GetCallerName(entity caller)
 }
 
 // verify that the client provided is acceptable for use
-float VerifyClientEntity(entity client, float must_be_real, float allow_bots)
+float VerifyClientEntity(entity client, float must_be_real, float must_be_bots)
 {
        if not(client.flags & FL_CLIENT)
                return CLIENT_DOESNT_EXIST;
        else if(must_be_real && (clienttype(client) != CLIENTTYPE_REAL))
                return CLIENT_NOT_REAL;
-       else if(!allow_bots && (clienttype(client) == CLIENTTYPE_BOT))
-               return CLIENT_IS_BOT;
+       else if(must_be_bots && (clienttype(client) != CLIENTTYPE_BOT))
+               return CLIENT_NOT_BOT;
                
        return CLIENT_ACCEPTABLE;
 }
@@ -41,7 +41,7 @@ string GetClientErrorString(float clienterror, string original_input)
        {
                case CLIENT_DOESNT_EXIST: { return strcat("Client '", original_input, "' doesn't exist"); }
                case CLIENT_NOT_REAL: { return strcat("Client '", original_input, "' is not real"); }
-               case CLIENT_IS_BOT: { return strcat("Client '", original_input, "' is a bot"); }
+               case CLIENT_NOT_BOT: { return strcat("Client '", original_input, "' is not a bot"); }
                default: { return "Incorrect usage of GetClientErrorString"; }
        }
 }
index 90be5f79d6aa65f4db012ca36e5e4a4251820e00..010d56b060f0b763073a21625c4636afd12ff1d7 100644 (file)
@@ -6,4 +6,4 @@
 #define CLIENT_ACCEPTABLE 1
 #define CLIENT_DOESNT_EXIST -1
 #define CLIENT_NOT_REAL -2
-#define CLIENT_IS_BOT -3
\ No newline at end of file
+#define CLIENT_NOT_BOT -3
\ No newline at end of file
index 91979acf2c5ec2e902177e32909f140344bd3524..f8d94f60263c8a49d2772f9f7fff05c1eed27807 100644 (file)
@@ -218,27 +218,25 @@ void GameCommand_allspec(float request, float argc)
        }
 }
 
-void GameCommand_anticheat(float request, float argc)
+void GameCommand_anticheat(float request, float argc) 
 {
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       entity client;
-                       float entno = stof(argv(1)); 
+                       entity client = GetFilteredEntity(argv(1));
+                       float accepted = VerifyClientEntity(client, FALSE, FALSE);
                        
-                       if((entno < 1) | (entno > maxclients)) {
-                               print("Player ", argv(1), " doesn't exist\n");
+                       if(accepted) 
+                       {
+                               self = client;
+                               anticheat_report();
                                return;
                        }
-                       client = edict_num(entno);
-                       if(clienttype(client) != CLIENTTYPE_REAL || clienttype(client) != CLIENTTYPE_BOT) {
-                               print("Player ", client.netname, " is not active\n");
-                               return;
+                       else
+                       {
+                               print("anticheat: ", GetClientErrorString(accepted, argv(1)), ".\n"); 
                        }
-                       self = client;
-                       anticheat_report();
-                       return;
                }
                        
                default:
@@ -345,7 +343,7 @@ void GameCommand_bbox(float request)
        }
 }
 
-void GameCommand_bot_cmd(float request, float argc) // what a mess... old old code.
+void GameCommand_bot_cmd(float request, float argc) // legacy
 {
        switch(request)
        {
@@ -471,7 +469,7 @@ void GameCommand_cointoss(float request, float argc)
        }
 }
 
-void GameCommand_database(float request, float argc)
+void GameCommand_database(float request, float argc) // legacy
 {
        switch(request)
        {
@@ -582,7 +580,7 @@ void GameCommand_defer_clear_all(float request)
        }
 }
 
-void GameCommand_delrec(float request, float argc) // UNTESTED // perhaps merge later with records and printstats and such?
+void GameCommand_delrec(float request, float argc) // legacy // perhaps merge later with records and printstats and such?
 {
        switch(request)
        {
@@ -611,7 +609,7 @@ void GameCommand_delrec(float request, float argc) // UNTESTED // perhaps merge
        }
 }
 
-void GameCommand_effectindexdump(float request)
+void GameCommand_effectindexdump(float request) // legacy
 {
        switch(request)
        {
@@ -959,7 +957,7 @@ void GameCommand_moveplayer(float request, float argc)
 
                                        // Check to see if the player is a valid target
                                        client = GetFilteredEntity(t);
-                                       accepted = VerifyClientEntity(client, FALSE, TRUE);
+                                       accepted = VerifyClientEntity(client, FALSE, FALSE);
                                        
                                        if not(accepted) 
                                        {
@@ -1129,76 +1127,76 @@ void GameCommand_playerdemo(float request, float argc) // UNTESTED
        {
                case CMD_REQUEST_COMMAND:
                {
-                       entity client;
-                       float i, n, entno;
-                       string s;
-                       
-                       switch(argv(1))
+                       if(argv(2) && argv(3))
                        {
-                               case "read":
+                               entity client;
+                               float i, n, accepted;
+                               
+                               switch(argv(1))
                                {
-                                       // TODO: Create a general command for looking this up, save a lot of space everywhere in this file
-                                       entno = GetFilteredNumber(argv(2));
-                                       if((entno < 1) | (entno > maxclients)) {
-                                               print("Player ", argv(2), " doesn't exist\n");
+                                       case "read":
+                                       {
+                                               client = GetFilteredEntity(argv(2));
+                                               accepted = VerifyClientEntity(client, FALSE, TRUE);
+                                               
+                                               if not(accepted) 
+                                               {
+                                                       print("playerdemo: read: ", GetClientErrorString(accepted, argv(2)), ".\n"); 
+                                                       return;
+                                               }
+                                               
+                                               self = client;
+                                               playerdemo_open_read(argv(3));
                                                return;
                                        }
-                                       client = edict_num(entno);
-                                       if(clienttype(client) != CLIENTTYPE_BOT) {
-                                               print("Player ", client.netname, " is not a bot\n");
+                                       
+                                       case "write":
+                                       {
+                                               client = GetFilteredEntity(argv(2));
+                                               accepted = VerifyClientEntity(client, FALSE, FALSE);
+                                               
+                                               if not(accepted) 
+                                               {
+                                                       print("playerdemo: write: ", GetClientErrorString(accepted, argv(2)), ".\n"); 
+                                                       return;
+                                               }
+                                               
+                                               self = client;
+                                               playerdemo_open_write(argv(3));
                                                return;
                                        }
-                                       self = client;
-                                       playerdemo_open_read(argv(3));
-                                       return;
-                               }
-                               
-                               case "write":
-                               {
-                                       entno = GetFilteredNumber(argv(2));
-                                       if((entno < 1) | (entno > maxclients)) {
-                                               print("Player ", argv(2), " doesn't exist\n");
+                                       
+                                       case "auto_read_and_write":
+                                       {
+                                               n = GetFilteredNumber(argv(3));
+                                               cvar_set("bot_number", ftos(n));
+                                               
+                                               localcmd("wait; wait; wait\n");
+                                               for(i = 0; i < n; ++i) { localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", argv(2), ftos(i+1), "\n"); }
+                                               
+                                               localcmd("sv_cmd playerdemo write 1 ", ftos(n+1), "\n");
+                                               return;
+                                       }
+                                       
+                                       case "auto_read":
+                                       {
+                                               n = GetFilteredNumber(argv(3));
+                                               cvar_set("bot_number", ftos(n));
+                                               
+                                               localcmd("wait; wait; wait\n");
+                                               for(i = 0; i < n; ++i) { localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", argv(2), ftos(i+1), "\n"); }
                                                return;
                                        }
-                                       client = edict_num(entno);
-                                       self = client;
-                                       playerdemo_open_write(argv(3));
-                                       return;
-                               }
-                               
-                               case "auto_read_and_write":
-                               {
-                                       s = argv(2);
-                                       n = GetFilteredNumber(argv(3));
-                                       cvar_set("bot_number", ftos(n));
-                                       localcmd("wait; wait; wait\n");
-                                       for(i = 0; i < n; ++i)
-                                               localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", s, ftos(i+1), "\n");
-                                       localcmd("sv_cmd playerdemo write 1 ", ftos(n+1), "\n");
-                                       return;
-                               }
-                               
-                               case "auto_read":
-                               {
-                                       s = argv(2);
-                                       n = GetFilteredNumber(argv(3));
-                                       cvar_set("bot_number", ftos(n));
-                                       localcmd("wait; wait; wait\n");
-                                       for(i = 0; i < n; ++i)
-                                               localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", s, ftos(i+1), "\n");
-                                       return;
                                }
-                               
-                               return;
                        }
                }
                        
                default:
-                       print("Incorrect parameters for ^2radarmap^7\n");
+                       print("Incorrect parameters for ^2playerdemo^7\n");
                case CMD_REQUEST_USAGE:
                {
-                       print("\nUsage:^3 sv_cmd \n");
-                       print("  TODO: Arguments currently unknown\n");
+                       print("\nUsage:^3 sv_cmd playerdemo command (entitynumber filename | entitynumber botnumber)\n");
+                       print("  Full list of commands here: \"read, write, auto_read_and_write, auto_read.\"\n");
                        return;
                }
        }
@@ -1435,7 +1433,7 @@ void GameCommand_stuffto(float request, float argc)
                        print("Incorrect parameters for ^2stuffto^7\n");
                case CMD_REQUEST_USAGE:
                {
-                       print("\nUsage:^3 sv_cmd stuffto client <command>\n");
+                       print("\nUsage:^3 sv_cmd stuffto client \"command\"\n");
                        print("  'client' is the entity number or name of the player,\n");
                        print("  and 'command' is the command to be sent to that player.\n");
                        return;