Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
DeadDropSystem: check lifecycle and null refs on compromise. (new-fro…
Browse files Browse the repository at this point in the history
…ntiers-14#2251)

* DeadDropSystem: compromise checks teardown

* DeadDropSystem: check teardown
  • Loading branch information
whatston3 authored Oct 15, 2024
1 parent 018a5a6 commit 3517de1
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Content.Server/_NF/Smuggling/DeadDropSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,18 @@ private void OnStationShutdown(EntityUid stationUid, StationDeadDropComponent co

public void CompromiseDeadDrop(EntityUid uid, DeadDropComponent _)
{
//Get our station: FIXME - check lifecycle on entities before adding another drop.
// Remove the dead drop.
RemComp<DeadDropComponent>(uid);

var station = _station.GetOwningStation(uid);
// If station is terminating, or if we aren't on one, nothing to do here.
if (station == null ||
!station.Value.Valid ||
MetaData(station.Value).EntityLifeStage >= EntityLifeStage.Terminating)
{
return;
}

//Remove the dead drop.
RemComp<DeadDropComponent>(uid);
//Find a new potential dead drop to spawn.
var deadDropQuery = EntityManager.EntityQueryEnumerator<PotentialDeadDropComponent>();
List<(EntityUid ent, PotentialDeadDropComponent comp)> potentialDeadDrops = new();
Expand All @@ -220,6 +227,12 @@ public void CompromiseDeadDrop(EntityUid uid, DeadDropComponent _)
if (potentialDeadDrops.Count > 0)
{
var item = _random.Pick(potentialDeadDrops);

// If the item is tearing down, do nothing for now.
// FIXME: separate sector-wide scheduler?
if (MetaData(item.ent).EntityLifeStage >= EntityLifeStage.Terminating)
return;

AddDeadDrop(item.ent);
_sawmill.Debug($"Dead drop at {uid} compromised, new drop at {item.ent}!");
}
Expand Down

0 comments on commit 3517de1

Please sign in to comment.