Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent NPE by using interface rather than Aero casting #5813

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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.");
Expand Down