Skip to content

Commit

Permalink
Merge pull request #5813 from Sleet01/Fix_5705_NPE_computing_LAM_move…
Browse files Browse the repository at this point in the history
…ment_envelope

Prevent NPE by using interface rather than Aero casting
  • Loading branch information
Sleet01 authored Jul 28, 2024
2 parents 305448d + c37b4d2 commit 6ce0fe4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions megamek/src/megamek/client/ui/swing/MovementDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -4414,13 +4414,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.");
Expand Down

0 comments on commit 6ce0fe4

Please sign in to comment.