From 417b7d656dda79ae15cd52439e6512c75199d543 Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 23 May 2021 21:57:59 -0700 Subject: [PATCH] Set newxp/newyp when creating player This fixes a bug where the player's y-position would be incorrect if they loaded a save that was on a conveyor and it was their first time loading in since the game was opened. This is because on the first load, the game creates a new player entity, but on subsequent loads, the game re-uses the player entity. Subsequent loads use mapclass::resetplayer(), which already has the newxp/newyp fix, but as for the first time, the game does not set newxp/newyp. So just set newxp/newyp, like in mapclass::resetplayer(). --- desktop_version/src/Entity.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index c7cb1fc7..b36797e7 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -1273,6 +1273,10 @@ void entityclass::createentity(int xp, int yp, int t, int meta1, int meta2, int entity.h = 21; entity.dir = 1; + /* Fix wrong y-position if spawning in on conveyor */ + entity.newxp = xp; + entity.newyp = yp; + if (meta1 == 1) entity.invis = true; entity.gravity = true;