Skip to content

Commit

Permalink
Merge branch 'master' into wordWrap_utilityMethod
Browse files Browse the repository at this point in the history
  • Loading branch information
IllianiCBT authored Aug 5, 2024
2 parents e82f991 + f0895fd commit afdf8aa
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 163 deletions.
2 changes: 2 additions & 0 deletions megamek/docs/history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ MEGAMEK VERSION HISTORY:
+ PR #5845: Force destruction of out-of-control DropShips and larger (implements #770)
+ PR #5841: FighterSquadron updates
+ PR #5846: Index guard for turn lookup to prevent error messages
+ Fix #5587: Check if Edge is enabled in Game Options before using it
+ PR #5859: Use OptionsConstants instead of hard-coded strings

0.49.20 (2024-06-28 2100 UTC) (THIS IS THE LAST VERSION TO SUPPORT JAVA 11)
+ PR #5281, #5327, #5308, #5336, #5318, #5383, #5369, #5384, #5455, #5505, #5541: Code internals: preparatory work for supporting game types such as SBF, code cleanup for string drawing, superclass change for BoardView,
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/Compute.java
Original file line number Diff line number Diff line change
Expand Up @@ -2443,7 +2443,7 @@ public static ToHitData getSecondaryTargetMod(Game game, Entity attacker,
if (attacker.getCrew().hasDedicatedGunner()) {
maxPrimary = attacker.getCrew().getCrewType().getMaxPrimaryTargets();
}
if (game.getOptions().booleanOption("tacops_tank_crews")
if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_TACOPS_TANK_CREWS)
&& (attacker instanceof Tank)) {

// If we are a tank, and only have 1 crew then we have some special
Expand Down
8 changes: 8 additions & 0 deletions megamek/src/megamek/common/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16050,4 +16050,12 @@ public Base64Image getBase64Icon() {
public boolean countForStrengthSum() {
return !isDestroyed() && !isTrapped() && !isPartOfFighterSquadron();
}

/** @return True if the unit should use Edge based on the current options and assigned Edge points */
public boolean shouldUseEdge(String option) {
return (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& getCrew() != null
&& getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(option));
}
}
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/FighterSquadron.java
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ public void computeSquadronBombLoadout() {
}

// Now that we know our bomb choices, load 'em
int gameTL = TechConstants.getSimpleLevel(game.getOptions().stringOption("techlevel"));
int gameTL = TechConstants.getSimpleLevel(game.getOptions().stringOption(OptionsConstants.ALLOWED_TECHLEVEL));
for (int type = 0; type < BombType.B_NUM; type++) {
for (int i = 0; i < extBombChoices[type]; i++) {
if ((type == BombType.B_ALAMO)
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/IBomber.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ default int getBombPoints(boolean externalOnly) {
*/
default void applyBombs() {
Game game = ((Entity) this).getGame();
int gameTL = TechConstants.getSimpleLevel(game.getOptions().stringOption("techlevel"));
int gameTL = TechConstants.getSimpleLevel(game.getOptions().stringOption(OptionsConstants.ALLOWED_TECHLEVEL));
Integer[] iSorted = new Integer[BombType.B_NUM];
// Apply the largest bombs first because we need to fit larger bombs into a single location
// in LAMs.
Expand Down
64 changes: 17 additions & 47 deletions megamek/src/megamek/common/Mech.java
Original file line number Diff line number Diff line change
Expand Up @@ -1992,8 +1992,7 @@ public HitData rollHitLocation(int table, int side, int aimedLocation, AimingMod
// normal front hits
switch (roll) {
case 2:
if ((getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC))
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC)
&& !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) {
getCrew().decreaseEdge();
HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover);
Expand All @@ -2018,9 +2017,7 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC))
case 11:
return new HitData(Mech.LOC_LARM);
case 12:
if (getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
HitData result = rollHitLocation(table, side,
aimedLocation, aimingMode, cover);
Expand All @@ -2033,8 +2030,7 @@ && getCrew().getOptions().booleanOption(
// normal left side hits
switch (roll) {
case 2:
if ((getCrew().hasEdgeRemaining() && getCrew()
.getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC))
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC)
&& !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) {
getCrew().decreaseEdge();
HitData result = rollHitLocation(table, side,
Expand Down Expand Up @@ -2070,9 +2066,7 @@ && getCrew().getOptions().booleanOption(
case 11:
return new HitData(Mech.LOC_RLEG);
case 12:
if (getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
HitData result = rollHitLocation(table, side,
aimedLocation, aimingMode, cover);
Expand All @@ -2085,8 +2079,7 @@ && getCrew().getOptions().booleanOption(
// normal right side hits
switch (roll) {
case 2:
if ((getCrew().hasEdgeRemaining() && getCrew()
.getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC))
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC)
&& !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) {
getCrew().decreaseEdge();
HitData result = rollHitLocation(table, side,
Expand Down Expand Up @@ -2122,9 +2115,7 @@ && getCrew().getOptions().booleanOption(
case 11:
return new HitData(Mech.LOC_LLEG);
case 12:
if (getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
HitData result = rollHitLocation(table, side,
aimedLocation, aimingMode, cover);
Expand All @@ -2140,9 +2131,7 @@ && getCrew().getOptions().booleanOption(
&& isProne()) {
switch (roll) {
case 2:
if ((getCrew().hasEdgeRemaining() && getCrew()
.getOptions()
.booleanOption(OptionsConstants.EDGE_WHEN_TAC))
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC)
&& !game.getOptions().booleanOption(
OptionsConstants.ADVCOMBAT_NO_TAC)) {
getCrew().decreaseEdge();
Expand Down Expand Up @@ -2170,9 +2159,7 @@ && isProne()) {
case 11:
return new HitData(Mech.LOC_LARM, true);
case 12:
if (getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
HitData result = rollHitLocation(table, side,
aimedLocation, aimingMode, cover);
Expand All @@ -2185,9 +2172,7 @@ && getCrew().getOptions().booleanOption(
} else {
switch (roll) {
case 2:
if ((getCrew().hasEdgeRemaining() && getCrew()
.getOptions()
.booleanOption(OptionsConstants.EDGE_WHEN_TAC))
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC)
&& !game.getOptions().booleanOption(
OptionsConstants.ADVCOMBAT_NO_TAC)) {
getCrew().decreaseEdge();
Expand Down Expand Up @@ -2215,9 +2200,7 @@ && getCrew().getOptions().booleanOption(
case 11:
return new HitData(Mech.LOC_LARM, true);
case 12:
if (getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
HitData result = rollHitLocation(table, side,
aimedLocation, aimingMode, cover);
Expand Down Expand Up @@ -2260,9 +2243,7 @@ && getCrew().getOptions().booleanOption(
case 5:
return new HitData(Mech.LOC_RARM);
case 6:
if (getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
HitData result = rollHitLocation(table, side,
aimedLocation, aimingMode, cover);
Expand All @@ -2284,9 +2265,7 @@ && getCrew().getOptions().booleanOption(
case 5:
return new HitData(Mech.LOC_LARM);
case 6:
if (getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
HitData result = rollHitLocation(table, side,
aimedLocation, aimingMode, cover);
Expand All @@ -2308,9 +2287,7 @@ && getCrew().getOptions().booleanOption(
case 5:
return new HitData(Mech.LOC_RARM);
case 6:
if (getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
HitData result = rollHitLocation(table, side,
aimedLocation, aimingMode, cover);
Expand All @@ -2334,9 +2311,7 @@ && getCrew().getOptions().booleanOption(
case 5:
return new HitData(Mech.LOC_RARM, true);
case 6:
if (getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
HitData result = rollHitLocation(table, side,
aimedLocation, aimingMode, cover);
Expand Down Expand Up @@ -2413,8 +2388,7 @@ && getCrew().getOptions().booleanOption(
// Swarm attack locations.
switch (roll) {
case 2:
if (getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) {
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover);
result.setUndoneLocation(new HitData(Mech.LOC_HEAD, false, effects));
Expand All @@ -2440,9 +2414,7 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) {
case 11:
return new HitData(Mech.LOC_CT, true, effects);
case 12:
if (getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
HitData result = rollHitLocation(table, side,
aimedLocation, aimingMode, cover);
Expand Down Expand Up @@ -2481,9 +2453,7 @@ && getCrew().getOptions().booleanOption(
case 5:
return new HitData(Mech.LOC_RARM, (side == ToHitData.SIDE_REAR));
case 6:
if (getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
HitData result = rollHitLocation(table, side,
aimedLocation, aimingMode, cover);
Expand Down
Loading

0 comments on commit afdf8aa

Please sign in to comment.