From 5a732acf64474ff809d972b2e372852f6d6db871 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 27 May 2021 14:15:27 -0700 Subject: [PATCH] Fix creating new fights to create player pilots. This is just a hack that automatically converts the assigned pilots to players if needed. This really needs to be replaced with a roster editor like the flight edit screen has, but that also requires squadron selection, which isn't a thing we're ready for yet. https://github.com/dcs-liberation/dcs_liberation/issues/1139 --- qt_ui/windows/mission/flight/QFlightCreator.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qt_ui/windows/mission/flight/QFlightCreator.py b/qt_ui/windows/mission/flight/QFlightCreator.py index 9a51b337..cfccee58 100644 --- a/qt_ui/windows/mission/flight/QFlightCreator.py +++ b/qt_ui/windows/mission/flight/QFlightCreator.py @@ -1,3 +1,4 @@ +import logging from typing import Optional from PySide2.QtCore import Qt, Signal @@ -184,7 +185,14 @@ class QFlightCreator(QDialog): divert, custom_name=self.custom_name_text, ) - flight.client_count = self.client_slots_spinner.value() + for pilot, idx in zip(flight.pilots, range(self.client_slots_spinner.value())): + if pilot is None: + logging.error( + f"Cannot create client slot because {flight} has no pilot for " + f"aircraft {idx}" + ) + continue + pilot.player = True # noinspection PyUnresolvedReferences self.created.emit(flight)