Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
generic.qc File Reference
Include dependency graph for generic.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void Curl_URI_Get_Callback (int id, float status, string data)
 GENERIC_COMMAND (addtolist, "Add a string to a cvar", true)
 GENERIC_COMMAND (dumpcommands, "Dump all commands on the program to <program>_cmd_dump.txt", false)
 GENERIC_COMMAND (maplist, "Automatic control of maplist", true)
 GENERIC_COMMAND (nextframe, "Execute the given command next frame of this VM", true)
 GENERIC_COMMAND (qc_curl, "Queries a URL", true)
 GENERIC_COMMAND (removefromlist, "Remove a string from a cvar", true)
 GENERIC_COMMAND (restartnotifs, "Re-initialize all notifications", false)
 GENERIC_COMMAND (rpn, "RPN calculator", true)
 GENERIC_COMMAND (runtest, "Run unit tests", false)
 GENERIC_COMMAND (settemp, "Temporarily set a value to a cvar which is restored later", false)
 GENERIC_COMMAND (settemp_restore, "Restore all cvars set by settemp command", false)
float GenericCommand (string command)
void GenericCommand_addtolist (int request, int argc)
float GenericCommand_macro_command (int argc, string command)
void GenericCommand_macro_help ()
float GenericCommand_macro_usage (int argc)
void GenericCommand_macro_write_aliases (float fh)
void GenericCommand_maplist (int request, int argc)
void GenericCommand_nextframe (int request, string command)
void GenericCommand_qc_curl (int request, int argc)
void GenericCommand_removefromlist (int request, int argc)
void GenericCommand_restartnotifs (int request)
void GenericCommand_runtest (int request, int argc)
void GenericCommand_settemp (int request, int argc)
void GenericCommand_settemp_restore (int request)
string maplist_shuffle (string input)

Function Documentation

◆ Curl_URI_Get_Callback()

void Curl_URI_Get_Callback ( int id,
float status,
string data )

Definition at line 31 of file generic.qc.

32{
33 int i = id - URI_GET_CURL;
34 float do_exec = curl_uri_get_exec[i];
35 string do_cvar = curl_uri_get_cvar[i];
36 if(status != 0)
37 {
38 LOG_TRACEF("error: status is %d", status);
39 if(do_cvar)
40 strunzone(do_cvar);
41 return;
42 }
43 if(do_exec)
44 localcmd(data);
45 if(do_cvar)
46 {
47 cvar_set(do_cvar, data);
48 strunzone(do_cvar);
49 }
50 if(!do_exec)
51 if (!do_cvar)
52 LOG_INFO(data);
53}
string curl_uri_get_cvar[URI_GET_CURL_END - URI_GET_CURL+1]
Definition generic.qh:40
float curl_uri_get_exec[URI_GET_CURL_END - URI_GET_CURL+1]
Definition generic.qh:39
#define LOG_TRACEF(...)
Definition log.qh:77
#define LOG_INFO(...)
Definition log.qh:65
void localcmd(string command,...)
void cvar_set(string name, string value)
void strunzone(string s)
const int URI_GET_CURL
Definition urllib.qh:7

References curl_uri_get_cvar, curl_uri_get_exec, cvar_set(), localcmd(), LOG_INFO, LOG_TRACEF, strunzone(), and URI_GET_CURL.

Referenced by URI_Get_Callback(), and URI_Get_Callback().

◆ GENERIC_COMMAND() [1/11]

GENERIC_COMMAND ( addtolist ,
"Add a string to a cvar" ,
true  )

Definition at line 556 of file generic.qc.

556{ GenericCommand_addtolist(request, arguments); }
void GenericCommand_addtolist(int request, int argc)
Definition generic.qc:60

References GenericCommand_addtolist().

◆ GENERIC_COMMAND() [2/11]

GENERIC_COMMAND ( dumpcommands ,
"Dump all commands on the program to <program>_cmd_dump.txt" ,
false  )

Definition at line 172 of file generic.qc.

