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,6 +157,7 @@ class EJS_GameManager {
}
createCueFile(fileNames) {
try {
if (fileNames.length > 1) {
fileNames = fileNames.filter((item) => {
return ["toc", "ccd", "exe", "pbp", "chd", "img", "bin"].includes(item.split(".").pop().toLowerCase());
})
@ -164,8 +165,9 @@ class EJS_GameManager {
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;

View file

@ -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('/')) {