Attempt at fixing Carrier killed in state.json but not being removed from game, issue #2405. GenericCarrierGenerator.generate() will now generate the ship group with an array that only contains alive ship units, just like GroundObjectGenerator.generate() has previously done.

Carrier groups will now also show up as destroyed/damaged on the map when the carrier is sunk.

cherry-pick from e53dc5b80b77154db5271cc9f03bb9e98f79febe
This commit is contained in:
MetalStormGhost 2022-09-10 10:55:01 +03:00 committed by RndName
parent bfed69573f
commit bde22b52ea
2 changed files with 13 additions and 3 deletions

View File

@ -405,7 +405,17 @@ class GenericCarrierGenerator(GroundObjectGenerator):
logging.warning(f"Found empty carrier group in {self.control_point}")
continue
ship_group = self.create_ship_group(group.group_name, group.units, atc)
ship_units = []
for unit in group.units:
if unit.alive:
# All alive Ships
ship_units.append(unit)
if not ship_units:
# Empty array (no alive units), stop here
return
ship_group = self.create_ship_group(group.group_name, ship_units, atc)
# Always steam into the wind, even if the carrier is being moved.
# There are multiple unsimulated hours between turns, so we can
@ -414,7 +424,7 @@ class GenericCarrierGenerator(GroundObjectGenerator):
brc = self.steam_into_wind(ship_group)
# Set Carrier Specific Options
if g_id == 0:
if g_id == 0 and self.control_point.runway_is_operational():
# Get Correct unit type for the carrier.
# This will upgrade to super carrier if option is enabled
carrier_type = self.carrier_type

View File

@ -1200,7 +1200,7 @@ class NavalControlPoint(ControlPoint, ABC):
# while its escorts are still alive.
for group in self.find_main_tgo().groups:
for u in group.units:
if u.type in [
if u.alive and u.type in [
Forrestal,
Stennis,
LHA_Tarawa,