173{
174 switch(request)
175 {
177 {
178 float fh;
179 string filename = strcat(GetProgramCommandPrefix(), "_dump.txt");
180 fh = fopen(filename, FILE_WRITE);
181
182 if(fh >= 0)
183 {
184 #ifdef SVQC
185 CMD_Write("dump of server console commands:\n");
187 CMD_Write("\n");
188
189 CMD_Write("dump of networked client only commands:\n");
191 CMD_Write("\n");
192
193 CMD_Write("dump of common commands:\n");
195 CMD_Write("\n");
196
197 CMD_Write("dump of ban commands:\n");
199 CMD_Write("\n");
200 #endif
201
202 #ifdef CSQC
203 CMD_Write("dump of client commands:\n");
205 CMD_Write("\n");
206 #endif
207
208 CMD_Write("dump of generic commands:\n");
210
211 LOG_INFO("Completed dump of aliases in ^2data/data/", GetProgramCommandPrefix(), "_dump.txt^7.");
212
213 fclose(fh);
214 }
215 else
216 {
217 LOG_INFO("^1Error: ^7Could not dump to file!");
218 }
219 return;
220 }
221
222 default:
224 {
225 LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " dumpcommands");
226 LOG_HELP(" No arguments required.");
227 return;
228 }
229 }
230}
void BanCommand_macro_write_aliases(float fh)
Definition banning.qc:511
void LocalCommand_macro_write_aliases(int fh)
Definition cl_cmd.qc:519
void ClientCommand_macro_write_aliases(float fh)
Definition cmd.qc:1156
const int CMD_REQUEST_COMMAND
Definition command.qh:3
const int CMD_REQUEST_USAGE
Definition command.qh:4
const float FILE_WRITE
void GenericCommand_macro_write_aliases(float fh)
Definition generic.qc:592
#define GetProgramCommandPrefix()
Definition generic.qh:25
#define CMD_Write(s)
Definition generic.qh:33
#define LOG_HELP(...)
Definition log.qh:85
void fclose(float fhandle)
float fopen(string filename, float mode)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
void CommonCommand_macro_write_aliases(int fh)
Definition common.qh:188
void GameCommand_macro_write_aliases(float fh)
Definition sv_cmd.qc:1836

References BanCommand_macro_write_aliases(), ClientCommand_macro_write_aliases(), CMD_REQUEST_COMMAND, CMD_REQUEST_USAGE, CMD_Write, CommonCommand_macro_write_aliases(), fclose(), FILE_WRITE, fopen(), GameCommand_macro_write_aliases(), GenericCommand_macro_write_aliases(), GetProgramCommandPrefix, LocalCommand_macro_write_aliases(), LOG_HELP, LOG_INFO, and strcat().

◆ GENERIC_COMMAND() [3/11]

GENERIC_COMMAND ( maplist ,
"Automatic control of maplist" ,
true  )

Definition at line 557 of file generic.qc.

557{ GenericCommand_maplist(request, arguments); }
void GenericCommand_maplist(int request, int argc)
Definition generic.qc:251

References GenericCommand_maplist().

◆ GENERIC_COMMAND() [4/11]

GENERIC_COMMAND ( nextframe ,
"Execute the given command next frame of this VM" ,
true  )

Definition at line 558 of file generic.qc.

558{ GenericCommand_nextframe(request, command); }
void GenericCommand_nextframe(int request, string command)
Definition generic.qc:336

References GenericCommand_nextframe().

◆ GENERIC_COMMAND() [5/11]

GENERIC_COMMAND ( qc_curl ,
"Queries a URL" ,
true  )

Definition at line 559 of file generic.qc.

559{ GenericCommand_qc_curl(request, arguments); }
void GenericCommand_qc_curl(int request, int argc)
Definition generic.qc:100

References GenericCommand_qc_curl().

◆ GENERIC_COMMAND() [6/11]

GENERIC_COMMAND ( removefromlist ,
"Remove a string from a cvar" ,
true  )

Definition at line 560 of file generic.qc.

560{ GenericCommand_removefromlist(request, arguments); }
void GenericCommand_removefromlist(int request, int argc)
Definition generic.qc:356

