Skip to content

Commit

Permalink
- Simplify PlayerAngle::settarget() by adding a dedicated angle set…
Browse files Browse the repository at this point in the history
…ter that resets interpolated value as well.
  • Loading branch information
mjr4077au committed May 30, 2022
1 parent 0416834 commit 5a55061
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions source/core/gameinput.h
Expand Up @@ -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(); }
Expand Down Expand Up @@ -207,17 +210,16 @@ 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);
}
else
{
ang = value;
if (backup) oang = ang;
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/triggers.cpp
Expand Up @@ -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));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/games/exhumed/src/player.cpp
Expand Up @@ -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));
Expand Down

0 comments on commit 5a55061

Please sign in to comment.