]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
debug: generic find command
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 13 Mar 2016 00:31:58 +0000 (11:31 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 13 Mar 2016 00:32:22 +0000 (11:32 +1100)
qcsrc/client/commands/cl_cmd.qc
qcsrc/common/command/generic.qc
qcsrc/common/command/generic.qh
qcsrc/common/debug.qh

index 873cef25893d66ac2c5feb726027189c8002d398..5e4013973ae1addfd62cfb05d604b35219c36073 100644 (file)
@@ -395,29 +395,6 @@ void LocalCommand_mv_download(int request, int argc)
        }
 }
 
-void LocalCommand_find(int request, int argc)
-{
-       switch (request)
-       {
-               case CMD_REQUEST_COMMAND:
-               {
-                       FOREACH_ENTITY_CLASS(argv(1), true, LAMBDA(LOG_INFO(etos(it), "\n")));
-                       return;
-               }
-
-               default:
-               {
-                       LOG_INFO("Incorrect parameters for ^2find^7\n");
-               }
-               case CMD_REQUEST_USAGE:
-               {
-                       LOG_INFO("\nUsage:^3 cl_cmd find classname\n");
-                       LOG_INFO("  Where 'classname' is the classname to search for.\n");
-                       return;
-               }
-       }
-}
-
 void LocalCommand_sendcvar(int request, int argc)
 {
        switch (request)
@@ -490,7 +467,6 @@ CLIENT_COMMAND(debugmodel, "Spawn a debug model manually") { LocalCommand_debugm
 CLIENT_COMMAND(handlevote, "System to handle selecting a vote or option") { LocalCommand_handlevote(request, arguments); }
 CLIENT_COMMAND(hud, "Commands regarding/controlling the HUD system") { LocalCommand_hud(request, arguments); }
 CLIENT_COMMAND(localprint, "Create your own centerprint sent to yourself") { LocalCommand_localprint(request, arguments); }
-CLIENT_COMMAND(find, "Search through entities for matching classname") { LocalCommand_find(request, arguments); }
 CLIENT_COMMAND(mv_download, "Retrieve mapshot picture from the server") { LocalCommand_mv_download(request, arguments); }
 CLIENT_COMMAND(sendcvar, "Send a cvar to the server (like weaponpriority)") { LocalCommand_sendcvar(request, arguments); }
 
index a720796ce13821968cbab0722e5ca1d9b141fea5..7bfd0ff7dadb10aa51425bfdeb3dd159958bcb58 100644 (file)
 //  Last updated: February 19th, 2012
 // =========================================================
 
-// used by generic commands for better help/usage information
-string GetProgramCommandPrefix()
-{
-       #ifdef SVQC
-       return "sv_cmd";
-       #endif
-       #ifdef CSQC
-       return "cl_cmd";
-       #endif
-       #ifdef MENUQC
-       return "menu_cmd";
-       #endif
-}
 
 // used by curl command
 void Curl_URI_Get_Callback(int id, float status, string data)
index be84c407ca193c3e4316f16d68e7950f4548b082..63e1dce83b9bfbabbf3b0a4aa0a779b622c6dd98 100644 (file)
@@ -22,7 +22,13 @@ void GenericCommand_macro_write_aliases(float fh);
 float GenericCommand(string command);
 
 // Returns command prefix specific for whatever program it is compiled in
-string GetProgramCommandPrefix();
+#ifdef SVQC
+       #define GetProgramCommandPrefix() "sv_cmd"
+#elif defined(CSQC)
+       #define GetProgramCommandPrefix() "cl_cmd"
+#elif defined(MENUQC)
+       #define GetProgramCommandPrefix() "menu_cmd"
+#endif
 
 // used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
 #define CMD_Write(s) fputs(fh, s)
index 2dab5a9f51337fbf6d0061cdb45a64b8a1cb3974..e1d43f34fefc2e18c9947ea563de7c27d20cfce3 100644 (file)
@@ -6,12 +6,6 @@
 REGISTER_NET_TEMP(net_debug)
 #endif
 
-#ifdef SVQC
-
-#include <server/command/all.qh>
-
-#endif
-
 #ifdef CSQC
        NET_HANDLE(net_debug, bool isNew)
        {
@@ -282,37 +276,37 @@ STATIC_INIT(TRACE_ENT)
 }
 #endif
 
-#ifdef SVQC
-SERVER_COMMAND(find, "Search through entities for matching classname")
+GENERIC_COMMAND(find, "Search through entities for matching classname")
 {
        switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       for (entity client = NULL; (client = find(client, classname, argv(1))); )
-                               LOG_INFO(etos(client), "\n");
+                       FOREACH_ENTITY_CLASS_ORDERED(argv(1), true, LAMBDA(LOG_INFOF("%i (%s)\n", it, it.classname)));
                        return;
                }
 
                default:
+               {
                        LOG_INFO("Incorrect parameters for ^2find^7\n");
+        }
                case CMD_REQUEST_USAGE:
                {
-                       LOG_INFO("\nUsage:^3 sv_cmd find classname\n");
+                       LOG_INFO("\nUsage:^3 " GetProgramCommandPrefix() " find classname\n");
                        LOG_INFO("  Where 'classname' is the classname to search for.\n");
                        return;
                }
        }
 }
 
-SERVER_COMMAND(findat, "Search through entities for matching origin")
+GENERIC_COMMAND(findat, "Search through entities for matching origin")
 {
        switch (request)
        {
                case CMD_REQUEST_COMMAND:
                {
                    vector match = stov(argv(1));
-                   FOREACH_ENTITY_ORDERED(it.origin == match, LAMBDA(LOG_INFOF("%i\n", it)));
+                   FOREACH_ENTITY_ORDERED(it.origin == match, LAMBDA(LOG_INFOF("%i (%s)\n", it, it.classname)));
                        return;
                }
 
@@ -320,9 +314,8 @@ SERVER_COMMAND(findat, "Search through entities for matching origin")
                        LOG_INFO("Incorrect parameters for ^2findat^7\n");
                case CMD_REQUEST_USAGE:
                {
-                       LOG_INFO("\nUsage:^3 sv_cmd findat \"0 0 0\"\n");
+                       LOG_INFO("\nUsage:^3 " GetProgramCommandPrefix() " findat \"0 0 0\"\n");
                        return;
                }
        }
 }
-#endif