From afb02bbb43933ca94b37845cda18cd1dcb979d6d Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 14 Jan 2025 19:46:49 -0600 Subject: [PATCH] Handle null templates in AtBDynamicScenarioFactory Prevented null templates from causing issues in scenario generation by adding a check and skipping them. This ensures better stability and avoids potential crashes during processing. --- .../mekhq/campaign/mission/AtBDynamicScenarioFactory.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index f2363eca8a..235edaa126 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -3695,6 +3695,12 @@ public static void setPlayerDeploymentTurns(AtBDynamicScenario scenario, Campaig // it there would likely break things for non-StratCon users. -- Illiani Collection templates = scenario.getPlayerForceTemplates().values(); for (ScenarioForceTemplate template : templates) { + if (template == null) { + // I don't know why 'templates' sometimes contains 'null' templates, but it + // does and this stops them from gumming up the works. + continue; + } + if (Objects.equals(template.getForceName(), ScenarioForceTemplate.PRIMARY_FORCE_TEMPLATE_ID)) { if (primaryForceIDs.contains(forceID)) { deployRound = template.getArrivalTurn();