From 3369892a36f29a15ef56bdc0dea2955651722c1a Mon Sep 17 00:00:00 2001 From: Justinas S Date: Sun, 21 May 2023 02:13:31 +0300 Subject: [PATCH] Fix laps driven estimate calculation and a random case when grip resets to 60% In our servers we observed that in some cases info.CurrentSpeed comes as NaN - this corrupts whole grip calculation, and resets grip value to 0 (it is clamped to 60%). --- LiveConditionsServerPlugin.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LiveConditionsServerPlugin.cs b/LiveConditionsServerPlugin.cs index 6d64563..a4f0793 100644 --- a/LiveConditionsServerPlugin.cs +++ b/LiveConditionsServerPlugin.cs @@ -202,7 +202,7 @@ private async Task UpdateStateAsync() { if (PluginManager != null) { foreach (var info in PluginManager.GetDriverInfos()) { - if (info?.IsConnected == true) { + if (info?.IsConnected == true && !float.IsNaN(info.CurrentSpeed) && info.CurrentSpeed > 0) { var drivenDistanceKm = info.CurrentSpeed * UpdateRainPeriod.TotalHours; _drivenLapsEstimate += drivenDistanceKm / _lapLengthKm; } @@ -529,4 +529,4 @@ private static double GetRoadTemperatureCoefficient(WeatherType type) { } } } -} \ No newline at end of file +}