diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/core.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/core.json index a7a23c6a..8253b0a8 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/core.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/core.json @@ -12,6 +12,9 @@ "release": { "betaDisclaimerTimeoutDelay": 30 }, + "onStart": { + "validateProfiles": true + }, "fixes": { "fixShotgunDispersion": true, "removeModItemsFromProfile": false, diff --git a/Libraries/SPTarkov.Server.Core/Helpers/ProfileValidatorHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/ProfileValidatorHelper.cs index 5a0a17df..1e2dd598 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/ProfileValidatorHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/ProfileValidatorHelper.cs @@ -2,7 +2,6 @@ using SPTarkov.Server.Core.Exceptions.Items; using SPTarkov.Server.Core.Extensions; using SPTarkov.Server.Core.Models.Common; -using SPTarkov.Server.Core.Models.Eft.Common; using SPTarkov.Server.Core.Models.Eft.Common.Tables; using SPTarkov.Server.Core.Models.Eft.Profile; using SPTarkov.Server.Core.Models.Enums; diff --git a/Libraries/SPTarkov.Server.Core/Models/Spt/Config/CoreConfig.cs b/Libraries/SPTarkov.Server.Core/Models/Spt/Config/CoreConfig.cs index 81bef520..a4f39381 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Spt/Config/CoreConfig.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Spt/Config/CoreConfig.cs @@ -36,6 +36,9 @@ public record CoreConfig : BaseConfig [JsonPropertyName("fixes")] public required GameFixes Fixes { get; set; } + [JsonPropertyName("onStart")] + public required OnStart OnStart { get; set; } + [JsonPropertyName("survey")] public required SurveyResponseData Survey { get; set; } @@ -208,6 +211,15 @@ public record GameFixes public bool FixProfileBreakingInventoryItemIssues { get; set; } } +public record OnStart +{ + /// + /// Run profile templateId checks on all profiles when server starts + /// + [JsonPropertyName("validateProfiles")] + public bool ValidateProfiles { get; set; } +} + public record ServerFeatures { [JsonExtensionData] diff --git a/Libraries/SPTarkov.Server.Core/Services/PostDbLoadService.cs b/Libraries/SPTarkov.Server.Core/Services/PostDbLoadService.cs index 596b4790..e449b81f 100644 --- a/Libraries/SPTarkov.Server.Core/Services/PostDbLoadService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/PostDbLoadService.cs @@ -1,5 +1,6 @@ using SPTarkov.DI.Annotations; using SPTarkov.Server.Core.Extensions; +using SPTarkov.Server.Core.Helpers; using SPTarkov.Server.Core.Models.Common; using SPTarkov.Server.Core.Models.Eft.Common; using SPTarkov.Server.Core.Models.Enums; @@ -20,6 +21,8 @@ public class PostDbLoadService( OpenZoneService openZoneService, ItemBaseClassService itemBaseClassService, RaidWeatherService raidWeatherService, + ProfileHelper profileHelper, + ProfileValidatorHelper profileValidatorHelper, ConfigServer configServer, ICloner cloner ) @@ -134,6 +137,14 @@ public class PostDbLoadService( var chosenBoss = GetWeeklyBoss(_botConfig.WeeklyBoss.BossPool, _botConfig.WeeklyBoss.ResetDay); FlagMapAsGuaranteedBoss(chosenBoss); } + + if (_coreConfig.OnStart.ValidateProfiles) + { + foreach (var (profileId, profile) in profileHelper.GetProfiles()) + { + profileValidatorHelper.CheckForOrphanedModdedData(profileId, profile); + } + } } ///