From e6a353ad9a7b141dfe3707f201dcb757f4b7da21 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 Aug 2023 12:43:35 -0400 Subject: [PATCH] prevent NPE when ending swarm attack --- .../src/megamek/common/weapons/StopSwarmAttackHandler.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/megamek/src/megamek/common/weapons/StopSwarmAttackHandler.java b/megamek/src/megamek/common/weapons/StopSwarmAttackHandler.java index a5584de98b1..cec3eff0a47 100644 --- a/megamek/src/megamek/common/weapons/StopSwarmAttackHandler.java +++ b/megamek/src/megamek/common/weapons/StopSwarmAttackHandler.java @@ -64,7 +64,10 @@ public boolean handle(GamePhase phase, Vector vPhaseReport) { // Only apply the "stop swarm 'attack'" to the swarmed Mek. if (ae.getSwarmTargetId() != target.getId()) { Entity other = game.getEntity(ae.getSwarmTargetId()); - other.setSwarmAttackerId(Entity.NONE); + + if (other != null) { + other.setSwarmAttackerId(Entity.NONE); + } } else { entityTarget.setSwarmAttackerId(Entity.NONE); }