From 33f73f5aaecdc28330b48873eba8657fcc152733 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:12:47 +0200 Subject: [PATCH] Thwart the nathty dithband thpammer (#11790) --- core/src/com/unciv/logic/map/mapunit/MapUnit.kt | 3 +++ .../ui/screens/worldscreen/unit/actions/UnitActionsTable.kt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/map/mapunit/MapUnit.kt b/core/src/com/unciv/logic/map/mapunit/MapUnit.kt index 0d62caf178..803d4d4642 100644 --- a/core/src/com/unciv/logic/map/mapunit/MapUnit.kt +++ b/core/src/com/unciv/logic/map/mapunit/MapUnit.kt @@ -933,6 +933,9 @@ class MapUnit : IsPartOfGameInfoSerialization { } fun disband() { + // Safeguard against running on already destroyed instances + if (isDestroyed) return + // evacuation of transported units before disbanding, if possible. toListed because we're modifying the unit list. for (unit in currentTile.getUnits() .filter { it.isTransported && isTransportTypeOf(it) } diff --git a/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionsTable.kt b/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionsTable.kt index de715d2ceb..f4fd47f475 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionsTable.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionsTable.kt @@ -60,6 +60,7 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table() { } clear() + keyShortcuts.clear() if (unit == null) return if (!worldScreen.canChangeState) return // No actions when it's not your turn or spectator! @@ -127,7 +128,6 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table() { pack() // Bind all currently invisible actions to their keys - keyShortcuts.clear() for (page in pageActionBuckets.indices) { if (page == currentPage) continue // these are already done for (unitAction in pageActionBuckets[page]) {