Skip to content

Commit

Permalink
update code related to fuel-less aeros
Browse files Browse the repository at this point in the history
  • Loading branch information
SJuliez committed May 29, 2024
1 parent 1e39548 commit 0f85887
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ public void prepare() {
stStr.add(new Status(GUIP.getCautionColor(), "ROLLED"));
}

if ((a.getCurrentFuel() <= 0) && entity.hasEngine() && !entity.getEngine().isSolar()) {
if ((a.getCurrentFuel() <= 0) && a.requiresFuel()) {
stStr.add(new Status(GUIP.getWarningColor(), "FUEL"));
}

Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/ConvFighter.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public double getFuelPointsPerTon() {

@Override
public int getFuelUsed(int thrust) {
if (!hasEngine() || getEngine().isSolar()) {
if (!hasEngine() || !requiresFuel()) {
return 0;
}
int overThrust = Math.max(thrust - getWalkMP(), 0);
Expand Down
6 changes: 3 additions & 3 deletions megamek/src/megamek/common/FixedWingSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ public double getFuelPointsPerTon() {

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

private static final TechAdvancement TA_FIXED_WING_SUPPORT = new TechAdvancement(TECH_BASE_ALL)
Expand Down
9 changes: 8 additions & 1 deletion megamek/src/megamek/common/IAero.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ default int getClusterMods() {

double getFuelPointsPerTon();

/**
* @return True when this aero requires fuel to move. Note that the result is undefined when
* the unit has no engine. Callers should consider this case themselves. Also note that
* this method does not check whether fuel use as a game option is active, only if the unit
* technically requires fuel to move. For example, returns false for solar powered prop-driven
* fixed wing support (TM p129).
*/
default boolean requiresFuel() {
return true;
}
Expand Down Expand Up @@ -776,7 +783,7 @@ default void land() {

default int getFuelUsed(int thrust) {
Entity entity = (Entity) this;
if (entity.hasEngine() && entity.getEngine().isSolar()) {
if (!entity.hasEngine() || !requiresFuel()) {
return 0;
} else {
int overThrust = Math.max(thrust - entity.getWalkMP(), 0);
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/MoveStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -1921,7 +1921,7 @@ private void compileIllegal(final Game game, final Entity entity,

// check the fuel requirements
if (game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_FUEL_CONSUMPTION)
&& entity.hasEngine() && !entity.getEngine().isSolar()) {
&& entity.hasEngine() && a.requiresFuel()) {
int fuelUsed = mpUsed + Math.max(mpUsed - cachedEntityState.getWalkMP(), 0);
if (fuelUsed > a.getCurrentFuel()) {
return;
Expand Down

0 comments on commit 0f85887

Please sign in to comment.