Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null protection when generating forces from fixed scenarios like Base Defense #4436

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -1433,13 +1433,18 @@ public static List<Entity> fillTransports (AtBScenario scenario,
// Strip roles that are not infantry or battle armor, and remove the artillery role
Map<Integer, Collection<MissionRole>> transportedRoles = new HashMap<>();

transportedRoles.put(UnitType.INFANTRY, requiredRoles.containsKey(UnitType.INFANTRY) ?
new ArrayList<>(requiredRoles.get(UnitType.INFANTRY)) : new ArrayList<>());
transportedRoles.get(UnitType.INFANTRY).remove((MissionRole.ARTILLERY));
if (requiredRoles != null) {

transportedRoles.put(UnitType.BATTLE_ARMOR, requiredRoles.containsKey(UnitType.BATTLE_ARMOR) ?
new ArrayList<>(requiredRoles.get(UnitType.BATTLE_ARMOR)) : new ArrayList<>());
transportedRoles.get(UnitType.BATTLE_ARMOR).remove((MissionRole.ARTILLERY));
transportedRoles.put(UnitType.INFANTRY, requiredRoles.containsKey(UnitType.INFANTRY) ?
new ArrayList<>(requiredRoles.get(UnitType.INFANTRY)) :
new ArrayList<>());
transportedRoles.get(UnitType.INFANTRY).remove((MissionRole.ARTILLERY));

transportedRoles.put(UnitType.BATTLE_ARMOR, requiredRoles.containsKey(UnitType.BATTLE_ARMOR) ?
new ArrayList<>(requiredRoles.get(UnitType.BATTLE_ARMOR)) :
new ArrayList<>());
transportedRoles.get(UnitType.BATTLE_ARMOR).remove((MissionRole.ARTILLERY));
}

List<Entity> transportedUnits = new ArrayList<>();

Expand Down