From f6b9c3cba726f2c025300adce29dcd76aa720969 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 3 Jan 2021 19:25:49 +1100 Subject: [PATCH] - Duke (RR): Fix braking on vehicles which never got picked up. --- source/games/duke/src/input.cpp | 4 +-- source/games/duke/src/player_r.cpp | 51 +++++++++--------------------- source/games/duke/src/types.h | 2 +- 3 files changed, 17 insertions(+), 40 deletions(-) diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 1bb8f8077..742d30f1a 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -741,9 +741,7 @@ static void processVehicleInput(player_struct *p, ControlInfo* const hidInput, I { p->vehForwardScale = std::min((buttonMap.ButtonDown(gamefunc_Move_Forward) || buttonMap.ButtonDown(gamefunc_Strafe)) + hidInput->dz, 1.f); p->vehReverseScale = std::min(buttonMap.ButtonDown(gamefunc_Move_Backward) + -hidInput->dz, 1.f); - - if (loc.actions & SB_RUN) - loc.actions |= SB_CROUCH; + p->vehBraking = buttonMap.ButtonDown(gamefunc_Run); } if (p->OnMotorcycle) diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 86f22b688..977216af2 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -1600,25 +1600,16 @@ static void onMotorcycle(int snum, ESyncBits &actions) auto p = &ps[snum]; auto pact = p->GetActor(); - bool braking; short rng; if (p->MotoSpeed < 0) p->MotoSpeed = 0; - if (actions & SB_CROUCH) - { - braking = true; - actions &= ~SB_CROUCH; - } - else - braking = false; - if (p->vehForwardScale != 0) { if (p->on_ground) { - if (p->MotoSpeed == 0 && braking) + if (p->MotoSpeed == 0 && p->vehBraking) { if (!S_CheckActorSoundPlaying(pact, 187)) S_PlayActorSound(187, pact); @@ -1676,7 +1667,7 @@ static void onMotorcycle(int snum, ESyncBits &actions) if (p->on_ground == 1) { - if (braking && p->MotoSpeed > 0) + if (p->vehBraking && p->MotoSpeed > 0) { p->MotoSpeed -= p->moto_on_oil ? 2 : 4; if (p->MotoSpeed < 0) @@ -1684,7 +1675,7 @@ static void onMotorcycle(int snum, ESyncBits &actions) p->VBumpTarget = -30; p->moto_do_bump = 1; } - else if (p->vehForwardScale != 0 && !braking) + else if (p->vehForwardScale != 0 && !p->vehBraking) { if (p->MotoSpeed < 40) { @@ -1704,13 +1695,13 @@ static void onMotorcycle(int snum, ESyncBits &actions) else if (p->MotoSpeed > 0) p->MotoSpeed--; - if (p->moto_do_bump && (!braking || p->MotoSpeed == 0)) + if (p->moto_do_bump && (!p->vehBraking || p->MotoSpeed == 0)) { p->VBumpTarget = 0; p->moto_do_bump = 0; } - if (p->vehReverseScale != 0 && p->MotoSpeed <= 0 && !braking) + if (p->vehReverseScale != 0 && p->MotoSpeed <= 0 && !p->vehBraking) { bool temp = p->vehTurnRight; p->vehTurnRight = p->vehTurnLeft; @@ -1831,10 +1822,8 @@ static void onMotorcycle(int snum, ESyncBits &actions) p->posyv += currSpeed * bsin(velAdjustment * -51 + p->angle.ang.asbuild(), 4); } - p->moto_on_mud = 0; - p->moto_on_oil = 0; - p->vehTurnLeft = false; - p->vehTurnRight = false; + p->moto_on_mud = p->moto_on_oil = 0; + p->vehTurnLeft = p->vehTurnRight = p->vehBraking = false; } //--------------------------------------------------------------------------- @@ -1848,7 +1837,7 @@ static void onBoat(int snum, ESyncBits &actions) auto p = &ps[snum]; auto pact = p->GetActor(); - bool heeltoe, braking; + bool heeltoe; short rng; if (p->NotOnWater) @@ -1868,12 +1857,11 @@ static void onBoat(int snum, ESyncBits &actions) if (p->MotoSpeed < 0) p->MotoSpeed = 0; - if ((actions & SB_CROUCH) && (p->vehForwardScale != 0)) + if (p->vehBraking && (p->vehForwardScale != 0)) { heeltoe = true; - braking = false; + p->vehBraking = false; p->vehForwardScale = 0; - actions &= ~SB_CROUCH; } else heeltoe = false; @@ -1909,14 +1897,6 @@ static void onBoat(int snum, ESyncBits &actions) S_PlayActorSound(87, pact); } - if (actions & SB_CROUCH) - { - braking = true; - actions &= ~SB_CROUCH; - } - else - braking = false; - if (p->vehTurnLeft && !S_CheckActorSoundPlaying(pact, 91) && p->MotoSpeed > 30 && !p->NotOnWater) S_PlayActorSound(91, pact); @@ -1962,7 +1942,7 @@ static void onBoat(int snum, ESyncBits &actions) p->moto_do_bump = 1; } } - else if (braking && p->MotoSpeed > 0) + else if (p->vehBraking && p->MotoSpeed > 0) { p->MotoSpeed -= 2; if (p->MotoSpeed < 0) @@ -1985,13 +1965,13 @@ static void onBoat(int snum, ESyncBits &actions) else if (p->MotoSpeed > 0) p->MotoSpeed--; - if (p->moto_do_bump && (!braking || p->MotoSpeed == 0)) + if (p->moto_do_bump && (!p->vehBraking || p->MotoSpeed == 0)) { p->VBumpTarget = 0; p->moto_do_bump = 0; } - if (p->vehReverseScale != 0 && p->MotoSpeed == 0 && !braking) + if (p->vehReverseScale != 0 && p->MotoSpeed == 0 && !p->vehBraking) { bool temp = p->vehTurnRight; p->vehTurnRight = p->vehTurnLeft; @@ -2080,8 +2060,7 @@ static void onBoat(int snum, ESyncBits &actions) if (p->NotOnWater && p->MotoSpeed > 50) p->MotoSpeed -= (p->MotoSpeed / 2.); - p->vehTurnLeft = false; - p->vehTurnRight = false; + p->vehTurnLeft = p->vehTurnRight = p->vehBraking = false; } //--------------------------------------------------------------------------- @@ -2340,7 +2319,7 @@ static void underwater(int snum, ESyncBits actions, int psect, int fz, int cz) p->poszv -= 348; if (p->poszv < -(256 * 6)) p->poszv = -(256 * 6); } - else if ((actions & SB_CROUCH) || p->OnMotorcycle) + else if (p->vehBraking || p->OnMotorcycle) { if (p->poszv < 0) p->poszv = 0; p->poszv += 348; diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 882fd67f6..27e3d902f 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -276,7 +276,7 @@ struct player_struct uint8_t OnMotorcycle, OnBoat, moto_underwater, NotOnWater, MotoOnGround; uint8_t moto_do_bump, moto_bump_fast, moto_on_oil, moto_on_mud; double vehForwardScale, vehReverseScale, MotoSpeed; - bool vehTurnLeft, vehTurnRight; + bool vehTurnLeft, vehTurnRight, vehBraking; // input stuff. InputPacket sync;