triplea icon indicating copy to clipboard operation
triplea copied to clipboard

ProPurchaseValidationUtils#canUnitsBePlaced:84 - java.lang.NullPointerException

Open tripleabuilderbot opened this issue 1 year ago • 3 comments

User Description

Tried to load the game with the Central Powers as Hard AI and every other nation as human. Error also comes up when any of Neutral_Allied, Neutral_Central, Neutral_Central, Neutral_True, Contested are set to Hard AI.

Map

world_war_i_1914_balanced / World War I 1914 Balanced

TripleA Version

2.6.14780

Java Version

11.0.19

Operating System

Windows 10

Heap Size

2028M

Stack Trace

Exception: java.lang.NullPointerException 
java.lang.Exception
	at games.strategy.triplea.ai.pro.util.ProPurchaseValidationUtils.canUnitsBePlaced(ProPurchaseValidationUtils.java:84)
	at games.strategy.triplea.ai.pro.util.ProPurchaseValidationUtils.lambda$findPurchaseOptionsForTerritory$0(ProPurchaseValidationUtils.java:58)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at games.strategy.triplea.ai.pro.util.ProPurchaseValidationUtils.findPurchaseOptionsForTerritory(ProPurchaseValidationUtils.java:61)
	at games.strategy.triplea.ai.pro.util.ProPurchaseValidationUtils.findPurchaseOptionsForTerritory(ProPurchaseValidationUtils.java:44)
	at games.strategy.triplea.ai.pro.util.ProPurchaseUtils.findMaxPurchaseDefenders(ProPurchaseUtils.java:96)
	at games.strategy.triplea.ai.pro.ProCombatMoveAi.removeAttacksUntilCapitalCanBeHeld(ProCombatMoveAi.java:1789)
	at games.strategy.triplea.ai.pro.ProCombatMoveAi.doCombatMove(ProCombatMoveAi.java:128)
	at games.strategy.triplea.ai.pro.AbstractProAi.purchase(AbstractProAi.java:219)
	at games.strategy.triplea.ai.AbstractAi.start(AbstractAi.java:509)
	at games.strategy.engine.framework.ServerGame.waitForPlayerToFinishStep(ServerGame.java:603)
	at games.strategy.engine.framework.ServerGame.runStep(ServerGame.java:452)
	at games.strategy.engine.framework.ServerGame.runNextStep(ServerGame.java:347)
	at games.strategy.engine.framework.ServerGame.startGame(ServerGame.java:314)
	at games.strategy.engine.framework.startup.launcher.LocalLauncher.launchInternal(LocalLauncher.java:92)
	at games.strategy.engine.framework.startup.launcher.LocalLauncher.lambda$launch$0(LocalLauncher.java:60)
	at java.base/java.lang.Thread.run(Thread.java:829)


tripleabuilderbot avatar Aug 28 '24 06:08 tripleabuilderbot

Crashing here: https://github.com/triplea-game/triplea/blob/7b1a73d777b114481cfb89976d8510360100f2f7/game-app/game-core/src/main/java/games/strategy/triplea/ai/pro/util/ProPurchaseValidationUtils.java#L84

So placeDelegate is null.

asvitkine avatar Aug 28 '24 17:08 asvitkine

But what should happen at this point in time if täplaceDelegate is null? Seems a bit too late to properly react to this.

frigoref avatar Aug 28 '24 22:08 frigoref

Is there a link to the world_war_i_1914_improved map? I only see world_war_i_1914 on github: https://github.com/triplea-maps/world_war_i_1914/blob/master/games/world_war_i_1914.xml

Probably the map should fail to load if there's a placeDelegate missing?

asvitkine avatar Nov 02 '24 19:11 asvitkine