]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/command/common.qc
Merge branch 'master' into Mirio/balance
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / common.qc
index 0bdc6672fbf550daa7d2d66b54bdb30cf69b99d3..14965d8c73be1189f3c0abb44675cd0af0ffcedc 100644 (file)
@@ -1,11 +1,12 @@
-#include "../../common/command/command.qh"
 #include "common.qh"
-#include "../_all.qh"
+#include <common/command/command.qh>
+#include "common.qh"
 
 #include "../scores.qh"
 
-#include "../../common/notifications.qh"
-#include "../../common/counting.qh"
+#include <common/monsters/all.qh>
+#include <common/notifications/all.qh>
+#include <lib/warpzone/common.qh>
 
 
 // ====================================================
 // select the proper prefix for usage and other messages
 string GetCommandPrefix(entity caller)
 {
-       if(caller)
-               return "cmd";
-       else
-               return "sv_cmd";
+       if (caller) return "cmd";
+       else return "sv_cmd";
 }
 
 // if client return player nickname, or if server return admin nickname
 string GetCallerName(entity caller)
 {
-       if(caller)
-               return caller.netname;
-       else
-               return admin_name(); //((autocvar_sv_adminnick != "") ? autocvar_sv_adminnick : autocvar_hostname);
+       if (caller) return caller.netname;
+       else return admin_name();  // ((autocvar_sv_adminnick != "") ? autocvar_sv_adminnick : autocvar_hostname);
 }
 
 // verify that the client provided is acceptable for kicking
 float VerifyKickableEntity(entity client)
 {
-       if (!IS_REAL_CLIENT(client))
-               return CLIENT_NOT_REAL;
+       if (!IS_REAL_CLIENT(client)) return CLIENT_NOT_REAL;
        return CLIENT_ACCEPTABLE;
 }
 
 // verify that the client provided is acceptable for use
 float VerifyClientEntity(entity client, float must_be_real, float must_be_bots)
 {
-       if (!IS_CLIENT(client))
-               return CLIENT_DOESNT_EXIST;
-       else if(must_be_real && !IS_REAL_CLIENT(client))
-               return CLIENT_NOT_REAL;
-       else if(must_be_bots && !IS_BOT_CLIENT(client))
-               return CLIENT_NOT_BOT;
+       if (!IS_CLIENT(client)) return CLIENT_DOESNT_EXIST;
+       else if (must_be_real && !IS_REAL_CLIENT(client)) return CLIENT_NOT_REAL;
+       else if (must_be_bots && !IS_BOT_CLIENT(client)) return CLIENT_NOT_BOT;
 
        return CLIENT_ACCEPTABLE;
 }
