diff --git a/project/assets/configs/core.json b/project/assets/configs/core.json index 0a53ef3c..80025841 100644 --- a/project/assets/configs/core.json +++ b/project/assets/configs/core.json @@ -16,6 +16,7 @@ "fixes": { "fixShotgunDispersion": true, "removeModItemsFromProfile": false, + "removeInvalidTradersFromProfile": false, "fixProfileBreakingInventoryItemIssues": false }, "survey": { diff --git a/project/assets/database/locales/server/en.json b/project/assets/database/locales/server/en.json index f9fc378f..897cc2a0 100644 --- a/project/assets/database/locales/server/en.json +++ b/project/assets/database/locales/server/en.json @@ -80,7 +80,7 @@ "fence-unable_to_get_ammo_penetration_value": "No penetration value found for Ammo: %s, Unable to check if its above penetration limit, assuming false", "fixer-clothing_item_found": "Clothing item: %s found in profile that does not exist in SPT. You WILL experience errors, this can be due to using a clothing mod and removing the mod with your character still wearing it. DO NOT USE THIS PROFILE. Open SPT_Data\\Server\\configs\\core.json, edit 'removeModItemsFromProfile' to be true. This will allow the server to edit your profile and hopefully remove the missing clothing", "fixer-mod_item_found": "Item: %s found in profile that does not exist in items db. You WILL experience errors, this can be due to using an items mod and removing the mod without deleting the modded items from your inventory. DO NOT USE THIS PROFILE. Open SPT_Data\\Server\\configs\\core.json, edit 'removeModItemsFromProfile' to be true. This will allow the server to edit your profile and hopefully remove the bad items", - "fixer-trader_found": "Trader: %s found in profile but does not exist in SPT. You WILL experience errors, this can be due to using an trader mod and removing the mod without deleting the messages from said trader. DO NOT USE THIS PROFILE. Open SPT_Data\\Server\\configs\\core.json, edit 'removeModItemsFromProfile' to be true. This will allow the server to edit your profile and hopefully remove the bad messages", + "fixer-trader_found": "Trader: %s found in profile but does not exist in SPT. You WILL experience errors, this can be due to using an trader mod and removing the mod without deleting the messages from said trader. DO NOT USE THIS PROFILE. Open SPT_Data\\Server\\configs\\core.json, edit 'removeModItemsFromProfile' and `removeInvalidTradersFromProfile` to be true. This will allow the server to edit your profile and hopefully remove the bad messages", "fixer-updated_pockets": "Updated 'pocket' item to new 18876 version with x3 special slots", "gameevent-bot_not_found": "addEventGearToScavs() - unable to find bot of type %s in database, skipping", "gameevent-no_gear_data": "No gear data in seasonalevents.json config for event %s", diff --git a/project/src/controllers/GameController.ts b/project/src/controllers/GameController.ts index 1a47975c..544ac767 100644 --- a/project/src/controllers/GameController.ts +++ b/project/src/controllers/GameController.ts @@ -156,6 +156,8 @@ export class GameController { this.profileFixerService.checkForOrphanedModdedItems(sessionID, fullProfile); } + this.profileFixerService.checkForAndRemoveInvalidTraders(fullProfile); + this.profileFixerService.checkForAndFixPmcProfileIssues(pmcProfile); if (pmcProfile.Hideout) { diff --git a/project/src/models/spt/config/ICoreConfig.ts b/project/src/models/spt/config/ICoreConfig.ts index 6475a278..e579ceac 100644 --- a/project/src/models/spt/config/ICoreConfig.ts +++ b/project/src/models/spt/config/ICoreConfig.ts @@ -75,6 +75,8 @@ export interface IGameFixes { fixShotgunDispersion: boolean; /** Remove items added by mods when the mod no longer exists - can fix dead profiles stuck at game load */ removeModItemsFromProfile: boolean; + /** Remove invalid traders from profile - trader data can be leftover when player removes trader mod */ + removeInvalidTradersFromProfile: boolean; /** Fix issues that cause the game to not start due to inventory item issues */ fixProfileBreakingInventoryItemIssues: boolean; } diff --git a/project/src/services/ProfileFixerService.ts b/project/src/services/ProfileFixerService.ts index a322e4d1..4e4d87f6 100644 --- a/project/src/services/ProfileFixerService.ts +++ b/project/src/services/ProfileFixerService.ts @@ -499,7 +499,9 @@ export class ProfileFixerService { if (!this.traderHelper.traderEnumHasValue(traderId)) { this.logger.error(this.localisationService.getText("fixer-trader_found", traderId)); if (this.coreConfig.fixes.removeModItemsFromProfile) { - this.logger.warning(`Non-default trader: ${traderId} removed from traderPurchases list in profile`); + this.logger.warning( + `Non-default trader: ${traderId} purchase removed from traderPurchases list in profile`, + ); delete fullProfile.traderPurchases[traderId]; } } @@ -650,4 +652,30 @@ export class ProfileFixerService { return profileBonuses.find((x) => x.type === bonus.type && x.value === bonus.value); } + + public checkForAndRemoveInvalidTraders(fullProfile: ISptProfile) { + for (const traderId in fullProfile.characters.pmc.TradersInfo) { + if (!this.traderHelper.traderEnumHasValue(traderId)) { + this.logger.error(this.localisationService.getText("fixer-trader_found", traderId)); + if (this.coreConfig.fixes.removeInvalidTradersFromProfile) { + this.logger.warning( + `Non-default trader: ${traderId} removed from PMC TradersInfo in: ${fullProfile.info.id} profile`, + ); + delete fullProfile.characters.pmc.TradersInfo[traderId]; + } + } + } + + for (const traderId in fullProfile.characters.scav.TradersInfo) { + if (!this.traderHelper.traderEnumHasValue(traderId)) { + this.logger.error(this.localisationService.getText("fixer-trader_found", traderId)); + if (this.coreConfig.fixes.removeInvalidTradersFromProfile) { + this.logger.warning( + `Non-default trader: ${traderId} removed from Scav TradersInfo in: ${fullProfile.info.id} profile`, + ); + delete fullProfile.characters.scav.TradersInfo[traderId]; + } + } + } + } }