|
|
1.1 ! root 1: #include "g_local.h" ! 2: #include "m_player.h" ! 3: ! 4: ! 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: ! 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: ! 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: ! 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: ! 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: */ ! 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: */ ! 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: */ ! 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: */ ! 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: */ ! 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: */ ! 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: */ ! 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: */ ! 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: */ ! 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: index = (selected_weapon + i)%MAX_ITEMS; ! 536: if (!cl->pers.inventory[index]) ! 537: continue; ! 538: it = &itemlist[index]; ! 539: if (!it->use) ! 540: continue; ! 541: if (! (it->flags & IT_WEAPON) ) ! 542: continue; ! 543: it->use (ent, it); ! 544: if (cl->pers.weapon == it) ! 545: return; // successful ! 546: } ! 547: } ! 548: ! 549: /* ! 550: ================= ! 551: Cmd_WeapNext_f ! 552: ================= ! 553: */ ! 554: void Cmd_WeapNext_f (edict_t *ent) ! 555: { ! 556: gclient_t *cl; ! 557: int i, index; ! 558: gitem_t *it; ! 559: int selected_weapon; ! 560: ! 561: cl = ent->client; ! 562: ! 563: if (!cl->pers.weapon) ! 564: return; ! 565: ! 566: selected_weapon = ITEM_INDEX(cl->pers.weapon); ! 567: ! 568: // scan for the next valid one ! 569: for (i=1 ; i<=MAX_ITEMS ; i++) ! 570: { ! 571: index = (selected_weapon + MAX_ITEMS - i)%MAX_ITEMS; ! 572: if (!cl->pers.inventory[index]) ! 573: continue; ! 574: it = &itemlist[index]; ! 575: if (!it->use) ! 576: continue; ! 577: if (! (it->flags & IT_WEAPON) ) ! 578: continue; ! 579: it->use (ent, it); ! 580: if (cl->pers.weapon == it) ! 581: return; // successful ! 582: } ! 583: } ! 584: ! 585: /* ! 586: ================= ! 587: Cmd_WeapLast_f ! 588: ================= ! 589: */ ! 590: void Cmd_WeapLast_f (edict_t *ent) ! 591: { ! 592: gclient_t *cl; ! 593: int index; ! 594: gitem_t *it; ! 595: ! 596: cl = ent->client; ! 597: ! 598: if (!cl->pers.weapon || !cl->pers.lastweapon) ! 599: return; ! 600: ! 601: index = ITEM_INDEX(cl->pers.lastweapon); ! 602: if (!cl->pers.inventory[index]) ! 603: return; ! 604: it = &itemlist[index]; ! 605: if (!it->use) ! 606: return; ! 607: if (! (it->flags & IT_WEAPON) ) ! 608: return; ! 609: it->use (ent, it); ! 610: } ! 611: ! 612: /* ! 613: ================= ! 614: Cmd_InvDrop_f ! 615: ================= ! 616: */ ! 617: void Cmd_InvDrop_f (edict_t *ent) ! 618: { ! 619: gitem_t *it; ! 620: ! 621: ValidateSelectedItem (ent); ! 622: ! 623: if (ent->client->pers.selected_item == -1) ! 624: { ! 625: gi.cprintf (ent, PRINT_HIGH, "No item to drop.\n"); ! 626: return; ! 627: } ! 628: ! 629: it = &itemlist[ent->client->pers.selected_item]; ! 630: if (!it->drop) ! 631: { ! 632: gi.cprintf (ent, PRINT_HIGH, "Item is not dropable.\n"); ! 633: return; ! 634: } ! 635: it->drop (ent, it); ! 636: } ! 637: ! 638: /* ! 639: ================= ! 640: Cmd_Kill_f ! 641: ================= ! 642: */ ! 643: void Cmd_Kill_f (edict_t *ent) ! 644: { ! 645: if((level.time - ent->client->respawn_time) < 5) ! 646: return; ! 647: ent->flags &= ~FL_GODMODE; ! 648: ent->health = 0; ! 649: meansOfDeath = MOD_SUICIDE; ! 650: ! 651: //ROGUE ! 652: // make sure no trackers are still hurting us. ! 653: if(ent->client->tracker_pain_framenum) ! 654: RemoveAttackingPainDaemons (ent); ! 655: ! 656: if (ent->client->owned_sphere) ! 657: { ! 658: G_FreeEdict(ent->client->owned_sphere); ! 659: ent->client->owned_sphere = NULL; ! 660: } ! 661: //ROGUE ! 662: ! 663: player_die (ent, ent, ent, 100000, vec3_origin); ! 664: } ! 665: ! 666: /* ! 667: ================= ! 668: Cmd_PutAway_f ! 669: ================= ! 670: */ ! 671: void Cmd_PutAway_f (edict_t *ent) ! 672: { ! 673: ent->client->showscores = false; ! 674: ent->client->showhelp = false; ! 675: ent->client->showinventory = false; ! 676: } ! 677: ! 678: ! 679: int PlayerSort (void const *a, void const *b) ! 680: { ! 681: int anum, bnum; ! 682: ! 683: anum = *(int *)a; ! 684: bnum = *(int *)b; ! 685: ! 686: anum = game.clients[anum].ps.stats[STAT_FRAGS]; ! 687: bnum = game.clients[bnum].ps.stats[STAT_FRAGS]; ! 688: ! 689: if (anum < bnum) ! 690: return -1; ! 691: if (anum > bnum) ! 692: return 1; ! 693: return 0; ! 694: } ! 695: ! 696: /* ! 697: ================= ! 698: Cmd_Players_f ! 699: ================= ! 700: */ ! 701: void Cmd_Players_f (edict_t *ent) ! 702: { ! 703: int i; ! 704: int count; ! 705: char small[64]; ! 706: char large[1280]; ! 707: int index[256]; ! 708: ! 709: count = 0; ! 710: for (i = 0 ; i < maxclients->value ; i++) ! 711: if (game.clients[i].pers.connected) ! 712: { ! 713: index[count] = i; ! 714: count++; ! 715: } ! 716: ! 717: // sort by frags ! 718: qsort (index, count, sizeof(index[0]), PlayerSort); ! 719: ! 720: // print information ! 721: large[0] = 0; ! 722: ! 723: for (i = 0 ; i < count ; i++) ! 724: { ! 725: Com_sprintf (small, sizeof(small), "%3i %s\n", ! 726: game.clients[index[i]].ps.stats[STAT_FRAGS], ! 727: game.clients[index[i]].pers.netname); ! 728: if (strlen (small) + strlen(large) > sizeof(large) - 100 ) ! 729: { // can't print all of them in one packet ! 730: strcat (large, "...\n"); ! 731: break; ! 732: } ! 733: strcat (large, small); ! 734: } ! 735: ! 736: gi.cprintf (ent, PRINT_HIGH, "%s\n%i players\n", large, count); ! 737: } ! 738: ! 739: /* ! 740: ================= ! 741: Cmd_Wave_f ! 742: ================= ! 743: */ ! 744: void Cmd_Wave_f (edict_t *ent) ! 745: { ! 746: int i; ! 747: ! 748: i = atoi (gi.argv(1)); ! 749: ! 750: // can't wave when ducked ! 751: if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) ! 752: return; ! 753: ! 754: if (ent->client->anim_priority > ANIM_WAVE) ! 755: return; ! 756: ! 757: ent->client->anim_priority = ANIM_WAVE; ! 758: ! 759: switch (i) ! 760: { ! 761: case 0: ! 762: gi.cprintf (ent, PRINT_HIGH, "flipoff\n"); ! 763: ent->s.frame = FRAME_flip01-1; ! 764: ent->client->anim_end = FRAME_flip12; ! 765: break; ! 766: case 1: ! 767: gi.cprintf (ent, PRINT_HIGH, "salute\n"); ! 768: ent->s.frame = FRAME_salute01-1; ! 769: ent->client->anim_end = FRAME_salute11; ! 770: break; ! 771: case 2: ! 772: gi.cprintf (ent, PRINT_HIGH, "taunt\n"); ! 773: ent->s.frame = FRAME_taunt01-1; ! 774: ent->client->anim_end = FRAME_taunt17; ! 775: break; ! 776: case 3: ! 777: gi.cprintf (ent, PRINT_HIGH, "wave\n"); ! 778: ent->s.frame = FRAME_wave01-1; ! 779: ent->client->anim_end = FRAME_wave11; ! 780: break; ! 781: case 4: ! 782: default: ! 783: gi.cprintf (ent, PRINT_HIGH, "point\n"); ! 784: ent->s.frame = FRAME_point01-1; ! 785: ent->client->anim_end = FRAME_point12; ! 786: break; ! 787: } ! 788: } ! 789: ! 790: /* ! 791: ================== ! 792: Cmd_Say_f ! 793: ================== ! 794: */ ! 795: void Cmd_Say_f (edict_t *ent, qboolean team, qboolean arg0) ! 796: { ! 797: int i, j; ! 798: edict_t *other; ! 799: char *p; ! 800: char text[2048]; ! 801: gclient_t *cl; ! 802: ! 803: if (gi.argc () < 2 && !arg0) ! 804: return; ! 805: ! 806: if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS))) ! 807: team = false; ! 808: ! 809: if (team) ! 810: Com_sprintf (text, sizeof(text), "(%s): ", ent->client->pers.netname); ! 811: else ! 812: Com_sprintf (text, sizeof(text), "%s: ", ent->client->pers.netname); ! 813: ! 814: if (arg0) ! 815: { ! 816: strcat (text, gi.argv(0)); ! 817: strcat (text, " "); ! 818: strcat (text, gi.args()); ! 819: } ! 820: else ! 821: { ! 822: p = gi.args(); ! 823: ! 824: if (*p == '"') ! 825: { ! 826: p++; ! 827: p[strlen(p)-1] = 0; ! 828: } ! 829: strcat(text, p); ! 830: } ! 831: ! 832: // don't let text be too long for malicious reasons ! 833: if (strlen(text) > 150) ! 834: text[150] = 0; ! 835: ! 836: strcat(text, "\n"); ! 837: ! 838: if (flood_msgs->value) { ! 839: cl = ent->client; ! 840: ! 841: if (level.time < cl->flood_locktill) { ! 842: gi.cprintf(ent, PRINT_HIGH, "You can't talk for %d more seconds\n", ! 843: (int)(cl->flood_locktill - level.time)); ! 844: return; ! 845: } ! 846: i = cl->flood_whenhead - flood_msgs->value + 1; ! 847: if (i < 0) ! 848: i = (sizeof(cl->flood_when)/sizeof(cl->flood_when[0])) + i; ! 849: if (cl->flood_when[i] && ! 850: level.time - cl->flood_when[i] < flood_persecond->value) { ! 851: cl->flood_locktill = level.time + flood_waitdelay->value; ! 852: gi.cprintf(ent, PRINT_CHAT, "Flood protection: You can't talk for %d seconds.\n", ! 853: (int)flood_waitdelay->value); ! 854: return; ! 855: } ! 856: cl->flood_whenhead = (cl->flood_whenhead + 1) % ! 857: (sizeof(cl->flood_when)/sizeof(cl->flood_when[0])); ! 858: cl->flood_when[cl->flood_whenhead] = level.time; ! 859: } ! 860: ! 861: if (dedicated->value) ! 862: gi.cprintf(NULL, PRINT_CHAT, "%s", text); ! 863: ! 864: for (j = 1; j <= game.maxclients; j++) ! 865: { ! 866: other = &g_edicts[j]; ! 867: if (!other->inuse) ! 868: continue; ! 869: if (!other->client) ! 870: continue; ! 871: if (team) ! 872: { ! 873: if (!OnSameTeam(ent, other)) ! 874: continue; ! 875: } ! 876: gi.cprintf(other, PRINT_CHAT, "%s", text); ! 877: } ! 878: } ! 879: ! 880: //====== ! 881: //ROGUE ! 882: void Cmd_Ent_Count_f (edict_t *ent) ! 883: { ! 884: int x; ! 885: edict_t *e; ! 886: ! 887: x=0; ! 888: ! 889: for (e=g_edicts;e < &g_edicts[globals.num_edicts] ; e++) ! 890: { ! 891: if(e->inuse) ! 892: x++; ! 893: } ! 894: ! 895: gi.dprintf("%d entites active\n", x); ! 896: } ! 897: //ROGUE ! 898: //====== ! 899: ! 900: void Cmd_PlayerList_f(edict_t *ent) ! 901: { ! 902: int i; ! 903: char st[80]; ! 904: char text[1400]; ! 905: edict_t *e2; ! 906: ! 907: // connect time, ping, score, name ! 908: *text = 0; ! 909: for (i = 0, e2 = g_edicts + 1; i < maxclients->value; i++, e2++) { ! 910: if (!e2->inuse) ! 911: continue; ! 912: ! 913: sprintf(st, "%02d:%02d %4d %3d %s%s\n", ! 914: (level.framenum - e2->client->resp.enterframe) / 600, ! 915: ((level.framenum - e2->client->resp.enterframe) % 600)/10, ! 916: e2->client->ping, ! 917: e2->client->resp.score, ! 918: e2->client->pers.netname, ! 919: e2->client->resp.spectator ? " (spectator)" : ""); ! 920: if (strlen(text) + strlen(st) > sizeof(text) - 50) { ! 921: sprintf(text+strlen(text), "And more...\n"); ! 922: gi.cprintf(ent, PRINT_HIGH, "%s", text); ! 923: return; ! 924: } ! 925: strcat(text, st); ! 926: } ! 927: gi.cprintf(ent, PRINT_HIGH, "%s", text); ! 928: } ! 929: ! 930: ! 931: /* ! 932: ================= ! 933: ClientCommand ! 934: ================= ! 935: */ ! 936: void ClientCommand (edict_t *ent) ! 937: { ! 938: char *cmd; ! 939: ! 940: if (!ent->client) ! 941: return; // not fully in game yet ! 942: ! 943: cmd = gi.argv(0); ! 944: ! 945: if (Q_stricmp (cmd, "players") == 0) ! 946: { ! 947: Cmd_Players_f (ent); ! 948: return; ! 949: } ! 950: if (Q_stricmp (cmd, "say") == 0) ! 951: { ! 952: Cmd_Say_f (ent, false, false); ! 953: return; ! 954: } ! 955: if (Q_stricmp (cmd, "say_team") == 0) ! 956: { ! 957: Cmd_Say_f (ent, true, false); ! 958: return; ! 959: } ! 960: if (Q_stricmp (cmd, "score") == 0) ! 961: { ! 962: Cmd_Score_f (ent); ! 963: return; ! 964: } ! 965: if (Q_stricmp (cmd, "help") == 0) ! 966: { ! 967: Cmd_Help_f (ent); ! 968: return; ! 969: } ! 970: ! 971: if (level.intermissiontime) ! 972: return; ! 973: ! 974: if (Q_stricmp (cmd, "use") == 0) ! 975: Cmd_Use_f (ent); ! 976: else if (Q_stricmp (cmd, "drop") == 0) ! 977: Cmd_Drop_f (ent); ! 978: else if (Q_stricmp (cmd, "give") == 0) ! 979: Cmd_Give_f (ent); ! 980: else if (Q_stricmp (cmd, "god") == 0) ! 981: Cmd_God_f (ent); ! 982: else if (Q_stricmp (cmd, "notarget") == 0) ! 983: Cmd_Notarget_f (ent); ! 984: else if (Q_stricmp (cmd, "noclip") == 0) ! 985: Cmd_Noclip_f (ent); ! 986: else if (Q_stricmp (cmd, "inven") == 0) ! 987: Cmd_Inven_f (ent); ! 988: else if (Q_stricmp (cmd, "invnext") == 0) ! 989: SelectNextItem (ent, -1); ! 990: else if (Q_stricmp (cmd, "invprev") == 0) ! 991: SelectPrevItem (ent, -1); ! 992: else if (Q_stricmp (cmd, "invnextw") == 0) ! 993: SelectNextItem (ent, IT_WEAPON); ! 994: else if (Q_stricmp (cmd, "invprevw") == 0) ! 995: SelectPrevItem (ent, IT_WEAPON); ! 996: else if (Q_stricmp (cmd, "invnextp") == 0) ! 997: SelectNextItem (ent, IT_POWERUP); ! 998: else if (Q_stricmp (cmd, "invprevp") == 0) ! 999: SelectPrevItem (ent, IT_POWERUP); ! 1000: else if (Q_stricmp (cmd, "invuse") == 0) ! 1001: Cmd_InvUse_f (ent); ! 1002: else if (Q_stricmp (cmd, "invdrop") == 0) ! 1003: Cmd_InvDrop_f (ent); ! 1004: else if (Q_stricmp (cmd, "weapprev") == 0) ! 1005: Cmd_WeapPrev_f (ent); ! 1006: else if (Q_stricmp (cmd, "weapnext") == 0) ! 1007: Cmd_WeapNext_f (ent); ! 1008: else if (Q_stricmp (cmd, "weaplast") == 0) ! 1009: Cmd_WeapLast_f (ent); ! 1010: else if (Q_stricmp (cmd, "kill") == 0) ! 1011: Cmd_Kill_f (ent); ! 1012: else if (Q_stricmp (cmd, "putaway") == 0) ! 1013: Cmd_PutAway_f (ent); ! 1014: else if (Q_stricmp (cmd, "wave") == 0) ! 1015: Cmd_Wave_f (ent); ! 1016: else if (Q_stricmp(cmd, "playerlist") == 0) ! 1017: Cmd_PlayerList_f(ent); ! 1018: else if (Q_stricmp (cmd, "entcount") == 0) // PGM ! 1019: Cmd_Ent_Count_f (ent); // PGM ! 1020: else if (Q_stricmp (cmd, "disguise") == 0) // PGM ! 1021: { ! 1022: ent->flags |= FL_DISGUISED; ! 1023: } ! 1024: else // anything that doesn't match a command will be a chat ! 1025: Cmd_Say_f (ent, false, true); ! 1026: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.