Game can handle resources "disappearing" between versions (esp. for mods)

This commit is contained in:
Yair Morgenstern 2021-03-06 22:30:29 +02:00
parent ee05bc28ec
commit fd207d55c6
3 changed files with 6 additions and 4 deletions

View File

@ -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"

View File

@ -292,6 +292,7 @@ class GameInfo {
civInfo.policies.adoptedPolicies.remove("Facism")
civInfo.policies.adoptedPolicies.add("Fascism")
}
}

View File

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