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();