From c2ee169d16d61a713c649e21451a07d403e9f96c Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Fri, 6 Nov 2020 18:11:08 -0800 Subject: [PATCH] Fix regeneration of base defenses on capture. I messed up the counting here and was counting *every* object rather than just the base defenses, so it was very unlikely that we'd hit base defenses on the second object, which is the only index valid for SAM generation. That logic maybe needs to be different, but this restores the previous behavior. --- theater/controlpoint.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/theater/controlpoint.py b/theater/controlpoint.py index 4aaedf21..7c8963c6 100644 --- a/theater/controlpoint.py +++ b/theater/controlpoint.py @@ -17,7 +17,7 @@ from game import db from gen.ground_forces.combat_stance import CombatStance from .base import Base from .missiontarget import MissionTarget -from .theatergroundobject import TheaterGroundObject +from .theatergroundobject import SamGroundObject, TheaterGroundObject if TYPE_CHECKING: from game import Game @@ -226,8 +226,16 @@ class ControlPoint(MissionTarget): # Handle cyclic dependency. from .start_generator import generate_airbase_defense_group - for idx, ground_object in enumerate(self.ground_objects): + base_defense_idx = 0 + for ground_object in self.ground_objects: + if not isinstance(ground_object, SamGroundObject): + continue + if not ground_object.airbase_group: + continue + + # Reset in case we replace the SAM with something else. + ground_object.skynet_capable = False ground_object.groups = [] - if ground_object.airbase_group and faction_name != "": - generate_airbase_defense_group(idx, ground_object, - faction_name, game) + generate_airbase_defense_group(base_defense_idx, ground_object, + faction_name, game) + base_defense_idx += 1