Fix: Legacy maps with starting locations not playable (#5000)

* Fix: legacy maps with starting locations not playable

* Fix: legacy maps with starting locations not playable - ruleset
This commit is contained in:
SomeTroglodyte 2021-08-27 15:26:45 +02:00 committed by GitHub
parent bf2ee91b67
commit 7085ea95cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -48,7 +48,7 @@ class TileMap {
@Transient
lateinit var gameInfo: GameInfo
/** Keep a copy of the [Ruleset] object passer to setTransients, for now only to allow subsequent setTransients without. Copied on [clone]. */
/** Keep a copy of the [Ruleset] object passed to setTransients, for now only to allow subsequent setTransients without. Copied on [clone]. */
@Transient
var ruleset: Ruleset? = null
@ -330,6 +330,8 @@ class TileMap {
* Is run before setTransients, so make do without startingLocationsByNation
*/
fun getRulesetIncompatibility(ruleset: Ruleset): HashSet<String> {
setTransients(ruleset)
setStartingLocationsTransients()
val rulesetIncompatibilities = HashSet<String>()
for (set in values.map { it.getRulesetIncompatibility(ruleset) })
rulesetIncompatibilities.addAll(set)

View File

@ -176,14 +176,15 @@ class TileGroupIcons(val tileGroup: TileGroup) {
startingLocationIcons.clear()
if (!showResourcesAndImprovements) return
if (tileGroup.forMapEditorIcon) return // the editor options for terrain do not bother to fully initialize, so tileInfo.tileMap would be an uninitialized lateinit
val tileInfo = tileGroup.tileInfo
if (tileInfo.tileMap.startingLocationsByNation.isEmpty()) return
// Allow display of up to three nations starting locations on the same tile, rest only as count.
// Sorted so major get precedence and to make the display deterministic, otherwise you could get
// different stacking order of the same nations in the same editing session
val tileInfo = tileGroup.tileInfo
val nations = tileInfo.tileMap.startingLocationsByNation.asSequence()
.filter { tileInfo in it.value }
.map { it.key to ImageGetter.ruleset.nations[it.key]!! }
.map { it.key to tileInfo.tileMap.ruleset!!.nations[it.key]!! }
.sortedWith(compareBy({ it.second.isCityState() }, { it.first }))
.toList()
if (nations.isEmpty()) return