]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/command/cl_cmd.qc
Merge branch 'master' into Mario/minigames_merge
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / command / cl_cmd.qc
index 942c71938546b25c5f0283c481e29fbe5b021198..9fe33a4fc00cf06d88bc51a93c45d1a20c5f72b0 100644 (file)
@@ -14,6 +14,8 @@
 #include "../mapvoting.qh"
 #include "../miscfunctions.qh"
 
+#include "../mutators/events.qh"
+
 #include "../../common/mapinfo.qh"
 
 #include "../../common/command/generic.qh"
@@ -289,9 +291,15 @@ void LocalCommand_hud(int request, int argc)
                                case "radar":
                                {
                                        if(argv(2))
-                                               hud_panel_radar_maximized = InterpretBoolean(argv(2));
+                                               HUD_Radar_Show_Maximized(InterpretBoolean(argv(2)),0);
                                        else
-                                               hud_panel_radar_maximized = !hud_panel_radar_maximized;
+                                               HUD_Radar_Show_Maximized(!hud_panel_radar_maximized,0);
+                                       return;
+                               }
+
+                               case "clickradar":
+                               {
+                                       HUD_Radar_Show_Maximized(!hud_panel_radar_mouse,1);
                                        return;
                                }
                        }
@@ -360,6 +368,31 @@ void LocalCommand_mv_download(int request, int argc)
        }
 }
 
+void LocalCommand_find(int request, int argc)
+{
+       switch(request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       entity client;
+
+                       for(client = world; (client = find(client, classname, argv(1))); )
+                               print(etos(client), "\n");
+
+                       return;
+               }
+
+               default:
+                       print("Incorrect parameters for ^2find^7\n");
+               case CMD_REQUEST_USAGE:
+               {
+                       print("\nUsage:^3 cl_cmd find classname\n");
+                       print("  Where 'classname' is the classname to search for.\n");
+                       return;
+               }
+       }
+}
+
 void LocalCommand_sendcvar(int request, int argc)
 {
        switch(request)
@@ -431,6 +464,7 @@ void LocalCommand_(int request)
        CLIENT_COMMAND("handlevote", LocalCommand_handlevote(request, arguments), "System to handle selecting a vote or option") \
        CLIENT_COMMAND("hud", LocalCommand_hud(request, arguments), "Commands regarding/controlling the HUD system") \
        CLIENT_COMMAND("localprint", LocalCommand_localprint(request, arguments), "Create your own centerprint sent to yourself") \
+       CLIENT_COMMAND("find", LocalCommand_find(request, arguments), "Search through entities for matching classname") \
        CLIENT_COMMAND("mv_download", LocalCommand_mv_download(request, arguments), "Retrieve mapshot picture from the server") \
        CLIENT_COMMAND("sendcvar", LocalCommand_sendcvar(request, arguments), "Send a cvar to the server (like weaponpriority)") \
        /* nothing */
@@ -493,8 +527,8 @@ void GameCommand(string command)
        // argc:   1    - 2      - 3     - 4
        // argv:   0    - 1      - 2     - 3
        // cmd     vote - master - login - password
-
-       if(strtolower(argv(0)) == "help")
+       string s = strtolower(argv(0));
+       if (s == "help")
        {
                if(argc == 1)
                {
@@ -518,14 +552,11 @@ void GameCommand(string command)
                        return;
                }
        }
-       else if(GenericCommand(command))
-       {
-               return; // handled by common/command/generic.qc
-       }
-       else if(LocalCommand_macro_command(argc)) // continue as usual and scan for normal commands
-       {
-               return; // handled by one of the above LocalCommand_* functions
-       }
+       // continue as usual and scan for normal commands
+       if (GenericCommand(command)// handled by common/command/generic.qc
+       || LocalCommand_macro_command(argc) // handled by one of the above LocalCommand_* functions
+       || MUTATOR_CALLHOOK(CSQC_ConsoleCommand, s, argc, command) // handled by a mutator
+       ) return;
 
        // nothing above caught the command, must be invalid
        print(((command != "") ? strcat("Unknown client command \"", command, "\"") : "No command provided"), ". For a list of supported commands, try cl_cmd help.\n");
@@ -588,14 +619,12 @@ void ConsoleCommand_macro_init()
        #ifndef CAMERATEST
        }
        #endif
-
-       return;
 }
 
-bool ConsoleCommand_macro_normal(int argc)
+bool ConsoleCommand_macro_normal(string s, int argc)
 {
        #define CONSOLE_COMMAND(name,execution) \
-               { if(name == strtolower(argv(0))) { { execution } return true; } }
+               { if (name == s) { { execution } return true; } }
 
        CONSOLE_COMMANDS_NORMAL();
        #undef CONSOLE_COMMAND
@@ -603,12 +632,12 @@ bool ConsoleCommand_macro_normal(int argc)
        return false;
 }
 
-bool ConsoleCommand_macro_movement(int argc)
+bool ConsoleCommand_macro_movement(string s, int argc)
 {
        if(camera_active)
        {
                #define CONSOLE_COMMAND(name,execution) \
-                       { if(name == strtolower(argv(0))) { { execution } return true; } }
+                       { if (name == s) { { execution } return true; } }
 
                CONSOLE_COMMANDS_MOVEMENT();
                #undef CONSOLE_COMMAND
@@ -626,17 +655,9 @@ bool ConsoleCommand_macro_movement(int argc)
 bool CSQC_ConsoleCommand(string command)
 {
        int argc = tokenize_console(command);
-
-       if(ConsoleCommand_macro_normal(argc))
-       {
-               return true;
-       }
-       else if(ConsoleCommand_macro_movement(argc))
-       {
-               return true;
-       }
-
-       // Return value should be 1 if CSQC handled the command, otherwise return 0 to have the engine handle it.
-
-       return false;
+       string s = strtolower(argv(0));
+       // Return value should be true if CSQC handled the command, otherwise return false to have the engine handle it.
+       return (ConsoleCommand_macro_normal(s, argc)
+       || ConsoleCommand_macro_movement(s, argc)
+       );
 }