Added removeInvalidTradersFromProfile to core.json config to allow cleanup of incorrect trader data in profile

This commit is contained in:
Dev 2024-11-20 10:49:18 +00:00
parent ab4a3aac17
commit 9632238fab
5 changed files with 35 additions and 2 deletions

View File

@ -16,6 +16,7 @@
"fixes": { "fixes": {
"fixShotgunDispersion": true, "fixShotgunDispersion": true,
"removeModItemsFromProfile": false, "removeModItemsFromProfile": false,
"removeInvalidTradersFromProfile": false,
"fixProfileBreakingInventoryItemIssues": false "fixProfileBreakingInventoryItemIssues": false
}, },
"survey": { "survey": {

View File

@ -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", "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-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-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", "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-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", "gameevent-no_gear_data": "No gear data in seasonalevents.json config for event %s",

View File

@ -156,6 +156,8 @@ export class GameController {
this.profileFixerService.checkForOrphanedModdedItems(sessionID, fullProfile); this.profileFixerService.checkForOrphanedModdedItems(sessionID, fullProfile);
} }
this.profileFixerService.checkForAndRemoveInvalidTraders(fullProfile);
this.profileFixerService.checkForAndFixPmcProfileIssues(pmcProfile); this.profileFixerService.checkForAndFixPmcProfileIssues(pmcProfile);
if (pmcProfile.Hideout) { if (pmcProfile.Hideout) {

View File

@ -75,6 +75,8 @@ export interface IGameFixes {
fixShotgunDispersion: boolean; fixShotgunDispersion: boolean;
/** Remove items added by mods when the mod no longer exists - can fix dead profiles stuck at game load */ /** Remove items added by mods when the mod no longer exists - can fix dead profiles stuck at game load */
removeModItemsFromProfile: boolean; 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 */ /** Fix issues that cause the game to not start due to inventory item issues */
fixProfileBreakingInventoryItemIssues: boolean; fixProfileBreakingInventoryItemIssues: boolean;
} }

View File

@ -499,7 +499,9 @@ export class ProfileFixerService {
if (!this.traderHelper.traderEnumHasValue(traderId)) { if (!this.traderHelper.traderEnumHasValue(traderId)) {
this.logger.error(this.localisationService.getText("fixer-trader_found", traderId)); this.logger.error(this.localisationService.getText("fixer-trader_found", traderId));
if (this.coreConfig.fixes.removeModItemsFromProfile) { 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]; delete fullProfile.traderPurchases[traderId];
} }
} }
@ -650,4 +652,30 @@ export class ProfileFixerService {
return profileBonuses.find((x) => x.type === bonus.type && x.value === bonus.value); 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];
}
}
}
}
} }