Quake II RTX doxygen  1.0 dev
g_cmds.c
Go to the documentation of this file.
1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18 #include "g_local.h"
19 #include "m_player.h"
20 
21 
22 char *ClientTeam(edict_t *ent)
23 {
24  char *p;
25  static char value[512];
26 
27  value[0] = 0;
28 
29  if (!ent->client)
30  return value;
31 
32  strcpy(value, Info_ValueForKey(ent->client->pers.userinfo, "skin"));
33  p = strchr(value, '/');
34  if (!p)
35  return value;
36 
37  if ((int)(dmflags->value) & DF_MODELTEAMS) {
38  *p = 0;
39  return value;
40  }
41 
42  // if ((int)(dmflags->value) & DF_SKINTEAMS)
43  return ++p;
44 }
45 
46 qboolean OnSameTeam(edict_t *ent1, edict_t *ent2)
47 {
48  char ent1Team [512];
49  char ent2Team [512];
50 
51  if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS)))
52  return qfalse;
53 
54  strcpy(ent1Team, ClientTeam(ent1));
55  strcpy(ent2Team, ClientTeam(ent2));
56 
57  if (strcmp(ent1Team, ent2Team) == 0)
58  return qtrue;
59  return qfalse;
60 }
61 
62 
63 void SelectNextItem(edict_t *ent, int itflags)
64 {
65  gclient_t *cl;
66  int i, index;
67  gitem_t *it;
68 
69  cl = ent->client;
70 
71  if (cl->chase_target) {
72  ChaseNext(ent);
73  return;
74  }
75 
76  // scan for the next valid one
77  for (i = 1 ; i <= MAX_ITEMS ; i++) {
78  index = (cl->pers.selected_item + i) % MAX_ITEMS;
79  if (!cl->pers.inventory[index])
80  continue;
81  it = &itemlist[index];
82  if (!it->use)
83  continue;
84  if (!(it->flags & itflags))
85  continue;
86 
87  cl->pers.selected_item = index;
88  return;
89  }
90 
91  cl->pers.selected_item = -1;
92 }
93 
94 void SelectPrevItem(edict_t *ent, int itflags)
95 {
96  gclient_t *cl;
97  int i, index;
98  gitem_t *it;
99 
100  cl = ent->client;
101 
102  if (cl->chase_target) {
103  ChasePrev(ent);
104  return;
105  }
106 
107  // scan for the next valid one
108  for (i = 1 ; i <= MAX_ITEMS ; i++) {
109  index = (cl->pers.selected_item + MAX_ITEMS - i) % MAX_ITEMS;
110  if (!cl->pers.inventory[index])
111  continue;
112  it = &itemlist[index];
113  if (!it->use)
114  continue;
115  if (!(it->flags & itflags))
116  continue;
117 
118  cl->pers.selected_item = index;
119  return;
120  }
121 
122  cl->pers.selected_item = -1;
123 }
124 
125 void ValidateSelectedItem(edict_t *ent)
126 {
127  gclient_t *cl;
128 
129  cl = ent->client;
130 
131  if (cl->pers.inventory[cl->pers.selected_item])
132  return; // valid
133 
134  SelectNextItem(ent, -1);
135 }
136 
137 
138 //=================================================================================
139 
140 /*
141 ==================
142 Cmd_Give_f
143 
144 Give items to a client
145 ==================
146 */
147 void Cmd_Give_f(edict_t *ent)
148 {
149  char *name;
150  gitem_t *it;
151  int index;
152  int i;
153  qboolean give_all;
154  edict_t *it_ent;
155 
156  if (deathmatch->value && !sv_cheats->value) {
157  gi.cprintf(ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
158  return;
159  }
160 
161  name = gi.args();
162 
163  if (Q_stricmp(name, "all") == 0)
164  give_all = qtrue;
165  else
166  give_all = qfalse;
167 
168  if (give_all || Q_stricmp(gi.argv(1), "health") == 0) {
169  if (gi.argc() == 3)
170  ent->health = atoi(gi.argv(2));
171  else
172  ent->health = ent->max_health;
173  if (!give_all)
174  return;
175  }
176 
177  if (give_all || Q_stricmp(name, "weapons") == 0) {
178  for (i = 0 ; i < game.num_items ; i++) {
179  it = itemlist + i;
180  if (!it->pickup)
181  continue;
182  if (!(it->flags & IT_WEAPON))
183  continue;
184  ent->client->pers.inventory[i] += 1;
185  }
186  if (!give_all)
187  return;
188  }
189 
190  if (give_all || Q_stricmp(name, "ammo") == 0) {
191  for (i = 0 ; i < game.num_items ; i++) {
192  it = itemlist + i;
193  if (!it->pickup)
194  continue;
195  if (!(it->flags & IT_AMMO))
196  continue;
197  Add_Ammo(ent, it, 1000);
198  }
199  if (!give_all)
200  return;
201  }
202 
203  if (give_all || Q_stricmp(name, "armor") == 0) {
204  gitem_armor_t *info;
205 
206  it = FindItem("Jacket Armor");
207  ent->client->pers.inventory[ITEM_INDEX(it)] = 0;
208 
209  it = FindItem("Combat Armor");
210  ent->client->pers.inventory[ITEM_INDEX(it)] = 0;
211 
212  it = FindItem("Body Armor");
213  info = (gitem_armor_t *)it->info;
214  ent->client->pers.inventory[ITEM_INDEX(it)] = info->max_count;
215 
216  if (!give_all)
217  return;
218  }
219 
220  if (give_all || Q_stricmp(name, "Power Shield") == 0) {
221  it = FindItem("Power Shield");
222  it_ent = G_Spawn();
223  it_ent->classname = it->classname;
224  SpawnItem(it_ent, it);
225  Touch_Item(it_ent, ent, NULL, NULL);
226  if (it_ent->inuse)
227  G_FreeEdict(it_ent);
228 
229  if (!give_all)
230  return;
231  }
232 
233  if (give_all) {
234  for (i = 0 ; i < game.num_items ; i++) {
235  it = itemlist + i;
236  if (!it->pickup)
237  continue;
238  if (it->flags & (IT_ARMOR | IT_WEAPON | IT_AMMO))
239  continue;
240  ent->client->pers.inventory[i] = 1;
241  }
242  return;
243  }
244 
245  it = FindItem(name);
246  if (!it) {
247  name = gi.argv(1);
248  it = FindItem(name);
249  if (!it) {
250  gi.cprintf(ent, PRINT_HIGH, "unknown item\n");
251  return;
252  }
253  }
254 
255  if (!it->pickup) {
256  gi.cprintf(ent, PRINT_HIGH, "non-pickup item\n");
257  return;
258  }
259 
260  index = ITEM_INDEX(it);
261 
262  if (it->flags & IT_AMMO) {
263  if (gi.argc() == 3)
264  ent->client->pers.inventory[index] = atoi(gi.argv(2));
265  else
266  ent->client->pers.inventory[index] += it->quantity;
267  } else {
268  it_ent = G_Spawn();
269  it_ent->classname = it->classname;
270  SpawnItem(it_ent, it);
271  Touch_Item(it_ent, ent, NULL, NULL);
272  if (it_ent->inuse)
273  G_FreeEdict(it_ent);
274  }
275 }
276 
277 
278 /*
279 ==================
280 Cmd_God_f
281 
282 Sets client to godmode
283 
284 argv(0) god
285 ==================
286 */
287 void Cmd_God_f(edict_t *ent)
288 {
289  if (deathmatch->value && !sv_cheats->value) {
290  gi.cprintf(ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
291  return;
292  }
293 
294  ent->flags ^= FL_GODMODE;
295  if (!(ent->flags & FL_GODMODE))
296  gi.cprintf(ent, PRINT_HIGH, "godmode OFF\n");
297  else
298  gi.cprintf(ent, PRINT_HIGH, "godmode ON\n");
299 }
300 
301 
302 /*
303 ==================
304 Cmd_Notarget_f
305 
306 Sets client to notarget
307 
308 argv(0) notarget
309 ==================
310 */
311 void Cmd_Notarget_f(edict_t *ent)
312 {
313  if (deathmatch->value && !sv_cheats->value) {
314  gi.cprintf(ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
315  return;
316  }
317 
318  ent->flags ^= FL_NOTARGET;
319  if (!(ent->flags & FL_NOTARGET))
320  gi.cprintf(ent, PRINT_HIGH, "notarget OFF\n");
321  else
322  gi.cprintf(ent, PRINT_HIGH, "notarget ON\n");
323 }
324 
325 
326 /*
327 ==================
328 Cmd_Noclip_f
329 
330 argv(0) noclip
331 ==================
332 */
333 void Cmd_Noclip_f(edict_t *ent)
334 {
335  if (deathmatch->value && !sv_cheats->value) {
336  gi.cprintf(ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
337  return;
338  }
339 
340  if (ent->movetype == MOVETYPE_NOCLIP) {
341  ent->movetype = MOVETYPE_WALK;
342  gi.cprintf(ent, PRINT_HIGH, "noclip OFF\n");
343  } else {
344  ent->movetype = MOVETYPE_NOCLIP;
345  gi.cprintf(ent, PRINT_HIGH, "noclip ON\n");
346  }
347 }
348 
349 
350 /*
351 ==================
352 Cmd_Use_f
353 
354 Use an inventory item
355 ==================
356 */
357 void Cmd_Use_f(edict_t *ent)
358 {
359  int index;
360  gitem_t *it;
361  char *s;
362 
363  s = gi.args();
364  it = FindItem(s);
365  if (!it) {
366  gi.cprintf(ent, PRINT_HIGH, "unknown item: %s\n", s);
367  return;
368  }
369  if (!it->use) {
370  gi.cprintf(ent, PRINT_HIGH, "Item is not usable.\n");
371  return;
372  }
373  index = ITEM_INDEX(it);
374  if (!ent->client->pers.inventory[index]) {
375  gi.cprintf(ent, PRINT_HIGH, "Out of item: %s\n", s);
376  return;
377  }
378 
379  it->use(ent, it);
380 }
381 
382 
383 /*
384 ==================
385 Cmd_Drop_f
386 
387 Drop an inventory item
388 ==================
389 */
390 void Cmd_Drop_f(edict_t *ent)
391 {
392  int index;
393  gitem_t *it;
394  char *s;
395 
396  s = gi.args();
397  it = FindItem(s);
398  if (!it) {
399  gi.cprintf(ent, PRINT_HIGH, "unknown item: %s\n", s);
400  return;
401  }
402  if (!it->drop) {
403  gi.cprintf(ent, PRINT_HIGH, "Item is not dropable.\n");
404  return;
405  }
406  index = ITEM_INDEX(it);
407  if (!ent->client->pers.inventory[index]) {
408  gi.cprintf(ent, PRINT_HIGH, "Out of item: %s\n", s);
409  return;
410  }
411 
412  it->drop(ent, it);
413 }
414 
415 
416 /*
417 =================
418 Cmd_Inven_f
419 =================
420 */
421 void Cmd_Inven_f(edict_t *ent)
422 {
423  int i;
424  gclient_t *cl;
425 
426  cl = ent->client;
427 
428  cl->showscores = qfalse;
429  cl->showhelp = qfalse;
430 
431  if (cl->showinventory) {
432  cl->showinventory = qfalse;
433  return;
434  }
435 
436  cl->showinventory = qtrue;
437 
438  gi.WriteByte(svc_inventory);
439  for (i = 0 ; i < MAX_ITEMS ; i++) {
440  gi.WriteShort(cl->pers.inventory[i]);
441  }
442  gi.unicast(ent, qtrue);
443 }
444 
445 /*
446 =================
447 Cmd_InvUse_f
448 =================
449 */
450 void Cmd_InvUse_f(edict_t *ent)
451 {
452  gitem_t *it;
453 
455 
456  if (ent->client->pers.selected_item == -1) {
457  gi.cprintf(ent, PRINT_HIGH, "No item to use.\n");
458  return;
459  }
460 
461  it = &itemlist[ent->client->pers.selected_item];
462  if (!it->use) {
463  gi.cprintf(ent, PRINT_HIGH, "Item is not usable.\n");
464  return;
465  }
466  it->use(ent, it);
467 }
468 
469 /*
470 =================
471 Cmd_WeapPrev_f
472 =================
473 */
474 void Cmd_WeapPrev_f(edict_t *ent)
475 {
476  gclient_t *cl;
477  int i, index;
478  gitem_t *it;
479  int selected_weapon;
480 
481  cl = ent->client;
482 
483  if (!cl->pers.weapon)
484  return;
485 
486  selected_weapon = ITEM_INDEX(cl->pers.weapon);
487 
488  // scan for the next valid one
489  for (i = 1 ; i <= MAX_ITEMS ; i++) {
490  index = (selected_weapon + i) % MAX_ITEMS;
491  if (!cl->pers.inventory[index])
492  continue;
493  it = &itemlist[index];
494  if (!it->use)
495  continue;
496  if (!(it->flags & IT_WEAPON))
497  continue;
498  it->use(ent, it);
499  if (cl->pers.weapon == it)
500  return; // successful
501  }
502 }
503 
504 /*
505 =================
506 Cmd_WeapNext_f
507 =================
508 */
509 void Cmd_WeapNext_f(edict_t *ent)
510 {
511  gclient_t *cl;
512  int i, index;
513  gitem_t *it;
514  int selected_weapon;
515 
516  cl = ent->client;
517 
518  if (!cl->pers.weapon)
519  return;
520 
521  selected_weapon = ITEM_INDEX(cl->pers.weapon);
522 
523  // scan for the next valid one
524  for (i = 1 ; i <= MAX_ITEMS ; i++) {
525  index = (selected_weapon + MAX_ITEMS - i) % MAX_ITEMS;
526  if (!cl->pers.inventory[index])
527  continue;
528  it = &itemlist[index];
529  if (!it->use)
530  continue;
531  if (!(it->flags & IT_WEAPON))
532  continue;
533  it->use(ent, it);
534  if (cl->pers.weapon == it)
535  return; // successful
536  }
537 }
538 
539 /*
540 =================
541 Cmd_WeapLast_f
542 =================
543 */
544 void Cmd_WeapLast_f(edict_t *ent)
545 {
546  gclient_t *cl;
547  int index;
548  gitem_t *it;
549 
550  cl = ent->client;
551 
552  if (!cl->pers.weapon || !cl->pers.lastweapon)
553  return;
554 
555  index = ITEM_INDEX(cl->pers.lastweapon);
556  if (!cl->pers.inventory[index])
557  return;
558  it = &itemlist[index];
559  if (!it->use)
560  return;
561  if (!(it->flags & IT_WEAPON))
562  return;
563  it->use(ent, it);
564 }
565 
566 /*
567 =================
568 Cmd_InvDrop_f
569 =================
570 */
571 void Cmd_InvDrop_f(edict_t *ent)
572 {
573  gitem_t *it;
574 
576 
577  if (ent->client->pers.selected_item == -1) {
578  gi.cprintf(ent, PRINT_HIGH, "No item to drop.\n");
579  return;
580  }
581 
582  it = &itemlist[ent->client->pers.selected_item];
583  if (!it->drop) {
584  gi.cprintf(ent, PRINT_HIGH, "Item is not dropable.\n");
585  return;
586  }
587  it->drop(ent, it);
588 }
589 
590 /*
591 =================
592 Cmd_Kill_f
593 =================
594 */
595 void Cmd_Kill_f(edict_t *ent)
596 {
597  if ((level.time - ent->client->respawn_time) < 5)
598  return;
599  ent->flags &= ~FL_GODMODE;
600  ent->health = 0;
602  player_die(ent, ent, ent, 100000, vec3_origin);
603 }
604 
605 /*
606 =================
607 Cmd_PutAway_f
608 =================
609 */
610 void Cmd_PutAway_f(edict_t *ent)
611 {
612  ent->client->showscores = qfalse;
613  ent->client->showhelp = qfalse;
614  ent->client->showinventory = qfalse;
615 }
616 
617 
618 int PlayerSort(void const *a, void const *b)
619 {
620  int anum, bnum;
621 
622  anum = *(int *)a;
623  bnum = *(int *)b;
624 
625  anum = game.clients[anum].ps.stats[STAT_FRAGS];
626  bnum = game.clients[bnum].ps.stats[STAT_FRAGS];
627 
628  if (anum < bnum)
629  return -1;
630  if (anum > bnum)
631  return 1;
632  return 0;
633 }
634 
635 /*
636 =================
637 Cmd_Players_f
638 =================
639 */
640 void Cmd_Players_f(edict_t *ent)
641 {
642  int i;
643  int count;
644  char small[64];
645  char large[1280];
646  int index[256];
647 
648  count = 0;
649  for (i = 0 ; i < maxclients->value ; i++)
650  if (game.clients[i].pers.connected) {
651  index[count] = i;
652  count++;
653  }
654 
655  // sort by frags
656  qsort(index, count, sizeof(index[0]), PlayerSort);
657 
658  // print information
659  large[0] = 0;
660 
661  for (i = 0 ; i < count ; i++) {
662  Q_snprintf(small, sizeof(small), "%3i %s\n",
663  game.clients[index[i]].ps.stats[STAT_FRAGS],
664  game.clients[index[i]].pers.netname);
665  if (strlen(small) + strlen(large) > sizeof(large) - 100) {
666  // can't print all of them in one packet
667  strcat(large, "...\n");
668  break;
669  }
670  strcat(large, small);
671  }
672 
673  gi.cprintf(ent, PRINT_HIGH, "%s\n%i players\n", large, count);
674 }
675 
676 /*
677 =================
678 Cmd_Wave_f
679 =================
680 */
681 void Cmd_Wave_f(edict_t *ent)
682 {
683  int i;
684 
685  i = atoi(gi.argv(1));
686 
687  // can't wave when ducked
688  if (ent->client->ps.pmove.pm_flags & PMF_DUCKED)
689  return;
690 
691  if (ent->client->anim_priority > ANIM_WAVE)
692  return;
693 
694  ent->client->anim_priority = ANIM_WAVE;
695 
696  switch (i) {
697  case 0:
698  gi.cprintf(ent, PRINT_HIGH, "flipoff\n");
699  ent->s.frame = FRAME_flip01 - 1;
700  ent->client->anim_end = FRAME_flip12;
701  break;
702  case 1:
703  gi.cprintf(ent, PRINT_HIGH, "salute\n");
704  ent->s.frame = FRAME_salute01 - 1;
705  ent->client->anim_end = FRAME_salute11;
706  break;
707  case 2:
708  gi.cprintf(ent, PRINT_HIGH, "taunt\n");
709  ent->s.frame = FRAME_taunt01 - 1;
710  ent->client->anim_end = FRAME_taunt17;
711  break;
712  case 3:
713  gi.cprintf(ent, PRINT_HIGH, "wave\n");
714  ent->s.frame = FRAME_wave01 - 1;
715  ent->client->anim_end = FRAME_wave11;
716  break;
717  case 4:
718  default:
719  gi.cprintf(ent, PRINT_HIGH, "point\n");
720  ent->s.frame = FRAME_point01 - 1;
721  ent->client->anim_end = FRAME_point12;
722  break;
723  }
724 }
725 
726 /*
727 ==================
728 Cmd_Say_f
729 ==================
730 */
731 void Cmd_Say_f(edict_t *ent, qboolean team, qboolean arg0)
732 {
733  int i, j;
734  edict_t *other;
735  char *p;
736  char text[2048];
737  gclient_t *cl;
738 
739  if (gi.argc() < 2 && !arg0)
740  return;
741 
742  if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS)))
743  team = qfalse;
744 
745  if (team)
746  Q_snprintf(text, sizeof(text), "(%s): ", ent->client->pers.netname);
747  else
748  Q_snprintf(text, sizeof(text), "%s: ", ent->client->pers.netname);
749 
750  if (arg0) {
751  strcat(text, gi.argv(0));
752  strcat(text, " ");
753  strcat(text, gi.args());
754  } else {
755  p = gi.args();
756 
757  if (*p == '"') {
758  p++;
759  p[strlen(p) - 1] = 0;
760  }
761  strcat(text, p);
762  }
763 
764  // don't let text be too long for malicious reasons
765  if (strlen(text) > 150)
766  text[150] = 0;
767 
768  strcat(text, "\n");
769 
770  if (flood_msgs->value) {
771  cl = ent->client;
772 
773  if (level.time < cl->flood_locktill) {
774  gi.cprintf(ent, PRINT_HIGH, "You can't talk for %d more seconds\n",
775  (int)(cl->flood_locktill - level.time));
776  return;
777  }
778  i = cl->flood_whenhead - flood_msgs->value + 1;
779  if (i < 0)
780  i = (sizeof(cl->flood_when) / sizeof(cl->flood_when[0])) + i;
781  if (cl->flood_when[i] &&
782  level.time - cl->flood_when[i] < flood_persecond->value) {
783  cl->flood_locktill = level.time + flood_waitdelay->value;
784  gi.cprintf(ent, PRINT_CHAT, "Flood protection: You can't talk for %d seconds.\n",
785  (int)flood_waitdelay->value);
786  return;
787  }
788  cl->flood_whenhead = (cl->flood_whenhead + 1) %
789  (sizeof(cl->flood_when) / sizeof(cl->flood_when[0]));
790  cl->flood_when[cl->flood_whenhead] = level.time;
791  }
792 
793  if (dedicated->value)
794  gi.cprintf(NULL, PRINT_CHAT, "%s", text);
795 
796  for (j = 1; j <= game.maxclients; j++) {
797  other = &g_edicts[j];
798  if (!other->inuse)
799  continue;
800  if (!other->client)
801  continue;
802  if (team) {
803  if (!OnSameTeam(ent, other))
804  continue;
805  }
806  gi.cprintf(other, PRINT_CHAT, "%s", text);
807  }
808 }
809 
810 void Cmd_PlayerList_f(edict_t *ent)
811 {
812  int i;
813  char st[80];
814  char text[1400];
815  edict_t *e2;
816 
817  // connect time, ping, score, name
818  *text = 0;
819  for (i = 0, e2 = g_edicts + 1; i < maxclients->value; i++, e2++) {
820  if (!e2->inuse)
821  continue;
822 
823  Q_snprintf(st, sizeof(st), "%02d:%02d %4d %3d %s%s\n",
824  (level.framenum - e2->client->resp.enterframe) / 600,
825  ((level.framenum - e2->client->resp.enterframe) % 600) / 10,
826  e2->client->ping,
827  e2->client->resp.score,
828  e2->client->pers.netname,
829  e2->client->resp.spectator ? " (spectator)" : "");
830  if (strlen(text) + strlen(st) > sizeof(text) - 50) {
831  sprintf(text + strlen(text), "And more...\n");
832  gi.cprintf(ent, PRINT_HIGH, "%s", text);
833  return;
834  }
835  strcat(text, st);
836  }
837  gi.cprintf(ent, PRINT_HIGH, "%s", text);
838 }
839 
840 
841 /*
842 =================
843 ClientCommand
844 =================
845 */
846 void ClientCommand(edict_t *ent)
847 {
848  char *cmd;
849 
850  if (!ent->client)
851  return; // not fully in game yet
852 
853  cmd = gi.argv(0);
854 
855  if (Q_stricmp(cmd, "players") == 0) {
856  Cmd_Players_f(ent);
857  return;
858  }
859  if (Q_stricmp(cmd, "say") == 0) {
860  Cmd_Say_f(ent, qfalse, qfalse);
861  return;
862  }
863  if (Q_stricmp(cmd, "say_team") == 0) {
864  Cmd_Say_f(ent, qtrue, qfalse);
865  return;
866  }
867  if (Q_stricmp(cmd, "score") == 0) {
868  Cmd_Score_f(ent);
869  return;
870  }
871  if (Q_stricmp(cmd, "help") == 0) {
872  Cmd_Help_f(ent);
873  return;
874  }
875 
877  return;
878 
879  if (Q_stricmp(cmd, "use") == 0)
880  Cmd_Use_f(ent);
881  else if (Q_stricmp(cmd, "drop") == 0)
882  Cmd_Drop_f(ent);
883  else if (Q_stricmp(cmd, "give") == 0)
884  Cmd_Give_f(ent);
885  else if (Q_stricmp(cmd, "god") == 0)
886  Cmd_God_f(ent);
887  else if (Q_stricmp(cmd, "notarget") == 0)
888  Cmd_Notarget_f(ent);
889  else if (Q_stricmp(cmd, "noclip") == 0)
890  Cmd_Noclip_f(ent);
891  else if (Q_stricmp(cmd, "inven") == 0)
892  Cmd_Inven_f(ent);
893  else if (Q_stricmp(cmd, "invnext") == 0)
894  SelectNextItem(ent, -1);
895  else if (Q_stricmp(cmd, "invprev") == 0)
896  SelectPrevItem(ent, -1);
897  else if (Q_stricmp(cmd, "invnextw") == 0)
899  else if (Q_stricmp(cmd, "invprevw") == 0)
901  else if (Q_stricmp(cmd, "invnextp") == 0)
903  else if (Q_stricmp(cmd, "invprevp") == 0)
905  else if (Q_stricmp(cmd, "invuse") == 0)
906  Cmd_InvUse_f(ent);
907  else if (Q_stricmp(cmd, "invdrop") == 0)
908  Cmd_InvDrop_f(ent);
909  else if (Q_stricmp(cmd, "weapprev") == 0)
910  Cmd_WeapPrev_f(ent);
911  else if (Q_stricmp(cmd, "weapnext") == 0)
912  Cmd_WeapNext_f(ent);
913  else if (Q_stricmp(cmd, "weaplast") == 0)
914  Cmd_WeapLast_f(ent);
915  else if (Q_stricmp(cmd, "kill") == 0)
916  Cmd_Kill_f(ent);
917  else if (Q_stricmp(cmd, "putaway") == 0)
918  Cmd_PutAway_f(ent);
919  else if (Q_stricmp(cmd, "wave") == 0)
920  Cmd_Wave_f(ent);
921  else if (Q_stricmp(cmd, "playerlist") == 0)
922  Cmd_PlayerList_f(ent);
923  else // anything that doesn't match a command will be a chat
924  Cmd_Say_f(ent, qfalse, qtrue);
925 }
FindItem
gitem_t * FindItem(char *pickup_name)
Definition: g_items.c:98
gi
game_import_t gi
Definition: g_main.c:23
FRAME_taunt01
#define FRAME_taunt01
Definition: m_actor.h:256
IT_AMMO
#define IT_AMMO
Definition: g_local.h:212
gitem_armor_t::max_count
int max_count
Definition: g_local.h:203
Cmd_Inven_f
void Cmd_Inven_f(edict_t *ent)
Definition: g_cmds.c:421
deathmatch
cvar_t * deathmatch
Definition: g_main.c:33
client_state_s::inventory
int inventory[MAX_ITEMS]
Definition: client.h:270
G_Spawn
edict_t * G_Spawn(void)
Definition: g_utils.c:391
ChasePrev
void ChasePrev(edict_t *ent)
Definition: g_chase.c:131
Cmd_Give_f
void Cmd_Give_f(edict_t *ent)
Definition: g_cmds.c:147
FRAME_flip12
#define FRAME_flip12
Definition: m_actor.h:72
maxclients
cvar_t * maxclients
Definition: g_main.c:42
Q_snprintf
size_t Q_snprintf(char *dest, size_t size, const char *fmt,...)
Definition: shared.c:846
m_player.h
Add_Ammo
qboolean Add_Ammo(edict_t *ent, gitem_t *item, int count)
Definition: g_items.c:426
Cmd_Use_f
void Cmd_Use_f(edict_t *ent)
Definition: g_cmds.c:357
st
spawn_temp_t st
Definition: g_main.c:25
MOVETYPE_NOCLIP
@ MOVETYPE_NOCLIP
Definition: g_local.h:187
FRAME_point01
#define FRAME_point01
Definition: m_player.h:145
FRAME_wave01
#define FRAME_wave01
Definition: m_actor.h:284
gitem_s::pickup
qboolean(* pickup)(struct edict_s *ent, struct edict_s *other)
Definition: g_local.h:234
ITEM_INDEX
#define ITEM_INDEX(x)
Definition: g_local.h:600
player_die
void player_die(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
Definition: p_client.c:476
flood_msgs
cvar_t * flood_msgs
Definition: g_main.c:68
SpawnItem
void SpawnItem(edict_t *ent, gitem_t *item)
Definition: g_items.c:1003
Cmd_WeapLast_f
void Cmd_WeapLast_f(edict_t *ent)
Definition: g_cmds.c:544
FRAME_salute01
#define FRAME_salute01
Definition: m_actor.h:138
meansOfDeath
int meansOfDeath
Definition: g_main.c:29
g_edicts
edict_t * g_edicts
Definition: g_main.c:31
other
@ other
Definition: ogg.c:63
IT_WEAPON
#define IT_WEAPON
Definition: g_local.h:211
itemlist
gitem_t itemlist[]
Definition: g_items.c:1063
SelectPrevItem
void SelectPrevItem(edict_t *ent, int itflags)
Definition: g_cmds.c:94
gitem_s::use
void(* use)(struct edict_s *ent, struct gitem_s *item)
Definition: g_local.h:235
Cmd_Noclip_f
void Cmd_Noclip_f(edict_t *ent)
Definition: g_cmds.c:333
Cmd_God_f
void Cmd_God_f(edict_t *ent)
Definition: g_cmds.c:287
vec3_origin
vec3_t vec3_origin
Definition: shared.c:21
Cmd_Players_f
void Cmd_Players_f(edict_t *ent)
Definition: g_cmds.c:640
G_FreeEdict
void G_FreeEdict(edict_t *e)
Definition: g_utils.c:421
Cmd_PutAway_f
void Cmd_PutAway_f(edict_t *ent)
Definition: g_cmds.c:610
dedicated
cvar_t * dedicated
Definition: g_main.c:46
PlayerSort
int PlayerSort(void const *a, void const *b)
Definition: g_cmds.c:618
game_locals_t::num_items
int num_items
Definition: g_local.h:287
FRAME_point12
#define FRAME_point12
Definition: m_player.h:156
FL_GODMODE
#define FL_GODMODE
Definition: g_local.h:63
Cmd_Wave_f
void Cmd_Wave_f(edict_t *ent)
Definition: g_cmds.c:681
ClientTeam
char * ClientTeam(edict_t *ent)
Definition: g_cmds.c:22
Info_ValueForKey
char * Info_ValueForKey(const char *s, const char *key)
Definition: shared.c:945
game_locals_t::clients
gclient_t * clients
Definition: g_local.h:273
OnSameTeam
qboolean OnSameTeam(edict_t *ent1, edict_t *ent2)
Definition: g_cmds.c:46
gitem_armor_t
Definition: g_local.h:201
Touch_Item
void Touch_Item(edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
Definition: g_items.c:723
game
game_locals_t game
Definition: g_main.c:21
flood_persecond
cvar_t * flood_persecond
Definition: g_main.c:69
flood_waitdelay
cvar_t * flood_waitdelay
Definition: g_main.c:70
Cmd_WeapPrev_f
void Cmd_WeapPrev_f(edict_t *ent)
Definition: g_cmds.c:474
FL_NOTARGET
#define FL_NOTARGET
Definition: g_local.h:64
Cmd_InvDrop_f
void Cmd_InvDrop_f(edict_t *ent)
Definition: g_cmds.c:571
Cmd_Score_f
void Cmd_Score_f(edict_t *ent)
Definition: p_hud.c:255
Cmd_PlayerList_f
void Cmd_PlayerList_f(edict_t *ent)
Definition: g_cmds.c:810
MOVETYPE_WALK
@ MOVETYPE_WALK
Definition: g_local.h:191
gitem_s::quantity
int quantity
Definition: g_local.h:248
level_locals_t::framenum
int framenum
Definition: g_local.h:298
Cmd_InvUse_f
void Cmd_InvUse_f(edict_t *ent)
Definition: g_cmds.c:450
level_locals_t::time
float time
Definition: g_local.h:299
cl
client_state_t cl
Definition: main.c:99
Cmd_Kill_f
void Cmd_Kill_f(edict_t *ent)
Definition: g_cmds.c:595
IT_ARMOR
#define IT_ARMOR
Definition: g_local.h:213
Cmd_Help_f
void Cmd_Help_f(edict_t *ent)
Definition: p_hud.c:324
ValidateSelectedItem
void ValidateSelectedItem(edict_t *ent)
Definition: g_cmds.c:125
level_locals_t::intermissiontime
float intermissiontime
Definition: g_local.h:306
FRAME_flip01
#define FRAME_flip01
Definition: m_actor.h:61
sv_cheats
cvar_t * sv_cheats
Definition: g_main.c:66
FRAME_wave11
#define FRAME_wave11
Definition: m_actor.h:294
svc_inventory
#define svc_inventory
Definition: g_local.h:40
gitem_s::drop
void(* drop)(struct edict_s *ent, struct gitem_s *item)
Definition: g_local.h:236
level
level_locals_t level
Definition: g_main.c:22
ClientCommand
void ClientCommand(edict_t *ent)
Definition: g_cmds.c:846
ChaseNext
void ChaseNext(edict_t *ent)
Definition: g_chase.c:107
FRAME_salute11
#define FRAME_salute11
Definition: m_actor.h:148
Cmd_WeapNext_f
void Cmd_WeapNext_f(edict_t *ent)
Definition: g_cmds.c:509
SelectNextItem
void SelectNextItem(edict_t *ent, int itflags)
Definition: g_cmds.c:63
Cmd_Say_f
void Cmd_Say_f(edict_t *ent, qboolean team, qboolean arg0)
Definition: g_cmds.c:731
Cmd_Notarget_f
void Cmd_Notarget_f(edict_t *ent)
Definition: g_cmds.c:311
ANIM_WAVE
#define ANIM_WAVE
Definition: g_local.h:812
dmflags
cvar_t * dmflags
Definition: g_main.c:35
FRAME_taunt17
#define FRAME_taunt17
Definition: m_actor.h:272
gitem_s::flags
int flags
Definition: g_local.h:250
MOD_SUICIDE
#define MOD_SUICIDE
Definition: g_local.h:480
IT_POWERUP
#define IT_POWERUP
Definition: g_local.h:216
Cmd_Drop_f
void Cmd_Drop_f(edict_t *ent)
Definition: g_cmds.c:390
gitem_s::info
void * info
Definition: g_local.h:254
g_local.h
gitem_s::classname
char * classname
Definition: g_local.h:233
gitem_s
Definition: g_local.h:232
game_locals_t::maxclients
int maxclients
Definition: g_local.h:280