From 07217e9ed0e5324df4f89eafedc766e1df64248b Mon Sep 17 00:00:00 2001 From: Dev Date: Fri, 4 Aug 2023 10:25:21 +0100 Subject: [PATCH] Further extension of profiel fixing code, deletes more Clothing, active repeatable quests with bad trader/items, trader purchases from bad traders --- project/src/services/ProfileFixerService.ts | 68 +++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/project/src/services/ProfileFixerService.ts b/project/src/services/ProfileFixerService.ts index 333e2742..54eec43d 100644 --- a/project/src/services/ProfileFixerService.ts +++ b/project/src/services/ProfileFixerService.ts @@ -721,6 +721,74 @@ export class ProfileFixerService } } } + + const clothing = this.databaseServer.getTables().templates.customization; + for (const suitId of fullProfile.suits) + { + if (!clothing[suitId]) + { + this.logger.error(this.localisationService.getText("fixer-mod_item_found", suitId)); + if (this.coreConfig.fixes.removeModItemsFromProfile) + { + fullProfile.suits.splice(fullProfile.suits.indexOf(suitId), 1); + this.logger.warning(`Non-default suit purchase: ${suitId} removed from profile`); + } + } + } + + for (const repeatable of fullProfile.characters.pmc.RepeatableQuests) + { + for (const activeQuest of repeatable.activeQuests ?? []) + { + if (!Object.values(Traders).some((x) => x === activeQuest.traderId)) + { + this.logger.error(this.localisationService.getText("fixer-mod_item_found", activeQuest.traderId)); + if (this.coreConfig.fixes.removeModItemsFromProfile) + { + this.logger.warning(`Non-default quest: ${activeQuest._id} from trader: ${activeQuest.traderId} removed from RepeatableQuests list in profile`); + repeatable.activeQuests.splice(repeatable.activeQuests.findIndex(x => x._id === activeQuest._id), 1); + } + + continue; + } + + for (const successReward of activeQuest.rewards.Success) + { + if (successReward.type === "Item") + { + for (const rewardItem of successReward.items) + { + if (!itemsDb[rewardItem._tpl]) + { + this.logger.error(this.localisationService.getText("fixer-mod_item_found", rewardItem._tpl)); + if (this.coreConfig.fixes.removeModItemsFromProfile) + { + this.logger.warning(`Non-default quest: ${activeQuest._id} from trader: ${activeQuest.traderId} removed from RepeatableQuests list in profile`); + repeatable.activeQuests.splice(repeatable.activeQuests.findIndex(x => x._id === activeQuest._id), 1); + } + + continue; + } + } + } + + + } + } + } + + for (const traderId in fullProfile.traderPurchases) + { + if (!Object.values(Traders).some((x) => x === traderId)) + { + this.logger.error(this.localisationService.getText("fixer-mod_item_found", traderId)); + if (this.coreConfig.fixes.removeModItemsFromProfile) + { + this.logger.warning(`Non-default trader: ${traderId} removed from traderPurchases list in profile`); + delete fullProfile.traderPurchases[traderId]; + } + } + } } /**