- 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
NOBLOCKMAP flag taken away previously to make them move with a sector.
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;
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;
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);
// 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);
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;
#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;