mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-01 05:30:58 +00:00
Add even more santiy checks to g_cmds.c
This commit is contained in:
parent
7dff3c1423
commit
cda35b691f
1 changed files with 147 additions and 22 deletions
|
@ -35,6 +35,11 @@ ClientTeam(edict_t *ent)
|
|||
|
||||
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,6 +192,11 @@ ValidateSelectedItem(edict_t *ent)
|
|||
{
|
||||
gclient_t *cl;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cl = ent->client;
|
||||
|
||||
if (cl->pers.inventory[cl->pers.selected_item])
|
||||
|
@ -197,6 +222,11 @@ Cmd_Give_f(edict_t *ent)
|
|||
qboolean give_all;
|
||||
edict_t *it_ent;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((deathmatch->value || coop->value) && !sv_cheats->value)
|
||||
{
|
||||
gi.cprintf( ent, PRINT_HIGH,
|
||||
|
@ -398,6 +428,11 @@ Cmd_God_f(edict_t *ent)
|
|||
{
|
||||
char *msg;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((deathmatch->value || coop->value) && !sv_cheats->value)
|
||||
{
|
||||
gi.cprintf( ent, PRINT_HIGH,
|
||||
|
@ -427,6 +462,11 @@ Cmd_Notarget_f(edict_t *ent)
|
|||
{
|
||||
char *msg;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((deathmatch->value || coop->value) && !sv_cheats->value)
|
||||
{
|
||||
gi.cprintf( ent, PRINT_HIGH,
|
||||
|
@ -456,6 +496,11 @@ Cmd_Noclip_f(edict_t *ent)
|
|||
{
|
||||
char *msg;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((deathmatch->value || coop->value) && !sv_cheats->value)
|
||||
{
|
||||
gi.cprintf( ent, PRINT_HIGH,
|
||||
|
@ -487,6 +532,11 @@ Cmd_Use_f(edict_t *ent)
|
|||
gitem_t *it;
|
||||
char *s;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
s = gi.args();
|
||||
it = FindItem(s);
|
||||
|
||||
|
@ -523,6 +573,11 @@ Cmd_Drop_f(edict_t *ent)
|
|||
gitem_t *it;
|
||||
char *s;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
s = gi.args();
|
||||
it = FindItem(s);
|
||||
|
||||
|
@ -555,6 +610,11 @@ Cmd_Inven_f(edict_t *ent)
|
|||
int i;
|
||||
gclient_t *cl;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cl = ent->client;
|
||||
|
||||
cl->showscores = false;
|
||||
|
@ -583,6 +643,11 @@ Cmd_InvUse_f(edict_t *ent)
|
|||
{
|
||||
gitem_t *it;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ValidateSelectedItem(ent);
|
||||
|
||||
if (ent->client->pers.selected_item == -1)
|
||||
|
@ -610,6 +675,11 @@ Cmd_WeapPrev_f(edict_t *ent)
|
|||
gitem_t *it;
|
||||
int selected_weapon;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cl = ent->client;
|
||||
|
||||
if (!cl->pers.weapon)
|
||||
|
@ -658,6 +728,11 @@ Cmd_WeapNext_f(edict_t *ent)
|
|||
gitem_t *it;
|
||||
int selected_weapon;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cl = ent->client;
|
||||
|
||||
if (!cl->pers.weapon)
|
||||
|
@ -705,6 +780,11 @@ Cmd_WeapLast_f(edict_t *ent)
|
|||
int index;
|
||||
gitem_t *it;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cl = ent->client;
|
||||
|
||||
if (!cl->pers.weapon || !cl->pers.lastweapon)
|
||||
|
@ -739,6 +819,11 @@ Cmd_InvDrop_f(edict_t *ent)
|
|||
{
|
||||
gitem_t *it;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ValidateSelectedItem(ent);
|
||||
|
||||
if (ent->client->pers.selected_item == -1)
|
||||
|
@ -761,6 +846,11 @@ 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))
|
||||
{
|
||||
|
@ -776,6 +866,11 @@ 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;
|
||||
|
@ -786,6 +881,11 @@ PlayerSort(void const *a, void const *b)
|
|||
{
|
||||
int anum, bnum;
|
||||
|
||||
if (!a || !b)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
anum = *(int *)a;
|
||||
bnum = *(int *)b;
|
||||
|
||||
|
@ -814,6 +914,11 @@ Cmd_Players_f(edict_t *ent)
|
|||
char large[1280];
|
||||
int index[256];
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
count = 0;
|
||||
|
||||
for (i = 0; i < maxclients->value; i++)
|
||||
|
@ -855,6 +960,11 @@ Cmd_Wave_f(edict_t *ent)
|
|||
{
|
||||
int i;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
i = atoi(gi.argv(1));
|
||||
|
||||
/* can't wave when ducked */
|
||||
|
@ -910,6 +1020,11 @@ Cmd_Say_f(edict_t *ent, qboolean team, qboolean arg0)
|
|||
char text[2048];
|
||||
gclient_t *cl;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((gi.argc() < 2) && !arg0)
|
||||
{
|
||||
return;
|
||||
|
@ -1028,6 +1143,11 @@ Cmd_PlayerList_f(edict_t *ent)
|
|||
char text[1400];
|
||||
edict_t *e2;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* connect time, ping, score, name */
|
||||
*text = 0;
|
||||
|
||||
|
@ -1064,6 +1184,11 @@ ClientCommand(edict_t *ent)
|
|||
{
|
||||
char *cmd;
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ent->client)
|
||||
{
|
||||
return; /* not fully in game yet */
|
||||
|
|
Loading…
Reference in a new issue