From 4027f7256d23268df63cff0b3bc2d4a660784cde Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 15 Nov 2022 18:35:06 +1100 Subject: [PATCH] - Duke: Wrap calls to `player_struct::PlayerOldPosition.Y`. --- source/games/duke/src/actors.cpp | 4 ++-- source/games/duke/src/actors_r.cpp | 2 +- source/games/duke/src/gameexec.cpp | 4 ++-- source/games/duke/src/player.cpp | 4 ++-- source/games/duke/src/types.h | 4 ++++ 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index f05099e62..1adb62fe5 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -375,7 +375,7 @@ void movedummyplayers(void) } act->spr.pos.X += (ps[p].posX() - ps[p].posoldX()); - act->spr.pos.Y += (ps[p].posY() - ps[p].PlayerOldPosition.Y); + act->spr.pos.Y += (ps[p].posY() - ps[p].posoldY()); SetActor(act, act->spr.pos); } } @@ -4420,7 +4420,7 @@ void movefta(void) { auto xyrand = []() -> double { return (64 - (krand() & 127)) * maptoworld; }; double px = ps[p].posoldX() - xyrand(); - double py = ps[p].PlayerOldPosition.Y - xyrand(); + double py = ps[p].posoldY() - xyrand(); updatesector(DVector3(px, py, 0), &psect); if (psect == nullptr) { diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 618c7c822..9e86a7c89 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1335,7 +1335,7 @@ void movetransports_r(void) else if (isRRRA() && k == 2) { ps[p].posoldX() = ps[p].posX() += Owner->spr.pos.X - act->spr.pos.X; - ps[p].PlayerOldPosition.Y = ps[p].posY() += Owner->spr.pos.Y - act->spr.pos.Y; + ps[p].posoldY() = ps[p].posY() += Owner->spr.pos.Y - act->spr.pos.Y; ps[p].backupxy(); if (Owner->GetOwner() != Owner) diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 352a714bc..a2a7aa7d0 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -383,8 +383,8 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case PLAYER_OPOSY: - if (bSet) ps[iPlayer].PlayerOldPosition.Y = lValue * maptoworld; - else SetGameVarID(lVar2, int(ps[iPlayer].PlayerOldPosition.Y * (1 / maptoworld)), sActor, sPlayer); + if (bSet) ps[iPlayer].posoldY() = lValue * maptoworld; + else SetGameVarID(lVar2, int(ps[iPlayer].posoldY() * (1 / maptoworld)), sActor, sPlayer); break; case PLAYER_OPOSZ: diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index fb565bdd2..763a4f50b 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -766,12 +766,12 @@ void player_struct::backuppos(bool noclipping) if (!noclipping) { posoldX() = posX(); - PlayerOldPosition.Y = posY(); + posoldY() = posY(); } else { posX() = posoldX(); - posY() = PlayerOldPosition.Y; + posY() = posoldY(); } PlayerOldPosition.Z = posZget(); diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index cc6f082d6..79ac53ae4 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -405,6 +405,10 @@ struct player_struct { return PlayerOldPosition.X; } + double& posoldY() + { + return PlayerOldPosition.Y; + } DVector2& posoldXY() { return PlayerOldPosition.XY();