From d535dd338eb9ad2f551bde5d9dc6730b5a247704 Mon Sep 17 00:00:00 2001 From: Archangel Date: Fri, 11 Jul 2025 16:23:22 +0200 Subject: [PATCH] Restore lifetime data on profile wipe / prestige to match live --- .../Services/CreateProfileService.cs | 71 +++++++++++++++---- 1 file changed, 58 insertions(+), 13 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Services/CreateProfileService.cs b/Libraries/SPTarkov.Server.Core/Services/CreateProfileService.cs index 98c61486..d91ef3a9 100644 --- a/Libraries/SPTarkov.Server.Core/Services/CreateProfileService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/CreateProfileService.cs @@ -88,19 +88,6 @@ public class CreateProfileService( pmcData.Info.PrestigeLevel = account.CharacterData.PmcData.Info.PrestigeLevel; } - if (account.CharacterData?.PmcData?.Stats?.Eft is not null) - { - if (pmcData.Stats.Eft is not null) - { - pmcData.Stats.Eft.TotalInGameTime = account - .CharacterData - .PmcData - .Stats - .Eft - .TotalInGameTime; - } - } - UpdateInventoryEquipmentId(pmcData); pmcData.UnlockedInfo ??= new UnlockedInfo { UnlockedProductionRecipe = [] }; @@ -127,6 +114,34 @@ public class CreateProfileService( CustomisationUnlocks = [], }; + // Set old account in-game time data on wipe, if it exists to the pmc + if (account.CharacterData?.PmcData?.Stats?.Eft is not null) + { + if (pmcData.Stats.Eft is not null) + { + pmcData.Stats.Eft.TotalInGameTime = account + .CharacterData + .PmcData + .Stats + .Eft + .TotalInGameTime; + + // Get the old profile's scav lifetime counter, if it exists + var lifetimeCounter = + account.CharacterData?.PmcData?.Stats?.Eft?.OverallCounters?.Items?.FirstOrDefault( + x => x.Key?.Contains("LifeTime") == true + ); + + if (lifetimeCounter is not null) + { + // Set the old lifetime counter back, bsg seems to use this as well to keep track of the total amount of time played + profileDetails.CharacterData.PmcData.Stats.Eft.OverallCounters.Items.Add( + lifetimeCounter + ); + } + } + } + profileDetails.AddCustomisationUnlocksToProfile(); profileDetails.AddSuitsToProfile(profileTemplateClone.Suits); @@ -220,6 +235,36 @@ public class CreateProfileService( sessionId ); + // Set old account in-game time data on wipe, if it exists to the scav + if (account.CharacterData?.ScavData?.Stats?.Eft is not null) + { + if (profileDetails.CharacterData.ScavData.Stats?.Eft is not null) + { + profileDetails.CharacterData.ScavData.Stats.Eft.TotalInGameTime = account + .CharacterData + .ScavData + .Stats + .Eft + .TotalInGameTime; + + // Get the old profile's scav lifetime counter, if it exists + var lifetimeCounter = + account.CharacterData?.ScavData?.Stats?.Eft?.OverallCounters?.Items?.FirstOrDefault( + x => x.Key?.Contains("LifeTime") == true + ); + + if (lifetimeCounter is not null) + { + // Set the old lifetime counter back, bsg seems to use this as well to keep track of the total amount of time played + saveServer + .GetProfile(sessionId) + .CharacterData.ScavData.Stats.Eft.OverallCounters.Items.Add( + lifetimeCounter + ); + } + } + } + // Store minimal profile and reload it await saveServer.SaveProfileAsync(sessionId); await saveServer.LoadProfileAsync(sessionId);