Resolved crash when returning to empire overview and a category is missing

This commit is contained in:
Yair Morgenstern 2023-12-13 22:55:36 +02:00
parent 62469daff6
commit 626973bfb7
2 changed files with 2 additions and 2 deletions

View File

@ -116,7 +116,7 @@ class EmpireOverviewScreen(
// This is called by UncivGame.popScreen - e.g. after City Tab opened a City and the user closes that CityScreen...
// Notify the current tab via its IPageExtensions.activated entry point so it can refresh if needed
val index = tabbedPager.activePage
val category = EmpireOverviewCategories.values()[index - 1]
val category = EmpireOverviewCategories.values().getOrNull(index - 1) ?: return
pageObjects[category]?.activated(index, "", tabbedPager) // Fake caption marks this as popScreen-triggered
}
}

View File

@ -24,7 +24,7 @@ object UnitActions {
/** Returns whether the action was invoked */
fun invokeUnitAction(unit: MapUnit, unitActionType: UnitActionType): Boolean {
val unitAction = if (unitActionType in actionTypeToFunctions) actionTypeToFunctions[unitActionType]!!.invoke(unit, unit.getTile())
.firstOrNull{ it.action != null }
.firstOrNull { it.action != null }
else getNormalActions(unit).firstOrNull { it.type == unitActionType && it.action != null }
?: getAdditionalActions(unit).firstOrNull { it.type == unitActionType && it.action != null }
val internalAction = unitAction?.action ?: return false