From 8ba1325d0fe5f8b69fa36b27d26450c700cf9543 Mon Sep 17 00:00:00 2001 From: Misa Date: Wed, 22 Dec 2021 00:25:19 -0800 Subject: [PATCH] Fix regression with wall stuck flipping behavior exactly reversed The reason why the wall stuck flipping behavior happened in the first place was because the code went like this: if (jumppressed) { if (onground && gravitycontrol == 0) { gravitycontrol = 1; } if (onroof && gravitycontrol == 1) { gravitycontrol = 0; } } Basically, if you were both on ground and on a roof (i.e. stuck in a wall), you would flip, but then due to code order and the fact that the statement is not connected to the previous one, you would immediately unflip afterwards. But if you were already flipped then the only path that can be taken is to unflip you, since it's the statement that appears last. 52fceb3f69a66128766213dc3fe2915710df1bf7 replaces the onground/onroof conditionals with any_onground/any_onroof, so any player entity would allow you to flip. But otherwise the code is the same. So is that the problem? No; tracing it through with GDB reveals that when you flip, gravitycontrol is being set to 1, but never being set to 0. And it turns out that's because any_onroof is not getting set. And that happens because of another thing that 52fceb3f69a66128766213dc3fe2915710df1bf7 did - which was to set any_onground/any_onroof to true if indeed any player entity was on ground or on a roof. Unfortunately, the way Leo did it was to make the two statements mutually exclusive - an 'if'-'else if' instead of two separate statements. So a single entity could not mark both any_onground and any_onroof as true (and the majority of the time, you will be a single entity). Thus, the solution is to just drop that 'else'. Fixes #855. --- desktop_version/src/Input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 779ec718..25538d53 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -2198,7 +2198,7 @@ void gameinput(void) { any_onground = true; } - else if (obj.entities[ie].onroof > 0) + if (obj.entities[ie].onroof > 0) { any_onroof = true; }