Skip to content

Commit

Permalink
Merge pull request #4898 from MegaMek/fixed_wing_fuel
Browse files Browse the repository at this point in the history
Fix test for aerospace units that don't require fuel
  • Loading branch information
neoancient authored Nov 22, 2023
2 parents 8ac139f + 5a6a738 commit 6ddd0e4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion megamek/src/megamek/client/ui/swing/MovementDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -4117,7 +4117,7 @@ private void checkFuel() {
}

IAero aero = (IAero) ce;
if ((aero.getCurrentFuel() < 1) && !(ce.hasEngine() && ce.getEngine().isSolar())) {
if ((aero.getCurrentFuel() < 1) && aero.requiresFuel()) {
disableButtons();
butDone.setEnabled(true);
getBtn(MoveCommand.MOVE_NEXT).setEnabled(true);
Expand Down
14 changes: 10 additions & 4 deletions megamek/src/megamek/common/FixedWingSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,11 @@ public boolean hasPropChassisMod() {
* @return The mass of each point of fuel in kg.
*/
public int kgPerFuelPoint() {
if (!requiresFuel()) {
return 0;
}
int kg = KG_PER_FUEL_POINT[getWeightClass() - EntityWeightClass.WEIGHT_SMALL_SUPPORT][getEngineTechRating()];
if (hasPropChassisMod() || getMovementMode().equals(EntityMovementMode.AIRSHIP)) {
if (getEngine().isFusion() || (getEngine().getEngineType() == Engine.FISSION)
|| (getEngine().getEngineType() == Engine.SOLAR)) {
return 0;
}
kg = (int) Math.ceil(kg * 0.75);
}
return kg;
Expand All @@ -157,6 +156,13 @@ public double getFuelPointsPerTon() {
return 1000.0 / kgPerFuelPoint();
}

@Override
public boolean requiresFuel() {
return !(((hasPropChassisMod() || getMovementMode().isAirship()))
&& hasEngine() && (getEngine().isFusion() || (getEngine().getEngineType() == Engine.FISSION)
|| (getEngine().getEngineType() == Engine.SOLAR)));
}

private static final TechAdvancement TA_FIXED_WING_SUPPORT = new TechAdvancement(TECH_BASE_ALL)
.setAdvancement(DATE_PS, DATE_PS, DATE_PS)
.setTechRating(RATING_B).setAvailability(RATING_C, RATING_D, RATING_C, RATING_C)
Expand Down
4 changes: 4 additions & 0 deletions megamek/src/megamek/common/IAero.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ default int getClusterMods() {

double getFuelPointsPerTon();

default boolean requiresFuel() {
return true;
}

// Capital fighters
int getCapArmor();

Expand Down

0 comments on commit 6ddd0e4

Please sign in to comment.