Skip to content

Commit 650fef3

Browse files
committed
fix: Handle unsafe pointer access which breaks Welcome to Cuba, or any custom location
Existing user progression data not having a newly added location (Cuba, ToTT) will cause the game to hang up on mission end due to an invalid pointer access trying to set PreviouslySeenXP of null. Added error check to catch this and fill in default progression data in this case, so custom locations like Cuba can be completed without locking up the game.
1 parent 20a5798 commit 650fef3

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

components/scoreHandler.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import type {
4343
JwtData,
4444
MissionManifest,
4545
MissionManifestObjective,
46+
ProgressionData,
4647
Seconds,
4748
UserProfile,
4849
} from "./types/types"
@@ -882,11 +883,20 @@ export async function getMissionEndData(
882883

883884
const newLocationXp = completionData.XP
884885
let newLocationLevel = levelForXp(newLocationXp, masteryData?.XpPerLevel)
886+
const userProgressionLocations = userData.Extensions.progression.Locations
885887

886888
if (!query.masteryUnlockableId) {
887-
userData.Extensions.progression.Locations[
888-
locationParentId
889-
].PreviouslySeenXp = newLocationXp
889+
if (userProgressionLocations[locationParentId]) {
890+
userProgressionLocations[locationParentId].PreviouslySeenXp = newLocationXp
891+
} else {
892+
log(LogLevel.WARN, `Location progression missing for ${locationParentId}, adding default progression.`)
893+
const defaultProgression: ProgressionData = {
894+
Xp: 0,
895+
Level: 1,
896+
PreviouslySeenXp: newLocationXp
897+
}
898+
userProgressionLocations[locationParentId] = defaultProgression
899+
}
890900
}
891901

892902
if (!isDryRun) writeUserData(jwt.unique_name, gameVersion)

0 commit comments

Comments
 (0)