- fixed view centering in Exhumed.

Switched to GDX's code because the one present here looked quite weird.
This still does not feature interpolation.
Fixes #296
This commit is contained in:
Christoph Oelckers 2020-08-31 21:41:39 +02:00
parent 8905c5ee26
commit 6b1fa22aed
2 changed files with 21 additions and 42 deletions

View File

@ -550,7 +550,7 @@ void GameTicker()
{ {
bLockPan = false; bLockPan = false;
bPlayerPan = false; bPlayerPan = false;
PlayerList[nLocalPlayer].q16horiz = fix16_from_int(92); //PlayerList[nLocalPlayer].q16horiz = fix16_from_int(92);
nDestVertPan[nLocalPlayer] = fix16_from_int(92); nDestVertPan[nLocalPlayer] = fix16_from_int(92);
} }
if (localInput.actions & SB_TURNAROUND) if (localInput.actions & SB_TURNAROUND)

View File

@ -255,7 +255,7 @@ void PlayerInterruptKeys(bool after)
// Look/aim up/down functions. // Look/aim up/down functions.
if (localInput.actions & (SB_LOOK_UP|SB_AIM_UP)) if (localInput.actions & (SB_LOOK_UP|SB_AIM_UP))
{ {
bLockPan = false; bLockPan = (localInput.actions & SB_LOOK_UP);
if (PlayerList[nLocalPlayer].q16horiz < fix16_from_int(180)) { if (PlayerList[nLocalPlayer].q16horiz < fix16_from_int(180)) {
PlayerList[nLocalPlayer].q16horiz = fix16_sadd(PlayerList[nLocalPlayer].q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(4))); PlayerList[nLocalPlayer].q16horiz = fix16_sadd(PlayerList[nLocalPlayer].q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(4)));
} }
@ -265,7 +265,7 @@ void PlayerInterruptKeys(bool after)
} }
else if (localInput.actions & (SB_LOOK_DOWN|SB_AIM_DOWN)) else if (localInput.actions & (SB_LOOK_DOWN|SB_AIM_DOWN))
{ {
bLockPan = false; bLockPan = (localInput.actions & SB_LOOK_DOWN);
if (PlayerList[nLocalPlayer].q16horiz > fix16_from_int(4)) { if (PlayerList[nLocalPlayer].q16horiz > fix16_from_int(4)) {
PlayerList[nLocalPlayer].q16horiz = fix16_ssub(PlayerList[nLocalPlayer].q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(4))); PlayerList[nLocalPlayer].q16horiz = fix16_ssub(PlayerList[nLocalPlayer].q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(4)));
} }
@ -279,51 +279,30 @@ void PlayerInterruptKeys(bool after)
if (totalvel[nLocalPlayer] > 20) { if (totalvel[nLocalPlayer] > 20) {
bPlayerPan = false; bPlayerPan = false;
} }
if (nFreeze) return;
if (mouseaim)
bLockPan = true;
// loc_1C05E // loc_1C05E
fix16_t ecx = nDestVertPan[nLocalPlayer] - PlayerList[nLocalPlayer].q16horiz; fix16_t dVertPan = nDestVertPan[nLocalPlayer] - PlayerList[nLocalPlayer].q16horiz;
if (dVertPan != 0 && !bLockPan)
if (mouseaim)
{ {
ecx = 0; int val = dVertPan / 4;
} if (abs(val) >= 4)
if (!nFreeze)
{
if (ecx)
{ {
if (ecx / 4 == 0) if (val >= 4)
{ PlayerList[nLocalPlayer].q16horiz += fix16_from_int(4);
if (ecx >= 0) { else if (val <= -4)
ecx = 1; PlayerList[nLocalPlayer].q16horiz -= fix16_from_int(4);
} }
else else if (abs(dVertPan) >= fix16_one)
{ PlayerList[nLocalPlayer].q16horiz += dVertPan / 2.0f;
ecx = -1; else
} {
} if (mouseaim) bLockPan = true;
else PlayerList[nLocalPlayer].q16horiz = nDestVertPan[nLocalPlayer];
{
ecx /= 4;
if (ecx > fix16_from_int(4))
{
ecx = fix16_from_int(4);
}
else if (ecx < -fix16_from_int(4))
{
ecx = -fix16_from_int(4);
}
}
PlayerList[nLocalPlayer].q16horiz = fix16_sadd(PlayerList[nLocalPlayer].q16horiz, ecx);
} }
PlayerList[nLocalPlayer].q16horiz = fix16_clamp(PlayerList[nLocalPlayer].q16horiz, fix16_from_int(0), fix16_from_int(184));
} }
else bLockPan = mouseaim;
PlayerList[nLocalPlayer].q16horiz = fix16_clamp(PlayerList[nLocalPlayer].q16horiz, fix16_from_int(0), fix16_from_int(184));
} }