mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-03-31 23:41:25 +00:00
PVS Studio fixes for game/
This commit is contained in:
parent
ae3723c900
commit
95a3e46bdd
15 changed files with 28 additions and 78 deletions
|
@ -806,10 +806,6 @@ M_CheckAttack(edict_t *self)
|
|||
{
|
||||
chance = 0.4;
|
||||
}
|
||||
else if (enemy_range == RANGE_MELEE)
|
||||
{
|
||||
chance = 0.2;
|
||||
}
|
||||
else if (enemy_range == RANGE_NEAR)
|
||||
{
|
||||
chance = 0.1;
|
||||
|
@ -1319,8 +1315,5 @@ ai_run(edict_t *self, float dist)
|
|||
|
||||
G_FreeEdict(tempgoal);
|
||||
|
||||
if (self)
|
||||
{
|
||||
self->goalentity = save;
|
||||
}
|
||||
self->goalentity = save;
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ Killed(edict_t *targ, edict_t *inflictor, edict_t *attacker,
|
|||
}
|
||||
|
||||
/* medics won't heal monsters that they kill themselves */
|
||||
if (attacker && attacker->classname && strcmp(attacker->classname, "monster_medic") == 0)
|
||||
if (attacker->classname && strcmp(attacker->classname, "monster_medic") == 0)
|
||||
{
|
||||
targ->owner = attacker;
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ M_ReactToDamage(edict_t *targ, edict_t *attacker)
|
|||
}
|
||||
/* otherwise get mad at whoever they are mad
|
||||
at (help our buddy) unless it is us! */
|
||||
else if (attacker->enemy && (attacker->enemy != targ))
|
||||
else if (attacker->enemy)
|
||||
{
|
||||
if (targ->enemy && targ->enemy->client)
|
||||
{
|
||||
|
@ -655,12 +655,6 @@ T_Damage(edict_t *targ, edict_t *inflictor, edict_t *attacker,
|
|||
/* treat cheat/powerup savings the same as armor */
|
||||
asave += save;
|
||||
|
||||
/* team damage avoidance */
|
||||
if (!(dflags & DAMAGE_NO_PROTECTION) && false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* do the damage */
|
||||
if (take)
|
||||
{
|
||||
|
|
|
@ -568,7 +568,7 @@ plat_blocked(edict_t *self, edict_t *other)
|
|||
vec3_origin, 100000, 1, 0, MOD_CRUSH);
|
||||
|
||||
/* if it's still there, nuke it */
|
||||
if (other)
|
||||
if (other->inuse)
|
||||
{
|
||||
/* Hack for entity without it's origin near the model */
|
||||
VectorMA (other->absmin, 0.5, other->size, other->s.origin);
|
||||
|
@ -659,7 +659,7 @@ plat_spawn_inside_trigger(edict_t *ent)
|
|||
|
||||
tmin[0] = ent->mins[0] + 25;
|
||||
tmin[1] = ent->mins[1] + 25;
|
||||
tmin[2] = ent->mins[2];
|
||||
// tmin[2] = ent->mins[2];
|
||||
|
||||
tmax[0] = ent->maxs[0] - 25;
|
||||
tmax[1] = ent->maxs[1] - 25;
|
||||
|
@ -932,11 +932,6 @@ SP_func_rotating(edict_t *ent)
|
|||
|
||||
ent->use = rotating_use;
|
||||
|
||||
if (ent->dmg)
|
||||
{
|
||||
ent->blocked = rotating_blocked;
|
||||
}
|
||||
|
||||
if (ent->spawnflags & 1)
|
||||
{
|
||||
ent->use(ent, NULL, NULL);
|
||||
|
@ -1602,7 +1597,7 @@ door_blocked(edict_t *self, edict_t *other)
|
|||
vec3_origin, 100000, 1, 0, MOD_CRUSH);
|
||||
|
||||
/* if it's still there, nuke it */
|
||||
if (other)
|
||||
if (other->inuse)
|
||||
{
|
||||
/* Hack for entitiy without their origin near the model */
|
||||
VectorMA (other->absmin, 0.5, other->size, other->s.origin);
|
||||
|
@ -2035,10 +2030,6 @@ SP_func_water(edict_t *self)
|
|||
break;
|
||||
|
||||
case 1: /* water */
|
||||
self->moveinfo.sound_start = gi.soundindex("world/mov_watr.wav");
|
||||
self->moveinfo.sound_end = gi.soundindex("world/stp_watr.wav");
|
||||
break;
|
||||
|
||||
case 2: /* lava */
|
||||
self->moveinfo.sound_start = gi.soundindex("world/mov_watr.wav");
|
||||
self->moveinfo.sound_end = gi.soundindex("world/stp_watr.wav");
|
||||
|
@ -2134,7 +2125,7 @@ train_blocked(edict_t *self, edict_t *other)
|
|||
vec3_origin, 100000, 1, 0, MOD_CRUSH);
|
||||
|
||||
/* if it's still there, nuke it */
|
||||
if (other)
|
||||
if (other->inuse)
|
||||
{
|
||||
/* Hack for entity without an origin near the model */
|
||||
VectorMA (other->absmin, 0.5, other->size, other->s.origin);
|
||||
|
@ -2831,7 +2822,7 @@ door_secret_blocked(edict_t *self, edict_t *other)
|
|||
vec3_origin, 100000, 1, 0, MOD_CRUSH);
|
||||
|
||||
/* if it's still there, nuke it */
|
||||
if (other)
|
||||
if (other->inuse)
|
||||
{
|
||||
/* Hack for entities without their origin near the model */
|
||||
VectorMA (other->absmin, 0.5, other->size, other->s.origin);
|
||||
|
|
|
@ -1301,13 +1301,13 @@ Drop_Item(edict_t *ent, gitem_t *item)
|
|||
dropped->s.effects = item->world_model_flags;
|
||||
dropped->s.renderfx = RF_GLOW;
|
||||
|
||||
if (randk() > 0.5)
|
||||
if (frandk() > 0.5)
|
||||
{
|
||||
dropped->s.angles[1] += randk()*45;
|
||||
dropped->s.angles[1] += frandk()*45;
|
||||
}
|
||||
else
|
||||
{
|
||||
dropped->s.angles[1] -= randk()*45;
|
||||
dropped->s.angles[1] -= frandk()*45;
|
||||
}
|
||||
|
||||
VectorSet (dropped->mins, -16, -16, -16);
|
||||
|
|
|
@ -138,7 +138,7 @@ gib_think(edict_t *self)
|
|||
void
|
||||
gib_touch(edict_t *self, edict_t *other /* unused */, cplane_t *plane, csurface_t *surf /* unused */)
|
||||
{
|
||||
if (!self || !plane)
|
||||
if (!self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -892,13 +892,9 @@ void
|
|||
func_object_touch(edict_t *self, edict_t *other, cplane_t *plane,
|
||||
csurface_t *surf /* unused */)
|
||||
{
|
||||
if (!self || !other || !plane)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* only squash thing we fall on top of */
|
||||
if (!plane)
|
||||
|
||||
if (!self || !other || !plane)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -85,8 +85,8 @@ StringToFilter(char *s, ipfilter_t *f)
|
|||
{
|
||||
char num[128];
|
||||
int i, j;
|
||||
byte b[4];
|
||||
byte m[4];
|
||||
YQ2_ALIGNAS_TYPE(unsigned) byte b[4];
|
||||
YQ2_ALIGNAS_TYPE(unsigned) byte m[4];
|
||||
|
||||
if (!s || !f)
|
||||
{
|
||||
|
@ -141,7 +141,7 @@ SV_FilterPacket(char *from)
|
|||
{
|
||||
int i;
|
||||
unsigned in;
|
||||
byte m[4];
|
||||
YQ2_ALIGNAS_TYPE(unsigned) byte m[4];
|
||||
char *p;
|
||||
|
||||
if (!from)
|
||||
|
@ -259,7 +259,7 @@ void
|
|||
SVCmd_ListIP_f(void)
|
||||
{
|
||||
int i;
|
||||
byte b[4];
|
||||
YQ2_ALIGNAS_TYPE(unsigned) byte b[4];
|
||||
|
||||
gi.cprintf(NULL, PRINT_HIGH, "Filter list:\n");
|
||||
|
||||
|
@ -276,7 +276,7 @@ SVCmd_WriteIP_f(void)
|
|||
{
|
||||
FILE *f;
|
||||
char name[MAX_OSPATH];
|
||||
byte b[4];
|
||||
YQ2_ALIGNAS_TYPE(unsigned) byte b[4];
|
||||
int i;
|
||||
cvar_t *game;
|
||||
|
||||
|
|
|
@ -415,7 +415,7 @@ SP_target_explosion(edict_t *ent)
|
|||
void
|
||||
use_target_changelevel(edict_t *self, edict_t *other, edict_t *activator)
|
||||
{
|
||||
if (!self || !other || !activator)
|
||||
if (!self || !other)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ G_UseTargets(edict_t *ent, edict_t *activator)
|
|||
{
|
||||
edict_t *t;
|
||||
|
||||
if (!ent || !activator)
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -242,6 +242,11 @@ G_UseTargets(edict_t *ent, edict_t *activator)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!activator)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* print the message */
|
||||
if ((ent->message) && !(activator->svflags & SVF_MONSTER))
|
||||
{
|
||||
|
|
|
@ -742,10 +742,6 @@ Boss2_CheckAttack(edict_t *self)
|
|||
{
|
||||
chance = 0.4;
|
||||
}
|
||||
else if (enemy_range == RANGE_MELEE)
|
||||
{
|
||||
chance = 0.8;
|
||||
}
|
||||
else if (enemy_range == RANGE_NEAR)
|
||||
{
|
||||
chance = 0.8;
|
||||
|
|
|
@ -842,10 +842,6 @@ Jorg_CheckAttack(edict_t *self)
|
|||
{
|
||||
chance = 0.4;
|
||||
}
|
||||
else if (enemy_range == RANGE_MELEE)
|
||||
{
|
||||
chance = 0.8;
|
||||
}
|
||||
else if (enemy_range == RANGE_NEAR)
|
||||
{
|
||||
chance = 0.4;
|
||||
|
|
|
@ -1015,10 +1015,6 @@ Makron_CheckAttack(edict_t *self)
|
|||
{
|
||||
chance = 0.4;
|
||||
}
|
||||
else if (enemy_range == RANGE_MELEE)
|
||||
{
|
||||
chance = 0.8;
|
||||
}
|
||||
else if (enemy_range == RANGE_NEAR)
|
||||
{
|
||||
chance = 0.4;
|
||||
|
|
|
@ -193,11 +193,6 @@ GaldiatorMelee(edict_t *self)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VectorSet(aim, MELEE_DISTANCE, self->mins[0], -4);
|
||||
|
||||
if (fire_hit(self, aim, (20 + (randk() % 5)), 300))
|
||||
|
|
|
@ -644,9 +644,7 @@ insane_run(edict_t *self)
|
|||
{
|
||||
self->monsterinfo.currentmove = &insane_move_runcrawl;
|
||||
}
|
||||
else
|
||||
|
||||
if (random() <= 0.5) /* Else, mix it up */
|
||||
else if (frandk() <= 0.5) /* Else, mix it up */
|
||||
{
|
||||
self->monsterinfo.currentmove = &insane_move_run_normal;
|
||||
}
|
||||
|
|
|
@ -383,11 +383,6 @@ M_ChangeYaw(edict_t *ent)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
current = anglemod(ent->s.angles[YAW]);
|
||||
ideal = ent->ideal_yaw;
|
||||
|
||||
|
@ -500,11 +495,6 @@ SV_NewChaseDir(edict_t *actor, edict_t *enemy, float dist)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!enemy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
olddir = anglemod((int)(actor->ideal_yaw / 45) * 45);
|
||||
turnaround = anglemod(olddir - 180);
|
||||
|
||||
|
|
|
@ -801,7 +801,7 @@ LookAtKiller(edict_t *self, edict_t *inflictor, edict_t *attacker)
|
|||
{
|
||||
vec3_t dir;
|
||||
|
||||
if (!self || !inflictor || !attacker)
|
||||
if (!self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue