mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-13 17:28:57 +07:00
Quick win for #7491 - only update resources after trade/unit if resources are relevant
This commit is contained in:
@ -483,7 +483,7 @@ class CivilizationInfo : IsPartOfGameInfoSerialization {
|
|||||||
// exception will happen), also rearrange existing units so that
|
// exception will happen), also rearrange existing units so that
|
||||||
// 'nextPotentiallyDueAt' becomes 0. This way new units are always last to be due
|
// 'nextPotentiallyDueAt' becomes 0. This way new units are always last to be due
|
||||||
// (can be changed as wanted, just have a predictable place).
|
// (can be changed as wanted, just have a predictable place).
|
||||||
var newList = getCivUnitsStartingAtNextDue().toMutableList()
|
val newList = getCivUnitsStartingAtNextDue().toMutableList()
|
||||||
newList.add(mapUnit)
|
newList.add(mapUnit)
|
||||||
units = newList
|
units = newList
|
||||||
nextPotentiallyDueAt = 0
|
nextPotentiallyDueAt = 0
|
||||||
@ -492,19 +492,21 @@ class CivilizationInfo : IsPartOfGameInfoSerialization {
|
|||||||
// Not relevant when updating TileInfo transients, since some info of the civ itself isn't yet available,
|
// Not relevant when updating TileInfo transients, since some info of the civ itself isn't yet available,
|
||||||
// and in any case it'll be updated once civ info transients are
|
// and in any case it'll be updated once civ info transients are
|
||||||
updateStatsForNextTurn() // unit upkeep
|
updateStatsForNextTurn() // unit upkeep
|
||||||
updateDetailedCivResources()
|
if (mapUnit.baseUnit.getResourceRequirements().isNotEmpty())
|
||||||
|
updateDetailedCivResources()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun removeUnit(mapUnit: MapUnit) {
|
fun removeUnit(mapUnit: MapUnit) {
|
||||||
// See comment in addUnit().
|
// See comment in addUnit().
|
||||||
var newList = getCivUnitsStartingAtNextDue().toMutableList()
|
val newList = getCivUnitsStartingAtNextDue().toMutableList()
|
||||||
newList.remove(mapUnit)
|
newList.remove(mapUnit)
|
||||||
units = newList
|
units = newList
|
||||||
nextPotentiallyDueAt = 0
|
nextPotentiallyDueAt = 0
|
||||||
|
|
||||||
updateStatsForNextTurn() // unit upkeep
|
updateStatsForNextTurn() // unit upkeep
|
||||||
updateDetailedCivResources()
|
if (mapUnit.baseUnit.getResourceRequirements().isNotEmpty())
|
||||||
|
updateDetailedCivResources()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getIdleUnits() = getCivUnits().filter { it.isIdle() }
|
fun getIdleUnits() = getCivUnits().filter { it.isIdle() }
|
||||||
|
@ -580,7 +580,9 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
|
|||||||
else civInfo.addNotification("[${offer.name}] to [$otherCivName] has ended", otherCivName, NotificationIcon.Trade)
|
else civInfo.addNotification("[${offer.name}] to [$otherCivName] has ended", otherCivName, NotificationIcon.Trade)
|
||||||
|
|
||||||
civInfo.updateStatsForNextTurn() // if they were bringing us gold per turn
|
civInfo.updateStatsForNextTurn() // if they were bringing us gold per turn
|
||||||
civInfo.updateDetailedCivResources() // if they were giving us resources
|
if (trade.theirOffers.union(trade.ourOffers) // if resources were involved
|
||||||
|
.any { it.type == TradeType.Luxury_Resource || it.type == TradeType.Strategic_Resource })
|
||||||
|
civInfo.updateDetailedCivResources()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user