Fix IADS exception

Exception was caused by `skynet_nodes` trying to generate node for dead units, which would eventually be thrown by `dcs_name_for_group`
This commit is contained in:
Raffson 2022-11-04 18:47:46 +01:00
parent 206c046382
commit 5896bdccc1
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99

View File

@ -53,7 +53,7 @@ class SkynetNode:
# 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 IadsNetworkException(f"{group.name} has no skynet usable units")
else:
# Use the GroupName for SAMs, SAMAsEWR and PDs
return group.group_name
@ -121,6 +121,10 @@ class IadsNetwork:
# Skip culled ground objects
continue
all_dead = not any([x.alive for x in node.group.units])
if all_dead:
continue
# SkynetNode.from_group(node.group) may raise an exception
# (originating from SkynetNode.dcs_name_for_group)
# but if it does, we want to know because it's supposed to be impossible afaict
@ -217,7 +221,7 @@ class IadsNetwork:
node: Optional[IadsNetworkNode] = None
for group in tgo.groups:
# TODO Cleanup
if isinstance(group, IadsGroundGroup):
if isinstance(group, IadsGroundGroup) and group.alive_units > 0:
# The first IadsGroundGroup is always the primary Group
if not node and group.iads_role.participate:
# Primary Node