diff --git a/src/g_func.c b/src/g_func.c index a48f8d2..6b3852e 100644 --- a/src/g_func.c +++ b/src/g_func.c @@ -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; } diff --git a/src/g_misc.c b/src/g_misc.c index bc37e87..a62d1b6 100644 --- a/src/g_misc.c +++ b/src/g_misc.c @@ -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; diff --git a/src/g_phys.c b/src/g_phys.c index ebb9ca6..0c5cf9b 100644 --- a/src/g_phys.c +++ b/src/g_phys.c @@ -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); diff --git a/src/g_spawn.c b/src/g_spawn.c index 7264d7d..6764d40 100644 --- a/src/g_spawn.c +++ b/src/g_spawn.c @@ -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') diff --git a/src/g_utils.c b/src/g_utils.c index b40a5ff..7dcddca 100644 --- a/src/g_utils.c +++ b/src/g_utils.c @@ -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) diff --git a/src/header/shared.h b/src/header/shared.h index 80b7419..b714387 100644 --- a/src/header/shared.h +++ b/src/header/shared.h @@ -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) ? \ diff --git a/src/monster/boss/boss.c b/src/monster/boss/boss.c index 67da4de..f804a57 100644 --- a/src/monster/boss/boss.c +++ b/src/monster/boss/boss.c @@ -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); diff --git a/src/monster/misc/move.c b/src/monster/misc/move.c index 20a3a39..35f9a1c 100644 --- a/src/monster/misc/move.c +++ b/src/monster/misc/move.c @@ -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); diff --git a/src/player/client.c b/src/player/client.c index ef9fbde..b2830de 100644 --- a/src/player/client.c +++ b/src/player/client.c @@ -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); } diff --git a/src/player/view.c b/src/player/view.c index cc57f23..de87ed0 100644 --- a/src/player/view.c +++ b/src/player/view.c @@ -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 ) diff --git a/src/savegame/tables/gamefunc_decs.h b/src/savegame/tables/gamefunc_decs.h index 9cc08b0..fa4b88a 100644 --- a/src/savegame/tables/gamefunc_decs.h +++ b/src/savegame/tables/gamefunc_decs.h @@ -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 ] ) ; diff --git a/src/shared/shared.c b/src/shared/shared.c index 9a6dadb..6a77cbc 100644 --- a/src/shared/shared.c +++ b/src/shared/shared.c @@ -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) diff --git a/src/zaero/acannon.c b/src/zaero/acannon.c index e68c72a..ac115b5 100644 --- a/src/zaero/acannon.c +++ b/src/zaero/acannon.c @@ -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) diff --git a/src/zaero/ai.c b/src/zaero/ai.c index c235d58..ae0a95b 100644 --- a/src/zaero/ai.c +++ b/src/zaero/ai.c @@ -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)