From 77a636509bf3b2a429f18bcae0615b898aa7321b Mon Sep 17 00:00:00 2001 From: Misa Date: Mon, 28 Sep 2020 12:07:08 -0700 Subject: [PATCH] Remove duplicate onroof/onground assignment for vertical moving plats The onroof/onground attributes are used to determine if the player is standing on a surface and is eligible to flip. Most notably, it is an integer and not a boolean, and it starts at 2, giving the player 2 frames to edge-flip, i.e. they can still flip 2 frames after walking off an edge. However, these attributes are unnecessarily reassigned in movingplatformfix() (which is the function that deals exclusively with vertically-moving platforms; horizontal moving platforms get their own hormovingplatformfix()). Whoever wrote this misunderstood what onroof/onground meant; they thought that they were booleans, and so set them to true, instead of the proper value of 2. This ends up setting onroof/onground to 1 instead of 2, causing a discrepancy with vertical moving platforms and the rest of the surfaces in the game. The bigger mistake here is duplicating code that never needed to be duplicated. The onroof/onground assignment in gamelogic() works perfectly fine for vertical moving platforms. Indeed, after testing it with libTAS, I can confirm that removing the duplicate assignments restores being able to edge-flip off of moving platforms with 2 frames of leeway, instead of only 1 frame. It also doesn't change how long it takes for the onroof/onground to get set when the player is recognized as standing on a vertically-moving platform, either. And so, it's better to not duplicate this code, because when you duplicate it you run the risk of making a mistake, as I just demonstrated. --- desktop_version/src/Entity.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index 97dde6b9..b3dc641e 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -4473,13 +4473,11 @@ void entityclass::movingplatformfix( int t, int j ) { entities[j].yp = entities[t].yp + entities[t].h; entities[j].vy = 0; - entities[j].onroof = true; } else { entities[j].yp = entities[t].yp - entities[j].h-entities[j].cy; entities[j].vy = 0; - entities[j].onground = true; } } else