Fix spawning unused aircraft.

These are assigned a squadron even though they're unused as a hack. We
need to tolerate these aircraft having no pilot assigned since that's
the desired case for unused aircraft (though only happens when the
squadron runs out of pilots, which should be fixed).
This commit is contained in:
Dan Albert 2021-06-16 20:11:36 -07:00
parent 24884e4a77
commit 7170a7b302
2 changed files with 2 additions and 4 deletions

View File

@ -122,7 +122,7 @@ class Event:
def commit_air_losses(self, debriefing: Debriefing) -> None:
for loss in debriefing.air_losses.losses:
if (
if loss.pilot is not None and (
not loss.pilot.player
or not self.game.settings.invulnerable_player_pilots
):

View File

@ -19,7 +19,7 @@ from gen.flights.flight import Flight
@dataclass(frozen=True)
class FlyingUnit:
flight: Flight
pilot: Pilot
pilot: Optional[Pilot]
@dataclass(frozen=True)
@ -70,8 +70,6 @@ class UnitMap:
name = str(unit.name)
if name in self.aircraft:
raise RuntimeError(f"Duplicate unit name: {name}")
if pilot is None:
raise ValueError(f"{name} has no pilot assigned")
self.aircraft[name] = FlyingUnit(flight, pilot)
if flight.cargo is not None:
self.add_airlift_units(group, flight.cargo)