Skip to content

Commit

Permalink
Merge pull request #6181 from SJuliez/troopspace-rename
Browse files Browse the repository at this point in the history
Rename TroopSpace to InfantryCompartment
  • Loading branch information
HammerGS authored Nov 24, 2024
2 parents f6174fc + 60a4fe0 commit 61d2def
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,7 @@ MekSelectorDialog.Search.ClanEngine=Clan Engine:
MekSelectorDialog.Search.Source=Source:
MekSelectorDialog.Search.Source.TT=Multiple search tokens can be used, separated by spaces, e.g. "guide #9"
MekSelectorDialog.Search.MULId=MUL Id:
MekSelectorDialog.Search.TroopSpace=Troop Space:
MekSelectorDialog.Search.TroopSpace=Infantry Compartments:
MekSelectorDialog.Search.ASFBays=ASF Bays:
MekSelectorDialog.Search.SmallCraftBays=Small Craft Bays:
MekSelectorDialog.Search.MekBays=Mek Bays:
Expand Down
10 changes: 5 additions & 5 deletions megamek/src/megamek/common/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8931,7 +8931,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)");
Expand Down Expand Up @@ -10136,8 +10136,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;
Expand All @@ -10146,8 +10146,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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer, Double> troops = new HashMap<>();

/**
* The total amount of space available for troops.
*/
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -125,7 +125,7 @@ public Vector<Entity> getLoadedUnits() {
for (Map.Entry<Integer, Double> entry : troops.entrySet()) {
int key = entry.getKey();
Entity entity = game.getEntity(key);

if (entity != null) {
loaded.add(entity);
}
Expand Down Expand Up @@ -174,7 +174,7 @@ public boolean unload(Entity unit) {
*/
@Override
public String getUnusedString() {
return "Troops - " + currentSpace + " tons";
return "Infantry Compartment - " + currentSpace + " tons";
}

@Override
Expand Down Expand Up @@ -240,7 +240,7 @@ public String toString() {
public void setGame(Game game) {
this.game = game;
}

@Override
public void resetTransporter() {
troops = new HashMap<>();
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/Tank.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/loaders/BLKFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,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);
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/templates/TROView.java
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ protected String formatLocationTableEntry(Entity entity, Mounted<?> mounted) {
*/
protected @Nullable Map<String, Object> formatTransporter(Transporter transporter, String loc) {
final Map<String, Object> 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) {
Expand Down
6 changes: 3 additions & 3 deletions megamek/src/megamek/common/verifier/TestSupportVehicle.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/verifier/TestTank.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 61d2def

Please sign in to comment.