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,
|
||||
]:
|
||||
# Use UnitName for EWR, CommandCenter, Comms, Power
|
||||
is_dead = group.alive_units == 0
|
||||
for unit in group.units:
|
||||
# Check for alive units in the group
|
||||
if unit.alive:
|
||||
if unit.alive or (is_dead and unit.is_static):
|
||||
# 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
|
||||
if group.units[0].is_static:
|
||||
# Statics will be placed as dead unit
|
||||
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")
|
||||
# Raise error if there is no skynet capable unit in this group
|
||||
raise IadsNetworkException(f"Group {group.name} has no skynet usable units")
|
||||
else:
|
||||
# Use the GroupName for SAMs, SAMAsEWR and PDs
|
||||
return group.group_name
|
||||
@ -134,11 +133,11 @@ class IadsNetwork:
|
||||
# Skip culled ground objects
|
||||
continue
|
||||
|
||||
# HOTFIX! Skip non-static nodes with no alive units left
|
||||
# Delete this as soon as PRs #2285, #2286 & #2287 are merged
|
||||
unit_count = len(node.group.units)
|
||||
is_static = node.group.units[0].is_static if unit_count > 0 else False
|
||||
if node.group.alive_units == 0 and not is_static:
|
||||
if node.group.alive_units == 0 and not node.group.has_statics:
|
||||
# Skip non-static nodes with no alive units left
|
||||
# Dead static nodes can be added to skynet as these are added to the
|
||||
# mission as dead unit. Non static will not be added to the mission and
|
||||
# are therefore not accessible by skynet
|
||||
continue
|
||||
|
||||
# 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
|
||||
skynet_node = SkynetNode.from_group(node.group)
|
||||
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(
|
||||
skynet_node.player
|
||||
) and not game.iads_considerate_culling(connection.ground_object):
|
||||
|
||||
@ -185,6 +185,10 @@ class TheaterGroup:
|
||||
def alive_units(self) -> int:
|
||||
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:
|
||||
"""Calculate the maximum detection range of the TheaterGroup"""
|
||||
ranges = (u.detection_range for u in self.units if u.is_anti_air)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user