File tree Expand file tree Collapse file tree
src/Helldivers-2-Core/Mapping Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,8 +66,15 @@ internal MappingContext(WarId warId,
6666 InvariantWarStatus = warStatuses . FirstOrDefault ( ) . Value
6767 ?? throw new InvalidOperationException ( "No warstatus available" ) ;
6868
69+
6970 var gameTime = DateTime . UnixEpoch . AddSeconds ( warInfo . StartDate + InvariantWarStatus . Time ) ;
70- GameTimeDeviation = DateTime . UtcNow . Subtract ( gameTime ) ;
71+ GameTimeDeviation = TruncateToSeconds ( DateTime . UtcNow ) . Subtract ( gameTime ) ;
7172 RelativeGameStart = DateTime . UnixEpoch . Add ( GameTimeDeviation ) . AddSeconds ( warInfo . StartDate ) ;
7273 }
74+
75+ /// <summary>
76+ /// ArrowHead doesn't send timestamps more accurate than seconds, so we truncate our relative time to seconds.
77+ /// This prevents timestamps for the same value from being different (due to milli/micro second differences).
78+ /// </summary>
79+ private static DateTime TruncateToSeconds ( DateTime dateTime ) => dateTime . AddTicks ( - ( dateTime . Ticks % TimeSpan . TicksPerSecond ) ) ;
7380}
You can’t perform that action at this time.
0 commit comments