9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-21 16:09:29 +00:00

fix legacy object parsing

This commit is contained in:
Julian Krings
2025-12-18 14:22:21 +01:00
parent a4c5f46c37
commit 1737833bfe

View File

@@ -308,6 +308,9 @@ public class IrisObject extends IrisRegistrant {
blocks.put(new Vector3i(din.readShort(), din.readShort(), din.readShort()), B.get(din.readUTF())); blocks.put(new Vector3i(din.readShort(), din.readShort(), din.readShort()), B.get(din.readUTF()));
} }
if (din.available() == 0)
return;
try { try {
int size = din.readInt(); int size = din.readInt();
@@ -316,7 +319,6 @@ public class IrisObject extends IrisRegistrant {
} }
} catch (Throwable e) { } catch (Throwable e) {
Iris.reportError(e); Iris.reportError(e);
} }
} }
@@ -326,7 +328,7 @@ public class IrisObject extends IrisRegistrant {
this.h = din.readInt(); this.h = din.readInt();
this.d = din.readInt(); this.d = din.readInt();
if (!din.readUTF().equals("Iris V2 IOB;")) { if (!din.readUTF().equals("Iris V2 IOB;")) {
return; throw new HeaderException();
} }
center = new Vector3i(w / 2, h / 2, d / 2); center = new Vector3i(w / 2, h / 2, d / 2);
int s = din.readShort(); int s = din.readShort();
@@ -473,16 +475,14 @@ public class IrisObject extends IrisRegistrant {
} }
public void read(File file) throws IOException { public void read(File file) throws IOException {
var fin = new BufferedInputStream(new FileInputStream(file)); try (var fin = new BufferedInputStream(new FileInputStream(file))) {
try {
read(fin); read(fin);
fin.close();
} catch (Throwable e) { } catch (Throwable e) {
Iris.reportError(e); if (!(e instanceof HeaderException))
fin.close(); Iris.reportError(e);
fin = new BufferedInputStream(new FileInputStream(file)); try (var fin = new BufferedInputStream(new FileInputStream(file))) {
readLegacy(fin); readLegacy(fin);
fin.close(); }
} }
} }
@@ -1417,4 +1417,10 @@ public class IrisObject extends IrisRegistrant {
@Override @Override
public void scanForErrors(JSONObject p, VolmitSender sender) { public void scanForErrors(JSONObject p, VolmitSender sender) {
} }
private static class HeaderException extends IOException {
public HeaderException() {
super("Invalid Header");
}
}
} }