Skip to content

Commit

Permalink
Fix Rollbar@ 26366 - null reference exception when trying to act on c…
Browse files Browse the repository at this point in the history
…argo after handling a non-cargo mission.
  • Loading branch information
Tkael committed Aug 10, 2024
1 parent 14505fd commit a98cfbb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions CargoMonitor/CargoMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,11 @@ private void handleMissionAbandonedEvent(MissionAbandonedEvent @event)
private void _handleMissionAbandonedEvent(MissionAbandonedEvent @event)
{
var cargo = GetCargoWithMissionId(@event.missionid, out var amount);
cargo.RemoveDetailedQty( @event.missionid, amount );
cargo.AddDetailedQty(CargoType.stolen, amount, cargo.price);
if ( cargo != null )
{
cargo.RemoveDetailedQty( @event.missionid, amount );
cargo.AddDetailedQty( CargoType.stolen, amount, cargo.price );
}
}

// Check to see if this is a cargo mission and update our inventory accordingly
Expand Down Expand Up @@ -628,6 +631,7 @@ public Cargo GetCargoWithEDName(string edname)
return inventory.FirstOrDefault(c => c.edname.ToLowerInvariant() == edname);
}

[CanBeNull]
public Cargo GetCargoWithMissionId ( long missionid, out int amount )
{
amount = 0;
Expand Down

0 comments on commit a98cfbb

Please sign in to comment.