From 2cc0a4eaa6c5a5cb7ef6410f51be6293f113f14f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 10 Nov 2026 14:32:15 -0500 Subject: [PATCH] Serve a mod's file named for another game version under its own name instead of leaving it out A mod file whose name carries Product. and which the RomFS lacks was counted as made for another game version and never served. The game does ask for such names: on 1.4.3 with mods on, the file trace (trace = fs) shows it opening Sound/Resource/Pack_MasterSword.Product.110.bars.zs, while its RomFS holds only the Product.140 and the unversioned file. A sound mod that ships its pack under all those names was silent here and works on a console, where LayeredFS shows the game every file of a mod. Such files are now added overlays like any other new file. Another version's resource size table is still not served and still lends its entries; the files are still counted, and the Mods tab and docs/mods.md now say they are read only when asked for by name. tests/mods_romfs_check.py gets a case for it. Not run here: the test and --probe-fs need a build and the game's files. runtime/romfs.c compiles with llvm-mingw. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01TgQM2zwuVagwScByEJhT8V --- docs/mods.md | 2 +- runtime/mods.h | 5 +++-- runtime/romfs.c | 16 +++++++++++++--- runtime/ui_text.c | 18 +++++++++++------- runtime/ui_text.h | 2 +- tests/mods_romfs_check.py | 4 +++- 6 files changed, 32 insertions(+), 15 deletions(-) diff --git a/docs/mods.md b/docs/mods.md index c384095f..ab2d804f 100644 --- a/docs/mods.md +++ b/docs/mods.md @@ -111,7 +111,7 @@ keeps its textures at a quarter of the size. | On the Mods tab | Why | What to do | |---|---|---| | This folder has no romfs, exefs or cheats files. | The archive was unpacked one level too deep (`mods\Mod\Mod\romfs`), or it holds no game files. | Move the folders up so `romfs` sits directly in the mod's folder. | -| ... files are made for another game version and are left out. | The mod's files carry another update's version in their names (`.Product..`). | Download the mod's release for your game update. | +| ... files carry another game version in their names. | The files are named for another update (`.Product..`) and the game's own files have no such name. They are still served under those names, as on a console, because the game sometimes asks for one; another update's resource size table is the exception and only lends its entries. | Nothing if the mod works. If it does nothing, download its release for your game update. | | Its code patches (exefs) are made for another game version. | The patch files name another update's build id. | Same: get the release for your update. | | This mod brings its own game code (a subsdk plugin or a replaced main). | Mods such as UltraCam ship compiled Switch code. The port cannot load it. | No workaround; the whole mod stays off. | | This mod patches the game code (exefs) in a way the port cannot apply. | The patch writes the game's data, not its code, or changes code in a form the port cannot build. | No workaround; the reason follows on the row. | diff --git a/runtime/mods.h b/runtime/mods.h index 345fcc2b..8992c080 100644 --- a/runtime/mods.h +++ b/runtime/mods.h @@ -30,8 +30,9 @@ typedef struct { int kind, enabled; ModProblem problem; uint32_t replaced, added, overridden; // romfs.c: files served (replacing / added), files a higher mod serves - uint32_t other_version; // files for another game version (RomFS *.Product..*, ExeFS patches - // for another build), not used + uint32_t other_version; // files named for another game version: RomFS *.Product..* the RomFS + // lacks (served under their own names; another version's size table is + // not) and ExeFS patches for another build (not used) char overridden_by[256]; // the first higher mod that took one of its files char note[256]; // MOD_EXEFS_UNSUPPORTED: why uint32_t pending, pending_key; // ExeFS patch files the build lacks; FNV-1a of their names and contents diff --git a/runtime/romfs.c b/runtime/romfs.c index 3196f7ee..5f2d1372 100644 --- a/runtime/romfs.c +++ b/runtime/romfs.c @@ -340,7 +340,8 @@ static void overlay_push(Overlay o) { } // 1 when path names a file of one game version only (Product. in a name: the resource size table, the actor -// database and other version-bound files); the RomFS lacking it means it is another version's. +// database and other version-bound files); the RomFS lacking it means it is another version's, or a name this version +// still asks for (mod_walk_cb). static int other_version(const char *path) { for (const char *p = strstr(path, ".Product."); p; p = strstr(p + 1, ".Product.")) { const char *d = p + strlen(".Product."); @@ -420,9 +421,18 @@ static int mod_walk_cb(const char *leaf, int kind, uint64_t size, void *ctx) { } uint64_t i = index_any_case(path); if (i == UINT64_MAX && other_version(path)) { - if (is_restbl(path)) shipped_add(file, w->k + 1, 1); // its entries for this mod's files still apply m->other_version++; - return 1; + // Another version's resource size table is no file this game opens; its entries for this mod's files still + // apply. + if (is_restbl(path)) { + shipped_add(file, w->k + 1, 1); + return 1; + } + // Any other file is served under its own name below, as an added file, the way LayeredFS shows a console every + // file of a mod: the game does ask for names its RomFS lacks. Measured on 1.4.3 with mods on (trace = fs): it + // opened Sound/Resource/Pack_MasterSword.Product.110.bars.zs, where its RomFS holds Product.140 and the + // unversioned file only. A sound mod that ships its pack under all those names stayed silent while this file + // was left out. } PlatFile *f = open_read(file); if (!f) { diff --git a/runtime/ui_text.c b/runtime/ui_text.c index 690383b7..315db2d3 100644 --- a/runtime/ui_text.c +++ b/runtime/ui_text.c @@ -218,8 +218,9 @@ static const char *const text_en[UI_TEXT_COUNT] = { [UI_MENU_MODS_CHEATS] = "Cheats: %d. Switch them on the Cheats tab.", [UI_MENU_MODS_CHEATS_FILE] = "Cheats for this game version are read at start from cheats\\%s in this mod.", [UI_MENU_MODS_BAD_NAME] = "The folder name contains |, which the mod list uses between names. Rename the folder.", - [UI_MENU_MODS_OTHER_VERSION] = "%u of its files are made for another game version and are left out. Look for a " - "version of this mod made for your game version.", + [UI_MENU_MODS_OTHER_VERSION] = "%u of its files carry another game version in their names. The game reads them only " + "where something asks for those names. If the mod does nothing, look for a version " + "of it made for your game version.", [UI_MENU_MODS_UNUSED] = "not used", [UI_MENU_MODS_FPS60] = "60 FPS patch", [UI_MENU_MODS_FPS60_DESC] = "The port's own patch for 60 frames per second. Set it with Frame rate limit on the " @@ -699,8 +700,9 @@ static const char *const text_ru[UI_TEXT_COUNT] = { [UI_MENU_MODS_CHEATS] = "Читов: %d. Они включаются на вкладке «Читы».", [UI_MENU_MODS_CHEATS_FILE] = "Читы для этой версии игры читаются при запуске из cheats\\%s в этом моде.", [UI_MENU_MODS_BAD_NAME] = "В имени папки есть символ |, которым список модов разделяет имена. Переименуйте папку.", - [UI_MENU_MODS_OTHER_VERSION] = "Файлов для другой версии игры: %u, они пропущены. Поищите версию этого мода для " - "вашей версии игры.", + [UI_MENU_MODS_OTHER_VERSION] = "Файлов с другой версией игры в имени: %u. Игра читает их, только когда что-то " + "запрашивает эти имена. Если мод не работает, поищите его версию для вашей версии " + "игры.", [UI_MENU_MODS_UNUSED] = "не используется", [UI_MENU_MODS_FPS60] = "Патч 60 FPS", [UI_MENU_MODS_FPS60_DESC] = "Собственный патч порта для 60 кадров в секунду. Настраивается «Ограничением частоты " @@ -1029,8 +1031,9 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = { [UI_MENU_MODS_CHEATS] = "Cheats: %d. Ligue-os na aba Cheats.", [UI_MENU_MODS_CHEATS_FILE] = "Os cheats desta versão do jogo são lidos ao iniciar de cheats\\%s neste mod.", [UI_MENU_MODS_BAD_NAME] = "O nome da pasta contém |, que a lista de mods usa entre os nomes. Renomeie a pasta.", - [UI_MENU_MODS_OTHER_VERSION] = "%u dos seus arquivos são de outra versão do jogo e ficam de fora. Procure uma versão " - "deste mod feita para a sua versão do jogo.", + [UI_MENU_MODS_OTHER_VERSION] = "%u dos seus arquivos trazem outra versão do jogo no nome. O jogo só os lê quando algo " + "pede esses nomes. Se o mod não fizer nada, procure uma versão dele feita para a sua " + "versão do jogo.", [UI_MENU_MODS_UNUSED] = "não usado", [UI_MENU_MODS_FPS60] = "Patch de 60 FPS", [UI_MENU_MODS_FPS60_DESC] = "O patch do próprio port para 60 quadros por segundo. Ajuste em Limite de quadros na aba " @@ -1552,7 +1555,8 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = { [UI_MENU_MODS_CHEATS] = "金手指:%d 个。在“金手指”标签页中开关。", [UI_MENU_MODS_CHEATS_FILE] = "此游戏版本的金手指在启动时从此模组的 cheats\\%s 读取。", [UI_MENU_MODS_BAD_NAME] = "文件夹名称含有 |,模组列表用它分隔名称。请重命名该文件夹。", - [UI_MENU_MODS_OTHER_VERSION] = "它有 %u 个文件是为其他游戏版本制作的,已被跳过。请寻找适用于你的游戏版本的此模组。", + [UI_MENU_MODS_OTHER_VERSION] = "它有 %u 个文件的文件名带有其他游戏版本号。只有在有内容请求这些文件名时,游戏才会读取它们。" + "如果模组不起作用,请寻找适用于你的游戏版本的此模组。", [UI_MENU_MODS_UNUSED] = "未使用", [UI_MENU_MODS_FPS60] = "60 FPS 补丁", [UI_MENU_MODS_FPS60_DESC] = "移植版自带的 60 帧补丁。在“游戏”页的帧率上限中设置。", diff --git a/runtime/ui_text.h b/runtime/ui_text.h index 3bed8949..222b6185 100644 --- a/runtime/ui_text.h +++ b/runtime/ui_text.h @@ -88,7 +88,7 @@ typedef enum { UI_MENU_MODS_EXEFS_OTHER, UI_MENU_MODS_EXEFS_ON, // printf: its ExeFS patch files in use UI_MENU_MODS_REPLACES_BUILTIN, // printf: its ExeFS patch files in use, the port's own patch sets they turn off - UI_MENU_MODS_OTHER_VERSION, // printf: files made for another game version, left out + UI_MENU_MODS_OTHER_VERSION, // printf: files named for another game version, read only when asked for by name UI_MENU_MODS_UNUSED, // under the switch of a mod the port cannot use UI_MENU_MODS_CHEATS, // printf: its cheats as read at start UI_MENU_MODS_CHEATS_FILE, // printf: .txt, when none were read diff --git a/tests/mods_romfs_check.py b/tests/mods_romfs_check.py index c3eb5b1b..4ae2e062 100644 --- a/tests/mods_romfs_check.py +++ b/tests/mods_romfs_check.py @@ -152,13 +152,15 @@ def main(): put(mods, UNI, p2, b'mod-G') # a file of another game version's (no RomFS has a Product.999 table): counted, never served put(mods, 'Low', 'System/Resource/ResourceSizeTable.Product.999.rsizetable.zs', b'mod-H') + # any other file named for another version: counted, and served under its name as an added file + put(mods, 'Case', 'Sound/Resource/Named.Product.999.bars', b'mod-J') put(mods, 'Lite', 'Lite/added.bin', b'mod-I', part='romfslite') # TKMM's romfslite folder code, log = run(args.exe, mods, f'Top|Low|{UNI}|Case') check(code == 0, 'probe-fs passes with five mods (served bytes equal the winners\' files)', log) for line in ('mods: Top: 2 files served (1 replaced, 1 added), 0 overridden', 'mods: Low: 1 files served (1 replaced, 0 added), 2 overridden by Top, 1 for another game version', - 'mods: Case: 0 files served (0 replaced, 0 added), 1 overridden by Top', + 'mods: Case: 1 files served (0 replaced, 1 added), 1 overridden by Top, 1 for another game version', f'mods: {UNI}: 0 files served (0 replaced, 0 added), 1 overridden by Low', 'mods: Lite: 1 files served (0 replaced, 1 added), 0 overridden'): check(line in log, line, log)