From 135fa80d1f8e0ba353fc42751ccb56f6e7f7aac0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 15 May 2024 11:33:45 -0300 Subject: [PATCH] offline - fixed continue button --- src/account.ts | 9 ++++----- src/system/game-data.ts | 4 ++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/account.ts b/src/account.ts index 357cd5af4..94c34ae90 100644 --- a/src/account.ts +++ b/src/account.ts @@ -14,11 +14,10 @@ export function updateUserInfo(): Promise<[boolean, integer]> { if (bypassLogin) { loggedInUser = { username: 'Guest', lastSessionSlot: -1 }; let lastSessionSlot = -1; - for (let s = 0; s < 2; s++) { - if (localStorage.getItem(`sessionData${s ? s : ''}_${loggedInUser.username}`)) { - lastSessionSlot = s; - break; - } + // Get last slot saved and checks if it has data to enable continue + const slotId = parseInt(localStorage.getItem('slotId')); + if (localStorage.getItem(`sessionData${slotId ? slotId : ''}_${loggedInUser.username}`)) { + lastSessionSlot = slotId; } loggedInUser.lastSessionSlot = lastSessionSlot; return resolve([ true, 200 ]); diff --git a/src/system/game-data.ts b/src/system/game-data.ts index e7ffd281b..c832d3701 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -751,6 +751,7 @@ export class GameData { return new Promise(resolve => { if (bypassLogin) { localStorage.removeItem(`sessionData${this.scene.sessionSlotId ? this.scene.sessionSlotId : ''}_${loggedInUser.username}`); + updateUserInfo(); // Remove continue on session delete return resolve(true); } @@ -813,6 +814,7 @@ export class GameData { return new Promise<[boolean, boolean]>(resolve => { if (bypassLogin) { localStorage.removeItem(`sessionData${slotId ? slotId : ''}_${loggedInUser.username}`); + updateUserInfo(); // Remove continue on clear return resolve([true, true]); } @@ -925,6 +927,8 @@ export class GameData { }); } else { this.verify().then(success => { + // Last slot saved for continue purposes + localStorage.setItem('slotId', scene.sessionSlotId.toString()); this.scene.ui.savingIcon.hide(); resolve(success); });