diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index 330ed3386a..a1120c9f4d 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -386,7 +386,7 @@ class CityConstructions : IsPartOfGameInfoSerialization { chooseNextConstruction() } - private fun validateInProgressConstructions() { + fun validateInProgressConstructions() { // remove obsolete stuff from in progress constructions - happens often and leaves clutter in memory and save files // should have little visible consequences - any accumulated points that may be reused later should stay (nukes when manhattan project city lost, nat wonder when conquered an empty city...), all other points should be refunded // Should at least be called before each turn - if another civ completes a wonder after our previous turn, we should get the refund this turn diff --git a/core/src/com/unciv/logic/civilization/managers/TechManager.kt b/core/src/com/unciv/logic/civilization/managers/TechManager.kt index 46d4936600..273d819cd7 100644 --- a/core/src/com/unciv/logic/civilization/managers/TechManager.kt +++ b/core/src/com/unciv/logic/civilization/managers/TechManager.kt @@ -369,12 +369,17 @@ class TechManager : IsPartOfGameInfoSerialization { .toMutableList() } - // As long as TurnManager does cities after tech, we don't need to clean up - // inProgressConstructions - CityConstructions.validateInProgressConstructions does it. - // Add notifications for obsolete units/constructions for ((unit, cities) in unitUpgrades) { if (cities.isEmpty()) continue + + //The validation check happens again while processing start and end of turn, + //but for mid-turn free tech picks like Oxford University, it should happen immediately + //so the hammers from the obsolete unit are guaranteed to go to the upgraded unit + //and players don't think they lost all their production mid turn + for(city in cities) + city.cityConstructions.validateInProgressConstructions() + val locationAction = LocationAction(cities.asSequence().map { it.location }) val cityText = if (cities.size == 1) "[${cities.first().name}]" else "[${cities.size}] cities"