@@ -55,27 +48,33 @@ float VerifyClientEntity(entity client, float must_be_real, float must_be_bots)
 // if the client is not acceptable, return a string to be used for error messages
 string GetClientErrorString_color(float clienterror, string original_input, string col)
 {
-       switch(clienterror)
+       switch (clienterror)
        {
-               case CLIENT_DOESNT_EXIST: { return strcat(col, "Client '", original_input, col, "' doesn't exist"); }
-               case CLIENT_NOT_REAL: { return strcat(col, "Client '", original_input, col, "' is not real"); }
-               case CLIENT_NOT_BOT: { return strcat(col, "Client '", original_input, col, "' is not a bot"); }
-               default: { return "Incorrect usage of GetClientErrorString"; }
+               case CLIENT_DOESNT_EXIST:
+               { return strcat(col, "Client '", original_input, col, "' doesn't exist");
+               }
+               case CLIENT_NOT_REAL:
+               { return strcat(col, "Client '", original_input, col, "' is not real");
+               }
+               case CLIENT_NOT_BOT:
+               { return strcat(col, "Client '", original_input, col, "' is not a bot");
+               }
+               default:
+               { return "Incorrect usage of GetClientErrorString";
+               }
        }
 }
 
 // is this entity number even in the possible range of entities?
 float VerifyClientNumber(float tmp_number)
 {
-       if((tmp_number < 1) || (tmp_number > maxclients))
-               return false;
-       else
-               return true;
+       if ((tmp_number < 1) || (tmp_number > maxclients)) return false;
+       else return true;
 }
 
 entity GetIndexedEntity(float argc, float start_index)
 {
-       entity tmp_player, selection;
+       entity selection;
        float tmp_number, index;
        string tmp_string;
 
@@ -83,71 +82,79 @@ entity GetIndexedEntity(float argc, float start_index)
        index = start_index;
        selection = world;
 
-       if(argc > start_index)
+       if (argc > start_index)
        {
-               if(substring(argv(index), 0, 1) == "#")
+               if (substring(argv(index), 0, 1) == "#")
                {
                        tmp_string = substring(argv(index), 1, -1);
                        ++index;
 
-                       if(tmp_string != "") // is it all one token? like #1
+                       if (tmp_string != "")  // is it all one token? like #1
                        {
                                tmp_number = stof(tmp_string);
                        }
-                       else if(argc > index) // no, it's two tokens? # 1
+                       else if (argc > index)  // no, it's two tokens? # 1
                        {
                                tmp_number = stof(argv(index));
                                ++index;
                        }
                        else
+                       {
                                tmp_number = 0;
+                       }
                }
-               else // maybe it's ONLY a number?
+               else  // maybe it's ONLY a number?
                {
                        tmp_number = stof(argv(index));
                        ++index;
                }
 
-               if(VerifyClientNumber(tmp_number))
+               if (VerifyClientNumber(tmp_number))
                {
-                       selection = edict_num(tmp_number); // yes, it was a number
+                       selection = edict_num(tmp_number);  // yes, it was a number
                }
-               else // no, maybe it's a name?
+               else  // no, maybe it's a name?
                {
-                       FOR_EACH_CLIENT(tmp_player)
-                               if (strdecolorize(tmp_player.netname) == strdecolorize(argv(start_index)))
-                                       selection = tmp_player;
+                       FOREACH_CLIENT(true, LAMBDA(
+                               if(strdecolorize(it.netname) == strdecolorize(argv(start_index)))
+                               {
+                                       selection = it;
+                                       break; // no reason to keep looking
+                               }
+                       ));
 
                        index = (start_index + 1);
                }
        }
 
        next_token = index;
-       //print(strcat("start_index: ", ftos(start_index), ", next_token: ", ftos(next_token), ", edict: ", ftos(num_for_edict(selection)), ".\n"));
+       // print(strcat("start_index: ", ftos(start_index), ", next_token: ", ftos(next_token), ", edict: ", ftos(num_for_edict(selection)), ".\n"));
        return selection;
 }
 
 // find a player which matches the input string, and return their entity
 entity GetFilteredEntity(string input)
 {
-       entity tmp_player, selection;
+       entity selection;
        float tmp_number;
 
-       if(substring(input, 0, 1) == "#")
-               tmp_number = stof(substring(input, 1, -1));
-       else
-               tmp_number = stof(input);
+       if (substring(input, 0, 1) == "#") tmp_number = stof(substring(input, 1, -1));
+       else tmp_number = stof(input);
 
-       if(VerifyClientNumber(tmp_number))
+       if (VerifyClientNumber(tmp_number))
        {
                selection = edict_num(tmp_number);
        }
        else
        {
                selection = world;
-               FOR_EACH_CLIENT(tmp_player)
-                       if (strdecolorize(tmp_player.netname) == strdecolorize(input))
-                               selection = tmp_player;
+               FOREACH_CLIENT(true, LAMBDA(
+                       if(strdecolorize(it.netname) == strdecolorize(input))
+                       {
+                               selection = it;
+                               break; // no reason to keep looking
+                       }
+               ));
        }
 
        return selection;
@@ -159,7 +166,7 @@ float GetFilteredNumber(string input)
        entity selection = GetFilteredEntity(input);
        float output;
 
-       output = num_for_edict(selection);
+       output = etof(selection);
 
        return output;
 }
@@ -167,10 +174,8 @@ float GetFilteredNumber(string input)
 // switch between sprint and print depending on whether the receiver is the server or a player
 void print_to(entity to, string input)
 {
-    if(to)
-        sprint(to, strcat(input, "\n"));
-    else
-        print(input, "\n");
+       if (to) sprint(to, strcat(input, "\n"));
+       else LOG_INFO(input, "\n");
 }
 
 // ==========================================
