Skip to content

Commit

Permalink
Bugfix: Duplicated PitEntry
Browse files Browse the repository at this point in the history
In team events, when changing driver, you would get two PitEntry events
  • Loading branch information
dennis committed Aug 3, 2021
1 parent f9d9151 commit d4f9555
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Components/IRacing/Trackers/PitUsageTracker.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Slipstream.Components.IRacing.Models;
using Slipstream.Shared;

using System;

#nullable enable
Expand Down Expand Up @@ -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;
Expand All @@ -54,7 +58,7 @@ public void Handle(GameState.IState currentState, IRacingDataTrackerState state,
{
float? fuelLeft = null;

if(localUser)
if (localUser)
{
fuelLeft = currentState.FuelLevel;
}
Expand Down

0 comments on commit d4f9555

Please sign in to comment.