From a3e09ee5cc6c7b4ea03edba1e412bb2498323083 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Mon, 1 Apr 2024 15:18:15 -0400 Subject: [PATCH] Fix game not loading if save data is not found --- src/battle-scene.ts | 2 -- src/phases.ts | 49 +---------------------------------------- src/system/game-data.ts | 4 ++++ 3 files changed, 5 insertions(+), 50 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 924dcc0d7b3..529182a3495 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -685,8 +685,6 @@ export default class BattleScene extends Phaser.Scene { initMoveAnim(Moves.STRUGGLE).then(() => loadMoveAnimAssets(this, [ Moves.STRUGGLE ], true)) ]).then(() => { this.pushPhase(new LoginPhase(this)); - if (!bypassLogin) - this.pushPhase(new ConsolidateDataPhase(this)); // TODO: Remove this.pushPhase(new TitlePhase(this)); this.shiftPhase(); diff --git a/src/phases.ts b/src/phases.ts index 71961de1bb3..34b995ab306 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -92,7 +92,7 @@ export class LoginPhase extends Phase { buttonActions: [ () => { this.scene.ui.playSelect(); - loadData(); + updateUserInfo().then(() => this.end()); }, () => { this.scene.unshiftPhase(new LoginPhase(this.scene, false)); this.end(); @@ -300,53 +300,6 @@ export class TitlePhase extends Phase { } } -// TODO: Remove -export class ConsolidateDataPhase extends Phase { - start(): void { - super.start(); - - Utils.apiFetch(`savedata/get?datatype=${GameDataType.SYSTEM}`) - .then(response => response.text()) - .then(response => { - if (!response.length || response[0] !== '{') { - console.log('System data not found: Loading legacy local system data'); - - const systemDataStr = atob(localStorage.getItem('data')); - - Utils.apiPost(`savedata/update?datatype=${GameDataType.SYSTEM}`, systemDataStr) - .then(response => response.text()) - .then(error => { - if (error) { - console.error(error); - return this.end(); - } - - Utils.apiFetch(`savedata/get?datatype=${GameDataType.SESSION}`) - .then(response => response.text()) - .then(response => { - if (!response.length || response[0] !== '{') { - console.log('Session data not found: Loading legacy local session data'); - - const sessionDataStr = atob(localStorage.getItem('sessionData')); - - Utils.apiPost(`savedata/update?datatype=${GameDataType.SESSION}`, sessionDataStr) - .then(response => response.text()) - .then(error => { - if (error) - console.error(error); - - window.location = window.location; - }); - } else - window.location = window.location; - }); - }); - } else - this.end(); - }); - } -} - export class SelectGenderPhase extends Phase { constructor(scene: BattleScene) { super(scene); diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 0142b197d4b..2591eb9a8d3 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -354,6 +354,10 @@ export class GameData { .then(response => response.text()) .then(response => { if (!response.length || response[0] !== '{') { + if (response.startsWith('failed to read save file')) { + this.scene.queueMessage('Save data could not be found. If this is a new account, you can safely ignore this message.', null, true); + return resolve(true); + } console.error(response); return resolve(false); }