diff options
Diffstat (limited to 'src/baseq2/g_cmds.c')
-rw-r--r-- | src/baseq2/g_cmds.c | 489 |
1 files changed, 218 insertions, 271 deletions
diff --git a/src/baseq2/g_cmds.c b/src/baseq2/g_cmds.c index 5bc5511..f0f333c 100644 --- a/src/baseq2/g_cmds.c +++ b/src/baseq2/g_cmds.c @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "m_player.h" -char *ClientTeam (edict_t *ent) +char *ClientTeam(edict_t *ent) { char *p; static char value[512]; @@ -31,13 +31,12 @@ char *ClientTeam (edict_t *ent) if (!ent->client) return value; - strcpy(value, Info_ValueForKey (ent->client->pers.userinfo, "skin")); + strcpy(value, Info_ValueForKey(ent->client->pers.userinfo, "skin")); p = strchr(value, '/'); if (!p) return value; - if ((int)(dmflags->value) & DF_MODELTEAMS) - { + if ((int)(dmflags->value) & DF_MODELTEAMS) { *p = 0; return value; } @@ -46,7 +45,7 @@ char *ClientTeam (edict_t *ent) return ++p; } -qboolean OnSameTeam (edict_t *ent1, edict_t *ent2) +qboolean OnSameTeam(edict_t *ent1, edict_t *ent2) { char ent1Team [512]; char ent2Team [512]; @@ -54,8 +53,8 @@ qboolean OnSameTeam (edict_t *ent1, edict_t *ent2) if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS))) return qfalse; - strcpy (ent1Team, ClientTeam (ent1)); - strcpy (ent2Team, ClientTeam (ent2)); + strcpy(ent1Team, ClientTeam(ent1)); + strcpy(ent2Team, ClientTeam(ent2)); if (strcmp(ent1Team, ent2Team) == 0) return qtrue; @@ -63,7 +62,7 @@ qboolean OnSameTeam (edict_t *ent1, edict_t *ent2) } -void SelectNextItem (edict_t *ent, int itflags) +void SelectNextItem(edict_t *ent, int itflags) { gclient_t *cl; int i, index; @@ -77,9 +76,8 @@ void SelectNextItem (edict_t *ent, int itflags) } // scan for the next valid one - for (i=1 ; i<=MAX_ITEMS ; i++) - { - index = (cl->pers.selected_item + i)%MAX_ITEMS; + for (i = 1 ; i <= MAX_ITEMS ; i++) { + index = (cl->pers.selected_item + i) % MAX_ITEMS; if (!cl->pers.inventory[index]) continue; it = &itemlist[index]; @@ -95,7 +93,7 @@ void SelectNextItem (edict_t *ent, int itflags) cl->pers.selected_item = -1; } -void SelectPrevItem (edict_t *ent, int itflags) +void SelectPrevItem(edict_t *ent, int itflags) { gclient_t *cl; int i, index; @@ -109,9 +107,8 @@ void SelectPrevItem (edict_t *ent, int itflags) } // scan for the next valid one - for (i=1 ; i<=MAX_ITEMS ; i++) - { - index = (cl->pers.selected_item + MAX_ITEMS - i)%MAX_ITEMS; + for (i = 1 ; i <= MAX_ITEMS ; i++) { + index = (cl->pers.selected_item + MAX_ITEMS - i) % MAX_ITEMS; if (!cl->pers.inventory[index]) continue; it = &itemlist[index]; @@ -127,7 +124,7 @@ void SelectPrevItem (edict_t *ent, int itflags) cl->pers.selected_item = -1; } -void ValidateSelectedItem (edict_t *ent) +void ValidateSelectedItem(edict_t *ent) { gclient_t *cl; @@ -136,7 +133,7 @@ void ValidateSelectedItem (edict_t *ent) if (cl->pers.inventory[cl->pers.selected_item]) return; // valid - SelectNextItem (ent, -1); + SelectNextItem(ent, -1); } @@ -149,7 +146,7 @@ Cmd_Give_f Give items to a client ================== */ -void Cmd_Give_f (edict_t *ent) +void Cmd_Give_f(edict_t *ent) { char *name; gitem_t *it; @@ -158,9 +155,8 @@ void Cmd_Give_f (edict_t *ent) qboolean give_all; edict_t *it_ent; - if (deathmatch->value && !sv_cheats->value) - { - gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); + if (deathmatch->value && !sv_cheats->value) { + gi.cprintf(ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); return; } @@ -171,8 +167,7 @@ void Cmd_Give_f (edict_t *ent) else give_all = qfalse; - if (give_all || Q_stricmp(gi.argv(1), "health") == 0) - { + if (give_all || Q_stricmp(gi.argv(1), "health") == 0) { if (gi.argc() == 3) ent->health = atoi(gi.argv(2)); else @@ -181,10 +176,8 @@ void Cmd_Give_f (edict_t *ent) return; } - if (give_all || Q_stricmp(name, "weapons") == 0) - { - for (i=0 ; i<game.num_items ; i++) - { + if (give_all || Q_stricmp(name, "weapons") == 0) { + for (i = 0 ; i < game.num_items ; i++) { it = itemlist + i; if (!it->pickup) continue; @@ -196,23 +189,20 @@ void Cmd_Give_f (edict_t *ent) return; } - if (give_all || Q_stricmp(name, "ammo") == 0) - { - for (i=0 ; i<game.num_items ; i++) - { + if (give_all || Q_stricmp(name, "ammo") == 0) { + for (i = 0 ; i < game.num_items ; i++) { it = itemlist + i; if (!it->pickup) continue; if (!(it->flags & IT_AMMO)) continue; - Add_Ammo (ent, it, 1000); + Add_Ammo(ent, it, 1000); } if (!give_all) return; } - if (give_all || Q_stricmp(name, "armor") == 0) - { + if (give_all || Q_stricmp(name, "armor") == 0) { gitem_armor_t *info; it = FindItem("Jacket Armor"); @@ -229,13 +219,12 @@ void Cmd_Give_f (edict_t *ent) return; } - if (give_all || Q_stricmp(name, "Power Shield") == 0) - { + if (give_all || Q_stricmp(name, "Power Shield") == 0) { it = FindItem("Power Shield"); it_ent = G_Spawn(); it_ent->classname = it->classname; - SpawnItem (it_ent, it); - Touch_Item (it_ent, ent, NULL, NULL); + SpawnItem(it_ent, it); + Touch_Item(it_ent, ent, NULL, NULL); if (it_ent->inuse) G_FreeEdict(it_ent); @@ -243,53 +232,45 @@ void Cmd_Give_f (edict_t *ent) return; } - if (give_all) - { - for (i=0 ; i<game.num_items ; i++) - { + if (give_all) { + for (i = 0 ; i < game.num_items ; i++) { it = itemlist + i; if (!it->pickup) continue; - if (it->flags & (IT_ARMOR|IT_WEAPON|IT_AMMO)) + if (it->flags & (IT_ARMOR | IT_WEAPON | IT_AMMO)) continue; ent->client->pers.inventory[i] = 1; } return; } - it = FindItem (name); - if (!it) - { + it = FindItem(name); + if (!it) { name = gi.argv(1); - it = FindItem (name); - if (!it) - { - gi.cprintf (ent, PRINT_HIGH, "unknown item\n"); + it = FindItem(name); + if (!it) { + gi.cprintf(ent, PRINT_HIGH, "unknown item\n"); return; } } - if (!it->pickup) - { - gi.cprintf (ent, PRINT_HIGH, "non-pickup item\n"); + if (!it->pickup) { + gi.cprintf(ent, PRINT_HIGH, "non-pickup item\n"); return; } index = ITEM_INDEX(it); - if (it->flags & IT_AMMO) - { + if (it->flags & IT_AMMO) { if (gi.argc() == 3) ent->client->pers.inventory[index] = atoi(gi.argv(2)); else ent->client->pers.inventory[index] += it->quantity; - } - else - { + } else { it_ent = G_Spawn(); it_ent->classname = it->classname; - SpawnItem (it_ent, it); - Touch_Item (it_ent, ent, NULL, NULL); + SpawnItem(it_ent, it); + Touch_Item(it_ent, ent, NULL, NULL); if (it_ent->inuse) G_FreeEdict(it_ent); } @@ -305,23 +286,22 @@ Sets client to godmode argv(0) god ================== */ -void Cmd_God_f (edict_t *ent) +void Cmd_God_f(edict_t *ent) { char *msg; - if (deathmatch->value && !sv_cheats->value) - { - gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); + if (deathmatch->value && !sv_cheats->value) { + gi.cprintf(ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); return; } ent->flags ^= FL_GODMODE; - if (!(ent->flags & FL_GODMODE) ) + if (!(ent->flags & FL_GODMODE)) msg = "godmode OFF\n"; else msg = "godmode ON\n"; - gi.cprintf (ent, PRINT_HIGH, msg); + gi.cprintf(ent, PRINT_HIGH, msg); } @@ -334,23 +314,22 @@ Sets client to notarget argv(0) notarget ================== */ -void Cmd_Notarget_f (edict_t *ent) +void Cmd_Notarget_f(edict_t *ent) { char *msg; - if (deathmatch->value && !sv_cheats->value) - { - gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); + if (deathmatch->value && !sv_cheats->value) { + gi.cprintf(ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); return; } ent->flags ^= FL_NOTARGET; - if (!(ent->flags & FL_NOTARGET) ) + if (!(ent->flags & FL_NOTARGET)) msg = "notarget OFF\n"; else msg = "notarget ON\n"; - gi.cprintf (ent, PRINT_HIGH, msg); + gi.cprintf(ent, PRINT_HIGH, msg); } @@ -361,28 +340,24 @@ Cmd_Noclip_f argv(0) noclip ================== */ -void Cmd_Noclip_f (edict_t *ent) +void Cmd_Noclip_f(edict_t *ent) { char *msg; - if (deathmatch->value && !sv_cheats->value) - { - gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); + if (deathmatch->value && !sv_cheats->value) { + gi.cprintf(ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); return; } - if (ent->movetype == MOVETYPE_NOCLIP) - { + if (ent->movetype == MOVETYPE_NOCLIP) { ent->movetype = MOVETYPE_WALK; msg = "noclip OFF\n"; - } - else - { + } else { ent->movetype = MOVETYPE_NOCLIP; msg = "noclip ON\n"; } - gi.cprintf (ent, PRINT_HIGH, msg); + gi.cprintf(ent, PRINT_HIGH, msg); } @@ -393,32 +368,29 @@ Cmd_Use_f Use an inventory item ================== */ -void Cmd_Use_f (edict_t *ent) +void Cmd_Use_f(edict_t *ent) { int index; gitem_t *it; char *s; s = gi.args(); - it = FindItem (s); - if (!it) - { - gi.cprintf (ent, PRINT_HIGH, "unknown item: %s\n", s); + it = FindItem(s); + if (!it) { + gi.cprintf(ent, PRINT_HIGH, "unknown item: %s\n", s); return; } - if (!it->use) - { - gi.cprintf (ent, PRINT_HIGH, "Item is not usable.\n"); + if (!it->use) { + gi.cprintf(ent, PRINT_HIGH, "Item is not usable.\n"); return; } index = ITEM_INDEX(it); - if (!ent->client->pers.inventory[index]) - { - gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s); + if (!ent->client->pers.inventory[index]) { + gi.cprintf(ent, PRINT_HIGH, "Out of item: %s\n", s); return; } - it->use (ent, it); + it->use(ent, it); } @@ -429,32 +401,29 @@ Cmd_Drop_f Drop an inventory item ================== */ -void Cmd_Drop_f (edict_t *ent) +void Cmd_Drop_f(edict_t *ent) { int index; gitem_t *it; char *s; s = gi.args(); - it = FindItem (s); - if (!it) - { - gi.cprintf (ent, PRINT_HIGH, "unknown item: %s\n", s); + it = FindItem(s); + if (!it) { + gi.cprintf(ent, PRINT_HIGH, "unknown item: %s\n", s); return; } - if (!it->drop) - { - gi.cprintf (ent, PRINT_HIGH, "Item is not dropable.\n"); + if (!it->drop) { + gi.cprintf(ent, PRINT_HIGH, "Item is not dropable.\n"); return; } index = ITEM_INDEX(it); - if (!ent->client->pers.inventory[index]) - { - gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s); + if (!ent->client->pers.inventory[index]) { + gi.cprintf(ent, PRINT_HIGH, "Out of item: %s\n", s); return; } - it->drop (ent, it); + it->drop(ent, it); } @@ -463,7 +432,7 @@ void Cmd_Drop_f (edict_t *ent) Cmd_Inven_f ================= */ -void Cmd_Inven_f (edict_t *ent) +void Cmd_Inven_f(edict_t *ent) { int i; gclient_t *cl; @@ -473,20 +442,18 @@ void Cmd_Inven_f (edict_t *ent) cl->showscores = qfalse; cl->showhelp = qfalse; - if (cl->showinventory) - { + if (cl->showinventory) { cl->showinventory = qfalse; return; } cl->showinventory = qtrue; - gi.WriteByte (svc_inventory); - for (i=0 ; i<MAX_ITEMS ; i++) - { - gi.WriteShort (cl->pers.inventory[i]); + gi.WriteByte(svc_inventory); + for (i = 0 ; i < MAX_ITEMS ; i++) { + gi.WriteShort(cl->pers.inventory[i]); } - gi.unicast (ent, qtrue); + gi.unicast(ent, qtrue); } /* @@ -494,25 +461,23 @@ void Cmd_Inven_f (edict_t *ent) Cmd_InvUse_f ================= */ -void Cmd_InvUse_f (edict_t *ent) +void Cmd_InvUse_f(edict_t *ent) { gitem_t *it; - ValidateSelectedItem (ent); + ValidateSelectedItem(ent); - if (ent->client->pers.selected_item == -1) - { - gi.cprintf (ent, PRINT_HIGH, "No item to use.\n"); + if (ent->client->pers.selected_item == -1) { + gi.cprintf(ent, PRINT_HIGH, "No item to use.\n"); return; } it = &itemlist[ent->client->pers.selected_item]; - if (!it->use) - { - gi.cprintf (ent, PRINT_HIGH, "Item is not usable.\n"); + if (!it->use) { + gi.cprintf(ent, PRINT_HIGH, "Item is not usable.\n"); return; } - it->use (ent, it); + it->use(ent, it); } /* @@ -520,7 +485,7 @@ void Cmd_InvUse_f (edict_t *ent) Cmd_WeapPrev_f ================= */ -void Cmd_WeapPrev_f (edict_t *ent) +void Cmd_WeapPrev_f(edict_t *ent) { gclient_t *cl; int i, index; @@ -535,17 +500,16 @@ void Cmd_WeapPrev_f (edict_t *ent) selected_weapon = ITEM_INDEX(cl->pers.weapon); // scan for the next valid one - for (i=1 ; i<=MAX_ITEMS ; i++) - { - index = (selected_weapon + i)%MAX_ITEMS; + for (i = 1 ; i <= MAX_ITEMS ; i++) { + index = (selected_weapon + i) % MAX_ITEMS; if (!cl->pers.inventory[index]) continue; it = &itemlist[index]; if (!it->use) continue; - if (! (it->flags & IT_WEAPON) ) + if (!(it->flags & IT_WEAPON)) continue; - it->use (ent, it); + it->use(ent, it); if (cl->pers.weapon == it) return; // successful } @@ -556,7 +520,7 @@ void Cmd_WeapPrev_f (edict_t *ent) Cmd_WeapNext_f ================= */ -void Cmd_WeapNext_f (edict_t *ent) +void Cmd_WeapNext_f(edict_t *ent) { gclient_t *cl; int i, index; @@ -571,17 +535,16 @@ void Cmd_WeapNext_f (edict_t *ent) selected_weapon = ITEM_INDEX(cl->pers.weapon); // scan for the next valid one - for (i=1 ; i<=MAX_ITEMS ; i++) - { - index = (selected_weapon + MAX_ITEMS - i)%MAX_ITEMS; + for (i = 1 ; i <= MAX_ITEMS ; i++) { + index = (selected_weapon + MAX_ITEMS - i) % MAX_ITEMS; if (!cl->pers.inventory[index]) continue; it = &itemlist[index]; if (!it->use) continue; - if (! (it->flags & IT_WEAPON) ) + if (!(it->flags & IT_WEAPON)) continue; - it->use (ent, it); + it->use(ent, it); if (cl->pers.weapon == it) return; // successful } @@ -592,7 +555,7 @@ void Cmd_WeapNext_f (edict_t *ent) Cmd_WeapLast_f ================= */ -void Cmd_WeapLast_f (edict_t *ent) +void Cmd_WeapLast_f(edict_t *ent) { gclient_t *cl; int index; @@ -609,9 +572,9 @@ void Cmd_WeapLast_f (edict_t *ent) it = &itemlist[index]; if (!it->use) return; - if (! (it->flags & IT_WEAPON) ) + if (!(it->flags & IT_WEAPON)) return; - it->use (ent, it); + it->use(ent, it); } /* @@ -619,25 +582,23 @@ void Cmd_WeapLast_f (edict_t *ent) Cmd_InvDrop_f ================= */ -void Cmd_InvDrop_f (edict_t *ent) +void Cmd_InvDrop_f(edict_t *ent) { gitem_t *it; - ValidateSelectedItem (ent); + ValidateSelectedItem(ent); - if (ent->client->pers.selected_item == -1) - { - gi.cprintf (ent, PRINT_HIGH, "No item to drop.\n"); + if (ent->client->pers.selected_item == -1) { + gi.cprintf(ent, PRINT_HIGH, "No item to drop.\n"); return; } it = &itemlist[ent->client->pers.selected_item]; - if (!it->drop) - { - gi.cprintf (ent, PRINT_HIGH, "Item is not dropable.\n"); + if (!it->drop) { + gi.cprintf(ent, PRINT_HIGH, "Item is not dropable.\n"); return; } - it->drop (ent, it); + it->drop(ent, it); } /* @@ -645,14 +606,14 @@ void Cmd_InvDrop_f (edict_t *ent) Cmd_Kill_f ================= */ -void Cmd_Kill_f (edict_t *ent) +void Cmd_Kill_f(edict_t *ent) { - if((level.time - ent->client->respawn_time) < 5) + if ((level.time - ent->client->respawn_time) < 5) return; ent->flags &= ~FL_GODMODE; ent->health = 0; meansOfDeath = MOD_SUICIDE; - player_die (ent, ent, ent, 100000, vec3_origin); + player_die(ent, ent, ent, 100000, vec3_origin); } /* @@ -660,7 +621,7 @@ void Cmd_Kill_f (edict_t *ent) Cmd_PutAway_f ================= */ -void Cmd_PutAway_f (edict_t *ent) +void Cmd_PutAway_f(edict_t *ent) { ent->client->showscores = qfalse; ent->client->showhelp = qfalse; @@ -668,7 +629,7 @@ void Cmd_PutAway_f (edict_t *ent) } -int PlayerSort (void const *a, void const *b) +int PlayerSort(void const *a, void const *b) { int anum, bnum; @@ -690,7 +651,7 @@ int PlayerSort (void const *a, void const *b) Cmd_Players_f ================= */ -void Cmd_Players_f (edict_t *ent) +void Cmd_Players_f(edict_t *ent) { int i; int count; @@ -700,32 +661,30 @@ void Cmd_Players_f (edict_t *ent) count = 0; for (i = 0 ; i < maxclients->value ; i++) - if (game.clients[i].pers.connected) - { + if (game.clients[i].pers.connected) { index[count] = i; count++; } // sort by frags - qsort (index, count, sizeof(index[0]), PlayerSort); + qsort(index, count, sizeof(index[0]), PlayerSort); // print information large[0] = 0; - for (i = 0 ; i < count ; i++) - { - Q_snprintf (small, sizeof(small), "%3i %s\n", - game.clients[index[i]].ps.stats[STAT_FRAGS], - game.clients[index[i]].pers.netname); - if (strlen (small) + strlen(large) > sizeof(large) - 100 ) - { // can't print all of them in one packet - strcat (large, "...\n"); + for (i = 0 ; i < count ; i++) { + Q_snprintf(small, sizeof(small), "%3i %s\n", + game.clients[index[i]].ps.stats[STAT_FRAGS], + game.clients[index[i]].pers.netname); + if (strlen(small) + strlen(large) > sizeof(large) - 100) { + // can't print all of them in one packet + strcat(large, "...\n"); break; } - strcat (large, small); + strcat(large, small); } - gi.cprintf (ent, PRINT_HIGH, "%s\n%i players\n", large, count); + gi.cprintf(ent, PRINT_HIGH, "%s\n%i players\n", large, count); } /* @@ -733,11 +692,11 @@ void Cmd_Players_f (edict_t *ent) Cmd_Wave_f ================= */ -void Cmd_Wave_f (edict_t *ent) +void Cmd_Wave_f(edict_t *ent) { int i; - i = atoi (gi.argv(1)); + i = atoi(gi.argv(1)); // can't wave when ducked if (ent->client->ps.pmove.pm_flags & PMF_DUCKED) @@ -748,32 +707,31 @@ void Cmd_Wave_f (edict_t *ent) ent->client->anim_priority = ANIM_WAVE; - switch (i) - { + switch (i) { case 0: - gi.cprintf (ent, PRINT_HIGH, "flipoff\n"); - ent->s.frame = FRAME_flip01-1; + gi.cprintf(ent, PRINT_HIGH, "flipoff\n"); + ent->s.frame = FRAME_flip01 - 1; ent->client->anim_end = FRAME_flip12; break; case 1: - gi.cprintf (ent, PRINT_HIGH, "salute\n"); - ent->s.frame = FRAME_salute01-1; + gi.cprintf(ent, PRINT_HIGH, "salute\n"); + ent->s.frame = FRAME_salute01 - 1; ent->client->anim_end = FRAME_salute11; break; case 2: - gi.cprintf (ent, PRINT_HIGH, "taunt\n"); - ent->s.frame = FRAME_taunt01-1; + gi.cprintf(ent, PRINT_HIGH, "taunt\n"); + ent->s.frame = FRAME_taunt01 - 1; ent->client->anim_end = FRAME_taunt17; break; case 3: - gi.cprintf (ent, PRINT_HIGH, "wave\n"); - ent->s.frame = FRAME_wave01-1; + gi.cprintf(ent, PRINT_HIGH, "wave\n"); + ent->s.frame = FRAME_wave01 - 1; ent->client->anim_end = FRAME_wave11; break; case 4: default: - gi.cprintf (ent, PRINT_HIGH, "point\n"); - ent->s.frame = FRAME_point01-1; + gi.cprintf(ent, PRINT_HIGH, "point\n"); + ent->s.frame = FRAME_point01 - 1; ent->client->anim_end = FRAME_point12; break; } @@ -784,7 +742,7 @@ void Cmd_Wave_f (edict_t *ent) Cmd_Say_f ================== */ -void Cmd_Say_f (edict_t *ent, qboolean team, qboolean arg0) +void Cmd_Say_f(edict_t *ent, qboolean team, qboolean arg0) { int i, j; edict_t *other; @@ -792,31 +750,27 @@ void Cmd_Say_f (edict_t *ent, qboolean team, qboolean arg0) char text[2048]; gclient_t *cl; - if (gi.argc () < 2 && !arg0) + if (gi.argc() < 2 && !arg0) return; if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS))) team = qfalse; if (team) - Q_snprintf (text, sizeof(text), "(%s): ", ent->client->pers.netname); + Q_snprintf(text, sizeof(text), "(%s): ", ent->client->pers.netname); else - Q_snprintf (text, sizeof(text), "%s: ", ent->client->pers.netname); + Q_snprintf(text, sizeof(text), "%s: ", ent->client->pers.netname); - if (arg0) - { - strcat (text, gi.argv(0)); - strcat (text, " "); - strcat (text, gi.args()); - } - else - { + if (arg0) { + strcat(text, gi.argv(0)); + strcat(text, " "); + strcat(text, gi.args()); + } else { p = gi.args(); - if (*p == '"') - { + if (*p == '"') { p++; - p[strlen(p)-1] = 0; + p[strlen(p) - 1] = 0; } strcat(text, p); } @@ -832,36 +786,34 @@ void Cmd_Say_f (edict_t *ent, qboolean team, qboolean arg0) if (level.time < cl->flood_locktill) { gi.cprintf(ent, PRINT_HIGH, "You can't talk for %d more seconds\n", - (int)(cl->flood_locktill - level.time)); + (int)(cl->flood_locktill - level.time)); return; } i = cl->flood_whenhead - flood_msgs->value + 1; if (i < 0) - i = (sizeof(cl->flood_when)/sizeof(cl->flood_when[0])) + i; - if (cl->flood_when[i] && + i = (sizeof(cl->flood_when) / sizeof(cl->flood_when[0])) + i; + if (cl->flood_when[i] && level.time - cl->flood_when[i] < flood_persecond->value) { cl->flood_locktill = level.time + flood_waitdelay->value; gi.cprintf(ent, PRINT_CHAT, "Flood protection: You can't talk for %d seconds.\n", - (int)flood_waitdelay->value); + (int)flood_waitdelay->value); return; } cl->flood_whenhead = (cl->flood_whenhead + 1) % - (sizeof(cl->flood_when)/sizeof(cl->flood_when[0])); + (sizeof(cl->flood_when) / sizeof(cl->flood_when[0])); cl->flood_when[cl->flood_whenhead] = level.time; } if (dedicated->value) gi.cprintf(NULL, PRINT_CHAT, "%s", text); - for (j = 1; j <= game.maxclients; j++) - { + for (j = 1; j <= game.maxclients; j++) { other = &g_edicts[j]; if (!other->inuse) continue; if (!other->client) continue; - if (team) - { + if (team) { if (!OnSameTeam(ent, other)) continue; } @@ -883,14 +835,14 @@ void Cmd_PlayerList_f(edict_t *ent) continue; Q_snprintf(st, sizeof(st), "%02d:%02d %4d %3d %s%s\n", - (level.framenum - e2->client->resp.enterframe) / 600, - ((level.framenum - e2->client->resp.enterframe) % 600)/10, - e2->client->ping, - e2->client->resp.score, - e2->client->pers.netname, - e2->client->resp.spectator ? " (spectator)" : ""); + (level.framenum - e2->client->resp.enterframe) / 600, + ((level.framenum - e2->client->resp.enterframe) % 600) / 10, + e2->client->ping, + e2->client->resp.score, + e2->client->pers.netname, + e2->client->resp.spectator ? " (spectator)" : ""); if (strlen(text) + strlen(st) > sizeof(text) - 50) { - sprintf(text+strlen(text), "And more...\n"); + sprintf(text + strlen(text), "And more...\n"); gi.cprintf(ent, PRINT_HIGH, "%s", text); return; } @@ -905,7 +857,7 @@ void Cmd_PlayerList_f(edict_t *ent) ClientCommand ================= */ -void ClientCommand (edict_t *ent) +void ClientCommand(edict_t *ent) { char *cmd; @@ -914,79 +866,74 @@ void ClientCommand (edict_t *ent) cmd = gi.argv(0); - if (Q_stricmp (cmd, "players") == 0) - { - Cmd_Players_f (ent); + if (Q_stricmp(cmd, "players") == 0) { + Cmd_Players_f(ent); return; } - if (Q_stricmp (cmd, "say") == 0) - { - Cmd_Say_f (ent, qfalse, qfalse); + if (Q_stricmp(cmd, "say") == 0) { + Cmd_Say_f(ent, qfalse, qfalse); return; } - if (Q_stricmp (cmd, "say_team") == 0) - { - Cmd_Say_f (ent, qtrue, qfalse); + if (Q_stricmp(cmd, "say_team") == 0) { + Cmd_Say_f(ent, qtrue, qfalse); return; } - if (Q_stricmp (cmd, "score") == 0) - { - Cmd_Score_f (ent); + if (Q_stricmp(cmd, "score") == 0) { + Cmd_Score_f(ent); return; } - if (Q_stricmp (cmd, "help") == 0) - { - Cmd_Help_f (ent); + if (Q_stricmp(cmd, "help") == 0) { + Cmd_Help_f(ent); return; } if (level.intermissiontime) return; - if (Q_stricmp (cmd, "use") == 0) - Cmd_Use_f (ent); - else if (Q_stricmp (cmd, "drop") == 0) - Cmd_Drop_f (ent); - else if (Q_stricmp (cmd, "give") == 0) - Cmd_Give_f (ent); - else if (Q_stricmp (cmd, "god") == 0) - Cmd_God_f (ent); - else if (Q_stricmp (cmd, "notarget") == 0) - Cmd_Notarget_f (ent); - else if (Q_stricmp (cmd, "noclip") == 0) - Cmd_Noclip_f (ent); - else if (Q_stricmp (cmd, "inven") == 0) - Cmd_Inven_f (ent); - else if (Q_stricmp (cmd, "invnext") == 0) - SelectNextItem (ent, -1); - else if (Q_stricmp (cmd, "invprev") == 0) - SelectPrevItem (ent, -1); - else if (Q_stricmp (cmd, "invnextw") == 0) - SelectNextItem (ent, IT_WEAPON); - else if (Q_stricmp (cmd, "invprevw") == 0) - SelectPrevItem (ent, IT_WEAPON); - else if (Q_stricmp (cmd, "invnextp") == 0) - SelectNextItem (ent, IT_POWERUP); - else if (Q_stricmp (cmd, "invprevp") == 0) - SelectPrevItem (ent, IT_POWERUP); - else if (Q_stricmp (cmd, "invuse") == 0) - Cmd_InvUse_f (ent); - else if (Q_stricmp (cmd, "invdrop") == 0) - Cmd_InvDrop_f (ent); - else if (Q_stricmp (cmd, "weapprev") == 0) - Cmd_WeapPrev_f (ent); - else if (Q_stricmp (cmd, "weapnext") == 0) - Cmd_WeapNext_f (ent); - else if (Q_stricmp (cmd, "weaplast") == 0) - Cmd_WeapLast_f (ent); - else if (Q_stricmp (cmd, "kill") == 0) - Cmd_Kill_f (ent); - else if (Q_stricmp (cmd, "putaway") == 0) - Cmd_PutAway_f (ent); - else if (Q_stricmp (cmd, "wave") == 0) - Cmd_Wave_f (ent); + if (Q_stricmp(cmd, "use") == 0) + Cmd_Use_f(ent); + else if (Q_stricmp(cmd, "drop") == 0) + Cmd_Drop_f(ent); + else if (Q_stricmp(cmd, "give") == 0) + Cmd_Give_f(ent); + else if (Q_stricmp(cmd, "god") == 0) + Cmd_God_f(ent); + else if (Q_stricmp(cmd, "notarget") == 0) + Cmd_Notarget_f(ent); + else if (Q_stricmp(cmd, "noclip") == 0) + Cmd_Noclip_f(ent); + else if (Q_stricmp(cmd, "inven") == 0) + Cmd_Inven_f(ent); + else if (Q_stricmp(cmd, "invnext") == 0) + SelectNextItem(ent, -1); + else if (Q_stricmp(cmd, "invprev") == 0) + SelectPrevItem(ent, -1); + else if (Q_stricmp(cmd, "invnextw") == 0) + SelectNextItem(ent, IT_WEAPON); + else if (Q_stricmp(cmd, "invprevw") == 0) + SelectPrevItem(ent, IT_WEAPON); + else if (Q_stricmp(cmd, "invnextp") == 0) + SelectNextItem(ent, IT_POWERUP); + else if (Q_stricmp(cmd, "invprevp") == 0) + SelectPrevItem(ent, IT_POWERUP); + else if (Q_stricmp(cmd, "invuse") == 0) + Cmd_InvUse_f(ent); + else if (Q_stricmp(cmd, "invdrop") == 0) + Cmd_InvDrop_f(ent); + else if (Q_stricmp(cmd, "weapprev") == 0) + Cmd_WeapPrev_f(ent); + else if (Q_stricmp(cmd, "weapnext") == 0) + Cmd_WeapNext_f(ent); + else if (Q_stricmp(cmd, "weaplast") == 0) + Cmd_WeapLast_f(ent); + else if (Q_stricmp(cmd, "kill") == 0) + Cmd_Kill_f(ent); + else if (Q_stricmp(cmd, "putaway") == 0) + Cmd_PutAway_f(ent); + else if (Q_stricmp(cmd, "wave") == 0) + Cmd_Wave_f(ent); else if (Q_stricmp(cmd, "playerlist") == 0) Cmd_PlayerList_f(ent); else // anything that doesn't match a command will be a chat - Cmd_Say_f (ent, qfalse, qtrue); + Cmd_Say_f(ent, qfalse, qtrue); } |