From 0f01ac3ceb01876660cc00e404a917ddf451aa25 Mon Sep 17 00:00:00 2001 From: 1jamie Date: Sat, 26 Sep 2026 18:05:27 -0500 Subject: [PATCH] refactor: use modFieldView in field effects and reorder map initialization logic --- src/core/game3/field_effects.lua | 8 +++--- src/core/game3/map.lua | 48 +++++++++++++++----------------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/core/game3/field_effects.lua b/src/core/game3/field_effects.lua index ff5c1525..ebfa00fa 100644 --- a/src/core/game3/field_effects.lua +++ b/src/core/game3/field_effects.lua @@ -305,7 +305,7 @@ function FieldEffects.startFlash(onDone) } table.insert(FieldEffects._anims, anim) -- pokefirered/data/scripts/flash.inc:2 - local FieldView = fieldView() + local FieldView = modFieldView() local levelAnim if FieldView and FieldView.getFlashLevel and FieldView.getFlashLevel() ~= 0 then levelAnim = FieldEffects.animateFlashLevel(FieldView.getFlashLevel(), 0) @@ -1339,7 +1339,7 @@ function FieldEffects.step() end elseif anim.kind == "flash_level" then -- pokefirered/src/field_screen_effect.c:119 - local FieldView = fieldView() + local FieldView = modFieldView() if not FieldView then finished = true elseif anim.state == 2 then @@ -1363,7 +1363,7 @@ function FieldEffects.step() end end elseif anim.kind == "camera_shake" then - local FieldView = fieldView() + local FieldView = modFieldView() if not FieldView then finished = true elseif anim.amp == 0 then @@ -1446,7 +1446,7 @@ function FieldEffects.step() end elseif anim.kind == "deoxys_rock_destroy" then -- pokefirered/src/field_effect.c:3860 DestroyDeoxysRockEffect_* - local FieldView = fieldView() + local FieldView = modFieldView() if anim.state == "shake" then -- Task_DeoxysRockCameraShake (data[7]==0): full amplitude, sign flips -- when data[0] passes 1, i.e. every other frame. diff --git a/src/core/game3/map.lua b/src/core/game3/map.lua index ab10eb12..b2c0b5c2 100644 --- a/src/core/game3/map.lua +++ b/src/core/game3/map.lua @@ -307,29 +307,6 @@ function Map.load(mod, game, mapId, opts) Map.ensureMidLayout(game, mapId, def) Map._def = def Map._currentDef = def - local Player = require("src.core.game3.player") - local curSession = (Runtime and Runtime.getSession and Runtime.getSession()) - or (game and game.session) or session - local onCyclingRoad = Player.isOnCyclingRoad and Player.isOnCyclingRoad(curSession, x, y) - local wasBiking = Player.biking or (curSession and curSession.biking == true) - or (save and save.biking == true) - - -- pokefirered/src/overworld.c:878 GetAdjustedInitialTransitionFlags - local keepBike = false - if wasBiking or onCyclingRoad then - local allowed = def and def.bikingAllowed - if allowed ~= nil then - -- pokefirered/src/overworld.c:948 Overworld_IsBikingAllowed - keepBike = (tonumber(allowed) or 0) ~= 0 - else - local pair = def and (def.pair or (def.midLayout and def.midLayout.pair)) - keepBike = type(pair) == "string" and pair:find("outdoor", 1, true) ~= nil - end - if onCyclingRoad and not (Player.surfing or Player.surfHopping) then - keepBike = true - end - Player.biking = keepBike - end if opts.depth1Connections ~= false then Map.loadNeighborsDepth1(game, def) else @@ -350,6 +327,29 @@ function Map.load(mod, game, mapId, opts) end local session = Runtime.getSession and Runtime.getSession() + local save = game and game.save + local Player = require("src.core.game3.player") + local onCyclingRoad = Player.isOnCyclingRoad and Player.isOnCyclingRoad(session, x, y) + local wasBiking = Player.biking or (session and session.biking == true) + or (save and save.biking == true) + + -- pokefirered/src/overworld.c:878 GetAdjustedInitialTransitionFlags + local keepBike = false + if wasBiking or onCyclingRoad then + local allowed = def and def.bikingAllowed + if allowed ~= nil then + -- pokefirered/src/overworld.c:948 Overworld_IsBikingAllowed + keepBike = (tonumber(allowed) or 0) ~= 0 + else + local pair = def and (def.pair or (def.midLayout and def.midLayout.pair)) + keepBike = type(pair) == "string" and pair:find("outdoor", 1, true) ~= nil + end + if onCyclingRoad and not (Player.surfing or Player.surfHopping) then + keepBike = true + end + Player.biking = keepBike + end + if session then session.map = mapId session.x = x @@ -359,7 +359,6 @@ function Map.load(mod, game, mapId, opts) end -- Keep save.position current for ferry exit / host save without setMap. - local save = game and game.save if save then save.position = save.position or {} save.position.map = mapId @@ -369,7 +368,6 @@ function Map.load(mod, game, mapId, opts) save.biking = keepBike end - local Player = require("src.core.game3.player") if opts.seamless then -- Connection remap (pret LoadMapFromCameraTransition): keep mid-step motion. -- Caller parks one cell before landing and sets target toward landing.