@@ -180,6 +185,7 @@ void print_to(entity to, string input)
 // used by CommonCommand_timeout() and CommonCommand_timein() to handle game pausing and messaging and such.
 void timeout_handler_reset()
 {
+       SELFPARAM();
        timeout_caller = world;
        timeout_time = 0;
        timeout_leadtime = 0;
@@ -189,23 +195,22 @@ void timeout_handler_reset()
 
 void timeout_handler_think()
 {
-       entity tmp_player;
-
-       switch(timeout_status)
+       SELFPARAM();
+       switch (timeout_status)
        {
                case TIMEOUT_ACTIVE:
                {
-                       if(timeout_time > 0) // countdown is still going
+                       if (timeout_time > 0)  // countdown is still going
                        {
                                Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_TIMEOUT_ENDING, timeout_time);
 
-                               if(timeout_time == autocvar_sv_timeout_resumetime) // play a warning sound when only <sv_timeout_resumetime> seconds are left
+                               if (timeout_time == autocvar_sv_timeout_resumetime) // play a warning sound when only <sv_timeout_resumetime> seconds are left
                                        Send_Notification(NOTIF_ALL, world, MSG_ANNCE, ANNCE_PREPARE);
 
-                               self.nextthink = time + TIMEOUT_SLOWMO_VALUE; // think again in one second
-                               timeout_time -= 1; // decrease the time counter
+                               self.nextthink = time + TIMEOUT_SLOWMO_VALUE;       // think again in one second
+                               timeout_time -= 1;                                  // decrease the time counter
                        }
-                       else // time to end the timeout
+                       else  // time to end the timeout
                        {
                                timeout_status = TIMEOUT_INACTIVE;
 
@@ -213,8 +218,9 @@ void timeout_handler_think()
                                cvar_set("slowmo", ftos(orig_slowmo));
 
                                // unlock the view for players so they can move around again
-                               FOR_EACH_REALPLAYER(tmp_player)
-                                       tmp_player.fixangle = false;
+                               FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(
+                                       it.fixangle = false;
+                               ));
 
                                timeout_handler_reset();
                        }
@@ -224,14 +230,14 @@ void timeout_handler_think()
 
                case TIMEOUT_LEADTIME:
                {
-                       if(timeout_leadtime > 0) // countdown is still going
+                       if (timeout_leadtime > 0)  // countdown is still going
                        {
                                Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_TIMEOUT_BEGINNING, timeout_leadtime);
 
                                self.nextthink = time + 1; // think again in one second
-                               timeout_leadtime -= 1; // decrease the time counter
+                               timeout_leadtime -= 1;     // decrease the time counter
                        }
-                       else // time to begin the timeout
+                       else  // time to begin the timeout
                        {
                                timeout_status = TIMEOUT_ACTIVE;
 
@@ -239,16 +245,18 @@ void timeout_handler_think()
                                cvar_set("slowmo", ftos(TIMEOUT_SLOWMO_VALUE));
 
                                // reset all the flood variables
-                               FOR_EACH_CLIENT(tmp_player)
-                                       tmp_player.nickspamcount = tmp_player.nickspamtime = tmp_player.floodcontrol_chat =
-                                       tmp_player.floodcontrol_chatteam = tmp_player.floodcontrol_chattell =
-                                       tmp_player.floodcontrol_voice = tmp_player.floodcontrol_voiceteam = 0;
+                               FOREACH_CLIENT(true, LAMBDA(
+                                       it.nickspamcount = it.nickspamtime = it.floodcontrol_chat =
+                                               it.floodcontrol_chatteam = it.floodcontrol_chattell =
+                                                       it.floodcontrol_voice = it.floodcontrol_voiceteam = 0;
+                               ));
 
                                // copy .v_angle to .lastV_angle for every player in order to fix their view during pause (see PlayerPreThink)
-                               FOR_EACH_REALPLAYER(tmp_player)
-                                       tmp_player.lastV_angle = tmp_player.v_angle;
+                               FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(
+                                       it.lastV_angle = it.v_angle;
+                               ));
 
-                               self.nextthink = time; // think again next frame to handle it under TIMEOUT_ACTIVE code
+                               self.nextthink = time;  // think again next frame to handle it under TIMEOUT_ACTIVE code
                        }
 
                        return;
@@ -265,19 +273,18 @@ void timeout_handler_think()
 }
 
 
