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.
This commit is contained in:
Mitchell Richters 2020-05-11 15:28:58 +10:00 committed by Christoph Oelckers
parent 549ff75b99
commit da04a1d0aa

View file

@ -3180,7 +3180,8 @@ enum inputlock_t
static int P_CheckLockedMovement(int const playerNum) 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) if (pPlayer->on_crane >= 0)
return IL_NOMOVE|IL_NOANGLE; return IL_NOMOVE|IL_NOANGLE;
@ -3188,6 +3189,9 @@ static int P_CheckLockedMovement(int const playerNum)
if (pPlayer->newowner != -1) if (pPlayer->newowner != -1)
return IL_NOANGLE|IL_NOHORIZ; 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 if (pPlayer->dead_flag || pPlayer->fist_incs || pPlayer->transporter_hold > 2 || pPlayer->hard_landing || pPlayer->access_incs > 0
|| pPlayer->knee_incs > 0 || pPlayer->knee_incs > 0
|| (PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) == TRIPBOMB_WEAPON && pPlayer->kickback_pic > 1 || (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) 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->q16horiz = F16(100);
pPlayer->return_to_center = 0;
thisPlayer.horizRecenter = false; 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; pPlayer->q16horizoff = 0;
} }