]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add "separator" support to who command, limit nicknames to 20 characters, better...
authorSamual <samual@xonotic.org>
Sun, 18 Dec 2011 16:00:18 +0000 (11:00 -0500)
committerSamual <samual@xonotic.org>
Sun, 18 Dec 2011 16:00:18 +0000 (11:00 -0500)
commands.cfg
qcsrc/common/util.qc
qcsrc/server/command/cmd.qc
qcsrc/server/command/common.qc
qcsrc/server/command/sv_cmd.qc

index 4bfd5087f1fd469d47d8b77314a80b498e6981df..8d8e086557083071c50bdf59416204f7bcef73e0 100644 (file)
@@ -16,8 +16,8 @@ alias if_dedicated "${* asis}"
 _if_dedicated alias if_client ""
 if_client alias if_dedicated ""
 
-if_client alias cmd_prefix "cmd"
-if_dedicated alias cmd_prefix "sv_cmd"
+if_client set cmd_prefix "cmd"
+if_dedicated set cmd_prefix "sv_cmd"
 
 
 // ========
@@ -37,7 +37,7 @@ alias time "${cmd_prefix !} time"
 alias timein "${cmd_prefix !} timein"
 alias timeout "${cmd_prefix !} timeout"
 alias vote "${cmd_prefix !} vote ${* ?}"
-alias who "${cmd_prefix !} who"
+alias who "${cmd_prefix !} who ${* ?}"
 
 alias g_hitplots_add "qc_cmd rpn /g_hitplots_individuals g_hitplots_individuals ${1 !} union def"
 alias g_hitplots_remove "qc_cmd rpn /g_hitplots_individuals g_hitplots_individuals ${1 !} difference def"
index 5bb7943fe6d920923e998f3977c45be3c6ccf8d3..afcefd0d378a05a77953959cef53964a9dd6e60a 100644 (file)
@@ -2108,13 +2108,14 @@ float lowestbit(float f)
        return f;
 }
 
+/*
 string strlimitedlen(string input, string truncation, float strip_colors, float limit)
 {
        if(strlen((strip_colors ? strdecolorize(input) : input)) <= limit)
                return input;
        else
                return strcat(substring(input, 0, (strlen(input) - strlen(truncation))), truncation);
-}
+}*/
 
 #ifdef CSQC
 entity ReadCSQCEntity()
index 21521d753241ae54ca034e8276ab66b5fb9d3075..908d0190542d5852d9e2b67fc7ecc86c457149b3 100644 (file)
@@ -565,7 +565,7 @@ void ClientCommand_(float request)
        CLIENT_COMMAND("timeout", CommonCommand_timeout(request, self), "Call a timeout which pauses the game for certain amount of time unless unpaused") \
        CLIENT_COMMAND("voice", ClientCommand_voice(request, arguments, command), "Send voice message via sound") \
        CLIENT_COMMAND("vote", VoteCommand(request, self, arguments, command), "Request an action to be voted upon by players") \
-       CLIENT_COMMAND("who", CommonCommand_who(request, self), "Display detailed client information about all players") \
+       CLIENT_COMMAND("who", CommonCommand_who(request, self, arguments), "Display detailed client information about all players") \
        /* nothing */
        
 void ClientCommand_macro_help()
index d6d4a2dd29edb70c4233f97a5552a512d0c9e5b0..3d10c813701c2666266f1c4cad6f07837370d70c 100644 (file)
@@ -454,18 +454,21 @@ void CommonCommand_timeout(float request, entity caller) // DEAR GOD THIS COMMAN
        }
 }
 
