Always initialize IADS coalition lua tables.

These are read unconditionally, but were only initialized when the
coalition had nodes. When a coalition had no nodes, this caused a nil
access. It's unclear if that had any symptoms, but I expect at the very
least it would break the remainder of the script (so a non-functioning
blue IADS if the red IADS had no nodes).

There's a very small chance this is the culprit behind
https://github.com/dcs-liberation/dcs_liberation/issues/3073.
This commit is contained in:
Dan Albert
2023-07-12 19:44:02 -07:00
committed by Raffson
parent 12cdb8646c
commit 2c7e877086
2 changed files with 23 additions and 1 deletions

View File

@@ -194,6 +194,11 @@ class LuaGenerator:
# Generate IADS Lua Item
iads_object = lua_data.add_item("IADS")
# These should always be created even if they are empty.
iads_object.get_or_create_item("BLUE")
iads_object.get_or_create_item("RED")
# Should probably do the same with all the roles... but the script is already
# tolerant of those being empty.
for node in self.game.theater.iads_network.skynet_nodes(self.game):
coalition = iads_object.get_or_create_item("BLUE" if node.player else "RED")
iads_type = coalition.get_or_create_item(node.iads_role.value)