Fix too many ground spawns being popped

This commit is contained in:
Raffson 2024-07-27 20:52:13 +02:00
parent 0ecbd81a20
commit 8bc902fe64
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99

View File

@ -496,21 +496,20 @@ class FlightGroupSpawner:
) -> Optional[FlyingGroup[Any]]: ) -> Optional[FlyingGroup[Any]]:
is_airbase = False is_airbase = False
is_roadbase = False is_roadbase = False
ground_spawn = None
try: if not is_large and len(self.ground_spawns_roadbase[cp]) > 0:
if is_large: ground_spawn = self.ground_spawns_roadbase[cp].pop()
if len(self.ground_spawns_large[cp]) > 0: is_roadbase = True
ground_spawn = self.ground_spawns_large[cp].pop() elif not is_large and len(self.ground_spawns[cp]) > 0:
is_airbase = True ground_spawn = self.ground_spawns[cp].pop()
else: is_airbase = True
if len(self.ground_spawns_roadbase[cp]) > 0: elif len(self.ground_spawns_large[cp]) > 0:
ground_spawn = self.ground_spawns_roadbase[cp].pop() ground_spawn = self.ground_spawns_large[cp].pop()
is_roadbase = True is_airbase = True
if len(self.ground_spawns[cp]) > 0:
ground_spawn = self.ground_spawns[cp].pop() if ground_spawn is None:
is_airbase = True logging.warning("Not enough ground spawn slots available at " + cp.name)
except IndexError as ex:
logging.warning("Not enough ground spawn slots available at " + str(ex))
return None return None
group = self._generate_at_group(name, ground_spawn[0]) group = self._generate_at_group(name, ground_spawn[0])
@ -547,14 +546,12 @@ class FlightGroupSpawner:
for i in range(self.flight.count - 1): for i in range(self.flight.count - 1):
try: try:
terrain = cp.coalition.game.theater.terrain terrain = cp.coalition.game.theater.terrain
if is_large: if not is_large and len(self.ground_spawns_roadbase[cp]) > 0:
if len(self.ground_spawns_large[cp]) > 0: ground_spawn = self.ground_spawns_roadbase[cp].pop()
ground_spawn = self.ground_spawns_large[cp].pop() elif not is_large and len(self.ground_spawns[cp]) > 0:
else: ground_spawn = self.ground_spawns[cp].pop()
if len(self.ground_spawns_roadbase[cp]) > 0: elif len(self.ground_spawns_large[cp]) > 0:
ground_spawn = self.ground_spawns_roadbase[cp].pop() ground_spawn = self.ground_spawns_large[cp].pop()
else:
ground_spawn = self.ground_spawns[cp].pop()
group.units[1 + i].position = Point( group.units[1 + i].position = Point(
ground_spawn[0].x, ground_spawn[0].y, terrain=terrain ground_spawn[0].x, ground_spawn[0].y, terrain=terrain
) )