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 <noreply@anthropic.com>
This commit is contained in:
1 parent
d9d1c41d9e
commit
62b4a2a897
1 file changed
+17
-1
+17
-1
@@ -35,7 +35,7 @@ public class CacheParserUtil {
|
|||||||
public static File[] listJsonFiles(String folderPath) {
|
public static File[] listJsonFiles(String folderPath) {
|
||||||
|
|
||||||
File folder = new File(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) {
|
if (jsonFiles == null) {
|
||||||
Logger.error("Cache folder not found: " + folder.getAbsolutePath());
|
Logger.error("Cache folder not found: " + folder.getAbsolutePath());
|
||||||
@@ -45,6 +45,22 @@ public class CacheParserUtil {
|
|||||||
return jsonFiles;
|
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) {
|
public static int templateIdFromFile(File jsonFile) {
|
||||||
|
|
||||||
String fileName = jsonFile.getName();
|
String fileName = jsonFile.getName();
|
||||||
|
|||||||
Reference in new issue
Block a user