diff --git a/megamek/src/megamek/common/WeaponType.java b/megamek/src/megamek/common/WeaponType.java index 2fa39a52d9e..620309a0866 100644 --- a/megamek/src/megamek/common/WeaponType.java +++ b/megamek/src/megamek/common/WeaponType.java @@ -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;