From 6a6c09f69d4e886124d50e0ee347f1073c356173 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 25 Mar 2021 19:00:31 -0700 Subject: [PATCH] Fix 1-frame flicker entering room with warp lines and entity on edge Custom levels can have warp lines. If you have a warp line and a warping background in the same room, the warp line takes precedence over the warp background. However, whenever you enter a room with a warp line and warp background, any entities on the warping edges will be drawn with screenwrapping for one frame, even though they never wrapped at all. This is due to frame ordering: when the warp line gets created, obj.customwarpmode gets set to true. Then when the screen edges and warping logic gets ran, the very first thing that gets checked is this exact variable, and map.warpx/map.warpy get set appropriately - so there's no way the entity could legitimately screenwrap. However, that happens in gamelogic(). gamelogic() is also the one responsible for creating entities upon room load, but that happens after the obj.customwarpmode check - so when the game gets around to rendering in gamerender(), it sees that map.warpx or map.warpy is on, and draws the screenwrapping, even though map.warpx/map.warpy aren't really on at all. Only when gamelogic() is called in the frame later do map.warpx and map.warpy finally get set to false. To fix this, just set map.warpx and map.warpy to false when creating warp lines. --- desktop_version/src/Entity.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index f02e3584..7b97d0f3 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -1983,6 +1983,8 @@ void entityclass::createentity( float xp, float yp, int t, float vx /*= 0*/, flo if (map.custommode) { customwarpmode = true; + map.warpx = false; + map.warpy = false; } break; case 55: // Crew Member (custom, collectable)