diff --git a/megamek/data/mechfiles/vehicles/TRO Vehicle Annex/Wheeled/Brunel Dump Truck.blk b/megamek/data/mechfiles/vehicles/TRO Vehicle Annex/Wheeled/Brunel Dump Truck.blk index e7c0e1fea04..b387b58b57d 100644 --- a/megamek/data/mechfiles/vehicles/TRO Vehicle Annex/Wheeled/Brunel Dump Truck.blk +++ b/megamek/data/mechfiles/vehicles/TRO Vehicle Annex/Wheeled/Brunel Dump Truck.blk @@ -3,7 +3,7 @@ 1 -# Write the version number just in case... +##Write the version number just in case... MAM0 @@ -16,9 +16,9 @@ LargeSupportTank Brunel Dump Truck - + - + 3866 @@ -28,6 +28,10 @@ Brunel Dump Truck 2637 + +2637 + + IS Level 3 @@ -36,6 +40,9 @@ IS Level 3 Wheeled + + + 3 @@ -44,14 +51,6 @@ Wheeled 1 - -4 - - - -6 - - 21 13 @@ -61,14 +60,6 @@ Wheeled 10 - -3 - - - -2 - - ISOffRoadChassis @@ -91,16 +82,42 @@ Backhoe Dumper (Rear) +Cargo:SIZE:50.0 - -150.0 - + +6 + - -TRO: Vehicle Annex (Revised) - + +3 + + + +3 + + + +2 + Armor is based on fluff. No Record Sheet available. + + +TRO: Vehicle Annex (Revised) + + + +150.0 + + + +4.0 + + + +PETROCHEMICALS + + diff --git a/megamek/data/mechfiles/vehicles/TRO Vehicle Annex/Wheeled/Lesseps Dump Truck.blk b/megamek/data/mechfiles/vehicles/TRO Vehicle Annex/Wheeled/Lesseps Dump Truck.blk index 1ca3483278b..428cb75796f 100644 --- a/megamek/data/mechfiles/vehicles/TRO Vehicle Annex/Wheeled/Lesseps Dump Truck.blk +++ b/megamek/data/mechfiles/vehicles/TRO Vehicle Annex/Wheeled/Lesseps Dump Truck.blk @@ -3,7 +3,7 @@ 1 -# Write the version number just in case... +##Write the version number just in case... MAM0 @@ -16,9 +16,9 @@ SupportTank Lesseps Dump Truck - + - + 4499 @@ -28,6 +28,10 @@ Lesseps Dump Truck 2523 + +2523 + + IS Level 3 @@ -36,6 +40,9 @@ IS Level 3 Wheeled + + + 3 @@ -44,10 +51,6 @@ Wheeled 11 - -4 - - 28 19 @@ -55,14 +58,6 @@ Wheeled 12 - -5 - - - -3 - - ISOffRoadChassis @@ -79,11 +74,24 @@ Backhoe Dumper (Rear) +Cargo:SIZE:20.0 - -cargobay:20:1 - + +5 + + + +3 + + + +3 + + + +3 + TRO: Vehicle Annex (Revised) @@ -92,3 +100,8 @@ TRO: Vehicle Annex (Revised) 50.0 + + +4.0 + + diff --git a/megamek/src/megamek/common/EquipmentTypeLookup.java b/megamek/src/megamek/common/EquipmentTypeLookup.java index fb180238373..e95c6494bed 100644 --- a/megamek/src/megamek/common/EquipmentTypeLookup.java +++ b/megamek/src/megamek/common/EquipmentTypeLookup.java @@ -180,6 +180,7 @@ public class EquipmentTypeLookup { @EquipmentName public static final String WRECKING_BALL = "IS Wrecking Ball"; @EquipmentName public static final String LAM_FUEL_TANK = "LAM Fuel Tank"; @EquipmentName public static final String LAM_BOMB_BAY = "Bomb Bay"; + @EquipmentName public static final String CARGO = "Cargo"; @EquipmentName public static final String CL_BA_MORTAR_HEAVY = "CLBAHeavyMortar"; @EquipmentName public static final String CL_BA_MORTAR_LIGHT = "CLBALightMortar"; diff --git a/megamek/src/megamek/common/MechFileParser.java b/megamek/src/megamek/common/MechFileParser.java index 17d0513d13f..c27c6828853 100644 --- a/megamek/src/megamek/common/MechFileParser.java +++ b/megamek/src/megamek/common/MechFileParser.java @@ -23,6 +23,7 @@ import java.io.*; import java.util.*; import java.util.function.Predicate; +import java.util.stream.Collectors; import java.util.zip.ZipFile; /** @@ -778,6 +779,34 @@ else if ((ent instanceof Infantry) && ((Infantry) ent).canMakeAntiMekAttacks()) ent.setCanon(true); } ent.initMilitary(); + linkDumpers(ent); + } + + /** + * Links each Dumper to the first (unlinked) Cargo equipment if there is one in the same location. + * Works only for variable size Cargo, {@link MiscType#createCargo()}, but not Liquid Storage, + * Cargo containers or bays. + * + * @param entity The entity to add links to + */ + static void linkDumpers(Entity entity) { + List dumpers = entity.getMisc().stream() + .filter(mounted -> mounted.getType().hasFlag(MiscType.F_DUMPER)).collect(Collectors.toList()); + + List cargos = entity.getMisc().stream() + .filter(mounted -> mounted.is(EquipmentTypeLookup.CARGO)).collect(Collectors.toList()); + cargos.forEach(cargo -> cargo.setLinkedBy(null)); + + for (Mounted dumper : dumpers) { + dumper.setLinked(null); + for (Mounted cargo : cargos) { + if ((cargo.getLinkedBy() == null) && (cargo.getLocation() == dumper.getLocation())) { + dumper.setLinked(cargo); + cargo.setLinkedBy(dumper); + break; + } + } + } } /** diff --git a/megamek/src/megamek/common/MiscType.java b/megamek/src/megamek/common/MiscType.java index 043d5c5bb4b..de6c50b38e7 100644 --- a/megamek/src/megamek/common/MiscType.java +++ b/megamek/src/megamek/common/MiscType.java @@ -23,6 +23,7 @@ import megamek.common.weapons.ppc.ISLightPPC; import megamek.common.weapons.ppc.ISPPC; import megamek.common.weapons.ppc.ISSnubNosePPC; +import org.apache.logging.log4j.LogManager; /** * @author Ben @@ -885,7 +886,7 @@ public double getTonnage(Entity entity, int location, double size, RoundWeight d } else if (hasFlag(F_BA_MISSION_EQUIPMENT)) { // Size is weight in kg return RoundWeight.nearestKg(size / 1000.0); - } else if (hasFlag(MiscType.F_RAM_PLATE)) { + } else if (hasFlag(F_RAM_PLATE)) { return RoundWeight.nextTon(entity.getWeight() / 10.0); } // okay, I'm out of ideas @@ -7988,7 +7989,7 @@ public static MiscType createCargo() { MiscType misc = new MiscType(); misc.name = "Cargo"; - misc.setInternalName(misc.name); + misc.setInternalName(EquipmentTypeLookup.CARGO); misc.addLookupName("Cargo (1 ton)"); misc.addLookupName("Cargo (0.5 tons)"); misc.addLookupName("Cargo (1.5 tons)"); diff --git a/megamek/src/megamek/common/Mounted.java b/megamek/src/megamek/common/Mounted.java index 7f335129136..ab44e4b8494 100644 --- a/megamek/src/megamek/common/Mounted.java +++ b/megamek/src/megamek/common/Mounted.java @@ -542,11 +542,11 @@ public double getTonnage() { */ public double getTonnage(RoundWeight defaultRounding) { if ((getType() instanceof MiscType) && getType().hasFlag(MiscType.F_DUMPER)) { - final Bay bay = getEntity().getBayById(getLinkedBayId()); - if (bay != null) { - return defaultRounding.round(bay.getCapacity() * 0.05, getEntity()); + Mounted cargo = getLinked(); + if (cargo != null) { + return defaultRounding.round(cargo.getSize() * 0.05, getEntity()); } - LogManager.getLogger().warn("Found dumper not linked to a cargo bay. Using zero for the weight."); + LogManager.getLogger().warn("Found dumper not linked to a Cargo equipment. Using zero for the weight."); return 0.0; } double retVal = getType().getTonnage(getEntity(), getLocation(), getSize(), defaultRounding);