From 3b20c26275b48070edd937c679d5488a285258b5 Mon Sep 17 00:00:00 2001 From: Dmitri Kourennyi Date: Sun, 14 May 2017 13:42:48 -0400 Subject: [PATCH] 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. --- src/p_things.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/p_things.cpp b/src/p_things.cpp index 94dc1df1d..06a0252ab 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -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.