- Exhumed: Fix player panning when walking up/down steps while horizon is 0.

This commit is contained in:
Mitchell Richters 2021-01-05 11:01:31 +11:00
parent b034d9e059
commit d32dcd5f8e
2 changed files with 38 additions and 0 deletions

View file

@ -39,6 +39,18 @@ struct PlayerHorizon
}
}
void addadjustment(fixed_t value)
{
if (!SyncInput())
{
adjustment += value;
}
else
{
horiz += q16horiz(value);
}
}
void resetadjustment()
{
adjustment = 0;

View file

@ -1167,6 +1167,32 @@ void FuncPlayer(int a, int nDamage, int nRun)
}
sectdone:
static bool plrFalling = false;
if (!PlayerList[nPlayer].horizon.horiz.asbuild() || plrFalling)
{
// Calculate base pan amount based on how much the player is falling.
fixed_t dVertPan = (spr_z - sprite[nPlayerSprite].z) << 9;
if (dVertPan != 0)
{
fixed_t adjustment;
if (dVertPan >= IntToFixed(4))
adjustment = IntToFixed(4);
else if (dVertPan <= -IntToFixed(4))
adjustment = -IntToFixed(4);
else
adjustment = dVertPan << 1;
PlayerList[nPlayer].horizon.addadjustment(adjustment);
plrFalling = true;
}
else
{
sPlayerInput[nPlayer].actions |= SB_CENTERVIEW;
plrFalling = false;
}
}
playerX -= sprite[nPlayerSprite].x;
playerY -= sprite[nPlayerSprite].y;