From e799f73b1d58da5b2801ce4ba8f790bed15d9fe4 Mon Sep 17 00:00:00 2001 From: Robbie Lodico Date: Thu, 16 Jan 2025 12:09:51 +0100 Subject: [PATCH] chore: add debugging information for #2394 --- Intersect.Server.Core/General/Time.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Intersect.Server.Core/General/Time.cs b/Intersect.Server.Core/General/Time.cs index c7780c0d34..11b841e893 100644 --- a/Intersect.Server.Core/General/Time.cs +++ b/Intersect.Server.Core/General/Time.cs @@ -1,4 +1,5 @@ using Intersect.GameObjects; +using Intersect.Logging; using Intersect.Server.Networking; using Intersect.Utilities; @@ -54,9 +55,22 @@ public static void Update() } else { - sGameTime = sGameTime.Add(new TimeSpan(0, 0, 0, 0, (int)(1000 * timeBase.Rate))); - - //Not sure if Rate is negative if time will go backwards but we can hope! + var timeWas = sGameTime; + var timeRate = timeBase.Rate; + var addedTime = new TimeSpan(0, 0, 0, 0, (int)(1000 * timeRate)); + + // Not sure if Rate is negative if time will go backwards but we can hope! + try + { + sGameTime = sGameTime.Add(addedTime); + } + catch (ArgumentOutOfRangeException exception) + { + // Log the error with the value of timeBase.Rate and pass the exception + Log.Error(exception, $"Failed to update game time. Time was {timeWas}, Added Rate was {timeRate}, Added time span was {addedTime}"); + // Rethrow the exception to crash the server o_o !!! + throw; + } } //Calculate what "timeRange" we should be in, if we're not then switch and notify the world