From ad7a626b926f2e3af73a45d469e311b9d65b9a90 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 16 Nov 2022 14:02:48 +1100 Subject: [PATCH] - SW: Wrap calls that set `PLAYER::PlayerPrevPosition`. --- source/games/sw/src/game.h | 5 +++++ source/games/sw/src/osdcmds.cpp | 2 +- source/games/sw/src/player.cpp | 14 +++++++------- source/games/sw/src/save.cpp | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index bf3a3c2d2..5492902c6 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -755,6 +755,11 @@ struct PLAYER { PlayerPrevPosition.Z = val; } + + void posprevSet(const DVector3& val) + { + PlayerPrevPosition = val; + } }; extern PLAYER Player[MAX_SW_PLAYERS_REG+1]; diff --git a/source/games/sw/src/osdcmds.cpp b/source/games/sw/src/osdcmds.cpp index 87e449bf6..ab98243f9 100644 --- a/source/games/sw/src/osdcmds.cpp +++ b/source/games/sw/src/osdcmds.cpp @@ -58,7 +58,7 @@ void GameInterface::WarpToCoords(double x, double y, double z, DAngle ang) { Player->posSet(DVector3(x,y,z)); - Player->PlayerPrevPosition = Player->posGet(); + Player->posprevSet(Player->posGet()); if (ang != DAngle::fromDeg(INT_MIN)) { diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 098ec7af4..da1722b75 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1313,7 +1313,7 @@ void DoPlayerTeleportToSprite(PLAYER* pp, DVector3& pos, DAngle ang) { pp->angle.ang = pp->angle.oang = ang; pp->posSet(pos.plusZ(-PLAYER_HEIGHTF)); - pp->PlayerPrevPosition = pos.plusZ(-PLAYER_HEIGHTF); + pp->posprevSet(pos.plusZ(-PLAYER_HEIGHTF)); pp->PlayerOldPosition.XY() = pp->posXY(); updatesector(pp->posGet(), &pp->cursector); @@ -3765,7 +3765,7 @@ void PlayerWarpUpdatePos(PLAYER* pp) if (Prediction) return; - pp->PlayerPrevPosition = pp->posGet(); + pp->posprevSet(pp->posGet()); DoPlayerZrange(pp); UpdatePlayerSprite(pp); } @@ -4295,7 +4295,7 @@ void DoPlayerWarpToUnderwater(PLAYER* pp) pp->posZset(under_act->sector()->ceilingz + 6); - pp->PlayerPrevPosition = pp->posGet(); + pp->posprevSet(pp->posGet()); DoPlayerZrange(pp); return; @@ -4371,7 +4371,7 @@ void DoPlayerWarpToSurface(PLAYER* pp) pp->posZadd(-pp->WadeDepth); - pp->PlayerPrevPosition = pp->posGet(); + pp->posprevSet(pp->posGet()); return; } @@ -6830,7 +6830,7 @@ void MoveSkipSavePos(void) { pp = Player + pnum; - pp->PlayerPrevPosition = pp->posGet(); + pp->posprevSet(pp->posGet()); pp->obob_z = pp->bob_z; pp->angle.backup(); pp->horizon.backup(); @@ -7187,7 +7187,7 @@ void InitAllPlayers(void) for (pp = Player; pp < &Player[MAX_SW_PLAYERS]; pp++) { pp->posSet(pfirst->posGet()); - pp->PlayerPrevPosition = pfirst->posGet(); + pp->posprevSet(pfirst->posGet()); pp->angle.ang = pp->angle.oang = pfirst->angle.ang; pp->horizon.horiz = pp->horizon.ohoriz = pfirst->horizon.horiz; pp->cursector = pfirst->cursector; @@ -7348,7 +7348,7 @@ void PlayerSpawnPosition(PLAYER* pp) ASSERT(spawn_sprite != nullptr); pp->posSet(spawn_sprite->spr.pos); - pp->PlayerPrevPosition = pp->posGet(); + pp->posprevSet(pp->posGet()); pp->angle.ang = pp->angle.oang = spawn_sprite->spr.angle; pp->setcursector(spawn_sprite->sector()); diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index c7bdb9281..65fc7784b 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -574,7 +574,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYER& w, PLAYER* } if (arc.isReading()) { - w.PlayerPrevPosition = w.posGet(); + w.posprevSet(w.posGet()); w.ovect = w.vect; w.obob_z = w.bob_z; w.input = {};