From b4602dce23edeeb63f748f8a3eb3df33ded99a7b Mon Sep 17 00:00:00 2001 From: CWX Date: Wed, 29 Jan 2025 13:35:18 +0000 Subject: [PATCH] add timing to debug not info, remove a clone that i dont think is needed --- Libraries/Core/Controllers/BotController.cs | 5 ++++- Libraries/Core/Controllers/TraderController.cs | 3 +-- Libraries/Core/Generators/LocationLootGenerator.cs | 2 +- Libraries/Core/Generators/RagfairOfferGenerator.cs | 12 +++++++++--- Libraries/Core/Services/FenceService.cs | 1 + 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Libraries/Core/Controllers/BotController.cs b/Libraries/Core/Controllers/BotController.cs index 5e11c797..e71b20c4 100644 --- a/Libraries/Core/Controllers/BotController.cs +++ b/Libraries/Core/Controllers/BotController.cs @@ -189,7 +189,10 @@ public class BotController( Task.WaitAll(tasks.ToArray()); stopwatch.Stop(); - _logger.Info($"Took {stopwatch.ElapsedMilliseconds}ms to GenerateMultipleBotsAndCache"); + if (_logger.IsLogEnabled(LogLevel.Debug)) + { + _logger.Debug($"Took {stopwatch.ElapsedMilliseconds}ms to GenerateMultipleBotsAndCache"); + } return []; } diff --git a/Libraries/Core/Controllers/TraderController.cs b/Libraries/Core/Controllers/TraderController.cs index d3f0bbcc..7c799ab7 100644 --- a/Libraries/Core/Controllers/TraderController.cs +++ b/Libraries/Core/Controllers/TraderController.cs @@ -185,12 +185,11 @@ public class TraderController( public GetItemPricesResponse GetItemPrices(string sessionId, string traderId) { var handbookPrices = _ragfairPriceService.GetAllStaticPrices(); - var handbookPricesClone = _cloner.Clone(handbookPrices); return new() { SupplyNextTime = _traderHelper.GetNextUpdateTimestamp(traderId), - Prices = handbookPricesClone, + Prices = handbookPrices, CurrencyCourses = new Dictionary() { { "5449016a4bdc2d6f028b456f", handbookPrices[Money.ROUBLES] }, diff --git a/Libraries/Core/Generators/LocationLootGenerator.cs b/Libraries/Core/Generators/LocationLootGenerator.cs index 01d2564d..19e82df9 100644 --- a/Libraries/Core/Generators/LocationLootGenerator.cs +++ b/Libraries/Core/Generators/LocationLootGenerator.cs @@ -237,7 +237,7 @@ public class LocationLootGenerator( } } - _logger.Success($"A total of {staticLootItemCount}static items spawned"); + _logger.Success($"A total of {staticLootItemCount} static items spawned"); _logger.Success( _localisationService.GetText("location-containers_generated_success", staticContainerCount) diff --git a/Libraries/Core/Generators/RagfairOfferGenerator.cs b/Libraries/Core/Generators/RagfairOfferGenerator.cs index c695f903..3dc27ec7 100644 --- a/Libraries/Core/Generators/RagfairOfferGenerator.cs +++ b/Libraries/Core/Generators/RagfairOfferGenerator.cs @@ -15,6 +15,7 @@ using Core.Utils.Cloners; using Server; using SptCommon.Extensions; using Core.Models.Eft.Player; +using LogLevel = Core.Models.Spt.Logging.LogLevel; namespace Core.Generators; @@ -334,7 +335,10 @@ public class RagfairOfferGenerator( ? expiredOffers ?? [] : ragfairAssortGenerator.GetAssortItems(); stopwatch.Stop(); - logger.Info($"Took {stopwatch.ElapsedMilliseconds}ms to GetRagfairAssorts"); + if (logger.IsLogEnabled(LogLevel.Debug)) + { + logger.Debug($"Took {stopwatch.ElapsedMilliseconds}ms to GetRagfairAssorts"); + } stopwatch.Restart(); var tasks = new List(); foreach (var assortItem in assortItemsToProcess) @@ -347,8 +351,10 @@ public class RagfairOfferGenerator( } Task.WaitAll(tasks.ToArray()); stopwatch.Stop(); - logger.Info($"Took {stopwatch.ElapsedMilliseconds}ms to CreateOffersFromAssort"); - + if (logger.IsLogEnabled(LogLevel.Debug)) + { + logger.Debug($"Took {stopwatch.ElapsedMilliseconds}ms to CreateOffersFromAssort"); + } } /** diff --git a/Libraries/Core/Services/FenceService.cs b/Libraries/Core/Services/FenceService.cs index e287e0c8..31f016b2 100644 --- a/Libraries/Core/Services/FenceService.cs +++ b/Libraries/Core/Services/FenceService.cs @@ -1168,6 +1168,7 @@ public class FenceService( foreach (var requiredSlot in softInsertSlots) { var modItemDbDetails = itemHelper.GetItem(requiredSlot.Props.Filters[0].Plate).Value; + var durabilityValues = GetRandomisedArmorDurabilityValues( modItemDbDetails, traderConfig.Fence.ArmorMaxDurabilityPercentMinMax