]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/gamecommand.qc
Quick comments...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / gamecommand.qc
1 string GotoMap(string m);
2 void race_deleteTime(string map, float pos);
3
4 float FullTraceFraction(vector a, vector mi, vector ma, vector b)
5 {
6         vector c;
7         float white, black;
8
9         white = 0.001;
10         black = 0.001;
11
12         c = a;
13
14         float n, m;
15         n = m = 0;
16
17         while(vlen(c - b) > 1)
18         {
19                 ++m;
20
21                 tracebox(c, mi, ma, b, MOVE_WORLDONLY, world);
22                 ++n;
23
24                 if(!trace_startsolid)
25                 {
26                         black += vlen(trace_endpos - c);
27                         c = trace_endpos;
28                 }
29
30                 n += tracebox_inverted(c, mi, ma, b, MOVE_WORLDONLY, world);
31
32                 white += vlen(trace_endpos - c);
33                 c = trace_endpos;
34         }
35
36         if(n > 200)
37                 dprint("HOLY SHIT! FullTraceFraction: ", ftos(n), " total traces, ", ftos(m), " iterations\n");
38
39         return white / (black + white);
40 }
41
42 float RadarMapAtPoint_Trace(float x, float y, float w, float h, float zmin, float zsize, float q)
43 {
44         vector a, b, mi, ma;
45
46         mi = '0 0 0';
47         ma = '1 0 0' * w + '0 1 0' * h;
48         a = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
49         b = '1 0 0' * x + '0 1 0' * y + '0 0 1' * (zsize + zmin);
50
51         return FullTraceFraction(a, mi, ma, b);
52 }
53 float RadarMapAtPoint_LineBlock(float x, float y, float w, float h, float zmin, float zsize, float q)
54 {
55         vector o, mi, ma;
56         float i, r;
57         vector dz;
58
59         q = 256 * q - 1;
60         // 256q-1 is the ideal sample count to map equal amount of sample values to one pixel value
61
62         mi = '0 0 0';
63         dz = (zsize / q) * '0 0 1';
64         ma = '1 0 0' * w + '0 1 0' * h + dz;
65         o = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
66
67         if(x < world.absmin_x - w)
68                 return 0;
69         if(y < world.absmin_y - h)
70                 return 0;
71         if(x > world.absmax_x)
72                 return 0;
73         if(y > world.absmax_y)
74                 return 0;
75
76         r = 0;
77         for(i = 0; i < q; ++i)
78         {
79                 vector v1, v2;
80                 v1 = v2 = o + dz * i + mi;
81                 v1_x += random() * (ma_x - mi_x);
82                 v1_y += random() * (ma_y - mi_y);
83                 v1_z += random() * (ma_z - mi_z);
84                 v2_x += random() * (ma_x - mi_x);
85                 v2_y += random() * (ma_y - mi_y);
86                 v2_z += random() * (ma_z - mi_z);
87                 traceline(v1, v2, MOVE_WORLDONLY, world);
88                 if(trace_startsolid || trace_fraction < 1)
89                         ++r;
90         }
91         return r / q;
92 }
93 float RadarMapAtPoint_Block(float x, float y, float w, float h, float zmin, float zsize, float q)
94 {
95         vector o, mi, ma;
96         float i, r;
97         vector dz;
98
99         q = 256 * q - 1;
100         // 256q-1 is the ideal sample count to map equal amount of sample values to one pixel value
101
102         mi = '0 0 0';
103         dz = (zsize / q) * '0 0 1';
104         ma = '1 0 0' * w + '0 1 0' * h + dz;
105         o = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
106
107         if(x < world.absmin_x - w)
108                 return 0;
109         if(y < world.absmin_y - h)
110                 return 0;
111         if(x > world.absmax_x)
112                 return 0;
113         if(y > world.absmax_y)
114                 return 0;
115
116         r = 0;
117         for(i = 0; i < q; ++i)
118         {
119                 tracebox(o + dz * i, mi, ma, o + dz * i, MOVE_WORLDONLY, world);
120                 if(trace_startsolid)
121                         ++r;
122         }
123         return r / q;
124 }
125 float RadarMapAtPoint_Sample(float x, float y, float w, float h, float zmin, float zsize, float q)
126 {
127         vector a, b, mi, ma;
128
129         q *= 4; // choose q so it matches the regular algorithm in speed
130
131         q = 256 * q - 1;
132         // 256q-1 is the ideal sample count to map equal amount of sample values to one pixel value
133
134         mi = '0 0 0';
135         ma = '1 0 0' * w + '0 1 0' * h;
136         a = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
137         b = '1 0 0' * w + '0 1 0' * h + '0 0 1' * zsize;
138
139         float c, i;
140         c = 0;
141
142         for(i = 0; i < q; ++i)
143         {
144                 vector v;
145                 v_x = a_x + random() * b_x;
146                 v_y = a_y + random() * b_y;
147                 v_z = a_z + random() * b_z;
148                 traceline(v, v, MOVE_WORLDONLY, world);
149                 if(trace_startsolid)
150                         ++c;
151         }
152
153         return c / q;
154 }
155
156 // FF is contained twice, to map 256 to FF too
157 // removes the need to bound()
158 string doublehex = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFFFF";
159
160 float RADAR_WIDTH_MAX = 512;
161 float RADAR_HEIGHT_MAX = 512;
162 float sharpen_buffer[RADAR_WIDTH_MAX * 3];
163
164 void sharpen_set(float x, float v)
165 {
166         sharpen_buffer[x + 2 * RADAR_WIDTH_MAX] = v;
167 }
168
169 float sharpen_getpixel(float x, float y)
170 {
171         if(x < 0)
172                 return 0;
173         if(x >= RADAR_WIDTH_MAX)
174                 return 0;
175         if(y < 0)
176                 return 0;
177         if(y > 2)
178                 return 0;
179         return sharpen_buffer[x + y * RADAR_WIDTH_MAX];
180 }
181
182 float sharpen_get(float x, float a)
183 {
184         float sum;
185         sum = sharpen_getpixel(x, 1);
186         if(a == 0)
187                 return sum;
188         sum *= (8 + 1/a);
189         sum -= sharpen_getpixel(x - 1, 0);
190         sum -= sharpen_getpixel(x - 1, 1);
191         sum -= sharpen_getpixel(x - 1, 2);
192         sum -= sharpen_getpixel(x + 1, 0);
193         sum -= sharpen_getpixel(x + 1, 1);
194         sum -= sharpen_getpixel(x + 1, 2);
195         sum -= sharpen_getpixel(x, 0);
196         sum -= sharpen_getpixel(x, 2);
197         return bound(0, sum * a, 1);
198 }
199
200 void sharpen_shift(float w)
201 {
202         float i;
203         for(i = 0; i < w; ++i)
204         {
205                 sharpen_buffer[i] = sharpen_buffer[i + RADAR_WIDTH_MAX];
206                 sharpen_buffer[i + RADAR_WIDTH_MAX] = sharpen_buffer[i + 2 * RADAR_WIDTH_MAX];
207                 sharpen_buffer[i + 2 * RADAR_WIDTH_MAX] = 0;
208         }
209 }
210
211 void sharpen_init(float w)
212 {
213         float i;
214         for(i = 0; i < w; ++i)
215         {
216                 sharpen_buffer[i] = 0;
217                 sharpen_buffer[i + RADAR_WIDTH_MAX] = 0;
218                 sharpen_buffer[i + 2 * RADAR_WIDTH_MAX] = 0;
219         }
220 }
221
222 entity radarmapper;
223 void RadarMap_Next()
224 {
225         if(radarmapper.count & 4)
226         {
227                 localcmd("quit\n");
228         }
229         else if(radarmapper.count & 2)
230         {
231                 localcmd(strcat("defer 1 \"sv_cmd radarmap --flags ", ftos(radarmapper.count), strcat(" --res ", ftos(radarmapper.size_x), " ", ftos(radarmapper.size_y), " --sharpen ", ftos(radarmapper.ltime), " --qual ", ftos(radarmapper.size_z)), "\"\n"));
232                 GotoNextMap();
233         }
234         remove(radarmapper);
235         radarmapper = world;
236 }
237
238 // rough map entity
239 //   cnt: current line
240 //   size: pixel width/height
241 //   maxs: cell width/height
242 //   frame: counter
243 void RadarMap_Think()
244 {
245         float i, x, l;
246         string si;
247
248         if(self.frame == 0)
249         {
250                 // initialize
251                 get_mi_min_max_texcoords(1);
252                 self.mins = mi_picmin;
253                 self.maxs_x = (mi_picmax_x - mi_picmin_x) / self.size_x;
254                 self.maxs_y = (mi_picmax_y - mi_picmin_y) / self.size_y;
255                 self.maxs_z = mi_max_z - mi_min_z;
256                 print("Picture mins/maxs: ", ftos(self.maxs_x), " and ", ftos(self.maxs_y), " should match\n");
257                 self.netname = strzone(strcat("gfx/", mi_shortname, "_radar.xpm"));
258                 if(!(self.count & 1))
259                 {
260                         self.cnt = fopen(self.netname, FILE_READ);
261                         if(self.cnt < 0)
262                                 self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.tga"), FILE_READ);
263                         if(self.cnt < 0)
264                                 self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.png"), FILE_READ);
265                         if(self.cnt < 0)
266                                 self.cnt = fopen(strcat("gfx/", mi_shortname, "_radar.jpg"), FILE_READ);
267                         if(self.cnt < 0)
268                                 self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.tga"), FILE_READ);
269                         if(self.cnt < 0)
270                                 self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.png"), FILE_READ);
271                         if(self.cnt < 0)
272                                 self.cnt = fopen(strcat("gfx/", mi_shortname, "_mini.jpg"), FILE_READ);
273                         if(self.cnt >= 0)
274                         {
275                                 fclose(self.cnt);
276
277                                 print(self.netname, " already exists, aborting (you may want to specify --force)\n");
278                                 RadarMap_Next();
279                                 return;
280                         }
281                 }
282                 self.cnt = fopen(self.netname, FILE_WRITE);
283                 if(self.cnt < 0)
284                 {
285                         print("Error writing ", self.netname, "\n");
286                         remove(self);
287                         radarmapper = world;
288                         return;
289                 }
290                 print("Writing to ", self.netname, "...\n");
291                 fputs(self.cnt, "/* XPM */\n");
292                 fputs(self.cnt, "static char *RadarMap[] = {\n");
293                 fputs(self.cnt, "/* columns rows colors chars-per-pixel */\n");
294                 fputs(self.cnt, strcat("\"", ftos(self.size_x), " ", ftos(self.size_y), " 256 2\",\n"));
295                 for(i = 0; i < 256; ++i)
296                 {
297                         si = substring(doublehex, i*2, 2);
298                         fputs(self.cnt, strcat("\"", si, " c #", si, si, si, "\",\n"));
299                 }
300                 self.frame += 1;
301                 self.nextthink = time;
302                 sharpen_init(self.size_x);
303         }
304         else if(self.frame <= self.size_y)
305         {
306                 // fill the sharpen buffer with this line
307                 sharpen_shift(self.size_x);
308                 i = self.count & 24;
309
310                 switch(i)
311                 {
312                         case 0:
313                         default:
314                                 for(x = 0; x < self.size_x; ++x)
315                                 {
316                                         l = RadarMapAtPoint_Block(self.mins_x + x * self.maxs_x, self.mins_y + (self.size_y - self.frame) * self.maxs_y, self.maxs_x, self.maxs_y, self.mins_z, self.maxs_z, self.size_z);
317                                         sharpen_set(x, l);
318                                 }
319                                 break;
320                         case 8:
321                                 for(x = 0; x < self.size_x; ++x)
322                                 {
323                                         l = RadarMapAtPoint_Trace(self.mins_x + x * self.maxs_x, self.mins_y + (self.size_y - self.frame) * self.maxs_y, self.maxs_x, self.maxs_y, self.mins_z, self.maxs_z, self.size_z);
324                                         sharpen_set(x, l);
325                                 }
326                                 break;
327                         case 16:
328                                 for(x = 0; x < self.size_x; ++x)
329                                 {
330                                         l = RadarMapAtPoint_Sample(self.mins_x + x * self.maxs_x, self.mins_y + (self.size_y - self.frame) * self.maxs_y, self.maxs_x, self.maxs_y, self.mins_z, self.maxs_z, self.size_z);
331                                         sharpen_set(x, l);
332                                 }
333                                 break;
334                         case 24:
335                                 for(x = 0; x < self.size_x; ++x)
336                                 {
337                                         l = RadarMapAtPoint_LineBlock(self.mins_x + x * self.maxs_x, self.mins_y + (self.size_y - self.frame) * self.maxs_y, self.maxs_x, self.maxs_y, self.mins_z, self.maxs_z, self.size_z);
338                                         sharpen_set(x, l);
339                                 }
340                                 break;
341                 }
342
343                 // do we have enough lines?
344                 if(self.frame >= 2)
345                 {
346                         // write a pixel line
347                         fputs(self.cnt, "\"");
348                         for(x = 0; x < self.size_x; ++x)
349                         {
350                                 l = sharpen_get(x, self.ltime);
351                                 fputs(self.cnt, substring(doublehex, 2 * floor(l * 256.0), 2));
352                         }
353                         if(self.frame == self.size_y)
354                                 fputs(self.cnt, "\"\n");
355                         else
356                         {
357                                 fputs(self.cnt, "\",\n");
358                                 print(ftos(self.size_y - self.frame), " lines left\n");
359                         }
360                 }
361
362                 // is this the last line? then write back the missing line
363                 if(self.frame == self.size_y)
364                 {
365                         sharpen_shift(self.size_x);
366                         // write a pixel line
367                         fputs(self.cnt, "\"");
368                         for(x = 0; x < self.size_x; ++x)
369                         {
370                                 l = sharpen_get(x, self.ltime);
371                                 fputs(self.cnt, substring(doublehex, 2 * floor(l * 256.0), 2));
372                         }
373                         if(self.frame == self.size_y)
374                                 fputs(self.cnt, "\"\n");
375                         else
376                         {
377                                 fputs(self.cnt, "\",\n");
378                                 print(ftos(self.size_y - self.frame), " lines left\n");
379                         }
380                 }
381
382                 self.frame += 1;
383                 self.nextthink = time;
384         }
385         else
386         {
387                 // close the file
388                 fputs(self.cnt, "};\n");
389                 fclose(self.cnt);
390                 print("Finished. Please edit data/", self.netname, " with an image editing application and place it in the TGA format in the gfx folder.\n");
391                 RadarMap_Next();
392         }
393 }
394
395 void RadarMap(float argc)
396 {
397         if(radarmapper)
398                 return;
399         float i;
400         radarmapper = spawn();
401         radarmapper.classname = "radarmapper";
402         radarmapper.think = RadarMap_Think;
403         radarmapper.nextthink = time;
404         radarmapper.count = 8; // default to the --trace method, as it is faster now
405         radarmapper.ltime = 1;
406         radarmapper.size_x = 512;
407         radarmapper.size_y = 512;
408         radarmapper.size_z = 1;
409
410         for(i = 1; i < argc; ++i)
411         {
412                 if(argv(i) == "--force")
413                         radarmapper.count |= 1;
414                 else if(argv(i) == "--loop")
415                         radarmapper.count |= 2;
416                 else if(argv(i) == "--quit")
417                         radarmapper.count |= 4;
418                 else if(argv(i) == "--block")
419                 {
420                         radarmapper.count &~= 24;
421                 }
422                 else if(argv(i) == "--trace")
423                 {
424                         radarmapper.count &~= 24;
425                         radarmapper.count |= 8;
426                 }
427                 else if(argv(i) == "--sample")
428                 {
429                         radarmapper.count &~= 24;
430                         radarmapper.count |= 16;
431                 }
432                 else if(argv(i) == "--lineblock")
433                 {
434                         radarmapper.count |= 24;
435                 }
436                 else if(argv(i) == "--flags") // for the recursive call
437                 {
438                         ++i;
439                         radarmapper.count = stof(argv(i));
440                 }
441                 else if(argv(i) == "--sharpen") // for the recursive call
442                 {
443                         ++i;
444                         radarmapper.ltime = stof(argv(i));
445                 }
446                 else if(argv(i) == "--res") // resolution
447                 {
448                         ++i;
449                         radarmapper.size_x = stof(argv(i));
450                         ++i;
451                         radarmapper.size_y = stof(argv(i));
452                 }
453                 else if(argv(i) == "--qual") // quality multiplier
454                 {
455                         ++i;
456                         radarmapper.size_z = stof(argv(i));
457                 }
458                 else
459                 {
460                         remove(radarmapper);
461                         radarmapper = world;
462                         print("Usage: sv_cmd radarmap [--force] [--loop] [--quit] [--block | --trace | --sample | --lineblock] [--sharpen N] [--res W H] [--qual Q]\n");
463                         print("The quality factor Q is roughly proportional to the time taken.\n");
464                         print("--trace supports no quality factor; its result should look like --block with infinite quality factor.\n");
465                         print("--block \n");
466                         return;
467                 }
468         }
469
470         print("Radarmap entity spawned.\n");
471 }
472
473 // ======================
474 //  Supporting Functions
475 // ======================
476
477 void make_mapinfo_Think()
478 {
479         if(MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
480         {
481                 print("Done rebuiling mapinfos.\n");
482                 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
483                 remove(self);
484         }
485         else
486         {
487                 self.think = make_mapinfo_Think;
488                 self.nextthink = time;
489         }
490 }
491
492 void changematchtime(float delta, float mi, float ma)
493 {
494         float cur;
495         float new;
496         float lim;
497
498         if(delta == 0)
499                 return;
500         if(autocvar_timelimit < 0)
501                 return;
502
503         if(mi <= 10)
504                 mi = 10; // at least ten sec in the future
505         cur = time - game_starttime;
506         if(cur > 0)
507                 mi += cur; // from current time!
508
509         lim = autocvar_timelimit * 60;
510
511         if(delta > 0)
512         {
513                 if(lim == 0)
514                         return; // cannot increase any further
515                 else if(lim < ma)
516                         new = min(ma, lim + delta);
517                 else // already above maximum: FAIL
518                         return;
519         }
520         else
521         {
522                 if(lim == 0) // infinite: try reducing to max, if we are allowed to
523                         new = max(mi, ma);
524                 else if(lim > mi) // above minimum: decrease
525                         new = max(mi, lim + delta);
526                 else // already below minimum: FAIL
527                         return;
528         }
529
530         cvar_set("timelimit", ftos(new / 60));
531 }
532
533 float g_clientmodel_genericsendentity (entity to, float sf);
534 void modelbug_make_svqc();
535 void modelbug_make_csqc()
536 {
537         Net_LinkEntity(self, TRUE, 0, g_clientmodel_genericsendentity);
538         self.think = modelbug_make_svqc;
539         self.nextthink = time + 1;
540         setorigin(self, self.origin - '0 0 8');
541 }
542 void modelbug_make_svqc()
543 {
544         self.SendEntity = func_null;
545         self.think = modelbug_make_csqc;
546         self.nextthink = time + 1;
547         setorigin(self, self.origin + '0 0 8');
548 }
549
550 void modelbug()
551 {
552         entity e;
553         e = spawn();
554         setorigin(e, nextent(world).origin);
555         precache_model("models_portal.md3");
556         setmodel(e, "models/portal.md3");
557         e.think = modelbug_make_svqc;
558         e.nextthink = time + 1;
559 }
560
561 // ===================
562 //  Command Functions
563 // ===================
564 #define GC_REQUEST_HELP 1
565 #define GC_REQUEST_COMMAND 2
566 #define GC_REQUEST_USAGE 3
567
568 void GameCommand_adminmsg(float request, string command)
569 {
570         entity client;
571         float argc = tokenize_console(command);
572         float entno = stof(argv(1)); 
573         float n, i;
574         string s;
575         
576         switch(request)
577         {
578                 case GC_REQUEST_HELP:
579                         print("  ^2adminmsg^7: Send an admin message to a client directly\n");
580                         return;
581                         
582                 case GC_REQUEST_COMMAND:
583                         if(argc >= 3 && argc <= 4) {
584                                 if((entno < 0) | (entno > maxclients)) {
585                                         print("Player ", argv(1), " doesn't exist\n");
586                                         return;
587                                 }
588                                 n = 0;
589                                 for(i = (entno ? entno : 1); i <= (entno ? entno : maxclients); ++i)
590                                 {
591                                         client = edict_num(i);
592                                         if(client.flags & FL_CLIENT)
593                                         {
594                                                 if(argc == 4)
595                                                 {
596                                                         s = argv(2);
597                                                         s = strreplace("\n", "", s);
598                                                         s = strreplace("\\", "\\\\", s);
599                                                         s = strreplace("$", "$$", s);
600                                                         s = strreplace("\"", "\\\"", s);
601                                                         stuffcmd(client, sprintf("\ninfobar %f \"%s\"\n", stof(argv(3)), s));
602                                                 }
603                                                 else
604                                                 {
605                                                         centerprint_atprio(client, CENTERPRIO_ADMIN, strcat("^3", admin_name(), ":\n\n^7", argv(2)));
606                                                         sprint(client, strcat("\{1}\{13}^3", admin_name(), "^7: ", argv(2), "\n"));
607                                                 }
608                                                 dprint("Message sent to ", client.netname, "\n");
609                                                 ++n;
610                                         }
611                                 }
612                                 if(!n) { print("Client not found\n"); } 
613                                 return;
614                         } 
615                         
616                 default:
617                         print("Incorrect parameters for \"adminmsg\"\n");
618                 case GC_REQUEST_USAGE:
619                         print("\nUsage:^3 sv_cmd adminmsg clientnumber \"message\" [infobartime]\n");
620                         print("  If infobartime is provided, the message will be sent to infobar.\n");
621                         print("  Otherwise, it will just be sent as a centerprint message.\n");
622                         print("Examples: adminmsg 4 \"this message will last for ten seconds\" 10\n");
623                         print("          adminmsg 2 \"this message will be a centerprint\"\n");
624                         return;
625         }
626 }
627
628 void GameCommand_allready(float request)
629 {
630         switch(request)
631         {
632                 case GC_REQUEST_HELP:
633                         print("  ^2allready^7: Restart the server and reset the players\n");
634                         return;
635                         
636                 case GC_REQUEST_COMMAND:
637                         ReadyRestart();
638                         return;
639                         
640                 default:
641                 case GC_REQUEST_USAGE:
642                         print("\nUsage:^3 sv_cmd allready\n");
643                         print("  No arguments required.\n");
644                         return;
645         }
646 }
647
648 void GameCommand_allspec(float request) // todo: Add ability to provide a reason string?
649 {
650         entity client;
651         float i;
652         switch(request)
653         {
654                 case GC_REQUEST_HELP:
655                         print("  ^2allspec^7: Force all players to spectate\n");
656                         return;
657                         
658                 case GC_REQUEST_COMMAND:
659                         FOR_EACH_PLAYER(client)
660                         {
661                                 self = client;
662                                 PutObserverInServer();
663                                 ++i;
664                         }
665                         if(i) { bprint(strcat("Successfully forced all players to spectate (", ftos(i), ")\n")); } // should a message be added if no players were found? 
666                         return;
667                         
668                 default:
669                 case GC_REQUEST_USAGE:
670                         print("\nUsage:^3 sv_cmd allspec\n");
671                         print("  No arguments required.\n");
672                         print("  See also: ^2moveplayer^7\n");
673                         return;
674         }
675 }
676
677 void GameCommand_anticheat(float request, string command) // FIXME: player entity is never found
678 {
679         entity client;
680         float argc = tokenize_console(command);
681         float entno = stof(argv(1)); 
682         
683         switch(request)
684         {
685                 case GC_REQUEST_HELP:
686                         print("  ^2anticheat^7: Create an anticheat report for a client\n");
687                         return;
688                         
689                 case GC_REQUEST_COMMAND:
690                         if((entno < 1) | (entno > maxclients)) {
691                                 print("Player ", argv(1), " doesn't exist\n");
692                                 return;
693                         }
694                         client = edict_num(entno);
695                         if(clienttype(client) != CLIENTTYPE_REAL && clienttype(client) != CLIENTTYPE_BOT) {
696                                 print("Player ", client.netname, " is not active\n");
697                                 return;
698                         }
699                         self = client;
700                         anticheat_report();
701                         return;
702                         
703                 default:
704                         print("Incorrect parameters for \"anticheat\"\n");
705                 case GC_REQUEST_USAGE:
706                         print("\nUsage:^3 sv_cmd anticheat clientnumber\n");
707                         print("  where clientnumber is player entity number.\n");
708                         return;
709         }
710 }
711
712 void GameCommand_bbox(float request)
713 {
714         switch(request)
715         {
716                 case GC_REQUEST_HELP:
717                         print("  ^2bbox^7: Print detailed information about world size\n");
718                         return;
719                         
720                 case GC_REQUEST_COMMAND:
721                         print("Original size: ", ftos(world.absmin_x), " ", ftos(world.absmin_y), " ", ftos(world.absmin_z));
722                         print(" ", ftos(world.absmax_x), " ", ftos(world.absmax_y), " ", ftos(world.absmax_z), "\n");
723                         print("Currently set size: ", ftos(world.mins_x), " ", ftos(world.mins_y), " ", ftos(world.mins_z));
724                         print(" ", ftos(world.maxs_x), " ", ftos(world.maxs_y), " ", ftos(world.maxs_z), "\n");
725                         print("Solid bounding box size:");
726
727                         tracebox('1 0 0' * world.absmin_x,
728                                                         '0 1 0' * world.absmin_y + '0 0 1' * world.absmin_z,
729                                                         '0 1 0' * world.absmax_y + '0 0 1' * world.absmax_z,
730                                                         '1 0 0' * world.absmax_x,
731                                         MOVE_WORLDONLY,
732                                         world);
733                         if(trace_startsolid)
734                                 print(" ", ftos(world.absmin_x));
735                         else
736                                 print(" ", ftos(trace_endpos_x));
737
738                         tracebox('0 1 0' * world.absmin_y,
739                                                         '1 0 0' * world.absmin_x + '0 0 1' * world.absmin_z,
740                                                         '1 0 0' * world.absmax_x + '0 0 1' * world.absmax_z,
741                                                         '0 1 0' * world.absmax_y,
742                                         MOVE_WORLDONLY,
743                                         world);
744                         if(trace_startsolid)
745                                 print(" ", ftos(world.absmin_y));
746                         else
747                                 print(" ", ftos(trace_endpos_y));
748
749                         tracebox('0 0 1' * world.absmin_z,
750                                                         '1 0 0' * world.absmin_x + '0 1 0' * world.absmin_y,
751                                                         '1 0 0' * world.absmax_x + '0 1 0' * world.absmax_y,
752                                                         '0 0 1' * world.absmax_z,
753                                         MOVE_WORLDONLY,
754                                         world);
755                         if(trace_startsolid)
756                                 print(" ", ftos(world.absmin_z));
757                         else
758                                 print(" ", ftos(trace_endpos_z));
759
760                         tracebox('1 0 0' * world.absmax_x,
761                                                         '0 1 0' * world.absmin_y + '0 0 1' * world.absmin_z,
762                                                         '0 1 0' * world.absmax_y + '0 0 1' * world.absmax_z,
763                                                         '1 0 0' * world.absmin_x,
764                                         MOVE_WORLDONLY,
765                                         world);
766                         if(trace_startsolid)
767                                 print(" ", ftos(world.absmax_x));
768                         else
769                                 print(" ", ftos(trace_endpos_x));
770
771                         tracebox('0 1 0' * world.absmax_y,
772                                                         '1 0 0' * world.absmin_x + '0 0 1' * world.absmin_z,
773                                                         '1 0 0' * world.absmax_x + '0 0 1' * world.absmax_z,
774                                                         '0 1 0' * world.absmin_y,
775                                         MOVE_WORLDONLY,
776                                         world);
777                         if(trace_startsolid)
778                                 print(" ", ftos(world.absmax_y));
779                         else
780                                 print(" ", ftos(trace_endpos_y));
781
782                         tracebox('0 0 1' * world.absmax_z,
783                                                         '1 0 0' * world.absmin_x + '0 1 0' * world.absmin_y,
784                                                         '1 0 0' * world.absmax_x + '0 1 0' * world.absmax_y,
785                                                         '0 0 1' * world.absmin_z,
786                                         MOVE_WORLDONLY,
787                                         world);
788                         if(trace_startsolid)
789                                 print(" ", ftos(world.absmax_z));
790                         else
791                                 print(" ", ftos(trace_endpos_z));
792                                 
793                         print("\n");
794                         return;
795                         
796                 default:
797                 case GC_REQUEST_USAGE:
798                         print("\nUsage:^3 sv_cmd bbox\n");
799                         print("  No arguments required.\n");
800                         print("  See also: ^2gettaginfo^7\n");
801                         return;
802         }
803 }
804
805 void GameCommand_bot_cmd(float request, string command) // what a mess... old old code.
806 {
807         entity bot;
808         float argc = tokenize_console(command);
809         
810         switch(request)
811         {
812                 case GC_REQUEST_HELP:
813                         print("  ^2bot_cmd^7: Control and send commands to bots\n");
814                         return;
815                         
816                 case GC_REQUEST_COMMAND:
817                         if(argv(1) == "reset")
818                         {
819                                 bot_resetqueues();
820                                 return;
821                         }
822                         else if(argv(1) == "load" && argc == 3)
823                         {
824                                 float fh, i;
825                                 string s;
826                                 fh = fopen(argv(2), FILE_READ);
827                                 if(fh < 0)
828                                 {
829                                         print("cannot open the file\n");
830                                         return;
831                                 }
832
833                                 i = 0;
834                                 while((s = fgets(fh)))
835                                 {
836                                         argc = tokenize_console(s);
837
838                                         if(argc >= 3 && argv(0) == "sv_cmd" && argv(1) == "bot_cmd")
839                                         {
840                                                 // let's start at token 2 so we can skip sv_cmd bot_cmd
841                                                 bot = find_bot_by_number(stof(argv(2)));
842                                                 if(bot == world)
843                                                         bot = find_bot_by_name(argv(2));
844                                                 if(bot)
845                                                         bot_queuecommand(bot, strcat(argv(3), " ", argv(4)));
846                                         }
847                                         else
848                                                 localcmd(strcat(s, "\n"));
849
850                                         ++i;
851                                 }
852                                 print(ftos(i), " commands read\n");
853                                 fclose(fh);
854                                 return;
855                         }
856                         else if(argv(1) == "help")
857                         {
858                                 if(argv(2))
859                                         bot_cmdhelp(argv(2));
860                                 else
861                                         bot_list_commands();
862                                 return;
863                         }
864                         else if(argc >= 3) // this comes last
865                         {
866                                 bot = find_bot_by_number(stof(argv(1)));
867                                 if(bot == world)
868                                         bot = find_bot_by_name(argv(1));
869                                 if(bot)
870                                 {
871                                         print(strcat("Command '", (argv(2), " ", argv(3)), "' sent to bot ", bot.netname, "\n"));
872                                         bot_queuecommand(bot, strcat(argv(2), " ", argv(3)));
873                                         return;
874                                 }
875                                 else
876                                         print(strcat("Error: Can't find bot with the name or id '", argv(1),"' - Did you mistype the command?\n")); // don't return so that usage is shown
877                         }
878                         
879                 default:
880                         print("Incorrect parameters for \"bot_cmd\"\n");
881                 case GC_REQUEST_USAGE:
882                         print("\nUsage:^3 sv_cmd bot_cmd client command [argument]\n");
883                         print("  'client' can be either the name or entity id of the bot\n");
884                         print("  For full list of commands, see bot_cmd help [command].\n");
885                         print("Examples: bot_cmd <id> cc \"say something\"\n");
886                         print("          bot_cmd <id> presskey jump\n");
887                         return;
888         }
889 }
890
891 void GameCommand_cointoss(float request) // todo: Perhaps add the ability to give your own arguments to pick between? (Like player names)
892 {
893         entity client;
894         float choice = (random() > 0.5);
895         
896         switch(request)
897         {
898                 case GC_REQUEST_HELP:
899                         print("  ^2cointoss^7: Flip a virtual coin and give random result\n");
900                         return;
901                         
902                 case GC_REQUEST_COMMAND:
903                         FOR_EACH_CLIENT(client)
904                                 centerprint(client, strcat("^3Throwing coin... Result: ", (choice ? "^1HEADS^3!\n" : "^4TAILS^3!\n")));
905                         bprint(strcat("^3Throwing coin... Result: ", (choice ? "^1HEADS^3!\n" : "^4TAILS^3!\n")));
906                         return;
907                         
908                 default:
909                 case GC_REQUEST_USAGE:
910                         print("\nUsage:^3 sv_cmd cointoss\n");
911                         print("  No arguments required.\n");
912                         return;
913         }
914 }
915
916 void GameCommand_cvar_changes(float request)
917 {
918         switch(request)
919         {
920                 case GC_REQUEST_HELP:
921                         print("  ^2cvar_changes^7: Prints a list of all changed server cvars\n");
922                         return;
923                         
924                 case GC_REQUEST_COMMAND:
925                         print(cvar_changes);
926                         return;
927                         
928                 default:
929                 case GC_REQUEST_USAGE:
930                         print("\nUsage:^3 sv_cmd \n");
931                         print("  No arguments required.\n");
932                         print("  See also: ^2cvar_purechanges^7\n");
933                         return;
934         }
935 }
936
937 void GameCommand_cvar_purechanges(float request)
938 {
939         switch(request)
940         {
941                 case GC_REQUEST_HELP:
942                         print("  ^2cvar_purechanges^7: Prints a list of all changed gameplay cvars\n");
943                         return;
944                         
945                 case GC_REQUEST_COMMAND:
946                         print(cvar_purechanges);
947                         return;
948                         
949                 default:
950                 case GC_REQUEST_USAGE:
951                         print("\nUsage:^3 sv_cmd cvar_purechanges\n");
952                         print("  No arguments required.\n");
953                         print("  See also: ^2cvar_changes^7\n");
954                         return;
955         }
956 }
957
958 void GameCommand_database(float request, string command)
959 {
960         float argc = tokenize_console(command);
961         
962         switch(request)
963         {
964                 case GC_REQUEST_HELP:
965                         print("  ^2database^7: Extra controls of the serverprogs database\n");
966                         return;
967                         
968                 case GC_REQUEST_COMMAND:
969                         if(argc == 3)
970                         {
971                                 if(argv(1) == "save")
972                                 {
973                                         db_save(ServerProgsDB, argv(2));
974                                         print(strcat("Copied serverprogs database to '", argv(2), "' in the data directory.\n"));
975                                         return;
976                                 }
977                                 else if(argv(1) == "dump")
978                                 {
979                                         db_dump(ServerProgsDB, argv(2));
980                                         print("DB dumped.\n"); // wtf does this do?
981                                         return;
982                                 }
983                                 else if(argv(1) == "load")
984                                 {
985                                         db_close(ServerProgsDB);
986                                         ServerProgsDB = db_load(argv(2));
987                                         print(strcat("Loaded '", argv(2), "' as new serverprogs database.\n"));
988                                         return;
989                                 }
990                         }
991                         
992                 default:
993                         print("Incorrect parameters for \"database\"\n");
994                 case GC_REQUEST_USAGE:
995                         print("\nUsage:^3 sv_cmd database action filename\n");
996                         print("  Where 'action' is the command to complete,\n");
997                         print("  and 'filename' is what it acts upon.\n");
998                         print("  Full list of commands here: \"save, dump, load.\"\n");
999                         return;
1000         }
1001 }
1002
1003 void GameCommand_defer_clear(float request, string command)
1004 {
1005         entity client;
1006         float argc = tokenize_console(command);
1007         float entno = stof(argv(1));
1008         
1009         switch(request)
1010         {
1011                 case GC_REQUEST_HELP:
1012                         print("  ^2defer_clear^7: Clear all queued defer commands for client\n");
1013                         return;
1014                         
1015                 case GC_REQUEST_COMMAND:
1016                         if(argc == 2)
1017                         {
1018                                 // player_id is out of range
1019                                 if((entno < 1) | (entno > maxclients)) {
1020                                         print("Player ", argv(1), " doesn't exist\n");
1021                                         return;
1022                                 }
1023                                 client = edict_num(entno);
1024                                 if not(client.flags & FL_CLIENT) {
1025                                         print("Player ", argv(1), " doesn't exist\n");
1026                                         return;
1027                                 }
1028                                 if(clienttype(client) == CLIENTTYPE_BOT) {
1029                                         print("Player ", argv(1), " (", client.netname, ") is a bot\n");
1030                                         return;
1031                                 }
1032                                 stuffcmd(client, "defer clear\n");
1033                                 print("defer clear stuffed to ", argv(1), " (", client.netname, ")\n");
1034                                 return;
1035                         }
1036                 
1037                 default:
1038                         print("Incorrect parameters for \"defer_clear\"\n");
1039                 case GC_REQUEST_USAGE:
1040                         print("\nUsage:^3 sv_cmd defer_clear clientnumber\n");
1041                         print("  where 'clientnumber' is player entity number.\n");
1042                         print("  See also: ^2defer_clear_all^7\n");
1043                         return;
1044         }
1045 }
1046
1047 void GameCommand_defer_clear_all(float request)
1048 {
1049         entity client;
1050         float i;
1051         
1052         switch(request)
1053         {
1054                 case GC_REQUEST_HELP:
1055                         print("  ^2defer_clear_all^7: Clear all queued defer commands for all clients\n");
1056                         return;
1057                         
1058                 case GC_REQUEST_COMMAND:
1059                         FOR_EACH_CLIENT(client)
1060                         {
1061                                 GameCommand_defer_clear(GC_REQUEST_COMMAND, strcat("defer_clear ", ftos(num_for_edict(client))));       
1062                                 ++i;
1063                         }
1064                         if(i) { bprint(strcat("Successfully stuffed defer clear to all clients (", ftos(i), ")\n")); } // should a message be added if no players were found? 
1065                         return;
1066                 
1067                 default:
1068                 case GC_REQUEST_USAGE:
1069                         print("\nUsage:^3 sv_cmd defer_clear_all\n");
1070                         print("  No arguments required.\n");
1071                         print("  See also: ^2defer_clear^7\n");
1072                         return;
1073         }
1074 }
1075
1076 void GameCommand_delrec(float request, string command) // UNTESTED
1077 {
1078         float argc = tokenize_console(command);
1079
1080         switch(request)
1081         {
1082                 case GC_REQUEST_HELP:
1083                         print("  ^2delrec^7: Delete race time record for a map\n");
1084                         return;
1085                         
1086                 case GC_REQUEST_COMMAND:
1087                         if(argv(1))
1088                         {
1089                                 if(argv(2))
1090                                         race_deleteTime(argv(2), stof(argv(1)));
1091                                 else
1092                                         race_deleteTime(GetMapname(), stof(argv(1)));
1093                                 return;
1094                         }
1095                         
1096                 default:
1097                         print("Incorrect parameters for \"delrec\"\n");
1098                 case GC_REQUEST_USAGE:
1099                         print("\nUsage:^3 sv_cmd delrec ranking [map]\n");
1100                         print("  'ranking' is which ranking level to clear up to, \n");
1101                         print("  it will clear all records up to nth place.\n");
1102                         print("  if 'map' is not provided it will use current map.\n");
1103                         return;
1104         }
1105 }
1106
1107 void GameCommand_effectindexdump(float request)
1108 {
1109         float fh, d;
1110         string s;
1111         
1112         switch(request)
1113         {
1114                 case GC_REQUEST_HELP:
1115                         print("  ^2effectindexdump^7: Dump list of effects from code and effectinfo.txt\n");
1116                         return;
1117                         
1118                 case GC_REQUEST_COMMAND:
1119                         d = db_create();
1120                         print("begin of effects list\n");
1121                         db_put(d, "TE_GUNSHOT", "1"); print("effect TE_GUNSHOT is ", ftos(particleeffectnum("TE_GUNSHOT")), "\n");
1122                         db_put(d, "TE_GUNSHOTQUAD", "1"); print("effect TE_GUNSHOTQUAD is ", ftos(particleeffectnum("TE_GUNSHOTQUAD")), "\n");
1123                         db_put(d, "TE_SPIKE", "1"); print("effect TE_SPIKE is ", ftos(particleeffectnum("TE_SPIKE")), "\n");
1124                         db_put(d, "TE_SPIKEQUAD", "1"); print("effect TE_SPIKEQUAD is ", ftos(particleeffectnum("TE_SPIKEQUAD")), "\n");
1125                         db_put(d, "TE_SUPERSPIKE", "1"); print("effect TE_SUPERSPIKE is ", ftos(particleeffectnum("TE_SUPERSPIKE")), "\n");
1126                         db_put(d, "TE_SUPERSPIKEQUAD", "1"); print("effect TE_SUPERSPIKEQUAD is ", ftos(particleeffectnum("TE_SUPERSPIKEQUAD")), "\n");
1127                         db_put(d, "TE_WIZSPIKE", "1"); print("effect TE_WIZSPIKE is ", ftos(particleeffectnum("TE_WIZSPIKE")), "\n");
1128                         db_put(d, "TE_KNIGHTSPIKE", "1"); print("effect TE_KNIGHTSPIKE is ", ftos(particleeffectnum("TE_KNIGHTSPIKE")), "\n");
1129                         db_put(d, "TE_EXPLOSION", "1"); print("effect TE_EXPLOSION is ", ftos(particleeffectnum("TE_EXPLOSION")), "\n");
1130                         db_put(d, "TE_EXPLOSIONQUAD", "1"); print("effect TE_EXPLOSIONQUAD is ", ftos(particleeffectnum("TE_EXPLOSIONQUAD")), "\n");
1131                         db_put(d, "TE_TAREXPLOSION", "1"); print("effect TE_TAREXPLOSION is ", ftos(particleeffectnum("TE_TAREXPLOSION")), "\n");
1132                         db_put(d, "TE_TELEPORT", "1"); print("effect TE_TELEPORT is ", ftos(particleeffectnum("TE_TELEPORT")), "\n");
1133                         db_put(d, "TE_LAVASPLASH", "1"); print("effect TE_LAVASPLASH is ", ftos(particleeffectnum("TE_LAVASPLASH")), "\n");
1134                         db_put(d, "TE_SMALLFLASH", "1"); print("effect TE_SMALLFLASH is ", ftos(particleeffectnum("TE_SMALLFLASH")), "\n");
1135                         db_put(d, "TE_FLAMEJET", "1"); print("effect TE_FLAMEJET is ", ftos(particleeffectnum("TE_FLAMEJET")), "\n");
1136                         db_put(d, "EF_FLAME", "1"); print("effect EF_FLAME is ", ftos(particleeffectnum("EF_FLAME")), "\n");
1137                         db_put(d, "TE_BLOOD", "1"); print("effect TE_BLOOD is ", ftos(particleeffectnum("TE_BLOOD")), "\n");
1138                         db_put(d, "TE_SPARK", "1"); print("effect TE_SPARK is ", ftos(particleeffectnum("TE_SPARK")), "\n");
1139                         db_put(d, "TE_PLASMABURN", "1"); print("effect TE_PLASMABURN is ", ftos(particleeffectnum("TE_PLASMABURN")), "\n");
1140                         db_put(d, "TE_TEI_G3", "1"); print("effect TE_TEI_G3 is ", ftos(particleeffectnum("TE_TEI_G3")), "\n");
1141                         db_put(d, "TE_TEI_SMOKE", "1"); print("effect TE_TEI_SMOKE is ", ftos(particleeffectnum("TE_TEI_SMOKE")), "\n");
1142                         db_put(d, "TE_TEI_BIGEXPLOSION", "1"); print("effect TE_TEI_BIGEXPLOSION is ", ftos(particleeffectnum("TE_TEI_BIGEXPLOSION")), "\n");
1143                         db_put(d, "TE_TEI_PLASMAHIT", "1"); print("effect TE_TEI_PLASMAHIT is ", ftos(particleeffectnum("TE_TEI_PLASMAHIT")), "\n");
1144                         db_put(d, "EF_STARDUST", "1"); print("effect EF_STARDUST is ", ftos(particleeffectnum("EF_STARDUST")), "\n");
1145                         db_put(d, "TR_ROCKET", "1"); print("effect TR_ROCKET is ", ftos(particleeffectnum("TR_ROCKET")), "\n");
1146                         db_put(d, "TR_GRENADE", "1"); print("effect TR_GRENADE is ", ftos(particleeffectnum("TR_GRENADE")), "\n");
1147                         db_put(d, "TR_BLOOD", "1"); print("effect TR_BLOOD is ", ftos(particleeffectnum("TR_BLOOD")), "\n");
1148                         db_put(d, "TR_WIZSPIKE", "1"); print("effect TR_WIZSPIKE is ", ftos(particleeffectnum("TR_WIZSPIKE")), "\n");
1149                         db_put(d, "TR_SLIGHTBLOOD", "1"); print("effect TR_SLIGHTBLOOD is ", ftos(particleeffectnum("TR_SLIGHTBLOOD")), "\n");
1150                         db_put(d, "TR_KNIGHTSPIKE", "1"); print("effect TR_KNIGHTSPIKE is ", ftos(particleeffectnum("TR_KNIGHTSPIKE")), "\n");
1151                         db_put(d, "TR_VORESPIKE", "1"); print("effect TR_VORESPIKE is ", ftos(particleeffectnum("TR_VORESPIKE")), "\n");
1152                         db_put(d, "TR_NEHAHRASMOKE", "1"); print("effect TR_NEHAHRASMOKE is ", ftos(particleeffectnum("TR_NEHAHRASMOKE")), "\n");
1153                         db_put(d, "TR_NEXUIZPLASMA", "1"); print("effect TR_NEXUIZPLASMA is ", ftos(particleeffectnum("TR_NEXUIZPLASMA")), "\n");
1154                         db_put(d, "TR_GLOWTRAIL", "1"); print("effect TR_GLOWTRAIL is ", ftos(particleeffectnum("TR_GLOWTRAIL")), "\n");
1155                         db_put(d, "TR_SEEKER", "1"); print("effect TR_SEEKER is ", ftos(particleeffectnum("TR_SEEKER")), "\n");
1156                         db_put(d, "SVC_PARTICLE", "1"); print("effect SVC_PARTICLE is ", ftos(particleeffectnum("SVC_PARTICLE")), "\n");
1157
1158                         fh = fopen("effectinfo.txt", FILE_READ);
1159                         while((s = fgets(fh)))
1160                         {
1161                                 tokenize(s); // tokenize_console would hit the loop counter :(
1162                                 if(argv(0) == "effect")
1163                                 {
1164                                         if(db_get(d, argv(1)) != "1")
1165                                         {
1166                                                 if(particleeffectnum(argv(1)) >= 0)
1167                                                         print("effect ", argv(1), " is ", ftos(particleeffectnum(argv(1))), "\n");
1168                                                 db_put(d, argv(1), "1");
1169                                         }
1170                                 }
1171                         }
1172                         print("end of effects list\n");
1173
1174                         db_close(d);
1175                         return;
1176                         
1177                 default:
1178                 case GC_REQUEST_USAGE:
1179                         print("\nUsage:^3 sv_cmd effectindexdump\n");
1180                         print("  No arguments required.\n");
1181                         return;
1182         }
1183 }
1184
1185 void GameCommand_extendmatchtime(float request) // todo: Perhaps allows the user to send a specific time to extend it.
1186 {
1187         switch(request)
1188         {
1189                 case GC_REQUEST_HELP:
1190                         print("  ^2extendmatchtime^7: Increase the timelimit value incrementally\n");
1191                         return;
1192                         
1193                 case GC_REQUEST_COMMAND:
1194                         changematchtime(autocvar_timelimit_increment* 60, autocvar_timelimit_min*60, autocvar_timelimit_max*60);
1195                         return;
1196                         
1197                 default:
1198                 case GC_REQUEST_USAGE:
1199                         print("\nUsage:^3 sv_cmd extendmatchtime\n");
1200                         print("  No arguments required.\n");
1201                         print("  See also: ^2reducematchtime^7\n");
1202                         return;
1203         }
1204 }
1205
1206 void GameCommand_find(float request, string command)
1207 {
1208         entity client;
1209         float argc = tokenize_console(command);
1210         
1211         switch(request)
1212         {
1213                 case GC_REQUEST_HELP:
1214                         print("  ^2find^7: Search through entities for matching classname\n");
1215                         return;
1216                         
1217                 case GC_REQUEST_COMMAND:
1218                         for(client = world; (client = find(client, classname, argv(1))); )
1219                                 print(etos(client), "\n");
1220                         return;
1221                         
1222                 default:
1223                         print("Incorrect parameters for \"find\"\n");
1224                 case GC_REQUEST_USAGE:
1225                         print("\nUsage:^3 sv_cmd find classname\n");
1226                         print("  Where 'classname' is the classname to search for.\n");
1227                         return;
1228         }
1229 }
1230
1231 void GameCommand_gametype(float request, string command)
1232 {
1233         float argc = tokenize_console(command);
1234         string s = argv(1);
1235         float t = MapInfo_Type_FromString(s), tsave = MapInfo_CurrentGametype();
1236         
1237         switch(request)
1238         {
1239                 case GC_REQUEST_HELP:
1240                         print("  ^2gametype^7: Simple command to change the active gametype\n");
1241                         return;
1242                         
1243                 case GC_REQUEST_COMMAND:
1244                         if(t)
1245                         {
1246                                 MapInfo_SwitchGameType(t);
1247                                 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
1248                                 if(MapInfo_count > 0)
1249                                         bprint("Game type successfully switched to ", s, "\n");
1250                                 else
1251                                 {
1252                                         bprint("Cannot use this game type: no map for it found\n");
1253                                         MapInfo_SwitchGameType(tsave);
1254                                         MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
1255                                 }
1256                         }
1257                         else
1258                                 bprint("Game type switch to ", s, " failed: this type does not exist!\n");
1259                         return;
1260                         
1261                 default:
1262                         print("Incorrect parameters for \"gametype\"\n");
1263                 case GC_REQUEST_USAGE:
1264                         print("\nUsage:^3 sv_cmd gametype mode\n");
1265                         print("  Where 'mode' is the gametype mode to switch to.\n");
1266                         print("  See also: ^2gotomap^7\n");
1267                         return;
1268         }
1269 }
1270
1271 void GameCommand_gettaginfo(float request, string command) // UNTESTED // todo: finish usage description for it (but, must first learn this shit)
1272 {
1273         entity tmp_entity;
1274         float argc = tokenize_console(command), i;
1275         vector v;
1276         switch(request)
1277         {
1278                 case GC_REQUEST_HELP:
1279                         print("  ^2gettaginfo^7: Get specific information about a weapon model\n");
1280                         return;
1281                         
1282                 case GC_REQUEST_COMMAND:
1283                         if(argc >= 4)
1284                         {
1285                                 tmp_entity = spawn();
1286                                 if(argv(1) == "w")
1287                                         setmodel(tmp_entity, (nextent(world)).weaponentity.model);
1288                                 else
1289                                 {
1290                                         precache_model(argv(1));
1291                                         setmodel(tmp_entity, argv(1));
1292                                 }
1293                                 tmp_entity.frame = stof(argv(2));
1294                                 if(substring(argv(3), 0, 1) == "#")
1295                                         i = stof(substring(argv(3), 1, -1));
1296                                 else
1297                                         i = gettagindex(tmp_entity, argv(3));
1298                                 if(i)
1299                                 {
1300                                         v = gettaginfo(tmp_entity, i);
1301                                         print("model ", tmp_entity.model, " frame ", ftos(tmp_entity.frame), " tag ", gettaginfo_name);
1302                                         print(" index ", ftos(i), " parent ", ftos(gettaginfo_parent), "\n");
1303                                         print(" vector = ", ftos(v_x), " ", ftos(v_y), " ", ftos(v_z), "\n");
1304                                         print(" offset = ", ftos(gettaginfo_offset_x), " ", ftos(gettaginfo_offset_y), " ", ftos(gettaginfo_offset_z), "\n");
1305                                         print(" forward = ", ftos(gettaginfo_forward_x), " ", ftos(gettaginfo_forward_y), " ", ftos(gettaginfo_forward_z), "\n");
1306                                         print(" right = ", ftos(gettaginfo_right_x), " ", ftos(gettaginfo_right_y), " ", ftos(gettaginfo_right_z), "\n");
1307                                         print(" up = ", ftos(gettaginfo_up_x), " ", ftos(gettaginfo_up_y), " ", ftos(gettaginfo_up_z), "\n");
1308                                         if(argc >= 6)
1309                                         {
1310                                                 v_y = -v_y;
1311                                                 localcmd(strcat(argv(4), vtos(v), argv(5), "\n"));
1312                                         }
1313                                 }
1314                                 else
1315                                         print("bone not found\n");
1316                                         
1317                                 remove(tmp_entity);
1318                                 return;
1319                         }
1320                         
1321                 default:
1322                         print("Incorrect parameters for \"gettaginfo\"\n");
1323                 case GC_REQUEST_USAGE:
1324                         print("\nUsage:^3 sv_cmd gettaginfo\n");
1325                         print("  FIXME: Arguments currently unknown\n");
1326                         print("  See also: ^2bbox^7\n");
1327                         return;
1328         }
1329 }
1330
1331 void GameCommand_gotomap(float request, string command)
1332 {
1333         float argc = tokenize_console(command);
1334         
1335         switch(request)
1336         {
1337                 case GC_REQUEST_HELP:
1338                         print("  ^2gotomap^7: Simple command to switch to another map\n");
1339                         return;
1340                         
1341                 case GC_REQUEST_COMMAND:
1342                         if(argc == 2)
1343                         {
1344                                 print(GotoMap(argv(1)), "\n");
1345                                 return;
1346                         }
1347                         
1348                 default:
1349                         print("Incorrect parameters for \"gotomap\"\n");
1350                 case GC_REQUEST_USAGE:
1351                         print("\nUsage:^3 sv_cmd gotomap map\n");
1352                         print("  Where 'map' is the *.bsp file to change to.\n");
1353                         print("  See also: ^2gametype^7\n");
1354                         return;
1355         }
1356 }
1357
1358 void GameCommand_ladder(float request)
1359 {
1360         switch(request)
1361         {
1362                 case GC_REQUEST_HELP:
1363                         print("  ^2ladder^7: Get information about top players if supported\n");
1364                         return;
1365                         
1366                 case GC_REQUEST_COMMAND:
1367                         print(ladder_reply);
1368                         return;
1369                         
1370                 default:
1371                 case GC_REQUEST_USAGE:
1372                         print("\nUsage:^3 sv_cmd ladder\n");
1373                         print("  No arguments required.\n");
1374                         return;
1375         }
1376 }
1377
1378 void GameCommand_lockteams(float request)
1379 {
1380         switch(request)
1381         {
1382                 case GC_REQUEST_HELP:
1383                         print("  ^2lockteams^7: Disable the ability for players to switch or enter teams\n");
1384                         return;
1385                         
1386                 case GC_REQUEST_COMMAND:
1387                         if(teamplay)
1388                         {
1389                                 lockteams = 1;
1390                                 bprint("^1The teams are now locked.\n");
1391                         }
1392                         else
1393                                 bprint("That command can only be used in a team-based gamemode.\n");
1394                         return;
1395                         
1396                 default:
1397                 case GC_REQUEST_USAGE:
1398                         print("\nUsage:^3 sv_cmd lockteams\n");
1399                         print("  No arguments required.\n");
1400                         print("  See also: ^2unlockteams^7\n");
1401                         return;
1402         }
1403 }
1404
1405 void GameCommand_make_mapinfo(float request) // UNTESTED
1406 {
1407         entity tmp_entity;
1408         
1409         switch(request)
1410         {
1411                 case GC_REQUEST_HELP:
1412                         print("  ^2make_mapinfo^7: Automatically rebuild mapinfo files\n");
1413                         return;
1414                         
1415                 case GC_REQUEST_COMMAND: 
1416                         tmp_entity = spawn();
1417                         tmp_entity.classname = "make_mapinfo";
1418                         tmp_entity.think = make_mapinfo_Think;
1419                         tmp_entity.nextthink = time; // this sucks... todo: re-write this -- Use initializeentity later
1420                         MapInfo_Enumerate();
1421                         return;
1422                         
1423                 default:
1424                 case GC_REQUEST_USAGE:
1425                         print("\nUsage:^3 sv_cmd make_mapinfo\n");
1426                         print("  No arguments required.\n");
1427                         return;
1428         }
1429 }
1430
1431 void GameCommand_modelbug(float request) // UNTESTED // is this even needed anymore? 
1432 {
1433         switch(request)
1434         {
1435                 case GC_REQUEST_HELP:
1436                         print("  ^2modelbug^7: foobar\n");
1437                         return;
1438                         
1439                 case GC_REQUEST_COMMAND:
1440                         modelbug();
1441                         return;
1442                         
1443                 default:
1444                 case GC_REQUEST_USAGE:
1445                         print("\nUsage:^3 sv_cmd modelbug\n");
1446                         print("  No arguments required.\n");
1447                         return;
1448         }
1449 }
1450
1451 void GameCommand_moveplayer(float request, string command)
1452 {
1453         entity client;
1454         float argc, i;
1455         argc = tokenize_console(command); // we can only have one argc, so we store the information from it to other strings
1456         string targets = argv(1);
1457         string destination = argv(2);
1458         string notify = argv(3);
1459         argc = tokenizebyseparator(targets, ","); // and re-use it later for the target selection.
1460         
1461         switch(request)
1462         {
1463                 case GC_REQUEST_HELP:
1464                         print("  ^2moveplayer^7: Change the team/status of a player\n");
1465                         return;
1466                         
1467                 case GC_REQUEST_COMMAND:
1468                         // lets see if the target(s) even actually exist.
1469                         if((targets) && (destination))
1470                         { 
1471                                 for(i = 0; i < argc; ++i)
1472                                 {
1473                                         // Check to see if the player is a valid target
1474                                         if((stof(argv(i)) < 1) | (stof(argv(i)) > maxclients)) // player_id is out of range
1475                                         {
1476                                                 print(strcat("Player ", argv(i), " doesn't exist", (((i + 1) < argc) ? ", skipping to next player.\n" : ".\n")));
1477                                                 continue; 
1478                                         }
1479                                         client = edict_num(stof(argv(i)));
1480                                         if not(client.flags & FL_CLIENT) // player entity is not a client
1481                                         {
1482                                                 print(strcat("Player ", argv(i), " doesn't exist", (((i + 1) < argc) ? ", skipping to next player.\n" : ".\n")));
1483                                                 continue;
1484                                         }
1485                                         
1486                                         // Where are we putting this player?
1487                                         if(destination == "spec" || destination == "spectator") 
1488                                         {
1489                                                 if(client.classname != "spectator" && client.classname != "observer")
1490                                                 {
1491                                                         self = client;
1492                                                         PutObserverInServer();
1493                                                 }
1494                                                 else
1495                                                 {
1496                                                         print("Player ", argv(i), " (", client.netname, ") is already spectating.\n");
1497                                                 }
1498                                                 return;
1499                                         }
1500                                         else
1501                                         {
1502                                                 if(client.classname != "spectator" && client.classname != "observer")
1503                                                 {
1504                                                         if(teamplay)
1505                                                         {
1506                                                                 // set up
1507                                                                 float team_color;
1508                                                                 float save = client.team_forced;
1509                                                                 client.team_forced = 0;
1510
1511                                                                 // find the team to move the player to
1512                                                                 team_color = ColourToNumber(destination);
1513                                                                 if(team_color == client.team) // already on the destination team
1514                                                                 {
1515                                                                         // keep the forcing undone
1516                                                                         print("Player ", argv(i), " (", client.netname, ") is already on the ", ColoredTeamName(client.team), ".\n");
1517                                                                         return;
1518                                                                 } 
1519                                                                 else if(team_color == 0)  // auto team
1520                                                                 {
1521                                                                         team_color = NumberToTeamNumber(FindSmallestTeam(client, FALSE));
1522                                                                 }
1523                                                                 else
1524                                                                 {
1525                                                                         CheckAllowedTeams(client);
1526                                                                 }
1527                                                                 client.team_forced = save;
1528                                                                 
1529                                                                 // Check to see if the destination team is even available
1530                                                                 switch(team_color) 
1531                                                                 {
1532                                                                         case COLOR_TEAM1:
1533                                                                                 if(c1 == -1) {
1534                                                                                         print("Sorry, can't move player to red team if it doesn't exist.\n");
1535                                                                                         return;
1536                                                                                 }
1537                                                                                 break;
1538
1539                                                                         case COLOR_TEAM2:
1540                                                                                 if(c2 == -1) {
1541                                                                                         print("Sorry, can't move player to blue team if it doesn't exist.\n");
1542                                                                                         return;
1543                                                                                 }
1544                                                                                 break;
1545
1546                                                                         case COLOR_TEAM3:
1547                                                                                 if(c3 == -1) {
1548                                                                                         print("Sorry, can't move player to yellow team if it doesn't exist.\n");
1549                                                                                         return;
1550                                                                                 }
1551                                                                                 break;
1552
1553                                                                         case COLOR_TEAM4:
1554                                                                                 if(c4 == -1) {
1555                                                                                         print("Sorry, can't move player to pink team if it doesn't exist.\n");
1556                                                                                         return;
1557                                                                                 }
1558                                                                                 break;
1559
1560                                                                         default:
1561                                                                                 print("Sorry, can't move player here if team ", destination, " doesn't exist.\n");
1562                                                                                 return;
1563                                                                 }
1564                                                                 
1565                                                                 // If so, lets continue and finally move the player
1566                                                                 client.team_forced = 0;
1567                                                                 MoveToTeam(client, team_color, 6, stof(notify));
1568                                                                 print("Player ", argv(i), " (", client.netname, ") has been moved to the ", ColoredTeamName(team_color), ".\n");
1569                                                                 return;
1570                                                         }
1571                                                         else
1572                                                         {
1573                                                                 print("Can't change teams when currently not playing a team game.\n");
1574                                                                 return;
1575                                                         }
1576                                                 }
1577                                                 else
1578                                                 {
1579                                                         print("Can't change teams if the player isn't in the game.\n"); // well technically we could, but should we allow that? :P 
1580                                                         return;
1581                                                 }
1582                                         }
1583                                 }
1584                                 print("No acceptable players given, aborting.\n");
1585                                 return; // still correct parameters so return to avoid usage print
1586                         }
1587                         
1588                 default:
1589                         print("Incorrect parameters for \"moveplayer\"\n");
1590                 case GC_REQUEST_USAGE:
1591                         print("\nUsage:^3 sv_cmd moveplayer clientnumbers destination [notify]\n");
1592                         print("  'clientnumbers' is a list (separated by commas) of player entity ID's\n");
1593                         print("  'destination' is what to send the player to, be it team or spectating\n");
1594                         print("  Full list of destinations here: \"spec, spectator, red, blue, yellow, pink, auto.\"\n");
1595                         print("  'notify' is whether or not to send messages notifying of the move. Detail below.\n");
1596                         print("    0 (00) automove centerprint, admin message; 1 (01) automove centerprint, no admin message\n");
1597                         print("    2 (10) no centerprint, admin message; 3 (11) no centerprint, no admin message\n");
1598                         print("Examples: moveplayer 1,3,5 red 3\n");
1599                         print("          moveplayer 2 spec \n");
1600                         print("  See also: ^2allspec^7\n");
1601                         return;
1602         }
1603 }
1604
1605 void GameCommand_nospectators(float request)
1606 {
1607         switch(request)
1608         {
1609                 case GC_REQUEST_HELP:
1610                         print("  ^2nospectators^7: Automatically remove spectators from a match\n");
1611                         return;
1612                         
1613                 case GC_REQUEST_COMMAND:
1614                         blockSpectators = 1;
1615                         entity plr;
1616                         FOR_EACH_CLIENT(plr) //give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
1617                         {
1618                                 if(plr.classname == "spectator" || plr.classname == "observer")
1619                                 {
1620                                         plr.spectatortime = time;
1621                                         sprint(plr, strcat("^7You have to become a player within the next ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds, otherwise you will be kicked, because spectators aren't allowed at this time!\n"));
1622                                 }
1623                         }
1624                         bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds!\n"));
1625                         return;
1626                         
1627                 default:
1628                 case GC_REQUEST_USAGE:
1629                         print("\nUsage:^3 sv_cmd nospectators\n");
1630                         print("  No arguments required.\n");
1631                         return;
1632         }
1633 }
1634
1635 void GameCommand_onslaught_updatelinks(float request) // UNTESTED // should this be here? Perhaps some mutatorhook call instead....
1636 {
1637         switch(request)
1638         {
1639                 case GC_REQUEST_HELP:
1640                         print("  ^2onslaught_updatelinks^7: Refresh link status for onslaught\n");
1641                         return;
1642                         
1643                 case GC_REQUEST_COMMAND:
1644                         onslaught_updatelinks();
1645                         print("ONS links updated\n");
1646                         return;
1647                         
1648                 default:
1649                 case GC_REQUEST_USAGE:
1650                         print("\nUsage:^3 sv_cmd onslaught_updatelinks\n");
1651                         print("  No arguments required.\n");
1652                         return;
1653         }
1654 }
1655
1656 void GameCommand_playerdemo(float request, string command) // UNTESTED
1657 {
1658         entity client;
1659         float argc = tokenize_console(command), i, n, entno;
1660         string s;
1661         
1662         switch(request)
1663         {
1664                 case GC_REQUEST_HELP:
1665                         print("  ^2playerdemo^7: Control the ability to save demos of players\n");
1666                         return;
1667                         
1668                 case GC_REQUEST_COMMAND:
1669                         if(argv(1) == "read")
1670                         {
1671                                 // TODO: Create a general command for looking this up, save a lot of space everywhere in this file
1672                                 entno = stof(argv(2));
1673                                 if((entno < 1) | (entno > maxclients)) {
1674                                         print("Player ", argv(2), " doesn't exist\n");
1675                                         return;
1676                                 }
1677                                 client = edict_num(entno);
1678                                 if(clienttype(client) != CLIENTTYPE_BOT) {
1679                                         print("Player ", client.netname, " is not a bot\n");
1680                                         return;
1681                                 }
1682                                 self = client;
1683                                 playerdemo_open_read(argv(3));
1684                                 return;
1685                         }
1686                         else if(argv(1) == "write")
1687                         {
1688                                 entno = stof(argv(2));
1689                                 if((entno < 1) | (entno > maxclients)) {
1690                                         print("Player ", argv(2), " doesn't exist\n");
1691                                         return;
1692                                 }
1693                                 client = edict_num(entno);
1694                                 self = client;
1695                                 playerdemo_open_write(argv(3));
1696                                 return;
1697                         }
1698                         else if(argv(1) == "auto_read_and_write")
1699                         {
1700                                 s = argv(2);
1701                                 n = stof(argv(3));
1702                                 cvar_set("bot_number", ftos(n));
1703                                 localcmd("wait; wait; wait\n");
1704                                 for(i = 0; i < n; ++i)
1705                                         localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", s, ftos(i+1), "\n");
1706                                 localcmd("sv_cmd playerdemo write 1 ", ftos(n+1), "\n");
1707                                 return;
1708                         }
1709                         else if(argv(1) == "auto_read")
1710                         {
1711                                 s = argv(2);
1712                                 n = stof(argv(3));
1713                                 cvar_set("bot_number", ftos(n));
1714                                 localcmd("wait; wait; wait\n");
1715                                 for(i = 0; i < n; ++i)
1716                                         localcmd("sv_cmd playerdemo read ", ftos(i+2), " ", s, ftos(i+1), "\n");
1717                                 return;
1718                         }
1719                         return;
1720                         
1721                 default:
1722                 case GC_REQUEST_USAGE:
1723                         print("\nUsage:^3 sv_cmd \n");
1724                         print("  No arguments required.\n");
1725                         print("  FIXME: Arguments currently unknown\n");
1726                         return;
1727         }
1728 }
1729
1730 void GameCommand_printstats(float request)
1731 {
1732         switch(request)
1733         {
1734                 case GC_REQUEST_HELP:
1735                         print("  ^2printstats^7: foobar\n");
1736                         return;
1737                         
1738                 case GC_REQUEST_COMMAND:
1739                         DumpStats(FALSE);
1740                         print("stats dumped.\n"); 
1741                         return;
1742                         
1743                 default:
1744                 case GC_REQUEST_USAGE:
1745                         print("\nUsage:^3 sv_cmd printstats\n");
1746                         print("  No arguments required.\n");
1747                         return;
1748         }
1749 }
1750
1751 void GameCommand(string command)
1752 {
1753         // ===== TODO list =====
1754         
1755         // Finish adding the rest of the commands
1756         
1757         // Add ifdef to stuffto so that is can only be used when the game code is compiled for it 
1758         //(this way it's more obscure and harder to abuse on normal servers)
1759
1760         float search_request_type;
1761         float argc = tokenize_console(command);
1762
1763         if(argv(0) == "help") 
1764         {
1765                 if(argc == 1) 
1766                 {
1767                         print("\nUsage:^3 sv_cmd COMMAND...^7, where possible commands are:\n");
1768                         GameCommand_adminmsg(GC_REQUEST_HELP, "");
1769                         GameCommand_allready(GC_REQUEST_HELP);
1770                         GameCommand_allspec(GC_REQUEST_HELP);
1771                         GameCommand_anticheat(GC_REQUEST_HELP, "");
1772                         GameCommand_bbox(GC_REQUEST_HELP);
1773                         GameCommand_bot_cmd(GC_REQUEST_HELP, "");
1774                         GameCommand_cointoss(GC_REQUEST_HELP);
1775                         GameCommand_cvar_changes(GC_REQUEST_HELP);
1776                         GameCommand_cvar_purechanges(GC_REQUEST_HELP);
1777                         GameCommand_database(GC_REQUEST_HELP, "");
1778                         GameCommand_defer_clear(GC_REQUEST_HELP, "");
1779                         GameCommand_defer_clear_all(GC_REQUEST_HELP);
1780                         GameCommand_delrec(GC_REQUEST_HELP, "");
1781                         GameCommand_effectindexdump(GC_REQUEST_HELP);
1782                         GameCommand_extendmatchtime(GC_REQUEST_HELP);
1783                         GameCommand_find(GC_REQUEST_HELP, "");
1784                         GameCommand_gametype(GC_REQUEST_HELP, "");
1785                         GameCommand_gettaginfo(GC_REQUEST_HELP, "");
1786                         GameCommand_gotomap(GC_REQUEST_HELP, "");
1787                         GameCommand_ladder(GC_REQUEST_HELP);
1788                         GameCommand_lockteams(GC_REQUEST_HELP);
1789                         GameCommand_make_mapinfo(GC_REQUEST_HELP);
1790                         GameCommand_modelbug(GC_REQUEST_HELP);
1791                         GameCommand_moveplayer(GC_REQUEST_HELP, "");
1792                         GameCommand_nospectators(GC_REQUEST_HELP);
1793                         GameCommand_onslaught_updatelinks(GC_REQUEST_HELP);
1794                         GameCommand_playerdemo(GC_REQUEST_HELP, "");
1795                         GameCommand_printstats(GC_REQUEST_HELP);
1796                         GameCommand_Vote("help", world);
1797                         GameCommand_Ban("help");
1798                         GameCommand_Generic("help");
1799                         print("For help about specific commands, type sv_cmd help COMMAND\n");
1800                         return;
1801                 } 
1802                 else
1803                         search_request_type = GC_REQUEST_USAGE; // Instead of trying to call a command, we're going to see detailed information about it
1804         } 
1805         else if(GameCommand_Vote(command, world)) 
1806         {
1807                 return; // handled by server/vote.qc 
1808         }
1809         else if(GameCommand_Ban(command)) 
1810         {
1811                 return; // handled by server/ipban.qc
1812         }
1813         else if(GameCommand_Generic(command)) 
1814         {
1815                 return; // handled by common/gamecommand.qc
1816         }
1817         else
1818                 search_request_type = GC_REQUEST_COMMAND; // continue as usual and scan for normal commands
1819                 
1820         switch( ((argv(0) == "help") ? argv(1) : argv(0)) ) // if first argument is help, then search for the second argument. Else, search for first. 
1821         {
1822                 case "adminmsg": GameCommand_adminmsg(search_request_type, command); break;
1823                 case "allready": GameCommand_allready(search_request_type); break;
1824                 case "allspec": GameCommand_allspec(search_request_type); break;
1825                 case "anticheat": GameCommand_anticheat(search_request_type, command); break;
1826                 case "bbox": GameCommand_bbox(search_request_type); break;
1827                 case "bot_cmd": GameCommand_bot_cmd(search_request_type, command); break;
1828                 case "cointoss": GameCommand_cointoss(search_request_type); break; 
1829                 case "cvar_changes": GameCommand_cvar_changes(search_request_type); break; 
1830                 case "cvar_purechanges": GameCommand_cvar_purechanges(search_request_type); break; 
1831                 case "database": GameCommand_database(search_request_type, command); break;
1832                 case "defer_clear": GameCommand_defer_clear(search_request_type, command); break;
1833                 case "defer_clear_all": GameCommand_defer_clear_all(search_request_type); break;
1834                 case "delrec": GameCommand_delrec(search_request_type, command); break;
1835                 case "effectindexdump": GameCommand_effectindexdump(search_request_type); break;
1836                 case "extendmatchtime": GameCommand_extendmatchtime(search_request_type); break;
1837                 case "find": GameCommand_find(search_request_type, command); break; 
1838                 case "gametype": GameCommand_gametype(search_request_type, command); break;
1839                 case "gettaginfo": GameCommand_gettaginfo(search_request_type, command); break;
1840                 case "gotomap": GameCommand_gotomap(search_request_type, command); break;
1841                 case "ladder": GameCommand_ladder(search_request_type); break;
1842                 case "lockteams": GameCommand_lockteams(search_request_type); break;
1843                 case "make_mapinfo": GameCommand_make_mapinfo(search_request_type); break;
1844                 case "modelbug": GameCommand_modelbug(search_request_type); break;
1845                 case "moveplayer": GameCommand_moveplayer(search_request_type, command); break;
1846                 case "nospectators": GameCommand_nospectators(search_request_type); break;
1847                 case "onslaught_updatelinks": GameCommand_onslaught_updatelinks(search_request_type); break;
1848                 case "playerdemo": GameCommand_playerdemo(search_request_type, command); break;
1849                 case "printstats": GameCommand_printstats(search_request_type); break;
1850                 //case "radarmap": GameCommand_radarmap(search_request_type); break; // TODO: handled in server/radarmap.qc
1851                 
1852                 default:
1853                         print("Invalid command. For a list of supported commands, try sv_cmd help.\n");
1854         }
1855 }
1856