Merge pull request #11 from NeonKnightOA/cppcheckfixes

Fixed many issues pointed out by cppcheck.
This commit is contained in:
Yamagi 2020-04-21 12:48:32 +02:00 committed by GitHub
commit a047746337
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 52 additions and 89 deletions

View file

@ -573,15 +573,9 @@ void plat_blocked (edict_t *self, edict_t *other)
// give it a chance to go away on it's own terms (like gibs)
T_Damage (other, self, self, vec3_origin, other->s.origin, vec3_origin, 100000, 1, 0, MOD_CRUSH);
// if it's still there, nuke it
if (other)
{
/* Hack for entity without it's origin near the model */
vec3_t save;
VectorCopy(other->s.origin,save);
VectorMA (other->absmin, 0.5, other->size, other->s.origin);
BecomeExplosion1(other);
}
/* Hack for entity without it's origin near the model */
VectorMA (other->absmin, 0.5, other->size, other->s.origin);
BecomeExplosion1(other);
return;
}
@ -1497,15 +1491,9 @@ void door_blocked (edict_t *self, edict_t *other)
// give it a chance to go away on it's own terms (like gibs)
T_Damage (other, self, self, vec3_origin, other->s.origin, vec3_origin, 100000, 1, 0, MOD_CRUSH);
// if it's still there, nuke it
if (other)
{
/* Hack for entitiy without their origin near the model */
vec3_t save;
VectorCopy(other->s.origin,save);
VectorMA (other->absmin, 0.5, other->size, other->s.origin);
BecomeExplosion1(other);
}
/* Hack for entitiy without their origin near the model */
VectorMA (other->absmin, 0.5, other->size, other->s.origin);
BecomeExplosion1(other);
return;
}
@ -1928,15 +1916,9 @@ void train_blocked (edict_t *self, edict_t *other)
// give it a chance to go away on it's own terms (like gibs)
T_Damage (other, self, self, vec3_origin, other->s.origin, vec3_origin, 100000, 1, 0, MOD_CRUSH);
// if it's still there, nuke it
if (other)
{
/* Hack for entity without an origin near the model */
vec3_t save;
VectorCopy(other->s.origin,save);
VectorMA (other->absmin, 0.5, other->size, other->s.origin);
BecomeExplosion1(other);
}
/* Hack for entity without an origin near the model */
VectorMA (other->absmin, 0.5, other->size, other->s.origin);
BecomeExplosion1(other);
return;
}
@ -2620,15 +2602,9 @@ void door_secret_blocked (edict_t *self, edict_t *other)
// give it a chance to go away on it's own terms (like gibs)
T_Damage (other, self, self, vec3_origin, other->s.origin, vec3_origin, 100000, 1, 0, MOD_CRUSH);
// if it's still there, nuke it
if (other)
{
/* Hack for entities without their origin near the model */
vec3_t save;
VectorCopy(other->s.origin,save);
VectorMA (other->absmin, 0.5, other->size, other->s.origin);
BecomeExplosion1(other);
}
/* Hack for entities without their origin near the model */
VectorMA (other->absmin, 0.5, other->size, other->s.origin);
BecomeExplosion1(other);
return;
}

View file

