Handle scenaio where flight that is not added to the ATO (flight in the process of being created) is deleted (#3512)

This commit is contained in:
zhexu14 2025-06-30 19:53:10 +10:00 committed by GitHub
parent 7b1c84d347
commit bcdd9e1807
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -174,10 +174,15 @@ class PackageModel(QAbstractListModel):
EventStream.put_nowait(GameUpdateEvents().update_flight(flight)) EventStream.put_nowait(GameUpdateEvents().update_flight(flight))
# If there are no more flights in the package, delete the package. # If there are no more flights in the package, delete the package.
if len(self.package.flights) == 0: if len(self.package.flights) == 0:
flight.squadron.coalition.ato.remove_package(flight.package) # Check if package is in ATO first as flight may still be "tentative" i.e.
# Update ATO model so packages list is refreshed. # not added to the ATO yet.
is_player = flight.squadron.coalition.player if flight.package in flight.squadron.coalition.ato.packages:
self.game_model.ato_model_for(is_player).replace_from_game(is_player) flight.squadron.coalition.ato.remove_package(flight.package)
# Update ATO model so packages list is refreshed.
is_player = flight.squadron.coalition.player
self.game_model.ato_model_for(is_player).replace_from_game(
is_player
)
def delete_flight(self, flight: Flight) -> None: def delete_flight(self, flight: Flight) -> None:
"""Removes the given flight from the package.""" """Removes the given flight from the package."""