References GenericCommand_removefromlist().

◆ GENERIC_COMMAND() [7/11]

GENERIC_COMMAND ( restartnotifs ,
"Re-initialize all notifications" ,
false  )

Definition at line 561 of file generic.qc.

void GenericCommand_restartnotifs(int request)
Definition generic.qc:391

References GenericCommand_restartnotifs().

◆ GENERIC_COMMAND() [8/11]

GENERIC_COMMAND ( rpn ,
"RPN calculator" ,
true  )

Definition at line 562 of file generic.qc.

562{ GenericCommand_rpn(request, arguments, command); }
void GenericCommand_rpn(int request, int argc, string command)
Definition rpn.qc:63

References GenericCommand_rpn().

◆ GENERIC_COMMAND() [9/11]

GENERIC_COMMAND ( runtest ,
"Run unit tests" ,
false  )

Definition at line 565 of file generic.qc.

565{ GenericCommand_runtest(request, arguments); }
void GenericCommand_runtest(int request, int argc)
Definition generic.qc:506

References GenericCommand_runtest().

◆ GENERIC_COMMAND() [10/11]

GENERIC_COMMAND ( settemp ,
"Temporarily set a value to a cvar which is restored later" ,
false  )

Definition at line 563 of file generic.qc.

563{ GenericCommand_settemp(request, arguments); }
void GenericCommand_settemp(int request, int argc)
Definition generic.qc:448

References GenericCommand_settemp().

◆ GENERIC_COMMAND() [11/11]

GENERIC_COMMAND ( settemp_restore ,
"Restore all cvars set by settemp command" ,
false  )

Definition at line 564 of file generic.qc.

void GenericCommand_settemp_restore(int request)
Definition generic.qc:479

References GenericCommand_settemp_restore().

◆ GenericCommand()

float GenericCommand ( string command)

Definition at line 603 of file generic.qc.

604{
605 int argc = tokenize_console(command);
606 float n, j, f, i;
607 string s, s2, c;
608 vector rgb;
609
610 // Guide for working with argc arguments by example:
611 // argc: 1 - 2 - 3 - 4
612 // argv: 0 - 1 - 2 - 3
613 // cmd vote - master - login - password
614
615 if(GenericCommand_macro_command(argc, command)) // continue as usual and scan for normal commands
616 {
617 return true; // handled by one of the above GenericCommand_* functions
618 }
619 else if(argc >= 3 && argv(0) == "red")
620 {
623 return true;
624 }
625 else if(argc >= 3 && crc16(0, argv(0)) == 38566 && crc16(0, strcat(argv(0), argv(0), argv(0))) == 59830)
626 {
627 // other test case
628 s = strconv(2, 0, 0, substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2)));
629
630 n = floor(random() * 6 + 2);
631
632 s2 = "";
633 for(i = 0; i < n; ++i)
634 {
635 s2 = strcat(s2, "AH");
636 }
637
638 if(random() < 0.1)
639 s2 = strcat(substring(s2, 1, strlen(s2) - 1), "A");
640
641 if(s == "")
642 s = s2;
643 else
644 if(random() < 0.8)
645 s = strcat(s, " ", s2);
646 else
647 s = strcat(s2, " ", s);
648
649 s2 = substring(s, strlen(s) - 2, 2);
650 if(s2 == "AH" || s2 == "AY")
651 s = strcat(s, "))");
652 else
653 s = strcat(s, " ))");
654
655 if(random() < 0.1)
656 s = substring(s, 0, strlen(s) - 1);
657
658 if(random() < 0.1)
659 s = strconv(1, 0, 0, s);
660
661 localcmd(strcat(argv(1), " ", s));
662
663 return true;
664 }
665 else if(argc >= 3 && crc16(0, argv(0)) == 3826 && crc16(0, strcat(argv(0), argv(0), argv(0))) == 55790)
666 {
667 // test case for terencehill's color codes
668 s = strdecolorize(substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2)));
669 s2 = "";
670
671 n = strlen(s);
672 j = ((6 * max(1, floor(strlen(s)/32 + random() * 2 - 1))) / n) * (1 - 2 * (random() > 0.5));
673 f = random() * 6;
674
675 for(i = 0; i < n; ++i)
676 {
677 c = substring(s, i, 1);
678
679 if(c == ";")
680 c = ":";
681 else if(c == "^")
682 {
683 c = "^^";
684 if(substring(s, i+1, 1) == "^")
685 ++i;
686 }
687
688 if(c != " ")
689 {
690 rgb = hsl_to_rgb('1 0 0' * (j * i + f) + '0 1 .5');
691 c = strcat(rgb_to_hexcolor(rgb), c);
692 }
693 s2 = strcat(s2, c);
694 }
695
696 localcmd(strcat(argv(1), " ", s2));
697
698 return true;
699 }
700
701 return false;
702}
ERASEABLE string rgb_to_hexcolor(vector rgb)
Definition color.qh:183
ERASEABLE vector hsl_to_rgb(vector hsl)
Definition color.qh:167
#define argv_end_index
#define strlen
#define tokenize_console
#define argv_start_index
float GenericCommand_macro_command(int argc, string command)
Definition generic.qc:572
string GenericCommand_markup(string s2)
Definition markup.qc:61
string substring(string s, float start, float length)
float random(void)
float floor(float f)
string argv(float n)
float max(float f,...)
spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2 f1points s1 s2
Definition all.inc:469
vector
Definition self.qh:92

