]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Updates to moveplayer command, plus beginning of new feature which allows players...
authorSamual <samual@xonotic.org>
Sat, 5 Nov 2011 17:54:31 +0000 (13:54 -0400)
committerSamual <samual@xonotic.org>
Sat, 5 Nov 2011 17:54:31 +0000 (13:54 -0400)
qcsrc/server/gamecommand.qc
qcsrc/server/miscfunctions.qc

index bc2191333f52455c7e156c781701c6324eb8f465..cb93e3ef377f1223148c296e286d5b9e4dd72862 100644 (file)
@@ -1005,10 +1005,14 @@ void GameCommand_modelbug(float request) // UNTESTED // is this even needed anym
 void GameCommand_moveplayer(float request, float argc)
 {
        entity client;
+       
        string targets = argv(1);
        string destination = argv(2);
        string notify = argv(3);
+       string successful;
+       
        float i;
+       
        argc = tokenizebyseparator(targets, ","); // re-use argc for the targets
        
        switch(request)
@@ -1024,15 +1028,15 @@ void GameCommand_moveplayer(float request, float argc)
                                for(i = 0; i < argc; ++i)
                                {
                                        // Check to see if the player is a valid target
-                                       if((stof(argv(i)) < 1) | (stof(argv(i)) > maxclients)) // player_id is out of range
+                                       if((GetFilteredNumber(argv(i)) < 1) || (GetFilteredNumber(argv(i)) > maxclients)) // player_id is out of range
                                        {
-                                               print(strcat("Player ", argv(i), " doesn't exist", (((i + 1) < argc) ? ", skipping to next player.\n" : ".\n")));
+                                               print("Player ", ftos(GetFilteredNumber(argv(i))), " doesn't exist (out of range)", (((i + 1) < argc) ? ", skipping to next player.\n" : ".\n"));
                                                continue; 
                                        }
-                                       client = edict_num(stof(argv(i)));
+                                       client = edict_num(GetFilteredNumber(argv(i)));
                                        if not(client.flags & FL_CLIENT) // player entity is not a client
                                        {
-                                               print(strcat("Player ", argv(i), " doesn't exist", (((i + 1) < argc) ? ", skipping to next player.\n" : ".\n")));
+                                               print("Player ", ftos(GetFilteredNumber(argv(i))), " doesn't exist (not a client)", (((i + 1) < argc) ? ", skipping to next player.\n" : ".\n"));
                                                continue;
                                        }
                                        
@@ -1043,12 +1047,14 @@ void GameCommand_moveplayer(float request, float argc)
                                                {
                                                        self = client;
                                                        PutObserverInServer();
+                                                       
+                                                       successful = strcat(successful, (successful ? ", " : ""), client.netname);
                                                }
                                                else
                                                {
-                                                       print("Player ", argv(i), " (", client.netname, ") is already spectating.\n");
+                                                       print("Player ", ftos(GetFilteredNumber(argv(i))), " (", client.netname, ") is already spectating.\n");
                                                }
-                                               return;
+                                               continue;
                                        }
                                        else
                                        {
@@ -1066,8 +1072,8 @@ void GameCommand_moveplayer(float request, float argc)
                                                                if(team_color == client.team) // already on the destination team
                                                                {
                                                                        // keep the forcing undone
-                                                                       print("Player ", argv(i), " (", client.netname, ") is already on the ", ColoredTeamName(client.team), ".\n");
-                                                                       return;
+                                                                       print("Player ", ftos(GetFilteredNumber(argv(i))), " (", client.netname, ") is already on the ", ColoredTeamName(client.team), (((i + 1) < argc) ? ", skipping to next player.\n" : ".\n"));
+                                                                       continue;
                                                                } 
                                                                else if(team_color == 0)  // auto team
                                                                {
@@ -1118,8 +1124,11 @@ void GameCommand_moveplayer(float request, float argc)
                                                                // If so, lets continue and finally move the player
                                                                client.team_forced = 0;
                                                                MoveToTeam(client, team_color, 6, stof(notify));
-                                                               print("Player ", argv(i), " (", client.netname, ") has been moved to the ", ColoredTeamName(team_color), ".\n");
-                                                               return;
+                                                               print("Player ", ftos(GetFilteredNumber(argv(i))), " (", client.netname, ") has been moved to the ", ColoredTeamName(team_color), ".\n");
+                                                               
+                                                               successful = strcat(successful, (successful ? ", " : ""), client.netname);
+                                                               
+                                                               //if((i + 1) < argc) { continue; } // keep going with the loop, there are more players to parse through
                                                        }
                                                        else
                                                        {
@@ -1134,7 +1143,12 @@ void GameCommand_moveplayer(float request, float argc)
                                                }
                                        }
                                }
-                               print("No acceptable players given, aborting.\n");
+                               
+                               if(successful)
+                                       print("Successfully moved players ", successful, " to destination ", destination, ".\n");
+                               else
+                                       print("No players given (", targets, ") are able to move.\n");
+                                       
                                return; // still correct parameters so return to avoid usage print
                        }
                        
index 2fe562774d0d625468b36e4333f1e9547e17a607..d9c5589a705826a97ebff5934f2e3e0aa1d9419d 100644 (file)
@@ -3135,3 +3135,16 @@ float isPushable(entity e)
                return TRUE;
        return FALSE;
 }
+
+float GetFilteredNumber(string input)
+{
+       float output;
+       
+       if(substring(input, 0, 1) == "#")
+               output = stof(substring(input, 1, -1));
+       else
+               output = stof(input);
+               
+       print(strcat("input: ", input, ", output: ", ftos(output), ",\n"));
+       return output;
+}