Another stab at #5729 after the toInt didn't help.

This commit is contained in:
yairm210 2021-12-23 21:22:40 +02:00
parent eb4a76dcd0
commit 93268f53ee

View File

@ -52,8 +52,8 @@ class CivInfoStats(val civInfo: CivilizationInfo) {
// Sort by descending maintenance, then drop most expensive X units to make them free
// If more free than units left, returns empty sequence
// There's something here that causes a bug and I'm not sure where, so let's try taking this apart piece by piece
// Switching sort to use fixed point math. Perhaps error is due to floating comparisons
unitsToPayFor = unitsToPayFor.sortedByDescending { it.maintenance*100000.0.toInt() }.toList().asSequence()
// We tried toInt()ing, didn't help. Let's try converting to a final list before sorting.
unitsToPayFor = unitsToPayFor.toList().sortedByDescending { it.maintenance }.asSequence()
unitsToPayFor = unitsToPayFor.drop(freeUnits)
val numberOfUnitsToPayFor = max(0.0, unitsToPayFor.sumOf { it.maintenance.toDouble() }).toFloat()