Skip to content

Commit

Permalink
chore: add debugging information for #2394
Browse files Browse the repository at this point in the history
  • Loading branch information
lodicolo committed Jan 16, 2025
1 parent baaa0cb commit e799f73
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions Intersect.Server.Core/General/Time.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Intersect.GameObjects;
using Intersect.Logging;
using Intersect.Server.Networking;
using Intersect.Utilities;

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e799f73

Please sign in to comment.