- 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).


SVN r1538 (trunk)
This commit is contained in:
Randy Heit 2009-04-10 03:54:28 +00:00
parent be9a05e32b
commit bb9b5ebf92
3 changed files with 24 additions and 20 deletions

View file

@ -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 - Added NOBLOCKMAP/MOVEWITHSECTOR combination to a few items that had their
NOBLOCKMAP flag taken away previously to make them move with a sector. NOBLOCKMAP flag taken away previously to make them move with a sector.
This should fix the performance problem Claustrophobia had with recent This should fix the performance problem Claustrophobia had with recent

View file

@ -55,7 +55,7 @@ void A_Fire(AActor *self, int height)
angle_t an; angle_t an;
dest = self->tracer; dest = self->tracer;
if (!dest) if (dest == NULL || self->target == NULL)
return; return;
// don't move it if the vile lost sight // 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) DEFINE_ACTION_FUNCTION(AActor, A_VileAttack)
{ {
AActor *fire; AActor *fire, *target;
int an; int an;
if (!self->target) if (NULL == (target = self->target))
return; return;
A_FaceTarget (self); A_FaceTarget (self);
if (!P_CheckSight (self, self->target, 0) ) if (!P_CheckSight (self, target, 0) )
return; return;
S_Sound (self, CHAN_WEAPON, "vile/stop", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "vile/stop", 1, ATTN_NORM);
P_DamageMobj (self->target, self, self, 20, NAME_None); P_TraceBleed (20, target);
P_TraceBleed (20, self->target); P_DamageMobj (target, self, self, 20, NAME_None);
self->target->momz = 1000 * FRACUNIT / self->target->Mass; target->momz = 1000 * FRACUNIT / target->Mass;
an = self->angle >> ANGLETOFINESHIFT; an = self->angle >> ANGLETOFINESHIFT;
fire = self->tracer; fire = self->tracer;
if (!fire) if (fire != NULL)
return; {
// move the fire between the vile and the player
// move the fire between the vile and the player fire->SetOrigin (target->x - FixedMul (24*FRACUNIT, finecosine[an]),
fire->SetOrigin (self->target->x - FixedMul (24*FRACUNIT, finecosine[an]), target->y - FixedMul (24*FRACUNIT, finesine[an]),
self->target->y - FixedMul (24*FRACUNIT, finesine[an]), target->z);
self->target->z);
P_RadiusAttack (fire, self, 70, 70, NAME_Fire, false);
P_RadiusAttack (fire, self, 70, 70, NAME_Fire, false); }
} }

View file

@ -643,15 +643,12 @@ bool P_CheckSight (const AActor *t1, const AActor *t2, int flags)
bool res; bool res;
#ifdef _DEBUG
assert (t1 != NULL); assert (t1 != NULL);
assert (t2 != NULL); assert (t2 != NULL);
#else
if (t1 == NULL || t2 == NULL) if (t1 == NULL || t2 == NULL)
{ {
return false; return false;
} }
#endif
const sector_t *s1 = t1->Sector; const sector_t *s1 = t1->Sector;
const sector_t *s2 = t2->Sector; const sector_t *s2 = t2->Sector;