From 1df998e82b3eef783f30b35b40957b71aeaa0627 Mon Sep 17 00:00:00 2001 From: psikomonkie <189469115+psikomonkie@users.noreply.github.com> Date: Thu, 26 Dec 2024 12:48:07 -0500 Subject: [PATCH] Issue 6293: Prevent NPE when using non-scheduled Nuke --- .../megamek/server/totalwarfare/TWGameManager.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/megamek/src/megamek/server/totalwarfare/TWGameManager.java b/megamek/src/megamek/server/totalwarfare/TWGameManager.java index 6683d7f2c73..ec07c29ae1d 100644 --- a/megamek/src/megamek/server/totalwarfare/TWGameManager.java +++ b/megamek/src/megamek/server/totalwarfare/TWGameManager.java @@ -20671,12 +20671,15 @@ public void drawNukeHitOnBoard(int[] nukeArgs) { continue; } - var removeIncoming = hexes.get(coord).stream() - .filter(sdh -> sdh.getType() == SpecialHexDisplay.Type.NUKE_INCOMING) - .toList(); + if ((hexes != null) && (hexes.get(coord) != null)) { + var removeIncoming = hexes.get(coord).stream() + .filter(sdh -> sdh.getType() == SpecialHexDisplay.Type.NUKE_INCOMING) + .toList(); - for (var shd : removeIncoming) { - getGame().getBoard().removeSpecialHexDisplay(coord, shd); + + for (var shd : removeIncoming) { + getGame().getBoard().removeSpecialHexDisplay(coord, shd); + } } String imageSignature = nuke.getImageSignature(coord);