References argv(), argv_end_index, argv_start_index, floor(), GenericCommand_macro_command(), GenericCommand_markup(), hsl_to_rgb(), localcmd(), max(), random(), rgb_to_hexcolor(), s2, strcat(), strlen, substring(), tokenize_console, and vector.

Referenced by GameCommand(), and GameCommand().

◆ GenericCommand_addtolist()

void GenericCommand_addtolist ( int request,
int argc )

Definition at line 60 of file generic.qc.

61{
62 switch(request)
63 {
65 {
66 if(argc >= 2)
67 {
68 string original_cvar = argv(1);
69 string tmp_string = argv(2);
70
71 if(cvar_string(original_cvar) == "") // cvar was empty
72 {
73 cvar_set(original_cvar, tmp_string);
74 }
75 else // add it to the end of the list if the list doesn't already have it
76 {
77 FOREACH_WORD(cvar_string(original_cvar), it == tmp_string,
78 {
79 return; // already in the list
80 });
81
82 cvar_set(original_cvar, cons(cvar_string(original_cvar), tmp_string));
83 }
84 return;
85 }
86 }
87
88 default:
89 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
91 {
92 LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " addtolist <cvar> <value>");
93 LOG_HELP(" Where <cvar> is the cvar to add <value> to.");
94 LOG_HELP("See also: ^2removefromlist^7");
95 return;
96 }
97 }
98}
#define FOREACH_WORD(words, cond, body)
Definition iter.qh:33
#define LOG_INFOF(...)
Definition log.qh:66
const string cvar_string(string name)
ERASEABLE string cons(string a, string b)
Definition string.qh:276

References argv(), CMD_REQUEST_COMMAND, CMD_REQUEST_USAGE, cons(), cvar_set(), cvar_string(), FOREACH_WORD, GetProgramCommandPrefix, LOG_HELP, and LOG_INFOF.

Referenced by GENERIC_COMMAND().

◆ GenericCommand_macro_command()

float GenericCommand_macro_command ( int argc,
string command )

Definition at line 572 of file generic.qc.

573{
574 string c = strtolower(argv(0));
575 FOREACH(GENERIC_COMMANDS, it.m_name == c, {
576 it.m_invokecmd(it, CMD_REQUEST_COMMAND, NULL, argc, command);
577 return true;
578 });
579 return false;
580}
string strtolower(string s)
#define FOREACH(list, cond, body)
Definition iter.qh:19

References argv(), FOREACH, and strtolower().

Referenced by GenericCommand().

◆ GenericCommand_macro_help()

void GenericCommand_macro_help ( )

Definition at line 567 of file generic.qc.

