From 5a550613f3cc5fe1339900536edef01638e33856 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 30 May 2022 21:16:57 +1000 Subject: [PATCH] - Simplify `PlayerAngle::settarget()` by adding a dedicated angle setter that resets interpolated value as well. --- source/core/gameinput.h | 8 +++++--- source/games/blood/src/triggers.cpp | 2 +- source/games/exhumed/src/player.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/source/core/gameinput.h b/source/core/gameinput.h index 0f08967d4..894b35fe2 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -166,6 +166,9 @@ struct PlayerAngle binangle interpolatedlookang(double const smoothratio) { return interpolatedangle(olook_ang, look_ang, smoothratio); } binangle interpolatedrotscrn(double const smoothratio) { return interpolatedangle(orotscrnang, rotscrnang, smoothratio); } + // Setter to force angle and its interpolation companion. + void setvalue(binangle const value) { oang = ang = value; } + // Ticrate playsim adjustment helpers. void resetadjustment() { adjustment = 0; } bool targetset() { return target.asbam(); } @@ -207,9 +210,9 @@ struct PlayerAngle } } - void settarget(binangle const value, bool const backup = false) + void settarget(binangle const value) { - if (!SyncInput() && !backup) + if (!SyncInput()) { target = value; if (!targetset()) target = bamang(1); @@ -217,7 +220,6 @@ struct PlayerAngle else { ang = value; - if (backup) oang = ang; } } diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index 73b9fcce5..dfd176f38 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -1543,7 +1543,7 @@ void OperateTeleport(sectortype* pSector) { playerResetInertia(pPlayer); pPlayer->zViewVel = pPlayer->zWeaponVel = 0; - pPlayer->angle.settarget(buildang(actor->spr.ang), true); + pPlayer->angle.setvalue(buildang(actor->spr.ang)); } } } diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 8314700d9..238449ea5 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -935,7 +935,7 @@ void AIPlayer::Tick(RunListEvent* ev) if (nTotalPlayers <= 1) { auto ang = GetAngleToSprite(pPlayerActor, pSpiritSprite) & kAngleMask; - PlayerList[nPlayer].angle.settarget(buildang(ang), true); + PlayerList[nPlayer].angle.setvalue(buildang(ang)); pPlayerActor->spr.ang = ang; PlayerList[nPlayer].horizon.setvalue(buildhoriz(0));