Skip to content

Commit 0c6c096

Browse files
committed
sim: fix prespan of virtual-controller-only IFRs
1 parent 358426a commit 0c6c096

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pkg/sim/spawn.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -506,12 +506,16 @@ func (s *Sim) spawnDepartures() {
506506

507507
// Possibly spawn another aircraft, depending on how much time has
508508
// passed since the last one.
509-
if now.After(depState.NextIFRSpawn) && !s.prespawnUncontrolledOnly {
509+
if now.After(depState.NextIFRSpawn) {
510510
if ac, err := s.makeNewIFRDeparture(airport, runway); ac != nil && err == nil {
511-
s.addDepartureToPool(ac, runway)
512-
r := scaleRate(depState.IFRSpawnRate, s.State.LaunchConfig.DepartureRateScale)
513-
depState.NextIFRSpawn = now.Add(randomWait(r, false))
514-
changed()
511+
if !s.prespawnUncontrolledOnly || !s.isControlled(ac, true) { // keep virtual-controller-only ones
512+
s.addDepartureToPool(ac, runway)
513+
r := scaleRate(depState.IFRSpawnRate, s.State.LaunchConfig.DepartureRateScale)
514+
depState.NextIFRSpawn = now.Add(randomWait(r, false))
515+
changed()
516+
} else {
517+
s.State.DeleteAircraft(ac)
518+
}
515519
}
516520
}
517521
if now.After(depState.NextVFRSpawn) {

0 commit comments

Comments
 (0)