From d4f9555206ade95600e21d7ea4e2c31181231bf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20M=C3=B8llegaard=20Pedersen?= Date: Tue, 3 Aug 2021 20:52:58 +0200 Subject: [PATCH] Bugfix: Duplicated PitEntry In team events, when changing driver, you would get two PitEntry events --- Components/IRacing/Trackers/PitUsageTracker.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Components/IRacing/Trackers/PitUsageTracker.cs b/Components/IRacing/Trackers/PitUsageTracker.cs index 5679ae8e..9500e4fd 100644 --- a/Components/IRacing/Trackers/PitUsageTracker.cs +++ b/Components/IRacing/Trackers/PitUsageTracker.cs @@ -1,5 +1,6 @@ using Slipstream.Components.IRacing.Models; using Slipstream.Shared; + using System; #nullable enable @@ -29,7 +30,10 @@ public void Handle(GameState.IState currentState, IRacingDataTrackerState state, state.CarsTracked.Add(car.CarIdx, carState); } - if (carState.LastOnPitRoad != onPitRoad) + // Ignore car data if the location is NotInWord. In team events when changing drivers, it seems that the + // car is NotInWorld before returning to pits - and that will give two PitEnter events. To avoid this, we + // ignore data with NotInWorld.. NotInWorld also happens when you blink, but we can also ignore these. + if (carState.LastOnPitRoad != onPitRoad && car.Location != IIRacingEventFactory.CarLocation.NotInWorld) { var localUser = currentState.DriverCarIdx == car.CarIdx; var now = currentState.SessionTime; @@ -54,7 +58,7 @@ public void Handle(GameState.IState currentState, IRacingDataTrackerState state, { float? fuelLeft = null; - if(localUser) + if (localUser) { fuelLeft = currentState.FuelLevel; }