yairm210 / Unciv

Open-source Android/Desktop remake of Civ V
Mozilla Public License 2.0
8.6k stars 1.58k forks source link

I need help with error #10512

Closed Casperblaze closed 1 year ago

Casperblaze commented 1 year ago

Hello, I haven't played this game in a while, but I Remember playing it with my father, we had a great time so I decided to start playing it again, this is the 2nd play attempt and I encounter the same error can somebody please help me with it

Platform: Android Version: 4.8.17 (Build 927) Rulesets: [Higher quality builtin sounds, Modern Civilizations, Civ V - Vanilla, Brave New World, Resource Recyclers, Community Maps, Extra Buildings, Expanded Warfare, Civ V - Gods & Kings, Dacia Unciv mod, More Luxuries, Closer Cities Distance of 1, 5Hex Tileset, Additional Music Various] Last Screen: com.unciv.ui.screens.worldscreen.WorldScreen


Device Model: SM-A536B API Level: 33


Message:

kotlin.UninitializedPropertyAccessException: lateinit property currentTile has not been initialized
    at com.unciv.logic.map.mapunit.MapUnit.getCurrentTile(MapUnit.kt:45)
    at com.unciv.logic.map.mapunit.MapUnit.getTile(MapUnit.kt:203)
    at com.unciv.models.ruleset.unique.Unique$conditionalApplies$relevantTile$2.invoke(Unique.kt:153)
    at com.unciv.models.ruleset.unique.Unique$conditionalApplies$relevantTile$2.invoke(Unique.kt:151)
    at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
    at com.unciv.models.ruleset.unique.Unique.conditionalApplies$lambda$10(Unique.kt:151)
    at com.unciv.models.ruleset.unique.Unique.conditionalApplies(Unique.kt:291)
    at com.unciv.models.ruleset.unique.Unique.conditionalsApply(Unique.kt:68)
    at com.unciv.models.ruleset.unique.UniqueMap$getMatchingUniques$1.invoke(Unique.kt:442)
    at com.unciv.models.ruleset.unique.UniqueMap$getMatchingUniques$1.invoke(Unique.kt:442)
    at kotlin.sequences.FilteringSequence$iterator$1.calcNext(Sequences.kt:171)
    at kotlin.sequences.FilteringSequence$iterator$1.hasNext(Sequences.kt:194)
    at kotlin.sequences.SequenceBuilderIterator.yieldAll(SequenceBuilder.kt:172)
    at kotlin.sequences.SequenceScope.yieldAll(SequenceBuilder.kt:92)
    at com.unciv.logic.map.mapunit.MapUnit$getMatchingUniques$1.invokeSuspend(MapUnit.kt:215)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlin.sequences.SequenceBuilderIterator.hasNext(SequenceBuilder.kt:129)
    at kotlin.sequences.SequencesKt___SequencesKt.any(_Sequences.kt:1218)
    at com.unciv.logic.map.mapunit.MapUnit.hasUnique(MapUnit.kt:227)
    at com.unciv.logic.map.mapunit.MapUnit.hasUnique$default(MapUnit.kt:222)
    at com.unciv.logic.map.mapunit.MapUnitCache.updateUniques(MapUnitCache.kt:81)
    at com.unciv.logic.map.mapunit.MapUnit.updateUniques(MapUnit.kt:244)
    at com.unciv.logic.map.mapunit.MapUnit.setTransients(MapUnit.kt:509)
    at com.unciv.models.ruleset.unit.BaseUnit.getMapUnit(BaseUnit.kt:84)
    at com.unciv.logic.automation.civilization.ReligionAutomation.buyInquisitorNear(ReligionAutomation.kt:176)
    at com.unciv.logic.automation.civilization.ReligionAutomation.spendFaithOnReligion(ReligionAutomation.kt:67)
    at com.unciv.logic.automation.civilization.NextTurnAutomation.automateCivMoves(NextTurnAutomation.kt:47)
    at com.unciv.logic.civilization.managers.TurnManager.automateTurn(TurnManager.kt:327)
    at com.unciv.logic.GameInfo.nextTurn(GameInfo.kt:376)
    at com.unciv.ui.screens.worldscreen.WorldScreen$nextTurn$1.invokeSuspend(WorldScreen.kt:602)
    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:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
    at java.lang.Thread.run(Thread.java:1012)