-
 // ===================================================
 //  Common commands used in both sv_cmd.qc and cmd.qc
 // ===================================================
 
 void CommonCommand_cvar_changes(float request, entity caller)
 {
-       switch(request)
+       switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
                        print_to(caller, cvar_changes);
-                       return; // never fall through to usage
+                       return;  // never fall through to usage
                }
 
                default:
@@ -293,12 +300,12 @@ void CommonCommand_cvar_changes(float request, entity caller)
 
 void CommonCommand_cvar_purechanges(float request, entity caller)
 {
-       switch(request)
+       switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
                        print_to(caller, cvar_purechanges);
-                       return; // never fall through to usage
+                       return;  // never fall through to usage
                }
 
                default:
@@ -312,20 +319,164 @@ void CommonCommand_cvar_purechanges(float request, entity caller)
        }
 }
 
+void CommonCommand_editmob(int request, entity caller, int argc)
+{
+       switch (request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       if (autocvar_g_campaign) { print_to(caller, "Monster editing is disabled in singleplayer"); return; }
+                       // no checks for g_monsters here, as it may be toggled mid match which existing monsters
+
+                       if (caller)
+                       {
+                               makevectors(caller.v_angle);
+                               WarpZone_TraceLine(caller.origin + caller.view_ofs, caller.origin + caller.view_ofs + v_forward * 100, MOVE_NORMAL, caller);
+                       }
+
+                       entity mon = trace_ent;
+                       bool is_visible = IS_MONSTER(mon);
+                       string argument = argv(2);
+
+                       switch (argv(1))
+                       {
+                               case "name":
+                               {
+                                       if (!caller) { print_to(caller, "Only players can edit monsters"); return; }
+                                       if (!argument)   break;  // escape to usage
+                                       if (!autocvar_g_monsters_edit) { print_to(caller, "Monster editing is disabled"); return; }
+                                       if (mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; }
+                                       if (!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; }
+
+                                       string mon_oldname = mon.monster_name;
+
+                                       mon.monster_name = argument;
+                                       if (mon.sprite)   WaypointSprite_UpdateSprites(mon.sprite, WP_Monster, WP_Null, WP_Null);
+                                       print_to(caller, sprintf("Your pet '%s' is now known as '%s'", mon_oldname, mon.monster_name));
+                                       return;
+                               }
+                               case "spawn":
+                               {
+                                       if (!caller) { print_to(caller, "Only players can spawn monsters"); return; }
+                                       if (!argv(2))   break;  // escape to usage
+
+                                       int moveflag, tmp_moncount = 0;
+                                       string arg_lower = strtolower(argument);
+                                       moveflag = (argv(3)) ? stof(argv(3)) : 1;  // follow owner if not defined
+                                       ret_string = "Monster spawning is currently disabled by a mutator";
+
+                                       if (arg_lower == "list") { print_to(caller, monsterlist_reply); return; }
+
+                                       FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(
+                                               if(it.realowner == caller)
+                                                       ++tmp_moncount;
+                                       ));
+
+                                       if (!autocvar_g_monsters) { print_to(caller, "Monsters are disabled"); return; }
+                                       if (autocvar_g_monsters_max <= 0 || autocvar_g_monsters_max_perplayer <= 0) { print_to(caller, "Monster spawning is disabled"); return; }
+                                       if (!IS_PLAYER(caller)) { print_to(caller, "You must be playing to spawn a monster"); return; }
+                                       if (MUTATOR_CALLHOOK(AllowMobSpawning)) { print_to(caller, ret_string); return; }
+                                       if (caller.vehicle) { print_to(caller, "You can't spawn monsters while driving a vehicle"); return; }
+                                       if (STAT(FROZEN, caller)) { print_to(caller, "You can't spawn monsters while frozen"); return; }
+                                       if (IS_DEAD(caller)) { print_to(caller, "You can't spawn monsters while dead"); return; }
+                                       if (tmp_moncount >= autocvar_g_monsters_max) { print_to(caller, "The maximum monster count has been reached"); return; }
+                                       if (tmp_moncount >= autocvar_g_monsters_max_perplayer) { print_to(caller, "You can't spawn any more monsters"); return; }
+
+                                       bool found = false;
+                                       for (int i = MON_FIRST; i <= MON_LAST; ++i)
+                                       {
+                                               mon = get_monsterinfo(i);
+                                               if (mon.netname == arg_lower) { found = true; break; }
+                                       }
+
+                                       if (!found && arg_lower != "random") { print_to(caller, "Invalid monster"); return; }
+
+                                       totalspawned += 1;
+                                       WarpZone_TraceBox(CENTER_OR_VIEWOFS(caller), caller.mins, caller.maxs, CENTER_OR_VIEWOFS(caller) + v_forward * 150, true, caller);
+                                       mon = spawnmonster(arg_lower, 0, caller, caller, trace_endpos, false, false, moveflag);
+                                       print_to(caller, strcat("Spawned ", mon.monster_name));
+                                       return;
+                               }
+                               case "kill":
+                               {
+                                       if (!caller) { print_to(caller, "Only players can kill monsters"); return; }
+                                       if (mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; }
+                                       if (!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; }
+
+                                       Damage(mon, world, world, mon.health + mon.max_health + 200, DEATH_KILL.m_id, mon.origin, '0 0 0');
+                                       print_to(caller, strcat("Your pet '", mon.monster_name, "' has been brutally mutilated"));
+                                       return;
+                               }
+                               case "skin":
+                               {
+                                       if (!caller) { print_to(caller, "Only players can edit monsters"); return; }
+                                       if (!argument)   break;  // escape to usage
+                                       if (!autocvar_g_monsters_edit) { print_to(caller, "Monster editing is disabled"); return; }
+                                       if (!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; }
+                                       if (mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; }
+                                       if (mon.monsterid == MON_MAGE.monsterid) { print_to(caller, "Mage skins can't be changed"); return; }  // TODO
+
+                                       mon.skin = stof(argument);
+                                       print_to(caller, strcat("Monster skin successfully changed to ", ftos(mon.skin)));
+                                       return;
+                               }
+                               case "movetarget":
+                               {
+                                       if (!caller) { print_to(caller, "Only players can edit monsters"); return; }
+                                       if (!argument)   break;  // escape to usage
+                                       if (!autocvar_g_monsters_edit) { print_to(caller, "Monster editing is disabled"); return; }
+                                       if (!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; }
+                                       if (mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; }
+
+                                       mon.monster_moveflags = stof(argument);
+                                       print_to(caller, strcat("Monster move target successfully changed to ", ftos(mon.monster_moveflags)));
+                                       return;
+                               }
+                               case "butcher":
+                               {
+                                       if (caller) { print_to(caller, "This command is not available to players"); return; }
+                                       if (MUTATOR_CALLHOOK(AllowMobButcher)) { LOG_INFO(ret_string, "\n"); return; }
+
+                                       int tmp_remcount = 0;
+
+                                       FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(
+                                               Monster_Remove(it);
+                                               ++tmp_remcount;
+                                       ));
+
+                                       monsters_total = monsters_killed = totalspawned = 0;
+
+                                       print_to(caller, (tmp_remcount) ? sprintf("Killed %d monster%s", tmp_remcount, (tmp_remcount == 1) ? "" : "s") : "No monsters to kill");
+                                       return;
+                               }
+                       }
+               }
+
+               default:
+               case CMD_REQUEST_USAGE:
+               {
+                       print_to(caller, strcat("\nUsage:^3 ", GetCommandPrefix(caller), " editmob command [arguments]"));
+                       print_to(caller, "  Where 'command' can be butcher spawn skin movetarget kill name");
+                       print_to(caller, "  spawn, skin, movetarget and name require 'arguments'");
+                       print_to(caller, "  spawn also takes arguments list and random");
+                       print_to(caller, "  Monster will follow owner if third argument of spawn command is not defined");
+                       return;
+               }
+       }
+}
+
 void CommonCommand_info(float request, entity caller, float argc)
 {
-       switch(request)
+       switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
                        string command = builtin_cvar_string(strcat("sv_info_", argv(1)));
 
-                       if(command)
-                               wordwrap_sprint(command, 1000);
-                       else
-                               print_to(caller, "ERROR: unsupported info command");
+                       if (command) wordwrap_sprint(command, 1000);
+                       else print_to(caller, "ERROR: unsupported info command");
 
-                       return; // never fall through to usage
+                       return;  // never fall through to usage
                }
 
                default:
