From 93268f53eeeeb4dd6ace1a62918dd1caa26aca58 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Thu, 23 Dec 2021 21:22:40 +0200 Subject: [PATCH] Another stab at #5729 after the toInt didn't help. --- core/src/com/unciv/logic/civilization/CivInfoStats.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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()