From 7eba7aacbda136a98f6ca1a5c7e54c0017c342a6 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 23 Nov 2022 18:25:58 +1100 Subject: [PATCH] - SW: Remove last `PLAYER::posSet()` calls. --- source/games/sw/src/game.h | 4 ---- source/games/sw/src/misc.h | 2 +- source/games/sw/src/player.cpp | 18 +++--------------- source/games/sw/src/warp.cpp | 4 +++- 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 2de2e1e04..6fcfd5a6f 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1891,10 +1891,6 @@ struct PLAYER } - void posSet(const DVector3& val) - { - actor->spr.pos = val.plusZ(-actor->viewzoffset); - } void posAdd(const DVector2& val) { actor->spr.pos += val; diff --git a/source/games/sw/src/misc.h b/source/games/sw/src/misc.h index 5cc47d2a9..fd6695404 100644 --- a/source/games/sw/src/misc.h +++ b/source/games/sw/src/misc.h @@ -20,7 +20,7 @@ int32_t CONFIG_ReadSetup(void); bool WarpSectorInfo(sectortype* sect, DSWActor** sp_warp); DSWActor* Warp(DVector3& pos, sectortype** sect); -DSWActor* WarpPlane(DVector3& pos, sectortype** sect); +DSWActor* WarpPlane(DVector3& pos, sectortype** sect, double testz = DBL_MAX); diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 8a3d70be3..e57a5e1cc 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1402,11 +1402,7 @@ void DoPlayerWarpTeleporter(PLAYER* pp) TAG 5 to 8 = random match locations #endif - auto pos = pp->posGet(); - act_warp = Warp(pos, &pp->cursector); - pp->posSet(pos); - - if (act_warp == nullptr) + if ((act_warp = Warp(ppActor->spr.pos, &pp->cursector)) == nullptr) { return; } @@ -2197,11 +2193,7 @@ void DoPlayerMove(PLAYER* pp) } // check for warp - probably can remove from CeilingHit - auto pos = pp->posGet(); - auto res = WarpPlane(pos, &pp->cursector); - pp->posSet(pos); - - if (res) + if (WarpPlane(actor->spr.pos, &pp->cursector, actor->getOffsetZ())) { PlayerWarpUpdatePos(pp); } @@ -3405,11 +3397,7 @@ void DoPlayerClimb(PLAYER* pp) LadderUpdate = true; } - auto pos = pp->posGet(); - auto res = WarpPlane(pos, &pp->cursector); - pp->posSet(pos); - - if (res) + if (WarpPlane(pp->actor->spr.pos, &pp->cursector, pp->actor->getOffsetZ())) { PlayerWarpUpdatePos(pp); LadderUpdate = true; diff --git a/source/games/sw/src/warp.cpp b/source/games/sw/src/warp.cpp index e47967c8a..8816bc1e3 100644 --- a/source/games/sw/src/warp.cpp +++ b/source/games/sw/src/warp.cpp @@ -81,10 +81,12 @@ bool WarpPlaneSectorInfo(sectortype* sect, DSWActor** sp_ceiling, DSWActor** sp_ // //--------------------------------------------------------------------------- -DSWActor* WarpPlane(DVector3& pos, sectortype** sect) +DSWActor* WarpPlane(DVector3& pos, sectortype** sect, double testz) { DSWActor* sp_floor,* sp_ceiling; + if (testz == DBL_MAX) testz = pos.Z; + if (Prediction) return nullptr;