No longer add slotId to session data

This commit is contained in:
Sirz Benjie 2025-09-07 18:32:25 -05:00
parent 8e647b3a17
commit a233dee89c
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E

View File

@ -139,9 +139,6 @@ export interface SessionSaveData {
* Counts the amount of pokemon fainted in your party during the current arena encounter. * Counts the amount of pokemon fainted in your party during the current arena encounter.
*/ */
playerFaints: number; playerFaints: number;
/** The slot number the session was last saved in */
slotId: number;
} }
interface Unlocks { interface Unlocks {
@ -954,7 +951,6 @@ export class GameData {
mysteryEncounterType: globalScene.currentBattle.mysteryEncounter?.encounterType ?? -1, mysteryEncounterType: globalScene.currentBattle.mysteryEncounter?.encounterType ?? -1,
mysteryEncounterSaveData: globalScene.mysteryEncounterSaveData, mysteryEncounterSaveData: globalScene.mysteryEncounterSaveData,
playerFaints: globalScene.arena.playerFaints, playerFaints: globalScene.arena.playerFaints,
slotId: globalScene.sessionSlotId,
} as SessionSaveData; } as SessionSaveData;
} }
@ -967,7 +963,6 @@ export class GameData {
const handleSessionData = async (sessionDataStr: string) => { const handleSessionData = async (sessionDataStr: string) => {
try { try {
const sessionData = this.parseSessionData(sessionDataStr); const sessionData = this.parseSessionData(sessionDataStr);
sessionData.slotId = slotId;
resolve(sessionData); resolve(sessionData);
} catch (err) { } catch (err) {
reject(err); reject(err);
@ -1058,8 +1053,6 @@ export class GameData {
console.debug("Attempt to log session data failed:", err); console.debug("Attempt to log session data failed:", err);
} }
} }
// overwrite slot ID if somehow not set.
fromSession.slotId = slotId;
globalScene.gameMode = getGameMode(fromSession.gameMode || GameModes.CLASSIC); globalScene.gameMode = getGameMode(fromSession.gameMode || GameModes.CLASSIC);
if (fromSession.challenges) { if (fromSession.challenges) {
@ -1296,13 +1289,6 @@ export class GameData {
result = [true, true]; result = [true, true];
} else { } else {
const sessionData = this.getSessionSaveData(); const sessionData = this.getSessionSaveData();
if (sessionData.slotId !== slotId) {
console.warn(
`Tried to clear session at slot ${slotId}, but current session is at slot ${sessionData.slotId}. Overriding to ${sessionData.slotId}.`,
);
// Nullish coalescing is here in case of sessionData from before we added slotId
slotId = sessionData.slotId ?? slotId;
}
const { trainerId } = this; const { trainerId } = this;
const jsonResponse = await pokerogueApi.savedata.session.clear( const jsonResponse = await pokerogueApi.savedata.session.clear(
{ slot: slotId, trainerId, clientSessionId }, { slot: slotId, trainerId, clientSessionId },
@ -1428,8 +1414,7 @@ export class GameData {
const request = { const request = {
system: systemData, system: systemData,
session: sessionData, session: sessionData,
// Nullish coalescing is set here in case there is somehow sessionData that was loaded but has no slotID (due to transition) sessionSlotId: globalScene.sessionSlotId,
sessionSlotId: sessionData.slotId ?? globalScene.sessionSlotId,
clientSessionId: clientSessionId, clientSessionId: clientSessionId,
}; };
@ -1557,7 +1542,6 @@ export class GameData {
} }
case GameDataType.SESSION: { case GameDataType.SESSION: {
const sessionData = this.parseSessionData(dataStr); const sessionData = this.parseSessionData(dataStr);
sessionData.slotId = slotId;
valid = !!sessionData.party && !!sessionData.enemyParty && !!sessionData.timestamp; valid = !!sessionData.party && !!sessionData.enemyParty && !!sessionData.timestamp;
break; break;
} }