- Simplify PlayerAngle::settarget() by adding a dedicated angle setter that resets interpolated value as well.

This commit is contained in:
Mitchell Richters 2022-05-30 21:16:57 +10:00
parent 0416834d9d
commit 5a550613f3
3 changed files with 7 additions and 5 deletions

View file

@ -166,6 +166,9 @@ 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(); }
@ -207,9 +210,9 @@ struct PlayerAngle
}
}
void settarget(binangle const value, bool const backup = false)
void settarget(binangle const value)
{
if (!SyncInput() && !backup)
if (!SyncInput())
{
target = value;
if (!targetset()) target = bamang(1);
@ -217,7 +220,6 @@ struct PlayerAngle
else
{
ang = value;
if (backup) oang = ang;
}
}

View file

@ -1543,7 +1543,7 @@ void OperateTeleport(sectortype* pSector)
{
playerResetInertia(pPlayer);
pPlayer->zViewVel = pPlayer->zWeaponVel = 0;
pPlayer->angle.settarget(buildang(actor->spr.ang), true);
pPlayer->angle.setvalue(buildang(actor->spr.ang));
}
}
}

View file

@ -935,7 +935,7 @@ void AIPlayer::Tick(RunListEvent* ev)
if (nTotalPlayers <= 1)
{
auto ang = GetAngleToSprite(pPlayerActor, pSpiritSprite) & kAngleMask;
PlayerList[nPlayer].angle.settarget(buildang(ang), true);
PlayerList[nPlayer].angle.setvalue(buildang(ang));
pPlayerActor->spr.ang = ang;
PlayerList[nPlayer].horizon.setvalue(buildhoriz(0));