From 35718c00e79643007a83f82185b7da074d5ed9d1 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 23 May 2023 22:15:31 +0300 Subject: [PATCH] Fixed softlock for mod policies overriding existing policy locations --- core/src/com/unciv/models/ruleset/Ruleset.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index 603d2bc825..6d918dcbd8 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -345,6 +345,16 @@ class Ruleset { policy.requires = arrayListOf(branch.name) } policies[policy.name] = policy + + // If mods override a previous policy's location, we don't want that policy to stick around, + // because it leads to softlocks on the policy picker screen + val conflictingLocationPolicy = policies.values.firstOrNull { + it.branch.name == policy.branch.name + && it.column == policy.column + && it.row == policy.row + } + if (conflictingLocationPolicy!=null) + policies.remove(conflictingLocationPolicy.name) } // Add a finisher