Skip to content

Commit

Permalink
Merge pull request #3997 from MegaMek/dev_Windchild_3489
Browse files Browse the repository at this point in the history
MHQ 3489: Fixing Missing DockingCollar Handling in Load
  • Loading branch information
Windchild292 authored Nov 24, 2022
2 parents d9b2246 + 6437fff commit c1d8a8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
11 changes: 6 additions & 5 deletions megamek/src/megamek/common/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8119,17 +8119,18 @@ public void load(Entity unit, boolean checkElev, int bayNumber) {
while (iter.hasMoreElements()) {
Transporter next = iter.nextElement();
if (next.canLoad(unit)
&& (!checkElev || (unit.getElevation() == getElevation()))
&& ((bayNumber == -1) || (((Bay) next).getBayNumber() == bayNumber))) {
&& (!checkElev || (unit.getElevation() == getElevation()))
&& ((bayNumber == -1)
|| ((next instanceof Bay) && (((Bay) next).getBayNumber() == bayNumber))
|| ((next instanceof DockingCollar) && (((DockingCollar) next).getCollarNumber() == bayNumber)))) {
next.load(unit);
unit.setTargetBay(-1); // Reset the target bay for later.
return;
}
}

// If we got to this point, then we can't load the unit.
throw new IllegalArgumentException(getShortName() + " can not load "
+ unit.getShortName());
throw new IllegalArgumentException(getShortName() + " can not load " + unit.getShortName());
}

public void load(Entity unit, boolean checkElev) {
Expand Down Expand Up @@ -8165,7 +8166,7 @@ public void recover(Entity unit) {
choice = 2;
}
if (nextbay instanceof SmallCraftBay) {
choice = 1;
choice = 1;
}
}
}
Expand Down
12 changes: 4 additions & 8 deletions megamek/src/megamek/server/GameManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3428,11 +3428,7 @@ private void loadUnit(Entity loader, Entity unit, int bayNumber) {
// Load the unit. Do not check for elevation during deployment
boolean checkElevation = !getGame().getPhase().isLounge()
&& !getGame().getPhase().isDeployment();
if (bayNumber == -1) {
loader.load(unit, checkElevation);
} else {
loader.load(unit, checkElevation, bayNumber);
}
loader.load(unit, checkElevation, bayNumber);

// The loaded unit is being carried by the loader.
unit.setTransportId(loader.getId());
Expand All @@ -3443,9 +3439,9 @@ private void loadUnit(Entity loader, Entity unit, int bayNumber) {
// set deployment round of the loadee to equal that of the loader
unit.setDeployRound(loader.getDeployRound());

//Update the loading unit's passenger count, if it's a large craft
if (loader instanceof SmallCraft || loader instanceof Jumpship) {
//Don't add DropShip crew to a JumpShip or station's passenger list
// Update the loading unit's passenger count, if it's a large craft
if ((loader instanceof SmallCraft) || (loader instanceof Jumpship)) {
// Don't add DropShip crew to a JumpShip or station's passenger list
if (!unit.isLargeCraft()) {
loader.setNPassenger(loader.getNPassenger() + unit.getCrew().getSize());
}
Expand Down

0 comments on commit c1d8a8c

Please sign in to comment.