From 09ace425f4d4f294f76204d0f3d3c8fc31ad76cd Mon Sep 17 00:00:00 2001 From: thibautbus <310327033+thibautbus@users.noreply.github.com> Date: Sat, 3 Oct 2026 22:29:50 +0200 Subject: [PATCH] Read the Pyramid's floor names and Ever Grande City's fly destinations from the script cache The map name popup prints a Battle Pyramid floor's name through RomText.refIr(), and the region map reads Ever Grande City's two fly destinations by sEverGrandeCityNames' labels, so both follow a text override. --- src/ui/game3/map_name_popup.lua | 2 +- src/ui/game3/rse/region_map.lua | 11 +++++++++-- tests/engine/game3_emerald_pack_text_test.lua | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/ui/game3/map_name_popup.lua b/src/ui/game3/map_name_popup.lua index 7319106b..25648907 100644 --- a/src/ui/game3/map_name_popup.lua +++ b/src/ui/game3/map_name_popup.lua @@ -155,7 +155,7 @@ local function rsePrint() local idx = pyramid.location(sess) == pyramid.LOCATION.TOP and #headers or (tonumber(pyramid.frontier(sess).curChallengeBattleNum) or 0) + 1 local ref = headers[idx] - if ref then name = require("src.core.game3.scripting.text_ir").toPlain(ref.ir) end + if ref then name = require("src.core.game3.scripting.text_ir").toPlain(RomText.refIr(ref)) end elseif sec == rseConstants():id("region_map_sections", "MAPSEC_SECRET_BASE") then -- pokeemerald/src/secret_base.c:735 local sb = R.system("secretBase") diff --git a/src/ui/game3/rse/region_map.lua b/src/ui/game3/rse/region_map.lua index d93cc41d..19b8d157 100644 --- a/src/ui/game3/rse/region_map.lua +++ b/src/ui/game3/rse/region_map.lua @@ -353,14 +353,21 @@ local function newState(opts) end RegionMap.newState = newState +-- pokeemerald/src/region_map.c:349: the name list each multi-name +-- destination points at, which the script cache keys by its label. +local MULTI_NAME_TABLES = { "sEverGrandeCityNames" } + -- pokeemerald/src/region_map.c:1760 function RegionMap.updateFlyText(s) s.flyText = nil if s.mapSecType > TYPE.NONE then - for _, m in ipairs(RegionMap.manifest().multiNameFlyDestinations) do + for i, m in ipairs(RegionMap.manifest().multiNameFlyDestinations) do if s.mapSecId == m.mapSecId then if flagSet(s, m.flag) then - s.flyText = { tall = true, name = s.mapSecName, sub = m.names[s.posWithinMapSec + 1] or "" } + local sub = m.names[s.posWithinMapSec + 1] or "" + local key = MULTI_NAME_TABLES[i] and RomText.key(MULTI_NAME_TABLES[i], s.posWithinMapSec) + if key and RomText.has(key) then sub = RomText.plain(key) end + s.flyText = { tall = true, name = s.mapSecName, sub = sub } end break end diff --git a/tests/engine/game3_emerald_pack_text_test.lua b/tests/engine/game3_emerald_pack_text_test.lua index 62a9433e..c4f3a6fd 100644 --- a/tests/engine/game3_emerald_pack_text_test.lua +++ b/tests/engine/game3_emerald_pack_text_test.lua @@ -72,6 +72,22 @@ check(PyramidBag.description() == "Retourner au jeu", "the bag's return line nam BUNDLE.text.gText_TheField = nil check(PyramidBag.description() == "Retourner the field", "a place missing from the cache keeps the copy") +-- Ever Grande City's fly destinations (pokeemerald/src/region_map.c:343). +local RegionMap = require("src.ui.game3.rse.region_map") +RegionMap.manifest = function() + return { multiNameFlyDestinations = { { names = { "POKéMON LEAGUE", "POKéMON CENTER" }, mapSecId = 5, flag = 2100 } } } +end +local function flySub() + local s = { mapSecType = RegionMap.TYPE.CITY_CANFLY, mapSecId = 5, posWithinMapSec = 1, mapSecName = "EVER GRANDE", + session = { flags = { [2100] = true } } } + RegionMap.updateFlyText(s) + return s.flyText.sub +end +BUNDLE.text = { ["sEverGrandeCityNames[1]"] = ir("CENTRE POKéMON") } +check(flySub() == "CENTRE POKéMON", "a fly destination reads its name from the cache") +BUNDLE.text = {} +check(flySub() == "POKéMON CENTER", "a fly destination missing from the cache keeps the copy") + if failed > 0 then print(failed .. " check(s) failed") os.exit(1)