@ -153,11 +153,6 @@ void ThrowGib (edict_t *self, char *gibname, int damage, int type)
vec3_t size;
float vscale;
if (!self)
{
return;
}
if (!self || !gibname)
{
return;
@ -334,11 +329,6 @@ void ThrowDebris (edict_t *self, char *modelname, float speed, vec3_t origin)
edict_t *chunk;
vec3_t v;
if (!self)
{
return;
}
if (!self || !modelname)
{
return;

View file

@ -1102,7 +1102,7 @@ void SV_Physics_Step (edict_t *ent)
void SV_Physics_FallFloat (edict_t *ent)
{
float gravVal = ent->gravity * sv_gravity->value * FRAMETIME;
float gravVal;
qboolean wasonground = false;
qboolean hitsound = false;
@ -1111,6 +1111,8 @@ void SV_Physics_FallFloat (edict_t *ent)
return;
}
gravVal = ent->gravity * sv_gravity->value * FRAMETIME;
// check velocity
SV_CheckVelocity (ent);

View file

@ -311,11 +311,6 @@ void ED_CallSpawn (edict_t *ent)
return;
}
if (!ent)
{
return;
}
if (!ent->classname)
{
gi.dprintf ("ED_CallSpawn: NULL classname\n");
@ -369,7 +364,7 @@ char *ED_NewString (const char *string)
for (i=0 ; i< l ; i++)
{
if (string[i] == '\\' && i < l-1)
if ((i < l-1) && (string[i] == '\\'))
{
i++;
if (string[i] == 'n')

View file

@ -27,16 +27,16 @@ edict_t *G_Find (edict_t *from, int fieldofs, char *match)
{
char *s;
if (!from)
{
return NULL;
}
if (!from)
from = g_edicts;
else
from++;
if (!match)
{
return NULL;
}
for ( ; from < &g_edicts[globals.num_edicts] ; from++)
{
if (!from->inuse)
@ -66,15 +66,11 @@ edict_t *findradius (edict_t *from, vec3_t org, float rad)
vec3_t eorg;
int j;
if (!from)
{
return NULL;
}
if (!from)
from = g_edicts;
else
from++;
for ( ; from < &g_edicts[globals.num_edicts]; from++)
{
if (!from->inuse)

View file

@ -140,7 +140,7 @@ void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
void AngleVectors2(vec3_t value1, vec3_t angles);
int BoxOnPlaneSide(vec3_t emins, vec3_t emaxs, struct cplane_s *plane);
float anglemod(float a);
float LerpAngle(float a1, float a2, float frac);
float LerpAngle(float a2, float a1, float frac);
#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \
(((p)->type < 3) ? \

View file

@ -415,13 +415,15 @@ mmove_t zboss_move_pain3 = {FRAME_pain3Start, FRAME_pain3End, zboss_frames_pain3
void zboss_pain (edict_t *self, edict_t *other, float kick, int damage)
{
float r;
float hbreak = (self->max_health / 3.0);
float hbreak;
if (!self)
{
return;
}
hbreak = (self->max_health / 3.0);
// set the skin
if (self->health < hbreak)
{
@ -742,8 +744,8 @@ void zboss_reelInGraaple2(edict_t *self)
{
vec3_t vec, dir;
float length;
edict_t *enemy = self->laser->enemy;
vec3_t hookoffset = {-5, -24, 34};
edict_t *enemy;
vec3_t hookoffset;
vec3_t forward, right;
if (!self)
@ -751,6 +753,9 @@ void zboss_reelInGraaple2(edict_t *self)
return;
}
enemy = self->laser->enemy;
hookoffset = {-5, -24, 34};
AngleVectors (self->s.angles, forward, right, NULL);
G_ProjectSource(self->s.origin, hookoffset, forward, right, vec);
VectorSubtract (vec, self->laser->s.origin, dir);
@ -1026,14 +1031,14 @@ mmove_t zboss_move_prehook = {FRAME_preHookStart, FRAME_preHookEnd, zboss_frames
void PlasmaballBlastAnim(edict_t *ent)
{
ent->s.frame++;
ent->s.skinnum++;
if (!ent)
{
return;
}
ent->s.frame++;
ent->s.skinnum++;
if(ent->s.frame > 1)
{
G_FreeEdict(ent);

View file

@ -439,10 +439,6 @@ void SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist)
return;
}
//FIXME: how did we get here with no enemy
if (!enemy)
return;
olddir = anglemod( (int)(actor->ideal_yaw/45)*45 );
turnaround = anglemod(olddir - 180);

View file

@ -531,11 +531,11 @@ void LookAtKiller (edict_t *self, edict_t *inflictor, edict_t *attacker)
return;
}
if (attacker && attacker != world && attacker != self)
if (attacker != world && attacker != self)
{
VectorSubtract (attacker->s.origin, self->s.origin, dir);
}
else if (inflictor && inflictor != world && inflictor != self)
else if (inflictor != world && inflictor != self)
{
VectorSubtract (inflictor->s.origin, self->s.origin, dir);
}

View file

@ -887,14 +887,14 @@ G_SetClientEvent
*/
void G_SetClientEvent (edict_t *ent)
{
if (ent->s.event)
return;
if (!ent)
{
return;
}
if (ent->s.event)
return;
if ( ent->groundentity && xyspeed > 225)
{
if ( (int)(current_client->bobtime+bobmove) != bobcycle )

View file

@ -304,7 +304,7 @@ extern void AddPointToBounds ( vec3_t v , vec3_t mins , vec3_t maxs ) ;
extern void ClearBounds ( vec3_t mins , vec3_t maxs ) ;
extern int BoxOnPlaneSide2 ( vec3_t emins , vec3_t emaxs , struct cplane_s * p ) ;
extern float anglemod ( float a ) ;
extern float LerpAngle ( float a2 , float a1 , float frac ) ;
extern float LerpAngle(float a2, float a1, float frac);
extern float Q_fabs ( float f ) ;
extern void R_ConcatTransforms ( float in1 [ 3 ] [ 4 ] , float in2 [ 3 ] [ 4 ] , float out [ 3 ] [ 4 ] ) ;
extern void R_ConcatRotations ( float in1 [ 3 ] [ 3 ] , float in2 [ 3 ] [ 3 ] , float out [ 3 ] [ 3 ] ) ;

View file

@ -1157,7 +1157,7 @@ Info_ValueForKey(char *s, char *key)
o = value[valueindex];
while (*s != '\\' && *s)
while (*s != '\\')
{
if (!*s)
{
@ -1222,7 +1222,7 @@ Info_RemoveKey(char *s, char *key)
o = value;
while (*s != '\\' && *s)
while (*s != '\\')
{
if (!*s)
{
@ -1274,6 +1274,11 @@ Info_SetValueForKey(char *s, char *key, char *value)
int c;
int maxsize = MAX_INFO_STRING;
if (!value || !strlen(value))
{
return;
}
if (strstr(key, "\\") || strstr(value, "\\"))
{
Com_Printf("Can't use keys or values with a \\\n");
@ -1300,11 +1305,6 @@ Info_SetValueForKey(char *s, char *key, char *value)
Info_RemoveKey(s, key);
if (!value || !strlen(value))
{
return;
}
Com_sprintf(newi, sizeof(newi), "\\%s\\%s", key, value);
if (strlen(newi) + strlen(s) > maxsize)

View file

@ -426,13 +426,14 @@ void monster_autocannon_findenemy(edict_t *self)
void monster_autocannon_turn(edict_t *self)
{
vec3_t old_angles;
VectorCopy(self->s.angles, old_angles);
if (!self)
{
return;
}
VectorCopy(self->s.angles, old_angles);
if (!self->enemy)
{
if (self->monsterinfo.linkcount > 0)

View file

@ -102,13 +102,15 @@ int zFindRoamYaw(edict_t *self, float distcheck)
{
vec3_t forward, end, angles;
trace_t tr;
float current = anglemod(self->s.angles[YAW]);
float current;
if (!self)
{
return 0;
}
current = anglemod(self->s.angles[YAW]);
if(current <= self->ideal_yaw - 1 || current > self->ideal_yaw + 1)
{
if(fabs(current - self->ideal_yaw) <= 359.0)