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
This commit is contained in:
Dev 2023-07-15 10:53:08 +01:00
parent 9288a59a77
commit 195d0e3b1d
6 changed files with 59 additions and 10 deletions

View File

@ -3,5 +3,9 @@
"projectName": "SPT-AKI",
"compatibleTarkovVersion": "0.13.1.24742",
"serverName": "SPT Server",
"profileSaveIntervalSeconds": 15
"profileSaveIntervalSeconds": 15,
"fixes": {
"fixShotgunDispersion": true,
"removeModItemsFromProfile": false
}
}

View File

@ -648,4 +648,6 @@
"ignoreMaps": ["base", "develop", "hideout", "privatearea", "suburbs", "terminal", "town"]
},
"fitLootIntoContainerAttempts": 2
"addOpenZonesToAllMaps": true,
"addCustomBotWavesToMaps": true,
}

View File

@ -73,10 +73,20 @@ export class GameController
// Store start time in app context
this.applicationContext.addValue(ContextVariableType.CLIENT_START_TIMESTAMP, startTimeStampMS);
if (this.coreConfig.fixes.fixShotgunDispersion)
{
this.fixShotgunDispersions();
}
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);

View File

@ -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
}

View File

@ -16,6 +16,10 @@ export interface ILocationConfig extends IBaseConfig
forcedLootSingleSpawnById: Record<string, string[]>
/** 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

View File

@ -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
}
}
}
}