This commit is contained in:
yairm210
2024-06-21 17:30:56 +03:00
parent ff775056de
commit 1bf494a6f7
5 changed files with 11 additions and 7 deletions

View File

@ -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()
}

View File

@ -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()) {

View File

@ -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(

View File

@ -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

View File

@ -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 ->