diff --git a/core/src/com/unciv/UncivGame.kt b/core/src/com/unciv/UncivGame.kt index e4c754bc08..a1449b6793 100644 --- a/core/src/com/unciv/UncivGame.kt +++ b/core/src/com/unciv/UncivGame.kt @@ -124,6 +124,8 @@ class UncivGame(parameters: UncivGameParameters) : Game() { fun loadGame(gameInfo: GameInfo) { this.gameInfo = gameInfo ImageGetter.ruleset = gameInfo.ruleSet + Gdx.input.inputProcessor = null // Since we will set the world screen when we're ready, + // This is to avoid ANRs when loading. ImageGetter.refreshAtlas() worldScreen = WorldScreen(gameInfo.getPlayerToViewAs()) setWorldScreen() diff --git a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt index 36ec993057..d6a0635aad 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt @@ -237,19 +237,24 @@ class DiplomacyManager() { //endregion //region state-changing functions - fun removeUntenebleTrades(){ - val negativeCivResources = civInfo.getCivResources() - .filter { it.amount<0 }.map { it.resource.name } + fun removeUntenebleTrades() { + + for (trade in trades.toList()) { + + // Every cancelled trade can change this - if 1 resource is missing, + // don't cancel all trades of that resource, only cancel one (the first one, as it happens, since they're added chronologically) + val negativeCivResources = civInfo.getCivResources() + .filter { it.amount < 0 }.map { it.resource.name } - for(trade in trades.toList()) { for (offer in trade.ourOffers) { if (offer.type in listOf(TradeType.Luxury_Resource, TradeType.Strategic_Resource) - && offer.name in negativeCivResources){ + && offer.name in negativeCivResources) { trades.remove(trade) val otherCivTrades = otherCiv().getDiplomacyManager(civInfo).trades - otherCivTrades.removeAll{ it.equals(trade.reverse()) } - civInfo.addNotification("One of our trades with [$otherCivName] has been cut short",null, Color.GOLD) - otherCiv().addNotification("One of our trades with [${civInfo.civName}] has been cut short",null, Color.GOLD) + otherCivTrades.removeAll { it.equals(trade.reverse()) } + civInfo.addNotification("One of our trades with [$otherCivName] has been cut short", null, Color.GOLD) + otherCiv().addNotification("One of our trades with [${civInfo.civName}] has been cut short", null, Color.GOLD) + civInfo.updateDetailedCivResources() } } }