Save Mods:

[Modern Civilizations, Brave New World, Expanded Warfare, Resource Recyclers, Civ V - Gods & Kings, Community Maps, Dacia Unciv mod, More Luxuries, Closer Cities Distance of 1, Extra Buildings, 5Hex Tileset]

Save Data:

Show Saved Game ```
tuvus commented 1 year ago

It might have something to do with mods. The important line in your error is buyInquisitorNear(ReligionAutomation.kt:176), which searches through the ruleset (determined by the mods) for a unit that can act like an Inquisitor.

Could it be that we are trying to get the current tile of a hypothetical MapUnit that hasn't been placed yet called by some unique checking code?

Casperblaze commented 1 year ago

Pretty fascinating that you saw that in all the code, but therefore I think that's not fixable, that's something about the mods compatibility but Is there atleast a way to find out which of the mods is causing the error

SomeTroglodyte commented 1 year ago

Well, it.getMapUnit(civInfo).canDoLimitedAction(Constants.removeHeresy) is pretty nasty: Create a map unit not on the map just to look for a property, then discard it immediately... Plus it checks a deprecated Unique. So some mod could definitely avoid the crash while still maintaining intent - use the supported Unique instead. The offending Mod could be found with a file system content regex search pretty easily - on 'ix or 'doze. Can \[Remove Foreign religions from your own cities\] \[\d+\] times.*< should find it. Too lazy to download all that myself, maybe later (as in - 2024 :smiling_imp:) (spoiler: Mod checker will display the deprecation - go ahead, tell us)

SeventhM commented 1 year ago

Someone correct me (haven't checked the save that isn't even there yet), but is this not a duplicate of #10425? One of us should probably pr a fix for that

SomeTroglodyte commented 1 year ago

Dupe? In a way, yes, and the snippet in https://github.com/yairm210/Unciv/issues/10425#issuecomment-1793235892 would prevent this crash too. But is that a "solution" or A Solution... With that patch, all conditionals run on "I don't know my tile" and will probably return false, and thus logic relying on being able to recognize roles in the ruleset will fail silently instead of loudly as here - in other words, an Inquisitor that is only sometimes an Inquisitor will be treated by automation as never being an Inquisitor. Probably, depends on the specific unique, it could also decide "If I'm in an Alpha Centauri orbit, then <in [Forest] tiles> must be true, as I don't see any trees, as the saying goes."

SeventhM commented 1 year ago

Crash starts in mapUnitCache.updateUniques during getMapUnit. Therefore, regardless of if the unique that is being checked would return false or not is irrelevant. The fake unit isn't spawning in the first place

Sure, we can have concerns regarding the AI not recognizing unit roles due to blocking conditionals. But even if that was the case, you would still need to address 10425 first in some way, or else we can't even reach a point of the AI checking the unit role

yairm210 commented 1 year ago

Wow, a Crocodile Dundee "this is a knife" reference! I am getting more and more convinced that you're actually my father in an alternate universe, your reference bag is almost entirely equivalent

And... To answer your question, yes, I independently came up with the #10425 solution before I saw your comment, so I think that despite how ugly it looks it's the way to go. If anyone has a better solution to replace it later, fantastic, if not, let's at least fix the bug

SomeTroglodyte commented 1 year ago

convinced

I would probably be honored...

SomeTroglodyte commented 1 year ago

reference bag

The other one is from 1999, thus 13 years younger :roll_eyes:

yairm210 commented 1 year ago

That solves the "bug" part. However, the point remains that the "tile entering" uniques are all cached into booleans in UpdateUniques, which means that conditionals placed upon them may not work. Sounds like yet another mod checker addition

SomeTroglodyte commented 1 year ago

cached

We already have exception detection somewhere, some flag that knows when mods make it un-cacheable...??? Hmmm... Not quite, only noTerrainMovementUniques and its two siblings - could be a tad too simple for all the mad modders...