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
This commit is contained in:
Dan Albert 2021-05-27 14:15:27 -07:00
parent e4e06e0a6e
commit 5a732acf64

View File

@ -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)