From bbe05b0c81d0cd8b0f5d34691c3d048c40b521d3 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 6 Aug 2020 07:25:04 +1000 Subject: [PATCH] - harden `FinalizeInput()` with else blocks on each if statement after checking whether all movement is blocked. Fixes #105. --- source/games/duke/src/input.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 5cbc20985..17deccf69 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -1183,6 +1183,11 @@ static void FinalizeInput(int playerNum, input_t& input, bool vehicle) else loc.fvel = clamp(input.fvel, -(MAXVELMOTO / 8), MAXVELMOTO); } + else + { + loc.fvel = input.fvel = 0; + loc.svel = input.svel = 0; + } if (p->on_crane < 0 && p->newowner == -1) { @@ -1192,11 +1197,19 @@ static void FinalizeInput(int playerNum, input_t& input, bool vehicle) p->one_eighty_count = 0; } } + else + { + loc.q16avel = input.q16avel = 0; + } if (p->newowner == -1 && p->return_to_center <= 0) { loc.q16horz = fix16_clamp(loc.q16horz + input.q16horz, F16(-MAXHORIZVEL), F16(MAXHORIZVEL)); } + else + { + loc.q16horz = input.q16horz = 0; + } } }