fix(player): boot cue/gdi/ccd/mds disc sets whole by default

The EmulatorJS player defaulted to the first file of a multi-file rom, so a
BIN/CUE (or GDI, CloneCD, Alcohol) set booted either the sheet or a single
track alone and never reached the game. Default such sets to the whole-rom
download, which already ships every track with a generated playlist of the
sheets. A remembered per-rom choice still wins. The v1 player reuses the
same helper.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Georges-Antoine Assi
2026-09-27 14:44:20 -04:00
parent 61d0ef332b
commit d4e60af445
3 changed files with 40 additions and 4 deletions

View File

@@ -92,6 +92,32 @@ describe("defaultDisc", () => {
).toBe(ALL_DISCS);
});
it.each(["cue", "gdi", "ccd", "mds", "CUE"])(
"boots every file together when the set has a .%s sheet",
(extension) => {
expect(
defaultDisc([
file(1, `Game.${extension}`),
file(2, "Game (Track 1).bin"),
file(3, "Game (Track 2).bin"),
]),
).toBe(ALL_DISCS);
},
);
it("boots a lone sheet when it is the rom's only file", () => {
expect(defaultDisc([file(1, "Game.cue")])).toBe(1);
});
it("keeps a remembered track over the sheet default", () => {
const cueSet = [file(1, "Game.cue"), file(2, "Game.iso")];
expect(resolveStoredDisc("2", cueSet)).toEqual({ disc: 2, stale: false });
expect(resolveStoredDisc(null, cueSet)).toEqual({
disc: ALL_DISCS,
stale: false,
});
});
it("boots the first file when a multi-file set has no playlist", () => {
expect(defaultDisc(files(3, 4))).toBe(3);
});

View File

@@ -87,10 +87,19 @@ export function selectableDiscFiles<T extends DiscFile>(
return bootableFiles(files).filter((f) => !isM3uFile(f));
}
// A set shipping its own .m3u is a curated multi-disc release, so boot it whole;
// anything else boots one file to avoid pulling hundreds of unused MB.
// Sheets that point at sibling track files, so neither the sheet nor a track
// boots alone (issue #4209). Kept in step with backend/utils/m3u.py.
const DESCRIPTOR_EXTENSIONS: readonly string[] = ["cue", "gdi", "ccd", "mds"];
function isDescriptorFile(file: DiscFile): boolean {
const extension = file.file_name.toLowerCase().split(".").pop() ?? "";
return isM3uFile(file) || DESCRIPTOR_EXTENSIONS.includes(extension);
}
// A set carrying a playlist or disc sheet only boots whole; anything else boots
// one file to avoid pulling hundreds of unused MB.
export function defaultDisc(files: readonly DiscFile[]): DiscSelection {
if (files.length > 1 && files.some(isM3uFile)) return ALL_DISCS;
if (files.length > 1 && files.some(isDescriptorFile)) return ALL_DISCS;
return bootableFiles(files)[0]?.id ?? null;
}

View File

@@ -18,6 +18,7 @@ import storePlaying from "@/stores/playing";
import { type DetailedRom } from "@/stores/roms";
import type { Events } from "@/types/emitter";
import { getSupportedEJSCores } from "@/utils";
import { bootDiscId, defaultDisc } from "@/v2/utils/playerDisc";
import CacheDialog from "@/views/Player/EmulatorJS/CacheDialog.vue";
import Player from "@/views/Player/EmulatorJS/Player.vue";
import { exitEmulatorOnce, installIOSFullscreenShim } from "./utils";
@@ -234,7 +235,7 @@ onMounted(async () => {
selectedDisc.value = storedDiscId;
} else {
if (storedDisc) localStorage.removeItem(`player:${rom.value.id}:disc`);
selectedDisc.value = rom.value.files[0]?.id ?? null;
selectedDisc.value = bootDiscId(defaultDisc(rom.value.files));
}
const storedCore = localStorage.getItem(