From def2b9d483ffd0dfd8fc77991b8d1380b739d6a0 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 20 Sep 2022 09:15:26 +1000 Subject: [PATCH] - Flip `svel` around in the input code so we can use proper anti-clockwise vector math. --- source/core/gameinput.cpp | 16 ++++++++-------- source/games/blood/src/nnexts.cpp | 4 ++-- source/games/blood/src/player.cpp | 2 +- source/games/duke/src/input.cpp | 4 ++-- source/games/exhumed/src/exhumed.cpp | 5 +++-- source/games/sw/src/input.cpp | 4 ++-- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index f61ef340f..bc7a960cd 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -162,7 +162,7 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe if (!strafing) currInput->avel += float(hidInput->mouseturnx + (scaleAdjust * hidInput->dyaw * hidspeed)); else - currInput->svel -= int16_t(((hidInput->mousemovex * mousevelscale) + (scaleAdjust * hidInput->dyaw * keymove)) * hidprescale); + currInput->svel += int16_t(((hidInput->mousemovex * mousevelscale) + (scaleAdjust * hidInput->dyaw * keymove)) * hidprescale); if (!(inputBuffer->actions & SB_AIMMODE)) currInput->horz -= hidInput->mouseturny; @@ -171,7 +171,7 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe // process remaining controller input. currInput->horz -= float(scaleAdjust * hidInput->dpitch * hidspeed); - currInput->svel += int16_t(scaleAdjust * hidInput->dx * keymove * hidprescale); + currInput->svel -= int16_t(scaleAdjust * hidInput->dx * keymove * hidprescale); currInput->fvel += int16_t(scaleAdjust * hidInput->dz * keymove * hidprescale); // process keyboard turning keys. @@ -201,18 +201,18 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe else { if (buttonMap.ButtonDown(gamefunc_Turn_Left)) - currInput->svel += keymove; + currInput->svel -= keymove; if (buttonMap.ButtonDown(gamefunc_Turn_Right)) - currInput->svel -= keymove; + currInput->svel += keymove; } // process keyboard side velocity keys. if (buttonMap.ButtonDown(gamefunc_Strafe_Left) && allowstrafe) - currInput->svel += keymove; + currInput->svel -= keymove; if (buttonMap.ButtonDown(gamefunc_Strafe_Right) && allowstrafe) - currInput->svel -= keymove; + currInput->svel += keymove; // process keyboard forward velocity keys. if (!(isRR() && drink_amt >= 66 && drink_amt <= 87)) @@ -228,13 +228,13 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe if (buttonMap.ButtonDown(gamefunc_Move_Forward)) { currInput->fvel += keymove; - currInput->svel += drink_amt & 1 ? keymove : -keymove; + currInput->svel -= drink_amt & 1 ? keymove : -keymove; } if (buttonMap.ButtonDown(gamefunc_Move_Backward)) { currInput->fvel -= keymove; - currInput->svel -= drink_amt & 1 ? keymove : -keymove; + currInput->svel += drink_amt & 1 ? keymove : -keymove; } } diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index cb9476cd8..d3939f2c8 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -4393,8 +4393,8 @@ bool condCheckPlayer(DBloodActor* aCond, int cmpOp, bool PUSH) switch (arg1) { case 1: return (pPlayer->input.fvel > 0); // forward case 2: return (pPlayer->input.fvel < 0); // backward - case 3: return (pPlayer->input.svel > 0); // left - case 4: return (pPlayer->input.svel < 0); // right + case 3: return (pPlayer->input.svel < 0); // left + case 4: return (pPlayer->input.svel > 0); // right case 5: return !!(pPlayer->input.actions & SB_JUMP); // jump case 6: return !!(pPlayer->input.actions & SB_CROUCH); // crouch case 7: return !!(pPlayer->input.actions & SB_FIRE); // normal fire weapon diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 647f4cad8..1e2b94314 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -1596,7 +1596,7 @@ void ProcessInput(PLAYER* pPlayer) const double speed = 1. - (actor->xspr.height < 256 ? actor->xspr.height * (1. / 256.) : 0); const double& fvAccel = pInput->fvel > 0 ? pPosture->frontAccel : pPosture->backAccel; const double& svAccel = pPosture->sideAccel; - actor->vel.XY() += DVector2(pInput->fvel * fvAccel, -pInput->svel * svAccel).Rotated(actor->spr.angle) * speed; + actor->vel.XY() += DVector2(pInput->fvel * fvAccel, pInput->svel * svAccel).Rotated(actor->spr.angle) * speed; } if (SyncInput()) diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index ab10ac81c..77941c31a 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -852,8 +852,8 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju if (packet) { *packet = loc; - packet->fvel = MulScale(loc.fvel, p->angle.ang.Cos() * (1 << 14), 9) + MulScale(loc.svel, p->angle.ang.Sin() * (1 << 14), 9) + p->fric.X; - packet->svel = MulScale(loc.fvel, p->angle.ang.Sin() * (1 << 14), 9) - MulScale(loc.svel, p->angle.ang.Cos() * (1 << 14), 9) + p->fric.Y; + packet->fvel = MulScale(loc.fvel, p->angle.ang.Cos() * (1 << 14), 9) - MulScale(loc.svel, p->angle.ang.Sin() * (1 << 14), 9) + p->fric.X; + packet->svel = MulScale(loc.fvel, p->angle.ang.Sin() * (1 << 14), 9) + MulScale(loc.svel, p->angle.ang.Cos() * (1 << 14), 9) + p->fric.Y; loc = {}; } } diff --git a/source/games/exhumed/src/exhumed.cpp b/source/games/exhumed/src/exhumed.cpp index 9d83523c6..30d0ca6dd 100644 --- a/source/games/exhumed/src/exhumed.cpp +++ b/source/games/exhumed/src/exhumed.cpp @@ -373,11 +373,12 @@ void GameInterface::Ticker() auto& lPlayerVel = sPlayerInput[nLocalPlayer].vel; + auto inputvect = DVector2(localInput.fvel, localInput.svel).Rotated(inita) * (1. / 16.); + for (int i = 0; i < 4; i++) { // Velocities are stored as Q14.18 - lPlayerVel.X += (localInput.fvel * inita.Cos() + localInput.svel * inita.Sin()) / 16.; - lPlayerVel.Y += (localInput.fvel * inita.Sin() - localInput.svel * inita.Cos()) / 16.; + lPlayerVel += inputvect; lPlayerVel *= 0.953125; } UpdateInterpolations(); diff --git a/source/games/sw/src/input.cpp b/source/games/sw/src/input.cpp index 2461ec5d8..2d4f3405b 100644 --- a/source/games/sw/src/input.cpp +++ b/source/games/sw/src/input.cpp @@ -207,8 +207,8 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju if (packet) { *packet = loc; - packet->fvel = MulScale(loc.fvel, pp->angle.ang.Cos() * (1 << 14), 9) + MulScale(loc.svel, pp->angle.ang.Sin() * (1 << 14), 9); - packet->svel = MulScale(loc.fvel, pp->angle.ang.Sin() * (1 << 14), 9) - MulScale(loc.svel, pp->angle.ang.Cos() * (1 << 14), 9); + packet->fvel = MulScale(loc.fvel, pp->angle.ang.Cos() * (1 << 14), 9) - MulScale(loc.svel, pp->angle.ang.Sin() * (1 << 14), 9); + packet->svel = MulScale(loc.fvel, pp->angle.ang.Sin() * (1 << 14), 9) + MulScale(loc.svel, pp->angle.ang.Cos() * (1 << 14), 9); loc = {}; } }