From da04a1d0aaf222faecaa690fd02a1e6f28eae958 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 11 May 2020 15:28:58 +1000 Subject: [PATCH] RR: Return to centre improvements. - Lock player horizon while returning to centre. - Precisely scale player's horizon in time with rate at which 'pPlayer->return_to_center' decrements. - Check player's horizon is between 99 and 101 degrees, not 99.9 and 100.1. The extra 0.9 degrees of precision is not noticeable and is dramatically slower. - Reset 'pPlayer->return_to_center' to '0' when player's horizon is at 100. - Match q16horizoff precision to precision of q16horiz. --- source/rr/src/player.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source/rr/src/player.cpp b/source/rr/src/player.cpp index f4a84f512..c39876d9c 100644 --- a/source/rr/src/player.cpp +++ b/source/rr/src/player.cpp @@ -3180,7 +3180,8 @@ enum inputlock_t static int P_CheckLockedMovement(int const playerNum) { - auto const pPlayer = g_player[playerNum].ps; + auto &thisPlayer = g_player[playerNum]; + auto const pPlayer = thisPlayer.ps; if (pPlayer->on_crane >= 0) return IL_NOMOVE|IL_NOANGLE; @@ -3188,6 +3189,9 @@ static int P_CheckLockedMovement(int const playerNum) if (pPlayer->newowner != -1) return IL_NOANGLE|IL_NOHORIZ; + if (pPlayer->return_to_center > 0 || thisPlayer.horizRecenter) + return IL_NOHORIZ; + if (pPlayer->dead_flag || pPlayer->fist_incs || pPlayer->transporter_hold > 2 || pPlayer->hard_landing || pPlayer->access_incs > 0 || pPlayer->knee_incs > 0 || (PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) == TRIPBOMB_WEAPON && pPlayer->kickback_pic > 1 @@ -3515,15 +3519,16 @@ void P_GetInput(int const playerNum) } else if (pPlayer->return_to_center > 0 || thisPlayer.horizRecenter) { - pPlayer->q16horiz = fix16_sadd(pPlayer->q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl(fix16_from_dbl(200 / 3) - fix16_sdiv(pPlayer->q16horiz, F16(1.5)))))); + pPlayer->q16horiz = fix16_sadd(pPlayer->q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl(fix16_from_dbl(66.535) - fix16_sdiv(pPlayer->q16horiz, fix16_from_dbl(1.505)))))); - if ((!pPlayer->return_to_center && thisPlayer.horizRecenter) || (pPlayer->q16horiz >= F16(99.9) && pPlayer->q16horiz <= F16(100.1))) + if (pPlayer->q16horiz >= F16(99) && pPlayer->q16horiz <= F16(101)) { pPlayer->q16horiz = F16(100); + pPlayer->return_to_center = 0; thisPlayer.horizRecenter = false; } - if (pPlayer->q16horizoff >= F16(-0.1) && pPlayer->q16horizoff <= F16(0.1)) + if (pPlayer->q16horizoff >= F16(-1) && pPlayer->q16horizoff <= F16(1)) pPlayer->q16horizoff = 0; }