From 195d0e3b1d714b7dee90da0cd8f4fec7b4d7b05b Mon Sep 17 00:00:00 2001 From: Dev Date: Sat, 15 Jul 2023 10:53:08 +0100 Subject: [PATCH] Add 'fixes' section to core.json, expose some flags for enabling spt fixes Added flag to enable deletion of modded items from profile - default is off Fixed issue where loop would stop checking for modded items after finding the first item --- project/assets/configs/core.json | 8 ++++-- project/assets/configs/location.json | 2 ++ project/src/controllers/GameController.ts | 18 +++++++++--- project/src/models/spt/config/ICoreConfig.ts | 9 ++++++ .../src/models/spt/config/ILocationConfig.ts | 4 +++ project/src/services/ProfileFixerService.ts | 28 ++++++++++++++++--- 6 files changed, 59 insertions(+), 10 deletions(-) diff --git a/project/assets/configs/core.json b/project/assets/configs/core.json index 3cf9c1b4..93f94491 100644 --- a/project/assets/configs/core.json +++ b/project/assets/configs/core.json @@ -3,5 +3,9 @@ "projectName": "SPT-AKI", "compatibleTarkovVersion": "0.13.1.24742", "serverName": "SPT Server", - "profileSaveIntervalSeconds": 15 -} + "profileSaveIntervalSeconds": 15, + "fixes": { + "fixShotgunDispersion": true, + "removeModItemsFromProfile": false + } +} \ No newline at end of file diff --git a/project/assets/configs/location.json b/project/assets/configs/location.json index 93e823c2..b7bcd489 100644 --- a/project/assets/configs/location.json +++ b/project/assets/configs/location.json @@ -648,4 +648,6 @@ "ignoreMaps": ["base", "develop", "hideout", "privatearea", "suburbs", "terminal", "town"] }, "fitLootIntoContainerAttempts": 2 + "addOpenZonesToAllMaps": true, + "addCustomBotWavesToMaps": true, } diff --git a/project/src/controllers/GameController.ts b/project/src/controllers/GameController.ts index 58b7959b..b4872358 100644 --- a/project/src/controllers/GameController.ts +++ b/project/src/controllers/GameController.ts @@ -73,10 +73,20 @@ export class GameController // Store start time in app context this.applicationContext.addValue(ContextVariableType.CLIENT_START_TIMESTAMP, startTimeStampMS); - this.fixShotgunDispersions(); + if (this.coreConfig.fixes.fixShotgunDispersion) + { + this.fixShotgunDispersions(); + } - this.openZoneService.applyZoneChangesToAllMaps(); - this.customLocationWaveService.applyWaveChangesToAllMaps(); + if (this.locationConfig.addOpenZonesToAllMaps) + { + this.openZoneService.applyZoneChangesToAllMaps(); + } + + if (this.locationConfig.addCustomBotWavesToMaps) + { + this.customLocationWaveService.applyWaveChangesToAllMaps(); + } // repeatableQuests are stored by in profile.Quests due to the responses of the client (e.g. Quests in offraidData) // Since we don't want to clutter the Quests list, we need to remove all completed (failed / successful) repeatable quests. @@ -126,7 +136,7 @@ export class GameController if (pmcProfile.Inventory) { - this.profileFixerService.checkForOrphanedModdedItems(pmcProfile); + this.profileFixerService.checkForOrphanedModdedItems(sessionID, pmcProfile); } this.logProfileDetails(fullProfile); diff --git a/project/src/models/spt/config/ICoreConfig.ts b/project/src/models/spt/config/ICoreConfig.ts index 67a788ac..6a2a436a 100644 --- a/project/src/models/spt/config/ICoreConfig.ts +++ b/project/src/models/spt/config/ICoreConfig.ts @@ -8,5 +8,14 @@ export interface ICoreConfig extends IBaseConfig compatibleTarkovVersion: string serverName: string profileSaveIntervalSeconds: number + fixes: IGameFixes commit: string +} + +export interface IGameFixes +{ + /** Shotguns use a different value than normal guns causing huge pellet dispersion */ + fixShotgunDispersion: boolean + /** Remove items added by mods when the mod no longer exists - can fix dead profiles stuck at game load*/ + removeModItemsFromProfile: boolean } \ No newline at end of file diff --git a/project/src/models/spt/config/ILocationConfig.ts b/project/src/models/spt/config/ILocationConfig.ts index 149fd13b..9df92bb0 100644 --- a/project/src/models/spt/config/ILocationConfig.ts +++ b/project/src/models/spt/config/ILocationConfig.ts @@ -16,6 +16,10 @@ export interface ILocationConfig extends IBaseConfig forcedLootSingleSpawnById: Record /** How many attempts should be taken to fit an item into a container before giving up */ fitLootIntoContainerAttempts: number; + /** Add all possible zones to each maps `OpenZones` property */ + addOpenZonesToAllMaps: boolean + /** Allow addition of custom bot waves designed by SPT to be added to maps - defined in configs/location.json.customWaves*/ + addCustomBotWavesToMaps: boolean } export interface IFixEmptyBotWavesSettings diff --git a/project/src/services/ProfileFixerService.ts b/project/src/services/ProfileFixerService.ts index 1e1f4154..1d0043a7 100644 --- a/project/src/services/ProfileFixerService.ts +++ b/project/src/services/ProfileFixerService.ts @@ -1,6 +1,7 @@ import { inject, injectable } from "tsyringe"; import { HideoutHelper } from "../helpers/HideoutHelper"; +import { InventoryHelper } from "../helpers/InventoryHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; import { Bonus, HideoutSlot } from "../models/eft/common/tables/IBotBase"; import { @@ -8,10 +9,13 @@ import { } from "../models/eft/common/tables/IRepeatableQuests"; import { StageBonus } from "../models/eft/hideout/IHideoutArea"; import { IAkiProfile } from "../models/eft/profile/IAkiProfile"; +import { ConfigTypes } from "../models/enums/ConfigTypes"; import { HideoutAreas } from "../models/enums/HideoutAreas"; import { QuestStatus } from "../models/enums/QuestStatus"; import { Traders } from "../models/enums/Traders"; +import { ICoreConfig } from "../models/spt/config/ICoreConfig"; import { ILogger } from "../models/spt/utils/ILogger"; +import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { TimeUtil } from "../utils/TimeUtil"; import { Watermark } from "../utils/Watermark"; @@ -20,15 +24,21 @@ import { LocalisationService } from "./LocalisationService"; @injectable() export class ProfileFixerService { + protected coreConfig: ICoreConfig; + constructor( @inject("WinstonLogger") protected logger: ILogger, @inject("Watermark") protected watermark: Watermark, @inject("HideoutHelper") protected hideoutHelper: HideoutHelper, + @inject("InventoryHelper") protected inventoryHelper: InventoryHelper, @inject("LocalisationService") protected localisationService: LocalisationService, @inject("TimeUtil") protected timeUtil: TimeUtil, - @inject("DatabaseServer") protected databaseServer: DatabaseServer + @inject("DatabaseServer") protected databaseServer: DatabaseServer, + @inject("ConfigServer") protected configServer: ConfigServer ) - { } + { + this.coreConfig = this.configServer.getConfig(ConfigTypes.CORE); + } /** * Find issues in the pmc profile data that may cause issues and fix them @@ -580,9 +590,10 @@ export class ProfileFixerService /** * Checks profile inventiory for items that do not exist inside the items db + * @param sessionId Session id * @param pmcProfile Profile to check inventory of */ - public checkForOrphanedModdedItems(pmcProfile: IPmcData): void + public checkForOrphanedModdedItems(sessionId: string, pmcProfile: IPmcData): void { const itemsDb = this.databaseServer.getTables().templates.items; @@ -594,13 +605,22 @@ export class ProfileFixerService return; } + // Check each item in inventory to ensure item exists in itemdb for (const item of inventoryItemsToCheck) { if (!itemsDb[item._tpl]) { this.logger.error(this.localisationService.getText("fixer-mod_item_found", item._tpl)); - return; + if (this.coreConfig.fixes.removeModItemsFromProfile) + { + this.logger.success(`Deleting item from inventory and insurance with id: ${item._id} tpl: ${item._tpl}`); + + // Also deletes from insured array + this.inventoryHelper.removeItem(pmcProfile, item._id, sessionId); + + // TODO: delete item from mail + } } } }