From ab7d00aa0db35ef139e94671e4587675956481ca Mon Sep 17 00:00:00 2001 From: Chomp Date: Sat, 25 Jan 2025 09:34:41 +0000 Subject: [PATCH] FIxed AppContext.RAID_ADJUSTMENTS failure --- Libraries/Core/Models/Spt/Location/RaidChanges.cs | 4 ++-- .../Core/Services/RaidTimeAdjustmentService.cs | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Libraries/Core/Models/Spt/Location/RaidChanges.cs b/Libraries/Core/Models/Spt/Location/RaidChanges.cs index a62a3bab..2c502e78 100644 --- a/Libraries/Core/Models/Spt/Location/RaidChanges.cs +++ b/Libraries/Core/Models/Spt/Location/RaidChanges.cs @@ -1,4 +1,4 @@ -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Core.Models.Spt.Location; @@ -11,5 +11,5 @@ public record RaidChanges public double? StaticLootPercent { get; set; } [JsonPropertyName("simulatedRaidStartSeconds")] - public int? SimulatedRaidStartSeconds { get; set; } + public double? SimulatedRaidStartSeconds { get; set; } } diff --git a/Libraries/Core/Services/RaidTimeAdjustmentService.cs b/Libraries/Core/Services/RaidTimeAdjustmentService.cs index 8aa636d9..f533a8cf 100644 --- a/Libraries/Core/Services/RaidTimeAdjustmentService.cs +++ b/Libraries/Core/Services/RaidTimeAdjustmentService.cs @@ -73,11 +73,12 @@ public class RaidTimeAdjustmentService( mapBase.Waves = mapBase.Waves.Where(x => x.TimeMax > raidAdjustments.SimulatedRaidStartSeconds).ToList(); // Adjust wave min/max times to match new simulated start + var startSeconds = raidAdjustments.SimulatedRaidStartSeconds.GetValueOrDefault(1); foreach (var wave in mapBase.Waves) { // Dont let time fall below 0 - wave.TimeMax -= Math.Max(raidAdjustments.SimulatedRaidStartSeconds ?? 1, 0); - wave.TimeMax -= Math.Max(raidAdjustments.SimulatedRaidStartSeconds ?? 1, 0); + wave.TimeMin -= (int)Math.Max(startSeconds, 0); + wave.TimeMax -= (int)Math.Max(startSeconds, 0); } _logger.Debug( @@ -141,11 +142,11 @@ public class RaidTimeAdjustmentService( // Store time reduction percent in app context so loot gen can pick it up later _applicationContext.AddValue( ContextVariableType.RAID_ADJUSTMENTS, - new + new RaidChanges { - dynamicLootPercent = Math.Max(raidTimeRemainingPercent, mapSettings.MinDynamicLootPercent), - staticLootPercent = Math.Max(raidTimeRemainingPercent, mapSettings.MinStaticLootPercent), - simulatedRaidStartSeconds = simulatedRaidStartTimeMinutes * 60, + DynamicLootPercent = Math.Max(raidTimeRemainingPercent, mapSettings.MinDynamicLootPercent), + StaticLootPercent = Math.Max(raidTimeRemainingPercent, mapSettings.MinStaticLootPercent), + SimulatedRaidStartSeconds = simulatedRaidStartTimeMinutes * 60, } ); }