diff --git a/src/core/game3/map.lua b/src/core/game3/map.lua index c9cd53a6..05675d02 100644 --- a/src/core/game3/map.lua +++ b/src/core/game3/map.lua @@ -1,5 +1,5 @@ -- Game3 map loader. Owns Sevii enter: player, collision, EventObjects, Space scripts. --- Talk/interact is Field.interact. Do not call host setMap/warpToMapId here — +-- Talk/interact is Field.interact. Do not call host setMap/warpToMapId here: -- MAPSETUP.WARP races ON_FRAME and wipes applymovement tracks (Bill intro). local MapIds = require("src.core.game3.map_ids") @@ -683,13 +683,6 @@ function Map.load(mod, game, mapId, opts) Collision.clear() end - if not opts.seamless then - Map.applyInitialAvatar(session, def, savedAvatar, previousAvatar) - if session then - session._savedAvatar = nil - session.facing = Player.facing - end - end Player.syncSavePosition(game) Map._warmPairs = not opts.seamless or nil @@ -824,6 +817,15 @@ function Map.load(mod, game, mapId, opts) elseif Space and Space.onMapEnter then Space.onMapEnter(mod or Runtime._mod, mapId, game, world) end + -- pokeemerald/src/overworld.c:2172 + if not opts.seamless then + Map.applyInitialAvatar(session, def, savedAvatar, previousAvatar) + if session then + session._savedAvatar = nil + session.facing = Player.facing + end + Player.syncSavePosition(game) + end -- pokeemerald/src/overworld.c:870 if session and not opts.seamless and require("src.core.game3.capabilities").has(session, "tv") and def and require("src.core.game3.dataset").isIndoorMapType(def.mapType) then diff --git a/tests/drivers/em_sky_pillar_exit_2782.lua b/tests/drivers/em_sky_pillar_exit_2782.lua new file mode 100644 index 00000000..e24d8850 --- /dev/null +++ b/tests/drivers/em_sky_pillar_exit_2782.lua @@ -0,0 +1,29 @@ +local F = require("tests.drivers.em_fa_util") +local S = F.new("em_sky_pillar_exit_2782", os.getenv("POKEPORT_SHOT_DIR") or "/tmp/em_sky_pillar_exit_2782") + +return function(game) + if not F.boot(game, S) then return S.finish() end + local Runtime = require("src.core.game3.runtime") + local Player = require("src.core.game3.player") + local Collision = require("src.core.game3.collision") + local session = Runtime.getSession() + if not S.check(session.version == "emerald", "driver runs Emerald") then return S.finish() end + S.check(F.goTo(game, "EM_ROUTE131", 36, 8, "up"), "Route 131 south of Sky Pillar door") + Player.surfing = true + F.settle(game, 30) + F.holdKeys(game, { "up" }, 200, function() return F.map() == "EM_SKY_PILLAR_ENTRANCE" end) + F.settle(game, 300) + if not S.check(F.map() == "EM_SKY_PILLAR_ENTRANCE", "entered Sky Pillar Entrance") then return S.finish() end + S.check(not Player.surfing, "inside on foot") + S.check(S.still(game, "2782_01_inside.png"), "inside screenshot") + F.holdKeys(game, { "down" }, 200, function() return F.map() == "EM_ROUTE131" end) + S.note(("spawn cell %d,%d behavior=%s surfing=%s"):format(Player.cellX, Player.cellY, + tostring(Collision.behavior(Player.cellX, Player.cellY)), tostring(Player.surfing))) + F.settle(game, 300) + S.check(F.map() == "EM_ROUTE131", "exited to Route 131") + S.note(("exit cell %d,%d behavior=%s surfing=%s"):format(Player.cellX, Player.cellY, + tostring(Collision.behavior(Player.cellX, Player.cellY)), tostring(Player.surfing))) + S.check(not Player.surfing, "exit on foot, not surfing") + S.check(S.still(game, "2782_02_exit_route131.png"), "exit screenshot") + S.finish() +end