diff --git a/WebVersion/main.js b/WebVersion/main.js index 682501b..ca19e4f 100644 --- a/WebVersion/main.js +++ b/WebVersion/main.js @@ -32,12 +32,12 @@ function patch(view, fileNumber) { var version = readString(view.buffer, 0x00, 0x06); var validVersions = ["G8MJ01" /* JP */, "G8ME01" /* US */, "G8MP01" /* EU */]; if (!validVersions.includes(version)) - return 1 /* InvalidSaveFile */; + return 2 /* WrongSaveFileGameID */; var internalFilename = readString(view.buffer, 0x08, 0x11); if (internalFilename !== 'mariost_save_file') - return 1 /* InvalidSaveFile */; + return 3 /* WrongSaveFileInternalName */; if (fileNumber < 1 || fileNumber > 4) - return 2 /* InvalidFileNumber */; + return 4 /* InvalidFileNumber */; var offsetFile0 = ((fileNumber - 1) * 0x4000) + 0x2040; var offsetFile1 = offsetFile0 + 0x10000; function patchFilesU16(offset, value) { @@ -122,11 +122,19 @@ function displayResult(e) { errorMessage.textContent = ''; return true; } - else if (e === 1 /* InvalidSaveFile */) { + else if (e === 1 /* NotSaveFile */) { errorMessage.textContent = 'The file you specified was not a valid .gci save file'; return false; } - else if (e === 2 /* InvalidFileNumber */) { + else if (e === 2 /* WrongSaveFileGameID */) { + errorMessage.textContent = 'This save file is not for Paper Mario: The Thousand Year Door'; + return false; + } + else if (e === 3 /* WrongSaveFileInternalName */) { + errorMessage.textContent = 'This save file has the wrong internal ID. Please make sure you are using a normal Paper Mario: The Thousand Year Door save file.'; + return false; + } + else if (e === 4 /* InvalidFileNumber */) { // should not happen throw "whoops"; } @@ -135,7 +143,7 @@ function fileSubmitted() { var input = document.querySelector('input#fileupload'); var file = input.files[0]; if (!file.name.endsWith('.gci')) { - if (!displayResult(1 /* InvalidSaveFile */)) + if (!displayResult(1 /* NotSaveFile */)) return; } var fileNumberInput = document.querySelector('select#filenumber'); diff --git a/WebVersion/main.ts b/WebVersion/main.ts index 63f7d5a..915d455 100644 --- a/WebVersion/main.ts +++ b/WebVersion/main.ts @@ -42,7 +42,9 @@ function decodeBinaryData(S: string): ArrayBuffer { const enum PatchErrorCode { Success, - InvalidSaveFile, + NotSaveFile, + WrongSaveFileGameID, + WrongSaveFileInternalName, InvalidFileNumber, } @@ -51,11 +53,11 @@ function patch(view: DataView, fileNumber: number): PatchErrorCode { const validVersions = [GameVersion.JP, GameVersion.US, GameVersion.EU]; if (!validVersions.includes(version)) - return PatchErrorCode.InvalidSaveFile; + return PatchErrorCode.WrongSaveFileGameID; const internalFilename = readString(view.buffer, 0x08, 0x11); if (internalFilename !== 'mariost_save_file') - return PatchErrorCode.InvalidSaveFile; + return PatchErrorCode.WrongSaveFileInternalName; if (fileNumber < 1 || fileNumber > 4) return PatchErrorCode.InvalidFileNumber; @@ -153,9 +155,15 @@ function displayResult(e: PatchErrorCode): boolean { if (e === PatchErrorCode.Success) { errorMessage.textContent = ''; return true; - } else if (e === PatchErrorCode.InvalidSaveFile) { + } else if (e === PatchErrorCode.NotSaveFile) { errorMessage.textContent = 'The file you specified was not a valid .gci save file'; return false; + } else if (e === PatchErrorCode.WrongSaveFileGameID) { + errorMessage.textContent = 'This save file is not for Paper Mario: The Thousand Year Door'; + return false; + } else if (e === PatchErrorCode.WrongSaveFileInternalName) { + errorMessage.textContent = 'This save file has the wrong internal ID. Please make sure you are using a normal Paper Mario: The Thousand Year Door save file.'; + return false; } else if (e === PatchErrorCode.InvalidFileNumber) { // should not happen throw "whoops"; @@ -167,7 +175,7 @@ function fileSubmitted(): void { const file = input.files[0]; if (!file.name.endsWith('.gci')) { - if (!displayResult(PatchErrorCode.InvalidSaveFile)) + if (!displayResult(PatchErrorCode.NotSaveFile)) return; }