]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/command/sv_cmd.qc
Revert "Merge branch 'TimePath/bot_api' into 'master'\r"
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / sv_cmd.qc
index 08728a6403a5df75361c8c5a09da20eb31155c60..d08588ff99c1a3501fe28992bee5329c1654b7c5 100644 (file)
@@ -41,7 +41,7 @@ void PutObserverInServer (void);
 
 //  used by GameCommand_make_mapinfo()
 void make_mapinfo_Think()
-{
+{SELFPARAM();
        if(MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
        {
                LOG_INFO("Done rebuiling mapinfos.\n");
@@ -175,47 +175,6 @@ void GameCommand_adminmsg(float request, float argc)
        }
 }
 
-void GameCommand_mobbutcher(float request)
-{
-       switch(request)
-       {
-               case CMD_REQUEST_COMMAND:
-               {
-                       if(autocvar_g_campaign) { LOG_INFO("This command doesn't work in campaign mode.\n"); return; }
-                       if(g_invasion) { LOG_INFO("This command doesn't work during an invasion.\n"); return; }
-
-                       float removed_count = 0;
-                       entity head;
-
-                       FOR_EACH_MONSTER(head)
-                       {
-                               monster_remove(head);
-                               ++removed_count;
-                       }
-
-                       monsters_total = 0; // reset stats?
-                       monsters_killed = 0;
-
-                       totalspawned = 0;
-
-                       if(removed_count <= 0)
-                               LOG_INFO("No monsters to kill\n");
-                       else
-                               LOG_INFOF("Killed %d monster%s\n", removed_count, ((removed_count == 1) ? "" : "s"));
-
-                       return; // never fall through to usage
-               }
-
-               default:
-               case CMD_REQUEST_USAGE:
-               {
-                       LOG_INFO("\nUsage:^3 sv_cmd mobbutcher\n");
-                       LOG_INFO("  No arguments required.\n");
-                       return;
-               }
-       }
-}
-
 void GameCommand_allready(float request)
 {
        switch(request)
@@ -237,7 +196,7 @@ void GameCommand_allready(float request)
 }
 
 void GameCommand_allspec(float request, float argc)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -248,10 +207,9 @@ void GameCommand_allspec(float request, float argc)
 
                        FOR_EACH_REALPLAYER(client)
                        {
-                               self = client;
-                               if(self.caplayer)
-                                       self.caplayer = 0;
-                               PutObserverInServer();
+                               if (client.caplayer)
+                                       client.caplayer = 0;
+                               WITH(entity, self, client, PutObserverInServer());
                                ++i;
                        }
                        if(i) { bprint(strcat("Successfully forced all (", ftos(i), ") players to spectate", (reason ? strcat(" for reason: '", reason, "'") : ""), ".\n")); }
@@ -271,7 +229,7 @@ void GameCommand_allspec(float request, float argc)
 }
 
 void GameCommand_anticheat(float request, float argc)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -281,8 +239,7 @@ void GameCommand_anticheat(float request, float argc)
 
                        if(accepted > 0)
                        {
-                               self = client;
-                               anticheat_report();
+                               WITH(entity, self, client, anticheat_report());
                                return;
                        }
                        else
@@ -859,11 +816,11 @@ void GameCommand_gettaginfo(float request, float argc)
                        {
                                tmp_entity = spawn();
                                if(argv(1) == "w")
-                                       setmodel(tmp_entity, (nextent(world)).weaponentity.model);
+                                       _setmodel(tmp_entity, (nextent(world)).weaponentity.model);
                                else
                                {
                                        precache_model(argv(1));
-                                       setmodel(tmp_entity, argv(1));
+                                       _setmodel(tmp_entity, argv(1));
                                }
                                tmp_entity.frame = stof(argv(2));
                                if(substring(argv(3), 0, 1) == "#")
@@ -917,11 +874,11 @@ void GameCommand_animbench(float request, float argc)
                        {
                                tmp_entity = spawn();
                                if(argv(1) == "w")
-                                       setmodel(tmp_entity, (nextent(world)).weaponentity.model);
+                                       _setmodel(tmp_entity, (nextent(world)).weaponentity.model);
                                else
                                {
                                        precache_model(argv(1));
-                                       setmodel(tmp_entity, argv(1));
+                                       _setmodel(tmp_entity, argv(1));
                                }
                                float f1 = stof(argv(2));
                                float f2 = stof(argv(3));
@@ -1043,7 +1000,7 @@ void GameCommand_make_mapinfo(float request)
 }
 
 void GameCommand_moveplayer(float request, float argc)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -1080,10 +1037,9 @@ void GameCommand_moveplayer(float request, float argc)
                                        {
                                                if(!IS_SPEC(client) && !IS_OBSERVER(client))
                                                {
-                                                       self = client;
-                                                       if(self.caplayer)
-                                                               self.caplayer = 0;
-                                                       PutObserverInServer();
+                                                       if (client.caplayer)
+                                                               client.caplayer = 0;
+                                                       WITH(entity, self, client, PutObserverInServer());
 
                                                        successful = strcat(successful, (successful ? ", " : ""), client.netname);
                                                }
@@ -1212,7 +1168,7 @@ void GameCommand_nospectators(float request)
 }
 
 void GameCommand_playerdemo(float request, float argc)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -1235,8 +1191,7 @@ void GameCommand_playerdemo(float request, float argc)
                                                        return;
                                                }
 
-                                               self = client;
-                                               playerdemo_open_read(argv(next_token));
+                                               WITH(entity, self, client, playerdemo_open_read(argv(next_token)));
                                                return;
                                        }
 
@@ -1251,8 +1206,7 @@ void GameCommand_playerdemo(float request, float argc)
                                                        return;
                                                }
 
-                                               self = client;
-                                               playerdemo_open_write(argv(next_token));
+                                               WITH(entity, self, client, playerdemo_open_write(argv(next_token)));
                                                return;
                                        }
 
@@ -1385,7 +1339,7 @@ void GameCommand_setbots(float request, float argc)
 }
 
 void GameCommand_shuffleteams(float request)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -1450,7 +1404,7 @@ void GameCommand_shuffleteams(float request)
                                                                continue; // not a player, move on to next random slot
 
                                                        if(VerifyClientNumber(shuffleteams_players[z]))
-                                                               self = edict_num(shuffleteams_players[z]);
+                                                               setself(edict_num(shuffleteams_players[z]));
 
                                                        if(self.team != team_color)
                                                                MoveToTeam(self, team_color, 6);
@@ -1816,7 +1770,6 @@ void GameCommand_(float request)
 // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
 #define SERVER_COMMANDS(request,arguments,command) \
        SERVER_COMMAND("adminmsg", GameCommand_adminmsg(request, arguments), "Send an admin message to a client directly") \
-       SERVER_COMMAND("mobbutcher", GameCommand_mobbutcher(request), "Instantly removes all monsters on the map") \
        SERVER_COMMAND("allready", GameCommand_allready(request), "Restart the server and reset the players") \
        SERVER_COMMAND("allspec", GameCommand_allspec(request, arguments), "Force all players to spectate") \
        SERVER_COMMAND("anticheat", GameCommand_anticheat(request, arguments), "Create an anticheat report for a client") \
@@ -1947,6 +1900,10 @@ void GameCommand(string command)
                        return;
                }
        }
+       else if(MUTATOR_CALLHOOK(SV_ParseServerCommand, strtolower(argv(0)), argc, command))
+       {
+               return; // handled by a mutator
+       }
        else if(BanCommand(command))
        {
                return; // handled by server/command/ipban.qc