@@ -340,12 +491,12 @@ void CommonCommand_info(float request, entity caller, float argc)
 
 void CommonCommand_ladder(float request, entity caller)
 {
-       switch(request)
+       switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
                        print_to(caller, ladder_reply);
-                       return; // never fall through to usage
+                       return;  // never fall through to usage
                }
 
                default:
@@ -360,12 +511,12 @@ void CommonCommand_ladder(float request, entity caller)
 
 void CommonCommand_lsmaps(float request, entity caller)
 {
-       switch(request)
+       switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
                        print_to(caller, lsmaps_reply);
-                       return; // never fall through to usage
+                       return;  // never fall through to usage
                }
 
                default:
@@ -380,12 +531,12 @@ void CommonCommand_lsmaps(float request, entity caller)
 
 void CommonCommand_printmaplist(float request, entity caller)
 {
-       switch(request)
+       switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
                        print_to(caller, maplist_reply);
-                       return; // never fall through to usage
+                       return;  // never fall through to usage
                }
 
                default:
@@ -400,12 +551,12 @@ void CommonCommand_printmaplist(float request, entity caller)
 
 void CommonCommand_rankings(float request, entity caller)
 {
-       switch(request)
+       switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
                        print_to(caller, rankings_reply);
-                       return; // never fall through to usage
+                       return;  // never fall through to usage
                }
 
                default:
