From b141320052be68ad463542fe3353a0b50521d437 Mon Sep 17 00:00:00 2001 From: zhexu14 <64713351+zhexu14@users.noreply.github.com> Date: Mon, 9 Jun 2025 15:47:03 +1000 Subject: [PATCH] Remove package when last flight in package is cancelled (#3507) This PR handles the scenario where the last flight in a package is cancelled (deleted). Previously, the package would show "No mission". With this PR, the package is cancelled (deleted). --- changelog.md | 1 + qt_ui/models.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/changelog.md b/changelog.md index 2f7d9732..da4b16ee 100644 --- a/changelog.md +++ b/changelog.md @@ -10,6 +10,7 @@ Saves from 13.x are not compatible with 14.0.0. * **[UI]** Air Wing and Transfers buttons disabled when no game is loaded as pressing them without a game loaded resulted in a crash. * **[UI]** Units are restored to full health when repaired. +* **[UI]** A package is cancelled (deleted) when the last flight in the package is cancelled instead of showing "No mission". # 13.0.0 diff --git a/qt_ui/models.py b/qt_ui/models.py index a609a290..441fa1dc 100644 --- a/qt_ui/models.py +++ b/qt_ui/models.py @@ -172,6 +172,12 @@ class PackageModel(QAbstractListModel): else: flight.abort() EventStream.put_nowait(GameUpdateEvents().update_flight(flight)) + # If there are no more flights in the package, delete the package. + if len(self.package.flights) == 0: + 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: """Removes the given flight from the package."""