Fix map editor can't place improvements (#11743)

* Fix map editor can't place improvements

* Prefer the 'has...' approach after all
This commit is contained in:
SomeTroglodyte 2024-06-15 20:58:04 +02:00 committed by GitHub
parent 294a0a71a4
commit bb1057e515
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -214,6 +214,9 @@ class TileMap(initialCapacity: Int = 10) : IsPartOfGameInfoSerialization {
//endregion
//region Pure Functions
/** Can we access [gameInfo]? e.g. for MapEditor use where there is a map but no game */
fun hasGameInfo() = ::gameInfo.isInitialized
/** @return All tiles in a hexagon of radius [distance], including the tile at [origin] and all up to [distance] steps away.
* Respects map edges and world wrap. */
fun getTilesInDistance(origin: Vector2, distance: Int): Sequence<Tile> =

View File

@ -217,7 +217,8 @@ class TileImprovementFunctions(val tile: Tile) {
}
}
if (improvementFieldHasChanged) {
if (improvementFieldHasChanged && tile.tileMap.hasGameInfo()) {
// Update the separately-kept "what a civ sees" - unless in map editor where there are no civs
for (civ in tile.tileMap.gameInfo.civilizations) {
if (civ.isDefeated() || !civ.isMajorCiv()) continue
if (civ == civToActivateBroaderEffects || tile.isVisible(civ))