mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 05:14:32 -04:00
Fix promotions being available when they shouldn't (#9986)
* Fix promotions being available when they shouldn't * Move unreachable code to the bottom * Remove unnecessary comment * Details for adopted nodes technically shouldn't be overriden * Add back in unreachable before we do checks * Just realized we're back to square one. Here's an actual fix
This commit is contained in:
parent
96292cbf4d
commit
8955d16e6a
@ -118,7 +118,8 @@ class PromotionTree(val unit: MapUnit) {
|
|||||||
// Also determine preferredParent / pathIsAmbiguous by weighing distanceToAdopted
|
// Also determine preferredParent / pathIsAmbiguous by weighing distanceToAdopted
|
||||||
for (node in allRoots()) {
|
for (node in allRoots()) {
|
||||||
node.depth = 0
|
node.depth = 0
|
||||||
node.distanceToAdopted = if (node.unreachable) Int.MAX_VALUE else if (node.isAdopted) 0 else 1
|
node.distanceToAdopted = if (node.isAdopted) 0
|
||||||
|
else if (node.unreachable) Int.MAX_VALUE else 1
|
||||||
}
|
}
|
||||||
for (depth in 0..99) {
|
for (depth in 0..99) {
|
||||||
var complete = true
|
var complete = true
|
||||||
@ -129,8 +130,9 @@ class PromotionTree(val unit: MapUnit) {
|
|||||||
}
|
}
|
||||||
if (node.depth != depth) continue
|
if (node.depth != depth) continue
|
||||||
for (child in node.children) {
|
for (child in node.children) {
|
||||||
val distance = if (node.distanceToAdopted == Int.MAX_VALUE) Int.MAX_VALUE
|
val distance = if (child.isAdopted) 0
|
||||||
else if (child.isAdopted) 0 else node.distanceToAdopted + 1
|
else if (node.distanceToAdopted == Int.MAX_VALUE) Int.MAX_VALUE else if (child.unreachable) Int.MAX_VALUE
|
||||||
|
else node.distanceToAdopted + 1
|
||||||
when {
|
when {
|
||||||
child.depth == Int.MIN_VALUE -> Unit // "New" node / first reached
|
child.depth == Int.MIN_VALUE -> Unit // "New" node / first reached
|
||||||
child.distanceToAdopted < distance -> continue // Already reached a better way
|
child.distanceToAdopted < distance -> continue // Already reached a better way
|
||||||
|
Loading…
x
Reference in New Issue
Block a user