Fix free buildings from other buildings not showing up correctly (#9857)

* Rearrange order of actions when adding buildings

* Turns out you need to updateCivResources after adding in uniques. Whoops

* Mirror change to remove buildings as well
This commit is contained in:
SeventhM 2023-07-30 07:37:24 -07:00 committed by GitHub
parent 488ec9f82f
commit 283edd0875
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -494,12 +494,11 @@ class CityConstructions : IsPartOfGameInfoSerialization {
builtBuildings.add(buildingName)
city.civ.cache.updateCitiesConnectedToCapital(false) // could be a connecting building, like a harbor
city.civ.cache.updateCivResources() // this building could be a resource-requiring one
/** Support for [UniqueType.CreatesOneImprovement] */
applyCreateOneImprovement(building)
addFreeBuildings()
triggerNewBuildingUniques(building)
@ -514,7 +513,9 @@ class CityConstructions : IsPartOfGameInfoSerialization {
UniqueType.StatsFromTiles, UniqueType.StatsFromTilesWithout, UniqueType.StatsFromObject,
UniqueType.StatPercentFromObject, UniqueType.AllStatsPercentFromObject
)
updateUniques()
// Happiness is global, so it could affect all cities
if(building.isStatRelated(Stat.Happiness)) {
for (city in civ.cities) {
@ -524,7 +525,9 @@ class CityConstructions : IsPartOfGameInfoSerialization {
else if(uniqueTypesModifyingYields.any { building.hasUnique(it) })
city.reassignPopulationDeferred()
updateUniques()
city.civ.cache.updateCivResources() // this building could be a resource-requiring one
addFreeBuildings()
}
fun triggerNewBuildingUniques(building: Building) {
@ -534,9 +537,9 @@ class CityConstructions : IsPartOfGameInfoSerialization {
if (!unique.hasTriggerConditional())
UniqueTriggerActivation.triggerCivwideUnique(unique, city.civ, city, triggerNotificationText = triggerNotificationText)
for (unique in city.civ.getTriggeredUniques(UniqueType.TriggerUponConstructingBuilding, StateForConditionals(city.civ, city)))
if (unique.conditionals.any {it.type == UniqueType.TriggerUponConstructingBuilding && building.matchesFilter(it.params[0])})
UniqueTriggerActivation.triggerCivwideUnique(unique, city.civ, city, triggerNotificationText = triggerNotificationText)
for (unique in city.civ.getTriggeredUniques(UniqueType.TriggerUponConstructingBuilding, StateForConditionals(city.civ, city)))
if (unique.conditionals.any {it.type == UniqueType.TriggerUponConstructingBuilding && building.matchesFilter(it.params[0])})
UniqueTriggerActivation.triggerCivwideUnique(unique, city.civ, city, triggerNotificationText = triggerNotificationText)
for (unique in city.civ.getTriggeredUniques(UniqueType.TriggerUponConstructingBuildingCityFilter, StateForConditionals(city.civ, city)))
if (unique.conditionals.any {it.type == UniqueType.TriggerUponConstructingBuildingCityFilter
@ -552,8 +555,8 @@ class CityConstructions : IsPartOfGameInfoSerialization {
else builtBuildingObjects.removeAll{ it.name == buildingName }
builtBuildings.remove(buildingName)
city.civ.cache.updateCitiesConnectedToCapital(false) // could be a connecting building, like a harbor
city.civ.cache.updateCivResources() // this building could be a resource-requiring one
updateUniques()
city.civ.cache.updateCivResources() // this building could be a resource-requiring one
}
fun updateUniques(onLoadGame:Boolean = false) {