mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Fix IADS network error caused by dead groups
Fixed an error which would occur when dead units which are non static would be added as secondary node during the skynet lua data generation. This should in general not be possible as connection nodes and power sources are currently most of the time static. cherry-pick from e1b530e4fc8262fd81950ea1190b3e441f3d065e
This commit is contained in:
parent
f2e8a77862
commit
9ba717fd82
@ -44,15 +44,14 @@ class SkynetNode:
|
|||||||
IadsRole.POWER_SOURCE,
|
IadsRole.POWER_SOURCE,
|
||||||
]:
|
]:
|
||||||
# Use UnitName for EWR, CommandCenter, Comms, Power
|
# Use UnitName for EWR, CommandCenter, Comms, Power
|
||||||
|
is_dead = group.alive_units == 0
|
||||||
for unit in group.units:
|
for unit in group.units:
|
||||||
# Check for alive units in the group
|
if unit.alive or (is_dead and unit.is_static):
|
||||||
if unit.alive:
|
# Return first alive unit within the group or otherwise return the
|
||||||
|
# first static object as these will still be added to the mission
|
||||||
return unit.unit_name
|
return unit.unit_name
|
||||||
if group.units[0].is_static:
|
# Raise error if there is no skynet capable unit in this group
|
||||||
# Statics will be placed as dead unit
|
raise IadsNetworkException(f"Group {group.name} has no skynet usable units")
|
||||||
return group.units[0].unit_name
|
|
||||||
# If no alive unit is available and not static raise error
|
|
||||||
raise IadsNetworkException("Group has no skynet usable units")
|
|
||||||
else:
|
else:
|
||||||
# Use the GroupName for SAMs, SAMAsEWR and PDs
|
# Use the GroupName for SAMs, SAMAsEWR and PDs
|
||||||
return group.group_name
|
return group.group_name
|
||||||
@ -134,11 +133,11 @@ class IadsNetwork:
|
|||||||
# Skip culled ground objects
|
# Skip culled ground objects
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# HOTFIX! Skip non-static nodes with no alive units left
|
if node.group.alive_units == 0 and not node.group.has_statics:
|
||||||
# Delete this as soon as PRs #2285, #2286 & #2287 are merged
|
# Skip non-static nodes with no alive units left
|
||||||
unit_count = len(node.group.units)
|
# Dead static nodes can be added to skynet as these are added to the
|
||||||
is_static = node.group.units[0].is_static if unit_count > 0 else False
|
# mission as dead unit. Non static will not be added to the mission and
|
||||||
if node.group.alive_units == 0 and not is_static:
|
# are therefore not accessible by skynet
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# SkynetNode.from_group(node.group) may raise an exception
|
# SkynetNode.from_group(node.group) may raise an exception
|
||||||
@ -146,6 +145,9 @@ class IadsNetwork:
|
|||||||
# but if it does, we want to know because it's supposed to be impossible afaict
|
# but if it does, we want to know because it's supposed to be impossible afaict
|
||||||
skynet_node = SkynetNode.from_group(node.group)
|
skynet_node = SkynetNode.from_group(node.group)
|
||||||
for connection in node.connections.values():
|
for connection in node.connections.values():
|
||||||
|
if connection.alive_units == 0 and not connection.has_statics:
|
||||||
|
# Skip non static and dead connection nodes. See comment above
|
||||||
|
continue
|
||||||
if connection.ground_object.is_friendly(
|
if connection.ground_object.is_friendly(
|
||||||
skynet_node.player
|
skynet_node.player
|
||||||
) and not game.iads_considerate_culling(connection.ground_object):
|
) and not game.iads_considerate_culling(connection.ground_object):
|
||||||
|
|||||||
@ -185,6 +185,10 @@ class TheaterGroup:
|
|||||||
def alive_units(self) -> int:
|
def alive_units(self) -> int:
|
||||||
return sum(unit.alive for unit in self.units)
|
return sum(unit.alive for unit in self.units)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def has_statics(self) -> bool:
|
||||||
|
return any(unit.is_static for unit in self.units)
|
||||||
|
|
||||||
def max_detection_range(self) -> Distance:
|
def max_detection_range(self) -> Distance:
|
||||||
"""Calculate the maximum detection range of the TheaterGroup"""
|
"""Calculate the maximum detection range of the TheaterGroup"""
|
||||||
ranges = (u.detection_range for u in self.units if u.is_anti_air)
|
ranges = (u.detection_range for u in self.units if u.is_anti_air)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user