@@ -420,15 +571,14 @@ void CommonCommand_rankings(float request, entity caller)
 
 void CommonCommand_records(float request, entity caller)
 {
-       switch(request)
+       switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       for(int i = 0; i < 10; ++i)
-                               if(records_reply[i] != "")
-                                       print_to(caller, records_reply[i]);
+                       for (int i = 0; i < 10; ++i)
+                               if (records_reply[i] != "") print_to(caller, records_reply[i]);
 
-                       return; // never fall through to usage
+                       return;  // never fall through to usage
                }
 
                default:
@@ -443,12 +593,12 @@ void CommonCommand_records(float request, entity caller)
 
 void CommonCommand_teamstatus(float request, entity caller)
 {
-       switch(request)
+       switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
                        Score_NicePrint(caller);
-                       return; // never fall through to usage
+                       return;  // never fall through to usage
                }
 
                default:
@@ -463,7 +613,7 @@ void CommonCommand_teamstatus(float request, entity caller)
 
 void CommonCommand_time(float request, entity caller)
 {
-       switch(request)
+       switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
@@ -489,24 +639,27 @@ void CommonCommand_time(float request, entity caller)
 
 void CommonCommand_timein(float request, entity caller)
 {
-       switch(request)
+       switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       if(!caller || autocvar_sv_timeout)
+                       if (!caller || autocvar_sv_timeout)
                        {
                                if (!timeout_status) { print_to(caller, "^7Error: There is no active timeout called."); }
-                               else if(caller && (caller != timeout_caller)) { print_to(caller, "^7Error: You are not allowed to stop the active timeout."); }
+                               else if (caller && (caller != timeout_caller))
+                               {
+                                       print_to(caller, "^7Error: You are not allowed to stop the active timeout.");
+                               }
 
-                               else // everything should be okay, continue aborting timeout
+                               else  // everything should be okay, continue aborting timeout
                                {
-                                       switch(timeout_status)
+                                       switch (timeout_status)
                                        {
                                                case TIMEOUT_LEADTIME:
                                                {
                                                        timeout_status = TIMEOUT_INACTIVE;
                                                        timeout_time = 0;
-                                                       timeout_handler.nextthink = time; // timeout_handler has to take care of it immediately
+                                                       timeout_handler.nextthink = time;  // timeout_handler has to take care of it immediately
                                                        bprint(strcat("^7The timeout was aborted by ", GetCallerName(caller), " !\n"));
                                                        return;
                                                }
@@ -514,18 +667,19 @@ void CommonCommand_timein(float request, entity caller)
                                                case TIMEOUT_ACTIVE:
                                                {
                                                        timeout_time = autocvar_sv_timeout_resumetime;
-                                                       timeout_handler.nextthink = time; // timeout_handler has to take care of it immediately
+                                                       timeout_handler.nextthink = time;  // timeout_handler has to take care of it immediately
                                                        bprint(strcat("^1Attention: ^7", GetCallerName(caller), " resumed the game! Prepare for battle!\n"));
                                                        return;
                                                }
 
-                                               default: dprint("timeout status was inactive, but this code was executed anyway?"); return;
+                                               default: LOG_TRACE("timeout status was inactive, but this code was executed anyway?");
+                                                       return;
                                        }
                                }
                        }
                        else { print_to(caller, "^1Timeins are not allowed to be called, enable them with sv_timeout 1.\n"); }
 
-                       return; // never fall through to usage
+                       return;  // never fall through to usage
                }
 
                default:
@@ -538,29 +692,47 @@ void CommonCommand_timein(float request, entity caller)
        }
 }
 
