From 4e89fbbfd8f627e9e26050be5ed627de40e77bfe Mon Sep 17 00:00:00 2001 From: Chomp Date: Sat, 14 Jun 2025 12:42:19 +0100 Subject: [PATCH] Fixed typos and improved code readability --- .../Helpers/HealthHelper.cs | 22 ++++++++-------- .../Services/LocationLifecycleService.cs | 25 +++++++++++++------ 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Helpers/HealthHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/HealthHelper.cs index 3365cf69..fdb4e045 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/HealthHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/HealthHelper.cs @@ -175,7 +175,7 @@ public class HealthHelper( TransferPostRaidLimbEffectsToProfile(postRaidHealth.BodyParts, pmcData); - // Adjust hydration/energy/temp and limb hp using temp storage hydated above + // Adjust hydration/energy/temp and limb hp using temp storage hydrated above SaveHealth(pmcData, sessionID); // Reset temp storage @@ -189,11 +189,11 @@ public class HealthHelper( SptProfile fullProfile, double hydration, double energy, - double temprature) + double temperature) { fullProfile.VitalityData.Hydration = hydration; fullProfile.VitalityData.Energy = energy; - fullProfile.VitalityData.Temperature = temprature; + fullProfile.VitalityData.Temperature = temperature; } /// @@ -209,27 +209,25 @@ public class HealthHelper( { // Get effects on body part from profile var bodyPartEffects = postRaidBodyParts[bodyPartId.Key].Effects; - foreach (var effect in bodyPartEffects) + foreach (var(key, effectDetails) in bodyPartEffects) { - var effectDetails = bodyPartEffects[effect.Key]; - // Null guard profileData.Health.BodyParts[bodyPartId.Key].Effects ??= new Dictionary(); // Effect already exists on limb in server profile, skip var profileBodyPartEffects = profileData.Health.BodyParts[bodyPartId.Key].Effects; - if (profileBodyPartEffects.TryGetValue(effect.Key, out _)) + if (profileBodyPartEffects.ContainsKey(key)) { - if (effectsToIgnore.Contains(effect.Key)) + if (effectsToIgnore.Contains(key)) // Get rid of certain effects we don't want to persist out of raid { - profileBodyPartEffects[effect.Key] = null; + profileBodyPartEffects[key] = null; } continue; } - if (effectsToIgnore.Contains(effect.Key)) + if (effectsToIgnore.Contains(key)) // Do not pass some effects to out of raid profile { continue; @@ -240,9 +238,9 @@ public class HealthHelper( Time = effectDetails.Time ?? -1 }; // Add effect to server profile - if (profileBodyPartEffects.TryAdd(effect.Key, effectToAdd)) + if (profileBodyPartEffects.TryAdd(key, effectToAdd)) { - profileBodyPartEffects[effect.Key] = effectToAdd; + profileBodyPartEffects[key] = effectToAdd; } } } diff --git a/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs b/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs index 809259f6..3fddbdec 100644 --- a/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs @@ -454,7 +454,15 @@ public class LocationLifecycleService if (!isPmc) { - HandlePostRaidPlayerScav(sessionId, pmcProfile, scavProfile, isDead, isTransfer, isSurvived, request); + HandlePostRaidPlayerScav( + sessionId, + pmcProfile, + scavProfile, + isDead, + isTransfer, + isSurvived, + request); + return; } @@ -487,21 +495,24 @@ public class LocationLifecycleService } } - private void SendCoopTakenFenceMessage(string sessionId) + /// + /// After taking a COOP extract, send player a gift via mail + /// + /// Player/Session id + protected void SendCoopTakenFenceMessage(string sessionId) { - // Generate reward for taking coop extract + // Generate randomised reward for taking coop extract var loot = _lootGenerator.CreateRandomLoot(_traderConfig.Fence.CoopExtractGift); - var mailableLoot = new List(); var parentId = _hashUtil.Generate(); foreach (var itemAndChildren in loot) { // Set all root items parent to new id - itemAndChildren[0].ParentId = parentId; + itemAndChildren.FirstOrDefault().ParentId = parentId; } // Flatten - mailableLoot.AddRange(loot.SelectMany(x => x)); + List mailableLoot = [..loot.SelectMany(x => x)]; // Send message from fence giving player reward generated above _mailSendService.SendLocalisedNpcMessageToPlayer( @@ -522,7 +533,7 @@ public class LocationLifecycleService protected bool ExtractWasViaCar(string extractName) { // exit name is undefined on death - if (extractName is null) + if (string.IsNullOrEmpty(extractName)) { return false; }