]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/command/cmd.qc
3d1015dfcd7d5ffd33d0045f3f7ce0d137d2e383
[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 not(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 && !g_arena)
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 not(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                         return;
303                 }
304         }
305 }
306
307 void ClientCommand_ready(float request) // todo: anti-spam for toggling readyness
308 {
309         switch(request)
310         {
311                 case CMD_REQUEST_COMMAND:
312                 {
313                         if(IS_CLIENT(self))
314                         {
315                                 if(warmup_stage || autocvar_sv_ready_restart || g_race_qualifying == 2)
316                                 {
317                                         if(!readyrestart_happened || autocvar_sv_ready_restart_repeatable)
318                                         {
319                                                 if(time < game_starttime) // game is already restarting
320                                                         return;
321                                                 if (self.ready) // toggle
322                                                 {
323                                                         self.ready = FALSE;
324                                                         bprint(self.netname, "^2 is ^1NOT^2 ready\n");
325                                                 }
326                                                 else
327                                                 {
328                                                         self.ready = TRUE;
329                                                         bprint(self.netname, "^2 is ready\n");
330                                                 }
331
332                                                 // cannot reset the game while a timeout is active!
333                                                 if not(timeout_status)
334                                                         ReadyCount();
335                                         } else {
336                                                 sprint(self, "^1Game has already been restarted\n");
337                                         }
338                                 }
339                         }
340                         return; // never fall through to usage
341                 }
342                         
343                 default:
344                 case CMD_REQUEST_USAGE:
345                 {
346                         sprint(self, "\nUsage:^3 cmd ready\n");
347                         sprint(self, "  No arguments required.\n");
348                         return;
349                 }
350         }
351 }
352
353 void ClientCommand_say(float request, float argc, string command)
354 {
355         switch(request)
356         {
357                 case CMD_REQUEST_COMMAND:
358                 {
359                         if(argc >= 2) { Say(self, FALSE, world, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1); }
360                         return; // never fall through to usage
361                 }
362                         
363                 default:
364                 case CMD_REQUEST_USAGE:
365                 {
366                         sprint(self, "\nUsage:^3 cmd say <message>\n");
367                         sprint(self, "  Where 'message' is the string of text to say.\n");
368                         return;
369                 }
370         }
371 }
372
373 void ClientCommand_say_team(float request, float argc, string command)
374 {
375         switch(request)
376         {
377                 case CMD_REQUEST_COMMAND:
378                 {
379                         if(argc >= 2) { Say(self, TRUE, world, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), 1); }
380                         return; // never fall through to usage
381                 }
382                         
383                 default:
384                 case CMD_REQUEST_USAGE:
385                 {
386                         sprint(self, "\nUsage:^3 cmd say_team <message>\n");
387                         sprint(self, "  Where 'message' is the string of text to say.\n");
388                         return;
389                 }
390         }
391 }
392
393 void ClientCommand_selectteam(float request, float argc)
394 {
395         switch(request)
396         {
397                 case CMD_REQUEST_COMMAND:
398                 {
399                         if(argv(1) != "")
400                         {
401                                 if(IS_CLIENT(self))
402                                 {
403                                         if(teamplay)
404                                                 if not(self.team_forced > 0) 
405                                                         if not(lockteams) 
406                                                         {
407                                                                 float selection;
408                                                                 
409                                                                 switch(argv(1))
410                                                                 {
411                                                                         case "red": selection = NUM_TEAM_1; break;
412                                                                         case "blue": selection = NUM_TEAM_2; break;
413                                                                         case "yellow": selection = NUM_TEAM_3; break;
414                                                                         case "pink": selection = NUM_TEAM_4; break;
415                                                                         case "auto": selection = (-1); break;
416                                                                         
417                                                                         default: selection = 0; break;
418                                                                 }
419                                                                 
420                                                                 if(selection)
421                                                                 {
422                                                                         if(self.team == selection && self.deadflag == DEAD_NO)
423                                                                                 sprint(self, "^7You already are on that team.\n");
424                                                                         else if(self.wasplayer && autocvar_g_changeteam_banned)
425                                                                                 sprint(self, "^1You cannot change team, forbidden by the server.\n");
426                                                                         else
427                                                                                 ClientKill_TeamChange(selection);
428                                                                 }
429                                                         }
430                                                         else
431                                                                 sprint(self, "^7The game has already begun, you must wait until the next map to be able to join a team.\n");
432                                                 else
433                                                         sprint(self, "^7selectteam can not be used as your team is forced\n");
434                                         else
435                                                 sprint(self, "^7selectteam can only be used in teamgames\n");
436                                 }
437                                 return; 
438                         }
439                 }
440
441                 default:
442                         sprint(self, "Incorrect parameters for ^2selectteam^7\n");
443                 case CMD_REQUEST_USAGE:
444                 {
445                         sprint(self, "\nUsage:^3 cmd selectteam team\n");
446                         sprint(self, "  Where 'team' is the prefered team to try and join.\n");
447                         sprint(self, "  Full list of options here: \"red, blue, yellow, pink, auto\"\n");
448                         return;
449                 }
450         }
451 }
452
453 void ClientCommand_selfstuff(float request, string command)
454 {
455         switch(request)
456         {
457                 case CMD_REQUEST_COMMAND:
458                 {
459                         if(argv(1) != "")
460                         {
461                                 stuffcmd(self, substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
462                                 return;
463                         }
464                 }
465                         
466                 default:
467                         sprint(self, "Incorrect parameters for ^2selectteam^7\n");
468                 case CMD_REQUEST_USAGE:
469                 {
470                         sprint(self, "\nUsage:^3 cmd selfstuff <command>\n");
471                         sprint(self, "  Where 'command' is the string to be stuffed to your client.\n");
472                         return;
473                 }
474         }
475 }
476
477 void ClientCommand_sentcvar(float request, float argc, string command)
478 {
479         switch(request)
480         {
481                 case CMD_REQUEST_COMMAND:
482                 {
483                         if(argv(1) != "")
484                         {
485                                 //float tokens;
486                                 string s;
487                                 
488                                 if(argc == 2) // undefined cvar: use the default value on the server then
489                                 {
490                                         s = strcat(substring(command, argv_start_index(0), argv_end_index(1) - argv_start_index(0)), " \"", cvar_defstring(argv(1)), "\"");
491                                         tokenize_console(s);
492                                 }
493                                 
494                                 GetCvars(1);
495                                 
496                                 return;
497                         }
498                 }
499                         
500                 default:
501                         sprint(self, "Incorrect parameters for ^2sentcvar^7\n");
502                 case CMD_REQUEST_USAGE:
503                 {
504                         sprint(self, "\nUsage:^3 cmd sentcvar <cvar>\n");
505                         sprint(self, "  Where 'cvar' is the cvar plus arguments to send to the server.\n");
506                         return;
507                 }
508         }
509 }
510
511 void ClientCommand_spectate(float request) 
512 {
513         switch(request)
514         {
515                 case CMD_REQUEST_COMMAND:
516                 {
517                         if(IS_CLIENT(self))
518                         {
519                                 if(g_arena) { return; } 
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 }