mirror of
https://github.com/DrBeef/Raze.git
synced 2025-03-11 03:31:43 +00:00
Revert "- Simplify PlayerHorizon::settarget()
by adding a dedicated angle setter that resets interpolated value as well."
This reverts commit0416834d9d
. Revert "- Simplify `PlayerAngle::settarget()` by adding a dedicated angle setter that resets interpolated value as well." This reverts commit5a550613f3
. Revert "- Add bool `lock` to `PlayerHorizon::settarget()` when setting target from the ticker without having to call setters and resetters." This reverts commit18541d1ab4
. Revert "- Add bool `lock` to `PlayerAngle::settarget()` when setting target from the ticker without having to call setters and resetters." This reverts commit1ac58dc41c
. * We need to ensure only the ticker can unlock the player's input if it's telling us to lock the input.
This commit is contained in:
parent
0359d49df2
commit
71fb91940d
5 changed files with 24 additions and 21 deletions
|
@ -55,14 +55,13 @@ 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(); }
|
||||
|
||||
// Input locking helpers.
|
||||
void lockinput() { inputdisabled = true; }
|
||||
void unlockinput() { inputdisabled = false; }
|
||||
bool movementlocked() { return targetset() || inputdisabled; }
|
||||
|
||||
// Draw code helpers.
|
||||
|
@ -96,19 +95,19 @@ struct PlayerHorizon
|
|||
}
|
||||
}
|
||||
|
||||
void settarget(fixedhoriz value, bool const lock = false)
|
||||
void settarget(fixedhoriz value, bool const backup = false)
|
||||
{
|
||||
// Clamp incoming variable because sometimes the caller can exceed bounds.
|
||||
value = q16horiz(clamp(value.asq16(), gi->playerHorizMin(), gi->playerHorizMax()));
|
||||
|
||||
if (!SyncInput())
|
||||
if (!SyncInput() && !backup)
|
||||
{
|
||||
inputdisabled = lock;
|
||||
target = value.asq16() ? value : q16horiz(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
horiz = value;
|
||||
if (backup) ohoriz = horiz;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,7 +125,6 @@ struct PlayerHorizon
|
|||
{
|
||||
horiz = target;
|
||||
target = q16horiz(0);
|
||||
inputdisabled = false;
|
||||
}
|
||||
}
|
||||
else if (adjustment)
|
||||
|
@ -172,14 +170,13 @@ 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(); }
|
||||
|
||||
// Input locking helpers.
|
||||
void lockinput() { inputdisabled = true; }
|
||||
void unlockinput() { inputdisabled = false; }
|
||||
bool movementlocked() { return targetset() || inputdisabled; }
|
||||
|
||||
// Draw code helpers.
|
||||
|
@ -214,16 +211,16 @@ struct PlayerAngle
|
|||
}
|
||||
}
|
||||
|
||||
void settarget(binangle const value, bool const lock = false)
|
||||
void settarget(binangle const value, bool const backup = false)
|
||||
{
|
||||
if (!SyncInput())
|
||||
if (!SyncInput() && !backup)
|
||||
{
|
||||
inputdisabled = lock;
|
||||
target = value.asbam() ? value : bamang(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ang = value;
|
||||
if (backup) oang = ang;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,7 +238,6 @@ struct PlayerAngle
|
|||
{
|
||||
ang = target;
|
||||
target = bamang(0);
|
||||
inputdisabled = false;
|
||||
}
|
||||
}
|
||||
else if (adjustment)
|
||||
|
|
|
@ -2234,7 +2234,8 @@ void trPlayerCtrlSetLookAngle(int value, PLAYER* pPlayer)
|
|||
adjustment = 0;
|
||||
}
|
||||
|
||||
pPlayer->horizon.settarget(buildfhoriz(100. * tan(adjustment * pi::pi() / 1024.)), true);
|
||||
pPlayer->horizon.settarget(buildfhoriz(100. * tan(adjustment * pi::pi() * (1. / 1024.))));
|
||||
pPlayer->horizon.lockinput();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -3119,7 +3120,8 @@ void useTeleportTarget(DBloodActor* sourceactor, DBloodActor* actor)
|
|||
{
|
||||
if (pPlayer)
|
||||
{
|
||||
pPlayer->angle.settarget(buildang(sourceactor->spr.ang), true);
|
||||
pPlayer->angle.settarget(buildang(sourceactor->spr.ang));
|
||||
pPlayer->angle.lockinput();
|
||||
}
|
||||
else if (isDude) sourceactor->xspr.goalAng = actor->spr.ang = sourceactor->spr.ang;
|
||||
else actor->spr.ang = sourceactor->spr.ang;
|
||||
|
@ -5840,11 +5842,13 @@ bool modernTypeOperateSprite(DBloodActor* actor, EVENT& event)
|
|||
if (actor->xspr.data4 != 0) break;
|
||||
else if (actor->spr.flags & kModernTypeFlag1)
|
||||
{
|
||||
pPlayer->angle.settarget(buildang(actor->spr.ang), true);
|
||||
pPlayer->angle.settarget(buildang(actor->spr.ang));
|
||||
pPlayer->angle.lockinput();
|
||||
}
|
||||
else if (valueIsBetween(actor->xspr.data2, -kAng360, kAng360))
|
||||
{
|
||||
pPlayer->angle.settarget(buildang(actor->xspr.data2), true);
|
||||
pPlayer->angle.settarget(buildang(actor->xspr.data2));
|
||||
pPlayer->angle.lockinput();
|
||||
}
|
||||
break;
|
||||
case 10: // 74 (de)activate powerup
|
||||
|
|
|
@ -1781,6 +1781,9 @@ void ProcessInput(PLAYER* pPlayer)
|
|||
doslopetilting(pPlayer);
|
||||
}
|
||||
|
||||
pPlayer->angle.unlockinput();
|
||||
pPlayer->horizon.unlockinput();
|
||||
|
||||
pPlayer->slope = -pPlayer->horizon.horiz.asq16() >> 9;
|
||||
if (pInput->actions & SB_INVPREV)
|
||||
{
|
||||
|
|
|
@ -1543,7 +1543,7 @@ void OperateTeleport(sectortype* pSector)
|
|||
{
|
||||
playerResetInertia(pPlayer);
|
||||
pPlayer->zViewVel = pPlayer->zWeaponVel = 0;
|
||||
pPlayer->angle.setvalue(buildang(actor->spr.ang));
|
||||
pPlayer->angle.settarget(buildang(actor->spr.ang), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -935,10 +935,10 @@ void AIPlayer::Tick(RunListEvent* ev)
|
|||
if (nTotalPlayers <= 1)
|
||||
{
|
||||
auto ang = GetAngleToSprite(pPlayerActor, pSpiritSprite) & kAngleMask;
|
||||
PlayerList[nPlayer].angle.setvalue(buildang(ang));
|
||||
PlayerList[nPlayer].angle.settarget(buildang(ang), true);
|
||||
pPlayerActor->spr.ang = ang;
|
||||
|
||||
PlayerList[nPlayer].horizon.setvalue(buildhoriz(0));
|
||||
PlayerList[nPlayer].horizon.settarget(buildhoriz(0), true);
|
||||
|
||||
lPlayerXVel = 0;
|
||||
lPlayerYVel = 0;
|
||||
|
|
Loading…
Reference in a new issue