568{
569 FOREACH(GENERIC_COMMANDS, true, LOG_HELPF(" ^2%s^7: %s", it.m_name, it.m_description));
570}
#define LOG_HELPF(...)
Definition log.qh:86

References FOREACH, and LOG_HELPF.

Referenced by GameCommand(), and GameCommand().

◆ GenericCommand_macro_usage()

float GenericCommand_macro_usage ( int argc)

Definition at line 582 of file generic.qc.

583{
584 string c = strtolower(argv(1));
585 FOREACH(GENERIC_COMMANDS, it.m_name == c, {
586 it.m_invokecmd(it, CMD_REQUEST_USAGE, NULL, argc, "");
587 return true;
588 });
589 return false;
590}

References argv(), FOREACH, and strtolower().

Referenced by GameCommand().

◆ GenericCommand_macro_write_aliases()

void GenericCommand_macro_write_aliases ( float fh)

Definition at line 592 of file generic.qc.

593{
594 FOREACH(GENERIC_COMMANDS, true, CMD_Write_Alias("qc_cmd_svmenu", it.m_name, it.m_description));
595}
#define CMD_Write_Alias(execute, command, description)
Definition generic.qh:34

References CMD_Write_Alias, and FOREACH.

Referenced by GENERIC_COMMAND().

◆ GenericCommand_maplist()

void GenericCommand_maplist ( int request,
int argc )

Definition at line 251 of file generic.qc.

252{
253 switch(request)
254 {
256 {
257 string tmp_string;
258 float i;
259
260 switch(argv(1))
261 {
262 case "add": // appends new maps to the maplist
263 {
264 if(argc == 3)
265 {
266 if (!fexists(strcat("maps/", argv(2), ".bsp")))
267 {
268 LOG_INFO("maplist: ERROR: ", argv(2), " does not exist!");
269 break;
270 }
271
272 if(cvar_string("g_maplist") == "")
273 cvar_set("g_maplist", argv(2));
274 else
275 cvar_set("g_maplist", strcat(argv(2), " ", cvar_string("g_maplist")));
276
277 return;
278 }
279 break; // go to usage
280 }
281
282 case "cleanup": // scans maplist and only adds back the ones which are really usable
283 {
286 string filtered = "";
287 FOREACH_WORD(cvar_string("g_maplist"), MapInfo_CheckMap(it), filtered = cons(filtered, it));
288 cvar_set("g_maplist", filtered);
289 return;
290 }
291
292 case "remove": // scans maplist and only adds back whatever maps were not provided in argv(2)
293 {
294 if(argc == 3)
295 {
296 // save argv(2) from being overridden by tokenize engine call
297 string del_map_name = argv(2);
298 argc = tokenizebyseparator(cvar_string("g_maplist"), " ");
299
300 tmp_string = "";
301 for(i = 0; i < argc; ++i)
302 if(argv(i) != del_map_name)
303 tmp_string = strcat(tmp_string, " ", argv(i));
304
305 tmp_string = substring(tmp_string, 1, strlen(tmp_string) - 1);
306 cvar_set("g_maplist", tmp_string);
307
308 return;
309 }
310 break; // go to usage
311 }
312
313 case "shuffle": // randomly shuffle the maplist
314 {
315 cvar_set("g_maplist", maplist_shuffle(cvar_string("g_maplist")));
316 return;
317 }
318
319 default: break;
320 }
321 }
322
323 default:
324 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
326 {
327 LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " maplist <action> [<map>]");
328 LOG_HELP(" Where <action> is the command to complete,");
329 LOG_HELP(" and <map> is what it acts upon (for the 'add' and 'remove' actions).");
330 LOG_HELP(" Full list of commands here: add, cleanup, remove, shuffle.");
331 return;
332 }
333 }
334}
#define tokenizebyseparator
ERASEABLE bool fexists(string f)
Definition file.qh:4
string maplist_shuffle(string input)
Definition generic.qc:232
float MapInfo_CheckMap(string s)
Definition mapinfo.qc:1510
float MapInfo_FilterGametype(Gametype pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
Definition mapinfo.qc:177
int MapInfo_RequiredFlags()
Definition mapinfo.qc:1679
Gametype MapInfo_CurrentGametype()
Definition mapinfo.qc:1490
int MapInfo_ForbiddenFlags()
Definition mapinfo.qc:1664
int MapInfo_CurrentFeatures()
Definition mapinfo.qc:1480
void MapInfo_Enumerate()
Definition mapinfo.qc:134

References argv(), CMD_REQUEST_COMMAND, CMD_REQUEST_USAGE, cons(), cvar_set(), cvar_string(), fexists(), FOREACH_WORD, GetProgramCommandPrefix, LOG_HELP, LOG_INFO, LOG_INFOF, MapInfo_CheckMap(), MapInfo_CurrentFeatures(), MapInfo_CurrentGametype(), MapInfo_Enumerate(), MapInfo_FilterGametype(), MapInfo_ForbiddenFlags(), MapInfo_RequiredFlags(), maplist_shuffle(), strcat(), strlen, substring(), and tokenizebyseparator.

Referenced by GENERIC_COMMAND().

◆ GenericCommand_nextframe()

void GenericCommand_nextframe ( int request,
string command )

Definition at line 336 of file generic.qc.

337{
338 switch(request)
339 {
341 {
343 return;
344 }
345
346 default:
348 {
349 LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " nextframe <command>");
350 LOG_HELP(" Where <command> will be executed next frame of this VM");
351 return;
352 }
353 }
354}
void queue_to_execute_next_frame(string s)
Definition util.qc:1756

