From b01e0fa06e265bc6d321d422d0fd62fccd91f1d7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 24 Feb 2016 10:08:23 +0100 Subject: [PATCH] - removed debug output from portal transition code. - handle the case where a portal transition crosses more than a single boundary in one move. --- src/actor.h | 2 +- src/p_mobj.cpp | 45 +++++++++++++++++++++++++-------------------- src/r_utility.cpp | 22 +++++++++++++++------- 3 files changed, 41 insertions(+), 28 deletions(-) diff --git a/src/actor.h b/src/actor.h index 47f6ef44b0..15c2ea2abd 100644 --- a/src/actor.h +++ b/src/actor.h @@ -742,7 +742,7 @@ public: bool IsHostile (AActor *other); inline bool IsNoClip2() const; - void CheckPortalTransition(); + void CheckPortalTransition(bool islinked); // What species am I? virtual FName GetSpecies(); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 73683824b9..dafbaffbaa 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3289,40 +3289,45 @@ void AActor::SetRoll(angle_t r, bool interpolate) } -void AActor::CheckPortalTransition() +void AActor::CheckPortalTransition(bool islinked) { - if (!Sector->PortalBlocksMovement(sector_t::ceiling)) + bool moved = false; + while (!Sector->PortalBlocksMovement(sector_t::ceiling)) { AActor *port = Sector->SkyBoxes[sector_t::ceiling]; if (Z() > port->threshold) { fixedvec3 oldpos = Pos(); - UnlinkFromWorld(); + if (islinked && !moved) UnlinkFromWorld(); SetXYZ(PosRelative(port->Sector)); PrevX += X() - oldpos.x; PrevY += Y() - oldpos.y; PrevZ += Z() - oldpos.z; - LinkToWorld(); - if (player) Printf("Transitioned upwards to sector %d\n", Sector->sectornum); - return; + Sector = P_PointInSector(X(), Y()); + moved = true; } + else break; } - if (!Sector->PortalBlocksMovement(sector_t::floor)) + if (!moved) { - AActor *port = Sector->SkyBoxes[sector_t::floor]; - if (Z() < port->threshold && floorz < port->threshold) + while (!Sector->PortalBlocksMovement(sector_t::floor)) { - fixedvec3 oldpos = Pos(); - UnlinkFromWorld(); - SetXYZ(PosRelative(port->Sector)); - PrevX += X() - oldpos.x; - PrevY += Y() - oldpos.y; - PrevZ += Z() - oldpos.z; - LinkToWorld(); - if (player) Printf("Transitioned downwards to sector %d\n", Sector->sectornum); - return; + AActor *port = Sector->SkyBoxes[sector_t::floor]; + if (Z() < port->threshold && floorz < port->threshold) + { + fixedvec3 oldpos = Pos(); + if (islinked && !moved) UnlinkFromWorld(); + SetXYZ(PosRelative(port->Sector)); + PrevX += X() - oldpos.x; + PrevY += Y() - oldpos.y; + PrevZ += Z() - oldpos.z; + Sector = P_PointInSector(X(), Y()); + moved = true; + } + else break; } } + if (islinked && moved) LinkToWorld(); } // @@ -3392,7 +3397,7 @@ void AActor::Tick () UnlinkFromWorld (); flags |= MF_NOBLOCKMAP; SetXYZ(Vec3Offset(velx, vely, velz)); - CheckPortalTransition(); + CheckPortalTransition(false); SetMovement(velx, vely, velz); LinkToWorld (); } @@ -3860,7 +3865,7 @@ void AActor::Tick () Crash(); } - CheckPortalTransition(); + CheckPortalTransition(true); UpdateWaterLevel (oldz); diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 60a415d807..a97ebc65ec 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -640,7 +640,8 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi // Due to interpolation this is not necessarily the same as the sector the camera is in. viewsector = R_PointInSubsector(viewx, viewy)->sector; - if (!viewsector->PortalBlocksMovement(sector_t::ceiling)) + bool moved = false; + while (!viewsector->PortalBlocksMovement(sector_t::ceiling)) { AActor *point = viewsector->SkyBoxes[sector_t::ceiling]; if (viewz > point->threshold) @@ -648,16 +649,23 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi viewx += point->scaleX; viewy += point->scaleY; viewsector = R_PointInSubsector(viewx, viewy)->sector; + moved = true; } + else break; } - if (!viewsector->PortalBlocksMovement(sector_t::floor)) + if (!moved) { - AActor *point = viewsector->SkyBoxes[sector_t::floor]; - if (viewz < point->threshold) + while (!viewsector->PortalBlocksMovement(sector_t::floor)) { - viewx += point->scaleX; - viewy += point->scaleY; - viewsector = R_PointInSubsector(viewx, viewy)->sector; + AActor *point = viewsector->SkyBoxes[sector_t::floor]; + if (viewz < point->threshold) + { + viewx += point->scaleX; + viewy += point->scaleY; + viewsector = R_PointInSubsector(viewx, viewy)->sector; + moved = true; + } + else break; } } }