From 3bee592eff3ab267a9ee2a8f2c50875cbbca7c97 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 5 Nov 2024 18:01:50 +0100 Subject: [PATCH] rename TroopSpace to InfantryCompartment --- megamek/src/megamek/common/Entity.java | 10 +++++----- .../{TroopSpace.java => InfantryCompartment.java} | 12 ++++++------ megamek/src/megamek/common/Tank.java | 2 +- .../conversion/ASSpecialAbilityConverter.java | 2 +- megamek/src/megamek/common/loaders/BLKFile.java | 2 +- megamek/src/megamek/common/templates/TROView.java | 2 +- .../megamek/common/verifier/TestSupportVehicle.java | 6 +++--- megamek/src/megamek/common/verifier/TestTank.java | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) rename megamek/src/megamek/common/{TroopSpace.java => InfantryCompartment.java} (98%) diff --git a/megamek/src/megamek/common/Entity.java b/megamek/src/megamek/common/Entity.java index 06d10d45800..5e0b3a3974c 100644 --- a/megamek/src/megamek/common/Entity.java +++ b/megamek/src/megamek/common/Entity.java @@ -8918,7 +8918,7 @@ public String getUnusedString(ViewFormatting formatting) { } else { result.append(next.getUnusedString()); } - if (isOmni() && ((next instanceof TroopSpace) + if (isOmni() && ((next instanceof InfantryCompartment) || (next instanceof Bay))) { if (omniPodTransports.contains(next)) { result.append(" (Pod)"); @@ -10123,8 +10123,8 @@ public boolean isEligibleForTargetingPhase() { public double getTroopCarryingSpace() { double space = 0; for (Transporter t : transports) { - if (t instanceof TroopSpace) { - space += ((TroopSpace) t).totalSpace; + if (t instanceof InfantryCompartment) { + space += ((InfantryCompartment) t).totalSpace; } } return space; @@ -10133,8 +10133,8 @@ public double getTroopCarryingSpace() { public double getPodMountedTroopCarryingSpace() { double space = 0; for (Transporter t : omniPodTransports) { - if (t instanceof TroopSpace) { - space += ((TroopSpace) t).totalSpace; + if (t instanceof InfantryCompartment) { + space += ((InfantryCompartment) t).totalSpace; } } return space; diff --git a/megamek/src/megamek/common/TroopSpace.java b/megamek/src/megamek/common/InfantryCompartment.java similarity index 98% rename from megamek/src/megamek/common/TroopSpace.java rename to megamek/src/megamek/common/InfantryCompartment.java index 82e6ba524d6..e753648b27c 100644 --- a/megamek/src/megamek/common/TroopSpace.java +++ b/megamek/src/megamek/common/InfantryCompartment.java @@ -23,14 +23,14 @@ * Represents a volume of space set aside for carrying troops and their equipment under battle * conditions. Typically, a component of an APC. */ -public final class TroopSpace implements Transporter { +public final class InfantryCompartment implements Transporter { private static final long serialVersionUID = 7837499891552862932L; /** * The troops being carried. */ Map troops = new HashMap<>(); - + /** * The total amount of space available for troops. */ @@ -46,7 +46,7 @@ public final class TroopSpace implements Transporter { /** * The default constructor is only for serialization. */ - private TroopSpace() { + private InfantryCompartment() { totalSpace = 0; currentSpace = 0; } @@ -58,7 +58,7 @@ private TroopSpace() { * * @param space The weight of troops (in tons) this space can carry. */ - public TroopSpace(double space) { + public InfantryCompartment(double space) { totalSpace = space; currentSpace = space; } @@ -125,7 +125,7 @@ public Vector getLoadedUnits() { for (Map.Entry entry : troops.entrySet()) { int key = entry.getKey(); Entity entity = game.getEntity(key); - + if (entity != null) { loaded.add(entity); } @@ -240,7 +240,7 @@ public String toString() { public void setGame(Game game) { this.game = game; } - + @Override public void resetTransporter() { troops = new HashMap<>(); diff --git a/megamek/src/megamek/common/Tank.java b/megamek/src/megamek/common/Tank.java index a5fece70f62..6aa3a0a4efd 100644 --- a/megamek/src/megamek/common/Tank.java +++ b/megamek/src/megamek/common/Tank.java @@ -2498,7 +2498,7 @@ public int getFreeSlots() { // total) boolean infantryBayCounted = false; for (Transporter transport : getTransports()) { - if (transport instanceof TroopSpace) { + if (transport instanceof InfantryCompartment) { usedSlots++; infantryBayCounted = true; break; diff --git a/megamek/src/megamek/common/alphaStrike/conversion/ASSpecialAbilityConverter.java b/megamek/src/megamek/common/alphaStrike/conversion/ASSpecialAbilityConverter.java index 9a848aed646..3362941fcec 100644 --- a/megamek/src/megamek/common/alphaStrike/conversion/ASSpecialAbilityConverter.java +++ b/megamek/src/megamek/common/alphaStrike/conversion/ASSpecialAbilityConverter.java @@ -450,7 +450,7 @@ protected void processTransports() { assign("Docking Collar", DT, 1); } else if (t instanceof InfantryBay) { assign("Infantry Bay", IT, ((InfantryBay) t).getCapacity()); - } else if (t instanceof TroopSpace) { + } else if (t instanceof InfantryCompartment) { assign("Troop Space", IT, t.getUnused()); } else if (t instanceof MekBay) { assign("Mek Bay", MT, (int) ((MekBay) t).getCapacity()); diff --git a/megamek/src/megamek/common/loaders/BLKFile.java b/megamek/src/megamek/common/loaders/BLKFile.java index 05a8659090f..635fd9b8811 100644 --- a/megamek/src/megamek/common/loaders/BLKFile.java +++ b/megamek/src/megamek/common/loaders/BLKFile.java @@ -1193,7 +1193,7 @@ protected void addTransports(Entity e) throws EntityLoadingException { case "troopspace": // Everything after the ':' should be the space's size. double fsize = Double.parseDouble(numbers); - e.addTransporter(new TroopSpace(fsize), isPod); + e.addTransporter(new InfantryCompartment(fsize), isPod); break; case "cargobay": pbi = new ParsedBayInfo(numbers, usedBayNumbers); diff --git a/megamek/src/megamek/common/templates/TROView.java b/megamek/src/megamek/common/templates/TROView.java index e30ebd14fd2..fef8b33fbd4 100644 --- a/megamek/src/megamek/common/templates/TROView.java +++ b/megamek/src/megamek/common/templates/TROView.java @@ -684,7 +684,7 @@ protected String formatLocationTableEntry(Entity entity, Mounted mounted) { */ protected @Nullable Map formatTransporter(Transporter transporter, String loc) { final Map retVal = new HashMap<>(); - if (transporter instanceof TroopSpace) { + if (transporter instanceof InfantryCompartment) { retVal.put("name", Messages.getString("TROView.TroopSpace")); retVal.put("tonnage", transporter.getUnused()); } else if (transporter instanceof Bay) { diff --git a/megamek/src/megamek/common/verifier/TestSupportVehicle.java b/megamek/src/megamek/common/verifier/TestSupportVehicle.java index afdf415e453..4e0f8775af3 100644 --- a/megamek/src/megamek/common/verifier/TestSupportVehicle.java +++ b/megamek/src/megamek/common/verifier/TestSupportVehicle.java @@ -1512,7 +1512,7 @@ public StringBuffer printSlotCalculation() { boolean troopSpaceFound = false; for (Transporter transport : supportVee.getTransports()) { - if ((transport instanceof TroopSpace) && !troopSpaceFound) { + if ((transport instanceof InfantryCompartment) && !troopSpaceFound) { buff.append(StringUtil.makeLength("Troop Space", 30)); buff.append("1\n"); troopSpaceFound = true; @@ -1702,7 +1702,7 @@ public int getCrewSlots() { } /** - * Each distinct bay requires a slot, regardless of size. All {@link TroopSpace} + * Each distinct bay requires a slot, regardless of size. All {@link InfantryCompartment} * is treated as a single bay. * * @return The number of slots required by transporters. @@ -1714,7 +1714,7 @@ public int getTransportSlots() { for (Transporter transporter : supportVee.getTransports()) { if ((transporter instanceof Bay transportBay) && !transportBay.isQuarters()) { slots++; - } else if ((transporter instanceof TroopSpace) && !foundTroopSpace) { + } else if ((transporter instanceof InfantryCompartment) && !foundTroopSpace) { slots++; foundTroopSpace = true; } diff --git a/megamek/src/megamek/common/verifier/TestTank.java b/megamek/src/megamek/common/verifier/TestTank.java index cd0ec0ed217..9a569837d4f 100755 --- a/megamek/src/megamek/common/verifier/TestTank.java +++ b/megamek/src/megamek/common/verifier/TestTank.java @@ -667,7 +667,7 @@ public StringBuffer printSlotCalculation() { // total) boolean infantryBayCounted = false; for (Transporter transport : tank.getTransports()) { - if (transport instanceof TroopSpace) { + if (transport instanceof InfantryCompartment) { buff.append(StringUtil.makeLength("Troop Space", 30)); buff.append("1\n"); infantryBayCounted = true;