References argv_end_index, argv_start_index, CMD_REQUEST_COMMAND, CMD_REQUEST_USAGE, GetProgramCommandPrefix, LOG_HELP, queue_to_execute_next_frame(), and substring().

Referenced by GENERIC_COMMAND().

◆ GenericCommand_qc_curl()

void GenericCommand_qc_curl ( int request,
int argc )

Definition at line 100 of file generic.qc.

101{
102 switch(request)
103 {
105 {
106 bool do_exec = false;
107 string do_cvar = string_null;
108 float key = -1;
109 int i;
110 for(i = 1; i+1 < argc; ++i)
111 {
112 if(argv(i) == "--cvar" && i+2 < argc)
113 {
114 ++i;
115 do_cvar = strzone(argv(i));
116 continue;
117 }
118 if(argv(i) == "--exec")
119 {
120 do_exec = true;
121 continue;
122 }
123 if(argv(i) == "--key" && i+2 < argc)
124 {
125 ++i;
126 key = stof(argv(i));
127 continue;
128 }
129 break;
130 }
131
132 // now, argv(i) is the URL
133 // following args may be POST parameters
134 string url = argv(i);
135 ++i;
136 float buf = buf_create();
137 int j;
138 for(j = 0; i+1 < argc; i += 2)
139 bufstr_set(buf, ++j, sprintf("%s=%s", uri_escape(argv(i)), uri_escape(argv(i+1))));
140 if(i < argc)
141 bufstr_set(buf, ++j, sprintf("submit=%s", uri_escape(argv(i))));
142
143 float r;
144 if(j == 0) // no args: GET
145 r = crypto_uri_postbuf(url, URI_GET_CURL + curl_uri_get_pos, string_null, string_null, -1, key);
146 else // with args: POST
147 r = crypto_uri_postbuf(url, URI_GET_CURL + curl_uri_get_pos, "application/x-www-form-urlencoded", "&", buf, key);
148
149 if(r)
150 {
154 }
155 else
156 LOG_INFO(_("error creating curl handle"));
157
158 buf_del(buf);
159
160 return;
161 }
162
163 default:
165 {
166 LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " qc_curl [--key <n>] [--cvar] [--exec] <url> [<postargs>]");
167 return;
168 }
169 }
170}
#define buf_create
int curl_uri_get_pos
Definition generic.qh:38
float stof(string val,...)
string strzone(string s)
string string_null
Definition nil.qh:9
const int URI_GET_CURL_END
Definition urllib.qh:8

