mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 21:30:20 +07:00
Better map-to-ruleset incompatibility checks
This commit is contained in:
@ -750,7 +750,8 @@ open class TileInfo {
|
|||||||
out.add("Terrain feature [$terrainFeature] does not exist in ruleset!")
|
out.add("Terrain feature [$terrainFeature] does not exist in ruleset!")
|
||||||
if (resource != null && !ruleset.tileResources.containsKey(resource))
|
if (resource != null && !ruleset.tileResources.containsKey(resource))
|
||||||
out.add("Resource [$resource] does not exist in ruleset!")
|
out.add("Resource [$resource] does not exist in ruleset!")
|
||||||
if (improvement != null && !ruleset.tileImprovements.containsKey(improvement))
|
if (improvement != null && !improvement!!.startsWith(TileMap.startingLocationPrefix)
|
||||||
|
&& !ruleset.tileImprovements.containsKey(improvement))
|
||||||
out.add("Improvement [$improvement] does not exist in ruleset!")
|
out.add("Improvement [$improvement] does not exist in ruleset!")
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
@ -374,11 +374,17 @@ class TileMap {
|
|||||||
* Is run before setTransients, so make do without startingLocationsByNation
|
* Is run before setTransients, so make do without startingLocationsByNation
|
||||||
*/
|
*/
|
||||||
fun getRulesetIncompatibility(ruleset: Ruleset): HashSet<String> {
|
fun getRulesetIncompatibility(ruleset: Ruleset): HashSet<String> {
|
||||||
setTransients(ruleset)
|
|
||||||
setStartingLocationsTransients()
|
|
||||||
val rulesetIncompatibilities = HashSet<String>()
|
val rulesetIncompatibilities = HashSet<String>()
|
||||||
for (set in values.map { it.getRulesetIncompatibility(ruleset) })
|
for (set in values.map { it.getRulesetIncompatibility(ruleset) })
|
||||||
rulesetIncompatibilities.addAll(set)
|
rulesetIncompatibilities.addAll(set)
|
||||||
|
|
||||||
|
// All the rest is to find missing nations
|
||||||
|
try { // This can fail if the map contains a resource that isn't in the ruleset, in TileInfo.tileResource
|
||||||
|
setTransients(ruleset)
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
return rulesetIncompatibilities
|
||||||
|
}
|
||||||
|
setStartingLocationsTransients()
|
||||||
for ((_, nationName) in startingLocations) {
|
for ((_, nationName) in startingLocations) {
|
||||||
if (nationName !in ruleset.nations)
|
if (nationName !in ruleset.nations)
|
||||||
rulesetIncompatibilities.add("Nation [$nationName] does not exist in ruleset!")
|
rulesetIncompatibilities.add("Nation [$nationName] does not exist in ruleset!")
|
||||||
|
Reference in New Issue
Block a user