From 94e9098ac050b9f37c65196b53ca29708fb28a54 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 27 Aug 2018 12:32:07 +0300 Subject: [PATCH] Solved a conccurrency problem in getHappiness --- core/src/com/unciv/logic/city/CityStats.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 5a196568..9fef0229 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -101,11 +101,12 @@ class CityStats { // -3 happiness per city fun getCityHappiness(): LinkedHashMap { val civInfo = cityInfo.civInfo + val newHappinessList = LinkedHashMap() var unhappinessModifier = civInfo.getDifficulty().unhappinessModifier if(!civInfo.isPlayerCivilization()) unhappinessModifier *= civInfo.gameInfo.getPlayerCivilization().getDifficulty().aiUnhappinessModifier - happinessList["Cities"] = -3f * unhappinessModifier + newHappinessList ["Cities"] = -3f * unhappinessModifier var unhappinessFromCitizens = cityInfo.population.population.toFloat() if (civInfo.policies.isAdopted("Democracy")) @@ -115,7 +116,7 @@ class CityStats { if (civInfo.policies.isAdopted("Meritocracy")) unhappinessFromCitizens *= 0.95f - happinessList["Population"] = -unhappinessFromCitizens * unhappinessModifier + newHappinessList ["Population"] = -unhappinessFromCitizens * unhappinessModifier var happinessFromPolicies = 0f if (civInfo.policies.isAdopted("Aristocracy")) @@ -125,12 +126,13 @@ class CityStats { if (civInfo.policies.isAdopted("Meritocracy") && isConnectedToCapital(RoadStatus.Road)) happinessFromPolicies += 1f - happinessList["Policies"] = happinessFromPolicies + newHappinessList ["Policies"] = happinessFromPolicies val happinessFromBuildings = cityInfo.cityConstructions.getStats().happiness.toInt().toFloat() - happinessList["Buildings"] = happinessFromBuildings + newHappinessList ["Buildings"] = happinessFromBuildings - return happinessList + happinessList=newHappinessList + return newHappinessList } private fun getStatsFromSpecialists(specialists: Stats, policies: HashSet): Stats {