Skip to content

Commit 148b2d0

Browse files
authored
Merge pull request #8270 from psikomonkie/issue/8226/hhw-crews
Fix #8226: Prevent HHWs from being crewed
2 parents 2c203af + f130d04 commit 148b2d0

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

MekHQ/src/mekhq/campaign/ResolveScenarioTracker.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,6 @@ private UnitStatus processAlliedUnit(Entity e) {
557557
* <p>
558558
* This method should be run the first time an entity is loaded into the tracker, either from the game or from a MUL
559559
* file.
560-
*
561560
*/
562561
private void checkForLostLimbs(Entity en, boolean controlsField) {
563562
for (int loc = 0; loc < en.locations(); loc++) {
@@ -666,7 +665,7 @@ public void checkStatusOfPersonnel() {
666665
}
667666
}
668667
// No crew? All's good, no personnel, next.
669-
if (u.isUnmannedTrailer()) {
668+
if (u.isNotCrewedEntityType()) {
670669
continue;
671670
}
672671

MekHQ/src/mekhq/campaign/mission/CrewSkillUpgrader.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ private int addSingleSPA(Entity entity, double xpCap) {
197197
break;
198198
default:
199199
// If there's no crew, stop looking for SPAs
200-
if (entity.getCrew() == null) {
200+
if (entity.isUncrewed()) {
201201
return 0;
202202
// If we can't access the option, try a different one
203203
} else if ((entity.getCrew().getOptions() == null) ||
@@ -257,7 +257,6 @@ private List<SpecialAbility> coalescedSPAList(int unitType, double xpCap) {
257257

258258
/**
259259
* Contains "special" logic to ensure SPA is appropriate for the entity, beyond the simple unit type check.
260-
*
261260
*/
262261
private boolean extraEligibilityCheck(SpecialAbility spa, Entity entity) {
263262
if (spa.getName().equals(OptionsConstants.PILOT_ANIMAL_MIMIC)) {

MekHQ/src/mekhq/campaign/unit/Unit.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
import megamek.common.options.PilotOptions;
9595
import megamek.common.rolls.TargetRoll;
9696
import megamek.common.units.*;
97-
import megamek.common.units.CrewType;
9897
import megamek.common.util.C3Util;
9998
import megamek.common.weapons.attacks.InfantryAttack;
10099
import megamek.common.weapons.bayWeapons.BayWeapon;
@@ -1223,7 +1222,7 @@ public void undeploy() {
12231222
if (!isFunctional()) {
12241223
return "unit is not functional";
12251224
}
1226-
if (isUnmanned() && !(isUnmannedTrailer())) {
1225+
if (isUnmanned() && isNotCrewedEntityType()) {
12271226
return "unit has no pilot";
12281227
}
12291228
if (isRefitting()) {
@@ -5675,6 +5674,9 @@ public void remove(final @Nullable Person person, final boolean log) {
56755674
}
56765675
}
56775676

5677+
/**
5678+
* @return true if the unit has no commander
5679+
*/
56785680
public boolean isUnmanned() {
56795681
return (null == getCommander());
56805682
}
@@ -5685,8 +5687,8 @@ public boolean isUnmanned() {
56855687
* @return true if this Unit is an unmanned trailer, false if it isn't a trailer or has a crew
56865688
*/
56875689
public boolean isUnmannedTrailer() {
5688-
if (getEntity() instanceof Tank tank) {
5689-
return tank.isTrailer() && (tank.defaultCrewType().equals(CrewType.NONE));
5690+
if (isNotCrewedEntityType() && getEntity() instanceof Tank tank) {
5691+
return tank.isTrailer();
56905692
}
56915693

56925694
return false;
@@ -5696,6 +5698,14 @@ public boolean isHandheldWeapon() {
56965698
return entity instanceof HandheldWeapon;
56975699
}
56985700

5701+
/**
5702+
* @return true if the unit is always uncrewed, like a Handheld Weapon or unarmed, unpowered trailer. Should not
5703+
* return true for remote drone OS. False if the entity is null.
5704+
*/
5705+
public boolean isNotCrewedEntityType() {
5706+
return entity != null && entity.isNotCrewedEntityType();
5707+
}
5708+
56995709
public int getForceId() {
57005710
return forceId;
57015711
}

MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ protected Optional<JPopupMenu> createPopupMenu() {
10471047
}
10481048
} else if ((u.getForceId() < 1) &&
10491049
(u.isPresent()) &&
1050-
(u.isUnmannedTrailer() || u.isHandheldWeapon())) {
1050+
(u.isNotCrewedEntityType())) {
10511051
JMenuItem menuItem0 = new JMenuItem(u.getName());
10521052
menuItem0.setActionCommand(TOEMouseAdapter.COMMAND_ADD_UNIT + u.getId() + '|' + forceIds);
10531053
menuItem0.addActionListener(this);

0 commit comments

Comments
 (0)