Resolve #11795 - fix performance problem for displaying air units in cities

This commit is contained in:
Yair Morgenstern 2024-06-24 23:53:36 +03:00
parent 0678957c8e
commit 39de50829a
3 changed files with 8 additions and 5 deletions

View File

@ -75,7 +75,7 @@ class RoadBetweenCitiesAutomation(val civInfo: Civilization, cachedForTurn: Int,
/**
* Tries to return a list of road plans to connect this city to the surrounding cities.
* If there are no surrounding cities to connect to and this city is still unconnected to the capital it will try and build a special road to the capital.
*
*
* @return every road that we want to try and connect assosiated with this city.
*/
fun getRoadsToBuildFromCity(city: City): List<RoadPlan> {
@ -144,7 +144,7 @@ class RoadBetweenCitiesAutomation(val civInfo: Civilization, cachedForTurn: Int,
if (roadToCapital != null) {
val worstRoadStatus = getWorstRoadTypeInPath(roadToCapital.second)
var roadPriority = basePriority
roadPriority += if (worstRoadStatus == RoadStatus.None) 2f else 1f
roadPriority += if (worstRoadStatus == RoadStatus.None) 2f else 1f
val newRoadPlan = RoadPlan(roadToCapital.second, roadPriority + (city.population.population) / 2f, city, roadToCapital.first)
roadsToBuild.add(newRoadPlan)
@ -155,7 +155,6 @@ class RoadBetweenCitiesAutomation(val civInfo: Civilization, cachedForTurn: Int,
}
}
workerUnit.destroy()
roadsToBuildByCitiesCache[city] = roadsToBuild
return roadsToBuild
}

View File

@ -13,11 +13,11 @@ import com.unciv.models.ruleset.RejectionReason
import com.unciv.models.ruleset.RejectionReasonType
import com.unciv.models.ruleset.Ruleset
import com.unciv.models.ruleset.RulesetObject
import com.unciv.models.ruleset.unique.Conditionals
import com.unciv.models.ruleset.unique.StateForConditionals
import com.unciv.models.ruleset.unique.Unique
import com.unciv.models.ruleset.unique.UniqueTarget
import com.unciv.models.ruleset.unique.UniqueType
import com.unciv.models.ruleset.unique.Conditionals
import com.unciv.models.stats.Stat
import com.unciv.ui.components.extensions.getNeedMoreAmountString
import com.unciv.ui.components.extensions.toPercent
@ -194,11 +194,11 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
// Expensive, since adding and removing the fake unit causes side-effects
if (isAirUnit()) {
// Not actually added to civ so doesn't require destroy
val fakeUnit = getMapUnit(cityConstructions.city.civ, Constants.NO_ID)
val canUnitEnterTile = fakeUnit.movement.canMoveTo(cityConstructions.city.getCenterTile())
if (!canUnitEnterTile)
yield(RejectionReasonType.NoPlaceToPutUnit.toInstance())
fakeUnit.destroy()
}
}

View File

@ -1927,6 +1927,7 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Modifiers that can be added to other uniques to limit when they will be active
??? example "&lt;for [amount] turns&gt;"
Turns this unique into a trigger, activating this unique as a *global* unique for a number of turns
Example: "&lt;for [3] turns&gt;"
Applicable to: Conditional
@ -2113,18 +2114,21 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Applicable to: Conditional
??? example "&lt;when above [amount] [stat/resource]&gt;"
Stats refers to the accumulated stat, not stat-per-turn
Example: "&lt;when above [3] [Culture]&gt;"
This unique's effect can be modified with &lt;(modified by game speed)&gt;
Applicable to: Conditional
??? example "&lt;when below [amount] [stat/resource]&gt;"
Stats refers to the accumulated stat, not stat-per-turn
Example: "&lt;when below [3] [Culture]&gt;"
This unique's effect can be modified with &lt;(modified by game speed)&gt;
Applicable to: Conditional
??? example "&lt;when between [amount] and [amount] [stat/resource]&gt;"
Stats refers to the accumulated stat, not stat-per-turn
Example: "&lt;when between [3] and [3] [Culture]&gt;"
This unique's effect can be modified with &lt;(modified by game speed)&gt;