From a25d38992d150dc5ceaf0f803fbc4aa142065cf1 Mon Sep 17 00:00:00 2001 From: Samual Date: Wed, 28 Dec 2011 11:54:19 -0500 Subject: [PATCH] Make it compilable :D --- qcsrc/client/progs.src | 2 ++ qcsrc/common/command/generic.qc | 49 +++++++++++++++++------------ qcsrc/common/command/generic.qh | 4 ++- qcsrc/common/command/rpn.qc | 5 +-- qcsrc/common/command/shared_defs.qh | 2 +- qcsrc/dpdefs/menudefs.qc | 9 ++++++ qcsrc/menu/progs.src | 2 ++ qcsrc/server/progs.src | 2 ++ 8 files changed, 49 insertions(+), 26 deletions(-) diff --git a/qcsrc/client/progs.src b/qcsrc/client/progs.src index cc1191898..d869d663b 100644 --- a/qcsrc/client/progs.src +++ b/qcsrc/client/progs.src @@ -18,6 +18,7 @@ Defs.qc ../common/items.qh ../common/explosion_equation.qh ../common/mapinfo.qh +../common/command/rpn.qh ../common/command/generic.qh ../common/command/shared_defs.qh @@ -88,6 +89,7 @@ bgmscript.qc noise.qc ../common/util.qc +../common/command/rpn.qc ../common/command/generic.qc ../common/mapinfo.qc ../common/items.qc diff --git a/qcsrc/common/command/generic.qc b/qcsrc/common/command/generic.qc index 856f29bc8..d90a3f7fe 100644 --- a/qcsrc/common/command/generic.qc +++ b/qcsrc/common/command/generic.qc @@ -3,7 +3,8 @@ // Last updated: December 28th, 2011 // ========================================================= -string GetProgamCommandPrefix() +// used by generic commands for better help/usage information +string GetProgramCommandPrefix(void) { #ifdef SVQC return "sv_cmd"; @@ -127,35 +128,40 @@ string GameCommand_Markup(string s2) return s; } -void GenericCommand_addtolist(float request) +void GenericCommand_addtolist(float request, float argc) { switch(request) { case CMD_REQUEST_COMMAND: { + float i; + if(argc >= 2) { - s = argv(1); - s2 = argv(2); - if(cvar_string(s) == "") - cvar_set(s, s2); - else + if(cvar_string(argv(1)) == "") // cvar was empty { - n = tokenizebyseparator(cvar_string(s), " "); - for(i = 0; i < n; ++i) - if(argv(i) == s2) + cvar_set(argv(1), argv(2)); + } + else // add it to the end of the list if the list doesn't already have it + { + argc = tokenizebyseparator(cvar_string(argv(1)), " "); + for(i = 0; i < argc; ++i) + if(argv(i) == argv(2)) return; // already in list - cvar_set(s, strcat(s2, " ", cvar_string(s))); + + cvar_set(argv(1), strcat(argv(2), " ", cvar_string(argv(1)))); } + return; } - return; } default: + // todo case CMD_REQUEST_USAGE: { - print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(caller), " "))); - print(" No arguments required.\n"); + print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " addtolist variable [value]")); + print(" Where 'variable' is what to add to the list,\n"); + print(" and 'value' is any extra optional paramaters to add with quotes."); return; } } @@ -239,7 +245,7 @@ void GenericCommand_maplist(float request, float argc) default: case CMD_REQUEST_USAGE: { - print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(caller), " maplist command [map]"))); // todo + print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " maplist command [map]")); // todo print(" No arguments required.\n"); return; } @@ -267,7 +273,7 @@ void GenericCommand_settemp(float request, float argc) print("Incorrect parameters for ^2settemp^7\n"); case CMD_REQUEST_USAGE: { - print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(caller), " settemp \"cvar\" \"arguments\"\n")); + print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " settemp \"cvar\" \"arguments\"\n")); print(" Where 'cvar' is the cvar you want to temporarily set with 'arguments'.\n"); return; } @@ -293,7 +299,7 @@ void GenericCommand_settemp_restore(float request, float argc) default: case CMD_REQUEST_USAGE: { - print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(caller), " settemp_restore\n")); + print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " settemp_restore\n")); print(" No arguments required.\n"); return; } @@ -315,7 +321,7 @@ void GenericCommand_(float request) default: case CMD_REQUEST_USAGE: { - print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(caller), " "))); + print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " "))); print(" No arguments required.\n"); return; } @@ -378,6 +384,9 @@ float GenericCommand_macro_usage(float argc) float GenericCommand(string command) { float argc = tokenize_console(command); + float n, j, f, i; + string s, s2, c; + vector rgb; // Guide for working with argc arguments by example: // argc: 1 - 2 - 3 - 4 @@ -396,9 +405,9 @@ float GenericCommand(string command) return TRUE; } } - else if(GenericCommand_macro_command(argc)) // continue as usual and scan for normal commands + else if(GenericCommand_macro_command(argc, command)) // continue as usual and scan for normal commands { - return TRUE; // handled by one of the above LocalCommand_* functions + return TRUE; // handled by one of the above GenericCommand_* functions } else if(argc >= 3 && argv(0) == "red") { diff --git a/qcsrc/common/command/generic.qh b/qcsrc/common/command/generic.qh index 1bfd3b439..d6abcea03 100644 --- a/qcsrc/common/command/generic.qh +++ b/qcsrc/common/command/generic.qh @@ -1,2 +1,4 @@ float GenericCommand(string command); // returns true if handled, false if not. Note: It tokenizes its input, so be careful! -string GetProgamCommandPrefix(); // returns command prefix specific for each program it is compiled in \ No newline at end of file + +// returns command prefix specific for each program it is compiled in +string GetProgramCommandPrefix(void); \ No newline at end of file diff --git a/qcsrc/common/command/rpn.qc b/qcsrc/common/command/rpn.qc index a5a68f62f..5a50577a1 100644 --- a/qcsrc/common/command/rpn.qc +++ b/qcsrc/common/command/rpn.qc @@ -63,9 +63,6 @@ void GenericCommand_rpn(float request, float argc, string command) if(argc >= 2) { - float rpnpos; - string rpncmd; - float f2, f3; rpn_sp = 0; rpn_error = FALSE; for(rpnpos = 1; rpnpos < argc; ++rpnpos) @@ -519,7 +516,7 @@ void GenericCommand_rpn(float request, float argc, string command) default: case CMD_REQUEST_USAGE: { - print(" rpn EXPRESSION... - a RPN calculator.\n"); + print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " rpn EXPRESSION...\n")); print(" Operator description (x: string, s: set, f: float):\n"); print(" x pop -----------------------------> : removes the top\n"); print(" x dup -----------------------------> x x : duplicates the top\n"); diff --git a/qcsrc/common/command/shared_defs.qh b/qcsrc/common/command/shared_defs.qh index 777608b88..f06ee3239 100644 --- a/qcsrc/common/command/shared_defs.qh +++ b/qcsrc/common/command/shared_defs.qh @@ -5,4 +5,4 @@ // identifiers for subfunction requests by the command code structure #define CMD_REQUEST_COMMAND 1 -#define CMD_REQUEST_USAGE 2 +#define CMD_REQUEST_USAGE 2 \ No newline at end of file diff --git a/qcsrc/dpdefs/menudefs.qc b/qcsrc/dpdefs/menudefs.qc index 8fc5f56f0..cf15840a8 100644 --- a/qcsrc/dpdefs/menudefs.qc +++ b/qcsrc/dpdefs/menudefs.qc @@ -431,6 +431,15 @@ float(float bufhandle, string str, float order) bufstr_add = #448; void(float bufhandle, float string_index) bufstr_free = #449; void(float bufhandle, string pattern, string antipattern) buf_cvarlist = #517; +//DP_QC_STRING_CASE_FUNCTIONS +//idea: Dresk +//darkplaces implementation: LordHavoc / Dresk +//builtin definitions: +string(string s) strtolower = #480; // returns the passed in string in pure lowercase form +string(string s) strtoupper = #481; // returns the passed in string in pure uppercase form +//description: +//provides simple string uppercase and lowercase functions + //DP_QC_CVAR_DESCRIPTION //idea: divVerent //DarkPlaces implementation: divVerent diff --git a/qcsrc/menu/progs.src b/qcsrc/menu/progs.src index 84b65e12f..0af6bebe5 100644 --- a/qcsrc/menu/progs.src +++ b/qcsrc/menu/progs.src @@ -15,6 +15,7 @@ oo/base.h ../common/mapinfo.qh ../common/campaign_common.qh ../common/items.qh +../common/command/rpn.qh ../common/command/generic.qh ../common/command/shared_defs.qh @@ -30,6 +31,7 @@ oo/implementation.h classes.c ../common/util.qc +../common/command/rpn.qc ../common/command/generic.qc command/menu_cmd.qc menu.qc diff --git a/qcsrc/server/progs.src b/qcsrc/server/progs.src index d99b07891..0280a7f8a 100644 --- a/qcsrc/server/progs.src +++ b/qcsrc/server/progs.src @@ -17,6 +17,7 @@ sys-post.qh ../common/items.qh ../common/explosion_equation.qh ../common/urllib.qh +../common/command/rpn.qh ../common/command/generic.qh ../common/command/shared_defs.qh @@ -146,6 +147,7 @@ campaign.qc ../common/campaign_setup.qc ../common/urllib.qc +../common/command/rpn.qc ../common/command/generic.qc command/common.qc command/ipban.qc -- 2.39.2