Fix helicopter spawning inside each other

Also use NoParkingSlotError for better error handling if no helipads are available
This commit is contained in:
RndName 2022-02-24 21:47:37 +01:00
parent c88fa6d2af
commit 6f8c30ec81
No known key found for this signature in database
GPG Key ID: 5EF516FD9537F7C0

View File

@ -233,7 +233,7 @@ class FlightGroupSpawner:
# helipad = self.helipads[cp][0] # helipad = self.helipads[cp][0]
helipad = self.helipads[cp].pop() helipad = self.helipads[cp].pop()
except IndexError as ex: except IndexError as ex:
raise RuntimeError(f"Not enough helipads available at {cp}") from ex raise NoParkingSlotError(f"Not enough helipads available at {cp}") from ex
group = self._generate_at_group(name, helipad) group = self._generate_at_group(name, helipad)
@ -246,12 +246,14 @@ class FlightGroupSpawner:
group.points[0].type = "TakeOffParkingHot" group.points[0].type = "TakeOffParkingHot"
for i in range(self.flight.count - 1): for i in range(self.flight.count - 1):
try:
helipad = self.helipads[cp].pop()
except IndexError as ex:
raise NoParkingSlotError(
f"Not enough helipads available at {cp}"
) from ex
group.units[1 + i].position = copy.copy(helipad.position) group.units[1 + i].position = copy.copy(helipad.position)
group.units[1 + i].heading = helipad.units[0].heading group.units[1 + i].heading = helipad.units[0].heading
try:
self.helipads[cp].pop()
except IndexError as ex:
raise RuntimeError(f"Not enough helipads available at {cp}") from ex
return group return group
def dcs_start_type(self) -> DcsStartType: def dcs_start_type(self) -> DcsStartType: