From c37b4d20a495db8d153e45dc6ed5059ac342a4b4 Mon Sep 17 00:00:00 2001 From: sleet01 Date: Sun, 28 Jul 2024 00:02:00 -0700 Subject: [PATCH] Prevent NPE by using interface rather than Aero casting --- megamek/src/megamek/client/ui/swing/MovementDisplay.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/MovementDisplay.java b/megamek/src/megamek/client/ui/swing/MovementDisplay.java index 614d303fb17..f5efe6e0421 100644 --- a/megamek/src/megamek/client/ui/swing/MovementDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MovementDisplay.java @@ -4422,13 +4422,14 @@ public void computeAeroMovementEnvelope(Entity entity) { } // Increment the entity's delta-v then compute the movement envelope. - Aero ae = (Aero)entity; + // LAM and Aeros both implement this interface + IAero ae = (IAero) entity; int currentVelocity = ae.getCurrentVelocity(); ae.setCurrentVelocity(cmd.getFinalVelocity()); // Refresh the new velocity envelope on the map. try { - computeMovementEnvelope(ae); + computeMovementEnvelope(entity); updateMove(); } catch (Exception e) { LogManager.getLogger().error("An error occured trying to compute the move envelope for an Aero.");