From 51b13028c14ac54c0906c11163e9997b09f1763d Mon Sep 17 00:00:00 2001 From: Carl Spain Date: Mon, 17 Feb 2020 11:01:52 -0600 Subject: [PATCH 1/3] Moved motive type filtering for CV equipment to TestTank for validation. --- .../src/megamek/common/verifier/TestTank.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/megamek/src/megamek/common/verifier/TestTank.java b/megamek/src/megamek/common/verifier/TestTank.java index b2f2a309bae..21c5339b2f1 100755 --- a/megamek/src/megamek/common/verifier/TestTank.java +++ b/megamek/src/megamek/common/verifier/TestTank.java @@ -406,6 +406,10 @@ public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { correct = false; } } + if (!legalForMotiveType(m.getType(), tank.getMovementMode())) { + buff.append(m.getType().getName()).append(" is incompatible with ").append(tank.getMovementModeAsString()); + correct = false; + } } for (int loc = 0; loc < tank.locations(); loc++) { int count = 0; @@ -451,6 +455,55 @@ public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { return correct; } + /** + * Checks whether the equipment is compatible with the vehicle's motive type + * + * @param eq The equipment to check + * @param mode The vehicle's motive type + * @return Whether the equipment and motive type are compatible + */ + public static boolean legalForMotiveType(EquipmentType eq, EntityMovementMode mode) { + if (eq.hasFlag(MiscType.F_FLOTATION_HULL)) { + // Per errata, WiGE vehicles automatically include flotation hull + return mode.equals(EntityMovementMode.HOVER) || mode.equals(EntityMovementMode.VTOL); + } + if (eq.hasFlag(MiscType.F_FULLY_AMPHIBIOUS) + || eq.hasFlag(MiscType.F_LIMITED_AMPHIBIOUS) + || eq.hasFlag(MiscType.F_BULLDOZER) + || (eq.hasFlag(MiscType.F_CLUB) && eq.hasSubType(MiscType.S_COMBINE))) { + return mode.equals(EntityMovementMode.WHEELED) || mode.equals(EntityMovementMode.TRACKED); + } + if (eq.hasFlag(MiscType.F_DUNE_BUGGY)) { + return mode.equals(EntityMovementMode.WHEELED); + } + if (eq.hasFlag(MiscType.F_CLUB) + && eq.hasSubType(MiscType.S_CHAINSAW | MiscType.S_DUAL_SAW | MiscType.S_MINING_DRILL)) { + return mode.equals(EntityMovementMode.WHEELED) || mode.equals(EntityMovementMode.TRACKED) + || mode.equals(EntityMovementMode.HOVER) || mode.equals(EntityMovementMode.WIGE); + } + if (eq.hasFlag(MiscType.F_LIFEBOAT)) { + // Need to filter out atmospheric lifeboat + return eq.hasFlag(MiscType.F_TANK_EQUIPMENT) + && (mode.equals(EntityMovementMode.NAVAL) + || mode.equals(EntityMovementMode.HYDROFOIL) + || mode.equals(EntityMovementMode.SUBMARINE)); + } + if (eq.hasFlag(MiscType.F_HEAVY_BRIDGE_LAYER) + || eq.hasFlag(MiscType.F_MEDIUM_BRIDGE_LAYER) + || eq.hasFlag(MiscType.F_LIGHT_BRIDGE_LAYER) + || (eq.hasFlag(MiscType.F_CLUB) + && eq.hasSubType(MiscType.S_BACKHOE | MiscType.S_ROCK_CUTTER + | MiscType.S_SPOT_WELDER | MiscType.S_WRECKING_BALL))) { + return !mode.equals(EntityMovementMode.VTOL); + } + if (eq.hasFlag(MiscType.F_CLUB) && eq.hasSubType(MiscType.S_PILE_DRIVER)) { + return !mode.equals(EntityMovementMode.VTOL) + && !mode.equals(EntityMovementMode.HOVER) + && !mode.equals(EntityMovementMode.WIGE); + } + return true; + } + @Override public boolean correctWeight(StringBuffer buff, boolean showO, boolean showU) { boolean correct = super.correctWeight(buff, showO, showU); From 7e0b9849bef2a3f034ccc0e80aa78589682c5b02 Mon Sep 17 00:00:00 2001 From: Carl Spain Date: Tue, 18 Feb 2020 09:16:39 -0600 Subject: [PATCH 2/3] Add motive type validataion for weapons. --- .../src/megamek/common/verifier/TestTank.java | 101 +++++++++++------- 1 file changed, 60 insertions(+), 41 deletions(-) diff --git a/megamek/src/megamek/common/verifier/TestTank.java b/megamek/src/megamek/common/verifier/TestTank.java index 21c5339b2f1..bc14b266e9b 100755 --- a/megamek/src/megamek/common/verifier/TestTank.java +++ b/megamek/src/megamek/common/verifier/TestTank.java @@ -399,6 +399,13 @@ public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { correct = false; } } + for (Mounted m : tank.getEquipment()) { + if (!legalForMotiveType(m.getType(), tank.getMovementMode())) { + buff.append(m.getType().getName()).append(" is incompatible with ") + .append(tank.getMovementModeAsString()); + correct = false; + } + } for (Mounted m : tank.getMisc()) { if (m.getType().hasFlag(MiscType.F_COMBAT_VEHICLE_ESCAPE_POD)) { if (m.getLocation() != (tank instanceof SuperHeavyTank?SuperHeavyTank.LOC_REAR:Tank.LOC_REAR)) { @@ -406,10 +413,6 @@ public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { correct = false; } } - if (!legalForMotiveType(m.getType(), tank.getMovementMode())) { - buff.append(m.getType().getName()).append(" is incompatible with ").append(tank.getMovementModeAsString()); - correct = false; - } } for (int loc = 0; loc < tank.locations(); loc++) { int count = 0; @@ -463,43 +466,59 @@ public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { * @return Whether the equipment and motive type are compatible */ public static boolean legalForMotiveType(EquipmentType eq, EntityMovementMode mode) { - if (eq.hasFlag(MiscType.F_FLOTATION_HULL)) { - // Per errata, WiGE vehicles automatically include flotation hull - return mode.equals(EntityMovementMode.HOVER) || mode.equals(EntityMovementMode.VTOL); - } - if (eq.hasFlag(MiscType.F_FULLY_AMPHIBIOUS) - || eq.hasFlag(MiscType.F_LIMITED_AMPHIBIOUS) - || eq.hasFlag(MiscType.F_BULLDOZER) - || (eq.hasFlag(MiscType.F_CLUB) && eq.hasSubType(MiscType.S_COMBINE))) { - return mode.equals(EntityMovementMode.WHEELED) || mode.equals(EntityMovementMode.TRACKED); - } - if (eq.hasFlag(MiscType.F_DUNE_BUGGY)) { - return mode.equals(EntityMovementMode.WHEELED); - } - if (eq.hasFlag(MiscType.F_CLUB) - && eq.hasSubType(MiscType.S_CHAINSAW | MiscType.S_DUAL_SAW | MiscType.S_MINING_DRILL)) { - return mode.equals(EntityMovementMode.WHEELED) || mode.equals(EntityMovementMode.TRACKED) - || mode.equals(EntityMovementMode.HOVER) || mode.equals(EntityMovementMode.WIGE); - } - if (eq.hasFlag(MiscType.F_LIFEBOAT)) { - // Need to filter out atmospheric lifeboat - return eq.hasFlag(MiscType.F_TANK_EQUIPMENT) - && (mode.equals(EntityMovementMode.NAVAL) - || mode.equals(EntityMovementMode.HYDROFOIL) - || mode.equals(EntityMovementMode.SUBMARINE)); - } - if (eq.hasFlag(MiscType.F_HEAVY_BRIDGE_LAYER) - || eq.hasFlag(MiscType.F_MEDIUM_BRIDGE_LAYER) - || eq.hasFlag(MiscType.F_LIGHT_BRIDGE_LAYER) - || (eq.hasFlag(MiscType.F_CLUB) - && eq.hasSubType(MiscType.S_BACKHOE | MiscType.S_ROCK_CUTTER - | MiscType.S_SPOT_WELDER | MiscType.S_WRECKING_BALL))) { - return !mode.equals(EntityMovementMode.VTOL); - } - if (eq.hasFlag(MiscType.F_CLUB) && eq.hasSubType(MiscType.S_PILE_DRIVER)) { - return !mode.equals(EntityMovementMode.VTOL) - && !mode.equals(EntityMovementMode.HOVER) - && !mode.equals(EntityMovementMode.WIGE); + final boolean isNaval = mode.equals(EntityMovementMode.NAVAL) + || mode.equals(EntityMovementMode.HYDROFOIL) + || mode.equals(EntityMovementMode.SUBMARINE); + if (eq instanceof MiscType) { + if (eq.hasFlag(MiscType.F_FLOTATION_HULL)) { + // Per errata, WiGE vehicles automatically include flotation hull + return mode.equals(EntityMovementMode.HOVER) || mode.equals(EntityMovementMode.VTOL); + } + if (eq.hasFlag(MiscType.F_FULLY_AMPHIBIOUS) + || eq.hasFlag(MiscType.F_LIMITED_AMPHIBIOUS) + || eq.hasFlag(MiscType.F_BULLDOZER) + || (eq.hasFlag(MiscType.F_CLUB) && eq.hasSubType(MiscType.S_COMBINE))) { + return mode.equals(EntityMovementMode.WHEELED) || mode.equals(EntityMovementMode.TRACKED); + } + if (eq.hasFlag(MiscType.F_DUNE_BUGGY)) { + return mode.equals(EntityMovementMode.WHEELED); + } + if (eq.hasFlag(MiscType.F_CLUB) + && eq.hasSubType(MiscType.S_CHAINSAW | MiscType.S_DUAL_SAW | MiscType.S_MINING_DRILL)) { + return mode.equals(EntityMovementMode.WHEELED) || mode.equals(EntityMovementMode.TRACKED) + || mode.equals(EntityMovementMode.HOVER) || mode.equals(EntityMovementMode.WIGE); + } + if (eq.hasFlag(MiscType.F_MINESWEEPER)) { + return mode.equals(EntityMovementMode.WHEELED) || mode.equals(EntityMovementMode.TRACKED) + || isNaval; + } + if (eq.hasFlag(MiscType.F_LIFEBOAT)) { + // Need to filter out atmospheric lifeboat + return isNaval && (eq.hasFlag(MiscType.F_TANK_EQUIPMENT) || eq.hasFlag(MiscType.F_SUPPORT_TANK_EQUIPMENT)); + } + if (eq.hasFlag(MiscType.F_HEAVY_BRIDGE_LAYER) + || eq.hasFlag(MiscType.F_MEDIUM_BRIDGE_LAYER) + || eq.hasFlag(MiscType.F_LIGHT_BRIDGE_LAYER) + || (eq.hasFlag(MiscType.F_CLUB) + && eq.hasSubType(MiscType.S_BACKHOE | MiscType.S_ROCK_CUTTER + | MiscType.S_SPOT_WELDER | MiscType.S_WRECKING_BALL))) { + return !mode.equals(EntityMovementMode.VTOL); + } + if (eq.hasFlag(MiscType.F_CLUB) && eq.hasSubType(MiscType.S_PILE_DRIVER)) { + return !mode.equals(EntityMovementMode.VTOL) + && !mode.equals(EntityMovementMode.HOVER) + && !mode.equals(EntityMovementMode.WIGE); + } + if (eq.hasFlag(MiscType.F_AP_POD)) { + return !isNaval; + } + } else if (eq instanceof WeaponType) { + if (((WeaponType) eq).getAmmoType() == AmmoType.T_BPOD) { + return !isNaval; + } + if (((WeaponType) eq).getAmmoType() == AmmoType.T_NAIL_RIVET_GUN) { + return !mode.equals(EntityMovementMode.VTOL); + } } return true; } From 06ec6f8b30e79745897dd2db34ea049214870915 Mon Sep 17 00:00:00 2001 From: Carl Spain Date: Tue, 18 Feb 2020 09:17:39 -0600 Subject: [PATCH 3/3] Validate support tank equipment against motive type. --- .../src/megamek/common/verifier/TestSupportVehicle.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/megamek/src/megamek/common/verifier/TestSupportVehicle.java b/megamek/src/megamek/common/verifier/TestSupportVehicle.java index e2ee7d8cc28..8b6f9d9a889 100644 --- a/megamek/src/megamek/common/verifier/TestSupportVehicle.java +++ b/megamek/src/megamek/common/verifier/TestSupportVehicle.java @@ -1007,6 +1007,15 @@ public boolean correctEntity(StringBuffer buff, int ammoTechLvl) { buff.append("Omni configuration exceeds weapon capacity of base chassis fire control system.\n"); correct = false; } + if (supportVee instanceof Tank) { + for (Mounted m : supportVee.getEquipment()) { + if (!TestTank.legalForMotiveType(m.getType(), supportVee.getMovementMode())) { + buff.append(m.getType().getName()).append(" is incompatible with ") + .append(supportVee.getMovementModeAsString()); + correct = false; + } + } + } for (int loc = 0; loc < supportVee.locations(); loc++) { int count = 0; for (Mounted misc : supportVee.getMisc()) {