-void CommonCommand_timeout(float request, entity caller) // DEAR GOD THIS COMMAND IS TERRIBLE.
+void CommonCommand_timeout(float request, entity caller)  // DEAR GOD THIS COMMAND IS TERRIBLE.
 {
-       switch(request)
+       switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       if(!caller || autocvar_sv_timeout)
+                       if (!caller || autocvar_sv_timeout)
                        {
                                float last_possible_timeout = ((autocvar_timelimit * 60) - autocvar_sv_timeout_leadtime - 1);
 
-                               if(timeout_status) { print_to(caller, "^7Error: A timeout is already active."); }
-                               else if(vote_called) { print_to(caller, "^7Error: You can not call a timeout while a vote is active."); }
-                               else if(warmup_stage && !g_warmup_allow_timeout) { print_to(caller, "^7Error: You can not call a timeout in warmup-stage."); }
-                               else if(time < game_starttime) { print_to(caller, "^7Error: You can not call a timeout while the map is being restarted."); }
-                               else if(caller && (caller.allowed_timeouts < 1)) { print_to(caller, "^7Error: You already used all your timeout calls for this map."); }
-                               else if(caller && !IS_PLAYER(caller)) { print_to(caller, "^7Error: You must be a player to call a timeout."); }
-                               else if((autocvar_timelimit) && (last_possible_timeout < time - game_starttime)) { print_to(caller, "^7Error: It is too late to call a timeout now!"); }
-
-                               else // everything should be okay, proceed with starting the timeout
+                               if (timeout_status) { print_to(caller, "^7Error: A timeout is already active."); }
+                               else if (vote_called)
+                               {
+                                       print_to(caller, "^7Error: You can not call a timeout while a vote is active.");
+                               }
+                               else if (warmup_stage && !g_warmup_allow_timeout)
+                               {
+                                       print_to(caller, "^7Error: You can not call a timeout in warmup-stage.");
+                               }
+                               else if (time < game_starttime)
                                {
-                                       if(caller) { caller.allowed_timeouts -= 1; }
+                                       print_to(caller, "^7Error: You can not call a timeout while the map is being restarted.");
+                               }
+                               else if (caller && (caller.allowed_timeouts < 1))
+                               {
+                                       print_to(caller, "^7Error: You already used all your timeout calls for this map.");
+                               }
+                               else if (caller && !IS_PLAYER(caller))
+                               {
+                                       print_to(caller, "^7Error: You must be a player to call a timeout.");
+                               }
+                               else if ((autocvar_timelimit) && (last_possible_timeout < time - game_starttime))
+                               {
+                                       print_to(caller, "^7Error: It is too late to call a timeout now!");
+                               }
 
-                                       bprint(GetCallerName(caller), " ^7called a timeout", (caller ? strcat(" (", ftos(caller.allowed_timeouts), " timeout(s) left)") : ""), "!\n"); // write a bprint who started the timeout (and how many they have left)
+                               else  // everything should be okay, proceed with starting the timeout
+                               {
+                                       if (caller)   caller.allowed_timeouts -= 1;
+                                       // write a bprint who started the timeout (and how many they have left)
+                                       bprint(GetCallerName(caller), " ^7called a timeout", (caller ? strcat(" (", ftos(caller.allowed_timeouts), " timeout(s) left)") : ""), "!\n");
 
                                        timeout_status = TIMEOUT_LEADTIME;
                                        timeout_caller = caller;
@@ -569,14 +741,14 @@ void CommonCommand_timeout(float request, entity caller) // DEAR GOD THIS COMMAN
 
                                        timeout_handler = spawn();
                                        timeout_handler.think = timeout_handler_think;
-                                       timeout_handler.nextthink = time; // always let the entity think asap
+                                       timeout_handler.nextthink = time;  // always let the entity think asap
 
                                        Send_Notification(NOTIF_ALL, world, MSG_ANNCE, ANNCE_TIMEOUT);
                                }
                        }
                        else { print_to(caller, "^1Timeouts are not allowed to be called, enable them with sv_timeout 1.\n"); }
 
-                       return; // never fall through to usage
+                       return;  // never fall through to usage
                }
 
                default:
