Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename TroopSpace to InfantryCompartment #6181

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions megamek/src/megamek/common/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)");
Expand Down Expand Up @@ -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;
Expand All @@ -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;
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 @@ -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 @@ -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);
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