From a54f68528f4b64e5a7913d1c5858828e51a6a661 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 20 May 2019 19:48:18 +0300 Subject: [PATCH] Resolved #782 - Wonders are no longer built twice under "race conditions" --- android/build.gradle | 2 +- core/src/com/unciv/logic/city/CityConstructions.kt | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 5558c58409..bb4a227188 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,7 +21,7 @@ android { applicationId "com.unciv.app" minSdkVersion 14 targetSdkVersion 28 - versionCode 243 + versionCode 244 versionName "2.16.7" } diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index 7545b9d7cf..4026880234 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -143,6 +143,8 @@ class CityConstructions { } fun constructIfEnough(){ + stopUnbuildableConstruction() + val construction = getConstruction(currentConstruction) if(construction is SpecialConstruction) return @@ -154,10 +156,16 @@ class CityConstructions { } fun endTurn(cityStats: Stats) { - val construction = getConstruction(currentConstruction) - if(construction is SpecialConstruction) return + stopUnbuildableConstruction() + if(getConstruction(currentConstruction) !is SpecialConstruction) + addProductionPoints(Math.round(cityStats.production)) + } + + private fun stopUnbuildableConstruction() { // Let's try to remove the building from the city, and see if we can still build it (we need to remove because of wonders etc.) + val construction = getConstruction(currentConstruction) + val saveCurrentConstruction = currentConstruction currentConstruction = "" if (!construction.isBuildable(this)) { @@ -166,8 +174,6 @@ class CityConstructions { chooseNextConstruction() } else currentConstruction = saveCurrentConstruction - - addProductionPoints(Math.round(cityStats.production)) } fun constructionComplete(construction: IConstruction) {