yairm210 / Unciv

Open-source Android/Desktop remake of Civ V

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Promotion crash

hackedpassword opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Game Version

4.11.5

Describe the bug

Crash data below:

Platform: Android
Version: 4.11.5 (Build 988)
Rulesets: [Policy mod, RekMOD, Community Maps, Nextgen Maps, BabylonUI, NextgenMaps Labs, AFX, Z2, Inverted World, Antiyoy maps, Better ruins Lite, Civ V - Vanilla, No Fog Of War, Resource Recyclers, Civ V Leader portraits, CoeHarMod, Alpha Frontier, Raze anything, All units can be automated, Civ V - Gods & Kings, The Great Unciv Rework, Closer Cities Distance of 1, Better Workers, Better ruins, Mapping Tools for Unciv]
Last Screen: com.unciv.ui.screens.worldscreen.WorldScreen


Device Model: SM-G973U1
API Level: 31
System Memory: 7461 MB
Available (used by Kernel): 2411 MB
System Low Memory state: false
Java heap limit: 512 MB
Java heap free: 1 MB


Message:

java.lang.NullPointerException
	at com.unciv.logic.map.mapunit.UnitPromotions.addPromotion(UnitPromotions.kt:67)
	at com.unciv.logic.map.TileMap.placeUnitNearTile(TileMap.kt:591)
	at com.unciv.logic.civilization.managers.UnitManager.placeUnitNearTile(UnitManager.kt:94)
	at com.unciv.logic.civilization.managers.UnitManager.placeUnitNearTile(UnitManager.kt:85)
	at com.unciv.logic.civilization.managers.UnitManager.addUnit(UnitManager.kt:61)
	at com.unciv.models.ruleset.unit.BaseUnit.postBuildEvent(BaseUnit.kt:297)
	at com.unciv.models.ruleset.INonPerpetualConstruction$DefaultImpls.postBuildEvent$default(IConstruction.kt:43)
	at com.unciv.logic.city.CityConstructions.constructionComplete(CityConstructions.kt:461)
	at com.unciv.logic.city.CityConstructions.constructIfEnough(CityConstructions.kt:340)
	at com.unciv.logic.city.managers.CityTurnManager.startTurn(CityTurnManager.kt:23)
	at com.unciv.logic.civilization.managers.TurnManager.startTurn(TurnManager.kt:76)
	at com.unciv.logic.GameInfo.nextTurn(GameInfo.kt:387)
	at com.unciv.ui.screens.worldscreen.WorldScreen$nextTurn$1.invokeSuspend(WorldScreen.kt:597)
	at com.unciv.ui.screens.worldscreen.WorldScreen$nextTurn$1.invoke(Unknown Source:8)
	at com.unciv.ui.screens.worldscreen.WorldScreen$nextTurn$1.invoke(Unknown Source:4)
	at com.unciv.utils.ConcurrencyKt$launchCrashHandling$1.invokeSuspend(Concurrency.kt:87)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
	at com.unciv.utils.CrashHandlingDispatcher$dispatch$1.invoke(Concurrency.kt:173)
	at com.unciv.utils.CrashHandlingDispatcher$dispatch$1.invoke(Concurrency.kt:173)
	at com.unciv.ui.crashhandling.CrashHandlingExtensionsKt$wrapCrashHandling$1.invoke(CrashHandlingExtensions.kt:17)
	at com.unciv.ui.crashhandling.CrashHandlingExtensionsKt$wrapCrashHandlingUnit$1.invoke(CrashHandlingExtensions.kt:33)
	at com.unciv.ui.crashhandling.CrashHandlingExtensionsKt$wrapCrashHandlingUnit$1.invoke(CrashHandlingExtensions.kt:33)
	at com.unciv.utils.CrashHandlingDispatcher.dispatch$lambda$0(Concurrency.kt:173)
	at com.unciv.utils.CrashHandlingDispatcher.$r8$lambda$GFMOlD6QMgmLfgwAvPAW33Ob6HE(Unknown Source:0)
	at com.unciv.utils.CrashHandlingDispatcher$$ExternalSyntheticLambda0.run(Unknown Source:2)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:920)

Save Mods:

[Z2]

Permanent audiovisual Mods:

[BabylonUI, Raze anything, All units can be automated, Resource Recyclers, 5Hex Tileset]

Steps to Reproduce

Been modifying promotions, everything was OK. After hitting next turn, this crash happened.

Most recent updates have been to the promotion tree structure. It's entirely possible that the game is unhappy that a few promotions ceased existing mid-game, like Amphibious - > Amphibious I.

Screenshots

Screenshot_20240416-013328_Unciv

This really has nothing to do with it but was one of the last rendered screens. And it looks cool.

Link to save file

Too big!

https://pastebin.com/yXnJe9WK

Operating System

Android

Additional Information

I'll put this up to get feedback, poke at it more in a bit.

Yep that's what it is: pulling promotions out mid-game is confusing Unciv. I went back and copied each changed Example I to another Example promotion. Having the legacy promo allowed next turn to complete.

So it's not our bug except if we want to prevent such happenings actively - by updating GameInfo.removeMissingModReferences (in BackwardCompatibility) so these bad references are caught? removeUnitsAndPromotions sounds like it should already... Only runs on game load though. Is there a loophole to reload mods and rebuild a ruleset without... nah, impossible.

With exact steps to repro we could debug maybe.

When you change promotions, units with existing promotions that no longer exist have them removed.
The problem here is that we didn't safeguard against uniques granting this promotion - probably "All newly-trained [baseUnitFilter] units [cityFilter] receive the [promotion] promotion" but I would check the mod checker on your end.