From fd05d320ffbdca39a4fb8d5ac2364bd91f074c41 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Fri, 25 Nov 2022 18:32:31 +1100 Subject: [PATCH] - Wrap access to previous pitch. --- source/core/gameinput.cpp | 2 +- source/core/gameinput.h | 12 +++++++----- source/games/duke/src/gameexec.cpp | 4 ++-- source/games/duke/src/premap.cpp | 2 +- source/games/exhumed/src/player.cpp | 4 ++-- source/games/sw/src/player.cpp | 2 +- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 807be8c9b..3d535003b 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -352,7 +352,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, P w.ZzOLDROTSCRNANG = w.ZzROTSCRNANG; w.legacyDisabledYaw = w.legacyDisabledYaw; w.resetAdjustmentYaw(); - w.ZzOLDHORIZON = w.ZzHORIZON(); + w.ZzOLDHORIZON() = w.ZzHORIZON(); w.ZzOHORIZOFF = w.ZzHORIZOFF; w.legacyDisabledPitch = w.legacyDisabledPitch; w.resetAdjustmentPitch(); diff --git a/source/core/gameinput.h b/source/core/gameinput.h index bd3be06d3..bee77e400 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -11,6 +11,8 @@ struct PlayerAngles // Temporary wrappers. DAngle thisHoriz; DAngle& ZzHORIZON() { return thisHoriz; } + DAngle prevHoriz; + DAngle& ZzOLDHORIZON() { return prevHoriz; } friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, PlayerAngles* def); @@ -52,7 +54,7 @@ struct PlayerAngles else { ZzHORIZON() = value; - if (backup) ZzOLDHORIZON = ZzHORIZON(); + if (backup) ZzOLDHORIZON() = ZzHORIZON(); } } @@ -105,7 +107,7 @@ struct PlayerAngles // Legacy, to be removed. - DAngle ZzOLDHORIZON, ZzHORIZOFF, ZzOHORIZOFF; + DAngle ZzHORIZOFF, ZzOHORIZOFF; void processLegacyHelperPitch(double const scaleAdjust) { if (targetedPitch()) @@ -129,15 +131,15 @@ struct PlayerAngles } void backupPitch() { - ZzOLDHORIZON = ZzHORIZON(); + ZzOLDHORIZON() = ZzHORIZON(); ZzOHORIZOFF = ZzHORIZOFF; } void restorePitch() { - ZzHORIZON() = ZzOLDHORIZON; + ZzHORIZON() = ZzOLDHORIZON(); ZzHORIZOFF = ZzOHORIZOFF; } - DAngle horizOLDSUM() { return ZzOLDHORIZON + ZzOHORIZOFF; } + DAngle horizOLDSUM() { return ZzOLDHORIZON() + ZzOHORIZOFF; } DAngle horizSUM() { return ZzHORIZON() + ZzHORIZOFF; } DAngle horizLERPSUM(double const interpfrac) { return interpolatedvalue(horizOLDSUM(), horizSUM(), interpfrac); } void resetAdjustmentPitch() { legacyAdjustmentPitch = nullAngle; } diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index d7fb83e08..3d5469b61 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -350,7 +350,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case PLAYER_OHORIZ: - if (!bSet) SetGameVarID(lVar2, int(ps[iPlayer].Angles.ZzOLDHORIZON.Tan() * -128.), sActor, sPlayer); + if (!bSet) SetGameVarID(lVar2, int(ps[iPlayer].Angles.ZzOLDHORIZON().Tan() * -128.), sActor, sPlayer); break; case PLAYER_HORIZOFF: @@ -2247,7 +2247,7 @@ int ParseState::parse(void) ps[g_p].last_extra = g_ac->spr.extra = gs.max_player_health; ps[g_p].wantweaponfire = -1; - ps[g_p].Angles.ZzOLDHORIZON = ps[g_p].Angles.ZzHORIZON() = nullAngle; + ps[g_p].Angles.ZzOLDHORIZON() = ps[g_p].Angles.ZzHORIZON() = nullAngle; ps[g_p].on_crane = nullptr; ps[g_p].frag_ps = g_p; ps[g_p].Angles.ZzOHORIZOFF = ps[g_p].Angles.ZzHORIZOFF = nullAngle; diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 6c58a7056..5d0ac62d9 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -125,7 +125,7 @@ void resetplayerstats(int snum) p->footprintpal = 0; p->footprintshade = 0; p->jumping_toggle = 0; - p->Angles.ZzOLDHORIZON = p->Angles.ZzHORIZON() = DAngle::fromDeg(-17.354); + p->Angles.ZzOLDHORIZON() = p->Angles.ZzHORIZON() = DAngle::fromDeg(-17.354); p->Angles.ZzOHORIZOFF = p->Angles.ZzHORIZOFF = nullAngle; p->bobcounter = 0; p->on_ground = 0; diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index b519d4392..6666791b6 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -411,7 +411,7 @@ void RestartPlayer(int nPlayer) plr->nThrust.Zero(); - plr->nDestVertPan = plr->Angles.ZzOLDHORIZON = plr->Angles.ZzHORIZON() = nullAngle; + plr->nDestVertPan = plr->Angles.ZzOLDHORIZON() = plr->Angles.ZzHORIZON() = nullAngle; plr->nBreathTimer = 90; plr->nTauntTimer = RandomSize(3) + 3; @@ -507,7 +507,7 @@ void StartDeathSeq(int nPlayer, int nVal) StopFiringWeapon(nPlayer); - PlayerList[nPlayer].Angles.ZzOLDHORIZON = PlayerList[nPlayer].Angles.ZzHORIZON() = nullAngle; + PlayerList[nPlayer].Angles.ZzOLDHORIZON() = PlayerList[nPlayer].Angles.ZzHORIZON() = nullAngle; pActor->oviewzoffset = pActor->viewzoffset = -55; PlayerList[nPlayer].nInvisible = 0; dVertPan[nPlayer] = 15; diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index b3e60db62..60d60a2f2 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -7048,7 +7048,7 @@ void InitAllPlayers(void) for (pp = Player; pp < &Player[MAX_SW_PLAYERS]; pp++) { pp->Angles.ZzANGLE = pp->Angles.ZzOLDANGLE = pfirst->Angles.ZzANGLE; - pp->Angles.ZzHORIZON() = pp->Angles.ZzOLDHORIZON = pfirst->Angles.ZzHORIZON(); + pp->Angles.ZzHORIZON() = pp->Angles.ZzOLDHORIZON() = pfirst->Angles.ZzHORIZON(); pp->cursector = pfirst->cursector; // set like this so that player can trigger something on start of the level pp->lastcursector = pfirst->cursector+1;