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
This commit is contained in:
SomeTroglodyte 2023-11-30 18:35:18 +01:00 committed by GitHub
parent 70bbfe14d6
commit 30f3a8f712
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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))
}
}