X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fcommand%2Fgeneric.qc;h=9b4cdfe8a1c441006f3311319c583bd13ae60757;hb=eb877d9a99429c3ffc846377fac46fb750af8620;hp=8f3449b3e16cfaef91bcc8b0b0bd47171deb8523;hpb=3e21073f2bd7f282947bc1f214b3ec25d69ccae0;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/command/generic.qc b/qcsrc/common/command/generic.qc index 8f3449b3e..9b4cdfe8a 100644 --- a/qcsrc/common/command/generic.qc +++ b/qcsrc/common/command/generic.qc @@ -1,11 +1,13 @@ -#include "all.qh" +#include "generic.qh" +#include "_mod.qh" +#include "reg.qh" #include "markup.qh" #include "rpn.qh" #include "../mapinfo.qh" -#ifndef MENUQC +#ifdef GAMEQC #include "../notifications/all.qh" #endif @@ -14,10 +16,7 @@ #endif #ifdef SVQC - #include - #include - #include - #include + #include #include #include #endif @@ -75,13 +74,12 @@ void GenericCommand_addtolist(float request, float argc) } else // add it to the end of the list if the list doesn't already have it { - argc = tokenizebyseparator(cvar_string(original_cvar), " "); - int i; - for(i = 0; i < argc; ++i) - if(argv(i) == tmp_string) - return; // already in list + FOREACH_WORD(cvar_string(original_cvar), it == tmp_string, + { + return; // already in the list + }); - cvar_set(original_cvar, strcat(tmp_string, " ", cvar_string(original_cvar))); + cvar_set(original_cvar, cons(cvar_string(original_cvar), tmp_string)); } return; } @@ -91,7 +89,7 @@ void GenericCommand_addtolist(float request, float argc) LOG_INFO("Incorrect parameters for ^2addtolist^7\n"); case CMD_REQUEST_USAGE: { - LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " addtolist variable value\n")); + LOG_INFO("Usage:^3 ", GetProgramCommandPrefix(), " addtolist variable value\n"); LOG_INFO(" Where 'variable' is what to add 'value' to.\n"); LOG_INFO("See also: ^2removefromlist^7\n"); return; @@ -165,7 +163,7 @@ void GenericCommand_qc_curl(float request, float argc) default: case CMD_REQUEST_USAGE: { - LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " qc_curl [--key N] [--cvar] [--exec] URL [postargs...]")); + LOG_INFO("Usage:^3 ", GetProgramCommandPrefix(), " qc_curl [--key N] [--cvar] [--exec] URL [postargs...]"); return; } } @@ -219,7 +217,7 @@ GENERIC_COMMAND(dumpcommands, "Dump all commands on the program to *_cmd_dump.tx default: case CMD_REQUEST_USAGE: { - LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpcommands")); + LOG_INFO("Usage:^3 ", GetProgramCommandPrefix(), " dumpcommands"); LOG_INFO(" No arguments required.\n"); return; } @@ -300,7 +298,7 @@ void GenericCommand_maplist(float request, float argc) LOG_INFO("Incorrect parameters for ^2maplist^7\n"); case CMD_REQUEST_USAGE: { - LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " maplist action [map]\n")); + LOG_INFO("Usage:^3 ", GetProgramCommandPrefix(), " maplist action [map]\n"); LOG_INFO(" Where 'action' is the command to complete,\n"); LOG_INFO(" and 'map' is what it acts upon (if required).\n"); LOG_INFO(" Full list of commands here: \"add, cleanup, remove, shuffle.\"\n"); @@ -322,7 +320,7 @@ void GenericCommand_nextframe(float request, float arguments, string command) default: case CMD_REQUEST_USAGE: { - LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " nextframe command...\n")); + LOG_INFO("Usage:^3 ", GetProgramCommandPrefix(), " nextframe command...\n"); LOG_INFO(" Where command will be executed next frame of this VM\n"); return; } @@ -337,19 +335,15 @@ void GenericCommand_removefromlist(float request, float argc) { if(argc == 3) { - float i; string original_cvar = argv(1); string removal = argv(2); - string tmp_string; - argc = tokenizebyseparator(cvar_string(original_cvar), " "); - - tmp_string = ""; - for(i = 0; i < argc; ++i) - if(argv(i) != removal) - tmp_string = strcat(tmp_string, " ", argv(i)); + string tmp_string = ""; + FOREACH_WORD(cvar_string(original_cvar), it != removal, + { + tmp_string = cons(tmp_string, it); + }); - tmp_string = substring(tmp_string, 1, strlen(tmp_string) - 1); cvar_set(original_cvar, tmp_string); return; @@ -360,7 +354,7 @@ void GenericCommand_removefromlist(float request, float argc) LOG_INFO("Incorrect parameters for ^2removefromlist^7\n"); case CMD_REQUEST_USAGE: { - LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " removefromlist variable value\n")); + LOG_INFO("Usage:^3 ", GetProgramCommandPrefix(), " removefromlist variable value\n"); LOG_INFO(" Where 'variable' is what cvar to remove 'value' from.\n"); LOG_INFO("See also: ^2addtolist^7\n"); return; @@ -374,7 +368,7 @@ void GenericCommand_restartnotifs(float request) { case CMD_REQUEST_COMMAND: { - #ifndef MENUQC + #ifdef GAMEQC int NOTIF_ANNCE_COUNT = 0; FOREACH(Notifications, it.nent_type == MSG_ANNCE, { ++NOTIF_ANNCE_COUNT; }); int NOTIF_INFO_COUNT = 0; FOREACH(Notifications, it.nent_type == MSG_INFO, { ++NOTIF_INFO_COUNT; }); int NOTIF_CENTER_COUNT = 0; FOREACH(Notifications, it.nent_type == MSG_CENTER, { ++NOTIF_CENTER_COUNT; }); @@ -409,7 +403,7 @@ void GenericCommand_restartnotifs(float request) default: case CMD_REQUEST_USAGE: { - LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " restartnotifs")); + LOG_INFO("Usage:^3 ", GetProgramCommandPrefix(), " restartnotifs"); LOG_INFO(" No arguments required.\n"); return; } @@ -439,7 +433,7 @@ void GenericCommand_settemp(float request, float argc) LOG_INFO("Incorrect parameters for ^2settemp^7\n"); case CMD_REQUEST_USAGE: { - LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " settemp \"cvar\" \"arguments\"\n")); + LOG_INFO("Usage:^3 ", GetProgramCommandPrefix(), " settemp \"cvar\" \"arguments\"\n"); LOG_INFO(" Where 'cvar' is the cvar you want to temporarily set with 'arguments'.\n"); LOG_INFO("See also: ^2settemp_restore^7\n"); return; @@ -466,7 +460,7 @@ void GenericCommand_settemp_restore(float request, float argc) default: case CMD_REQUEST_USAGE: { - LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " settemp_restore\n")); + LOG_INFO("Usage:^3 ", GetProgramCommandPrefix(), " settemp_restore\n"); LOG_INFO(" No arguments required.\n"); LOG_INFO("See also: ^2settemp^7\n"); return; @@ -494,7 +488,7 @@ void GenericCommand_runtest(float request, float argc) default: case CMD_REQUEST_USAGE: { - LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " [function to run]")); + LOG_INFO("Usage:^3 ", GetProgramCommandPrefix(), " [function to run]"); return; } }