From eb0fb09a37295463b31c3aa8c83d218d8c73a2bc Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 7 May 2024 09:02:44 +0100 Subject: [PATCH] Fixed profile creation failing when player alt+f4s partially through profile creation process Added nullguard to `userbuilds` code inside `checkForOrphanedModdedItems()` --- project/src/services/ProfileFixerService.ts | 33 +++++++++++---------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/project/src/services/ProfileFixerService.ts b/project/src/services/ProfileFixerService.ts index 28205ee0..d07b025b 100644 --- a/project/src/services/ProfileFixerService.ts +++ b/project/src/services/ProfileFixerService.ts @@ -897,24 +897,27 @@ export class ProfileFixerService } } - // Remove invalid builds from weapon, equipment and magazine build lists - const weaponBuilds = fullProfile.userbuilds?.weaponBuilds || []; - fullProfile.userbuilds.weaponBuilds = weaponBuilds.filter((weaponBuild) => + if (fullProfile.userbuilds) { - return !this.shouldRemoveWeaponEquipmentBuild("weapon", weaponBuild, itemsDb); - }); + // Remove invalid builds from weapon, equipment and magazine build lists + const weaponBuilds = fullProfile.userbuilds?.weaponBuilds || []; + fullProfile.userbuilds.weaponBuilds = weaponBuilds.filter((weaponBuild) => + { + return !this.shouldRemoveWeaponEquipmentBuild("weapon", weaponBuild, itemsDb); + }); - const equipmentBuilds = fullProfile.userbuilds?.equipmentBuilds || []; - fullProfile.userbuilds.equipmentBuilds = equipmentBuilds.filter((equipmentBuild) => - { - return !this.shouldRemoveWeaponEquipmentBuild("equipment", equipmentBuild, itemsDb); - }); + const equipmentBuilds = fullProfile.userbuilds?.equipmentBuilds || []; + fullProfile.userbuilds.equipmentBuilds = equipmentBuilds.filter((equipmentBuild) => + { + return !this.shouldRemoveWeaponEquipmentBuild("equipment", equipmentBuild, itemsDb); + }); - const magazineBuilds = fullProfile.userbuilds?.magazineBuilds || []; - fullProfile.userbuilds.magazineBuilds = magazineBuilds.filter((magazineBuild) => - { - return !this.shouldRemoveMagazineBuild(magazineBuild, itemsDb); - }); + const magazineBuilds = fullProfile.userbuilds?.magazineBuilds || []; + fullProfile.userbuilds.magazineBuilds = magazineBuilds.filter((magazineBuild) => + { + return !this.shouldRemoveMagazineBuild(magazineBuild, itemsDb); + }); + } // Iterate over dialogs, looking for messages with items not found in item db, remove message if item found for (const dialogId in fullProfile.dialogues)