Skip to content

Commit

Permalink
Merge pull request #5926 from Sleet01/Fix_5669_NPE_loading_artillery_…
Browse files Browse the repository at this point in the history
…ammo_on_flying_DropShips

Fix #5669: Stop NPE when UI checks if Airborne artillery has Homing ammo
  • Loading branch information
SJuliez authored Aug 21, 2024
2 parents 1cb5b5c + cebf34e commit 29421d0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions megamek/src/megamek/client/ui/swing/OffBoardTargetOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import megamek.common.actions.WeaponAttackAction;
import megamek.common.util.ImageUtil;
import megamek.common.util.fileUtils.MegaMekFile;
import megamek.common.weapons.bayweapons.BayWeapon;

import javax.swing.*;
import java.awt.*;
Expand Down Expand Up @@ -87,10 +88,15 @@ private boolean shouldBeVisible() {
if (selectedArtilleryWeapon == null) {
return false;
}
// Bay weapons cannot fire homing artillery rounds (currently)
// TODO: revisit when aero errata is implemented
if (selectedArtilleryWeapon.getType() instanceof BayWeapon) {
return false;
}

// the artillery weapon needs to be using non-homing ammo
Mounted ammo = selectedArtilleryWeapon.getLinked();
if (ammo.isHomingAmmoInHomingMode()) {
if (!(ammo == null) && ammo.isHomingAmmoInHomingMode()) {
return false;
}

Expand All @@ -111,7 +117,7 @@ private boolean showDirectionalElement(OffBoardDirection direction, Mounted sele
for (Entity entity : getCurrentGame().getAllOffboardEnemyEntities(getCurrentPlayer())) {
if (entity.isOffBoardObserved(getCurrentPlayer().getTeam()) &&
(entity.getOffBoardDirection() == direction) &&
(targetingPhaseDisplay.ce() != null &&
(targetingPhaseDisplay.ce() != null &&
targetingPhaseDisplay.ce().isOffBoard() ||
weaponFacingInDirection(selectedArtilleryWeapon, direction))) {
return true;
Expand Down

0 comments on commit 29421d0

Please sign in to comment.