Skip to content

Commit

Permalink
Merge pull request #4891 from MegaMek/recover_aero
Browse files Browse the repository at this point in the history
Check for available bay when recovering aero instead of using the first
  • Loading branch information
neoancient authored Nov 16, 2023
2 parents cf0792c + 01aa7a2 commit dde3af1
Showing 1 changed file with 21 additions and 31 deletions.
52 changes: 21 additions & 31 deletions megamek/src/megamek/common/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8171,42 +8171,32 @@ public void recover(Entity unit) {
// Walk through this entity's transport components;
// find those that can load the unit.
// load the unit into the best match.
int choice = 0;
for (Transporter nextbay : transports) {
if (nextbay.canLoad(unit) && (unit.getElevation() == getElevation())) {
if (nextbay instanceof DockingCollar) {
choice = 3;
}
if (nextbay instanceof ASFBay) {
choice = 2;
}
if (nextbay instanceof SmallCraftBay) {
choice = 1;
}
}
}
if (choice == 3) {
for (Transporter nextbay : transports) {
while (nextbay instanceof DockingCollar) {
((DockingCollar) nextbay).recover(unit);
return;
if (unit.getElevation() == getElevation()) {
if (unit.isDropShip()) {
for (Transporter nextbay : transports) {
if ((nextbay instanceof DockingCollar) && nextbay.canLoad(unit)) {
((DockingCollar) nextbay).recover(unit);
return;
}
}
}
} else if (choice == 2) {
for (Bay nextbay : getTransportBays()) {
while (nextbay instanceof ASFBay) {
((ASFBay) nextbay).recover(unit);
return;
} else {
if (unit.isFighter()) {
for (Bay nextbay : getTransportBays()) {
if ((nextbay instanceof ASFBay) && nextbay.canLoad(unit)) {
((ASFBay) nextbay).recover(unit);
return;
}
}
}
}
} else if (choice == 1) {
for (Bay nextbay : getTransportBays()) {
while (nextbay instanceof SmallCraftBay) {
((SmallCraftBay) nextbay).recover(unit);
return;
for (Bay nextbay : getTransportBays()) {
if ((nextbay instanceof SmallCraftBay) && nextbay.canLoad(unit)) {
((SmallCraftBay) nextbay).recover(unit);
return;
}
}
}
}
throw new IllegalArgumentException(getDisplayName() + " does not have a bay that can load" + unit.getDisplayName());
}


Expand Down

0 comments on commit dde3af1

Please sign in to comment.