mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-05 15:59:50 +07:00
Resolved #6179 - when changing units production due to deprecation, notification no longer counts the same city multiple times if it appears multiple times in its queue
This commit is contained in:
@ -280,7 +280,7 @@ class TechManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val obsoleteUnits = getRuleset().units.values.filter { it.obsoleteTech == techName }.map { it.name }
|
val obsoleteUnits = getRuleset().units.values.filter { it.obsoleteTech == techName }.map { it.name }
|
||||||
val unitUpgrades = HashMap<String, ArrayList<CityInfo>>()
|
val unitUpgrades = HashMap<String, HashSet<CityInfo>>()
|
||||||
for (city in civInfo.cities) {
|
for (city in civInfo.cities) {
|
||||||
// Do not use replaceAll - that's a Java 8 feature and will fail on older phones!
|
// Do not use replaceAll - that's a Java 8 feature and will fail on older phones!
|
||||||
val oldQueue = city.cityConstructions.constructionQueue.toList() // copy, since we're changing the queue
|
val oldQueue = city.cityConstructions.constructionQueue.toList() // copy, since we're changing the queue
|
||||||
@ -288,7 +288,7 @@ class TechManager {
|
|||||||
for (constructionName in oldQueue) {
|
for (constructionName in oldQueue) {
|
||||||
if (constructionName in obsoleteUnits) {
|
if (constructionName in obsoleteUnits) {
|
||||||
if (constructionName !in unitUpgrades.keys) {
|
if (constructionName !in unitUpgrades.keys) {
|
||||||
unitUpgrades[constructionName] = ArrayList<CityInfo>()
|
unitUpgrades[constructionName] = hashSetOf()
|
||||||
}
|
}
|
||||||
unitUpgrades[constructionName]?.add(city)
|
unitUpgrades[constructionName]?.add(city)
|
||||||
val construction = city.cityConstructions.getConstruction(constructionName)
|
val construction = city.cityConstructions.getConstruction(constructionName)
|
||||||
@ -301,9 +301,9 @@ class TechManager {
|
|||||||
|
|
||||||
// Add notifications for obsolete units/constructions
|
// Add notifications for obsolete units/constructions
|
||||||
for ((unit, cities) in unitUpgrades) {
|
for ((unit, cities) in unitUpgrades) {
|
||||||
val construction = cities[0].cityConstructions.getConstruction(unit)
|
val construction = cities.first().cityConstructions.getConstruction(unit)
|
||||||
if (cities.size == 1) {
|
if (cities.size == 1) {
|
||||||
val city = cities[0]
|
val city = cities.first()
|
||||||
if (construction is BaseUnit && construction.upgradesTo != null) {
|
if (construction is BaseUnit && construction.upgradesTo != null) {
|
||||||
val text = "[${city.name}] changed production from [$unit] to [${construction.upgradesTo!!}]"
|
val text = "[${city.name}] changed production from [$unit] to [${construction.upgradesTo!!}]"
|
||||||
civInfo.addNotification(text, city.location, unit, NotificationIcon.Construction, construction.upgradesTo!!)
|
civInfo.addNotification(text, city.location, unit, NotificationIcon.Construction, construction.upgradesTo!!)
|
||||||
|
Reference in New Issue
Block a user