]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/command/sv_cmd.qc
Merge branch 'master' into Mario/notifications
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / sv_cmd.qc
index c98ed3cfed0c94cc1700f8790475f8eb1b04863c..27ed6b8694e16ce8406b98b76cb7d95f020a19f7 100644 (file)
@@ -139,7 +139,7 @@ void GameCommand_adminmsg(float request, float argc)
        }
 }
 
-void GameCommand_butcher(float request)
+void GameCommand_mobbutcher(float request)
 {
        switch(request)
        {
@@ -147,36 +147,33 @@ void GameCommand_butcher(float request)
                {
                        if(autocvar_g_campaign) { print("This command doesn't work in campaign mode.\n"); return; }
                        if(g_invasion) { print("This command doesn't work during an invasion.\n"); return; }
-               
-            float removed_count = 0;
+
+                       float removed_count = 0;
                        entity head;
-                       
+
                        FOR_EACH_MONSTER(head)
                        {
                                monster_remove(head);
                                ++removed_count;
                        }
-                       
-                       FOR_EACH_PLAYER(head)
-                               head.monstercount = 0;
-                               
+
                        monsters_total = 0; // reset stats?
                        monsters_killed = 0;
-                               
+
                        totalspawned = 0;
-                       
+
                        if(removed_count <= 0)
                                print("No monsters to kill\n");
                        else
-                               print(sprintf("Killed %d monster%s\n", removed_count, ((removed_count == 1) ? "" : "s")));
-                               
+                               printf("Killed %d monster%s\n", removed_count, ((removed_count == 1) ? "" : "s"));
+
                        return; // never fall through to usage
                }
-                       
+
                default:
                case CMD_REQUEST_USAGE:
                {
-                       print("\nUsage:^3 sv_cmd butcher\n");
+                       print("\nUsage:^3 sv_cmd mobbutcher\n");
                        print("  No arguments required.\n");
                        return;
                }
@@ -216,6 +213,8 @@ void GameCommand_allspec(float request, float argc)
                        FOR_EACH_REALPLAYER(client)
                        {
                                self = client;
+                               if(self.caplayer)
+                                       self.caplayer = 0;
                                PutObserverInServer();
                                ++i;
                        }
@@ -479,14 +478,11 @@ void GameCommand_cointoss(float request, float argc)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       entity client;
-                       string result1 = (argv(2) ? strcat("^7", argv(1), "^3!\n") : "^1HEADS^3!\n");
-                       string result2 = (argv(2) ? strcat("^7", argv(2), "^3!\n") : "^4TAILS^3!\n");
+                       string result1 = (argv(2) ? strcat("^7", argv(1)) : "^1HEADS");
+                       string result2 = (argv(2) ? strcat("^7", argv(2)) : "^4TAILS");
                        string choice = ((random() > 0.5) ? result1 : result2);
-
-                       FOR_EACH_CLIENT(client)
-                               centerprint(client, strcat("^3Throwing coin... Result: ", choice));
-                       bprint(strcat("^3Throwing coin... Result: ", choice));
+                       
+                       Send_Notification(NOTIF_ALL, world, MSG_MULTI, MULTI_COINTOSS, choice);
                        return;
                }
 
@@ -1048,6 +1044,8 @@ void GameCommand_moveplayer(float request, float argc)
                                                if(!IS_SPEC(client) && !IS_OBSERVER(client))
                                                {
                                                        self = client;
+                                                       if(self.caplayer)
+                                                               self.caplayer = 0;
                                                        PutObserverInServer();
 
                                                        successful = strcat(successful, (successful ? ", " : ""), client.netname);
@@ -1079,6 +1077,7 @@ void GameCommand_moveplayer(float request, float argc)
                                                                }
                                                                else if(team_id == 0)  // auto team
                                                                {
+                                                                       CheckAllowedTeams(client);
                                                                        team_id = Team_NumberToTeam(FindSmallestTeam(client, FALSE));
                                                                }
                                                                else
@@ -1152,9 +1151,10 @@ void GameCommand_nospectators(float request)
                {
                        blockSpectators = 1;
                        entity plr;
-                       FOR_EACH_CLIENT(plr) //give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
+                       FOR_EACH_REALCLIENT(plr) //give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
                        {
                                if(IS_SPEC(plr) || IS_OBSERVER(plr))
+                               if(!plr.caplayer)
                                {
                                        plr.spectatortime = time;
                                        Send_Notification(NOTIF_ONE_ONLY, plr, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
@@ -1515,7 +1515,9 @@ void GameCommand_trace(float request, float argc)
                        {
                                case "debug":
                                {
+                                       float hitcount = 0;
                                        print("TEST CASE. If this returns the runaway loop counter error, possibly everything is oaky.\n");
+                                       float worst_endpos_bug = 0;
                                        for(;;)
                                        {
                                                org = world.mins;
@@ -1533,49 +1535,49 @@ void GameCommand_trace(float request, float argc)
                                                end = stov(vtos(end));
 
                                                tracebox(start, PL_MIN, PL_MAX, end, MOVE_NOMONSTERS, world);
-                                               if(!trace_startsolid)
+                                               if(!trace_startsolid && trace_fraction < 1)
                                                {
                                                        p = trace_endpos;
                                                        tracebox(p, PL_MIN, PL_MAX, p, MOVE_NOMONSTERS, world);
-                                                       if(trace_startsolid || trace_fraction == 1)
+                                                       if(trace_startsolid)
                                                        {
                                                                rint(42); // do an engine breakpoint on VM_rint so you can get the trace that errnoeously returns startsolid
                                                                tracebox(start, PL_MIN, PL_MAX, end, MOVE_NOMONSTERS, world);
 
-                                                               if(trace_startsolid)
+                                                               // how much do we need to back off?
+                                                               safe = 1;
+                                                               unsafe = 0;
+                                                               for(;;)
                                                                {
-                                                                       // how much do we need to back off?
-                                                                       safe = 1;
-                                                                       unsafe = 0;
-                                                                       for(;;)
+                                                                       pos = p * (1 - (safe + unsafe) * 0.5) + start * ((safe + unsafe) * 0.5);
+                                                                       tracebox(pos, PL_MIN, PL_MAX, pos, MOVE_NOMONSTERS, world);
+                                                                       if(trace_startsolid)
                                                                        {
-                                                                               pos = p * (1 - (safe + unsafe) * 0.5) + start * ((safe + unsafe) * 0.5);
-                                                                               tracebox(pos, PL_MIN, PL_MAX, pos, MOVE_NOMONSTERS, world);
-                                                                               if(trace_startsolid)
-                                                                               {
-                                                                                       if((safe + unsafe) * 0.5 == unsafe)
-                                                                                               break;
-                                                                                       unsafe = (safe + unsafe) * 0.5;
-                                                                               }
-                                                                               else
-                                                                               {
-                                                                                       if((safe + unsafe) * 0.5 == safe)
-                                                                                               break;
-                                                                                       safe = (safe + unsafe) * 0.5;
-                                                                               }
+                                                                               if((safe + unsafe) * 0.5 == unsafe)
+                                                                                       break;
+                                                                               unsafe = (safe + unsafe) * 0.5;
                                                                        }
-
-                                                                       print("safe distance to back off: ", ftos(safe * vlen(p - start)), "qu\n");
-                                                                       print("unsafe distance to back off: ", ftos(unsafe * vlen(p - start)), "qu\n");
-
-                                                                       tracebox(p, PL_MIN + '0.1 0.1 0.1', PL_MAX - '0.1 0.1 0.1', p, MOVE_NOMONSTERS, world);
-                                                                       if(trace_startsolid)
-                                                                               print("trace_endpos much in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n");
                                                                        else
-                                                                               print("trace_endpos just in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n");
-                                                                       break;
+                                                                       {
+                                                                               if((safe + unsafe) * 0.5 == safe)
+                                                                                       break;
+                                                                               safe = (safe + unsafe) * 0.5;
+                                                                       }
                                                                }
 
+                                                               print("safe distance to back off: ", ftos(safe * vlen(p - start)), "qu\n");
+                                                               print("unsafe distance to back off: ", ftos(unsafe * vlen(p - start)), "qu\n");
+
+                                                               tracebox(p, PL_MIN + '0.1 0.1 0.1', PL_MAX - '0.1 0.1 0.1', p, MOVE_NOMONSTERS, world);
+                                                               if(trace_startsolid)
+                                                                       print("trace_endpos much in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n");
+                                                               else
+                                                                       print("trace_endpos just in solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n");
+                                                               if (++hitcount >= 10)
+                                                                       break;
+                                                       }
+                                                       else
+                                                       {
                                                                q0 = p;
                                                                dq = 0;
                                                                dqf = 1;
@@ -1592,11 +1594,13 @@ void GameCommand_trace(float request, float argc)
                                                                        dqf *= 0.5;
                                                                        q0 = q;
                                                                }
-                                                               if(dq > 0)
+                                                               if(dq > worst_endpos_bug)
                                                                {
+                                                                       worst_endpos_bug = dq;
                                                                        print("trace_endpos still before solid when tracing from ", vtos(start), " to ", vtos(end), " endpos ", vtos(p), "\n");
                                                                        print("could go ", ftos(dq), " units further to ", vtos(q), "\n");
-                                                                       break;
+                                                                       if (++hitcount >= 10)
+                                                                               break;
                                                                }
                                                        }
                                                }
@@ -1772,7 +1776,7 @@ 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("butcher", GameCommand_butcher(request), "Instantly removes all monsters on the map") \
+       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") \