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

Fix MML #1429: MegaMek side of fix for MML NPE in Aero Equipment tab #5176

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
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
Loading