Add even more santiy checks to g_cmds.c

This commit is contained in:
Yamagi Burmeister 2011-09-27 18:01:29 +00:00
parent 7dff3c1423
commit cda35b691f

View file

@ -34,7 +34,12 @@ ClientTeam(edict_t *ent)
static char value[512];
value[0] = 0;
if (!ent)
{
return value;
}
if (!ent->client)
{
return value;
@ -63,6 +68,11 @@ OnSameTeam(edict_t *ent1, edict_t *ent2)
char ent1Team[512];
char ent2Team[512];
if (!ent1 || !ent2)
{
return false;
}
if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS)))
{
return false;
@ -86,6 +96,11 @@ SelectNextItem(edict_t *ent, int itflags)
int i, index;
gitem_t *it;
if (!ent)
{
return;
}
cl = ent->client;
if (cl->chase_target)
@ -130,6 +145,11 @@ SelectPrevItem(edict_t *ent, int itflags)
int i, index;
gitem_t *it;
if (!ent)
{
return;
}
cl = ent->client;
if (cl->chase_target)
@ -172,11 +192,16 @@ ValidateSelectedItem(edict_t *ent)
{
gclient_t *cl;
if (!ent)
{
return;
}
cl = ent->client;
if (cl->pers.inventory[cl->pers.selected_item])
{
return; /* valid */
return; /* valid */
}
SelectNextItem(ent, -1);
@ -196,7 +221,12 @@ Cmd_Give_f(edict_t *ent)
int i;
qboolean give_all;
edict_t *it_ent;
if (!ent)
{
return;
}
if ((deathmatch->value || coop->value) && !sv_cheats->value)
{
gi.cprintf( ent, PRINT_HIGH,
@ -397,7 +427,12 @@ void
Cmd_God_f(edict_t *ent)
{
char *msg;
if (!ent)
{
return;
}
if ((deathmatch->value || coop->value) && !sv_cheats->value)
{
gi.cprintf( ent, PRINT_HIGH,
@ -426,7 +461,12 @@ void
Cmd_Notarget_f(edict_t *ent)
{
char *msg;
if (!ent)
{
return;
}
if ((deathmatch->value || coop->value) && !sv_cheats->value)
{
gi.cprintf( ent, PRINT_HIGH,
@ -455,7 +495,12 @@ void
Cmd_Noclip_f(edict_t *ent)
{
char *msg;
if (!ent)
{
return;
}
if ((deathmatch->value || coop->value) && !sv_cheats->value)
{
gi.cprintf( ent, PRINT_HIGH,
@ -486,7 +531,12 @@ Cmd_Use_f(edict_t *ent)
int index;
gitem_t *it;
char *s;
if (!ent)
{
return;
}
s = gi.args();
it = FindItem(s);
@ -521,7 +571,12 @@ Cmd_Drop_f(edict_t *ent)
{
int index;
gitem_t *it;
char *s;
char *s;
if (!ent)
{
return;
}
s = gi.args();
it = FindItem(s);
@ -554,7 +609,12 @@ Cmd_Inven_f(edict_t *ent)
{
int i;
gclient_t *cl;
if (!ent)
{
return;
}
cl = ent->client;
cl->showscores = false;
@ -582,7 +642,12 @@ void
Cmd_InvUse_f(edict_t *ent)
{
gitem_t *it;
if (!ent)
{
return;
}
ValidateSelectedItem(ent);
if (ent->client->pers.selected_item == -1)
@ -609,7 +674,12 @@ Cmd_WeapPrev_f(edict_t *ent)
int i, index;
gitem_t *it;
int selected_weapon;
if (!ent)
{
return;
}
cl = ent->client;
if (!cl->pers.weapon)
@ -657,7 +727,12 @@ Cmd_WeapNext_f(edict_t *ent)
int i, index;
gitem_t *it;
int selected_weapon;
if (!ent)
{
return;
}
cl = ent->client;
if (!cl->pers.weapon)
@ -704,7 +779,12 @@ Cmd_WeapLast_f(edict_t *ent)
gclient_t *cl;
int index;
gitem_t *it;
if (!ent)
{
return;
}
cl = ent->client;
if (!cl->pers.weapon || !cl->pers.lastweapon)
@ -738,7 +818,12 @@ void
Cmd_InvDrop_f(edict_t *ent)
{
gitem_t *it;
if (!ent)
{
return;
}
ValidateSelectedItem(ent);
if (ent->client->pers.selected_item == -1)
@ -760,7 +845,12 @@ Cmd_InvDrop_f(edict_t *ent)
void
Cmd_Kill_f(edict_t *ent)
{
{
if (!ent)
{
return;
}
if (((level.time - ent->client->respawn_time) < 5) ||
(ent->client->resp.spectator))
{
@ -775,7 +865,12 @@ Cmd_Kill_f(edict_t *ent)
void
Cmd_PutAway_f(edict_t *ent)
{
{
if (!ent)
{
return;
}
ent->client->showscores = false;
ent->client->showhelp = false;
ent->client->showinventory = false;
@ -785,7 +880,12 @@ int
PlayerSort(void const *a, void const *b)
{
int anum, bnum;
if (!a || !b)
{
return 0;
}
anum = *(int *)a;
bnum = *(int *)b;
@ -813,7 +913,12 @@ Cmd_Players_f(edict_t *ent)
char small[64];
char large[1280];
int index[256];
if (!ent)
{
return;
}
count = 0;
for (i = 0; i < maxclients->value; i++)
@ -854,7 +959,12 @@ void
Cmd_Wave_f(edict_t *ent)
{
int i;
if (!ent)
{
return;
}
i = atoi(gi.argv(1));
/* can't wave when ducked */
@ -909,7 +1019,12 @@ Cmd_Say_f(edict_t *ent, qboolean team, qboolean arg0)
char *p;
char text[2048];
gclient_t *cl;
if (!ent)
{
return;
}
if ((gi.argc() < 2) && !arg0)
{
return;
@ -1027,7 +1142,12 @@ Cmd_PlayerList_f(edict_t *ent)
char st[80];
char text[1400];
edict_t *e2;
if (!ent)
{
return;
}
/* connect time, ping, score, name */
*text = 0;
@ -1063,7 +1183,12 @@ void
ClientCommand(edict_t *ent)
{
char *cmd;
if (!ent)
{
return;
}
if (!ent->client)
{
return; /* not fully in game yet */