References argv(), buf_create, CMD_REQUEST_COMMAND, CMD_REQUEST_USAGE, curl_uri_get_cvar, curl_uri_get_exec, curl_uri_get_pos, GetProgramCommandPrefix, LOG_HELP, LOG_INFO, stof(), string_null, strzone(), URI_GET_CURL, and URI_GET_CURL_END.

Referenced by GENERIC_COMMAND().

◆ GenericCommand_removefromlist()

void GenericCommand_removefromlist ( int request,
int argc )

Definition at line 356 of file generic.qc.

357{
358 switch(request)
359 {
361 {
362 if(argc == 3)
363 {
364 string original_cvar = argv(1);
365 string removal = argv(2);
366
367 string tmp_string = "";
368 FOREACH_WORD(cvar_string(original_cvar), it != removal,
369 {
370 tmp_string = cons(tmp_string, it);
371 });
372
373 cvar_set(original_cvar, tmp_string);
374
375 return;
376 }
377 }
378
379 default:
380 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
382 {
383 LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " removefromlist <cvar> <value>");
384 LOG_HELP(" Where <cvar> is the cvar to remove <value> from.");
385 LOG_HELP("See also: ^2addtolist^7");
386 return;
387 }
388 }
389}

References argv(), CMD_REQUEST_COMMAND, CMD_REQUEST_USAGE, cons(), cvar_set(), cvar_string(), FOREACH_WORD, GetProgramCommandPrefix, LOG_HELP, and LOG_INFOF.

Referenced by GENERIC_COMMAND().

◆ GenericCommand_restartnotifs()

void GenericCommand_restartnotifs ( int request)

Definition at line 391 of file generic.qc.

392{
393 switch(request)
394 {
396 {
397 #ifdef GAMEQC
398 int NOTIF_ANNCE_COUNT = 0;
399 int NOTIF_INFO_COUNT = 0;
400 int NOTIF_CENTER_COUNT = 0;
401 int NOTIF_MULTI_COUNT = 0;
402 int NOTIF_CHOICE_COUNT = 0;
403 FOREACH(Notifications, true, {
404 switch (it.nent_type)
405 {
406 case MSG_ANNCE: ++NOTIF_ANNCE_COUNT; break;
407 case MSG_INFO: ++NOTIF_INFO_COUNT; break;
408 case MSG_CENTER: ++NOTIF_CENTER_COUNT; break;
409 case MSG_MULTI: ++NOTIF_MULTI_COUNT; break;
410 case MSG_CHOICE: ++NOTIF_CHOICE_COUNT; break;
411 }
412 });
413
414 LOG_INFOF(
415 "Restart_Notifications(): Restarting %d notifications... "
416 "Counts: MSG_ANNCE = %d, MSG_INFO = %d, MSG_CENTER = %d, MSG_MULTI = %d, MSG_CHOICE = %d",
417 (
418 NOTIF_ANNCE_COUNT +
419 NOTIF_INFO_COUNT +
420 NOTIF_CENTER_COUNT +
421 NOTIF_MULTI_COUNT +
422 NOTIF_CHOICE_COUNT
423 ),
424 NOTIF_ANNCE_COUNT,
425 NOTIF_INFO_COUNT,
426 NOTIF_CENTER_COUNT,
427 NOTIF_MULTI_COUNT,
428 NOTIF_CHOICE_COUNT
429 );
431 CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
432 #else
433 LOG_INFO("Notification restart command only works with cl_cmd and sv_cmd.");
434 #endif
435 return;
436 }
437
438 default:
440 {
441 LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " restartnotifs");
442 LOG_HELP(" No arguments required.");
443 return;
444 }
445 }
446}
#define CALL_ACCUMULATED_FUNCTION(func)
Definition accumulate.qh:45
void Destroy_All_Notifications()
Definition all.qc:159

References CALL_ACCUMULATED_FUNCTION, CMD_REQUEST_COMMAND, CMD_REQUEST_USAGE, Destroy_All_Notifications(), FOREACH, GetProgramCommandPrefix, LOG_HELP, LOG_INFO, and LOG_INFOF.

Referenced by GENERIC_COMMAND().

