diff --git a/core/src/com/unciv/logic/civilization/CivInfoStats.kt b/core/src/com/unciv/logic/civilization/CivInfoStats.kt index fe97b62d30..fea531f8b3 100644 --- a/core/src/com/unciv/logic/civilization/CivInfoStats.kt +++ b/core/src/com/unciv/logic/civilization/CivInfoStats.kt @@ -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()