mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-15 02:09:21 +07:00
perf
This commit is contained in:
@ -237,7 +237,8 @@ class CityReligionManager : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
|
||||
fun getMajorityReligion(): Religion? {
|
||||
return city.civ.gameInfo.religions[getMajorityReligionName()]
|
||||
val majorityReligionName = getMajorityReligionName() ?: return null
|
||||
return city.civ.gameInfo.religions[majorityReligionName]
|
||||
}
|
||||
|
||||
private fun getAffectedBySurroundingCities() {
|
||||
@ -269,8 +270,9 @@ class CityReligionManager : IsPartOfGameInfoSerialization {
|
||||
spreadRange += unique.params[0].toInt()
|
||||
}
|
||||
|
||||
if (getMajorityReligion() != null) {
|
||||
for (unique in getMajorityReligion()!!.getFounder().getMatchingUniques(UniqueType.ReligionSpreadDistance))
|
||||
val majorityReligion = getMajorityReligion()
|
||||
if (majorityReligion != null) {
|
||||
for (unique in majorityReligion.getFounder().getMatchingUniques(UniqueType.ReligionSpreadDistance))
|
||||
spreadRange += unique.params[0].toInt()
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,8 @@ class CivInfoTransientCache(val civInfo: Civilization) {
|
||||
for (tile in civInfo.viewableTiles) {
|
||||
val tileOwner = tile.getOwner()
|
||||
if (tileOwner != null) viewedCivs[tileOwner] = tile
|
||||
for (unit in tile.getUnits()) viewedCivs[unit.civ] = tile
|
||||
val unitOwner = tile.getFirstUnit()?.civ
|
||||
if (unitOwner != null) viewedCivs[unitOwner] = tile
|
||||
}
|
||||
|
||||
if (!civInfo.isBarbarian()) {
|
||||
|
@ -404,7 +404,8 @@ class TileMap(initialCapacity: Int = 10) : IsPartOfGameInfoSerialization {
|
||||
|
||||
This can all be summed up as "I can see c if a=>b || c>b"
|
||||
*/
|
||||
val bMinimumHighestSeenTerrainSoFar = viewableTiles.filter { it.tile in cTile.neighbors }
|
||||
val bMinimumHighestSeenTerrainSoFar = viewableTiles
|
||||
.filter { it.tile.aerialDistanceTo(cTile) == 1 }
|
||||
.minOf { it.maxHeightSeenToTile }
|
||||
|
||||
tilesToAddInDistanceI.add(ViewableTile(
|
||||
|
@ -152,7 +152,7 @@ object MovementCost {
|
||||
// function is surprisingly less efficient than the current neighbor-intersection approach.
|
||||
// See #4085 for more details.
|
||||
val tilesExertingZoneOfControl = getTilesExertingZoneOfControl(unit, from)
|
||||
if (tilesExertingZoneOfControl.none { to.neighbors.contains(it)})
|
||||
if (tilesExertingZoneOfControl.none { it.aerialDistanceTo(it) == 1 })
|
||||
return false
|
||||
|
||||
// Even though this is a very fast check, we perform it last. This is because very few units
|
||||
|
@ -99,7 +99,7 @@ class Religion() : INamed, IsPartOfGameInfoSerialization {
|
||||
|
||||
fun isEnhancedReligion() = getBeliefs(BeliefType.Enhancer).any()
|
||||
|
||||
fun getFounder() = gameInfo.civilizations.first { it.civName == foundingCivName }
|
||||
fun getFounder() = gameInfo.getCivilization(foundingCivName)
|
||||
|
||||
private fun unlockedBuildingsPurchasable(): List<String> {
|
||||
return getAllBeliefsOrdered().flatMap { belief ->
|
||||
|
Reference in New Issue
Block a user