mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 20:31:51 -04:00
Fix crash when a starting unit has a random conditional (#11596)
* Harden StateForConditionals.hashCode against uninitialized lateinit * Fix potential crash in new game screen (leftover debug assert)
This commit is contained in:
parent
428edfb12a
commit
5238ff23e1
@ -48,8 +48,10 @@ data class StateForConditionals(
|
||||
fun Civilization?.hash() = this?.civName?.hashCode() ?: 0
|
||||
fun City?.hash() = this?.id?.hashCode() ?: 0
|
||||
fun Tile?.hash() = this?.position?.hashCode() ?: 0
|
||||
fun MapUnit?.hash() = (this?.name?.hashCode() ?: 0) + 17 * this?.currentTile.hash()
|
||||
fun ICombatant?.hash() = (this?.getName()?.hashCode() ?: 0) + 17 * this?.getTile().hash()
|
||||
fun MapUnit?.hash() = if (this == null) 0 else name.hashCode() + (if (hasTile()) 17 * currentTile.hash() else 0)
|
||||
fun ICombatant?.hash() = if (this == null) 0
|
||||
else if (this is MapUnitCombatant) unit.hash() // line only serves as `lateinit currentTile not initialized` guard
|
||||
else getName().hashCode() + 17 * getTile().hash()
|
||||
fun CombatAction?.hash() = this?.name?.hashCode() ?: 0
|
||||
fun Region?.hash() = this?.rect?.hashCode() ?: 0
|
||||
|
||||
|
@ -212,7 +212,7 @@ class ModCheckboxTable(
|
||||
private fun disableIncompatibleMods() {
|
||||
for (modWidget in modWidgets) {
|
||||
val enable = ModCompatibility.meetsAllRequirements(modWidget.mod, baseRuleset, getSelectedMods())
|
||||
assert(enable || !modWidget.widget.isChecked) { "Mod compatibility conflict: Trying to disable ${modWidget.mod.name} while it is selected" }
|
||||
if (!enable && modWidget.widget.isChecked) modWidget.widget.isChecked = false // mod widgets can't, but selecting a map can cause this situation
|
||||
modWidget.widget.isDisabled = !enable // isEnabled is only for TextButtons
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user