From fd207d55c646bb2cc1511faec22d98de3c533441 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sat, 6 Mar 2021 22:30:29 +0200 Subject: [PATCH] Game can handle resources "disappearing" between versions (esp. for mods) --- buildSrc/src/main/kotlin/BuildConfig.kt | 4 ++-- core/src/com/unciv/logic/GameInfo.kt | 1 + .../unciv/logic/civilization/diplomacy/DiplomacyManager.kt | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/kotlin/BuildConfig.kt b/buildSrc/src/main/kotlin/BuildConfig.kt index 4dddd2ed12..796146f162 100644 --- a/buildSrc/src/main/kotlin/BuildConfig.kt +++ b/buildSrc/src/main/kotlin/BuildConfig.kt @@ -3,8 +3,8 @@ package com.unciv.build object BuildConfig { const val kotlinVersion = "1.4.30" const val appName = "Unciv" - const val appCodeNumber = 539 - const val appVersion = "3.13.5-patch1" + const val appCodeNumber = 540 + const val appVersion = "3.13.5-patch2" const val gdxVersion = "1.9.14" const val roboVMVersion = "2.3.1" diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index 11466e5153..5e5d3080df 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -292,6 +292,7 @@ class GameInfo { civInfo.policies.adoptedPolicies.remove("Facism") civInfo.policies.adoptedPolicies.add("Fascism") } + } diff --git a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt index 436bcc7170..6c997d19ac 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt @@ -253,7 +253,8 @@ class DiplomacyManager() { fun resourcesFromTrade(): ResourceSupplyList { val counter = ResourceSupplyList() val resourcesMap = civInfo.gameInfo.ruleSet.tileResources - val isResourceFilter: (TradeOffer) -> Boolean = { it.type == TradeType.Strategic_Resource || it.type == TradeType.Luxury_Resource } + val isResourceFilter: (TradeOffer) -> Boolean = { (it.type == TradeType.Strategic_Resource || it.type == TradeType.Luxury_Resource) + && civInfo.gameInfo.ruleSet.tileResources.containsKey(it.name) } for (trade in trades) { for (offer in trade.ourOffers.filter(isResourceFilter)) counter.add(resourcesMap[offer.name]!!, -offer.amount, "Trade") @@ -294,7 +295,7 @@ class DiplomacyManager() { for (offer in trade.ourOffers) { if (offer.type in listOf(TradeType.Luxury_Resource, TradeType.Strategic_Resource) - && offer.name in negativeCivResources) { + && (offer.name in negativeCivResources || !civInfo.gameInfo.ruleSet.tileResources.containsKey(offer.name))) { trades.remove(trade) val otherCivTrades = otherCiv().getDiplomacyManager(civInfo).trades otherCivTrades.removeAll { it.equals(trade.reverse()) }