From 094ef672b7b5629e29ef81b849dcb81c0fd66579 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Sat, 3 Aug 2024 22:19:10 +0200 Subject: [PATCH] Fix new improvements becoming visible on non-observed tiles (#12054) --- core/src/com/unciv/logic/map/tile/Tile.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/map/tile/Tile.kt b/core/src/com/unciv/logic/map/tile/Tile.kt index abcec7fd5a..60a2d16a0f 100644 --- a/core/src/com/unciv/logic/map/tile/Tile.kt +++ b/core/src/com/unciv/logic/map/tile/Tile.kt @@ -321,7 +321,15 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable { else ruleset.tileImprovements[getUnpillagedRoad().name] } - fun getShownImprovement(viewingCiv: Civilization?): String? = viewingCiv?.getLastSeenImprovement(position) ?: improvement + /** + * Improvement to display, accounting for knowledge about a Tile possibly getting stale when a human player is no longer actively watching it. + * Relies on a Civilization's lastSeenImprovement always being up to date while the civ can see the Tile. + * @param viewingCiv `null` means civ-agnostic and thus always showing the actual improvement + * @return The improvement name, or `null` if no improvement should be shown + */ + fun getShownImprovement(viewingCiv: Civilization?): String? = + if (viewingCiv == null || viewingCiv.playerType == PlayerType.AI || viewingCiv.isSpectator()) improvement + else viewingCiv.getLastSeenImprovement(position) /** Returns true if this tile has fallout or an equivalent terrain feature */ fun hasFalloutEquivalent(): Boolean = terrainFeatures.any { ruleset.terrains[it]!!.hasUnique(UniqueType.NullifyYields)}