From 949e45601826b8ece63122dd3a3b9e30dd37f470 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Fri, 1 Jan 2021 21:33:00 +1100 Subject: [PATCH] - All Games: Slight tidy up of `gi->GetInput()` functions. --- source/exhumed/src/input.cpp | 1 + source/games/duke/src/input.cpp | 19 ++++++++----------- source/sw/src/input.cpp | 9 ++------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/source/exhumed/src/input.cpp b/source/exhumed/src/input.cpp index e502bd626..72213c729 100644 --- a/source/exhumed/src/input.cpp +++ b/source/exhumed/src/input.cpp @@ -136,6 +136,7 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput) if (packet) { *packet = localInput; + localInput = {}; } } diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 24544287f..58da321ea 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -854,15 +854,15 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput) } auto const p = &ps[myconnectindex]; - + bool const rrraVehicle = isRRRA() && (p->OnMotorcycle || p->OnBoat); double const scaleAdjust = InputScale(); InputPacket input{}; - if (isRRRA() && (p->OnMotorcycle || p->OnBoat)) + processInputBits(p, hidInput); + + if (rrraVehicle) { - processInputBits(p, hidInput); processVehicleInput(p, hidInput, input, scaleAdjust); - FinalizeInput(myconnectindex, input, true); if (!SyncInput() && p->GetActor()->s.extra > 0) { @@ -871,11 +871,11 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput) } else { - processInputBits(p, hidInput); processMovement(&input, &loc, hidInput, scaleAdjust, p->drink_amt); - FinalizeInput(myconnectindex, input, false); } + FinalizeInput(myconnectindex, input, rrraVehicle); + if (!SyncInput()) { if (p->GetActor()->s.extra > 0) @@ -893,12 +893,9 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput) if (packet) { - auto cos = p->angle.ang.bcos(); - auto sin = p->angle.ang.bsin(); - *packet = loc; - packet->fvel = mulscale9(loc.fvel, cos) + mulscale9(loc.svel, sin) + p->fric.x; - packet->svel = mulscale9(loc.fvel, sin) - mulscale9(loc.svel, cos) + p->fric.y; + packet->fvel = mulscale9(loc.fvel, p->angle.ang.bcos()) + mulscale9(loc.svel, p->angle.ang.bsin()) + p->fric.x; + packet->svel = mulscale9(loc.fvel, p->angle.ang.bsin()) - mulscale9(loc.svel, p->angle.ang.bcos()) + p->fric.y; loc = {}; } } diff --git a/source/sw/src/input.cpp b/source/sw/src/input.cpp index 5b8461d2e..c60be4e2e 100644 --- a/source/sw/src/input.cpp +++ b/source/sw/src/input.cpp @@ -231,14 +231,9 @@ void GameInterface::GetInput(InputPacket *packet, ControlInfo* const hidInput) if (packet) { - auto const cos = pp->angle.ang.bcos(); - auto const sin = pp->angle.ang.bsin(); - *packet = loc; - - packet->fvel = mulscale9(loc.fvel, cos) + mulscale9(loc.svel, sin); - packet->svel = mulscale9(loc.fvel, sin) - mulscale9(loc.svel, cos); - + packet->fvel = mulscale9(loc.fvel, pp->angle.ang.bcos()) + mulscale9(loc.svel, pp->angle.ang.bsin()); + packet->svel = mulscale9(loc.fvel, pp->angle.ang.bsin()) - mulscale9(loc.svel, pp->angle.ang.bcos()); loc = {}; } }