From 7d7112f42719f2fabc0da7faf1d796d6e6777950 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 7 Mar 2016 00:17:52 +0100 Subject: [PATCH] - added portal support to A_ThrustImpale, P_PushUp and P_PushDown. --- src/actor.h | 6 ------ src/g_hexen/a_spike.cpp | 26 +++++++++++++++++--------- src/p_map.cpp | 29 ++++++++++++++++++----------- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/actor.h b/src/actor.h index b5b32611c..344f5c267 100644 --- a/src/actor.h +++ b/src/actor.h @@ -813,12 +813,6 @@ public: return bloodcls; } - bool intersects(AActor *other) const - { - fixed_t blockdist = radius + other->radius; - return ( abs(X() - other->X()) < blockdist && abs(Y() - other->Y()) < blockdist); - } - fixed_t AproxDistance(fixed_t otherx, fixed_t othery) { return P_AproxDistance(X() - otherx, Y() - othery); diff --git a/src/g_hexen/a_spike.cpp b/src/g_hexen/a_spike.cpp index 0987d48d9..10444ecb9 100644 --- a/src/g_hexen/a_spike.cpp +++ b/src/g_hexen/a_spike.cpp @@ -153,24 +153,32 @@ DEFINE_ACTION_FUNCTION(AActor, A_ThrustImpale) { PARAM_ACTION_PROLOGUE; - AActor *thing; // This doesn't need to iterate through portals. - FBlockThingsIterator it(FBoundingBox(self->X(), self->Y(), self->radius)); - while ((thing = it.Next())) + + FPortalGroupArray check; + FMultiBlockThingsIterator it(check, self); + FMultiBlockThingsIterator::CheckResult cres; + while (it.Next(&cres)) { - if (!thing->intersects(self)) - { + fixed_t blockdist = self->radius + cres.thing->radius; + if (abs(self->X() - cres.position.x) >= blockdist || abs(self->Y() - cres.position.y) >= blockdist) continue; + + // Q: Make this z-aware for everything? It never was before. + if (cres.thing->Top() < self->Z() || cres.thing->Z() > self->Top()) + { + if (self->Sector->PortalGroup != cres.thing->Sector->PortalGroup) + continue; } - if (!(thing->flags & MF_SHOOTABLE) ) + if (!(cres.thing->flags & MF_SHOOTABLE) ) continue; - if (thing == self) + if (cres.thing == self) continue; // don't clip against self - int newdam = P_DamageMobj (thing, self, self, 10001, NAME_Crush); - P_TraceBleed (newdam > 0 ? newdam : 10001, thing); + int newdam = P_DamageMobj (cres.thing, self, self, 10001, NAME_Crush); + P_TraceBleed (newdam > 0 ? newdam : 10001, cres.thing); self->args[1] = 1; // Mark thrust thing as bloody } return 0; diff --git a/src/p_map.cpp b/src/p_map.cpp index 15718ec4c..3470de394 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -5513,14 +5513,16 @@ void P_FindAboveIntersectors(AActor *actor) if (!(actor->flags & MF_SOLID)) return; - AActor *thing; - FBlockThingsIterator it(FBoundingBox(actor->X(), actor->Y(), actor->radius)); - while ((thing = it.Next())) + FPortalGroupArray check; + FMultiBlockThingsIterator it(check, actor); + FMultiBlockThingsIterator::CheckResult cres; + while (it.Next(&cres)) { - if (!thing->intersects(actor)) - { + AActor *thing = cres.thing; + fixed_t blockdist = actor->radius + thing->radius; + if (abs(actor->X() - cres.position.x) >= blockdist || abs(actor->Y() - cres.position.y) >= blockdist) continue; - } + if (!(thing->flags & MF_SOLID)) { // Can't hit thing continue; @@ -5568,13 +5570,16 @@ void P_FindBelowIntersectors(AActor *actor) return; AActor *thing; - FBlockThingsIterator it(FBoundingBox(actor->X(), actor->Y(), actor->radius)); - while ((thing = it.Next())) + FPortalGroupArray check; + FMultiBlockThingsIterator it(check, actor); + FMultiBlockThingsIterator::CheckResult cres; + while (it.Next(&cres)) { - if (!thing->intersects(actor)) - { + AActor *thing = cres.thing; + fixed_t blockdist = actor->radius + thing->radius; + if (abs(actor->X() - cres.position.x) >= blockdist || abs(actor->Y() - cres.position.y) >= blockdist) continue; - } + if (!(thing->flags & MF_SOLID)) { // Can't hit thing continue; @@ -5718,6 +5723,7 @@ int P_PushUp(AActor *thing, FChangePosition *cpos) return 2; } } + thing->CheckPortalTransition(true); return 0; } @@ -5765,6 +5771,7 @@ int P_PushDown(AActor *thing, FChangePosition *cpos) } } } + thing->CheckPortalTransition(true); return 0; }