From c40439d04fd4b7ad242e33a383869825e76f14c9 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sat, 23 Aug 2025 10:30:26 +0100 Subject: [PATCH] Updated core difficulty code to use `JsonElement` --- Libraries/SPTarkov.Server.Core/Models/Spt/Bots/Bots.cs | 3 ++- .../SPTarkov.Server.Core/Services/SeasonalEventService.cs | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Models/Spt/Bots/Bots.cs b/Libraries/SPTarkov.Server.Core/Models/Spt/Bots/Bots.cs index fa8be9f1..e3ae87ec 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Spt/Bots/Bots.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Spt/Bots/Bots.cs @@ -1,3 +1,4 @@ +using System.Text.Json; using System.Text.Json.Serialization; using SPTarkov.Server.Core.Models.Eft.Common.Tables; @@ -12,5 +13,5 @@ public record Bots public required BotBase Base { get; init; } [JsonPropertyName("core")] - public required Dictionary Core { get; init; } + public required Dictionary Core { get; init; } } diff --git a/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs b/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs index 8cc5f597..f0234eaf 100644 --- a/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs @@ -731,10 +731,7 @@ public class SeasonalEventService( { // Flag zombies as being enabled var botData = databaseService.GetBots(); - if (!botData.Core.TryAdd("ACTIVE_HALLOWEEN_ZOMBIES_EVENT", true)) - { - botData.Core["ACTIVE_HALLOWEEN_ZOMBIES_EVENT"] = true; - } + botData.Core["ACTIVE_HALLOWEEN_ZOMBIES_EVENT"] = JsonDocument.Parse("true").RootElement.Clone(); var globals = databaseService.GetGlobals(); var infectionHalloween = globals.Configuration.SeasonActivity.InfectionHalloween; @@ -750,7 +747,7 @@ public class SeasonalEventService( ? infectionPercentage : Convert.ToDouble(randomUtil.GetInt(Convert.ToInt32(infectionPercentage), 100)); if (logger.IsLogEnabled(LogLevel.Debug)) - logger.Debug($"Percent infected from map {locationId} is {randomInfectionPercentage}"); + logger.Debug($"Percent infected from map: {locationId} is: {randomInfectionPercentage}"); // Infection rates sometimes apply to multiple maps, e.g. Factory day/night or Sandbox/sandbox_high // Get the list of maps that should have infection value applied to their base // 90% of locations are just 1 map e.g. bigmap = customs