From a886917cbd1076b025ab5fbbf8d1f8b35668a0f3 Mon Sep 17 00:00:00 2001 From: Carl Spain Date: Sat, 5 Oct 2019 13:40:39 -0500 Subject: [PATCH 1/2] Remove tech base check from protmech armor enum lookup. All protomech armor has a Clan tech base. Since standard uses the MiscType corresponding to T_STANDARD, and it has an tech level of Intro, it can't make the Clan/IS distinction and when the armor is set to standard in MML it is treated as IS and fails to match. The tech base match was kept when the code was copied from other unit types and modified, but is not necessary for protomechs. --- .../common/verifier/TestProtomech.java | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/megamek/src/megamek/common/verifier/TestProtomech.java b/megamek/src/megamek/common/verifier/TestProtomech.java index a016113ac37..d0b2b51baf4 100644 --- a/megamek/src/megamek/common/verifier/TestProtomech.java +++ b/megamek/src/megamek/common/verifier/TestProtomech.java @@ -95,16 +95,14 @@ public static List allJJs() { * */ public static enum ProtomechArmor { - STANDARD (EquipmentType.T_ARMOR_STANDARD, true, 0), - EDP (EquipmentType.T_ARMOR_EDP, true, 1); + STANDARD (EquipmentType.T_ARMOR_STANDARD, 0), + EDP (EquipmentType.T_ARMOR_EDP, 1); private final int type; - private final boolean isClan; private final int torsoSlots; - ProtomechArmor(int t, boolean c, int slots) { + ProtomechArmor(int t, int slots) { type = t; - isClan = c; torsoSlots = slots; } @@ -122,8 +120,7 @@ public static int armorCount() { * or null if no match was found. */ public static @Nullable ProtomechArmor getArmor(Protomech proto) { - return getArmor(proto.getArmorType(Protomech.LOC_TORSO), - TechConstants.isClan(proto.getArmorTechLevel(Protomech.LOC_TORSO))); + return getArmor(proto.getArmorType(Protomech.LOC_TORSO)); } /** @@ -131,24 +128,38 @@ public static int armorCount() { * represents that type. * * @param t The armor type. - * @param c Whether this armor type is Clan or not. * @return The {@link ProtomechArmor} that corresponds to the given type * or null if no match was found. */ - public static @Nullable ProtomechArmor getArmor(int t, boolean c) { + public static @Nullable ProtomechArmor getArmor(int t) { for (ProtomechArmor a : values()) { - if ((a.type == t) && (a.isClan == c)) { + if (a.type == t) { return a; } } return null; } + + /** + * Given an armor type, return the {@link ProtomechArmor} instance that + * represents that type. + * @deprecated Use {@link #getArmor(int)} instead + + * @param t The armor type. + * @param c Whether the armor has a Clan tech base + * @return The {@link ProtomechArmor} that corresponds to the given type + * or null if no match was found. + */ + @Deprecated + public static @Nullable ProtomechArmor getArmor(int t, boolean c) { + return getArmor(t); + } /** * @return The {@link MiscType} for this armor. */ public EquipmentType getArmorEqType() { - String name = EquipmentType.getArmorTypeName(type, isClan); + String name = EquipmentType.getArmorTypeName(type, true); return EquipmentType.get(name); } @@ -158,11 +169,7 @@ public int getType() { public int getArmorTech() { EquipmentType eq = getArmorEqType(); - return eq.getStaticTechLevel().getCompoundTechLevel(isClan); - } - - public boolean isClan() { - return isClan; + return eq.getStaticTechLevel().getCompoundTechLevel(true); } public int getTorsoSlots() { From b5b2ed9d82a96b1d3ad2bdbc6cc8663c7c3e1fc0 Mon Sep 17 00:00:00 2001 From: Carl Spain Date: Sat, 5 Oct 2019 13:57:41 -0500 Subject: [PATCH 2/2] Javadoc fix --- .../src/megamek/common/verifier/TestProtomech.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/megamek/src/megamek/common/verifier/TestProtomech.java b/megamek/src/megamek/common/verifier/TestProtomech.java index d0b2b51baf4..98783d66232 100644 --- a/megamek/src/megamek/common/verifier/TestProtomech.java +++ b/megamek/src/megamek/common/verifier/TestProtomech.java @@ -111,13 +111,12 @@ public static int armorCount() { } /** - * Given an armor type, return the {@link ProtomechArmor} instance that - * represents that type. + * Given a protomech, return the {@link ProtomechArmor} instance that + * represents the type installed * - * @param t The armor type. - * @param c Whether this armor type is Clan or not. - * @return The {@link ProtomechArmor} that corresponds to the given type - * or null if no match was found. + * @param proto The protomech + * @return The {@link ProtomechArmor} that corresponds to the given type + * or null if no match was found. */ public static @Nullable ProtomechArmor getArmor(Protomech proto) { return getArmor(proto.getArmorType(Protomech.LOC_TORSO));