Fix psx cue not correctly generating

This commit is contained in:
Ethan O'Brien 2023-07-08 19:46:06 -05:00
parent c04aef77da
commit ecbdb9b5e4
2 changed files with 15 additions and 11 deletions

View file

@ -157,15 +157,17 @@ class EJS_GameManager {
} }
createCueFile(fileNames) { createCueFile(fileNames) {
try { try {
fileNames = fileNames.filter((item) => { if (fileNames.length > 1) {
return ["toc", "ccd", "exe", "pbp", "chd", "img", "bin"].includes(item.split(".").pop().toLowerCase()); 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"); fileNames = fileNames.sort((a, b) => {
return (parseInt(a.charAt()) > parseInt(b.charAt())) ? 1 : -1; 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) { } catch(e) {
console.log(fileNames); console.log(e, fileNames);
if (fileNames.length > 1) { if (fileNames.length > 1) {
console.warn("Could not auto-create cue file(s)."); console.warn("Could not auto-create cue file(s).");
return null; return null;

View file

@ -626,24 +626,26 @@ class EmulatorJS {
return; return;
} }
this.checkCompression(new Uint8Array(data), this.localization("Decompress Game Data")).then((data) => { 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 = (() => { const fileNames = (() => {
let rv = []; let rv = [];
for (const k in data) rv.push(k); for (const k in data) rv.push(k);
return rv; return rv;
})(); })();
if (fileNames.length === 1) fileNames[0] = altName;
let execFile = null; let execFile = null;
if (this.getCore(true) === "psx") { if (this.getCore(true) === "psx") {
execFile = this.gameManager.createCueFile(fileNames); execFile = this.gameManager.createCueFile(fileNames);
} }
for (const k in data) { for (const k in data) {
if (k === "!!notCompressedData") { 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) { if (this.getCore(true) === "psx" && execFile !== null) {
this.fileName = execFile; this.fileName = execFile;
} else { } else {
this.fileName = fileName; this.fileName = altName;
} }
FS.writeFile(fileName, data[k]); FS.writeFile(altName, data[k]);
break; break;
} }
if (k.endsWith('/')) { if (k.endsWith('/')) {