From e75742d3d678eb6452b4ef5bc4c6a8d535d80c6d Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 23 May 2023 22:37:10 +0300 Subject: [PATCH] Fixed policy branch finishers overriding branches - oops! --- core/src/com/unciv/models/ruleset/Ruleset.kt | 21 +++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index 6d918dcbd8..c9f11c73d6 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -344,17 +344,20 @@ class Ruleset { if (policy.requires == null) { policy.requires = arrayListOf(branch.name) } + + if (policy != branch.policies.last()) { + // 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) + } 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