From: TimePath Date: Sun, 13 Mar 2016 00:31:58 +0000 (+1100) Subject: debug: generic find command X-Git-Tag: xonotic-v0.8.2~1112 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5b5fbd7f5a8b82ebe39c30e3b20b90e84676fbf0;p=xonotic%2Fxonotic-data.pk3dir.git debug: generic find command --- diff --git a/qcsrc/client/commands/cl_cmd.qc b/qcsrc/client/commands/cl_cmd.qc index 873cef258..5e4013973 100644 --- a/qcsrc/client/commands/cl_cmd.qc +++ b/qcsrc/client/commands/cl_cmd.qc @@ -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); } diff --git a/qcsrc/common/command/generic.qc b/qcsrc/common/command/generic.qc index a720796ce..7bfd0ff7d 100644 --- a/qcsrc/common/command/generic.qc +++ b/qcsrc/common/command/generic.qc @@ -27,19 +27,6 @@ // 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) diff --git a/qcsrc/common/command/generic.qh b/qcsrc/common/command/generic.qh index be84c407c..63e1dce83 100644 --- a/qcsrc/common/command/generic.qh +++ b/qcsrc/common/command/generic.qh @@ -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) diff --git a/qcsrc/common/debug.qh b/qcsrc/common/debug.qh index 2dab5a9f5..e1d43f34f 100644 --- a/qcsrc/common/debug.qh +++ b/qcsrc/common/debug.qh @@ -6,12 +6,6 @@ REGISTER_NET_TEMP(net_debug) #endif -#ifdef SVQC - -#include - -#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