Fix A_CheckProximity setting pointer to dead things when it shouldn't.

When using A_CheckProximity with CPXF_SETTARGET, the target pointer could
be set to a dead monster even without the CPXF_COUNTDEAD and CPXF_DEADONLY
flags. This is becuase the check for death would occur after setting the
pointer.

Fix simply moves death check to occur before setting pointers.
This commit is contained in:
Dmitri Kourennyi 2017-05-14 13:42:48 -04:00 committed by Christoph Oelckers
parent bbea0ee4a1
commit 3b20c26275

View file

@ -756,6 +756,16 @@ int P_Thing_CheckProximity(AActor *self, PClass *classname, double distance, int
if ((flags & CPXF_CHECKSIGHT) && !(P_CheckSight(mo, ref, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY)))
continue;
if (mo->flags6 & MF6_KILLED)
{
if (!(flags & (CPXF_COUNTDEAD | CPXF_DEADONLY)))
continue;
}
else
{
if (flags & CPXF_DEADONLY)
continue;
}
if (ptrWillChange)
{
current = ref->Distance2D(mo);
@ -773,16 +783,6 @@ int P_Thing_CheckProximity(AActor *self, PClass *classname, double distance, int
else if (!dist)
dist = mo; // Just get the first one and call it quits if there's nothing selected.
}
if (mo->flags6 & MF6_KILLED)
{
if (!(flags & (CPXF_COUNTDEAD | CPXF_DEADONLY)))
continue;
}
else
{
if (flags & CPXF_DEADONLY)
continue;
}
counter++;
// Abort if the number of matching classes nearby is greater, we have obviously succeeded in our goal.