Skip to content

Commit

Permalink
Strip BA parts from non-BA units MegaMek#2396
Browse files Browse the repository at this point in the history
  • Loading branch information
sixlettervariables committed Feb 6, 2021
1 parent b1f5d76 commit 0a95d4f
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions MekHQ/src/mekhq/campaign/unit/Unit.java
Original file line number Diff line number Diff line change
Expand Up @@ -2285,13 +2285,15 @@ public void initializeParts(boolean addParts) {
partsToRemove.add(part);
}
} else if (part instanceof BattleArmorSuit) {
if (((BattleArmorSuit) part).getTrooper() < locations.length) {
if ((entity instanceof BattleArmor)
&& ((BattleArmorSuit) part).getTrooper() < locations.length) {
locations[((BattleArmorSuit) part).getTrooper()] = part;
} else {
partsToRemove.add(part);
}
} else if (part instanceof MissingBattleArmorSuit) {
if (((MissingBattleArmorSuit) part).getTrooper() < locations.length) {
if ((entity instanceof BattleArmor)
&& ((MissingBattleArmorSuit) part).getTrooper() < locations.length) {
locations[((MissingBattleArmorSuit) part).getTrooper()] = part;
} else {
partsToRemove.add(part);
Expand Down Expand Up @@ -2325,19 +2327,27 @@ public void initializeParts(boolean addParts) {
} else if (part instanceof MissingJumpJet) {
jumpJets.put(((MissingJumpJet)part).getEquipmentNum(), part);
} else if (part instanceof BattleArmorEquipmentPart) {
Part[] parts = baEquipParts.get(((BattleArmorEquipmentPart)part).getEquipmentNum());
if (null == parts) {
parts = new Part[((BattleArmor)entity).getSquadSize()];
if (!(entity instanceof BattleArmor)) {
partsToRemove.add(part);
} else {
Part[] parts = baEquipParts.get(((BattleArmorEquipmentPart)part).getEquipmentNum());
if (null == parts) {
parts = new Part[((BattleArmor)entity).getSquadSize()];
}
parts[((BattleArmorEquipmentPart)part).getTrooper()-BattleArmor.LOC_TROOPER_1] = part;
baEquipParts.put(((BattleArmorEquipmentPart)part).getEquipmentNum(), parts);
}
parts[((BattleArmorEquipmentPart)part).getTrooper()-BattleArmor.LOC_TROOPER_1] = part;
baEquipParts.put(((BattleArmorEquipmentPart)part).getEquipmentNum(), parts);
} else if (part instanceof MissingBattleArmorEquipmentPart) {
Part[] parts = baEquipParts.get(((MissingBattleArmorEquipmentPart)part).getEquipmentNum());
if (null == parts) {
parts = new Part[((BattleArmor)entity).getSquadSize()];
if (!(entity instanceof BattleArmor)) {
partsToRemove.add(part);
} else {
Part[] parts = baEquipParts.get(((MissingBattleArmorEquipmentPart)part).getEquipmentNum());
if (null == parts) {
parts = new Part[((BattleArmor)entity).getSquadSize()];
}
parts[((MissingBattleArmorEquipmentPart)part).getTrooper()-BattleArmor.LOC_TROOPER_1] = part;
baEquipParts.put(((MissingBattleArmorEquipmentPart)part).getEquipmentNum(), parts);
}
parts[((MissingBattleArmorEquipmentPart)part).getTrooper()-BattleArmor.LOC_TROOPER_1] = part;
baEquipParts.put(((MissingBattleArmorEquipmentPart)part).getEquipmentNum(), parts);
} else if (part instanceof EquipmentPart) {
equipParts.put(((EquipmentPart)part).getEquipmentNum(), part);
} else if (part instanceof MissingEquipmentPart) {
Expand Down

0 comments on commit 0a95d4f

Please sign in to comment.