From 8e3ae45f124eada7f555c61d5b10b254a55296e1 Mon Sep 17 00:00:00 2001 From: Chris Adamson Date: Mon, 18 Aug 2025 19:34:06 -0500 Subject: [PATCH 1/2] alt-f4 is for timmys and rats, not chads like Chomp --- .../SPTarkov.Server.Assets/SPT_Data/configs/lostondeath.json | 3 ++- .../Models/Spt/Config/LostOnDeathConfig.cs | 3 +++ .../Services/LocationLifecycleService.cs | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/lostondeath.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/lostondeath.json index a8cda3c21..16560200c 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": true } 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..7b336ea91 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 @@ -72,6 +73,10 @@ public virtual StartLocalRaidResponseData StartLocalRaid(MongoId sessionId, Star : playerProfile.CharacterData.ScavData.Skills.Common ); + // If config enabled, remove players equipped items to prevent alt-F4 from persisting items + if (_lostOnDeathConfig.WipeOnRaidStart) + inRaidHelper.DeleteInventory(playerProfile.CharacterData.PmcData, sessionId); + // Raid is starting, adjust run times to reduce server load while player is in raid _ragfairConfig.RunIntervalSeconds = _ragfairConfig.RunIntervalValues.InRaid; _hideoutConfig.RunIntervalSeconds = _hideoutConfig.RunIntervalValues.InRaid; From 2676564e114d322babe51f76e4bbe05e9b08e5a8 Mon Sep 17 00:00:00 2001 From: Chris Adamson Date: Tue, 19 Aug 2025 10:33:46 -0500 Subject: [PATCH 2/2] peer review fixes --- .../SPT_Data/configs/lostondeath.json | 2 +- .../Services/LocationLifecycleService.cs | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/lostondeath.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/lostondeath.json index 16560200c..d01ac0866 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/lostondeath.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/lostondeath.json @@ -18,5 +18,5 @@ }, "questItems": true, "specialSlotItems": false, - "wipeOnRaidStart": true + "wipeOnRaidStart": false } diff --git a/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs b/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs index 7b336ea91..49952424a 100644 --- a/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs @@ -73,10 +73,6 @@ public virtual StartLocalRaidResponseData StartLocalRaid(MongoId sessionId, Star : playerProfile.CharacterData.ScavData.Skills.Common ); - // If config enabled, remove players equipped items to prevent alt-F4 from persisting items - if (_lostOnDeathConfig.WipeOnRaidStart) - inRaidHelper.DeleteInventory(playerProfile.CharacterData.PmcData, sessionId); - // Raid is starting, adjust run times to reduce server load while player is in raid _ragfairConfig.RunIntervalSeconds = _ragfairConfig.RunIntervalValues.InRaid; _hideoutConfig.RunIntervalSeconds = _hideoutConfig.RunIntervalValues.InRaid; @@ -133,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 ///