@@ -591,12 +763,11 @@ void CommonCommand_timeout(float request, entity caller) // DEAR GOD THIS COMMAN
 
 void CommonCommand_who(float request, entity caller, float argc)
 {
-       switch(request)
+       switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
                        float total_listed_players, is_bot;
-                       entity tmp_player;
 
                        float privacy = (caller && autocvar_sv_status_privacy);
                        string separator = strreplace("%", " ", strcat((argv(1) ? argv(1) : " "), "^7"));
@@ -607,41 +778,40 @@ void CommonCommand_who(float request, entity caller, float argc)
                                "ent", "nickname", "ping", "pl", "time", "ip", "crypto_id"));
 
                        total_listed_players = 0;
-                       FOR_EACH_CLIENT(tmp_player)
-                       {
-                               is_bot = (IS_BOT_CLIENT(tmp_player));
+                       FOREACH_CLIENT(true, LAMBDA(
+                               is_bot = (IS_BOT_CLIENT(it));
 
-                               if(is_bot)
+                               if (is_bot)
                                {
                                        tmp_netaddress = "null/botclient";
                                        tmp_crypto_idfp = "null/botclient";
                                }
-                               else if(privacy)
+                               else if (privacy)
                                {
                                        tmp_netaddress = "hidden";
                                        tmp_crypto_idfp = "hidden";
                                }
                                else
                                {
-                                       tmp_netaddress = tmp_player.netaddress;
-                                       tmp_crypto_idfp = tmp_player.crypto_idfp;
+                                       tmp_netaddress = it.netaddress;
+                                       tmp_crypto_idfp = it.crypto_idfp;
                                }
 
                                print_to(caller, sprintf(strreplace(" ", separator, " #%-3d %-20.20s %-5d %-3d %-9s %-16s %s "),
-                                       num_for_edict(tmp_player),
-                                       tmp_player.netname,
-                                       tmp_player.ping,
-                                       tmp_player.ping_packetloss,
-                                       process_time(1, time - tmp_player.jointime),
+                                       etof(it),
+                                       it.netname,
+                                       it.ping,
+                                       it.ping_packetloss,
+                                       process_time(1, time - it.jointime),
                                        tmp_netaddress,
                                        tmp_crypto_idfp));
 
                                ++total_listed_players;
-                       }
+                       ));
 
                        print_to(caller, strcat("Finished listing ", ftos(total_listed_players), " client(s) out of ", ftos(maxclients), " slots."));
 
-                       return; // never fall through to usage
+                       return;  // never fall through to usage
                }
 
                default:
@@ -658,21 +828,21 @@ void CommonCommand_who(float request, entity caller, float argc)
 ** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION!
 void CommonCommand_(float request, entity caller)
 {
-       switch(request)
-       {
-               case CMD_REQUEST_COMMAND:
-               {
-
-                       return; // never fall through to usage
-               }
-
-               default:
-               case CMD_REQUEST_USAGE:
-               {
-                       print_to(caller, strcat("\nUsage:^3 ", GetCommandPrefix(caller), " "));
-                       print_to(caller, "  No arguments required.");
-                       return;
-               }
-       }
+    switch(request)
+    {
+        case CMD_REQUEST_COMMAND:
+        {
+
+            return; // never fall through to usage
+        }
+
+        default:
+        case CMD_REQUEST_USAGE:
+        {
+            print_to(caller, strcat("\nUsage:^3 ", GetCommandPrefix(caller), " "));
+            print_to(caller, "  No arguments required.");
+            return;
+        }
+    }
 }
 */