From 30f3a8f712491a3d00f90b8fb9d469334dc4a218 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Thu, 30 Nov 2023 18:35:18 +0100 Subject: [PATCH] Fix crash for trade notifications as Spectator or during waiting for player (#10614) * Fix crash when tapping a Diplomacy notification for trades as Spectator or during waiting for player * Fix no tech showing as researched when tapping a Tech researched notification as Spectator --- .../com/unciv/logic/civilization/NotificationActions.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/NotificationActions.kt b/core/src/com/unciv/logic/civilization/NotificationActions.kt index b89a61c986..793262ba2a 100644 --- a/core/src/com/unciv/logic/civilization/NotificationActions.kt +++ b/core/src/com/unciv/logic/civilization/NotificationActions.kt @@ -59,7 +59,7 @@ class LocationAction(internal val location: Vector2 = Vector2.Zero) : Notificati class TechAction(private val techName: String = "") : NotificationAction { override fun execute(worldScreen: WorldScreen) { val tech = worldScreen.gameInfo.ruleset.technologies[techName] - worldScreen.game.pushScreen(TechPickerScreen(worldScreen.viewingCiv, tech)) + worldScreen.game.pushScreen(TechPickerScreen(worldScreen.selectedCiv, tech)) } } @@ -83,7 +83,11 @@ class DiplomacyAction( ) : NotificationAction { override fun execute(worldScreen: WorldScreen) { val otherCiv = worldScreen.gameInfo.getCivilization(otherCivName) - worldScreen.game.pushScreen(DiplomacyScreen(worldScreen.viewingCiv, otherCiv, showTrade = showTrade)) + if (showTrade && otherCiv == worldScreen.gameInfo.getCurrentPlayerCivilization()) + // Because TradeTable will set up otherCiv against that one, + // not the one we pass below, and two equal civs will crash - can't look up a DiplomacyManager. + return + worldScreen.game.pushScreen(DiplomacyScreen(worldScreen.selectedCiv, otherCiv, showTrade = showTrade)) } }