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