Skip to content

Commit

Permalink
We've already established that currentStatus is null and we can pro…
Browse files Browse the repository at this point in the history
…ceed a little further if `lastStatus` is null.
  • Loading branch information
Tkael committed Jun 22, 2024
1 parent 8a75494 commit 289b5b7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions StatusMonitor/StatusMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,13 @@ public void HandleStatus(Status status)
EDDI.Instance.Cmdr.credits = Convert.ToUInt64( currentStatus.credit_balance );
}

if ( currentStatus is null || lastStatus is null ) { return; }

// Update vehicle information
if ( !string.IsNullOrEmpty( currentStatus.vehicle ) && currentStatus.vehicle != lastStatus.vehicle )
if ( !string.IsNullOrEmpty( currentStatus.vehicle ) && currentStatus.vehicle != lastStatus?.vehicle )
{
if ( EDDI.Instance.Vehicle != currentStatus.vehicle )
{
var statusSummary = new Dictionary<string, Status> { { "isStatus", currentStatus }, { "wasStatus", lastStatus } };
Logging.Debug( $"Status changed vehicle from {lastStatus.vehicle} to {currentStatus.vehicle}", statusSummary );
Logging.Debug( $"Status changed vehicle from {lastStatus?.vehicle ?? "<NULL>"} to {currentStatus.vehicle}", statusSummary );
EDDI.Instance.Vehicle = currentStatus.vehicle;
}
}
Expand All @@ -93,6 +91,8 @@ public void HandleStatus(Status status)
EDDI.Instance.CurrentShip.fuelInReservoir = currentStatus.fuelInReservoir ?? 0;
}

if ( lastStatus is null ) { return; }

// Trigger events for changed status, as applicable
if ( currentStatus.shields_up != lastStatus.shields_up && currentStatus.vehicle == lastStatus.vehicle )
{
Expand Down

0 comments on commit 289b5b7

Please sign in to comment.