diff --git a/core/src/com/riiablo/io/InvalidFormat.java b/core/src/com/riiablo/io/InvalidFormat.java new file mode 100644 index 00000000..0f38d4bc --- /dev/null +++ b/core/src/com/riiablo/io/InvalidFormat.java @@ -0,0 +1,28 @@ +package com.riiablo.io; + +public class InvalidFormat extends RuntimeException { + public final long offset; + + public InvalidFormat(ByteInput in, String message) { + this(in, message, null); + } + + public InvalidFormat(ByteInput in, Throwable cause) { + this(in, "Invalid format", cause); + } + + public InvalidFormat(ByteInput in, String message, Throwable cause) { + super(message + " @0x" + Integer.toHexString(in.bytesRead()), cause); + this.offset = in.bytesRead(); + } + + @Deprecated + public InvalidFormat(String message) { + super(message, null); + this.offset = 0L; + } + + public long offset() { + return offset; + } +} diff --git a/core/src/com/riiablo/item/ItemSerializer.java b/core/src/com/riiablo/item/ItemSerializer.java index 5065b3c8..40f8668f 100644 --- a/core/src/com/riiablo/item/ItemSerializer.java +++ b/core/src/com/riiablo/item/ItemSerializer.java @@ -8,9 +8,9 @@ import com.badlogic.gdx.utils.Array; import com.riiablo.Riiablo; import com.riiablo.codec.excel.Gems; import com.riiablo.codec.util.BitStream; +import com.riiablo.io.InvalidFormat; import com.riiablo.log.Log; import com.riiablo.log.LogManager; -import com.riiablo.save.InvalidFormat; import com.riiablo.util.DebugUtils; public class ItemSerializer {