From c4e1a7d22bb3d53eaa42c3847c37b1483c738e96 Mon Sep 17 00:00:00 2001 From: ProgrammerDan Date: Tue, 27 Jul 2021 22:06:33 -0400 Subject: [PATCH] File.listFiles does not guarantee order but this code depends on alphabetic sort. Made that explicit. --- src/haven/Resource.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/haven/Resource.java b/src/haven/Resource.java index d77a045..96071d7 100644 --- a/src/haven/Resource.java +++ b/src/haven/Resource.java @@ -136,7 +136,7 @@ public ImageReadException() { } } - public static BufferedImage readimage(InputStream fp) throws IOException { + public static BufferedImage readimage(final InputStream fp) throws IOException { try { /* This can crash if not privileged due to ImageIO * creating tempfiles without doing that privileged @@ -1480,6 +1480,11 @@ private void loadfromdecode(String full) throws Exception { Constructor cons; df = l[i].listFiles(); + Arrays.sort(df, new Comparator() { + public int compare(File a, File b) { + return a.getName().compareTo(b.getName()); + } + }); switch (n) { case "image": case "tile": { /* .data + .png */