diff --git a/source/games/exhumed/src/exhumed.cpp b/source/games/exhumed/src/exhumed.cpp index 2c06f33ac..80546f280 100644 --- a/source/games/exhumed/src/exhumed.cpp +++ b/source/games/exhumed/src/exhumed.cpp @@ -374,10 +374,9 @@ void GameInterface::Ticker() for (int i = 0; i < 4; i++) { // Velocities are stored as Q14.18 - lPlayerXVel += int((localInput.fvel * inita.Cos() + localInput.svel * inita.Sin()) * 16384); - lPlayerYVel += int((localInput.fvel * inita.Sin() - localInput.svel * inita.Cos()) * 16384); - lPlayerXVel -= (lPlayerXVel >> 5) + (lPlayerXVel >> 6); - lPlayerYVel -= (lPlayerYVel >> 5) + (lPlayerYVel >> 6); + lPlayerVel.X += (localInput.fvel * inita.Cos() + localInput.svel * inita.Sin()) / 16.; + lPlayerVel.Y += (localInput.fvel * inita.Sin() - localInput.svel * inita.Cos()) / 16.; + lPlayerVel *= 0.953125; } UpdateInterpolations(); @@ -473,8 +472,7 @@ void GameInterface::Ticker() sPlayerInput[nLocalPlayer].actions = localInput.actions; if (oldactions & SB_CENTERVIEW) sPlayerInput[nLocalPlayer].actions |= SB_CENTERVIEW; - sPlayerInput[nLocalPlayer].xVel = lPlayerXVel; - sPlayerInput[nLocalPlayer].yVel = lPlayerYVel; + sPlayerInput[nLocalPlayer].vel = lPlayerVel; sPlayerInput[nLocalPlayer].buttons = lLocalCodes; sPlayerInput[nLocalPlayer].pTarget = bestTarget; sPlayerInput[nLocalPlayer].nAngle = localInput.avel; diff --git a/source/games/exhumed/src/init.cpp b/source/games/exhumed/src/init.cpp index 16ad74f52..ffb645a92 100644 --- a/source/games/exhumed/src/init.cpp +++ b/source/games/exhumed/src/init.cpp @@ -191,8 +191,7 @@ void InitLevel(MapRecord* map) ResetEngine(); totalmoves = 0; GrabPalette(); - lPlayerXVel = 0; - lPlayerYVel = 0; + lPlayerVel.Zero(); if (!mus_redbook && map->music.IsNotEmpty()) Mus_Play(map->music, true); // Allow non-CD music if defined for the current level playCDtrack(map->cdSongId, true); diff --git a/source/games/exhumed/src/input.cpp b/source/games/exhumed/src/input.cpp index 4024cd32a..e97ca6016 100644 --- a/source/games/exhumed/src/input.cpp +++ b/source/games/exhumed/src/input.cpp @@ -79,8 +79,7 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju } else { - lPlayerYVel = 0; - lPlayerXVel = 0; + lPlayerVel.Zero(); } if (!SyncInput()) diff --git a/source/games/exhumed/src/input.h b/source/games/exhumed/src/input.h index b60072809..1934ced84 100644 --- a/source/games/exhumed/src/input.h +++ b/source/games/exhumed/src/input.h @@ -33,8 +33,7 @@ enum { struct PlayerInput { TObjPtr pTarget; - int xVel; - int yVel; + DVector2 vel; uint16_t buttons; float nAngle; float pan; diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 2528aec72..6d7df80c9 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -42,8 +42,7 @@ BEGIN_PS_NS extern int nStatusSeqOffset; -int lPlayerXVel = 0; -int lPlayerYVel = 0; +DVector2 lPlayerVel; int obobangle = 0, bobangle = 0; static actionSeq PlayerSeq[] = { @@ -858,7 +857,7 @@ bool CheckMovingBlocks(int nPlayer, Collision& nMove, DVector3& spr_pos, sectort { PlayerList[nPlayer].pPlayerPushSect = sect; - DVector2 vel(FixedToFloat<18>(sPlayerInput[nPlayer].xVel), FixedToFloat<18>(sPlayerInput[nPlayer].yVel)); + DVector2 vel = sPlayerInput[nPlayer].vel; auto nMyAngle = VecToAngle(vel).Normalized360(); setsectinterpolate(sect); @@ -915,8 +914,7 @@ void AIPlayer::Tick(RunListEvent* ev) PlayerList[nPlayer].horizon.resetadjustment(); PlayerList[nPlayer].oeyelevel = PlayerList[nPlayer].eyelevel; - pPlayerActor->vel.X = FixedToFloat<18>(sPlayerInput[nPlayer].xVel); - pPlayerActor->vel.Y = FixedToFloat<18>(sPlayerInput[nPlayer].yVel); + pPlayerActor->vel.XY() = sPlayerInput[nPlayer].vel; if (sPlayerInput[nPlayer].nItem > -1) { @@ -1013,7 +1011,7 @@ void AIPlayer::Tick(RunListEvent* ev) auto playerPos = pPlayerActor->spr.pos.XY(); - DVector2 vect(FixedToFloat<18>(sPlayerInput[nPlayer].xVel), FixedToFloat<18>(sPlayerInput[nPlayer].yVel)); + DVector2 vect = sPlayerInput[nPlayer].vel; double zz = pPlayerActor->vel.Z; if (pPlayerActor->vel.Z > 32) @@ -1084,12 +1082,9 @@ void AIPlayer::Tick(RunListEvent* ev) PlayerList[nPlayer].horizon.settarget(buildhoriz(0), true); - lPlayerXVel = 0; - lPlayerYVel = 0; + lPlayerVel.Zero(); - pPlayerActor->vel.X = 0; - pPlayerActor->vel.Y = 0; - pPlayerActor->vel.Z = 0; + pPlayerActor->vel.Zero(); if (nFreeze < 1) { @@ -2753,8 +2748,7 @@ void SerializePlayer(FSerializer& arc) { if (arc.BeginObject("player")) { - arc("lxvel", lPlayerXVel) - ("lyvel", lPlayerYVel) + arc("lvel", lPlayerVel) ("bobangle", bobangle) ("standheight", nStandHeight) ("playercount", PlayerCount) diff --git a/source/games/exhumed/src/player.h b/source/games/exhumed/src/player.h index 16afa2150..d0688a10b 100644 --- a/source/games/exhumed/src/player.h +++ b/source/games/exhumed/src/player.h @@ -40,8 +40,7 @@ enum extern int nLocalPlayer; -extern int lPlayerXVel; -extern int lPlayerYVel; +extern DVector2 lPlayerVel; struct PlayerSave {