Fix game not loading if save data is not found
parent
e6c7f5dc77
commit
a3e09ee5cc
|
@ -685,8 +685,6 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
initMoveAnim(Moves.STRUGGLE).then(() => loadMoveAnimAssets(this, [ Moves.STRUGGLE ], true))
|
initMoveAnim(Moves.STRUGGLE).then(() => loadMoveAnimAssets(this, [ Moves.STRUGGLE ], true))
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
this.pushPhase(new LoginPhase(this));
|
this.pushPhase(new LoginPhase(this));
|
||||||
if (!bypassLogin)
|
|
||||||
this.pushPhase(new ConsolidateDataPhase(this)); // TODO: Remove
|
|
||||||
this.pushPhase(new TitlePhase(this));
|
this.pushPhase(new TitlePhase(this));
|
||||||
|
|
||||||
this.shiftPhase();
|
this.shiftPhase();
|
||||||
|
|
|
@ -92,7 +92,7 @@ export class LoginPhase extends Phase {
|
||||||
buttonActions: [
|
buttonActions: [
|
||||||
() => {
|
() => {
|
||||||
this.scene.ui.playSelect();
|
this.scene.ui.playSelect();
|
||||||
loadData();
|
updateUserInfo().then(() => this.end());
|
||||||
}, () => {
|
}, () => {
|
||||||
this.scene.unshiftPhase(new LoginPhase(this.scene, false));
|
this.scene.unshiftPhase(new LoginPhase(this.scene, false));
|
||||||
this.end();
|
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 {
|
export class SelectGenderPhase extends Phase {
|
||||||
constructor(scene: BattleScene) {
|
constructor(scene: BattleScene) {
|
||||||
super(scene);
|
super(scene);
|
||||||
|
|
|
@ -354,6 +354,10 @@ export class GameData {
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.length || response[0] !== '{') {
|
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);
|
console.error(response);
|
||||||
return resolve(false);
|
return resolve(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue