diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 3c3eb4b48..63e26bc1b 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,11 @@ -April 9, 2009 (Changes by Graf Zahl) +April 9, 2009 +- Added a NULL pointer check to A_Fire() and copied the target to a local + variable inside A_VileAttack() so that if P_DamageMobj() destroys the + target, the function will still have a valid pointer to it (since reading + it from the actor's instance data invokes the read barrier, which would + return NULL). + +April 9, 2009 (Changes by Graf Zahl) - Added NOBLOCKMAP/MOVEWITHSECTOR combination to a few items that had their NOBLOCKMAP flag taken away previously to make them move with a sector. This should fix the performance problem Claustrophobia had with recent diff --git a/src/g_doom/a_archvile.cpp b/src/g_doom/a_archvile.cpp index 64eb22f12..4286995d7 100644 --- a/src/g_doom/a_archvile.cpp +++ b/src/g_doom/a_archvile.cpp @@ -55,7 +55,7 @@ void A_Fire(AActor *self, int height) angle_t an; dest = self->tracer; - if (!dest) + if (dest == NULL || self->target == NULL) return; // don't move it if the vile lost sight @@ -103,33 +103,33 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileTarget) // DEFINE_ACTION_FUNCTION(AActor, A_VileAttack) { - AActor *fire; + AActor *fire, *target; int an; - if (!self->target) + if (NULL == (target = self->target)) return; A_FaceTarget (self); - if (!P_CheckSight (self, self->target, 0) ) + if (!P_CheckSight (self, target, 0) ) return; S_Sound (self, CHAN_WEAPON, "vile/stop", 1, ATTN_NORM); - P_DamageMobj (self->target, self, self, 20, NAME_None); - P_TraceBleed (20, self->target); - self->target->momz = 1000 * FRACUNIT / self->target->Mass; + P_TraceBleed (20, target); + P_DamageMobj (target, self, self, 20, NAME_None); + target->momz = 1000 * FRACUNIT / target->Mass; an = self->angle >> ANGLETOFINESHIFT; fire = self->tracer; - if (!fire) - return; - - // move the fire between the vile and the player - fire->SetOrigin (self->target->x - FixedMul (24*FRACUNIT, finecosine[an]), - self->target->y - FixedMul (24*FRACUNIT, finesine[an]), - self->target->z); - - P_RadiusAttack (fire, self, 70, 70, NAME_Fire, false); + if (fire != NULL) + { + // move the fire between the vile and the player + fire->SetOrigin (target->x - FixedMul (24*FRACUNIT, finecosine[an]), + target->y - FixedMul (24*FRACUNIT, finesine[an]), + target->z); + + P_RadiusAttack (fire, self, 70, 70, NAME_Fire, false); + } } diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 2e0282213..345e35b2f 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -643,15 +643,12 @@ bool P_CheckSight (const AActor *t1, const AActor *t2, int flags) bool res; -#ifdef _DEBUG assert (t1 != NULL); assert (t2 != NULL); -#else if (t1 == NULL || t2 == NULL) { return false; } -#endif const sector_t *s1 = t1->Sector; const sector_t *s2 = t2->Sector;