diff --git a/data/GameManager.js b/data/GameManager.js index 31dbfac..19f3d77 100644 --- a/data/GameManager.js +++ b/data/GameManager.js @@ -157,15 +157,17 @@ class EJS_GameManager { } createCueFile(fileNames) { try { - fileNames = fileNames.filter((item) => { - return ["toc", "ccd", "exe", "pbp", "chd", "img", "bin"].includes(item.split(".").pop().toLowerCase()); - }) - fileNames = fileNames.sort((a, b) => { - if (isNaN(a.charAt()) || isNaN(b.charAt())) throw new Error("Incorrect file name format"); - return (parseInt(a.charAt()) > parseInt(b.charAt())) ? 1 : -1; - }) + if (fileNames.length > 1) { + fileNames = fileNames.filter((item) => { + return ["toc", "ccd", "exe", "pbp", "chd", "img", "bin"].includes(item.split(".").pop().toLowerCase()); + }) + fileNames = fileNames.sort((a, b) => { + if (isNaN(a.charAt()) || isNaN(b.charAt())) throw new Error("Incorrect file name format"); + return (parseInt(a.charAt()) > parseInt(b.charAt())) ? 1 : -1; + }) + } } catch(e) { - console.log(fileNames); + console.log(e, fileNames); if (fileNames.length > 1) { console.warn("Could not auto-create cue file(s)."); return null; diff --git a/data/emulator.js b/data/emulator.js index ed35942..93afac9 100644 --- a/data/emulator.js +++ b/data/emulator.js @@ -626,24 +626,26 @@ class EmulatorJS { return; } this.checkCompression(new Uint8Array(data), this.localization("Decompress Game Data")).then((data) => { + const altName = this.config.gameUrl.startsWith("blob:") ? this.config.gameName || "game" : this.config.gameUrl.split('/').pop().split("#")[0].split("?")[0]; const fileNames = (() => { let rv = []; for (const k in data) rv.push(k); return rv; })(); + if (fileNames.length === 1) fileNames[0] = altName; let execFile = null; if (this.getCore(true) === "psx") { execFile = this.gameManager.createCueFile(fileNames); } for (const k in data) { if (k === "!!notCompressedData") { - const fileName = this.config.gameUrl.startsWith("blob:") ? this.config.gameName || "game" : this.config.gameUrl.split('/').pop().split("#")[0].split("?")[0]; + if (this.getCore(true) === "psx" && execFile !== null) { this.fileName = execFile; } else { - this.fileName = fileName; + this.fileName = altName; } - FS.writeFile(fileName, data[k]); + FS.writeFile(altName, data[k]); break; } if (k.endsWith('/')) {