Skip to content

Commit

Permalink
MegaMek side of fix for MML NPE in Aero Equipment tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleet01 committed Feb 18, 2024
1 parent 31044f4 commit e71ee00
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions megamek/src/megamek/common/WeaponType.java
Original file line number Diff line number Diff line change
Expand Up @@ -608,28 +608,33 @@ public int getWExtremeRange() {
}

public int getMaxRange(Mounted weapon) {
if (weapon == null) {
return getMaxRange();
}
return getMaxRange(weapon, weapon.getLinked());
}

public int getMaxRange() {
return maxRange;
}

public int getMaxRange(Mounted weapon, Mounted ammo) {
if (null != weapon) {
if (getAmmoType() == AmmoType.T_ATM) {
AmmoType ammoType = (AmmoType) ammo.getType();
if ((ammoType.getAmmoType() == AmmoType.T_ATM)
&& (ammoType.getMunitionType().contains(AmmoType.Munitions.M_EXTENDED_RANGE))) {
return RANGE_EXT;
} else if ((ammoType.getAmmoType() == AmmoType.T_ATM)
&& (ammoType.getMunitionType().contains(AmmoType.Munitions.M_HIGH_EXPLOSIVE))) {
return RANGE_SHORT;
}
if (getAmmoType() == AmmoType.T_ATM) {
AmmoType ammoType = (AmmoType) ammo.getType();
if ((ammoType.getAmmoType() == AmmoType.T_ATM)
&& (ammoType.getMunitionType().contains(AmmoType.Munitions.M_EXTENDED_RANGE))) {
return RANGE_EXT;
} else if ((ammoType.getAmmoType() == AmmoType.T_ATM)
&& (ammoType.getMunitionType().contains(AmmoType.Munitions.M_HIGH_EXPLOSIVE))) {
return RANGE_SHORT;
}
if (getAmmoType() == AmmoType.T_MML) {
AmmoType ammoType = (AmmoType) ammo.getType();
if (ammoType.hasFlag(AmmoType.F_MML_LRM) || (getAmmoType() == AmmoType.T_LRM_TORPEDO)) {
return RANGE_LONG;
} else {
return RANGE_SHORT;
}
}
if (getAmmoType() == AmmoType.T_MML) {
AmmoType ammoType = (AmmoType) ammo.getType();
if (ammoType.hasFlag(AmmoType.F_MML_LRM) || (getAmmoType() == AmmoType.T_LRM_TORPEDO)) {
return RANGE_LONG;
} else {
return RANGE_SHORT;
}
}
return maxRange;
Expand Down

0 comments on commit e71ee00

Please sign in to comment.