Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public static void main(String[] args) throws Exception {
check(pk.variantReady("60") && new File(pack, "60/romfs").equals(pk.variantRomfs("60")), "ready, with its overlay: " + pk.variantRomfs("60"));
check(pk.variantRomfs("evil") == null && pk.variantRomfs("none") == null && pk.variantRomfs("gone") == null, "never outside the pack, '-' is none");
check(!pk.variantReady("43") && !pk.variantReady(null), "no row: not ready");
check(pk.variantOriginals("60") == null && pk.variantOriginals("none") == null, "an older pack: no originals to merge a mod's copy against");
check(new File(pack, "60/romfs-orig").mkdirs() && new File(pack, "60/romfs-orig").equals(pk.variantOriginals("60")), "the originals beside the overlay: " + pk.variantOriginals("60"));
Files.write(new File(pack, "pack.tsv").toPath(), head.getBytes(StandardCharsets.UTF_8));
check(!Pack.read(pack).variantReady("60"), "a pack without the row (another version, an older pack) is not ready though its 60/main is there");
System.out.println("ok");
Expand Down
285 changes: 285 additions & 0 deletions android/app/src/jvmtest/java/dev/peanuts/mods/VariantMergeJvmTest.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,12 @@ private void start() {
if (fpsRomfs != null) {
String chain = null;
for (String kv : env) if (kv.startsWith(SceneRes.ENV + "=")) chain = kv.substring(SceneRes.ENV.length() + 1); // the line in force so far (the mods' or the scene's): kept after it
env.add(SceneRes.ENV + "=" + fpsRomfs.getPath() + (chain != null && !chain.isEmpty() ? ":" + chain : ""));
// PEANUTS: the enabled mods' copies of the variant's files, merged into the variant's (VariantMerge), ahead of it: else the variant's copy hid the mod's whole file
dev.peanuts.mods.VariantMerge.Result merged = dev.peanuts.mods.VariantMerge.merge(fpsRomfs, pack.variantOriginals(fpsVariantAtStart),
dev.peanuts.mods.ModRuntime.romfsDirs(game.isDirectory() ? game : game.getParentFile(), id, packDir),
new File(getFilesDir(), "mods_stage/" + id.toUpperCase(java.util.Locale.ROOT) + "/variant-romfs"), fpsVariantAtStart);
for (String n : merged.notes) if (!quietNotes.contains(n)) quietNotes.add(n);
env.add(SceneRes.ENV + "=" + (merged.root != null ? merged.root.getPath() + ":" : "") + fpsRomfs.getPath() + (chain != null && !chain.isEmpty() ? ":" + chain : ""));
}
String modCheats = dev.peanuts.mods.ModRuntime.cheatsEnv(this, game.isDirectory() ? game : game.getParentFile(), id, packDir); // PEANUTS: mods beside the game; a code mod's cheats only with its build
if (modCheats != null && !cheatsMerged) env.add(modCheats); // PEANUTS: not beside upstream's own DM_CHEATS, which holds the mods' cheats then (cheatsEnv, ModCheats): the later line won, and the panel listed cheats the host did not run
Expand Down
7 changes: 7 additions & 0 deletions android/app/src/main/java/dev/nxnative/android/Pack.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ File variantRomfs(String name) {
File f = new File(dir, rel);
return f.isDirectory() ? f : null;
}
/** The files the variant's RomFS overlay was made from (pack_android.py variant_overlays: <its folder>-orig), null for none (a pack from before they were kept):
* what an enabled mod's copy of one of its files is merged against at a start (dev.peanuts.mods.VariantMerge) */
File variantOriginals(String name) {
File r = variantRomfs(name);
File f = r == null ? null : new File(r.getParentFile(), r.getName() + "-orig");
return f != null && f.isDirectory() ? f : null;
}
// PEANUTS end
// A pack of program n > 0 of a dump folder (pack_android.py --program; a Switch 2 Edition's program 1, updates/<v>/program/1/): which program, its application (the save and the add-ons
// are the application's) and each program index's RomFS (the host's DM_ROMFS_PROGRAM_<i>: 0 is the game's, the edition mounts it as "conorig"). 0 / "" / empty otherwise
Expand Down
3 changes: 3 additions & 0 deletions android/app/src/main/java/dev/peanuts/mods/ModRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ static List<ModStore.Mod> forStart(File gameHome, String titleId, File packDir)
return ModStore.contributing(mods, ModStore.playsVariant(titleId, ModStore.enabledCodeMods(mods), packDir));
}

/** The enabled mods' romfs folders for a start of packDir, first wins: what a frame rate variant's own files are merged with (VariantMerge) */
public static List<File> romfsDirs(File gameHome, String titleId, File packDir) { return ModStore.enabledRomfsDirs(forStart(gameHome, titleId, packDir)); }

/** As above for a start of packDir (GameActivity.start's pack folder): see {@link #forStart} */
public static String romfsOverlayEnv(Context c, File gameHome, String titleId, File sceneOverlayDirOrNull, File packDir) {
List<File> dirs = ModStore.enabledRomfsDirs(forStart(gameHome, titleId, packDir));
Expand Down
Loading