From 4d43b8d226fe23902fc12cfc4f0affade738a058 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 8 Jul 2018 18:40:26 +0300 Subject: [PATCH] Fixed bug where if you discovered and enemy and traded ith him and your trade finished without leaving and reentering the game, the game would crash (but would be okay on reload) --- .../unciv/logic/civilization/CivilizationInfo.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 088b914e..07d4d3eb 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -253,8 +253,8 @@ class CivilizationInfo { for(otherCiv in viewedCivs) if(!diplomacy.containsKey(otherCiv.civName)){ - diplomacy[otherCiv.civName] = DiplomacyManager().apply { otherCivName=otherCiv.civName } - otherCiv.diplomacy[civName] = DiplomacyManager().apply { otherCivName=civName } + diplomacy[otherCiv.civName] = DiplomacyManager(this@CivilizationInfo,otherCiv.civName) + otherCiv.diplomacy[civName] = DiplomacyManager(otherCiv,civName) addNotification("We have encountered ["+otherCiv.civName+"]!".tr(),null, Color.GOLD) } @@ -270,7 +270,6 @@ class CivilizationInfo { fun isDefeated()= cities.isEmpty() && !getCivUnits().any{it.name=="Settler"} fun getEra(): TechEra { - val maxEraOfTech = tech.techsResearched.map { GameBasics.Technologies[it]!! } .map { it.era() } .max() @@ -284,9 +283,14 @@ enum class DiplomaticStatus{ War } -class DiplomacyManager { +class DiplomacyManager() { @Transient lateinit var civInfo:CivilizationInfo lateinit var otherCivName:String + + constructor(civilizationInfo: CivilizationInfo, OtherCivName:String) : this() { + civInfo=civilizationInfo + otherCivName=OtherCivName + } // var status:DiplomaticStatus = DiplomaticStatus.War var trades = ArrayList() @@ -315,7 +319,7 @@ class DiplomacyManager { } } - fun otherCiv() = civInfo.gameInfo.civilizations.first{it.civName==otherCivName} + //fun otherCiv() = civInfo.gameInfo.civilizations.first{it.civName==otherCivName} // fun declareWar(){ // status = DiplomaticStatus.War // otherCiv().diplomacy[civInfo.civName]!!.status = DiplomaticStatus.War