The Mods tab order decides code sites too, conflicts show per mod, and each mod can be used without its code

Load order: mods_exefs_apply ranks each mod's patch sets by its position (rt_patch_rank) and runtime/patches.c fills
the pick byte of every contested site from the sets that are on, lowest rank first; a tie (two files of one mod)
goes to the later file, as emulators apply a mod's files in name order. Reorder and restart, no rebuild. The pick is
redone when an ordered set is switched at run time. Nothing changes for sites one set patches.

Conflicts: one table (mods_conflict) of winner, loser, part (files, data bytes, code sites) and count. romfs.c fills
it for files, mods_exefs_apply for the data bytes two mods stored and for the contested code sites. The log has both
directions per entry and one line per contested code site; each row of the Mods tab lists what the mod overrides and
what overrides it.

Use without its code: a per-mod switch under the row of a mod with a code module or an ExeFS patch file the port
cannot apply (mods_no_code in totk.ini, off by default). On, that code is left out and the rest of the mod is used;
the row says what is left out and why. mods_without_code = 1 holds it on for every mod and now covers the
unsupported patch files too.

--probe-mods: order to winner at contested sites in both orders, the same-mod tie, a switched-off mod, a run-time
switch of the winner, the conflict table for data and code, the per-mod switch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-11-16 20:11:43 +03:00
1 parent 4d2e29aa79
commit 873903d98f
14 files changed
+650 -127

No files matched your search

+38 -10
View File
@@ -1241,10 +1241,26 @@ static void tab_mods(float scale) {
const char *after = mods_changed() ? menu_text(UI_MENU_AFTER_RESTART) : nullptr;
for (int i = 0; i < n; i++) {
const ModInfo *m = mods_at(i);
char id[32], desc[1536];
char id[32], desc[4096];
snprintf(id, sizeof id, "##mod%d", i);
char over[512] = "", other[512] = "";
if (m->overridden) snprintf(over, sizeof over, menu_text(UI_MENU_MODS_OVERRIDDEN), m->overridden, m->overridden_by);
char over[2048] = "", other[512] = "";
// what it won or lost to another mod, files, data and code alike (the conflict table, as at start)
static const UiTextId lost[MOD_PARTS] = {UI_MENU_MODS_OVERRIDDEN, UI_MENU_MODS_DATA_OVERRIDDEN,
UI_MENU_MODS_CODE_OVERRIDDEN},
won[MOD_PARTS] = {UI_MENU_MODS_OVERRIDES_FILES, UI_MENU_MODS_OVERRIDES_DATA,
UI_MENU_MODS_OVERRIDES_CODE};
for (int c = 0; c < mods_conflict_count(); c++) {
const ModConflict *e = mods_conflict_at(c);
bool lose = e->loser == m->id;
if (!lose && e->winner != m->id) continue;
const ModInfo *them = mods_by_id(lose ? e->winner : e->loser);
if (!them) continue;
size_t at = strlen(over);
if (at) at += (size_t)snprintf(over + at, sizeof over - at, "\n\n");
if (at < sizeof over)
snprintf(over + at, sizeof over - at, menu_text(lose ? lost[e->part] : won[e->part]), e->count,
them->name);
}
if (m->other_version) snprintf(other, sizeof other, menu_text(UI_MENU_MODS_OTHER_VERSION), m->other_version);
char cheat[256] = "";
if (m->kind & MOD_CHEATS) { // its cheats as read at start, or the file they come from
@@ -1254,9 +1270,11 @@ static void tab_mods(float scale) {
if (count) snprintf(cheat, sizeof cheat, menu_text(UI_MENU_MODS_CHEATS), count);
else snprintf(cheat, sizeof cheat, menu_text(UI_MENU_MODS_CHEATS_FILE), cheats_file());
}
char code[512] = "", problem[512] = "", skipped[512] = "";
if (m->code[0] && m->problem != MOD_PLUGIN) // used without that code (mods_without_code = 1)
char code[512] = "", problem[512] = "", skipped[512] = "", left[512] = "";
if (m->code[0] && m->problem != MOD_PLUGIN) // used without its code
snprintf(skipped, sizeof skipped, menu_text(UI_MENU_MODS_CODE_SKIPPED), m->code);
if (m->unsupported && m->problem != MOD_EXEFS_UNSUPPORTED)
snprintf(left, sizeof left, menu_text(UI_MENU_MODS_EXEFS_SKIPPED), m->unsupported, m->note);
if (m->nsets && m->overrides[0])
snprintf(code, sizeof code, menu_text(UI_MENU_MODS_REPLACES_BUILTIN), m->nsets, m->overrides);
else if (m->nsets || m->ndata)
@@ -1273,7 +1291,7 @@ static void tab_mods(float scale) {
default: break;
}
int k = snprintf(desc, sizeof desc, menu_text(UI_MENU_MODS_ROW_DESC), m->replaced, m->added);
const char *parts[] = {over, other, cheat, code, skipped, problem, menu_text(UI_MENU_MODS_MOVE_HINT)};
const char *parts[] = {over, other, cheat, code, skipped, left, problem, menu_text(UI_MENU_MODS_MOVE_HINT)};
for (const char *part : parts)
if (*part && k >= 0 && k < (int)sizeof desc) k += snprintf(desc + k, sizeof desc - k, "\n\n%s", part);
const char *note = m->enabled && m->problem != MOD_OK ? menu_text(UI_MENU_MODS_UNUSED) : after;
@@ -1287,12 +1305,22 @@ static void tab_mods(float scale) {
snprintf(id, sizeof id, "##mod%d", to);
opt_focus_key(id); // the cursor follows the mod
opt_save_soon();
continue; // m is the moved mod's neighbour now; its switch row comes next frame
}
// under a mod with code the port cannot run (a code module, an ExeFS patch file it cannot apply): its switch
// "use without its code"; mods_without_code = 1 holds it on for every mod
if (m->code[0] || m->unsupported) {
char nid[32], label[320];
snprintf(nid, sizeof nid, "##modnc%d", i);
snprintf(label, sizeof label, menu_text(UI_MENU_MODS_WITHOUT_CODE), m->name);
bool all = cfg_bool("TOTK_MODS_WITHOUT_CODE") != 0;
if (all) opt_disable_next(UI_MENU_MODS_WITHOUT_CODE_ALL);
if (opt_toggle_text(nid, label, menu_text(UI_MENU_MODS_WITHOUT_CODE_DESC), all || m->no_code) && !all) {
mods_set_no_code(i, !m->no_code);
opt_save_soon();
}
}
}
// The switch for mods with their own code shows once a mod with a code module is there (or the switch is on)
bool code_mods = cfg_bool("TOTK_MODS_WITHOUT_CODE");
for (int i = 0; i < n && !code_mods; i++) code_mods = mods_at(i)->code[0] != 0;
if (code_mods) opt_toggle("TOTK_MODS_WITHOUT_CODE", UI_MENU_MODS_WITHOUT_CODE, UI_MENU_MODS_WITHOUT_CODE_DESC);
bool rebuild =
cheats_rebuild_pending() && opt_button("##restart", UI_MENU_CHEATS_REBUILD, UI_MENU_CHEATS_REBUILD_DESC);
static uint64_t open_failed; // plat_now_ns until which the button says it failed