From 62b4a2a897ae43d92ea0d72908e8f2e52bd949e6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 17 Oct 2026 13:44:45 -0400 Subject: [PATCH] Skip cache JSON files whose name is not a 32-bit template id The client cache holds RUNE/10788957847552 (2512 << 32), which would overflow Integer.parseInt and abort the rune load. Such files are now skipped with a warning. The file is not in MBDATA yet, so the 880/2695/4011 counts are unchanged. Co-Authored-By: Claude Opus 5.5 --- src/engine/parsers/cache/CacheParserUtil.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/engine/parsers/cache/CacheParserUtil.java b/src/engine/parsers/cache/CacheParserUtil.java index 026322d6..13fbda6a 100644 --- a/src/engine/parsers/cache/CacheParserUtil.java +++ b/src/engine/parsers/cache/CacheParserUtil.java @@ -35,7 +35,7 @@ public class CacheParserUtil { public static File[] listJsonFiles(String folderPath) { File folder = new File(folderPath); - File[] jsonFiles = folder.listFiles((dir, name) -> name.endsWith(".json")); + File[] jsonFiles = folder.listFiles((dir, name) -> name.endsWith(".json") && hasTemplateId(name)); if (jsonFiles == null) { Logger.error("Cache folder not found: " + folder.getAbsolutePath()); @@ -45,6 +45,22 @@ public class CacheParserUtil { return jsonFiles; } + // Template ids are 32-bit. The client cache has RUNE/10788957847552, which is + // 2512 << 32 (the Huntress id in the high word); files like it are skipped. + + private static boolean hasTemplateId(String fileName) { + + String idText = fileName.substring(0, fileName.length() - ".json".length()); + + try { + Integer.parseInt(idText); + return true; + } catch (NumberFormatException e) { + Logger.warn("Skipping " + fileName + ": name is not a 32-bit template id"); + return false; + } + } + public static int templateIdFromFile(File jsonFile) { String fileName = jsonFile.getName();