]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/command/cmd.qc
fb891125882c08be9f861d6b30f48edafb5a6b72
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / cmd.qc
1 // =========================================================
2 //  Server side networked commands code, reworked by Samual
3 //  Last updated: December 28th, 2011
4 // =========================================================
5
6 float SV_ParseClientCommand_floodcheck()
7 {
8         if (!timeout_status) // not while paused
9         {
10                 if(time <= (self.cmd_floodtime + autocvar_sv_clientcommand_antispam_time))
11                 {
12                         self.cmd_floodcount += 1;
13                         if(self.cmd_floodcount > autocvar_sv_clientcommand_antispam_count) { return FALSE; } // too much spam, halt
14                 }
15                 else
16                 {
17                         self.cmd_floodtime = time;
18                         self.cmd_floodcount = 1;
19                 }
20         }
21         return TRUE; // continue, as we're not flooding yet
22 }
23
24
25 // =======================
26 //  Command Sub-Functions
27 // =======================
28
29 void ClientCommand_autoswitch(float request, float argc)
30 {
31         switch(request)
32         {
33                 case CMD_REQUEST_COMMAND:
34                 {
35                         if(argv(1) != "")
36                         {
37                                 self.autoswitch = InterpretBoolean(argv(1));
38                                 sprint(self, strcat("^1autoswitch is currently turned ", (self.autoswitch ? "on" : "off"), ".\n"));
39                                 return;
40                         }
41                 }
42
43                 default:
44                         sprint(self, "Incorrect parameters for ^2autoswitch^7\n");
45                 case CMD_REQUEST_USAGE:
46                 {
47                         sprint(self, "\nUsage:^3 cmd autoswitch selection\n");
48                         sprint(self, "  Where 'selection' controls if autoswitch is on or off.\n");
49                         return;
50                 }
51         }
52 }
53
54 void ClientCommand_checkfail(float request, string command) // internal command, used only by code
55 {
56         switch(request)
57         {
58                 case CMD_REQUEST_COMMAND:
59                 {
60                         print(sprintf("CHECKFAIL: %s (%s) epically failed check %s\n", self.netname, self.netaddress, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1))));
61                         self.checkfail = 1;
62                         return; // never fall through to usage
63                 }
64
65                 default:
66                         sprint(self, "Incorrect parameters for ^2checkfail^7\n");
67                 case CMD_REQUEST_USAGE:
68                 {
69                         sprint(self, "\nUsage:^3 cmd checkfail <message>\n");
70                         sprint(self, "  Where 'message' is the message reported by client about the fail.\n");
71                         return;
72                 }
73         }
74 }
75
76 void ClientCommand_clientversion(float request, float argc) // internal command, used only by code
77 {
78         switch(request)
79         {
80                 case CMD_REQUEST_COMMAND:
81                 {
82                         if(argv(1) != "")
83                         {
84                                 if(IS_CLIENT(self))
85                                 {
86                                         self.version = ((argv(1) == "$gameversion") ? 1 : stof(argv(1)));
87
88                                         if(self.version < autocvar_gameversion_min || self.version > autocvar_gameversion_max)
89                                         {
90                                                 self.version_mismatch = 1;
91                                                 ClientKill_TeamChange(-2); // observe
92                                         }
93                                         else if(autocvar_g_campaign || autocvar_g_balance_teams)
94                                         {
95                                                 //JoinBestTeam(self, FALSE, TRUE);
96                                         }
97                                         else if(teamplay && !autocvar_sv_spectate && !(self.team_forced > 0))
98                                         {
99                                                 self.classname = "observer"; // really?
100                                                 stuffcmd(self, "menu_showteamselect\n");
101                                         }
102                                 }
103
104                                 return;
105                         }
106                 }
107
108                 default:
109                         sprint(self, "Incorrect parameters for ^2clientversion^7\n");
110                 case CMD_REQUEST_USAGE:
111                 {
112                         sprint(self, "\nUsage:^3 cmd clientversion version\n");
113                         sprint(self, "  Where 'version' is the game version reported by self.\n");
114                         return;
115                 }
116         }
117 }
118
119 void ClientCommand_mv_getpicture(float request, float argc) // internal command, used only by code
120 {
121         switch(request)
122         {
123                 case CMD_REQUEST_COMMAND:
124                 {
125                         if(argv(1) != "")
126                         {
127                                 if(intermission_running)
128                                         MapVote_SendPicture(stof(argv(1)));
129
130                                 return;
131                         }
132                 }
133
134                 default:
135                         sprint(self, "Incorrect parameters for ^2mv_getpicture^7\n");
136                 case CMD_REQUEST_USAGE:
137                 {
138                         sprint(self, "\nUsage:^3 cmd mv_getpicture mapid\n");
139                         sprint(self, "  Where 'mapid' is the id number of the map to request an image of on the map vote selection menu.\n");
140                         return;
141                 }
142         }
143 }
144
145 void ClientCommand_join(float request)
146 {
147         switch(request)
148         {
149                 case CMD_REQUEST_COMMAND:
150                 {
151                         if(IS_CLIENT(self))
152                         {
153                                 if(!IS_PLAYER(self) && !lockteams)
154                                 {
155                                         if(nJoinAllowed(self))
156                                         {
157                                                 if(autocvar_g_campaign) { campaign_bots_may_start = 1; }
158
159                                                 self.classname = "player";
160                                                 PlayerScore_Clear(self);
161                                                 Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_PREVENT_JOIN);
162                                                 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_JOIN_PLAY, self.netname);
163                                                 PutClientInServer();
164                                         }
165                                         else
166                                         {
167                                                 //player may not join because of g_maxplayers is set
168                                                 Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_JOIN_PREVENT);
169                                         }
170                                 }
171                         }
172                         return; // never fall through to usage
173                 }
174
175                 default:
176                 case CMD_REQUEST_USAGE:
177                 {
178                         sprint(self, "\nUsage:^3 cmd join\n");
179                         sprint(self, "  No arguments required.\n");
180                         return;
181                 }
182         }
183 }
184
185 void ClientCommand_mobedit(float request, float argc)
186 {
187         switch(request)
188         {
189                 case CMD_REQUEST_COMMAND:
190                 {
191                         makevectors(self.v_angle);
192                         WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 100, MOVE_NORMAL, self);
193                         
194                         if(!(trace_ent.flags & FL_MONSTER)) { sprint(self, "You need to aim at your monster to edit its properties.\n"); return; }
195                         if(trace_ent.realowner != self) { sprint(self, "That monster does not belong to you.\n"); return; }
196                         
197                         switch(argv(1))
198                         {
199                                 case "skin": if(trace_ent.monsterid != MON_MAGE) { trace_ent.skin = stof(argv(2)); } return;
200                                 case "movetarget": trace_ent.monster_moveflags = stof(argv(2)); return;
201                         }
202                 }
203                 default:
204                         sprint(self, "Incorrect parameters for ^2mobedit^7\n");
205                 case CMD_REQUEST_USAGE:
206                 {
207                         sprint(self, "\nUsage:^3 cmd mobedit [argument]\n");
208                         sprint(self, "  Where 'argument' can be skin or movetarget.\n");
209                         return;
210                 }
211         }
212 }
213
214 void ClientCommand_mobkill(float request)
215 {
216         switch(request)
217         {
218                 case CMD_REQUEST_COMMAND:
219                 {
220                         makevectors(self.v_angle);
221                         WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 100, MOVE_NORMAL, self);
222                         
223                         if(trace_ent.flags & FL_MONSTER)
224                         {
225                                 if(trace_ent.realowner != self)
226                                 {
227                                         sprint(self, "That monster does not belong to you.\n");
228                                         return;
229                                 }
230                                 sprint(self, strcat("Your pet '", trace_ent.monster_name, "' has been brutally mutilated.\n"));
231                                 Damage (trace_ent, world, world, trace_ent.health + trace_ent.max_health + 200, DEATH_KILL, trace_ent.origin, '0 0 0');
232                                 return;
233                         }
234                         else
235                                 sprint(self, "You need to aim at your monster to kill it.\n");
236                         
237                         return;
238                 }
239         
240                 default:
241                         sprint(self, "Incorrect parameters for ^2mobkill^7\n");
242                 case CMD_REQUEST_USAGE:
243                 {
244                         sprint(self, "\nUsage:^3 cmd mobkill\n");
245                         sprint(self, "  Aim at your monster to kill it.\n");
246                         return;
247                 }
248         }
249 }
250
251 void ClientCommand_mobspawn(float request, float argc)
252 {
253         switch(request)
254         {
255                 case CMD_REQUEST_COMMAND:
256                 {
257                         entity e;
258                         string tospawn;
259                         float moveflag;
260                         
261                         moveflag = (argv(2) ? stof(argv(2)) : 1); // follow owner if not defined
262                         tospawn = strtolower(argv(1));
263                         
264                         if(tospawn == "list")
265                         {
266                                 sprint(self, monsterlist_reply);
267                                 return;
268                         }
269                         
270                         if(autocvar_g_monsters_max <= 0 || autocvar_g_monsters_max_perplayer <= 0) { sprint(self, "Monster spawning is disabled.\n"); }
271                         else if(!IS_PLAYER(self)) { sprint(self, "You can't spawn monsters while spectating.\n"); }
272                         else if(g_invasion) { sprint(self, "You can't spawn monsters during an invasion!\n"); }
273                         else if(!autocvar_g_monsters) { Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_MONSTERS_DISABLED); }
274                         else if(self.vehicle) { sprint(self, "You can't spawn monsters while driving a vehicle.\n"); }
275                         else if(autocvar_g_campaign) { sprint(self, "You can't spawn monsters in campaign mode.\n"); }
276                         else if(self.deadflag != DEAD_NO) { sprint(self, "You can't spawn monsters while dead.\n"); }
277                         else if(self.monstercount >= autocvar_g_monsters_max_perplayer) { sprint(self, "You have spawned too many monsters, kill some before trying to spawn any more.\n"); }
278                         else if(totalspawned >= autocvar_g_monsters_max) { sprint(self, "The global maximum monster count has been reached, kill some before trying to spawn any more.\n"); }
279                         else // all worked out, so continue
280                         {
281                                 self.monstercount += 1;
282                                 totalspawned += 1;
283                         
284                                 makevectors(self.v_angle);
285                                 WarpZone_TraceBox (CENTER_OR_VIEWOFS(self), PL_MIN, PL_MAX, CENTER_OR_VIEWOFS(self) + v_forward * 150, TRUE, self);
286                                 //WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 150, MOVE_NORMAL, self);
287                         
288                                 e = spawnmonster(tospawn, 0, self, self, trace_endpos, FALSE, moveflag);
289                                 
290                                 sprint(self, strcat("Spawned ", e.monster_name, "\n"));
291                         }
292                         
293                         return;
294                 }
295         
296                 default:
297                         sprint(self, "Incorrect parameters for ^2mobspawn^7\n");
298                 case CMD_REQUEST_USAGE:
299                 {
300                         sprint(self, "\nUsage:^3 cmd mobspawn monster\n");
301                         sprint(self, "  See 'cmd mobspawn list' for available arguments.\n");
302                         sprint(self, "  Argument 'random' spawns a randomly selected monster.\n");
303                         return;
304                 }
305         }
306 }
307
308 void ClientCommand_ready(float request) // todo: anti-spam for toggling readyness
309 {
310         switch(request)
311         {
312                 case CMD_REQUEST_COMMAND:
313                 {
314                         if(IS_CLIENT(self))
315                         {
316                                 if(warmup_stage || autocvar_sv_ready_restart || g_race_qualifying == 2)
317                                 {
318                                         if(!readyrestart_happened || autocvar_sv_ready_restart_repeatable)
319                                         {
320                                                 if(time < game_starttime) // game is already restarting
321                                                         return;
322                                                 if (self.ready) // toggle
323                                                 {
324                                                         self.ready = FALSE;
325                                                         bprint(self.netname, "^2 is ^1NOT^2 ready\n");
326                                                 }
327                                                 else
328                                                 {
329                                                         self.ready = TRUE;
330                                                         bprint(self.netname, "^2 is ready\n");
331                                                 }
332
333                                                 // cannot reset the game while a timeout is active!
334                                                 if (!timeout_status)
335                                                         ReadyCount();
336                                         } else {
337                                                 sprint(self, "^1Game has already been restarted\n");
338                                         }
339                                 }
340                         }
341                         return; // never fall through to usage
342                 }
343
344                 default:
345                 case CMD_REQUEST_USAGE:
346                 {
347                         sprint(self, "\nUsage:^3 cmd ready\n");
348                         sprint(self, "  No arguments required.\n");
349                         return;
350                 }
351         }
352 }
353
354 void ClientCommand_say(float request, float argc, string command)
355 {
356         switch(request)
357         {
358                 case CMD_REQUEST_COMMAND:
359                 {
360                         if(argc >= 2) { Say(self, FALSE, world, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1); }
361                         return; // never fall through to usage
362                 }
363
364                 default:
365                 case CMD_REQUEST_USAGE:
366                 {
367                         sprint(self, "\nUsage:^3 cmd say <message>\n");
368                         sprint(self, "  Where 'message' is the string of text to say.\n");
369                         return;
370                 }
371         }
372 }
373
374 void ClientCommand_say_team(float request, float argc, string command)
375 {
376         switch(request)
377         {
378                 case CMD_REQUEST_COMMAND:
379                 {
380                         if(argc >= 2) { Say(self, TRUE, world, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1); }
381                         return; // never fall through to usage
382                 }
383
384                 default:
385                 case CMD_REQUEST_USAGE:
386                 {
387                         sprint(self, "\nUsage:^3 cmd say_team <message>\n");
388                         sprint(self, "  Where 'message' is the string of text to say.\n");
389                         return;
390                 }
391         }
392 }
393
394 void ClientCommand_selectteam(float request, float argc)
395 {
396         switch(request)
397         {
398                 case CMD_REQUEST_COMMAND:
399                 {
400                         if(argv(1) != "")
401                         {
402                                 if(IS_CLIENT(self))
403                                 {
404                                         if(teamplay)
405                                                 if(self.team_forced <= 0)
406                                                         if (!lockteams)
407                                                         {
408                                                                 float selection;
409
410                                                                 switch(argv(1))
411                                                                 {
412                                                                         case "red": selection = NUM_TEAM_1; break;
413                                                                         case "blue": selection = NUM_TEAM_2; break;
414                                                                         case "yellow": selection = NUM_TEAM_3; break;
415                                                                         case "pink": selection = NUM_TEAM_4; break;
416                                                                         case "auto": selection = (-1); break;
417
418                                                                         default: selection = 0; break;
419                                                                 }
420
421                                                                 if(selection)
422                                                                 {
423                                                                         if(self.team == selection && self.deadflag == DEAD_NO)
424                                                                                 sprint(self, "^7You already are on that team.\n");
425                                                                         else if(self.wasplayer && autocvar_g_changeteam_banned)
426                                                                                 sprint(self, "^1You cannot change team, forbidden by the server.\n");
427                                                                         else
428                                                                                 ClientKill_TeamChange(selection);
429                                                                 }
430                                                         }
431                                                         else
432                                                                 sprint(self, "^7The game has already begun, you must wait until the next map to be able to join a team.\n");
433                                                 else
434                                                         sprint(self, "^7selectteam can not be used as your team is forced\n");
435                                         else
436                                                 sprint(self, "^7selectteam can only be used in teamgames\n");
437                                 }
438                                 return;
439                         }
440                 }
441
442                 default:
443                         sprint(self, "Incorrect parameters for ^2selectteam^7\n");
444                 case CMD_REQUEST_USAGE:
445                 {
446                         sprint(self, "\nUsage:^3 cmd selectteam team\n");
447                         sprint(self, "  Where 'team' is the prefered team to try and join.\n");
448                         sprint(self, "  Full list of options here: \"red, blue, yellow, pink, auto\"\n");
449                         return;
450                 }
451         }
452 }
453
454 void ClientCommand_selfstuff(float request, string command)
455 {
456         switch(request)
457         {
458                 case CMD_REQUEST_COMMAND:
459                 {
460                         if(argv(1) != "")
461                         {
462                                 stuffcmd(self, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
463                                 return;
464                         }
465                 }
466
467                 default:
468                         sprint(self, "Incorrect parameters for ^2selectteam^7\n");
469                 case CMD_REQUEST_USAGE:
470                 {
471                         sprint(self, "\nUsage:^3 cmd selfstuff <command>\n");
472                         sprint(self, "  Where 'command' is the string to be stuffed to your client.\n");
473                         return;
474                 }
475         }
476 }
477
478 void ClientCommand_sentcvar(float request, float argc, string command)
479 {
480         switch(request)
481         {
482                 case CMD_REQUEST_COMMAND:
483                 {
484                         if(argv(1) != "")
485                         {
486                                 //float tokens;
487                                 string s;
488
489                                 if(argc == 2) // undefined cvar: use the default value on the server then
490                                 {
491                                         s = strcat(substring(command, argv_start_index(0), argv_end_index(1) - argv_start_index(0)), " \"", cvar_defstring(argv(1)), "\"");
492                                         tokenize_console(s);
493                                 }
494
495                                 GetCvars(1);
496
497                                 return;
498                         }
499                 }
500
501                 default:
502                         sprint(self, "Incorrect parameters for ^2sentcvar^7\n");
503                 case CMD_REQUEST_USAGE:
504                 {
505                         sprint(self, "\nUsage:^3 cmd sentcvar <cvar>\n");
506                         sprint(self, "  Where 'cvar' is the cvar plus arguments to send to the server.\n");
507                         return;
508                 }
509         }
510 }
511
512 void ClientCommand_spectate(float request)
513 {
514         switch(request)
515         {
516                 case CMD_REQUEST_COMMAND:
517                 {
518                         if(IS_CLIENT(self))
519                         {
520                                 if(g_lms)
521                                 {
522                                         if(self.lms_spectate_warning)
523                                         {
524                                                 // for the forfeit message...
525                                                 self.lms_spectate_warning = 2;
526                                                 // mark player as spectator
527                                                 PlayerScore_Add(self, SP_LMS_RANK, 666 - PlayerScore_Add(self, SP_LMS_RANK, 0));
528                                         }
529                                         else
530                                         {
531                                                 self.lms_spectate_warning = 1;
532                                                 sprint(self, "WARNING: you won't be able to enter the game again after spectating in LMS. Use the same command again to spectate anyway.\n");
533                                                 return;
534                                         }
535                                 }
536
537                                 if(IS_PLAYER(self) && autocvar_sv_spectate == 1)
538                                         ClientKill_TeamChange(-2); // observe
539
540                                 // in CA, allow a dead player to move to spectators (without that, caplayer!=0 will be moved back to the player list)
541                                 // note: if arena game mode is ever done properly, this needs to be removed.
542                                 if(self.caplayer && (IS_SPEC(self) || IS_OBSERVER(self)))
543                                 {
544                                         sprint(self, "WARNING: you will spectate in the next round.\n");
545                                         self.caplayer = 0;
546                                 }
547                         }
548                         return; // never fall through to usage
549                 }
550
551                 default:
552                 case CMD_REQUEST_USAGE:
553                 {
554                         sprint(self, "\nUsage:^3 cmd spectate\n");
555                         sprint(self, "  No arguments required.\n");
556                         return;
557                 }
558         }
559 }
560
561 void ClientCommand_suggestmap(float request, float argc)
562 {
563         switch(request)
564         {
565                 case CMD_REQUEST_COMMAND:
566                 {
567                         if(argv(1) != "")
568                         {
569                                 sprint(self, strcat(MapVote_Suggest(argv(1)), "\n"));
570                                 return;
571                         }
572                 }
573
574                 default:
575                         sprint(self, "Incorrect parameters for ^2suggestmap^7\n");
576                 case CMD_REQUEST_USAGE:
577                 {
578                         sprint(self, "\nUsage:^3 cmd suggestmap map\n");
579                         sprint(self, "  Where 'map' is the name of the map to suggest.\n");
580                         return;
581                 }
582         }
583 }
584
585 void ClientCommand_tell(float request, float argc, string command)
586 {
587         switch(request)
588         {
589                 case CMD_REQUEST_COMMAND:
590                 {
591                         if(argc >= 3)
592                         {
593                                 entity tell_to = GetIndexedEntity(argc, 1);
594                                 float tell_accepted = VerifyClientEntity(tell_to, TRUE, FALSE);
595
596                                 if(tell_accepted > 0) // the target is a real client
597                                 {
598                                         if(tell_to != self) // and we're allowed to send to them :D
599                                         {
600                                                 Say(self, FALSE, tell_to, substring(command, argv_start_index(next_token), argv_end_index(-1) - argv_start_index(next_token)), TRUE);
601                                                 return;
602                                         }
603                                         else { print_to(self, "You can't ^2tell^7 a message to yourself."); return; }
604                                 }
605                                 else if(argv(1) == "#0")
606                                 {
607                                         trigger_magicear_processmessage_forallears(self, -1, world, substring(command, argv_start_index(next_token), argv_end_index(-1) - argv_start_index(next_token)));
608                                         return;
609                                 }
610                                 else { print_to(self, strcat("tell: ", GetClientErrorString(tell_accepted, argv(1)), ".")); return; }
611                         }
612                 }
613
614                 default:
615                         sprint(self, "Incorrect parameters for ^2tell^7\n");
616                 case CMD_REQUEST_USAGE:
617                 {
618                         sprint(self, "\nUsage:^3 cmd tell client <message>\n");
619                         sprint(self, "  Where 'client' is the entity number or name of the player to send 'message' to.\n");
620                         return;
621                 }
622         }
623 }
624
625 void ClientCommand_voice(float request, float argc, string command)
626 {
627         switch(request)
628         {
629                 case CMD_REQUEST_COMMAND:
630                 {
631                         if(argv(1) != "")
632                         {
633                                 if(argc >= 3)
634                                         VoiceMessage(argv(1), substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2)));
635                                 else
636                                         VoiceMessage(argv(1), "");
637
638                                 return;
639                         }
640                 }
641
642                 default:
643                         sprint(self, "Incorrect parameters for ^2voice^7\n");
644                 case CMD_REQUEST_USAGE:
645                 {
646                         sprint(self, "\nUsage:^3 cmd voice messagetype <soundname>\n");
647                         sprint(self, "  'messagetype' is the type of broadcast to do, like team only or such,\n");
648                         sprint(self, "  and 'soundname' is the string/filename of the sound/voice message to play.\n");
649                         return;
650                 }
651         }
652 }
653
654 /* use this when creating a new command, making sure to place it in alphabetical order... also,
655 ** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION!
656 void ClientCommand_(float request)
657 {
658         switch(request)
659         {
660                 case CMD_REQUEST_COMMAND:
661                 {
662
663                         return; // never fall through to usage
664                 }
665
666                 default:
667                 case CMD_REQUEST_USAGE:
668                 {
669                         sprint(self, "\nUsage:^3 cmd \n");
670                         sprint(self, "  No arguments required.\n");
671                         return;
672                 }
673         }
674 }
675 */
676
677
678 // =====================================
679 //  Macro system for networked commands
680 // =====================================
681
682 // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
683 #define CLIENT_COMMANDS(request,arguments,command) \
684         CLIENT_COMMAND("autoswitch", ClientCommand_autoswitch(request, arguments), "Whether or not to switch automatically when getting a better weapon") \
685         CLIENT_COMMAND("checkfail", ClientCommand_checkfail(request, command), "Report if a client-side check failed") \
686         CLIENT_COMMAND("clientversion", ClientCommand_clientversion(request, arguments), "Release version of the game") \
687         CLIENT_COMMAND("mv_getpicture", ClientCommand_mv_getpicture(request, arguments), "Retrieve mapshot picture from the server") \
688         CLIENT_COMMAND("join", ClientCommand_join(request), "Become a player in the game") \
689         CLIENT_COMMAND("mobedit", ClientCommand_mobedit(request, arguments), "Edit your monster's properties") \
690         CLIENT_COMMAND("mobkill", ClientCommand_mobkill(request), "Kills your monster") \
691         CLIENT_COMMAND("mobspawn", ClientCommand_mobspawn(request, arguments), "Spawn monsters infront of yourself") \
692         CLIENT_COMMAND("ready", ClientCommand_ready(request), "Qualify as ready to end warmup stage (or restart server if allowed)") \
693         CLIENT_COMMAND("say", ClientCommand_say(request, arguments, command), "Print a message to chat to all players") \
694         CLIENT_COMMAND("say_team", ClientCommand_say_team(request, arguments, command), "Print a message to chat to all team mates") \
695         CLIENT_COMMAND("selectteam", ClientCommand_selectteam(request, arguments), "Attempt to choose a team to join into") \
696         CLIENT_COMMAND("selfstuff", ClientCommand_selfstuff(request, command), "Stuffcmd a command to your own client") \
697         CLIENT_COMMAND("sentcvar", ClientCommand_sentcvar(request, arguments, command), "New system for sending a client cvar to the server") \
698         CLIENT_COMMAND("spectate", ClientCommand_spectate(request), "Become an observer") \
699         CLIENT_COMMAND("suggestmap", ClientCommand_suggestmap(request, arguments), "Suggest a map to the mapvote at match end") \
700         CLIENT_COMMAND("tell", ClientCommand_tell(request, arguments, command), "Send a message directly to a player") \
701         CLIENT_COMMAND("voice", ClientCommand_voice(request, arguments, command), "Send voice message via sound") \
702         /* nothing */
703
704 void ClientCommand_macro_help()
705 {
706         #define CLIENT_COMMAND(name,function,description) \
707                 { sprint(self, "  ^2", name, "^7: ", description, "\n"); }
708
709         CLIENT_COMMANDS(0, 0, "")
710         #undef CLIENT_COMMAND
711
712         return;
713 }
714
715 float ClientCommand_macro_command(float argc, string command)
716 {
717         #define CLIENT_COMMAND(name,function,description) \
718                 { if(name == strtolower(argv(0))) { function; return TRUE; } }
719
720         CLIENT_COMMANDS(CMD_REQUEST_COMMAND, argc, command)
721         #undef CLIENT_COMMAND
722
723         return FALSE;
724 }
725
726 float ClientCommand_macro_usage(float argc)
727 {
728         #define CLIENT_COMMAND(name,function,description) \
729                 { if(name == strtolower(argv(1))) { function; return TRUE; } }
730
731         CLIENT_COMMANDS(CMD_REQUEST_USAGE, argc, "")
732         #undef CLIENT_COMMAND
733
734         return FALSE;
735 }
736
737 void ClientCommand_macro_write_aliases(float fh)
738 {
739         #define CLIENT_COMMAND(name,function,description) \
740                 { CMD_Write_Alias("qc_cmd_cmd", name, description); }
741
742         CLIENT_COMMANDS(0, 0, "")
743         #undef CLIENT_COMMAND
744
745         return;
746 }
747
748 // ======================================
749 //  Main Function Called By Engine (cmd)
750 // ======================================
751 // If this function exists, server game code parses clientcommand before the engine code gets it.
752
753 void SV_ParseClientCommand(string command)
754 {
755         // if we're banned, don't even parse the command
756         if(Ban_MaybeEnforceBanOnce(self))
757                 return;
758
759         float argc = tokenize_console(command);
760
761         // for the mutator hook system
762         cmd_name = strtolower(argv(0));
763         cmd_argc = argc;
764         cmd_string = command;
765
766         // Guide for working with argc arguments by example:
767         // argc:   1    - 2      - 3     - 4
768         // argv:   0    - 1      - 2     - 3
769         // cmd     vote - master - login - password
770
771         // for floodcheck
772         switch(strtolower(argv(0)))
773         {
774                 // exempt commands which are not subject to floodcheck
775                 case "begin": break; // handled by engine in host_cmd.c
776                 case "download": break; // handled by engine in cl_parse.c
777                 case "mv_getpicture": break; // handled by server in this file
778                 case "pause": break; // handled by engine in host_cmd.c
779                 case "prespawn": break; // handled by engine in host_cmd.c
780                 case "sentcvar": break; // handled by server in this file
781                 case "spawn": break; // handled by engine in host_cmd.c
782
783                 default:
784                         if(SV_ParseClientCommand_floodcheck())
785                                 break; // "TRUE": continue, as we're not flooding yet
786                         else
787                                 return; // "FALSE": not allowed to continue, halt // print("^1ERROR: ^7ANTISPAM CAUGHT: ", command, ".\n");
788         }
789
790         /* NOTE: should this be disabled? It can be spammy perhaps, but hopefully it's okay for now */
791         if(argv(0) == "help")
792         {
793                 if(argc == 1)
794                 {
795                         sprint(self, "\nClient networked commands:\n");
796                         ClientCommand_macro_help();
797
798                         sprint(self, "\nCommon networked commands:\n");
799                         CommonCommand_macro_help(self);
800
801                         sprint(self, "\nUsage:^3 cmd COMMAND...^7, where possible commands are listed above.\n");
802                         sprint(self, "For help about a specific command, type cmd help COMMAND\n");
803                         return;
804                 }
805                 else if(CommonCommand_macro_usage(argc, self)) // Instead of trying to call a command, we're going to see detailed information about it
806                 {
807                         return;
808                 }
809                 else if(ClientCommand_macro_usage(argc)) // same, but for normal commands now
810                 {
811                         return;
812                 }
813         }
814         else if(MUTATOR_CALLHOOK(SV_ParseClientCommand))
815         {
816                 return; // handled by a mutator
817         }
818         else if(CheatCommand(argc))
819         {
820                 return; // handled by server/cheats.qc
821         }
822         else if(CommonCommand_macro_command(argc, self, command))
823         {
824                 return; // handled by server/command/common.qc
825         }
826         else if(ClientCommand_macro_command(argc, command)) // continue as usual and scan for normal commands
827         {
828                 return; // handled by one of the above ClientCommand_* functions
829         }
830         else
831                 clientcommand(self, command);
832 }