]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/command/sv_cmd.qc
Manual riddance of remaining "if not".
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / sv_cmd.qc
index 0710ddfa8474874cca23787d9ed6221e44660ebd..7dbafa7ab8b747d888e1e06868a3717938463d3a 100644 (file)
@@ -93,7 +93,7 @@ void GameCommand_adminmsg(float request, float argc)
                                        client = GetFilteredEntity(t);
                                        accepted = VerifyClientEntity(client, TRUE, FALSE);
                                        
                                        client = GetFilteredEntity(t);
                                        accepted = VerifyClientEntity(client, TRUE, FALSE);
                                        
-                                       if not(accepted > 0) 
+                                       if(accepted <= 0) 
                                        {
                                                print("adminmsg: ", GetClientErrorString(accepted, t), (targets ? ", skipping to next player.\n" : ".\n")); 
                                                continue;
                                        {
                                                print("adminmsg: ", GetClientErrorString(accepted, t), (targets ? ", skipping to next player.\n" : ".\n")); 
                                                continue;
@@ -736,7 +736,12 @@ void GameCommand_gametype(float request, float argc)
                                        MapInfo_SwitchGameType(t);
                                        MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
                                        if(MapInfo_count > 0)
                                        MapInfo_SwitchGameType(t);
                                        MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
                                        if(MapInfo_count > 0)
+                                       {
+                                               // update lsmaps in case the gametype changed, this way people can easily list maps for it
+                                               if(lsmaps_reply != "") { strunzone(lsmaps_reply); }
+                                               lsmaps_reply = strzone(getlsmaps());
                                                bprint("Game type successfully switched to ", s, "\n");
                                                bprint("Game type successfully switched to ", s, "\n");
+                                       }
                                        else
                                        {
                                                bprint("Cannot use this game type: no map for it found\n");
                                        else
                                        {
                                                bprint("Cannot use this game type: no map for it found\n");
@@ -972,7 +977,6 @@ void GameCommand_moveplayer(float request, float argc)
                        string targets = strreplace(",", " ", argv(1));
                        string original_targets = strreplace(" ", ", ", targets);
                        string destination = argv(2);
                        string targets = strreplace(",", " ", argv(1));
                        string original_targets = strreplace(" ", ", ", targets);
                        string destination = argv(2);
-                       string notify = argv(3);
                        
                        string successful, t;
                        successful = string_null;
                        
                        string successful, t;
                        successful = string_null;
@@ -988,7 +992,7 @@ void GameCommand_moveplayer(float request, float argc)
                                        client = GetFilteredEntity(t);
                                        accepted = VerifyClientEntity(client, FALSE, FALSE);
                                        
                                        client = GetFilteredEntity(t);
                                        accepted = VerifyClientEntity(client, FALSE, FALSE);
                                        
-                                       if not(accepted > 0) 
+                                       if(accepted <= 0) 
                                        {
                                                print("moveplayer: ", GetClientErrorString(accepted, t), (targets ? ", skipping to next player.\n" : ".\n")); 
                                                continue;
                                        {
                                                print("moveplayer: ", GetClientErrorString(accepted, t), (targets ? ", skipping to next player.\n" : ".\n")); 
                                                continue;
@@ -997,7 +1001,7 @@ void GameCommand_moveplayer(float request, float argc)
                                        // Where are we putting this player?
                                        if(destination == "spec" || destination == "spectator") 
                                        {
                                        // Where are we putting this player?
                                        if(destination == "spec" || destination == "spectator") 
                                        {
-                                               if(client.classname != "spectator" && client.classname != "observer")
+                                               if(!IS_SPEC(client) && !IS_OBSERVER(client))
                                                {
                                                        self = client;
                                                        PutObserverInServer();
                                                {
                                                        self = client;
                                                        PutObserverInServer();
@@ -1012,26 +1016,26 @@ void GameCommand_moveplayer(float request, float argc)
                                        }
                                        else
                                        {
                                        }
                                        else
                                        {
-                                               if(client.classname != "spectator" && client.classname != "observer")
+                                               if(!IS_SPEC(client) && !IS_OBSERVER(client))
                                                {
                                                        if(teamplay)
                                                        {
                                                                // set up
                                                {
                                                        if(teamplay)
                                                        {
                                                                // set up
-                                                               float team_color;
+                                                               float team_id;
                                                                float save = client.team_forced;
                                                                client.team_forced = 0;
 
                                                                // find the team to move the player to
                                                                float save = client.team_forced;
                                                                client.team_forced = 0;
 
                                                                // find the team to move the player to
-                                                               team_color = ColourToNumber(destination);
-                                                               if(team_color == client.team) // already on the destination team
+                                                               team_id = Team_ColorToTeam(destination);
+                                                               if(team_id == client.team) // already on the destination team
                                                                {
                                                                        // keep the forcing undone
                                                                {
                                                                        // keep the forcing undone
-                                                                       print("Player ", ftos(GetFilteredNumber(t)), " (", client.netname, ") is already on the ", ColoredTeamName(client.team), (targets ? ", skipping to next player.\n" : ".\n"));
+                                                                       print("Player ", ftos(GetFilteredNumber(t)), " (", client.netname, ") is already on the ", Team_ColoredFullName(client.team), (targets ? "^7, skipping to next player.\n" : "^7.\n"));
                                                                        continue;
                                                                } 
                                                                        continue;
                                                                } 
-                                                               else if(team_color == 0)  // auto team
+                                                               else if(team_id == 0)  // auto team
                                                                {
                                                                {
-                                                                       team_color = NumberToTeamNumber(FindSmallestTeam(client, FALSE));
+                                                                       team_id = Team_NumberToTeam(FindSmallestTeam(client, FALSE));
                                                                }
                                                                else
                                                                {
                                                                }
                                                                else
                                                                {
@@ -1040,21 +1044,21 @@ void GameCommand_moveplayer(float request, float argc)
                                                                client.team_forced = save;
                                                                
                                                                // Check to see if the destination team is even available
                                                                client.team_forced = save;
                                                                
                                                                // Check to see if the destination team is even available
-                                                               switch(team_color
+                                                               switch(team_id
                                                                {
                                                                {
-                                                                       case COLOR_TEAM1: if(c1 == -1) { print("Sorry, can't move player to red team if it doesn't exist.\n"); return; } break;
-                                                                       case COLOR_TEAM2: if(c2 == -1) { print("Sorry, can't move player to blue team if it doesn't exist.\n"); return; } break;
-                                                                       case COLOR_TEAM3: if(c3 == -1) { print("Sorry, can't move player to yellow team if it doesn't exist.\n"); return; } break;
-                                                                       case COLOR_TEAM4: if(c4 == -1) { print("Sorry, can't move player to pink team if it doesn't exist.\n"); return; } break;
+                                                                       case NUM_TEAM_1: if(c1 == -1) { print("Sorry, can't move player to red team if it doesn't exist.\n"); return; } break;
+                                                                       case NUM_TEAM_2: if(c2 == -1) { print("Sorry, can't move player to blue team if it doesn't exist.\n"); return; } break;
+                                                                       case NUM_TEAM_3: if(c3 == -1) { print("Sorry, can't move player to yellow team if it doesn't exist.\n"); return; } break;
+                                                                       case NUM_TEAM_4: if(c4 == -1) { print("Sorry, can't move player to pink team if it doesn't exist.\n"); return; } break;
                                                                        
                                                                        default: print("Sorry, can't move player here if team ", destination, " doesn't exist.\n"); return;
                                                                }
                                                                
                                                                // If so, lets continue and finally move the player
                                                                client.team_forced = 0;
                                                                        
                                                                        default: print("Sorry, can't move player here if team ", destination, " doesn't exist.\n"); return;
                                                                }
                                                                
                                                                // If so, lets continue and finally move the player
                                                                client.team_forced = 0;
-                                                               MoveToTeam(client, team_color, 6, stof(notify));
+                                                               MoveToTeam(client, team_id, 6);
                                                                successful = strcat(successful, (successful ? ", " : ""), client.netname);
                                                                successful = strcat(successful, (successful ? ", " : ""), client.netname);
-                                                               print("Player ", ftos(GetFilteredNumber(t)), " (", client.netname, ") has been moved to the ", ColoredTeamName(team_color), ".\n");
+                                                               print("Player ", ftos(GetFilteredNumber(t)), " (", client.netname, ") has been moved to the ", Team_ColoredFullName(team_id), "^7.\n");
                                                                continue;
                                                        }
                                                        else
                                                                continue;
                                                        }
                                                        else
@@ -1084,13 +1088,10 @@ void GameCommand_moveplayer(float request, float argc)
                        print("Incorrect parameters for ^2moveplayer^7\n");
                case CMD_REQUEST_USAGE:
                {
                        print("Incorrect parameters for ^2moveplayer^7\n");
                case CMD_REQUEST_USAGE:
                {
-                       print("\nUsage:^3 sv_cmd moveplayer clients destination [notify]\n");
+                       print("\nUsage:^3 sv_cmd moveplayer clients destination\n");
                        print("  'clients' is a list (separated by commas) of player entity ID's or nicknames\n");
                        print("  'destination' is what to send the player to, be it team or spectating\n");
                        print("  Full list of destinations here: \"spec, spectator, red, blue, yellow, pink, auto.\"\n");
                        print("  'clients' is a list (separated by commas) of player entity ID's or nicknames\n");
                        print("  'destination' is what to send the player to, be it team or spectating\n");
                        print("  Full list of destinations here: \"spec, spectator, red, blue, yellow, pink, auto.\"\n");
-                       print("  'notify' is whether or not to send messages notifying of the move. Detail below.\n");
-                       print("    0 (00) automove centerprint, admin message; 1 (01) automove centerprint, no admin message\n");
-                       print("    2 (10) no centerprint, admin message; 3 (11) no centerprint, no admin message\n");
                        print("Examples: sv_cmd moveplayer 1,3,5 red 3\n");
                        print("          sv_cmd moveplayer 2 spec \n");
                        print("See also: ^2allspec, shuffleteams^7\n");
                        print("Examples: sv_cmd moveplayer 1,3,5 red 3\n");
                        print("          sv_cmd moveplayer 2 spec \n");
                        print("See also: ^2allspec, shuffleteams^7\n");
@@ -1109,10 +1110,10 @@ void GameCommand_nospectators(float request)
                        entity plr;
                        FOR_EACH_CLIENT(plr) //give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
                        {
                        entity plr;
                        FOR_EACH_CLIENT(plr) //give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
                        {
-                               if(plr.classname == "spectator" || plr.classname == "observer")
+                               if(IS_SPEC(plr) || IS_OBSERVER(plr))
                                {
                                        plr.spectatortime = time;
                                {
                                        plr.spectatortime = time;
-                                       sprint(plr, strcat("^7You have to become a player within the next ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
+                                       Send_Notification(NOTIF_ONE_ONLY, plr, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
                                }
                        }
                        bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds!\n"));
                                }
                        }
                        bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds!\n"));
@@ -1147,7 +1148,7 @@ void GameCommand_playerdemo(float request, float argc)
                                                client = GetIndexedEntity(argc, 2);
                                                accepted = VerifyClientEntity(client, FALSE, TRUE);
                                                
                                                client = GetIndexedEntity(argc, 2);
                                                accepted = VerifyClientEntity(client, FALSE, TRUE);
                                                
-                                               if not(accepted > 0) 
+                                               if(accepted <= 0) 
                                                {
                                                        print("playerdemo: read: ", GetClientErrorString(accepted, argv(2)), ".\n"); 
                                                        return;
                                                {
                                                        print("playerdemo: read: ", GetClientErrorString(accepted, argv(2)), ".\n"); 
                                                        return;
@@ -1163,7 +1164,7 @@ void GameCommand_playerdemo(float request, float argc)
                                                client = GetIndexedEntity(argc, 2);
                                                accepted = VerifyClientEntity(client, FALSE, FALSE);
                                                
                                                client = GetIndexedEntity(argc, 2);
                                                accepted = VerifyClientEntity(client, FALSE, FALSE);
                                                
-                                               if not(accepted > 0) 
+                                               if(accepted <= 0) 
                                                {
                                                        print("playerdemo: write: ", GetClientErrorString(accepted, argv(2)), ".\n"); 
                                                        return;
                                                {
                                                        print("playerdemo: write: ", GetClientErrorString(accepted, argv(2)), ".\n"); 
                                                        return;
@@ -1354,21 +1355,21 @@ void GameCommand_shuffleteams(float request)
                                        x = (t_players / t_teams);
                                        x = ((i == 1) ? ceil(x) : floor(x));
                                        
                                        x = (t_players / t_teams);
                                        x = ((i == 1) ? ceil(x) : floor(x));
                                        
-                                       team_color = NumberToTeamNumber(i);
+                                       team_color = Team_NumberToTeam(i);
                                        
                                        // sort through the random list of players made earlier 
                                        for(z = 1; z <= maxclients; ++z)
                                        {                                                       
                                        
                                        // sort through the random list of players made earlier 
                                        for(z = 1; z <= maxclients; ++z)
                                        {                                                       
-                                               if not(shuffleteams_teams[i] >= x)
+                                               if (!(shuffleteams_teams[i] >= x))
                                                {
                                                {
-                                                       if not(shuffleteams_players[z])
+                                                       if (!(shuffleteams_players[z]))
                                                                continue; // not a player, move on to next random slot
                                                                
                                                        if(VerifyClientNumber(shuffleteams_players[z]))
                                                                self = edict_num(shuffleteams_players[z]);
 
                                                        if(self.team != team_color) 
                                                                continue; // not a player, move on to next random slot
                                                                
                                                        if(VerifyClientNumber(shuffleteams_players[z]))
                                                                self = edict_num(shuffleteams_players[z]);
 
                                                        if(self.team != team_color) 
-                                                               MoveToTeam(self, team_color, 6, 0);
+                                                               MoveToTeam(self, team_color, 6);
 
                                                        shuffleteams_players[z] = 0;
                                                        shuffleteams_teams[i] = shuffleteams_teams[i] + 1;
 
                                                        shuffleteams_players[z] = 0;
                                                        shuffleteams_teams[i] = shuffleteams_teams[i] + 1;
@@ -1413,8 +1414,9 @@ void GameCommand_stuffto(float request, float argc)
        // This... is a fairly dangerous and powerful command... - It allows any arguments to be sent to a client via rcon.
        // Because of this, it is disabled by default and must be enabled by the server owner when doing compilation. That way,
        // we can be certain they understand the risks of it... So to enable, compile server with -DSTUFFTO_ENABLED argument.
        // This... is a fairly dangerous and powerful command... - It allows any arguments to be sent to a client via rcon.
        // Because of this, it is disabled by default and must be enabled by the server owner when doing compilation. That way,
        // we can be certain they understand the risks of it... So to enable, compile server with -DSTUFFTO_ENABLED argument.
-       
+
        #ifdef STUFFTO_ENABLED
        #ifdef STUFFTO_ENABLED
+       #message "stuffto command enabled"
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -1591,10 +1593,10 @@ void GameCommand_trace(float request, float argc)
                                
                                case "walk":
                                {
                                
                                case "walk":
                                {
-                                       if(argc == 3)
+                                       if(argc == 4)
                                        {
                                                e = nextent(world);
                                        {
                                                e = nextent(world);
-                                               if(tracewalk(e, stov(argv(1)), e.mins, e.maxs, stov(argv(2)), MOVE_NORMAL))
+                                               if(tracewalk(e, stov(argv(2)), e.mins, e.maxs, stov(argv(3)), MOVE_NORMAL))
                                                        print("can walk\n");
                                                else
                                                        print("cannot walk\n");
                                                        print("can walk\n");
                                                else
                                                        print("cannot walk\n");
@@ -1604,10 +1606,10 @@ void GameCommand_trace(float request, float argc)
                                
                                case "showline":
                                {
                                
                                case "showline":
                                {
-                                       if(argc == 3)
+                                       if(argc == 4)
                                        {
                                        {
-                                               vv = stov(argv(1));
-                                               dv = stov(argv(2));
+                                               vv = stov(argv(2));
+                                               dv = stov(argv(3));
                                                traceline(vv, dv, MOVE_NORMAL, world);
                                                trailparticles(world, particleeffectnum("TR_NEXUIZPLASMA"), vv, trace_endpos);
                                                trailparticles(world, particleeffectnum("TR_CRYLINKPLASMA"), trace_endpos, dv);
                                                traceline(vv, dv, MOVE_NORMAL, world);
                                                trailparticles(world, particleeffectnum("TR_NEXUIZPLASMA"), vv, trace_endpos);
                                                trailparticles(world, particleeffectnum("TR_CRYLINKPLASMA"), trace_endpos, dv);
@@ -1724,7 +1726,6 @@ void GameCommand_(float request)
 // ==================================
 
 // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
 // ==================================
 
 // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
-// Common commands have double indentation to separate them a bit.
 #define SERVER_COMMANDS(request,arguments,command) \
        SERVER_COMMAND("adminmsg", GameCommand_adminmsg(request, arguments), "Send an admin message to a client directly") \
        SERVER_COMMAND("allready", GameCommand_allready(request), "Restart the server and reset the players") \
 #define SERVER_COMMANDS(request,arguments,command) \
        SERVER_COMMAND("adminmsg", GameCommand_adminmsg(request, arguments), "Send an admin message to a client directly") \
        SERVER_COMMAND("allready", GameCommand_allready(request), "Restart the server and reset the players") \