Fix: Killing the client will no longer save your items (#557)

* alt-f4 is for timmys and rats, not chads like Chomp

* peer review fixes

---------

Co-authored-by: Chomp <27521899+chompDev@users.noreply.github.com>
This commit is contained in:
Chris Adamson
2025-08-19 11:39:20 -05:00
committed by GitHub
parent 100c3a7b47
commit 457e7cd36c
3 changed files with 22 additions and 1 deletions
@@ -55,6 +55,7 @@ public class LocationLifecycleService(
protected readonly RagfairConfig _ragfairConfig = configServer.GetConfig<RagfairConfig>();
protected readonly HideoutConfig _hideoutConfig = configServer.GetConfig<HideoutConfig>();
protected readonly PmcConfig _pmcConfig = configServer.GetConfig<PmcConfig>();
protected readonly LostOnDeathConfig _lostOnDeathConfig = configServer.GetConfig<LostOnDeathConfig>();
/// <summary>
/// Handle client/match/local/start
@@ -128,9 +129,25 @@ public class LocationLifecycleService(
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;
}
/// <summary>
/// Handle Pre Raid checks Alt-F4 Prevention and player inventory wiping
/// </summary>
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);
}
}
/// <summary>
/// Replace map exits with scav exits when player is scavving
/// </summary>