From 0abcd22728d1024cc2d6072805b69ed373af4c2f Mon Sep 17 00:00:00 2001 From: yairm210 Date: Tue, 15 Jul 2025 23:44:04 +0300 Subject: [PATCH] chore: Hexmath purity --- build.gradle.kts | 3 +++ core/src/com/unciv/logic/map/HexMath.kt | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index b37d8cd870..9548d3a0ec 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -49,6 +49,9 @@ allprojects { configure{ wellKnownPureFunctions = setOf( "com.unciv.logic.civilization.diplomacy.RelationshipLevel.compareTo", + "kotlin.math.max", + "kotlin.math.min", + "kotlin.math.abs" ) wellKnownReadonlyFunctions = setOf( // Looks like the Collection.contains is not considered overridden :thunk: diff --git a/core/src/com/unciv/logic/map/HexMath.kt b/core/src/com/unciv/logic/map/HexMath.kt index 3dea1c896c..843ec07ca9 100644 --- a/core/src/com/unciv/logic/map/HexMath.kt +++ b/core/src/com/unciv/logic/map/HexMath.kt @@ -232,10 +232,12 @@ object HexMath { } /** Get number of hexes from [origin] to [destination] _without respecting world-wrap_ */ + @Pure fun getDistance(origin: Vector2, destination: Vector2): Int { return getDistance(origin.x.toInt(), origin.y.toInt(), destination.x.toInt(), destination.y.toInt()) } - + + @Pure fun getDistance(originX: Int, originY: Int, destinationX: Int, destinationY: Int): Int { val relativeX = originX - destinationX val relativeY = originY - destinationY