- Add bool lock to PlayerHorizon::settarget() when setting target from the ticker without having to call setters and resetters.

This commit is contained in:
Mitchell Richters 2022-05-30 21:21:18 +10:00
parent 5a550613f3
commit 18541d1ab4
3 changed files with 3 additions and 8 deletions

View file

@ -57,8 +57,6 @@ struct PlayerHorizon
bool targetset() { return target.asq16(); }
// Input locking helpers.
void lockinput() { inputdisabled = true; }
void unlockinput() { inputdisabled = false; }
bool movementlocked() { return targetset() || inputdisabled; }
// Draw code helpers.
@ -92,9 +90,10 @@ struct PlayerHorizon
}
}
void settarget(fixedhoriz value)
void settarget(fixedhoriz value, bool const lock = false)
{
value = q16horiz(clamp(value.asq16(), gi->playerHorizMin(), gi->playerHorizMax()));
inputdisabled = lock;
if (!SyncInput())
{

View file

@ -2234,8 +2234,7 @@ void trPlayerCtrlSetLookAngle(int value, PLAYER* pPlayer)
adjustment = 0;
}
pPlayer->horizon.settarget(buildfhoriz(100. * tan(adjustment * pi::pi() / 1024.)));
pPlayer->horizon.lockinput();
pPlayer->horizon.settarget(buildfhoriz(100. * tan(adjustment * pi::pi() / 1024.)), true);
}
//---------------------------------------------------------------------------

View file

@ -1781,9 +1781,6 @@ void ProcessInput(PLAYER* pPlayer)
doslopetilting(pPlayer);
}
pPlayer->angle.unlockinput();
pPlayer->horizon.unlockinput();
pPlayer->slope = -pPlayer->horizon.horiz.asq16() >> 9;
if (pInput->actions & SB_INVPREV)
{