-void CommonCommand_who(float request, entity caller)
+void CommonCommand_who(float request, entity caller, float argc)
 {
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
                {
                        float total_listed_players, tmp_hours, tmp_minutes, tmp_seconds;
-                       entity tmp_player;
-                       //string tmp_player_name;
+                       entity tmp_player;                      
                        
-                       print_to(caller, strcat("List of client information", (autocvar_sv_status_privacy ? " (some data is hidden for privacy)" : string_null), ":"));
-                       print_to(caller, sprintf(" %-4s %-20s %-5s %-3s %-9s %-16s %s", "ent", "nickname", "ping", "pl", "time", "ip", "crypto_id"));
+                       string separator = strcat((argv(1) ? argv(1) : " "), "^7");
+                       float privacy = (caller && autocvar_sv_status_privacy);
+                       
+                       print_to(caller, strcat("List of client information", (privacy ? " (some data is hidden for privacy)" : string_null), ":"));
+                       print_to(caller, sprintf(strreplace(" ", separator, " %-4s %-20s %-5s %-3s %-9s %-16s %s "), 
+                               "ent", "nickname", "ping", "pl", "time", "ip", "crypto_id"));
                        
                        FOR_EACH_CLIENT(tmp_player)
                        {
@@ -478,13 +481,14 @@ void CommonCommand_who(float request, entity caller)
                                if(tmp_minutes) { tmp_seconds -= (tmp_minutes * 60); }                          
                                if(tmp_hours) { tmp_minutes -= (tmp_hours * 60); }
 
-                               print_to(caller, sprintf(" %-4s %-20s %-5d %-3d %-9s %-16s %s"
+                               print_to(caller, sprintf(strreplace(" ", separator, " %-4s %-20.20s %-5d %-3d %-9s %-16s %s ")
                                        strcat("#", ftos(num_for_edict(tmp_player))), 
-                                       tmp_player.netname, //strcat(tmp_player_name, sprintf("%*s", (20 - strlen(strdecolorize(tmp_player_name))), "")),
-                                       tmp_player.ping, tmp_player.ping_packetloss, 
+                                       tmp_player.netname,
+                                       tmp_player.ping, 
+                                       tmp_player.ping_packetloss, 
                                        sprintf("%02d:%02d:%02d", tmp_hours, tmp_minutes, tmp_seconds),
-                                       (autocvar_sv_status_privacy ? "hidden" : tmp_player.netaddress),
-                                       (autocvar_sv_status_privacy ? "hidden" : tmp_player.crypto_idfp)));
+                                       (privacy ? "hidden" : tmp_player.netaddress),
+                                       (privacy ? "hidden" : tmp_player.crypto_idfp)));
                                        
                                ++total_listed_players;
                        }
@@ -497,8 +501,8 @@ void CommonCommand_who(float request, entity caller)
                default:
                case CMD_REQUEST_USAGE:
                {
-                       print_to(caller, strcat("\nUsage:^3 ", GetCommandPrefix(caller), " who"));
-                       print_to(caller, "  No arguments required.");
+                       print_to(caller, strcat("\nUsage:^3 ", GetCommandPrefix(caller), " who [separator]"));
+                       print_to(caller, "  Where 'separator' is the optional string to separate the values with, default is a space.");
                        return;
                }
        }
index 34e302458d2fd8294c7c41f6f12441a4df94f0d6..6b43308db273a05dc1602c3a2536309f6ba42e52 100644 (file)
@@ -1760,7 +1760,7 @@ void GameCommand_(float request)
        SERVER_COMMAND("trace", GameCommand_trace(request, arguments), "Various debugging tools with tracing") \
        SERVER_COMMAND("unlockteams", GameCommand_unlockteams(request), "Enable the ability for players to switch or enter teams") \
        SERVER_COMMAND("warp", GameCommand_warp(request, arguments), "Choose different level in campaign") \
-       SERVER_COMMAND("who", CommonCommand_who(request, world), "Display detailed client information about all players") \
+       SERVER_COMMAND("who", CommonCommand_who(request, world, arguments), "Display detailed client information about all players") \
        SERVER_COMMAND("vote", VoteCommand(request, world, arguments, command), "Server side control of voting") \
        /* nothing */