Skip to content

Commit cee8e52

Browse files
authored
Merge pull request #5438 from Scoppio/fix/npe-acar-gunemplacement-bandaid
fix: quick bandaid for gun emplacements in ACAR
2 parents 3d412f6 + 003244b commit cee8e52

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

MekHQ/src/mekhq/campaign/autoresolve/converter/ForceToFormationConverter.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@
3232
import megamek.common.strategicBattleSystems.BaseFormationConverter;
3333
import megamek.common.strategicBattleSystems.SBFUnit;
3434
import megamek.common.strategicBattleSystems.SBFUnitConverter;
35+
import megamek.logging.MMLogger;
3536
import mekhq.campaign.autoresolve.acar.SimulationContext;
3637
import mekhq.campaign.autoresolve.component.Formation;
3738

3839
import java.util.ArrayList;
3940

4041
public class ForceToFormationConverter extends BaseFormationConverter<Formation> {
42+
private static final MMLogger logger = MMLogger.create(ForceToFormationConverter.class);
4143

4244
public ForceToFormationConverter(Force force, SimulationContext game) {
4345
super(force, game, new Formation());
@@ -50,7 +52,13 @@ public Formation convert() {
5052
var thisUnit = new ArrayList<AlphaStrikeElement>();
5153
for (ForceAssignable entity : forces.getFullEntities(subforce)) {
5254
if (entity instanceof Entity entityCast) {
53-
thisUnit.add(ASConverter.convertAndKeepRefs(entityCast));
55+
var element = ASConverter.convertAndKeepRefs(entityCast);
56+
if (element != null) {
57+
thisUnit.add(element);
58+
} else {
59+
var msg = String.format("Could not convert entity %s to AS element", entityCast);
60+
logger.error(msg);
61+
}
5462
}
5563
}
5664
SBFUnit convertedUnit = new SBFUnitConverter(thisUnit, subforce.getName(), report).createSbfUnit();

0 commit comments

Comments
 (0)