diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/lostondeath.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/lostondeath.json index a8cda3c21..d01ac0866 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/lostondeath.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/lostondeath.json @@ -17,5 +17,6 @@ "SecuredContainer": false }, "questItems": true, - "specialSlotItems": false + "specialSlotItems": false, + "wipeOnRaidStart": false } diff --git a/Libraries/SPTarkov.Server.Core/Models/Spt/Config/LostOnDeathConfig.cs b/Libraries/SPTarkov.Server.Core/Models/Spt/Config/LostOnDeathConfig.cs index dc5dd3214..bfdb1bfce 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Spt/Config/LostOnDeathConfig.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Spt/Config/LostOnDeathConfig.cs @@ -24,6 +24,9 @@ public record LostOnDeathConfig : BaseConfig /// [JsonPropertyName("questItems")] public bool QuestItems { get; set; } + + [JsonPropertyName("wipeOnRaidStart")] + public bool WipeOnRaidStart { get; set; } } public record LostEquipment diff --git a/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs b/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs index 5198a23c6..49952424a 100644 --- a/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs @@ -55,6 +55,7 @@ BtrDeliveryService btrDeliveryService protected readonly RagfairConfig _ragfairConfig = configServer.GetConfig(); protected readonly HideoutConfig _hideoutConfig = configServer.GetConfig(); protected readonly PmcConfig _pmcConfig = configServer.GetConfig(); + protected readonly LostOnDeathConfig _lostOnDeathConfig = configServer.GetConfig(); /// /// Handle client/match/local/start @@ -128,9 +129,25 @@ public virtual StartLocalRaidResponseData StartLocalRaid(MongoId sessionId, Star GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive, true, true); + // Handle Player Inventory Wiping checks for alt-f4 prevention + HandlePreRaidInventoryChecks(request.PlayerSide, playerProfile.CharacterData.PmcData, sessionId); + return result; } + /// + /// Handle Pre Raid checks Alt-F4 Prevention and player inventory wiping + /// + protected void HandlePreRaidInventoryChecks(string playerSide, PmcData pmcData, string sessionId) + { + // If config enabled, remove players equipped items to prevent alt-F4 from persisting items + if (string.Equals(playerSide, "pmc", StringComparison.OrdinalIgnoreCase) && _lostOnDeathConfig.WipeOnRaidStart) + { + logger.Debug("Wiping player inventory on raid start to prevent alt-f4"); + inRaidHelper.DeleteInventory(pmcData, sessionId); + } + } + /// /// Replace map exits with scav exits when player is scavving ///