◆ GenericCommand_runtest()

void GenericCommand_runtest ( int request,
int argc )

Definition at line 506 of file generic.qc.

507{
508 switch(request)
509 {
511 {
512 if(argc > 1)
513 {
514 float i;
515 for(i = 1; i < argc; ++i)
516 TEST_Run(argv(i));
517 }
518 else
520 return;
521 }
522
523 default:
525 {
526 LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " <function>");
527 return;
528 }
529 }
530}
bool RUN_ALL_TESTS()
Definition test.qc:4
bool TEST_Run(string s)
Definition test.qc:19

References argv(), CMD_REQUEST_COMMAND, CMD_REQUEST_USAGE, GetProgramCommandPrefix, LOG_HELP, RUN_ALL_TESTS(), and TEST_Run().

Referenced by GENERIC_COMMAND().

◆ GenericCommand_settemp()

void GenericCommand_settemp ( int request,
int argc )

Definition at line 448 of file generic.qc.

449{
450 switch(request)
451 {
453 {
454 if(argc >= 3)
455 {
456 float f = cvar_settemp(argv(1), argv(2));
457 if(f == 1)
458 LOG_TRACE("Creating new settemp tracker for ", argv(1), " and setting it to \"", argv(2), "\" temporarily.");
459 else if(f == -1)
460 LOG_TRACE("Already had a tracker for ", argv(1), ", updating it to \"", argv(2), "\".");
461 // else cvar_settemp itself errors out
462
463 return;
464 }
465 }
466
467 default:
468 LOG_INFOF("Incorrect parameters for ^2%s^7", argv(0));
470 {
471 LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " settemp <cvar> \"<arguments>\"");
472 LOG_HELP(" Where <cvar> is the cvar you want to temporarily set with <arguments>.");
473 LOG_HELP("See also: ^2settemp_restore^7");
474 return;
475 }
476 }
477}
float cvar_settemp(string tmp_cvar, string tmp_value)
Definition util.qc:811
#define LOG_TRACE(...)
Definition log.qh:76

References argv(), CMD_REQUEST_COMMAND, CMD_REQUEST_USAGE, cvar_settemp(), GetProgramCommandPrefix, LOG_HELP, LOG_INFOF, and LOG_TRACE.

Referenced by GENERIC_COMMAND().

◆ GenericCommand_settemp_restore()

void GenericCommand_settemp_restore ( int request)

Definition at line 479 of file generic.qc.

480{
481 switch(request)
482 {
484 {
485 float i = cvar_settemp_restore();
486
487 if(i)
488 LOG_TRACE("Restored ", ftos(i), " temporary cvar settings to their original values.");
489 else
490 LOG_TRACE("Nothing to restore.");
491
492 return;
493 }
494
495 default:
497 {
498 LOG_HELP("Usage:^3 ", GetProgramCommandPrefix(), " settemp_restore");
499 LOG_HELP(" No arguments required.");
500 LOG_HELP("See also: ^2settemp^7");
501 return;
502 }
503 }
504}
int cvar_settemp_restore()
Definition util.qc:851
string ftos(float f)

References CMD_REQUEST_COMMAND, CMD_REQUEST_USAGE, cvar_settemp_restore(), ftos(), GetProgramCommandPrefix, LOG_HELP, and LOG_TRACE.

Referenced by GENERIC_COMMAND().

◆ maplist_shuffle()

string maplist_shuffle ( string input)

Definition at line 232 of file generic.qc.

233{
234 int buf = buf_create();
235
236 int _cnt = 0;
237 FOREACH_WORD(input, true,
238 {
239 int _j = floor(random() * (_cnt + 1));
240 if(_j != _cnt)
241 bufstr_set(buf, _cnt, bufstr_get(buf, _j));
242 bufstr_set(buf, _j, it);
243 ++_cnt;
244 });
245
246 string output = buf_implode(buf, " ");
247 buf_del(buf);
248 return substring(output, 1, -1);
249}

References buf_create, floor(), FOREACH_WORD, random(), and substring().

Referenced by GenericCommand_maplist().