From 895c4da2f63959ac83a1aea0c5da73686bad77f4 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 18 Jul 2025 11:22:11 -0400 Subject: [PATCH] Better logging for unknown save versions --- core/src/mindustry/io/MapIO.java | 2 ++ core/src/mindustry/io/SaveIO.java | 2 +- gradle.properties | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/mindustry/io/MapIO.java b/core/src/mindustry/io/MapIO.java index 26cc9cd8ac..d918ff29b0 100644 --- a/core/src/mindustry/io/MapIO.java +++ b/core/src/mindustry/io/MapIO.java @@ -39,6 +39,7 @@ public class MapIO{ SaveIO.readHeader(stream); int version = stream.readInt(); SaveVersion ver = SaveIO.getSaveWriter(version); + if(ver == null) throw new IOException("Unknown save version: " + version + ". Are you trying to load a save from a newer version?"); StringMap tags = new StringMap(); ver.region("meta", stream, counter, in -> tags.putAll(ver.readStringMap(in))); return new Map(file, tags.getInt("width"), tags.getInt("height"), tags, custom, version, Version.build); @@ -69,6 +70,7 @@ public class MapIO{ SaveIO.readHeader(stream); int version = stream.readInt(); SaveVersion ver = SaveIO.getSaveWriter(version); + if(ver == null) throw new IOException("Unknown save version: " + version + ". Are you trying to load a save from a newer version?"); ver.region("meta", stream, counter, ver::readStringMap); Pixmap floors = new Pixmap(map.width, map.height); diff --git a/core/src/mindustry/io/SaveIO.java b/core/src/mindustry/io/SaveIO.java index dea4ce7b72..161b0681a4 100644 --- a/core/src/mindustry/io/SaveIO.java +++ b/core/src/mindustry/io/SaveIO.java @@ -32,7 +32,7 @@ public class SaveIO{ return versionArray.peek(); } - public static SaveVersion getSaveWriter(int version){ + public static @Nullable SaveVersion getSaveWriter(int version){ return versions.get(version); } diff --git a/gradle.properties b/gradle.properties index 5e1d3a2b35..65165c4661 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,4 +26,4 @@ org.gradle.caching=true org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 android.enableR8.fullMode=false -archash=ae3b50eaca +archash=e3a5a3a832