From 5e685e10aa8087fbc33df918d3614f4c9551f3bb Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Sun, 3 Mar 2024 19:03:40 +0100 Subject: [PATCH] Fix tileset sanity check for builtin rulesets when run from jar (#11230) * Avoid using folder listing for tileset sanity checks for builtin rulesets from jar * Remove an unnecessary java import * Revert the builtin-tileset-within-jar special check, not necessary for a release --- .../com/unciv/models/ruleset/validation/RulesetValidator.kt | 6 ++++++ .../com/unciv/ui/components/widgets/ZoomableScrollPane.kt | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/validation/RulesetValidator.kt b/core/src/com/unciv/models/ruleset/validation/RulesetValidator.kt index c0b3dfd4c1..439ae28fa3 100644 --- a/core/src/com/unciv/models/ruleset/validation/RulesetValidator.kt +++ b/core/src/com/unciv/models/ruleset/validation/RulesetValidator.kt @@ -1,6 +1,7 @@ package com.unciv.models.ruleset.validation import com.badlogic.gdx.Gdx +import com.badlogic.gdx.files.FileHandle import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData import com.unciv.Constants @@ -755,6 +756,11 @@ class RulesetValidator(val ruleset: Ruleset) { } private fun checkTilesetSanity(lines: RulesetErrorList) { + // If running from a jar *and* checking a builtin ruleset, skip this check. + // - We can't list() the jsons, and the unit test before relase is sufficient, the tileset config can't have changed since then. + if (ruleset.folderLocation == null && this::class.java.`package`?.specificationVersion != null) + return + val tilesetConfigFolder = (ruleset.folderLocation ?: Gdx.files.internal("")).child("jsons\\TileSets") if (!tilesetConfigFolder.exists()) return diff --git a/core/src/com/unciv/ui/components/widgets/ZoomableScrollPane.kt b/core/src/com/unciv/ui/components/widgets/ZoomableScrollPane.kt index 9aaefe2ca9..cf78e3eea2 100644 --- a/core/src/com/unciv/ui/components/widgets/ZoomableScrollPane.kt +++ b/core/src/com/unciv/ui/components/widgets/ZoomableScrollPane.kt @@ -19,8 +19,6 @@ import com.unciv.UncivGame import com.unciv.models.metadata.GameSettings import com.unciv.ui.components.ZoomGestureListener import com.unciv.ui.components.input.KeyboardPanningListener -import java.lang.Float.max -import java.lang.Float.min import kotlin.math.sqrt @@ -138,7 +136,7 @@ open class ZoomableScrollPane( } open fun zoom(zoomScale: Float) { - val newZoom = min(max(zoomScale, minZoom), maxZoom) + val newZoom = zoomScale.coerceIn(minZoom, maxZoom) val oldZoomX = scaleX val oldZoomY = scaleY