diff --git a/core/src/com/unciv/logic/city/managers/CityReligionManager.kt b/core/src/com/unciv/logic/city/managers/CityReligionManager.kt index 08dd7e500b..46e24cfce6 100644 --- a/core/src/com/unciv/logic/city/managers/CityReligionManager.kt +++ b/core/src/com/unciv/logic/city/managers/CityReligionManager.kt @@ -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() } diff --git a/core/src/com/unciv/logic/civilization/transients/CivInfoTransientCache.kt b/core/src/com/unciv/logic/civilization/transients/CivInfoTransientCache.kt index 94ea86d0af..f59851ecd7 100644 --- a/core/src/com/unciv/logic/civilization/transients/CivInfoTransientCache.kt +++ b/core/src/com/unciv/logic/civilization/transients/CivInfoTransientCache.kt @@ -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()) { diff --git a/core/src/com/unciv/logic/map/TileMap.kt b/core/src/com/unciv/logic/map/TileMap.kt index 53d0adee22..114a3ab211 100644 --- a/core/src/com/unciv/logic/map/TileMap.kt +++ b/core/src/com/unciv/logic/map/TileMap.kt @@ -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( diff --git a/core/src/com/unciv/logic/map/mapunit/movement/MovementCost.kt b/core/src/com/unciv/logic/map/mapunit/movement/MovementCost.kt index e81b5f0713..250089b30a 100644 --- a/core/src/com/unciv/logic/map/mapunit/movement/MovementCost.kt +++ b/core/src/com/unciv/logic/map/mapunit/movement/MovementCost.kt @@ -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 diff --git a/core/src/com/unciv/models/Religion.kt b/core/src/com/unciv/models/Religion.kt index 231b9ff296..3cf5ff7481 100644 --- a/core/src/com/unciv/models/Religion.kt +++ b/core/src/com/unciv/models/Religion.kt @@ -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 { return getAllBeliefsOrdered().flatMap { belief ->