From 7eb88646f24f43042547663ae4d9019a73a0e7e6 Mon Sep 17 00:00:00 2001 From: Chomp Date: Tue, 19 Aug 2025 12:04:15 +0100 Subject: [PATCH] Second attempt at fixing prestige issue #558 --- .../Generators/PlayerScavGenerator.cs | 24 +++++++++---------- .../Helpers/ProfileHelper.cs | 7 +++++- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Generators/PlayerScavGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/PlayerScavGenerator.cs index acdaf312..394b9498 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/PlayerScavGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/PlayerScavGenerator.cs @@ -82,7 +82,18 @@ public class PlayerScavGenerator( pmcDataClone ); - // Remove cached bot data after scav was generated + // Add additional items to player scav as loot + AddAdditionalLootToPlayerScavContainers( + scavData.Id.Value, + playerScavKarmaSettings.LootItemsToAddChancePercent, + scavData, + [EquipmentSlots.TacticalVest, EquipmentSlots.Pockets, EquipmentSlots.Backpack] + ); + + // No need for cache data, clear up + botInventoryContainerService.ClearCache(scavData.Id.Value); + + // Remove cached bot loot cache now scav is generated botLootCacheService.ClearCache(); // Add scav metadata @@ -112,17 +123,6 @@ public class PlayerScavGenerator( scavData.WishList = existingScavDataClone.WishList ?? new(); scavData.Encyclopedia = pmcDataClone.Encyclopedia ?? new(); - // Add additional items to player scav as loot - AddAdditionalLootToPlayerScavContainers( - scavData.Id.Value, - playerScavKarmaSettings.LootItemsToAddChancePercent, - scavData, - [EquipmentSlots.TacticalVest, EquipmentSlots.Pockets, EquipmentSlots.Backpack] - ); - - // No need for cache data, clear up - botInventoryContainerService.ClearCache(scavData.Id.Value); - // Remove secure container scavData = profileHelper.RemoveSecureContainer(scavData); diff --git a/Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs index a9c69b17..31056b43 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs @@ -88,9 +88,14 @@ public class ProfileHelper( /// A clone of the full player profile protected void SanitizeProfileForClient(SptProfile clonedProfile) { + if (clonedProfile.CharacterData?.PmcData?.TradersInfo?.Values is null) + { + return; + } + // Remove `loyaltyLevel` from `TradersInfo`, as otherwise it causes the client to not // properly calculate the player's `loyaltyLevel` - foreach (var trader in clonedProfile.CharacterData?.PmcData?.TradersInfo?.Values!) + foreach (var trader in clonedProfile.CharacterData.PmcData.TradersInfo.Values) { trader.LoyaltyLevel = null; }