mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-13 12:27:40 +07:00
Resolved edge case crash when conquering the capital of a civ that has a unique capital city indicator
This commit is contained in:
parent
5d160508d3
commit
15cbf8359f
@ -230,10 +230,21 @@ class CityInfoConquestFunctions(val city: CityInfo){
|
||||
fun moveToCiv(newCivInfo: CivilizationInfo) {
|
||||
city.apply {
|
||||
val oldCiv = civInfo
|
||||
|
||||
|
||||
// Remove/relocate palace for old Civ - need to do this BEFORE we move the cities between
|
||||
// civs so the capitalCityIndicator recognizes the unique buildings of the conquered civ
|
||||
val capitalCityIndicator = capitalCityIndicator()
|
||||
if (cityConstructions.isBuilt(capitalCityIndicator)) {
|
||||
cityConstructions.removeBuilding(capitalCityIndicator)
|
||||
val firstOtherCity = oldCiv.cities.firstOrNull { it != this }
|
||||
if (firstOtherCity != null)
|
||||
firstOtherCity.cityConstructions.addBuilding(capitalCityIndicator) // relocate palace
|
||||
}
|
||||
|
||||
civInfo.cities = civInfo.cities.toMutableList().apply { remove(city) }
|
||||
newCivInfo.cities = newCivInfo.cities.toMutableList().apply { add(city) }
|
||||
civInfo = newCivInfo
|
||||
if (isOriginalCapital) civInfo.hasEverOwnedOriginalCapital = true
|
||||
hasJustBeenConquered = false
|
||||
turnAcquired = civInfo.gameInfo.turns
|
||||
previousOwner = oldCiv.civName
|
||||
@ -244,14 +255,6 @@ class CityInfoConquestFunctions(val city: CityInfo){
|
||||
population.autoAssignPopulation()
|
||||
}
|
||||
|
||||
// Remove/relocate palace for old Civ
|
||||
val capitalCityIndicator = capitalCityIndicator()
|
||||
if (cityConstructions.isBuilt(capitalCityIndicator)) {
|
||||
cityConstructions.removeBuilding(capitalCityIndicator)
|
||||
if (oldCiv.cities.isNotEmpty()) {
|
||||
oldCiv.cities.first().cityConstructions.addBuilding(capitalCityIndicator) // relocate palace
|
||||
}
|
||||
}
|
||||
|
||||
// Remove their free buildings from this city and remove free buildings provided by the city from their cities
|
||||
removeBuildingsOnMoveToCiv(oldCiv)
|
||||
|
@ -166,6 +166,7 @@ class CivilizationInfo {
|
||||
// To correctly determine "game over" condition as clarified in #4707
|
||||
// Nullable type meant to be deprecated and converted to non-nullable,
|
||||
// default false once we no longer want legacy save-game compatibility
|
||||
// This parameter means they owned THEIR OWN capital btw, not other civs'.
|
||||
var hasEverOwnedOriginalCapital: Boolean? = null
|
||||
|
||||
val passableImpassables = HashSet<String>() // For Carthage-like uniques
|
||||
@ -676,7 +677,7 @@ class CivilizationInfo {
|
||||
* */
|
||||
fun setNationTransient() {
|
||||
nation = gameInfo.ruleSet.nations[civName]
|
||||
?: throw java.lang.Exception("Nation $civName is not found!")
|
||||
?: throw UncivShowableException("Nation $civName is not found!")
|
||||
}
|
||||
|
||||
fun setTransients() {
|
||||
|
Loading…
Reference in New Issue
Block a user