panMunitions.setLayout(gbl);
GridBagConstraints gbc = new GridBagConstraints();
int row = 0;
for (Mounted m : entity.getAmmo()) {
AmmoType at = (AmmoType) m.getType();
Vector<AmmoType> vTypes = new Vector<AmmoType>();
Vector<AmmoType> vAllTypes = new Vector<AmmoType>();
vAllTypes = AmmoType.getMunitionsFor(at.getAmmoType());
if (vAllTypes == null) {
continue;
}
// don't allow ammo switching of most things for Aeros
// allow only MML, ATM, NARC, and LBX switching
// TODO: need a better way to customize munitions on Aeros
// currently this doesn't allow AR10 and tele-missile launchers
// to switch back and forth between tele and regular missiles
// also would be better to not have to add Santa Anna's in such
// an idiosyncratic fashion
if ((entity instanceof Aero)
&& !((at.getAmmoType() == AmmoType.T_MML)
|| (at.getAmmoType() == AmmoType.T_ATM)
|| (at.getAmmoType() == AmmoType.T_NARC) || (at
.getAmmoType() == AmmoType.T_AC_LBX))) {
continue;
}
for (int x = 0, n = vAllTypes.size(); x < n; x++) {
AmmoType atCheck = vAllTypes.elementAt(x);
boolean bTechMatch = TechConstants.isLegal(entity
.getTechLevel(), atCheck.getTechLevel());
// allow all lvl2 IS units to use level 1 ammo
// lvl1 IS units don't need to be allowed to use lvl1 ammo,
// because there is no special lvl1 ammo, therefore it doesn't
// need to show up in this display.
if (!bTechMatch
&& (entity.getTechLevel() == TechConstants.T_IS_TW_NON_BOX)
&& (atCheck.getTechLevel() == TechConstants.T_INTRO_BOXSET)) {
bTechMatch = true;
}
// if is_eq_limits is unchecked allow l1 guys to use l2 stuff
if (!clientgui.getClient().game.getOptions().booleanOption(
"is_eq_limits") //$NON-NLS-1$
&& (entity.getTechLevel() == TechConstants.T_INTRO_BOXSET)
&& (atCheck.getTechLevel() == TechConstants.T_IS_TW_NON_BOX)) {
bTechMatch = true;
}
// Possibly allow advanced/experimental ammos, possibly not.
if (clientgui.getClient().game.getOptions().booleanOption(
"allow_advanced_ammo")) {
if (!clientgui.getClient().game.getOptions().booleanOption(
"is_eq_limits")) {
if ((entity.getTechLevel() == TechConstants.T_CLAN_TW)
&& ((atCheck.getTechLevel() == TechConstants.T_CLAN_ADVANCED)
|| (atCheck.getTechLevel() == TechConstants.T_CLAN_EXPERIMENTAL) || (atCheck
.getTechLevel() == TechConstants.T_CLAN_UNOFFICIAL))) {
bTechMatch = true;
}
if (((entity.getTechLevel() == TechConstants.T_INTRO_BOXSET) || (entity
.getTechLevel() == TechConstants.T_IS_TW_NON_BOX))
&& ((atCheck.getTechLevel() == TechConstants.T_IS_ADVANCED)
|| (atCheck.getTechLevel() == TechConstants.T_IS_EXPERIMENTAL) || (atCheck
.getTechLevel() == TechConstants.T_IS_UNOFFICIAL))) {
bTechMatch = true;
}
}
} else if ((atCheck.getTechLevel() == TechConstants.T_IS_ADVANCED)
|| (atCheck.getTechLevel() == TechConstants.T_CLAN_ADVANCED)) {
bTechMatch = false;
}
// allow mixed Tech Mechs to use both IS and Clan ammo of any
// level (since mixed tech is always level 3)
if (entity.isMixedTech()) {
bTechMatch = true;
}
// If clan_ignore_eq_limits is unchecked,
// do NOT allow Clans to use IS-only ammo.
// N.B. play bit-shifting games to allow "incendiary"
// to be combined to other munition types.
long muniType = atCheck.getMunitionType();
muniType &= ~AmmoType.M_INCENDIARY_LRM;
if (!clientgui.getClient().game.getOptions().booleanOption(
"clan_ignore_eq_limits") //$NON-NLS-1$
&& entity.isClan()
&& ((muniType == AmmoType.M_SEMIGUIDED)
|| (muniType == AmmoType.M_SWARM_I)
|| (muniType == AmmoType.M_FLARE)
|| (muniType == AmmoType.M_FRAGMENTATION)
|| (muniType == AmmoType.M_THUNDER_AUGMENTED)
|| (muniType == AmmoType.M_THUNDER_INFERNO)
|| (muniType == AmmoType.M_THUNDER_VIBRABOMB)
|| (muniType == AmmoType.M_THUNDER_ACTIVE)
|| (muniType == AmmoType.M_INFERNO_IV)
|| (muniType == AmmoType.M_VIBRABOMB_IV)
|| (muniType == AmmoType.M_LISTEN_KILL) || (muniType == AmmoType.M_ANTI_TSM))) {
bTechMatch = false;
}
if (!clientgui.getClient().game.getOptions().booleanOption(
"minefields") && //$NON-NLS-1$
AmmoType.canDeliverMinefield(atCheck)) {
continue;
}
// Only Protos can use Proto-specific ammo
if (atCheck.hasFlag(AmmoType.F_PROTOMECH)
&& !(entity instanceof Protomech)) {
continue;
}
// When dealing with machine guns, Protos can only
// use proto-specific machine gun ammo
if ((entity instanceof Protomech)
&& atCheck.hasFlag(AmmoType.F_MG)
&& !atCheck.hasFlag(AmmoType.F_PROTOMECH)) {
continue;
}
// Battle Armor ammo can't be selected at all.
// All other ammo types need to match on rack size and tech.
if (bTechMatch
&& (atCheck.getRackSize() == at.getRackSize())
&& (atCheck.hasFlag(AmmoType.F_BATTLEARMOR) == at
.hasFlag(AmmoType.F_BATTLEARMOR))
&& (atCheck.hasFlag(AmmoType.F_ENCUMBERING) == at
.hasFlag(AmmoType.F_ENCUMBERING))
&& (atCheck.getTonnage(entity) == at.getTonnage(entity))) {
vTypes.addElement(atCheck);
}
}
if ((vTypes.size() < 2)
&& !client.game.getOptions().booleanOption(