From 0416834d9d72e4077d1fa90acf416d55dd5df81a Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 30 May 2022 21:14:34 +1000 Subject: [PATCH] - Simplify `PlayerHorizon::settarget()` by adding a dedicated angle setter that resets interpolated value as well. --- source/core/gameinput.h | 8 +++++--- source/games/exhumed/src/player.cpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/core/gameinput.h b/source/core/gameinput.h index bd9bc985b..0f08967d4 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -49,6 +49,9 @@ struct PlayerHorizon fixedhoriz sum() { return horiz + horizoff; } fixedhoriz interpolatedsum(double const smoothratio) { return interpolatedhorizon(osum(), sum(), smoothratio); } + // Setter to force horizon and its interpolation companion. + void setvalue(fixedhoriz const value) { ohoriz = horiz = q16horiz(clamp(value.asq16(), gi->playerHorizMin(), gi->playerHorizMax())); } + // Ticrate playsim adjustment helpers. void resetadjustment() { adjustment = 0; } bool targetset() { return target.asq16(); } @@ -89,11 +92,11 @@ struct PlayerHorizon } } - void settarget(fixedhoriz value, bool const backup = false) + void settarget(fixedhoriz value) { value = q16horiz(clamp(value.asq16(), gi->playerHorizMin(), gi->playerHorizMax())); - if (!SyncInput() && !backup) + if (!SyncInput()) { target = value; if (!targetset()) target = q16horiz(1); @@ -101,7 +104,6 @@ struct PlayerHorizon else { horiz = value; - if (backup) ohoriz = horiz; } } diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 841098cb0..8314700d9 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -938,7 +938,7 @@ void AIPlayer::Tick(RunListEvent* ev) PlayerList[nPlayer].angle.settarget(buildang(ang), true); pPlayerActor->spr.ang = ang; - PlayerList[nPlayer].horizon.settarget(buildhoriz(0), true); + PlayerList[nPlayer].horizon.setvalue(buildhoriz(0)); lPlayerXVel = 0; lPlayerYVel = 0;