From dad8e4719c4035dd26f0f1aefe0f41b7a6db3c7d Mon Sep 17 00:00:00 2001 From: Boondorl Date: Tue, 14 Jan 2025 07:32:25 -0500 Subject: [PATCH] Don't create thing iterator if THRUACTORS is set when moving --- src/playsim/p_map.cpp | 81 ++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/src/playsim/p_map.cpp b/src/playsim/p_map.cpp index c4b4c96ebc8..b3e052c81f4 100644 --- a/src/playsim/p_map.cpp +++ b/src/playsim/p_map.cpp @@ -1880,52 +1880,55 @@ bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, boo FBoundingBox box(pos.X, pos.Y, thing->radius); FPortalGroupArray pcheck; - FMultiBlockThingsIterator it2(pcheck, thing->Level, pos.X, pos.Y, thing->Z(), thing->Height, thing->radius, false, newsec); - FMultiBlockThingsIterator::CheckResult tcres; if (!(thing->flags2 & MF2_THRUACTORS)) - while ((it2.Next(&tcres))) - { - if (!PIT_CheckThing(it2, tcres, it2.Box(), tm)) - { // [RH] If a thing can be stepped up on, we need to continue checking - // other things in the blocks and see if we hit something that is - // definitely blocking. Otherwise, we need to check the lines, or we - // could end up stuck inside a wall. - AActor *BlockingMobj = thing->BlockingMobj; - - // If this blocks through a restricted line portal, it will always completely block. - if (BlockingMobj == NULL || (thing->Level->i_compatflags & COMPATF_NO_PASSMOBJ) || (tcres.portalflags & FFCF_RESTRICTEDPORTAL)) - { // Thing slammed into something; don't let it move now. - thing->Height = realHeight; - return false; - } - else if (!BlockingMobj->player && !(thing->flags & (MF_FLOAT | MF_MISSILE | MF_SKULLFLY)) && - BlockingMobj->Top() - thing->Z() <= thing->MaxStepHeight) - { - if (thingblocker == NULL || - BlockingMobj->Z() > thingblocker->Z()) + { + FMultiBlockThingsIterator it2(pcheck, thing->Level, pos.X, pos.Y, thing->Z(), thing->Height, thing->radius, false, newsec); + FMultiBlockThingsIterator::CheckResult tcres; + + while ((it2.Next(&tcres))) + { + if (!PIT_CheckThing(it2, tcres, it2.Box(), tm)) + { // [RH] If a thing can be stepped up on, we need to continue checking + // other things in the blocks and see if we hit something that is + // definitely blocking. Otherwise, we need to check the lines, or we + // could end up stuck inside a wall. + AActor* BlockingMobj = thing->BlockingMobj; + + // If this blocks through a restricted line portal, it will always completely block. + if (BlockingMobj == NULL || (thing->Level->i_compatflags & COMPATF_NO_PASSMOBJ) || (tcres.portalflags & FFCF_RESTRICTEDPORTAL)) + { // Thing slammed into something; don't let it move now. + thing->Height = realHeight; + return false; + } + else if (!BlockingMobj->player && !(thing->flags & (MF_FLOAT | MF_MISSILE | MF_SKULLFLY)) && + BlockingMobj->Top() - thing->Z() <= thing->MaxStepHeight) { - thingblocker = BlockingMobj; + if (thingblocker == NULL || + BlockingMobj->Z() > thingblocker->Z()) + { + thingblocker = BlockingMobj; + } + thing->BlockingMobj = NULL; } - thing->BlockingMobj = NULL; - } - else if (thing->player && - thing->Top() - BlockingMobj->Z() <= thing->MaxStepHeight) - { - if (thingblocker) - { // There is something to step up on. Return this thing as - // the blocker so that we don't step up. + else if (thing->player && + thing->Top() - BlockingMobj->Z() <= thing->MaxStepHeight) + { + if (thingblocker) + { // There is something to step up on. Return this thing as + // the blocker so that we don't step up. + thing->Height = realHeight; + return false; + } + // Nothing is blocking us, but this actor potentially could + // if there is something else to step on. + thing->BlockingMobj = NULL; + } + else + { // Definitely blocking thing->Height = realHeight; return false; } - // Nothing is blocking us, but this actor potentially could - // if there is something else to step on. - thing->BlockingMobj = NULL; - } - else - { // Definitely blocking - thing->Height = realHeight; - return false; } } }