diff --git a/src/main/java/BitmapFont.java b/src/main/java/BitmapFont.java index cae0bcc..e400310 100644 --- a/src/main/java/BitmapFont.java +++ b/src/main/java/BitmapFont.java @@ -16,33 +16,33 @@ public class BitmapFont { public BitmapFont(FileArchive archive, String name, boolean quill) throws IOException { Buffer dat = new Buffer(archive.read(name + ".dat")); Buffer idx = new Buffer(archive.read("index.dat")); - idx.position = dat.get2U() + 4; + idx.position = dat.read16U() + 4; - int k = idx.get1U(); + int k = idx.read8U(); if (k > 0) { idx.position += 3 * (k - 1); } for (int c = 0; c < 256; c++) { - charOffsetX[c] = idx.get1U(); - charOffsetY[c] = idx.get1U(); + charOffsetX[c] = idx.read8U(); + charOffsetY[c] = idx.read8U(); - int w = charMaskWidth[c] = idx.get2U(); - int h = charMaskHeight[c] = idx.get2U(); - int storeOrder = idx.get1U(); + int w = charMaskWidth[c] = idx.read16U(); + int h = charMaskHeight[c] = idx.read16U(); + int storeOrder = idx.read8U(); int len = w * h; charMask[c] = new byte[len]; if (storeOrder == 0) { for (int i = 0; i < len; i++) { - charMask[c][i] = dat.get1(); + charMask[c][i] = dat.read8(); } } else if (storeOrder == 1) { for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { - charMask[c][x + (y * w)] = dat.get1(); + charMask[c][x + (y * w)] = dat.read8(); } } } diff --git a/src/main/java/Buffer.java b/src/main/java/Buffer.java index 790df01..689e617 100644 --- a/src/main/java/Buffer.java +++ b/src/main/java/Buffer.java @@ -5,8 +5,8 @@ import java.nio.charset.StandardCharsets; /** * A {@link Buffer} encapsulates a finite amount of data and provides methods for reading and writing to that data. - * The put() and get() methods describe the type of data they use by attributes in their - * suffix. The naming convention is put[type][U:unsigned][endianness][modifier]. + * The write() and read() methods describe the type of data they use by attributes in their + * suffix. The naming convention is (read|write)[type][U:unsigned][endianness][modifier]. *

* Types:
* # — the number of bytes
@@ -22,9 +22,9 @@ import java.nio.charset.StandardCharsets; * Note: ME and RME are not standard, and are a form of obfuscation similar to the modifier attribute.
*

* Modifiers:
- * A — put(v + 128) — get returns (v - 128)
- * C — put(-v) — get returns (-v)
- * S — put(128 - v) — get returns (128 - v)
+ * A — put(v + 128) — read returns (v - 128)
+ * C — put(-v) — read returns (-v)
+ * S — put(128 - v) — read returns (128 - v)
*/ public class Buffer extends DoublyLinkedList.Node { @@ -58,67 +58,67 @@ public class Buffer extends DoublyLinkedList.Node { position = 0; } - public void putOp(int i) { + public void writeOp(int i) { data[position++] = (byte) (i + random.nextInt()); } - public void putSize1(int i) { + public void writeSize(int i) { data[position - i - 1] = (byte) i; } - public void put1(int i) { + public void write8(int i) { data[position++] = (byte) i; } - public void put1C(int i) { + public void write8C(int i) { data[position++] = (byte) (-i); } - public void put1S(int j) { + public void write8S(int j) { data[position++] = (byte) (128 - j); } - public void put2(int i) { + public void write16(int i) { data[position++] = (byte) (i >> 8); data[position++] = (byte) i; } - public void put2A(int j) { + public void write16A(int j) { data[position++] = (byte) (j >> 8); data[position++] = (byte) (j + 128); } - public void put2LE(int i) { + public void write16LE(int i) { data[position++] = (byte) i; data[position++] = (byte) (i >> 8); } - public void put2LEA(int j) { + public void write16LEA(int j) { data[position++] = (byte) (j + 128); data[position++] = (byte) (j >> 8); } - public void put3(int i) { + public void write24(int i) { data[position++] = (byte) (i >> 16); data[position++] = (byte) (i >> 8); data[position++] = (byte) i; } - public void put4(int i) { + public void write32(int i) { data[position++] = (byte) (i >> 24); data[position++] = (byte) (i >> 16); data[position++] = (byte) (i >> 8); data[position++] = (byte) i; } - public void put4LE(int j) { + public void write32LE(int j) { data[position++] = (byte) j; data[position++] = (byte) (j >> 8); data[position++] = (byte) (j >> 16); data[position++] = (byte) (j >> 24); } - public void put8(long l) { + public void write64(long l) { data[position++] = (byte) (int) (l >> 56); data[position++] = (byte) (int) (l >> 48); data[position++] = (byte) (int) (l >> 40); @@ -129,51 +129,51 @@ public class Buffer extends DoublyLinkedList.Node { data[position++] = (byte) (int) l; } - public void put(String s) { - put(s.getBytes(StandardCharsets.ISO_8859_1)); - put1('\n'); + public void writeString(String s) { + writeBytes(s.getBytes(StandardCharsets.ISO_8859_1)); + write8('\n'); } - public void put(byte[] src, int off, int len) { + public void writeBytes(byte[] src, int off, int len) { System.arraycopy(src, off, data, position, len); position += len; } - public void put(byte[] src) { - put(src, 0, src.length); + public void writeBytes(byte[] src) { + writeBytes(src, 0, src.length); } - public void putA(byte[] src, int off, int len) { + public void writeBytesA(byte[] src, int off, int len) { for (int i = (off + len) - 1; i >= off; i--) { data[position++] = (byte) (src[i] + 128); } } - public byte get1() { + public byte read8() { return data[position++]; } - public byte get1C() { + public byte read8C() { return (byte) (-data[position++]); } - public byte get1S() { + public byte read8S() { return (byte) (128 - data[position++]); } - public int get1U() { + public int read8U() { return data[position++] & 0xff; } - public int get1UA() { + public int read8UA() { return (data[position++] - 128) & 0xff; } - public int get1UC() { + public int read8UC() { return -data[position++] & 0xff; } - public int get1US() { + public int read8US() { return (128 - data[position++]) & 0xff; } @@ -182,12 +182,12 @@ public class Buffer extends DoublyLinkedList.Node { * * @return the value. */ - public int getSmart() { + public int readSmart() { int i = data[position] & 0xff; if (i < 128) { - return get1U() - 64; + return read8U() - 64; } else { - return get2U() - 49152; + return read16U() - 49152; } } @@ -196,36 +196,36 @@ public class Buffer extends DoublyLinkedList.Node { * * @return the value. */ - public int getSmartU() { + public int readSmartU() { int i = data[position] & 0xff; if (i < 128) { - return get1U(); + return read8U(); } else { - return get2U() - 32768; + return read16U() - 32768; } } - public int get2U() { + public int read16U() { position += 2; return ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff); } - public int get2UA() { + public int read16UA() { position += 2; return ((data[position - 2] & 0xff) << 8) + ((data[position - 1] - 128) & 0xff); } - public int get2ULE() { + public int read16ULE() { position += 2; return ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff); } - public int get2ULEA() { + public int read16ULEA() { position += 2; return ((data[position - 1] & 0xff) << 8) + ((data[position - 2] - 128) & 0xff); } - public int get2() { + public int read16() { position += 2; int i = ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff); if (i > 32767) { @@ -234,7 +234,7 @@ public class Buffer extends DoublyLinkedList.Node { return i; } - public int get2LE() { + public int read16LE() { position += 2; int j = ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff); if (j > 0x7fff) { @@ -243,7 +243,7 @@ public class Buffer extends DoublyLinkedList.Node { return j; } - public int get2LEA() { + public int read16LEA() { position += 2; int j = ((data[position - 1] & 0xff) << 8) + ((data[position - 2] - 128) & 0xff); if (j > 0x7fff) { @@ -252,40 +252,40 @@ public class Buffer extends DoublyLinkedList.Node { return j; } - public int get3() { + public int read24() { position += 3; return ((data[position - 3] & 0xff) << 16) + ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff); } - public int get4() { + public int read32() { position += 4; return ((data[position - 4] & 0xff) << 24) + ((data[position - 3] & 0xff) << 16) + ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff); } - public int get4ME() { + public int read32ME() { position += 4; return ((data[position - 3] & 0xff) << 24) + ((data[position - 4] & 0xff) << 16) + ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff); } - public int get4RME() { + public int read32RME() { position += 4; return ((data[position - 2] & 0xff) << 24) + ((data[position - 1] & 0xff) << 16) + ((data[position - 4] & 0xff) << 8) + (data[position - 3] & 0xff); } - public long get8() { - long l = (long) get4() & 0xffffffffL; - long l1 = (long) get4() & 0xffffffffL; + public long read64() { + long l = (long) read32() & 0xffffffffL; + long l1 = (long) read32() & 0xffffffffL; return (l << 32) + l1; } - public String getString() { + public String readString() { int start = position; while (data[position++] != '\n') { } return new String(data, start, position - start - 1); } - public byte[] getStringRaw() { + public byte[] readStringRaw() { int start = position; while (data[position++] != '\n') { } @@ -296,12 +296,12 @@ public class Buffer extends DoublyLinkedList.Node { return raw; } - public void get(byte[] dst, int off, int len) { + public void readBytes(byte[] dst, int off, int len) { System.arraycopy(data, position, dst, off, len); position += len; } - public void getReversed(byte[] dst, int off, int len) { + public void getBytesReversed(byte[] dst, int off, int len) { for (int i = (off + len) - 1; i >= off; i--) { dst[i] = data[position++]; } @@ -311,7 +311,7 @@ public class Buffer extends DoublyLinkedList.Node { bitPosition = position * 8; } - public int getBits(int n) { + public int readN(int n) { int bytePos = bitPosition >> 3; int remaining = 8 - (bitPosition & 7); int value = 0; @@ -336,11 +336,11 @@ public class Buffer extends DoublyLinkedList.Node { int length = position; position = 0; byte[] raw = new byte[length]; - get(raw, 0, length); + readBytes(raw, 0, length); byte[] encrypted = new BigInteger(raw).modPow(exponent, modulus).toByteArray(); position = 0; - put1(encrypted.length); - put(encrypted, 0, encrypted.length); + write8(encrypted.length); + writeBytes(encrypted, 0, encrypted.length); } } diff --git a/src/main/java/Censor.java b/src/main/java/Censor.java index 3066bf1..f2f2fdd 100644 --- a/src/main/java/Censor.java +++ b/src/main/java/Censor.java @@ -30,50 +30,50 @@ public class Censor { } public static void method489(Buffer buffer) { - int i = buffer.get4(); + int i = buffer.read32(); aCharArrayArray624 = new char[i][]; anIntArray625 = new int[i]; for (int j = 0; j < i; j++) { - anIntArray625[j] = buffer.get1U(); - char[] ac = new char[buffer.get1U()]; + anIntArray625[j] = buffer.read8U(); + char[] ac = new char[buffer.read8U()]; for (int k = 0; k < ac.length; k++) { - ac[k] = (char) buffer.get1U(); + ac[k] = (char) buffer.read8U(); } aCharArrayArray624[j] = ac; } } public static void method490(Buffer buffer) { - int j = buffer.get4(); + int j = buffer.read32(); aCharArrayArray621 = new char[j][]; aByteArrayArrayArray622 = new byte[j][][]; method493(buffer, aCharArrayArray621, aByteArrayArrayArray622); } public static void method491(Buffer buffer) { - int i = buffer.get4(); + int i = buffer.read32(); aCharArrayArray623 = new char[i][]; method494(aCharArrayArray623, buffer, -490); } public static void method492(Buffer buffer) { - anIntArray620 = new int[buffer.get4()]; + anIntArray620 = new int[buffer.read32()]; for (int i = 0; i < anIntArray620.length; i++) { - anIntArray620[i] = buffer.get2U(); + anIntArray620[i] = buffer.read16U(); } } public static void method493(Buffer buffer, char[][] ac, byte[][][] abyte0) { for (int j = 0; j < ac.length; j++) { - char[] ac1 = new char[buffer.get1U()]; + char[] ac1 = new char[buffer.read8U()]; for (int k = 0; k < ac1.length; k++) { - ac1[k] = (char) buffer.get1U(); + ac1[k] = (char) buffer.read8U(); } ac[j] = ac1; - byte[][] abyte1 = new byte[buffer.get1U()][2]; + byte[][] abyte1 = new byte[buffer.read8U()][2]; for (int l = 0; l < abyte1.length; l++) { - abyte1[l][0] = (byte) buffer.get1U(); - abyte1[l][1] = (byte) buffer.get1U(); + abyte1[l][0] = (byte) buffer.read8U(); + abyte1[l][1] = (byte) buffer.read8U(); } if (abyte1.length > 0) { abyte0[j] = abyte1; @@ -86,9 +86,9 @@ public class Censor { return; } for (int j = 0; j < ac.length; j++) { - char[] ac1 = new char[buffer.get1U()]; + char[] ac1 = new char[buffer.read8U()]; for (int k = 0; k < ac1.length; k++) { - ac1[k] = (char) buffer.get1U(); + ac1[k] = (char) buffer.read8U(); } ac[j] = ac1; } diff --git a/src/main/java/ChatCompression.java b/src/main/java/ChatCompression.java index 64f28b9..9f47d39 100644 --- a/src/main/java/ChatCompression.java +++ b/src/main/java/ChatCompression.java @@ -19,7 +19,7 @@ public class ChatCompression { int carry = -1; for (int i = 0; i < expectedLength; i++) { - int value = buffer.get1U(); + int value = buffer.read8U(); int nibble = (value >> 4) & 0xf; if (carry == -1) { @@ -92,19 +92,19 @@ public class ChatCompression { if (index < 13) { carry = index; } else { - dst.put1(index); + dst.write8(index); } } else if (index < 13) { - dst.put1((carry << 4) + index); + dst.write8((carry << 4) + index); carry = -1; } else { - dst.put1((carry << 4) + (index >> 4)); + dst.write8((carry << 4) + (index >> 4)); carry = index & 0xf; } } if (carry != -1) { - dst.put1(carry << 4); + dst.write8(carry << 4); } } diff --git a/src/main/java/Component.java b/src/main/java/Component.java index bfc6b40..b8d3f05 100644 --- a/src/main/java/Component.java +++ b/src/main/java/Component.java @@ -17,94 +17,94 @@ public class Component { Buffer in = new Buffer(config.read("data")); int parentID = -1; - int count = in.get2U(); + int count = in.read16U(); instances = new Component[count]; while (in.position < in.data.length) { - int id = in.get2U(); + int id = in.read16U(); if (id == 65535) { - parentID = in.get2U(); - id = in.get2U(); + parentID = in.read16U(); + id = in.read16U(); } Component c = instances[id] = new Component(); c.id = id; c.parentID = parentID; - c.type = in.get1U(); - c.optionType = in.get1U(); - c.contentType = in.get2U(); - c.width = in.get2U(); - c.height = in.get2U(); - c.transparency = (byte) in.get1U(); - c.delegateHover = in.get1U(); + c.type = in.read8U(); + c.optionType = in.read8U(); + c.contentType = in.read16U(); + c.width = in.read16U(); + c.height = in.read16U(); + c.transparency = (byte) in.read8U(); + c.delegateHover = in.read8U(); if (c.delegateHover != 0) { - c.delegateHover = ((c.delegateHover - 1) << 8) + in.get1U(); + c.delegateHover = ((c.delegateHover - 1) << 8) + in.read8U(); } else { c.delegateHover = -1; } - int comparatorCount = in.get1U(); + int comparatorCount = in.read8U(); if (comparatorCount > 0) { c.scriptComparator = new int[comparatorCount]; c.scriptOperand = new int[comparatorCount]; for (int i = 0; i < comparatorCount; i++) { - c.scriptComparator[i] = in.get1U(); - c.scriptOperand[i] = in.get2U(); + c.scriptComparator[i] = in.read8U(); + c.scriptOperand[i] = in.read16U(); } } - int scriptCount = in.get1U(); + int scriptCount = in.read8U(); if (scriptCount > 0) { c.scripts = new int[scriptCount][]; for (int scriptID = 0; scriptID < scriptCount; scriptID++) { - int length = in.get2U(); + int length = in.read16U(); c.scripts[scriptID] = new int[length]; for (int i = 0; i < length; i++) { - c.scripts[scriptID][i] = in.get2U(); + c.scripts[scriptID][i] = in.read16U(); } } } if (c.type == 0) { - c.scrollableHeight = in.get2U(); - c.hidden = in.get1U() == 1; - int childCount = in.get2U(); + c.scrollableHeight = in.read16U(); + c.hidden = in.read8U() == 1; + int childCount = in.read16U(); c.children = new int[childCount]; c.childX = new int[childCount]; c.childY = new int[childCount]; for (int i = 0; i < childCount; i++) { - c.children[i] = in.get2U(); - c.childX[i] = in.get2(); - c.childY[i] = in.get2(); + c.children[i] = in.read16U(); + c.childX[i] = in.read16(); + c.childY[i] = in.read16(); } } if (c.type == 1) { - c.unusedInt = in.get2U(); - c.unusedBool = in.get1U() == 1; + c.unusedInt = in.read16U(); + c.unusedBool = in.read8U() == 1; } if (c.type == 2) { c.invSlotObjID = new int[c.width * c.height]; c.invSlotAmount = new int[c.width * c.height]; - c.invDraggable = in.get1U() == 1; - c.aBoolean249 = in.get1U() == 1; - c.invUsable = in.get1U() == 1; - c.invMoveReplaces = in.get1U() == 1; - c.invMarginX = in.get1U(); - c.invMarginY = in.get1U(); + c.invDraggable = in.read8U() == 1; + c.aBoolean249 = in.read8U() == 1; + c.invUsable = in.read8U() == 1; + c.invMoveReplaces = in.read8U() == 1; + c.invMarginX = in.read8U(); + c.invMarginY = in.read8U(); c.invSlotX = new int[20]; c.invSlotY = new int[20]; c.invSlotImage = new Image24[20]; for (int j2 = 0; j2 < 20; j2++) { - int k3 = in.get1U(); + int k3 = in.read8U(); if (k3 == 1) { - c.invSlotX[j2] = in.get2(); - c.invSlotY[j2] = in.get2(); - String s1 = in.getString(); + c.invSlotX[j2] = in.read16(); + c.invSlotY[j2] = in.read16(); + String s1 = in.readString(); if ((media != null) && (s1.length() > 0)) { int i5 = s1.lastIndexOf(","); c.invSlotImage[j2] = getImage(Integer.parseInt(s1.substring(i5 + 1)), media, s1.substring(0, i5)); @@ -113,7 +113,7 @@ public class Component { } c.invOptions = new String[5]; for (int i = 0; i < 5; i++) { - c.invOptions[i] = in.getString(); + c.invOptions[i] = in.readString(); if (c.invOptions[i].length() == 0) { c.invOptions[i] = null; } @@ -121,40 +121,40 @@ public class Component { } if (c.type == 3) { - c.fill = in.get1U() == 1; + c.fill = in.read8U() == 1; } if ((c.type == 4) || (c.type == 1)) { - c.center = in.get1U() == 1; - int fontID = in.get1U(); + c.center = in.read8U() == 1; + int fontID = in.read8U(); if (fonts != null) { c.font = fonts[fontID]; } - c.shadow = in.get1U() == 1; + c.shadow = in.read8U() == 1; } if (c.type == 4) { - c.text = in.getString(); - c.activeText = in.getString(); + c.text = in.readString(); + c.activeText = in.readString(); } if ((c.type == 1) || (c.type == 3) || (c.type == 4)) { - c.color = in.get4(); + c.color = in.read32(); } if ((c.type == 3) || (c.type == 4)) { - c.activeColor = in.get4(); - c.hoverColor = in.get4(); - c.activeHoverColor = in.get4(); + c.activeColor = in.read32(); + c.hoverColor = in.read32(); + c.activeHoverColor = in.read32(); } if (c.type == 5) { - String s = in.getString(); + String s = in.readString(); if ((media != null) && (s.length() > 0)) { int comma = s.lastIndexOf(","); c.image = getImage(Integer.parseInt(s.substring(comma + 1)), media, s.substring(0, comma)); } - s = in.getString(); + s = in.readString(); if ((media != null) && (s.length() > 0)) { int comma = s.lastIndexOf(","); c.activeImage = getImage(Integer.parseInt(s.substring(comma + 1)), media, s.substring(0, comma)); @@ -162,53 +162,53 @@ public class Component { } if (c.type == 6) { - int tmp = in.get1U(); + int tmp = in.read8U(); if (tmp != 0) { c.modelCategory = 1; - c.modelID = ((tmp - 1) << 8) + in.get1U(); + c.modelID = ((tmp - 1) << 8) + in.read8U(); } - tmp = in.get1U(); + tmp = in.read8U(); if (tmp != 0) { c.activeModelCategory = 1; - c.activeModelID = ((tmp - 1) << 8) + in.get1U(); + c.activeModelID = ((tmp - 1) << 8) + in.read8U(); } - tmp = in.get1U(); + tmp = in.read8U(); if (tmp != 0) { - c.seqID = ((tmp - 1) << 8) + in.get1U(); + c.seqID = ((tmp - 1) << 8) + in.read8U(); } else { c.seqID = -1; } - tmp = in.get1U(); + tmp = in.read8U(); if (tmp != 0) { - c.activeSeqID = ((tmp - 1) << 8) + in.get1U(); + c.activeSeqID = ((tmp - 1) << 8) + in.read8U(); } else { c.activeSeqID = -1; } - c.modelZoom = in.get2U(); - c.modelPitch = in.get2U(); - c.modelYaw = in.get2U(); + c.modelZoom = in.read16U(); + c.modelPitch = in.read16U(); + c.modelYaw = in.read16U(); } if (c.type == 7) { c.invSlotObjID = new int[c.width * c.height]; c.invSlotAmount = new int[c.width * c.height]; - c.center = in.get1U() == 1; - int fontID = in.get1U(); + c.center = in.read8U() == 1; + int fontID = in.read8U(); if (fonts != null) { c.font = fonts[fontID]; } - c.shadow = in.get1U() == 1; - c.color = in.get4(); - c.invMarginX = in.get2(); - c.invMarginY = in.get2(); - c.aBoolean249 = in.get1U() == 1; + c.shadow = in.read8U() == 1; + c.color = in.read32(); + c.invMarginX = in.read16(); + c.invMarginY = in.read16(); + c.aBoolean249 = in.read8U() == 1; c.invOptions = new String[5]; for (int k4 = 0; k4 < 5; k4++) { - c.invOptions[k4] = in.getString(); + c.invOptions[k4] = in.readString(); if (c.invOptions[k4].length() == 0) { c.invOptions[k4] = null; } @@ -216,17 +216,17 @@ public class Component { } if (c.type == 8) { - c.spellAction = in.getString(); + c.spellAction = in.readString(); } if ((c.optionType == 2) || (c.type == 2)) { - c.spellAction = in.getString(); - c.spellName = in.getString(); - c.spellFlags = in.get2U(); + c.spellAction = in.readString(); + c.spellName = in.readString(); + c.spellFlags = in.read16U(); } if ((c.optionType == 1) || (c.optionType == 4) || (c.optionType == 5) || (c.optionType == 6)) { - c.option = in.getString(); + c.option = in.readString(); if (c.option.length() == 0) { if (c.optionType == 1) { c.option = "Ok"; diff --git a/src/main/java/FileArchive.java b/src/main/java/FileArchive.java index 1c0843b..11d0cd2 100644 --- a/src/main/java/FileArchive.java +++ b/src/main/java/FileArchive.java @@ -24,8 +24,8 @@ public class FileArchive { public void load(byte[] src) throws IOException { Buffer buffer = new Buffer(src); - int unpackedSize = buffer.get3(); - int packedSize = buffer.get3(); + int unpackedSize = buffer.read24(); + int packedSize = buffer.read24(); if (packedSize != unpackedSize) { data = new byte[unpackedSize]; @@ -37,7 +37,7 @@ public class FileArchive { unpacked = false; } - fileCount = buffer.get2U(); + fileCount = buffer.read16U(); fileHash = new int[fileCount]; fileSizeInflated = new int[fileCount]; fileSizeDeflated = new int[fileCount]; @@ -46,9 +46,9 @@ public class FileArchive { int offset = buffer.position + (fileCount * 10); for (int file = 0; file < fileCount; file++) { - fileHash[file] = buffer.get4(); - fileSizeInflated[file] = buffer.get3(); - fileSizeDeflated[file] = buffer.get3(); + fileHash[file] = buffer.read32(); + fileSizeInflated[file] = buffer.read24(); + fileSizeDeflated[file] = buffer.read24(); fileOffset[file] = offset; offset += fileSizeDeflated[file]; } diff --git a/src/main/java/FloType.java b/src/main/java/FloType.java index cb8ff40..c0a011b 100644 --- a/src/main/java/FloType.java +++ b/src/main/java/FloType.java @@ -11,7 +11,7 @@ public class FloType { public static void unpack(FileArchive archive) throws IOException { Buffer buffer = new Buffer(archive.read("flo.dat")); - count = buffer.get2U(); + count = buffer.read16U(); if (instances == null) { instances = new FloType[count]; } @@ -40,27 +40,27 @@ public class FloType { public void method261(Buffer buffer) { do { - int i = buffer.get1U(); + int i = buffer.read8U(); if (i == 0) { return; } if (i == 1) { - rgb = buffer.get3(); + rgb = buffer.read24(); setColor(rgb); } else if (i == 2) { - textureID = buffer.get1U(); + textureID = buffer.read8U(); } else if (i == 3) { unusedBool = true; } else if (i == 5) { aBoolean393 = false; } else if (i == 6) { - unusedString = buffer.getString(); + unusedString = buffer.readString(); } else if (i == 7) { int hue = this.hue; int saturation = this.saturation; int lightness = this.lightness; int chroma = this.chroma; - int rgb = buffer.get3(); + int rgb = buffer.read24(); setColor(rgb); this.hue = hue; this.saturation = saturation; diff --git a/src/main/java/Game.java b/src/main/java/Game.java index ca9ea33..e75c970 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -1319,9 +1319,9 @@ public class Game extends GameShell { in.readFully(buffer.data, 0, 40); in.close(); for (int i1 = 0; i1 < 9; i1++) { - archiveChecksum[i1] = buffer.get4(); + archiveChecksum[i1] = buffer.read32(); } - int j1 = buffer.get4(); + int j1 = buffer.read32(); int k1 = 1234; for (int l1 = 0; l1 < 9; l1++) { k1 = (k1 << 1) + archiveChecksum[l1]; @@ -1686,7 +1686,7 @@ public class Game extends GameShell { } SceneBuilder sceneBuilder = new SceneBuilder(levelTileFlags, 104, 104, levelHeightmap); int k2 = sceneMapLandData.length; - out.putOp(0); + out.writeOp(0); if (!sceneInstanced) { for (int i3 = 0; i3 < k2; i3++) { int i4 = ((sceneMapIndex[i3] >> 8) * 64) - sceneBaseTileX; @@ -1704,7 +1704,7 @@ public class Game extends GameShell { sceneBuilder.method174(k7, 64, 64, l5); } } - out.putOp(0); + out.writeOp(0); for (int i6 = 0; i6 < k2; i6++) { byte[] abyte1 = sceneMapLocData[i6]; if (abyte1 != null) { @@ -1744,7 +1744,7 @@ public class Game extends GameShell { } } } - out.putOp(0); + out.writeOp(0); for (int l6 = 0; l6 < 4; l6++) { for (int j8 = 0; j8 < 13; j8++) { for (int j9 = 0; j9 < 13; j9++) { @@ -1767,10 +1767,10 @@ public class Game extends GameShell { } } } - out.putOp(0); + out.writeOp(0); sceneBuilder.method171(levelCollisionMap, scene); areaViewport.bind(); - out.putOp(0); + out.writeOp(0); int k3 = SceneBuilder.minLevel; if (k3 > currentLevel) { k3 = currentLevel; @@ -1792,8 +1792,8 @@ public class Game extends GameShell { LocType.staticCache.clear(); if (super.frame != null) { - out.putOp(210); - out.put4(0x3f008edd); + out.writeOp(210); + out.write32(0x3f008edd); } if (lowmem && (Signlink.cache_dat != null)) { @@ -2275,28 +2275,28 @@ public class Game extends GameShell { publicChatSetting = (publicChatSetting + 1) % 4; redrawPrivacySettings = true; redrawChatback = true; - out.putOp(95); - out.put1(publicChatSetting); - out.put1(privateChatSetting); - out.put1(tradeChatSetting); + out.writeOp(95); + out.write8(publicChatSetting); + out.write8(privateChatSetting); + out.write8(tradeChatSetting); } if ((super.mousePressX >= 135) && (super.mousePressX <= 235) && (super.mousePressY >= 467) && (super.mousePressY <= 499)) { privateChatSetting = (privateChatSetting + 1) % 3; redrawPrivacySettings = true; redrawChatback = true; - out.putOp(95); - out.put1(publicChatSetting); - out.put1(privateChatSetting); - out.put1(tradeChatSetting); + out.writeOp(95); + out.write8(publicChatSetting); + out.write8(privateChatSetting); + out.write8(tradeChatSetting); } if ((super.mousePressX >= 273) && (super.mousePressX <= 373) && (super.mousePressY >= 467) && (super.mousePressY <= 499)) { tradeChatSetting = (tradeChatSetting + 1) % 3; redrawPrivacySettings = true; redrawChatback = true; - out.putOp(95); - out.put1(publicChatSetting); - out.put1(privateChatSetting); - out.put1(tradeChatSetting); + out.writeOp(95); + out.write8(publicChatSetting); + out.write8(privateChatSetting); + out.write8(tradeChatSetting); } if ((super.mousePressX >= 412) && (super.mousePressX <= 512) && (super.mousePressY >= 467) && (super.mousePressY <= 499)) { if (viewportComponentID == -1) { @@ -2705,8 +2705,8 @@ public class Game extends GameShell { friendWorld[j] = friendWorld[j + 1]; friendName37[j] = friendName37[j + 1]; } - out.putOp(215); - out.put8(name37); + out.writeOp(215); + out.write64(name37); break; } } @@ -2999,8 +2999,8 @@ public class Game extends GameShell { friendWorld[friendCount] = 0; friendCount++; redrawInvback = true; - out.putOp(188); - out.put8(name37); + out.writeOp(188); + out.write64(name37); } } @@ -3065,7 +3065,7 @@ public class Game extends GameShell { public void method46(int i, Buffer buffer) { while ((buffer.bitPosition + 21) < (i * 8)) { - int k = buffer.getBits(14); + int k = buffer.readN(14); if (k == 16383) { break; } @@ -3075,17 +3075,17 @@ public class Game extends GameShell { NPCEntity npc = npcs[k]; npcIndices[npcCount++] = k; npc.anInt1537 = loopCycle; - int z = buffer.getBits(5); + int z = buffer.readN(5); if (z > 15) { z -= 32; } - int x = buffer.getBits(5); + int x = buffer.readN(5); if (x > 15) { x -= 32; } - int j1 = buffer.getBits(1); - npc.type = NPCType.get(buffer.getBits(12)); - int k1 = buffer.getBits(1); + int j1 = buffer.readN(1); + npc.type = NPCType.get(buffer.readN(12)); + int k1 = buffer.readN(1); if (k1 == 1) { anIntArray894[anInt893++] = k; } @@ -3247,23 +3247,23 @@ public class Game extends GameShell { validateCharacterDesign(); } if (type == 326) { - out.putOp(101); - out.put1(designGender ? 0 : 1); + out.writeOp(101); + out.write8(designGender ? 0 : 1); for (int i = 0; i < 7; i++) { - out.put1(designIdentikits[i]); + out.write8(designIdentikits[i]); } for (int i = 0; i < 5; i++) { - out.put1(designColors[i]); + out.write8(designColors[i]); } return true; } if ((type >= 601) && (type <= 612)) { closeInterfaces(); if (aString881.length() > 0) { - out.putOp(218); - out.put8(StringUtil.toBase37(aString881)); - out.put1(type - 601); - out.put1(aBoolean1158 ? 1 : 0); + out.writeOp(218); + out.write64(StringUtil.toBase37(aString881)); + out.write8(type - 601); + out.write8(aBoolean1158 ? 1 : 0); } } return false; @@ -3273,9 +3273,9 @@ public class Game extends GameShell { for (int j = 0; j < anInt893; j++) { int k = anIntArray894[j]; PlayerEntity player = players[k]; - int l = buffer.get1U(); + int l = buffer.read8U(); if ((l & 0x40) != 0) { - l += buffer.get1U() << 8; + l += buffer.read8U() << 8; } method107(l, k, buffer, player); } @@ -3569,7 +3569,7 @@ public class Game extends GameShell { sceneState = 2; SceneBuilder.anInt131 = currentLevel; method22(); - out.putOp(121); + out.writeOp(121); return 0; } } @@ -3853,8 +3853,8 @@ public class Game extends GameShell { synchronized (mouseRecorder.lock) { if (flagged) { if ((super.mousePressButton != 0) || (mouseRecorder.length >= 40)) { - out.putOp(45); - out.put1(0); + out.writeOp(45); + out.write8(0); int startPosition = out.position; int written = 0; for (int i = 0; i < mouseRecorder.length; i++) { @@ -3892,18 +3892,18 @@ public class Game extends GameShell { if ((lastWriteDuplicates < 8) && (dx >= -32) && (dx <= 31) && (dy >= -32) && (dy <= 31)) { dx += 32; dy += 32; - out.put2((lastWriteDuplicates << 12) + (dx << 6) + dy); + out.write16((lastWriteDuplicates << 12) + (dx << 6) + dy); lastWriteDuplicates = 0; } else if (lastWriteDuplicates < 8) { - out.put3(0x800000 + (lastWriteDuplicates << 19) + pos); + out.write24(0x800000 + (lastWriteDuplicates << 19) + pos); lastWriteDuplicates = 0; } else { - out.put4(0xc0000000 + (lastWriteDuplicates << 19) + pos); + out.write32(0xc0000000 + (lastWriteDuplicates << 19) + pos); lastWriteDuplicates = 0; } } } - out.putSize1(out.position - startPosition); + out.writeSize(out.position - startPosition); if (written >= mouseRecorder.length) { mouseRecorder.length = 0; } else { @@ -3943,8 +3943,8 @@ public class Game extends GameShell { button = 1; } int deltaInt = (int) delta; - out.putOp(241); - out.put4((deltaInt << 20) + (button << 19) + pos); + out.writeOp(241); + out.write32((deltaInt << 20) + (button << 19) + pos); } if (sendCameraDelay > 0) { @@ -3958,21 +3958,21 @@ public class Game extends GameShell { if (sendCamera && (sendCameraDelay <= 0)) { sendCameraDelay = 20; sendCamera = false; - out.putOp(86); - out.put2(orbitCameraPitch); - out.put2A(orbitCameraYaw); + out.writeOp(86); + out.write16(orbitCameraPitch); + out.write16A(orbitCameraYaw); } if (super.focused && !_focused) { _focused = true; - out.putOp(3); - out.put1(1); + out.writeOp(3); + out.write8(1); } if (!super.focused && _focused) { _focused = false; - out.putOp(3); - out.put1(0); + out.writeOp(3); + out.write8(0); } updateSceneState(); @@ -4067,11 +4067,11 @@ public class Game extends GameShell { } else { component.swapSlots(objDragSlot, hoveredSlot); } - out.putOp(214); - out.put2LEA(objDragComponentID); - out.put1C(mode); - out.put2LEA(objDragSlot); - out.put2LE(hoveredSlot); + out.writeOp(214); + out.write16LEA(objDragComponentID); + out.write8C(mode); + out.write16LEA(objDragSlot); + out.write16LE(hoveredSlot); } } else if (((mouseButtonsOption == 1) || method17(menuSize - 1)) && (menuSize > 2)) { showContextMenu(); @@ -4130,7 +4130,7 @@ public class Game extends GameShell { heartbeatTimer++; if (heartbeatTimer > 50) { - out.putOp(0); + out.writeOp(0); } try { @@ -4152,7 +4152,7 @@ public class Game extends GameShell { if (super.idleCycles > 4500) { idleTimeout = 250; super.idleCycles -= 500; - out.putOp(202); + out.writeOp(202); } } @@ -4308,7 +4308,7 @@ public class Game extends GameShell { datainputstream.readFully(abyte1, 0, 6); Buffer buffer = new Buffer(abyte1); buffer.position = 3; - int i2 = buffer.get3() + 6; + int i2 = buffer.read24() + 6; int j2 = 6; data = new byte[i2]; for (int k2 = 0; k2 < 6; k2++) { @@ -4448,11 +4448,11 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(57); - out.put2A(anInt1285); - out.put2A(c); - out.put2LE(anInt1283); - out.put2A(anInt1284); + out.writeOp(57); + out.write16A(anInt1285); + out.write16A(c); + out.write16LE(anInt1283); + out.write16A(anInt1284); } } if (action == 234) { @@ -4464,19 +4464,19 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(236); - out.put2LE(b + sceneBaseTileZ); - out.put2(c); - out.put2LE(a + sceneBaseTileX); + out.writeOp(236); + out.write16LE(b + sceneBaseTileZ); + out.write16(c); + out.write16LE(a + sceneBaseTileX); } if ((action == 62) && interactWithLoc(c, a, b)) { - out.putOp(192); - out.put2(anInt1284); - out.put2LE((c >> 14) & 0x7fff); - out.put2LEA(b + sceneBaseTileZ); - out.put2LE(anInt1283); - out.put2LEA(a + sceneBaseTileX); - out.put2(anInt1285); + out.writeOp(192); + out.write16(anInt1284); + out.write16LE((c >> 14) & 0x7fff); + out.write16LEA(b + sceneBaseTileZ); + out.write16LE(anInt1283); + out.write16LEA(a + sceneBaseTileX); + out.write16(anInt1285); } if (action == 511) { boolean flag2 = tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); @@ -4487,19 +4487,19 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(25); - out.put2LE(anInt1284); - out.put2A(anInt1285); - out.put2(c); - out.put2A(b + sceneBaseTileZ); - out.put2LEA(anInt1283); - out.put2(a + sceneBaseTileX); + out.writeOp(25); + out.write16LE(anInt1284); + out.write16A(anInt1285); + out.write16(c); + out.write16A(b + sceneBaseTileZ); + out.write16LEA(anInt1283); + out.write16(a + sceneBaseTileX); } if (action == 74) { - out.putOp(122); - out.put2LEA(b); - out.put2A(a); - out.put2LE(c); + out.writeOp(122); + out.write16LEA(b); + out.write16A(a); + out.write16LE(c); actionCycles = 0; actionComponentID = b; actionInvSlot = a; @@ -4518,8 +4518,8 @@ public class Game extends GameShell { notify = handleComponentAction(component); } if (notify) { - out.putOp(185); - out.put2(b); + out.writeOp(185); + out.write16(b); } } if (action == 561) { @@ -4530,8 +4530,8 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(128); - out.put2(c); + out.writeOp(128); + out.write16(c); } } if (action == 20) { @@ -4542,8 +4542,8 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(155); - out.put2LE(c); + out.writeOp(155); + out.write16LE(c); } } if (action == 779) { @@ -4554,8 +4554,8 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(153); - out.put2LE(c); + out.writeOp(153); + out.write16LE(c); } } if (action == 516) { @@ -4567,21 +4567,21 @@ public class Game extends GameShell { } if (action == 1062) { interactWithLoc(c, a, b); - out.putOp(228); - out.put2A((c >> 14) & 0x7fff); - out.put2A(b + sceneBaseTileZ); - out.put2(a + sceneBaseTileX); + out.writeOp(228); + out.write16A((c >> 14) & 0x7fff); + out.write16A(b + sceneBaseTileZ); + out.write16(a + sceneBaseTileX); } if ((action == 679) && !aBoolean1149) { - out.putOp(40); - out.put2(b); + out.writeOp(40); + out.write16(b); aBoolean1149 = true; } if (action == 431) { - out.putOp(129); - out.put2A(a); - out.put2(b); - out.put2A(c); + out.writeOp(129); + out.write16A(a); + out.write16(b); + out.write16A(c); actionCycles = 0; actionComponentID = b; actionInvSlot = a; @@ -4613,10 +4613,10 @@ public class Game extends GameShell { } } if (action == 53) { - out.putOp(135); - out.put2LE(a); - out.put2A(b); - out.put2LE(c); + out.writeOp(135); + out.write16LE(a); + out.write16A(b); + out.write16LE(c); actionCycles = 0; actionComponentID = b; actionInvSlot = a; @@ -4629,10 +4629,10 @@ public class Game extends GameShell { } } if (action == 539) { - out.putOp(16); - out.put2A(c); - out.put2LEA(a); - out.put2LEA(b); + out.writeOp(16); + out.write16A(c); + out.write16LEA(a); + out.write16LEA(b); actionCycles = 0; actionComponentID = b; actionInvSlot = a; @@ -4658,12 +4658,12 @@ public class Game extends GameShell { } tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], player_7.pathTileX[0], player_7.pathTileZ[0], 0, 1, 1, 0, 0, false); if (action == 484) { - out.putOp(139); - out.put2LE(playerIndices[j3]); + out.writeOp(139); + out.write16LE(playerIndices[j3]); } if (action == 6) { - out.putOp(128); - out.put2(playerIndices[j3]); + out.writeOp(128); + out.write16(playerIndices[j3]); } flag9 = true; break; @@ -4674,13 +4674,13 @@ public class Game extends GameShell { } } if (action == 870) { - out.putOp(53); - out.put2(a); - out.put2A(anInt1283); - out.put2LEA(c); - out.put2(anInt1284); - out.put2LE(anInt1285); - out.put2(b); + out.writeOp(53); + out.write16(a); + out.write16A(anInt1283); + out.write16LEA(c); + out.write16(anInt1284); + out.write16LE(anInt1285); + out.write16(b); actionCycles = 0; actionComponentID = b; actionInvSlot = a; @@ -4693,10 +4693,10 @@ public class Game extends GameShell { } } if (action == 847) { - out.putOp(87); - out.put2A(c); - out.put2(b); - out.put2A(a); + out.writeOp(87); + out.write16A(c); + out.write16(b); + out.write16A(a); actionCycles = 0; actionComponentID = b; actionInvSlot = a; @@ -4739,10 +4739,10 @@ public class Game extends GameShell { return; } if (action == 78) { - out.putOp(117); - out.put2LEA(b); - out.put2LEA(c); - out.put2LE(a); + out.writeOp(117); + out.write16LEA(b); + out.write16LEA(c); + out.write16LE(a); actionCycles = 0; actionComponentID = b; actionInvSlot = a; @@ -4762,8 +4762,8 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(73); - out.put2LE(c); + out.writeOp(73); + out.write16LE(c); } } if (action == 213) { @@ -4775,16 +4775,16 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(79); - out.put2LE(b + sceneBaseTileZ); - out.put2(c); - out.put2A(a + sceneBaseTileX); + out.writeOp(79); + out.write16LE(b + sceneBaseTileZ); + out.write16(c); + out.write16A(a + sceneBaseTileX); } if (action == 632) { - out.putOp(145); - out.put2A(b); - out.put2A(a); - out.put2A(c); + out.writeOp(145); + out.write16A(b); + out.write16A(a); + out.write16A(c); actionCycles = 0; actionComponentID = b; actionInvSlot = a; @@ -4797,10 +4797,10 @@ public class Game extends GameShell { } } if (action == 493) { - out.putOp(75); - out.put2LEA(b); - out.put2LE(a); - out.put2A(c); + out.writeOp(75); + out.write16LEA(b); + out.write16LE(a); + out.write16A(c); actionCycles = 0; actionComponentID = b; actionInvSlot = a; @@ -4821,10 +4821,10 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(156); - out.put2A(a + sceneBaseTileX); - out.put2LE(b + sceneBaseTileZ); - out.put2LEA(c); + out.writeOp(156); + out.write16A(a + sceneBaseTileX); + out.write16LE(b + sceneBaseTileZ); + out.write16LEA(c); } if (action == 94) { boolean flag5 = tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); @@ -4835,15 +4835,15 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(181); - out.put2LE(b + sceneBaseTileZ); - out.put2(c); - out.put2LE(a + sceneBaseTileX); - out.put2A(activeSpellComponent); + out.writeOp(181); + out.write16LE(b + sceneBaseTileZ); + out.write16(c); + out.write16LE(a + sceneBaseTileX); + out.write16A(activeSpellComponent); } if (action == 646) { - out.putOp(185); - out.put2(b); + out.writeOp(185); + out.write16(b); Component component_2 = Component.instances[b]; if ((component_2.scripts != null) && (component_2.scripts[0][0] == 5)) { int i2 = component_2.scripts[0][1]; @@ -4862,8 +4862,8 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(17); - out.put2LEA(c); + out.writeOp(17); + out.write16LEA(c); } } if (action == 965) { @@ -4874,8 +4874,8 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(21); - out.put2(c); + out.writeOp(21); + out.write16(c); } } if (action == 413) { @@ -4886,9 +4886,9 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(131); - out.put2LEA(c); - out.put2A(activeSpellComponent); + out.writeOp(131); + out.write16LEA(c); + out.write16A(activeSpellComponent); } } if (action == 200) { @@ -4914,10 +4914,10 @@ public class Game extends GameShell { } if (action == 900) { interactWithLoc(c, a, b); - out.putOp(252); - out.put2LEA((c >> 14) & 0x7fff); - out.put2LE(b + sceneBaseTileZ); - out.put2A(a + sceneBaseTileX); + out.writeOp(252); + out.write16LEA((c >> 14) & 0x7fff); + out.write16LE(b + sceneBaseTileZ); + out.write16A(a + sceneBaseTileX); } if (action == 412) { NPCEntity npc_6 = npcs[c]; @@ -4927,8 +4927,8 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(72); - out.put2A(c); + out.writeOp(72); + out.write16A(c); } } if (action == 365) { @@ -4939,9 +4939,9 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(249); - out.put2A(c); - out.put2LE(activeSpellComponent); + out.writeOp(249); + out.write16A(c); + out.write16LE(activeSpellComponent); } } if (action == 729) { @@ -4952,8 +4952,8 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(39); - out.put2LE(c); + out.writeOp(39); + out.write16LE(c); } } if (action == 577) { @@ -4964,16 +4964,16 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(139); - out.put2LE(c); + out.writeOp(139); + out.write16LE(c); } } if ((action == 956) && interactWithLoc(c, a, b)) { - out.putOp(35); - out.put2LE(a + sceneBaseTileX); - out.put2A(activeSpellComponent); - out.put2A(b + sceneBaseTileZ); - out.put2LE((c >> 14) & 0x7fff); + out.writeOp(35); + out.write16LE(a + sceneBaseTileX); + out.write16A(activeSpellComponent); + out.write16A(b + sceneBaseTileZ); + out.write16LE((c >> 14) & 0x7fff); } if (action == 567) { boolean flag6 = tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); @@ -4984,16 +4984,16 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(23); - out.put2LE(b + sceneBaseTileZ); - out.put2LE(c); - out.put2LE(a + sceneBaseTileX); + out.writeOp(23); + out.write16LE(b + sceneBaseTileZ); + out.write16LE(c); + out.write16LE(a + sceneBaseTileX); } if (action == 867) { - out.putOp(43); - out.put2LE(b); - out.put2A(c); - out.put2A(a); + out.writeOp(43); + out.write16LE(b); + out.write16A(c); + out.write16A(a); actionCycles = 0; actionComponentID = b; actionInvSlot = a; @@ -5006,11 +5006,11 @@ public class Game extends GameShell { } } if (action == 543) { - out.putOp(237); - out.put2(a); - out.put2A(c); - out.put2(b); - out.put2A(activeSpellComponent); + out.writeOp(237); + out.write16(a); + out.write16A(c); + out.write16(b); + out.write16A(activeSpellComponent); actionCycles = 0; actionComponentID = b; actionInvSlot = a; @@ -5050,11 +5050,11 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(14); - out.put2A(anInt1284); - out.put2(c); - out.put2(anInt1285); - out.put2LE(anInt1283); + out.writeOp(14); + out.write16A(anInt1284); + out.write16(c); + out.write16(anInt1285); + out.write16LE(anInt1283); } } if (action == 639) { @@ -5082,10 +5082,10 @@ public class Game extends GameShell { } } if (action == 454) { - out.putOp(41); - out.put2(c); - out.put2A(a); - out.put2A(b); + out.writeOp(41); + out.write16(c); + out.write16A(a); + out.write16A(b); actionCycles = 0; actionComponentID = b; actionInvSlot = a; @@ -5105,30 +5105,30 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(18); - out.put2LE(c); + out.writeOp(18); + out.write16LE(c); } } if (action == 113) { interactWithLoc(c, a, b); - out.putOp(70); - out.put2LE(a + sceneBaseTileX); - out.put2(b + sceneBaseTileZ); - out.put2LEA((c >> 14) & 0x7fff); + out.writeOp(70); + out.write16LE(a + sceneBaseTileX); + out.write16(b + sceneBaseTileZ); + out.write16LEA((c >> 14) & 0x7fff); } if (action == 872) { interactWithLoc(c, a, b); - out.putOp(234); - out.put2LEA(a + sceneBaseTileX); - out.put2A((c >> 14) & 0x7fff); - out.put2LEA(b + sceneBaseTileZ); + out.writeOp(234); + out.write16LEA(a + sceneBaseTileX); + out.write16A((c >> 14) & 0x7fff); + out.write16LEA(b + sceneBaseTileZ); } if (action == 502) { interactWithLoc(c, a, b); - out.putOp(132); - out.put2LEA(a + sceneBaseTileX); - out.put2((c >> 14) & 0x7fff); - out.put2A(b + sceneBaseTileZ); + out.writeOp(132); + out.write16LEA(a + sceneBaseTileX); + out.write16((c >> 14) & 0x7fff); + out.write16A(b + sceneBaseTileZ); } if (action == 1125) { ObjType type = ObjType.get(c); @@ -5144,8 +5144,8 @@ public class Game extends GameShell { addMessage(0, "", s5); } if (action == 169) { - out.putOp(185); - out.put2(b); + out.writeOp(185); + out.write16(b); Component component_3 = Component.instances[b]; if ((component_3.scripts != null) && (component_3.scripts[0][0] == 5)) { int l2 = component_3.scripts[0][1]; @@ -5184,10 +5184,10 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - out.putOp(253); - out.put2LE(a + sceneBaseTileX); - out.put2LEA(b + sceneBaseTileZ); - out.put2A(c); + out.writeOp(253); + out.write16LE(a + sceneBaseTileX); + out.write16LEA(b + sceneBaseTileZ); + out.write16A(c); } if (action == 1448) { ObjType type_1 = ObjType.get(c); @@ -5463,22 +5463,22 @@ public class Game extends GameShell { removeFriend(l1); } if ((socialAction == 3) && (socialInput.length() > 0)) { - out.putOp(126); - out.put1(0); + out.writeOp(126); + out.write8(0); int k = out.position; - out.put8(aLong953); + out.write64(aLong953); ChatCompression.pack(socialInput, out); - out.putSize1(out.position - k); + out.writeSize(out.position - k); socialInput = ChatCompression.method527(socialInput); socialInput = Censor.apply(socialInput); addMessage(6, StringUtil.formatName(StringUtil.fromBase37(aLong953)), socialInput); if (privateChatSetting == 2) { privateChatSetting = 1; redrawPrivacySettings = true; - out.putOp(95); - out.put1(publicChatSetting); - out.put1(privateChatSetting); - out.put1(tradeChatSetting); + out.writeOp(95); + out.write8(publicChatSetting); + out.write8(privateChatSetting); + out.write8(tradeChatSetting); } } if ((socialAction == 4) && (ignoreCount < 100)) { @@ -5506,8 +5506,8 @@ public class Game extends GameShell { i1 = Integer.parseInt(chatbackInput); } catch (Exception ignored) { } - out.putOp(208); - out.put4(i1); + out.writeOp(208); + out.write32(i1); } chatbackInputType = 0; redrawChatback = true; @@ -5523,8 +5523,8 @@ public class Game extends GameShell { } if ((key == 13) || (key == 10)) { if (chatbackInput.length() > 0) { - out.putOp(60); - out.put8(StringUtil.toBase37(chatbackInput)); + out.writeOp(60); + out.write64(StringUtil.toBase37(chatbackInput)); } chatbackInputType = 0; redrawChatback = true; @@ -5568,9 +5568,9 @@ public class Game extends GameShell { } } if (chatTyped.startsWith("::")) { - out.putOp(103); - out.put1(chatTyped.length() - 1); - out.put(chatTyped.substring(2)); + out.writeOp(103); + out.write8(chatTyped.length() - 1); + out.writeString(chatTyped.substring(2)); } else { String s = chatTyped.toLowerCase(); int j2 = 0; @@ -5629,15 +5629,15 @@ public class Game extends GameShell { i3 = 5; chatTyped = chatTyped.substring(6); } - out.putOp(4); - out.put1(0); + out.writeOp(4); + out.write8(0); int j3 = out.position; - out.put1S(i3); - out.put1S(j2); + out.write8S(i3); + out.write8S(j2); chatBuffer.position = 0; ChatCompression.pack(chatTyped, chatBuffer); - out.putA(chatBuffer.data, 0, chatBuffer.position); - out.putSize1(out.position - j3); + out.writeBytesA(chatBuffer.data, 0, chatBuffer.position); + out.writeSize(out.position - j3); chatTyped = ChatCompression.method527(chatTyped); chatTyped = Censor.apply(chatTyped); localPlayer.chat = chatTyped; @@ -5654,10 +5654,10 @@ public class Game extends GameShell { if (publicChatSetting == 2) { publicChatSetting = 3; redrawPrivacySettings = true; - out.putOp(95); - out.put1(publicChatSetting); - out.put1(privateChatSetting); - out.put1(tradeChatSetting); + out.writeOp(95); + out.write8(publicChatSetting); + out.write8(privateChatSetting); + out.write8(tradeChatSetting); } } chatTyped = ""; @@ -6370,8 +6370,8 @@ public class Game extends GameShell { long l = StringUtil.toBase37(username); int i = (int) ((l >> 16) & 31L); out.position = 0; - out.put1(14); - out.put1(i); + out.write8(14); + out.write8(i); connection.write(out.data, 0, 2); for (int j = 0; j < 8; j++) { connection.read(); @@ -6381,7 +6381,7 @@ public class Game extends GameShell { if (k == 0) { connection.read(in.data, 0, 8); in.position = 0; - aLong1215 = in.get8(); + aLong1215 = in.read64(); // apache math tries to fill the remaining 1008 bytes up with random junk if we don't give it 256 ints. int[] seed = new int[1 << 8]; @@ -6391,29 +6391,29 @@ public class Game extends GameShell { seed[2] = (int) (aLong1215 >> 32); seed[3] = (int) aLong1215; out.position = 0; - out.put1(10); - out.put4(seed[0]); - out.put4(seed[1]); - out.put4(seed[2]); - out.put4(seed[3]); - out.put4(Signlink.uid); - out.put(username); - out.put(password); + out.write8(10); + out.write32(seed[0]); + out.write32(seed[1]); + out.write32(seed[2]); + out.write32(seed[3]); + out.write32(Signlink.uid); + out.writeString(username); + out.writeString(password); out.encrypt(RSA_EXPONENT, RSA_MODULUS); login.position = 0; if (reconnect) { - login.put1(18); + login.write8(18); } else { - login.put1(16); + login.write8(16); } - login.put1(out.position + 36 + 1 + 1 + 2); - login.put1(255); - login.put2(317); - login.put1(lowmem ? 1 : 0); + login.write8(out.position + 36 + 1 + 1 + 2); + login.write8(255); + login.write16(317); + login.write8(lowmem ? 1 : 0); for (int l1 = 0; l1 < 9; l1++) { - login.put4(archiveChecksum[l1]); + login.write32(archiveChecksum[l1]); } - login.put(out.data, 0, out.position); + login.writeBytes(out.data, 0, out.position); out.random = new ISAACRandom(seed); for (int j2 = 0; j2 < 4; j2++) { seed[j2] += 50; @@ -6841,29 +6841,29 @@ public class Game extends GameShell { int startZ = bfsStepZ[length]; if (type == 0) { - out.putOp(164); - out.put1(count + count + 3); + out.writeOp(164); + out.write8(count + count + 3); } else if (type == 1) { - out.putOp(248); - out.put1(count + count + 3 + 14); + out.writeOp(248); + out.write8(count + count + 3 + 14); } else if (type == 2) { - out.putOp(98); - out.put1(count + count + 3); + out.writeOp(98); + out.write8(count + count + 3); } - out.put2LEA(startX + sceneBaseTileX); + out.write16LEA(startX + sceneBaseTileX); flagSceneTileX = bfsStepX[0]; flagSceneTileZ = bfsStepZ[0]; for (int i = 1; i < count; i++) { length--; - out.put1(bfsStepX[length] - startX); - out.put1(bfsStepZ[length] - startZ); + out.write8(bfsStepX[length] - startX); + out.write8(bfsStepZ[length] - startZ); } - out.put2LE(startZ + sceneBaseTileZ); - out.put1C((super.actionKey[5] != 1) ? 0 : 1); + out.write16LE(startZ + sceneBaseTileZ); + out.write8C((super.actionKey[5] != 1) ? 0 : 1); return true; } @@ -6874,16 +6874,16 @@ public class Game extends GameShell { for (int j = 0; j < anInt893; j++) { int k = anIntArray894[j]; NPCEntity npc = npcs[k]; - int l = buffer.get1U(); + int l = buffer.read8U(); if ((l & 0x10) != 0) { - int seqID = buffer.get2ULE(); + int seqID = buffer.read16ULE(); if (seqID == 65535) { seqID = -1; } - int delay = buffer.get1U(); + int delay = buffer.read8U(); if ((seqID == npc.primarySeqID) && (seqID != -1)) { int style = SeqType.instances[seqID].replayStyle; @@ -6907,16 +6907,16 @@ public class Game extends GameShell { } } if ((l & 8) != 0) { - int j1 = buffer.get1UA(); - int j2 = buffer.get1UC(); + int j1 = buffer.read8UA(); + int j2 = buffer.read8UC(); npc.method447(j2, j1, loopCycle); npc.combatCycle = loopCycle + 300; - npc.health = buffer.get1UA(); - npc.totalHealth = buffer.get1U(); + npc.health = buffer.read8UA(); + npc.totalHealth = buffer.read8U(); } if ((l & 0x80) != 0) { - npc.spotanim = buffer.get2U(); - int k1 = buffer.get4(); + npc.spotanim = buffer.read16U(); + int k1 = buffer.read32(); npc.spotanimY = k1 >> 16; npc.anInt1523 = loopCycle + (k1 & 0xffff); npc.spotanimFrame = 0; @@ -6929,25 +6929,25 @@ public class Game extends GameShell { } } if ((l & 0x20) != 0) { - npc.index = buffer.get2U(); + npc.index = buffer.read16U(); if (npc.index == 65535) { npc.index = -1; } } if ((l & 1) != 0) { - npc.chat = buffer.getString(); + npc.chat = buffer.readString(); npc.chatTimer = 100; } if ((l & 0x40) != 0) { - int l1 = buffer.get1UC(); - int k2 = buffer.get1US(); + int l1 = buffer.read8UC(); + int k2 = buffer.read8US(); npc.method447(k2, l1, loopCycle); npc.combatCycle = loopCycle + 300; - npc.health = buffer.get1US(); - npc.totalHealth = buffer.get1UC(); + npc.health = buffer.read8US(); + npc.totalHealth = buffer.read8UC(); } if ((l & 2) != 0) { - npc.type = NPCType.get(buffer.get2ULEA()); + npc.type = NPCType.get(buffer.read16ULEA()); npc.size = npc.type.size; npc.turnSpeed = npc.type.turnSpeed; npc.seqWalkID = npc.type.seqWalkID; @@ -6957,8 +6957,8 @@ public class Game extends GameShell { npc.seqStandID = npc.type.seqStandID; } if ((l & 4) != 0) { - npc.faceTileX = buffer.get2ULE(); - npc.faceTileZ = buffer.get2ULE(); + npc.faceTileX = buffer.read16ULE(); + npc.faceTileZ = buffer.read16ULE(); } } } @@ -7235,7 +7235,7 @@ public class Game extends GameShell { public void method91(Buffer buffer, int i) { while ((buffer.bitPosition + 10) < (i * 8)) { - int j = buffer.getBits(11); + int j = buffer.readN(11); if (j == 2047) { break; } @@ -7248,16 +7248,16 @@ public class Game extends GameShell { playerIndices[playerCount++] = j; PlayerEntity player = players[j]; player.anInt1537 = loopCycle; - int k = buffer.getBits(1); + int k = buffer.readN(1); if (k == 1) { anIntArray894[anInt893++] = j; } - int l = buffer.getBits(1); - int i1 = buffer.getBits(5); + int l = buffer.readN(1); + int i1 = buffer.readN(5); if (i1 > 15) { i1 -= 32; } - int j1 = buffer.getBits(5); + int j1 = buffer.readN(5); if (j1 > 15) { j1 -= 32; } @@ -7287,17 +7287,17 @@ public class Game extends GameShell { int j2 = (localPlayer.z - l1) >> 7; boolean flag1 = tryMove(1, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], i2, j2, 0, 0, 0, 0, 0, true); if (flag1) { - out.put1(x); - out.put1(y); - out.put2(orbitCameraYaw); - out.put1(57); - out.put1(minimapAnticheatAngle); - out.put1(minimapZoom); - out.put1(89); - out.put2(localPlayer.x); - out.put2(localPlayer.z); - out.put1(tryMoveNearest); - out.put1(63); + out.write8(x); + out.write8(y); + out.write16(orbitCameraYaw); + out.write8(57); + out.write8(minimapAnticheatAngle); + out.write8(minimapZoom); + out.write8(89); + out.write16(localPlayer.x); + out.write16(localPlayer.z); + out.write8(tryMoveNearest); + out.write8(63); } } } @@ -7861,8 +7861,8 @@ public class Game extends GameShell { } if ((flashingTab != -1) && (flashingTab == selectedTab)) { flashingTab = -1; - out.putOp(120); - out.put1(selectedTab); + out.writeOp(120); + out.write8(selectedTab); } redrawSideicons = false; areaBackhmid1.bind(); @@ -8429,19 +8429,19 @@ public class Game extends GameShell { public void method107(int masks, int j, Buffer buffer, PlayerEntity player) { if ((masks & 0x400) != 0) { - player.forceMoveStartSceneTileX = buffer.get1US(); - player.forceMoveStartSceneTileZ = buffer.get1US(); - player.forceMoveEndSceneTileX = buffer.get1US(); - player.forceMoveEndSceneTileZ = buffer.get1US(); - player.forceMoveEndCycle = buffer.get2ULEA() + loopCycle; - player.forceMoveStartCycle = buffer.get2UA() + loopCycle; - player.forceMoveFaceDirection = buffer.get1US(); + player.forceMoveStartSceneTileX = buffer.read8US(); + player.forceMoveStartSceneTileZ = buffer.read8US(); + player.forceMoveEndSceneTileX = buffer.read8US(); + player.forceMoveEndSceneTileZ = buffer.read8US(); + player.forceMoveEndCycle = buffer.read16ULEA() + loopCycle; + player.forceMoveStartCycle = buffer.read16UA() + loopCycle; + player.forceMoveFaceDirection = buffer.read8US(); player.resetPath(); } if ((masks & 0x100) != 0) { - player.spotanim = buffer.get2ULE(); - int k = buffer.get4(); + player.spotanim = buffer.read16ULE(); + int k = buffer.read32(); player.spotanimY = k >> 16; player.anInt1523 = loopCycle + (k & 0xffff); player.spotanimFrame = 0; @@ -8455,13 +8455,13 @@ public class Game extends GameShell { } if ((masks & 8) != 0) { - int seqID = buffer.get2ULE(); + int seqID = buffer.read16ULE(); if (seqID == 65535) { seqID = -1; } - int delay = buffer.get1UC(); + int delay = buffer.read8UC(); if ((seqID == player.primarySeqID) && (seqID != -1)) { int style = SeqType.instances[seqID].replayStyle; @@ -8487,7 +8487,7 @@ public class Game extends GameShell { } if ((masks & 4) != 0) { - player.chat = buffer.getString(); + player.chat = buffer.readString(); if (player.chat.charAt(0) == '~') { player.chat = player.chat.substring(1); addMessage(2, player.name, player.chat); @@ -8500,9 +8500,9 @@ public class Game extends GameShell { } if ((masks & 0x80) != 0) { - int colorStyle = buffer.get2ULE(); - int role = buffer.get1U(); - int length = buffer.get1UC(); + int colorStyle = buffer.read16ULE(); + int role = buffer.read8U(); + int length = buffer.read8UC(); int start = buffer.position; if ((player.name != null) && player.visible) { @@ -8522,7 +8522,7 @@ public class Game extends GameShell { if (!ignore && (overrideChat == 0)) { try { chatBuffer.position = 0; - buffer.getReversed(chatBuffer.data, 0, length); + buffer.getBytesReversed(chatBuffer.data, 0, length); chatBuffer.position = 0; String chat = ChatCompression.unpack(length, chatBuffer); @@ -8549,38 +8549,38 @@ public class Game extends GameShell { } if ((masks & 1) != 0) { - player.index = buffer.get2ULE(); + player.index = buffer.read16ULE(); if (player.index == 65535) { player.index = -1; } } if ((masks & 0x10) != 0) { - int j1 = buffer.get1UC(); + int j1 = buffer.read8UC(); byte[] abyte0 = new byte[j1]; Buffer buffer_1 = new Buffer(abyte0); - buffer.get(abyte0, 0, j1); + buffer.readBytes(abyte0, 0, j1); aBufferArray895[j] = buffer_1; player.method451(buffer_1); } if ((masks & 2) != 0) { - player.faceTileX = buffer.get2ULEA(); - player.faceTileZ = buffer.get2ULE(); + player.faceTileX = buffer.read16ULEA(); + player.faceTileZ = buffer.read16ULE(); } if ((masks & 0x20) != 0) { - int k1 = buffer.get1U(); - int k2 = buffer.get1UA(); + int k1 = buffer.read8U(); + int k2 = buffer.read8UA(); player.method447(k2, k1, loopCycle); player.combatCycle = loopCycle + 300; - player.health = buffer.get1UC(); - player.totalHealth = buffer.get1U(); + player.health = buffer.read8UC(); + player.totalHealth = buffer.read8U(); } if ((masks & 0x200) != 0) { - int l1 = buffer.get1U(); - int l2 = buffer.get1US(); + int l1 = buffer.read8U(); + int l2 = buffer.read8US(); player.method447(l2, l1, loopCycle); player.combatCycle = loopCycle + 300; - player.health = buffer.get1U(); - player.totalHealth = buffer.get1UC(); + player.health = buffer.read8U(); + player.totalHealth = buffer.read8UC(); } } @@ -8763,8 +8763,8 @@ public class Game extends GameShell { } ignoreName37[ignoreCount++] = name37; redrawInvback = true; - out.putOp(133); - out.put8(name37); + out.writeOp(133); + out.write64(name37); } public void updatePlayers() { @@ -8887,44 +8887,44 @@ public class Game extends GameShell { public void method117(Buffer buffer) { buffer.accessBits(); - int j = buffer.getBits(1); + int j = buffer.readN(1); if (j == 0) { return; } - int k = buffer.getBits(2); + int k = buffer.readN(2); if (k == 0) { anIntArray894[anInt893++] = LOCAL_PLAYER_INDEX; return; } if (k == 1) { - int l = buffer.getBits(3); + int l = buffer.readN(3); localPlayer.method448(false, l); - int k1 = buffer.getBits(1); + int k1 = buffer.readN(1); if (k1 == 1) { anIntArray894[anInt893++] = LOCAL_PLAYER_INDEX; } return; } if (k == 2) { - int i1 = buffer.getBits(3); + int i1 = buffer.readN(3); localPlayer.method448(true, i1); - int l1 = buffer.getBits(3); + int l1 = buffer.readN(3); localPlayer.method448(true, l1); - int j2 = buffer.getBits(1); + int j2 = buffer.readN(1); if (j2 == 1) { anIntArray894[anInt893++] = LOCAL_PLAYER_INDEX; } return; } if (k == 3) { - currentLevel = buffer.getBits(2); - int j1 = buffer.getBits(1); - int i2 = buffer.getBits(1); + currentLevel = buffer.readN(2); + int j1 = buffer.readN(1); + int i2 = buffer.readN(1); if (i2 == 1) { anIntArray894[anInt893++] = LOCAL_PLAYER_INDEX; } - int k2 = buffer.getBits(7); - int l2 = buffer.getBits(7); + int k2 = buffer.readN(7); + int l2 = buffer.readN(7); localPlayer.move(l2, k2, j1 == 1); } } @@ -9127,8 +9127,8 @@ public class Game extends GameShell { for (int k = j; k < ignoreCount; k++) { ignoreName37[k] = ignoreName37[k + 1]; } - out.putOp(74); - out.put8(name37); + out.writeOp(74); + out.write64(name37); return; } } @@ -9680,7 +9680,7 @@ public class Game extends GameShell { } public void method134(Buffer buffer) { - int j = buffer.getBits(8); + int j = buffer.readN(8); if (j < playerCount) { for (int k = j; k < playerCount; k++) { anIntArray840[anInt839++] = playerIndices[k]; @@ -9694,12 +9694,12 @@ public class Game extends GameShell { for (int l = 0; l < j; l++) { int i1 = playerIndices[l]; PlayerEntity player = players[i1]; - int j1 = buffer.getBits(1); + int j1 = buffer.readN(1); if (j1 == 0) { playerIndices[playerCount++] = i1; player.anInt1537 = loopCycle; } else { - int k1 = buffer.getBits(2); + int k1 = buffer.readN(2); if (k1 == 0) { playerIndices[playerCount++] = i1; player.anInt1537 = loopCycle; @@ -9707,20 +9707,20 @@ public class Game extends GameShell { } else if (k1 == 1) { playerIndices[playerCount++] = i1; player.anInt1537 = loopCycle; - int l1 = buffer.getBits(3); + int l1 = buffer.readN(3); player.method448(false, l1); - int j2 = buffer.getBits(1); + int j2 = buffer.readN(1); if (j2 == 1) { anIntArray894[anInt893++] = i1; } } else if (k1 == 2) { playerIndices[playerCount++] = i1; player.anInt1537 = loopCycle; - int i2 = buffer.getBits(3); + int i2 = buffer.readN(3); player.method448(true, i2); - int k2 = buffer.getBits(3); + int k2 = buffer.readN(3); player.method448(true, k2); - int l2 = buffer.getBits(1); + int l2 = buffer.readN(1); if (l2 == 1) { anIntArray894[anInt893++] = i1; } @@ -9841,12 +9841,12 @@ public class Game extends GameShell { public void readZonePacket(Buffer buffer, int opcode) { // update obj if (opcode == 84) { - int pos = buffer.get1U(); + int pos = buffer.read8U(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); - int objID = buffer.get2U(); - int objAmount = buffer.get2U(); - int newAmount = buffer.get2U(); + int objID = buffer.read16U(); + int objAmount = buffer.read16U(); + int newAmount = buffer.read16U(); if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104)) { DoublyLinkedList stacks = levelObjStacks[currentLevel][x][z]; if (stacks != null) { @@ -9865,11 +9865,11 @@ public class Game extends GameShell { // emit sound if (opcode == 105) { - int pos = buffer.get1U(); + int pos = buffer.read8U(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); - int waveID = buffer.get2U(); - int info = buffer.get1U(); + int waveID = buffer.read16U(); + int info = buffer.read8U(); int maxDist = (info >> 4) & 0xf; int loopCount = info & 0b111; if ((localPlayer.pathTileX[0] >= (x - maxDist)) && (localPlayer.pathTileX[0] <= (x + maxDist)) && (localPlayer.pathTileZ[0] >= (z - maxDist)) && (localPlayer.pathTileZ[0] <= (z + maxDist)) && aBoolean848 && !lowmem && (waveCount < 50)) { @@ -9882,12 +9882,12 @@ public class Game extends GameShell { // reveal obj (this would already be visible to the local player if it belongs to them) if (opcode == 215) { - int objID = buffer.get2UA(); - int pos = buffer.get1US(); + int objID = buffer.read16UA(); + int pos = buffer.read8US(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); - int ownerPID = buffer.get2UA(); - int objAmount = buffer.get2U(); + int ownerPID = buffer.read16UA(); + int objAmount = buffer.read16U(); if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104) && (ownerPID != localPID)) { ObjStackEntity obj = new ObjStackEntity(); obj.id = objID; @@ -9903,10 +9903,10 @@ public class Game extends GameShell { // remove obj if (opcode == 156) { - int pos = buffer.get1UA(); + int pos = buffer.read8UA(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); - int objID = buffer.get2U(); + int objID = buffer.read16U(); if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104)) { DoublyLinkedList list = levelObjStacks[currentLevel][x][z]; if (list != null) { @@ -9928,14 +9928,14 @@ public class Game extends GameShell { // update loc if (opcode == 160) { - int pos = buffer.get1US(); + int pos = buffer.read8US(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); - int info = buffer.get1US(); + int info = buffer.read8US(); int kind = info >> 2; int rotation = info & 3; int classID = LOC_KIND_TO_CLASS_ID[kind]; - int seqID = buffer.get2UA(); + int seqID = buffer.read16UA(); if ((x < 0) || (z < 0) || (x >= 103) || (z >= 103)) { return; @@ -9993,21 +9993,21 @@ public class Game extends GameShell { // attach loc to player if (opcode == 147) { - int pos = buffer.get1US(); + int pos = buffer.read8US(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); - int pid = buffer.get2U(); - byte maxX = buffer.get1S(); - int delay = buffer.get2ULE(); - byte maxZ = buffer.get1C(); - int duration = buffer.get2U(); - int info = buffer.get1US(); + int pid = buffer.read16U(); + byte maxX = buffer.read8S(); + int delay = buffer.read16ULE(); + byte maxZ = buffer.read8C(); + int duration = buffer.read16U(); + int info = buffer.read8US(); int kind = info >> 2; int rotation = info & 3; int classID = LOC_KIND_TO_CLASS_ID[kind]; - byte minX = buffer.get1(); - int locID = buffer.get2U(); - byte minZ = buffer.get1C(); + byte minX = buffer.read8(); + int locID = buffer.read16U(); + byte minZ = buffer.read8C(); PlayerEntity player; if (pid == localPID) { @@ -10065,11 +10065,11 @@ public class Game extends GameShell { // add loc (indefinitely) if (opcode == 151) { - int pos = buffer.get1UA(); + int pos = buffer.read8UA(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); - int id = buffer.get2ULE(); - int info = buffer.get1US(); + int id = buffer.read16ULE(); + int info = buffer.read8US(); int kind = info >> 2; int rotation = info & 3; int classID = LOC_KIND_TO_CLASS_ID[kind]; @@ -10081,12 +10081,12 @@ public class Game extends GameShell { // append spotanim if (opcode == 4) { - int pos = buffer.get1U(); + int pos = buffer.read8U(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); - int id = buffer.get2U(); - int y = buffer.get1U(); - int delay = buffer.get2U(); + int id = buffer.read16U(); + int y = buffer.read8U(); + int delay = buffer.read16U(); if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104)) { x = (x * 128) + 64; @@ -10099,9 +10099,9 @@ public class Game extends GameShell { // append item if (opcode == 44) { - int id = buffer.get2ULEA(); - int amount = buffer.get2U(); - int pos = buffer.get1U(); + int id = buffer.read16ULEA(); + int amount = buffer.read16U(); + int pos = buffer.read8U(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104)) { @@ -10119,11 +10119,11 @@ public class Game extends GameShell { // remove loc (indefinitely) if (opcode == 101) { - int info = buffer.get1UC(); + int info = buffer.read8UC(); int kind = info >> 2; int rotation = info & 3; int classID = LOC_KIND_TO_CLASS_ID[kind]; - int pos = buffer.get1U(); + int pos = buffer.read8U(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104)) { @@ -10134,19 +10134,19 @@ public class Game extends GameShell { // append projectile if (opcode == 117) { - int pos = buffer.get1U(); + int pos = buffer.read8U(); int srcX = baseX + ((pos >> 4) & 7); int srcZ = baseZ + (pos & 7); - int dstX = srcX + buffer.get1(); - int dstZ = srcZ + buffer.get1(); - int targetID = buffer.get2(); - int spotanimID = buffer.get2U(); - int srcY = buffer.get1U() * 4; - int dstY = buffer.get1U() * 4; - int delay = buffer.get2U(); - int duration = buffer.get2U(); - int peakPitch = buffer.get1U(); - int arcSize = buffer.get1U(); + int dstX = srcX + buffer.read8(); + int dstZ = srcZ + buffer.read8(); + int targetID = buffer.read16(); + int spotanimID = buffer.read16U(); + int srcY = buffer.read8U() * 4; + int dstY = buffer.read8U() * 4; + int delay = buffer.read16U(); + int duration = buffer.read16U(); + int peakPitch = buffer.read8U(); + int arcSize = buffer.read8U(); if ((srcX >= 0) && (srcZ >= 0) && (srcX < 104) && (srcZ < 104) && (dstX >= 0) && (dstZ >= 0) && (dstX < 104) && (dstZ < 104) && (spotanimID != 65535)) { srcX = (srcX * 128) + 64; srcZ = (srcZ * 128) + 64; @@ -10161,7 +10161,7 @@ public class Game extends GameShell { public void method139(Buffer buffer) { buffer.accessBits(); - int k = buffer.getBits(8); + int k = buffer.readN(8); if (k < npcCount) { for (int l = k; l < npcCount; l++) { anIntArray840[anInt839++] = npcIndices[l]; @@ -10175,12 +10175,12 @@ public class Game extends GameShell { for (int i1 = 0; i1 < k; i1++) { int j1 = npcIndices[i1]; NPCEntity npc = npcs[j1]; - int k1 = buffer.getBits(1); + int k1 = buffer.readN(1); if (k1 == 0) { npcIndices[npcCount++] = j1; npc.anInt1537 = loopCycle; } else { - int l1 = buffer.getBits(2); + int l1 = buffer.readN(2); if (l1 == 0) { npcIndices[npcCount++] = j1; npc.anInt1537 = loopCycle; @@ -10188,20 +10188,20 @@ public class Game extends GameShell { } else if (l1 == 1) { npcIndices[npcCount++] = j1; npc.anInt1537 = loopCycle; - int i2 = buffer.getBits(3); + int i2 = buffer.readN(3); npc.method448(false, i2); - int k2 = buffer.getBits(1); + int k2 = buffer.readN(1); if (k2 == 1) { anIntArray894[anInt893++] = j1; } } else if (l1 == 2) { npcIndices[npcCount++] = j1; npc.anInt1537 = loopCycle; - int j2 = buffer.getBits(3); + int j2 = buffer.readN(3); npc.method448(true, j2); - int l2 = buffer.getBits(3); + int l2 = buffer.readN(3); npc.method448(true, l2); - int i3 = buffer.getBits(1); + int i3 = buffer.readN(1); if (i3 == 1) { anIntArray894[anInt893++] = j1; } @@ -10513,7 +10513,7 @@ public class Game extends GameShell { if (available > 1) { connection.read(in.data, 0, 2); in.position = 0; - psize = in.get2U(); + psize = in.read16U(); available -= 2; } else { return false; @@ -10541,11 +10541,11 @@ public class Game extends GameShell { // login interface if (ptype == 176) { - daysSinceRecoveriesChanged = in.get1UC(); - unreadMessages = in.get2UA(); - warnMembersInNonMembers = in.get1U(); - lastAddress = in.get4ME(); - daysSinceLastLogin = in.get2U(); + daysSinceRecoveriesChanged = in.read8UC(); + unreadMessages = in.read16UA(); + warnMembersInNonMembers = in.read8U(); + lastAddress = in.read32ME(); + daysSinceLastLogin = in.read16U(); if ((lastAddress != 0) && (viewportComponentID == -1)) { Signlink.dnslookup(StringUtil.formatIPv4(lastAddress)); @@ -10571,8 +10571,8 @@ public class Game extends GameShell { // clear zone if (ptype == 64) { - baseX = in.get1UC(); - baseZ = in.get1US(); + baseX = in.read8UC(); + baseZ = in.read8US(); for (int x = baseX; x < (baseX + 8); x++) { for (int z = baseZ; z < (baseZ + 8); z++) { if (levelObjStacks[currentLevel][x][z] != null) { @@ -10592,7 +10592,7 @@ public class Game extends GameShell { // sets component to display player head if (ptype == 185) { - int id = in.get2ULEA(); + int id = in.read16ULEA(); Component.instances[id].modelCategory = 3; if (localPlayer.npcType == null) { Component.instances[id].modelID = (localPlayer.colors[0] << 25) + (localPlayer.colors[4] << 20) + (localPlayer.appearances[0] << 15) + (localPlayer.appearances[8] << 10) + (localPlayer.appearances[11] << 5) + localPlayer.appearances[1]; @@ -10615,7 +10615,7 @@ public class Game extends GameShell { // clear inventory if (ptype == 72) { - int id = in.get2ULE(); + int id = in.read16ULE(); Component component = Component.instances[id]; for (int slot = 0; slot < component.invSlotObjID.length; slot++) { component.invSlotObjID[slot] = -1; @@ -10629,7 +10629,7 @@ public class Game extends GameShell { if (ptype == 214) { ignoreCount = psize / 8; for (int j1 = 0; j1 < ignoreCount; j1++) { - ignoreName37[j1] = in.get8(); + ignoreName37[j1] = in.read64(); } ptype = -1; return true; @@ -10638,11 +10638,11 @@ public class Game extends GameShell { // move camera if (ptype == 166) { cinematic = true; - cinematicSrcLocalTileX = in.get1U(); - cinematicSrcLocalTileZ = in.get1U(); - cinematicSrcHeight = in.get2U(); - cinematicMoveSpeed = in.get1U(); - cinematicMoveAcceleration = in.get1U(); + cinematicSrcLocalTileX = in.read8U(); + cinematicSrcLocalTileZ = in.read8U(); + cinematicSrcHeight = in.read16U(); + cinematicMoveSpeed = in.read8U(); + cinematicMoveAcceleration = in.read8U(); if (cinematicMoveAcceleration >= 100) { cameraX = (cinematicSrcLocalTileX * 128) + 64; @@ -10657,11 +10657,11 @@ public class Game extends GameShell { // look at if (ptype == 177) { cinematic = true; - cinematicDstLocalTileX = in.get1U(); - cinematicDstLocalTileZ = in.get1U(); - cinematicDstHeight = in.get2U(); - cinematicRotateSpeed = in.get1U(); - cinematicRotateAcceleration = in.get1U(); + cinematicDstLocalTileX = in.read8U(); + cinematicDstLocalTileZ = in.read8U(); + cinematicDstHeight = in.read16U(); + cinematicRotateSpeed = in.read8U(); + cinematicRotateAcceleration = in.read8U(); if (cinematicRotateAcceleration >= 100) { int sceneX = (cinematicDstLocalTileX * 128) + 64; @@ -10687,9 +10687,9 @@ public class Game extends GameShell { // update skill if (ptype == 134) { redrawInvback = true; - int skill = in.get1U(); - int exp = in.get4RME(); - int level = in.get1U(); + int skill = in.read8U(); + int exp = in.read32RME(); + int level = in.read8U(); skillExperience[skill] = exp; skillLevel[skill] = level; skillBaseLevel[skill] = 1; @@ -10704,8 +10704,8 @@ public class Game extends GameShell { // set tab component if (ptype == 71) { - int component = in.get2U(); - int tab = in.get1UA(); + int component = in.read16U(); + int tab = in.read8UA(); if (component == 65535) { component = -1; } @@ -10716,7 +10716,7 @@ public class Game extends GameShell { return true; } if (ptype == 74) { - int next = in.get2ULE(); + int next = in.read16ULE(); if (next == 65535) { next = -1; } @@ -10730,8 +10730,8 @@ public class Game extends GameShell { return true; } if (ptype == 121) { - int next = in.get2ULEA(); - int delay = in.get2UA(); + int next = in.read16ULEA(); + int delay = in.read16UA(); if (midiActive && !lowmem) { music = next; musicFading = false; @@ -10748,9 +10748,9 @@ public class Game extends GameShell { } if (ptype == 70) { - int x = in.get2(); - int z = in.get2LE(); - int id = in.get2ULE(); + int x = in.read16(); + int z = in.read16LE(); + int id = in.read16ULE(); Component cmp = Component.instances[id]; cmp.x = x; cmp.y = z; @@ -10763,21 +10763,21 @@ public class Game extends GameShell { int zoneZ = sceneCenterZoneZ; if (ptype == 73) { - zoneX = in.get2UA(); - zoneZ = in.get2U(); + zoneX = in.read16UA(); + zoneZ = in.read16U(); sceneInstanced = false; } // instanced scenes describe the pieces that make them up. if (ptype == 241) { - zoneZ = in.get2UA(); + zoneZ = in.read16UA(); in.accessBits(); for (int level = 0; level < 4; level++) { for (int cx = 0; cx < 13; cx++) { for (int cz = 0; cz < 13; cz++) { - if (in.getBits(1) == 1) { - levelChunkBitset[level][cx][cz] = in.getBits(26); + if (in.readN(1) == 1) { + levelChunkBitset[level][cx][cz] = in.readN(26); } else { levelChunkBitset[level][cx][cz] = -1; } @@ -10786,7 +10786,7 @@ public class Game extends GameShell { } in.accessBytes(); - zoneX = in.get2U(); + zoneX = in.read16U(); sceneInstanced = true; } @@ -10998,7 +10998,7 @@ public class Game extends GameShell { // set viewport overlay if (ptype == 208) { - int componentID = in.get2LE(); + int componentID = in.read16LE(); if (componentID >= 0) { resetParentComponentSeq(componentID); } @@ -11009,15 +11009,15 @@ public class Game extends GameShell { // set minimap state if (ptype == 99) { - minimapState = in.get1U(); + minimapState = in.read8U(); ptype = -1; return true; } // set npc head model if (ptype == 75) { - int npcID = in.get2ULEA(); - int componentID = in.get2ULEA(); + int npcID = in.read16ULEA(); + int componentID = in.read16ULEA(); Component.instances[componentID].modelCategory = 2; Component.instances[componentID].modelID = npcID; ptype = -1; @@ -11025,25 +11025,25 @@ public class Game extends GameShell { } if (ptype == 114) { - systemUpdateTimer = in.get2ULE() * 30; + systemUpdateTimer = in.read16ULE() * 30; ptype = -1; return true; } if (ptype == 60) { - baseZ = in.get1U(); - baseX = in.get1UC(); + baseZ = in.read8U(); + baseX = in.read8UC(); while (in.position < psize) { - int opcode = in.get1U(); + int opcode = in.read8U(); readZonePacket(in, opcode); } ptype = -1; return true; } if (ptype == 35) { - int component = in.get1U(); - int k11 = in.get1U(); - int j17 = in.get1U(); - int k21 = in.get1U(); + int component = in.read8U(); + int k11 = in.read8U(); + int j17 = in.read8U(); + int k21 = in.read8U(); adjustCameraComponent[component] = true; adjustCameraShakeScale[component] = k11; cameraWobbleScale[component] = j17; @@ -11053,9 +11053,9 @@ public class Game extends GameShell { return true; } if (ptype == 174) { - int i4 = in.get2U(); - int l11 = in.get1U(); - int k17 = in.get2U(); + int i4 = in.read16U(); + int l11 = in.read8U(); + int k17 = in.read16U(); if (aBoolean848 && !lowmem && (waveCount < 50)) { waveIDs[waveCount] = i4; waveLoops[waveCount] = l11; @@ -11066,9 +11066,9 @@ public class Game extends GameShell { return true; } if (ptype == 104) { - int j4 = in.get1UC(); - int i12 = in.get1UA(); - String s6 = in.getString(); + int j4 = in.read8UC(); + int i12 = in.read8UA(); + String s6 = in.readString(); if ((j4 >= 1) && (j4 <= 5)) { if (s6.equalsIgnoreCase("null")) { s6 = null; @@ -11087,7 +11087,7 @@ public class Game extends GameShell { } if (ptype == 253) { - String s = in.getString(); + String s = in.readString(); if (s.endsWith(":tradereq:")) { String name = s.substring(0, s.indexOf(":")); @@ -11160,8 +11160,8 @@ public class Game extends GameShell { } if (ptype == 50) { - long l4 = in.get8(); - int i18 = in.get1U(); + long l4 = in.read64(); + int i18 = in.read8U(); String s7 = StringUtil.formatName(StringUtil.fromBase37(l4)); for (int k24 = 0; k24 < friendCount; k24++) { if (l4 != friendName37[k24]) { @@ -11212,14 +11212,14 @@ public class Game extends GameShell { if (selectedTab == 12) { redrawInvback = true; } - energy = in.get1U(); + energy = in.read8U(); ptype = -1; return true; } if (ptype == 254) { - hintType = in.get1U(); + hintType = in.read8U(); if (hintType == 1) { - hintNPC = in.get2U(); + hintNPC = in.read16U(); } if ((hintType >= 2) && (hintType <= 6)) { if (hintType == 2) { @@ -11243,19 +11243,19 @@ public class Game extends GameShell { hintOffsetZ = 128; } hintType = 2; - hintTileX = in.get2U(); - hintTileZ = in.get2U(); - hintHeight = in.get1U(); + hintTileX = in.read16U(); + hintTileZ = in.read16U(); + hintHeight = in.read8U(); } if (hintType == 10) { - hintPlayer = in.get2U(); + hintPlayer = in.read16U(); } ptype = -1; return true; } if (ptype == 248) { - int i5 = in.get2UA(); - int k12 = in.get2U(); + int i5 = in.read16UA(); + int k12 = in.read16U(); if (chatbackComponentID != -1) { chatbackComponentID = -1; redrawChatback = true; @@ -11273,8 +11273,8 @@ public class Game extends GameShell { return true; } if (ptype == 79) { - int j5 = in.get2ULE(); - int l12 = in.get2UA(); + int j5 = in.read16ULE(); + int l12 = in.read16UA(); Component component_3 = Component.instances[j5]; if ((component_3 != null) && (component_3.type == 0)) { if (l12 < 0) { @@ -11302,9 +11302,9 @@ public class Game extends GameShell { // add chat message if (ptype == 196) { - long name37 = in.get8(); - int messageID = in.get4(); - int role = in.get1U(); + long name37 = in.read64(); + int messageID = in.read32(); + int role = in.read8U(); boolean ignore = false; for (int i = 0; i < 100; i++) { if (messageIDs[i] == messageID) { @@ -11348,15 +11348,15 @@ public class Game extends GameShell { // set base if (ptype == 85) { - baseZ = in.get1UC(); - baseX = in.get1UC(); + baseZ = in.read8UC(); + baseX = in.read8UC(); ptype = -1; return true; } // flash tab if (ptype == 24) { - flashingTab = in.get1US(); + flashingTab = in.read8US(); if (flashingTab == selectedTab) { if (flashingTab == 3) { selectedTab = 1; @@ -11370,9 +11370,9 @@ public class Game extends GameShell { } if (ptype == 246) { - int componentID = in.get2ULE(); - int zoom = in.get2U(); - int objID = in.get2U(); + int componentID = in.read16ULE(); + int zoom = in.read16U(); + int objID = in.read16U(); if (objID == 65535) { Component.instances[componentID].modelCategory = 0; } else { @@ -11388,14 +11388,14 @@ public class Game extends GameShell { } if (ptype == 171) { - boolean hidden = in.get1U() == 1; - int componentID = in.get2U(); + boolean hidden = in.read8U() == 1; + int componentID = in.read16U(); Component.instances[componentID].hidden = hidden; ptype = -1; return true; } if (ptype == 142) { - int componentID = in.get2ULE(); + int componentID = in.read16ULE(); resetParentComponentSeq(componentID); if (chatbackComponentID != -1) { chatbackComponentID = -1; @@ -11414,8 +11414,8 @@ public class Game extends GameShell { return true; } if (ptype == 126) { - String s1 = in.getString(); - int k13 = in.get2UA(); + String s1 = in.readString(); + int k13 = in.read16UA(); if ((k13 >= 0) && (k13 < Component.instances.length)) { Component component = Component.instances[k13]; if (component != null) { @@ -11429,9 +11429,9 @@ public class Game extends GameShell { return true; } if (ptype == 206) { - publicChatSetting = in.get1U(); - privateChatSetting = in.get1U(); - tradeChatSetting = in.get1U(); + publicChatSetting = in.read8U(); + privateChatSetting = in.read8U(); + tradeChatSetting = in.read8U(); redrawPrivacySettings = true; redrawChatback = true; ptype = -1; @@ -11441,21 +11441,21 @@ public class Game extends GameShell { if (selectedTab == 12) { redrawInvback = true; } - weightCarried = in.get2(); + weightCarried = in.read16(); ptype = -1; return true; } if (ptype == 8) { - int componentID = in.get2ULEA(); - int modelID = in.get2U(); + int componentID = in.read16ULEA(); + int modelID = in.read16U(); Component.instances[componentID].modelCategory = 1; Component.instances[componentID].modelID = modelID; ptype = -1; return true; } if (ptype == 122) { - int componentID = in.get2ULEA(); - int rgb555 = in.get2ULEA(); + int componentID = in.read16ULEA(); + int rgb555 = in.read16ULEA(); int r = (rgb555 >> 10) & 0x1f; int g = (rgb555 >> 5) & 0x1f; int b = rgb555 & 0x1f; @@ -11467,20 +11467,20 @@ public class Game extends GameShell { // set inventory if (ptype == 53) { redrawInvback = true; - int componentID = in.get2U(); + int componentID = in.read16U(); Component component = Component.instances[componentID]; - int count = in.get2U(); + int count = in.read16U(); for (int slot = 0; slot < count; slot++) { - int amount = in.get1U(); + int amount = in.read8U(); if (amount == 255) { - amount = in.get4ME(); + amount = in.read32ME(); } if (slot >= component.invSlotObjID.length) { - in.get2ULEA(); + in.read16ULEA(); } else { - component.invSlotObjID[slot] = in.get2ULEA(); + component.invSlotObjID[slot] = in.read16ULEA(); component.invSlotAmount[slot] = amount; } } @@ -11496,10 +11496,10 @@ public class Game extends GameShell { // set model rotation and zoom if (ptype == 230) { - int zoom = in.get2UA(); - int componentID = in.get2U(); - int pitch = in.get2U(); - int yaw = in.get2ULEA(); + int zoom = in.read16UA(); + int componentID = in.read16U(); + int pitch = in.read16U(); + int yaw = in.read16ULEA(); Component.instances[componentID].modelPitch = pitch; Component.instances[componentID].modelYaw = yaw; Component.instances[componentID].modelZoom = zoom; @@ -11509,15 +11509,15 @@ public class Game extends GameShell { // set social state if (ptype == 221) { - socialState = in.get1U(); + socialState = in.read8U(); redrawInvback = true; ptype = -1; return true; } if (ptype == 249) { - anInt1046 = in.get1UA(); - localPID = in.get2ULEA(); + anInt1046 = in.read8UA(); + localPID = in.read16ULEA(); ptype = -1; return true; } @@ -11543,7 +11543,7 @@ public class Game extends GameShell { return true; } if (ptype == 97) { - int componentID = in.get2U(); + int componentID = in.read16U(); resetParentComponentSeq(componentID); if (invbackComponentID != -1) { invbackComponentID = -1; @@ -11564,14 +11564,14 @@ public class Game extends GameShell { return true; } if (ptype == 218) { - stickyChatbackComponentID = in.get2LEA(); + stickyChatbackComponentID = in.read16LEA(); redrawChatback = true; ptype = -1; return true; } if (ptype == 87) { - int j8 = in.get2ULE(); - int l14 = in.get4RME(); + int j8 = in.read16ULE(); + int l14 = in.read32RME(); anIntArray1045[j8] = l14; if (variables[j8] != l14) { variables[j8] = l14; @@ -11585,8 +11585,8 @@ public class Game extends GameShell { return true; } if (ptype == 36) { - int k8 = in.get2ULE(); - byte byte0 = in.get1(); + int k8 = in.read16ULE(); + byte byte0 = in.read8(); anIntArray1045[k8] = byte0; if (variables[k8] != byte0) { variables[k8] = byte0; @@ -11600,13 +11600,13 @@ public class Game extends GameShell { return true; } if (ptype == 61) { - multizone = in.get1U(); + multizone = in.read8U(); ptype = -1; return true; } if (ptype == 200) { - int l8 = in.get2U(); - int i15 = in.get2(); + int l8 = in.read16U(); + int i15 = in.read16(); Component component_4 = Component.instances[l8]; component_4.seqID = i15; if (i15 == -1) { @@ -11637,14 +11637,14 @@ public class Game extends GameShell { } if (ptype == 34) { redrawInvback = true; - int i9 = in.get2U(); + int i9 = in.read16U(); Component component_2 = Component.instances[i9]; while (in.position < psize) { - int j20 = in.getSmartU(); - int i23 = in.get2U(); - int l25 = in.get1U(); + int j20 = in.readSmartU(); + int i23 = in.read16U(); + int l25 = in.read8U(); if (l25 == 255) { - l25 = in.get4(); + l25 = in.read32(); } if ((j20 >= 0) && (j20 < component_2.invSlotObjID.length)) { component_2.invSlotObjID[j20] = i23; @@ -11660,14 +11660,14 @@ public class Game extends GameShell { return true; } if (ptype == 106) { - selectedTab = in.get1UC(); + selectedTab = in.read8UC(); redrawInvback = true; redrawSideicons = true; ptype = -1; return true; } if (ptype == 164) { - int j9 = in.get2ULE(); + int j9 = in.read16ULE(); resetParentComponentSeq(j9); if (invbackComponentID != -1) { invbackComponentID = -1; @@ -11801,7 +11801,7 @@ public class Game extends GameShell { } public void closeInterfaces() { - out.putOp(130); + out.writeOp(130); if (invbackComponentID != -1) { invbackComponentID = -1; redrawInvback = true; diff --git a/src/main/java/IDKType.java b/src/main/java/IDKType.java index e82c637..4f0d9d5 100644 --- a/src/main/java/IDKType.java +++ b/src/main/java/IDKType.java @@ -11,7 +11,7 @@ public class IDKType { public static void unpack(FileArchive archive) throws IOException { Buffer buffer = new Buffer(archive.read("idk.dat")); - count = buffer.get2U(); + count = buffer.read16U(); if (instances == null) { instances = new IDKType[count]; } @@ -35,26 +35,26 @@ public class IDKType { public void method536(Buffer buffer) { do { - int i = buffer.get1U(); + int i = buffer.read8U(); if (i == 0) { return; } if (i == 1) { - type = buffer.get1U(); + type = buffer.read8U(); } else if (i == 2) { - int j = buffer.get1U(); + int j = buffer.read8U(); modelIDs = new int[j]; for (int k = 0; k < j; k++) { - modelIDs[k] = buffer.get2U(); + modelIDs[k] = buffer.read16U(); } } else if (i == 3) { selectable = true; } else if ((i >= 40) && (i < 50)) { - colorSrc[i - 40] = buffer.get2U(); + colorSrc[i - 40] = buffer.read16U(); } else if ((i >= 50) && (i < 60)) { - colorDst[i - 50] = buffer.get2U(); + colorDst[i - 50] = buffer.read16U(); } else if ((i >= 60) && (i < 70)) { - headModelIDs[i - 60] = buffer.get2U(); + headModelIDs[i - 60] = buffer.read16U(); } else { System.out.println("Error unrecognised config code: " + i); } diff --git a/src/main/java/Image24.java b/src/main/java/Image24.java index 9850b22..39996b1 100644 --- a/src/main/java/Image24.java +++ b/src/main/java/Image24.java @@ -42,39 +42,39 @@ public class Image24 extends DoublyLinkedList.Node { public Image24(FileArchive archive, String file, int index) throws IOException { Buffer buffer = new Buffer(archive.read(file + ".dat")); Buffer buffer_1 = new Buffer(archive.read("index.dat")); - buffer_1.position = buffer.get2U(); - cropW = buffer_1.get2U(); - cropH = buffer_1.get2U(); - int j = buffer_1.get1U(); + buffer_1.position = buffer.read16U(); + cropW = buffer_1.read16U(); + cropH = buffer_1.read16U(); + int j = buffer_1.read8U(); int[] ai = new int[j]; for (int k = 0; k < (j - 1); k++) { - ai[k + 1] = buffer_1.get3(); + ai[k + 1] = buffer_1.read24(); if (ai[k + 1] == 0) { ai[k + 1] = 1; } } for (int l = 0; l < index; l++) { buffer_1.position += 2; - buffer.position += buffer_1.get2U() * buffer_1.get2U(); + buffer.position += buffer_1.read16U() * buffer_1.read16U(); buffer_1.position++; } - cropX = buffer_1.get1U(); - cropY = buffer_1.get1U(); - width = buffer_1.get2U(); - height = buffer_1.get2U(); - int layout = buffer_1.get1U(); + cropX = buffer_1.read8U(); + cropY = buffer_1.read8U(); + width = buffer_1.read16U(); + height = buffer_1.read16U(); + int layout = buffer_1.read8U(); int pixelLen = width * height; pixels = new int[pixelLen]; if (layout == 0) { for (int k1 = 0; k1 < pixelLen; k1++) { - pixels[k1] = ai[buffer.get1U()]; + pixels[k1] = ai[buffer.read8U()]; } return; } if (layout == 1) { for (int l1 = 0; l1 < width; l1++) { for (int i2 = 0; i2 < height; i2++) { - pixels[l1 + (i2 * width)] = ai[buffer.get1U()]; + pixels[l1 + (i2 * width)] = ai[buffer.read8U()]; } } } diff --git a/src/main/java/Image8.java b/src/main/java/Image8.java index 748762b..7a79b9c 100644 --- a/src/main/java/Image8.java +++ b/src/main/java/Image8.java @@ -14,36 +14,36 @@ public class Image8 { public Image8(FileArchive archive, String s, int i) throws IOException { Buffer buffer = new Buffer(archive.read(s + ".dat")); Buffer buffer_1 = new Buffer(archive.read("index.dat")); - buffer_1.position = buffer.get2U(); - cropW = buffer_1.get2U(); - cropH = buffer_1.get2U(); - int j = buffer_1.get1U(); + buffer_1.position = buffer.read16U(); + cropW = buffer_1.read16U(); + cropH = buffer_1.read16U(); + int j = buffer_1.read8U(); palette = new int[j]; for (int k = 0; k < (j - 1); k++) { - palette[k + 1] = buffer_1.get3(); + palette[k + 1] = buffer_1.read24(); } for (int l = 0; l < i; l++) { buffer_1.position += 2; - buffer.position += buffer_1.get2U() * buffer_1.get2U(); + buffer.position += buffer_1.read16U() * buffer_1.read16U(); buffer_1.position++; } - cropX = buffer_1.get1U(); - cropY = buffer_1.get1U(); - width = buffer_1.get2U(); - height = buffer_1.get2U(); - int i1 = buffer_1.get1U(); + cropX = buffer_1.read8U(); + cropY = buffer_1.read8U(); + width = buffer_1.read16U(); + height = buffer_1.read16U(); + int i1 = buffer_1.read8U(); int j1 = width * height; pixels = new byte[j1]; if (i1 == 0) { for (int k1 = 0; k1 < j1; k1++) { - pixels[k1] = buffer.get1(); + pixels[k1] = buffer.read8(); } return; } if (i1 == 1) { for (int l1 = 0; l1 < width; l1++) { for (int i2 = 0; i2 < height; i2++) { - pixels[l1 + (i2 * width)] = buffer.get1(); + pixels[l1 + (i2 * width)] = buffer.read8(); } } } diff --git a/src/main/java/LocType.java b/src/main/java/LocType.java index 29f1934..afe4f4d 100644 --- a/src/main/java/LocType.java +++ b/src/main/java/LocType.java @@ -54,12 +54,12 @@ public class LocType { public static void unpack(FileArchive archive) throws IOException { dat = new Buffer(archive.read("loc.dat")); Buffer buffer = new Buffer(archive.read("loc.idx")); - count = buffer.get2U(); + count = buffer.read16U(); offsets = new int[count]; int i = 2; for (int j = 0; j < count; j++) { offsets[j] = i; - i += buffer.get2U(); + i += buffer.read16U(); } cache = new LocType[20]; for (int k = 0; k < 20; k++) { @@ -385,51 +385,51 @@ public class LocType { do { int j; do { - j = buffer.get1U(); + j = buffer.read8U(); if (j == 0) { break label0; } if (j == 1) { - int k = buffer.get1U(); + int k = buffer.read8U(); if (k > 0) { if ((modelIDs == null) || lowmem) { modelKinds = new int[k]; modelIDs = new int[k]; for (int k1 = 0; k1 < k; k1++) { - modelIDs[k1] = buffer.get2U(); - modelKinds[k1] = buffer.get1U(); + modelIDs[k1] = buffer.read16U(); + modelKinds[k1] = buffer.read8U(); } } else { buffer.position += k * 3; } } } else if (j == 2) { - name = buffer.getString(); + name = buffer.readString(); } else if (j == 3) { - description = buffer.getString(); + description = buffer.readString(); } else if (j == 5) { - int l = buffer.get1U(); + int l = buffer.read8U(); if (l > 0) { if ((modelIDs == null) || lowmem) { modelKinds = null; modelIDs = new int[l]; for (int l1 = 0; l1 < l; l1++) { - modelIDs[l1] = buffer.get2U(); + modelIDs[l1] = buffer.read16U(); } } else { buffer.position += l * 2; } } } else if (j == 14) { - width = buffer.get1U(); + width = buffer.read8U(); } else if (j == 15) { - length = buffer.get1U(); + length = buffer.read8U(); } else if (j == 17) { solid = false; } else if (j == 18) { blocksProjectiles = false; } else if (j == 19) { - i = buffer.get1U(); + i = buffer.read8U(); if (i == 1) { interactable = true; } @@ -440,54 +440,54 @@ public class LocType { } else if (j == 23) { occludes = true; } else if (j == 24) { - seqID = buffer.get2U(); + seqID = buffer.read16U(); if (seqID == 65535) { seqID = -1; } } else if (j == 28) { - decorationPadding = buffer.get1U(); + decorationPadding = buffer.read8U(); } else if (j == 29) { - lightAmbient = buffer.get1(); + lightAmbient = buffer.read8(); } else if (j == 39) { - lightAttenuation = buffer.get1(); + lightAttenuation = buffer.read8(); } else if ((j >= 30) && (j < 39)) { if (actions == null) { actions = new String[5]; } - actions[j - 30] = buffer.getString(); + actions[j - 30] = buffer.readString(); if (actions[j - 30].equalsIgnoreCase("hidden")) { actions[j - 30] = null; } } else if (j == 40) { - int i1 = buffer.get1U(); + int i1 = buffer.read8U(); srcColor = new int[i1]; dstColor = new int[i1]; for (int i2 = 0; i2 < i1; i2++) { - srcColor[i2] = buffer.get2U(); - dstColor[i2] = buffer.get2U(); + srcColor[i2] = buffer.read16U(); + dstColor[i2] = buffer.read16U(); } } else if (j == 60) { - mapfunctionIcon = buffer.get2U(); + mapfunctionIcon = buffer.read16U(); } else if (j == 62) { invert = true; } else if (j == 64) { castShadow = false; } else if (j == 65) { - scaleX = buffer.get2U(); + scaleX = buffer.read16U(); } else if (j == 66) { - scaleZ = buffer.get2U(); + scaleZ = buffer.read16U(); } else if (j == 67) { - scaleY = buffer.get2U(); + scaleY = buffer.read16U(); } else if (j == 68) { - mapsceneIcon = buffer.get2U(); + mapsceneIcon = buffer.read16U(); } else if (j == 69) { - interactionSideFlags = buffer.get1U(); + interactionSideFlags = buffer.read8U(); } else if (j == 70) { - translateX = buffer.get2(); + translateX = buffer.read16(); } else if (j == 71) { - translateY = buffer.get2(); + translateY = buffer.read16(); } else if (j == 72) { - translateZ = buffer.get2(); + translateZ = buffer.read16(); } else if (j == 73) { important = true; } else if (j == 74) { @@ -496,22 +496,22 @@ public class LocType { if (j != 75) { continue; } - supportsObj = buffer.get1U(); + supportsObj = buffer.read8U(); } continue label0; } while (j != 77); - varbit = buffer.get2U(); + varbit = buffer.read16U(); if (varbit == 65535) { varbit = -1; } - varp = buffer.get2U(); + varp = buffer.read16U(); if (varp == 65535) { varp = -1; } - int j1 = buffer.get1U(); + int j1 = buffer.read8U(); overrideTypeIDs = new int[j1 + 1]; for (int j2 = 0; j2 <= j1; j2++) { - overrideTypeIDs[j2] = buffer.get2U(); + overrideTypeIDs[j2] = buffer.read16U(); if (overrideTypeIDs[j2] == 65535) { overrideTypeIDs[j2] = -1; } diff --git a/src/main/java/Model.java b/src/main/java/Model.java index f98fec5..fea55aa 100644 --- a/src/main/java/Model.java +++ b/src/main/java/Model.java @@ -113,19 +113,19 @@ public class Model extends Entity { buffer.position = src.length - 18; Header header = headers[id] = new Header(); header.data = src; - header.vertexCount = buffer.get2U(); - header.faceCount = buffer.get2U(); - header.texturedFaceCount = buffer.get1U(); - int k = buffer.get1U(); - int l = buffer.get1U(); - int i1 = buffer.get1U(); - int j1 = buffer.get1U(); - int k1 = buffer.get1U(); - int l1 = buffer.get2U(); - int i2 = buffer.get2U(); + header.vertexCount = buffer.read16U(); + header.faceCount = buffer.read16U(); + header.texturedFaceCount = buffer.read8U(); + int k = buffer.read8U(); + int l = buffer.read8U(); + int i1 = buffer.read8U(); + int j1 = buffer.read8U(); + int k1 = buffer.read8U(); + int l1 = buffer.read16U(); + int i2 = buffer.read16U(); //noinspection unused - int j2 = buffer.get2U(); - int k2 = buffer.get2U(); + int j2 = buffer.read16U(); + int k2 = buffer.read16U(); int offset = 0; header.obPoint1Position = offset; offset += header.vertexCount; @@ -390,22 +390,22 @@ public class Model extends Entity { int z = 0; for (int v = 0; v < vertexCount; v++) { - int flags = buf0.get1U(); + int flags = buf0.read8U(); int dx = 0; int dy = 0; int dz = 0; if ((flags & 1) != 0) { - dx = buf1.getSmart(); + dx = buf1.readSmart(); } if ((flags & 2) != 0) { - dy = buf2.getSmart(); + dy = buf2.readSmart(); } if ((flags & 4) != 0) { - dz = buf3.getSmart(); + dz = buf3.readSmart(); } vertexX[v] = x + dx; @@ -417,7 +417,7 @@ public class Model extends Entity { z = vertexZ[v]; if (vertexLabel != null) { - vertexLabel[v] = buf4.get1U(); + vertexLabel[v] = buf4.read8U(); } } @@ -428,22 +428,22 @@ public class Model extends Entity { buf4.position = header.obFace5Position; for (int face = 0; face < faceCount; face++) { - faceColor[face] = buf0.get2U(); + faceColor[face] = buf0.read16U(); if (faceInfo != null) { - faceInfo[face] = buf1.get1U(); + faceInfo[face] = buf1.read8U(); } if (facePriority != null) { - facePriority[face] = buf2.get1U(); + facePriority[face] = buf2.read8U(); } if (faceAlpha != null) { - faceAlpha[face] = buf3.get1U(); + faceAlpha[face] = buf3.read8U(); } if (faceLabel != null) { - faceLabel[face] = buf4.get1U(); + faceLabel[face] = buf4.read8U(); } } @@ -456,7 +456,7 @@ public class Model extends Entity { int last = 0; for (int face = 0; face < faceCount; face++) { - int orientation = buf1.get1U(); + int orientation = buf1.read8U(); // fancy shmansy compression type stuff. // vertex indices stored as deltas, with some faces @@ -464,11 +464,11 @@ public class Model extends Entity { // new a, b, c if (orientation == 1) { - a = buf0.getSmart() + last; + a = buf0.readSmart() + last; last = a; - b = buf0.getSmart() + last; + b = buf0.readSmart() + last; last = b; - c = buf0.getSmart() + last; + c = buf0.readSmart() + last; last = c; faceVertexA[face] = a; faceVertexB[face] = b; @@ -478,7 +478,7 @@ public class Model extends Entity { // reuse a, c, new b if (orientation == 2) { b = c; - c = buf0.getSmart() + last; + c = buf0.readSmart() + last; last = c; faceVertexA[face] = a; faceVertexB[face] = b; @@ -488,7 +488,7 @@ public class Model extends Entity { // reuse c, b, new a if (orientation == 3) { a = c; - c = buf0.getSmart() + last; + c = buf0.readSmart() + last; last = c; faceVertexA[face] = a; faceVertexB[face] = b; @@ -500,7 +500,7 @@ public class Model extends Entity { int a_ = a; a = b; b = a_; - c = buf0.getSmart() + last; + c = buf0.readSmart() + last; last = c; faceVertexA[face] = a; faceVertexB[face] = b; @@ -511,9 +511,9 @@ public class Model extends Entity { buf0.position = header.obAxisPosition; for (int face = 0; face < texturedFaceCount; face++) { - texturedVertexA[face] = buf0.get2U(); - texturedVertexB[face] = buf0.get2U(); - texturedVertexC[face] = buf0.get2U(); + texturedVertexA[face] = buf0.read16U(); + texturedVertexB[face] = buf0.read16U(); + texturedVertexC[face] = buf0.read16U(); } } diff --git a/src/main/java/NPCType.java b/src/main/java/NPCType.java index 29d582b..ade3fb9 100644 --- a/src/main/java/NPCType.java +++ b/src/main/java/NPCType.java @@ -33,13 +33,13 @@ public class NPCType { public static void unpack(FileArchive archive) throws IOException { dat = new Buffer(archive.read("npc.dat")); Buffer buffer = new Buffer(archive.read("npc.idx")); - count = buffer.get2U(); + count = buffer.read16U(); offsets = new int[count]; int offset = 2; for (int i = 0; i < count; i++) { offsets[i] = offset; - offset += buffer.get2U(); + offset += buffer.read16U(); } cache = new NPCType[20]; @@ -231,90 +231,90 @@ public class NPCType { public void read(Buffer buffer) { do { - int i = buffer.get1U(); + int i = buffer.read8U(); if (i == 0) { return; } if (i == 1) { - int j = buffer.get1U(); + int j = buffer.read8U(); modelIDs = new int[j]; for (int j1 = 0; j1 < j; j1++) { - modelIDs[j1] = buffer.get2U(); + modelIDs[j1] = buffer.read16U(); } } else if (i == 2) { - name = buffer.getString(); + name = buffer.readString(); } else if (i == 3) { - desc = buffer.getStringRaw(); + desc = buffer.readStringRaw(); } else if (i == 12) { - size = buffer.get1(); + size = buffer.read8(); } else if (i == 13) { - seqStandID = buffer.get2U(); + seqStandID = buffer.read16U(); } else if (i == 14) { - seqWalkID = buffer.get2U(); + seqWalkID = buffer.read16U(); } else if (i == 17) { - seqWalkID = buffer.get2U(); - seqTurnAroundID = buffer.get2U(); - seqTurnLeftID = buffer.get2U(); - seqTurnRightID = buffer.get2U(); + seqWalkID = buffer.read16U(); + seqTurnAroundID = buffer.read16U(); + seqTurnLeftID = buffer.read16U(); + seqTurnRightID = buffer.read16U(); } else if ((i >= 30) && (i < 40)) { if (op == null) { op = new String[5]; } - op[i - 30] = buffer.getString(); + op[i - 30] = buffer.readString(); if (op[i - 30].equalsIgnoreCase("hidden")) { op[i - 30] = null; } } else if (i == 40) { - int k = buffer.get1U(); + int k = buffer.read8U(); colorSrc = new int[k]; colorDst = new int[k]; for (int k1 = 0; k1 < k; k1++) { - colorSrc[k1] = buffer.get2U(); - colorDst[k1] = buffer.get2U(); + colorSrc[k1] = buffer.read16U(); + colorDst[k1] = buffer.read16U(); } } else if (i == 60) { - int l = buffer.get1U(); + int l = buffer.read8U(); headModelIDs = new int[l]; for (int l1 = 0; l1 < l; l1++) { - headModelIDs[l1] = buffer.get2U(); + headModelIDs[l1] = buffer.read16U(); } } else if (i == 90) { - unusedInt2 = buffer.get2U(); + unusedInt2 = buffer.read16U(); } else if (i == 91) { - unusedInt0 = buffer.get2U(); + unusedInt0 = buffer.read16U(); } else if (i == 92) { - unusedInt1 = buffer.get2U(); + unusedInt1 = buffer.read16U(); } else if (i == 93) { aBoolean87 = false; } else if (i == 95) { - level = buffer.get2U(); + level = buffer.read16U(); } else if (i == 97) { - anInt91 = buffer.get2U(); + anInt91 = buffer.read16U(); } else if (i == 98) { - anInt86 = buffer.get2U(); + anInt86 = buffer.read16U(); } else if (i == 99) { aBoolean93 = true; } else if (i == 100) { - anInt85 = buffer.get1(); + anInt85 = buffer.read8(); } else if (i == 101) { - anInt92 = buffer.get1() * 5; + anInt92 = buffer.read8() * 5; } else if (i == 102) { - headicon = buffer.get2U(); + headicon = buffer.read16U(); } else if (i == 103) { - turnSpeed = buffer.get2U(); + turnSpeed = buffer.read16U(); } else if (i == 106) { - varbitID = buffer.get2U(); + varbitID = buffer.read16U(); if (varbitID == 65535) { varbitID = -1; } - varpID = buffer.get2U(); + varpID = buffer.read16U(); if (varpID == 65535) { varpID = -1; } - int i1 = buffer.get1U(); + int i1 = buffer.read8U(); overrides = new int[i1 + 1]; for (int i2 = 0; i2 <= i1; i2++) { - overrides[i2] = buffer.get2U(); + overrides[i2] = buffer.read16U(); if (overrides[i2] == 65535) { overrides[i2] = -1; } diff --git a/src/main/java/ObjType.java b/src/main/java/ObjType.java index c15c739..10d3103 100644 --- a/src/main/java/ObjType.java +++ b/src/main/java/ObjType.java @@ -27,12 +27,12 @@ public class ObjType { public static void unpack(FileArchive archive) throws IOException { dat = new Buffer(archive.read("obj.dat")); Buffer idx = new Buffer(archive.read("obj.idx")); - count = idx.get2U(); + count = idx.read16U(); typeOffset = new int[count]; int i = 2; for (int j = 0; j < count; j++) { typeOffset[j] = i; - i += idx.get2U(); + i += idx.read16U(); } cached = new ObjType[10]; for (int k = 0; k < 10; k++) { @@ -508,55 +508,55 @@ public class ObjType { public void read(Buffer buffer) { do { - int i = buffer.get1U(); + int i = buffer.read8U(); if (i == 0) { return; } if (i == 1) { - modelID = buffer.get2U(); + modelID = buffer.read16U(); } else if (i == 2) { - name = buffer.getString(); + name = buffer.readString(); } else if (i == 3) { - examine = buffer.getStringRaw(); + examine = buffer.readStringRaw(); } else if (i == 4) { - iconZoom = buffer.get2U(); + iconZoom = buffer.read16U(); } else if (i == 5) { - iconPitch = buffer.get2U(); + iconPitch = buffer.read16U(); } else if (i == 6) { - iconYaw = buffer.get2U(); + iconYaw = buffer.read16U(); } else if (i == 7) { - iconOffsetX = buffer.get2U(); + iconOffsetX = buffer.read16U(); if (iconOffsetX > 32767) { iconOffsetX -= 0x10000; } } else if (i == 8) { - iconOffsetY = buffer.get2U(); + iconOffsetY = buffer.read16U(); if (iconOffsetY > 32767) { iconOffsetY -= 0x10000; } } else if (i == 10) { - unusedInt = buffer.get2U(); + unusedInt = buffer.read16U(); } else if (i == 11) { stackable = true; } else if (i == 12) { - cost = buffer.get4(); + cost = buffer.read32(); } else if (i == 16) { members = true; } else if (i == 23) { - maleModelId0 = buffer.get2U(); - maleOffsetY = buffer.get1(); + maleModelId0 = buffer.read16U(); + maleOffsetY = buffer.read8(); } else if (i == 24) { - maleModelId1 = buffer.get2U(); + maleModelId1 = buffer.read16U(); } else if (i == 25) { - femaleModelId0 = buffer.get2U(); - femaleOffsetY = buffer.get1(); + femaleModelId0 = buffer.read16U(); + femaleOffsetY = buffer.read8(); } else if (i == 26) { - femaleModelId1 = buffer.get2U(); + femaleModelId1 = buffer.read16U(); } else if ((i >= 30) && (i < 35)) { if (groundOptions == null) { groundOptions = new String[5]; } - groundOptions[i - 30] = buffer.getString(); + groundOptions[i - 30] = buffer.readString(); if (groundOptions[i - 30].equalsIgnoreCase("hidden")) { groundOptions[i - 30] = null; } @@ -564,52 +564,52 @@ public class ObjType { if (inventoryOptions == null) { inventoryOptions = new String[5]; } - inventoryOptions[i - 35] = buffer.getString(); + inventoryOptions[i - 35] = buffer.readString(); } else if (i == 40) { - int j = buffer.get1U(); + int j = buffer.read8U(); srcColor = new int[j]; dstColor = new int[j]; for (int k = 0; k < j; k++) { - srcColor[k] = buffer.get2U(); - dstColor[k] = buffer.get2U(); + srcColor[k] = buffer.read16U(); + dstColor[k] = buffer.read16U(); } } else if (i == 78) { - maleModelId2 = buffer.get2U(); + maleModelId2 = buffer.read16U(); } else if (i == 79) { - femaleModelId2 = buffer.get2U(); + femaleModelId2 = buffer.read16U(); } else if (i == 90) { - maleHeadModelId0 = buffer.get2U(); + maleHeadModelId0 = buffer.read16U(); } else if (i == 91) { - femaleHeadModel0 = buffer.get2U(); + femaleHeadModel0 = buffer.read16U(); } else if (i == 92) { - maleHeadModelId1 = buffer.get2U(); + maleHeadModelId1 = buffer.read16U(); } else if (i == 93) { - femaleHeadModel1 = buffer.get2U(); + femaleHeadModel1 = buffer.read16U(); } else if (i == 95) { - iconRoll = buffer.get2U(); + iconRoll = buffer.read16U(); } else if (i == 97) { - linkedID = buffer.get2U(); + linkedID = buffer.read16U(); } else if (i == 98) { - certificateID = buffer.get2U(); + certificateID = buffer.read16U(); } else if ((i >= 100) && (i < 110)) { if (stackIDs == null) { stackIDs = new int[10]; stackAmount = new int[10]; } - stackIDs[i - 100] = buffer.get2U(); - stackAmount[i - 100] = buffer.get2U(); + stackIDs[i - 100] = buffer.read16U(); + stackAmount[i - 100] = buffer.read16U(); } else if (i == 110) { - scaleX = buffer.get2U(); + scaleX = buffer.read16U(); } else if (i == 111) { - scaleZ = buffer.get2U(); + scaleZ = buffer.read16U(); } else if (i == 112) { - scaleY = buffer.get2U(); + scaleY = buffer.read16U(); } else if (i == 113) { - lightAmbient = buffer.get1(); + lightAmbient = buffer.read8(); } else if (i == 114) { - lightAttenuation = buffer.get1() * 5; + lightAttenuation = buffer.read8() * 5; } else if (i == 115) { - team = buffer.get1U(); + team = buffer.read8U(); } } while (true); } diff --git a/src/main/java/OnDemand.java b/src/main/java/OnDemand.java index 5cba7c5..1b5a514 100644 --- a/src/main/java/OnDemand.java +++ b/src/main/java/OnDemand.java @@ -190,7 +190,7 @@ public class OnDemand implements Runnable { storeFilePriorities[i] = new byte[count]; for (int l = 0; l < count; l++) { - storeFileVersions[i][l] = buffer.get2U(); + storeFileVersions[i][l] = buffer.read16U(); } } @@ -202,7 +202,7 @@ public class OnDemand implements Runnable { Buffer buffer = new Buffer(data); storeFileChecksums[i] = new int[count]; for (int l1 = 0; l1 < count; l1++) { - storeFileChecksums[i][l1] = buffer.get4(); + storeFileChecksums[i][l1] = buffer.read32(); } } @@ -229,10 +229,10 @@ public class OnDemand implements Runnable { mapPrefetched = new int[count]; for (int i2 = 0; i2 < count; i2++) { - mapIndex[i2] = buffer.get2U(); - mapLandFile[i2] = buffer.get2U(); - mapLocFile[i2] = buffer.get2U(); - mapPrefetched[i2] = buffer.get1U(); + mapIndex[i2] = buffer.read16U(); + mapLandFile[i2] = buffer.read16U(); + mapLocFile[i2] = buffer.read16U(); + mapPrefetched[i2] = buffer.read8U(); } data = versionlist.read("anim_index"); @@ -241,7 +241,7 @@ public class OnDemand implements Runnable { animIndex = new int[count]; for (int j2 = 0; j2 < count; j2++) { - animIndex[j2] = buffer.get2U(); + animIndex[j2] = buffer.read16U(); } data = versionlist.read("midi_index"); @@ -250,7 +250,7 @@ public class OnDemand implements Runnable { midiIndex = new int[count]; for (int k2 = 0; k2 < count; k2++) { - midiIndex[k2] = buffer.get1U(); + midiIndex[k2] = buffer.read8U(); } this.game = game; diff --git a/src/main/java/PlayerEntity.java b/src/main/java/PlayerEntity.java index 96e12e6..9adf395 100644 --- a/src/main/java/PlayerEntity.java +++ b/src/main/java/PlayerEntity.java @@ -116,24 +116,24 @@ public class PlayerEntity extends PathingEntity { public void method451(Buffer buffer) { buffer.position = 0; - gender = buffer.get1U(); - headicons = buffer.get1U(); + gender = buffer.read8U(); + headicons = buffer.read8U(); npcType = null; team = 0; for (int part = 0; part < 12; part++) { - int msb = buffer.get1U(); + int msb = buffer.read8U(); if (msb == 0) { appearances[part] = 0; continue; } - int lsb = buffer.get1U(); + int lsb = buffer.read8U(); appearances[part] = (msb << 8) + lsb; if ((part == 0) && (appearances[0] == 65535)) { - npcType = NPCType.get(buffer.get2U()); + npcType = NPCType.get(buffer.read16U()); break; } @@ -147,7 +147,7 @@ public class PlayerEntity extends PathingEntity { } for (int part = 0; part < 5; part++) { - int color = buffer.get1U(); + int color = buffer.read8U(); if ((color < 0) || (color >= Game.designPartColor[part].length)) { color = 0; @@ -156,37 +156,37 @@ public class PlayerEntity extends PathingEntity { colors[part] = color; } - super.seqStandID = buffer.get2U(); + super.seqStandID = buffer.read16U(); if (super.seqStandID == 65535) { super.seqStandID = -1; } - super.seqTurnID = buffer.get2U(); + super.seqTurnID = buffer.read16U(); if (super.seqTurnID == 65535) { super.seqTurnID = -1; } - super.seqWalkID = buffer.get2U(); + super.seqWalkID = buffer.read16U(); if (super.seqWalkID == 65535) { super.seqWalkID = -1; } - super.seqTurnAroundID = buffer.get2U(); + super.seqTurnAroundID = buffer.read16U(); if (super.seqTurnAroundID == 65535) { super.seqTurnAroundID = -1; } - super.seqTurnLeftID = buffer.get2U(); + super.seqTurnLeftID = buffer.read16U(); if (super.seqTurnLeftID == 65535) { super.seqTurnLeftID = -1; } - super.seqTurnRightID = buffer.get2U(); + super.seqTurnRightID = buffer.read16U(); if (super.seqTurnRightID == 65535) { super.seqTurnRightID = -1; } - super.seqRunID = buffer.get2U(); + super.seqRunID = buffer.read16U(); if (super.seqRunID == 65535) { super.seqRunID = -1; } - name = StringUtil.formatName(StringUtil.fromBase37(buffer.get8())); - combatLevel = buffer.get1U(); - skillLevel = buffer.get2U(); + name = StringUtil.formatName(StringUtil.fromBase37(buffer.read64())); + combatLevel = buffer.read8U(); + skillLevel = buffer.read16U(); visible = true; appearanceHashcode = 0L; diff --git a/src/main/java/SceneBuilder.java b/src/main/java/SceneBuilder.java index ea9dc75..c961447 100644 --- a/src/main/java/SceneBuilder.java +++ b/src/main/java/SceneBuilder.java @@ -35,7 +35,7 @@ public class SceneBuilder { public static void method173(Buffer buffer, OnDemand onDemand) { int i_110_ = -1; for (; ; ) { - int i_111_ = buffer.getSmartU(); + int i_111_ = buffer.readSmartU(); if (i_111_ == 0) { break; } @@ -43,11 +43,11 @@ public class SceneBuilder { LocType type = LocType.get(i_110_); type.method574(onDemand); for (; ; ) { - int i_112_ = buffer.getSmartU(); + int i_112_ = buffer.readSmartU(); if (i_112_ == 0) { break; } - buffer.get1U(); + buffer.read8U(); } } } @@ -349,7 +349,7 @@ public class SceneBuilder { Buffer buffer = new Buffer(is); int i_252_ = -1; for (; ; ) { - int i_253_ = buffer.getSmartU(); + int i_253_ = buffer.readSmartU(); if (i_253_ == 0) { break; } @@ -358,20 +358,20 @@ public class SceneBuilder { boolean bool_255_ = false; for (; ; ) { if (bool_255_) { - int i_256_ = buffer.getSmartU(); + int i_256_ = buffer.readSmartU(); if (i_256_ == 0) { break; } - buffer.get1U(); + buffer.read8U(); } else { - int i_257_ = buffer.getSmartU(); + int i_257_ = buffer.readSmartU(); if (i_257_ == 0) { break; } i_254_ += i_257_ - 1; int i_258_ = i_254_ & 0x3f; int i_259_ = (i_254_ >> 6) & 0x3f; - int i_260_ = buffer.get1U() >> 2; + int i_260_ = buffer.read8U() >> 2; int i_261_ = i_259_ + i; int i_262_ = i_258_ + i_250_; if ((i_261_ > 0) && (i_262_ > 0) && (i_261_ < 103) && (i_262_ < 103)) { @@ -1235,7 +1235,7 @@ public class SceneBuilder { if ((i_186_ >= 0) && (i_186_ < 104) && (i >= 0) && (i < 104)) { levelTileFlags[i_187_][i_186_][i] = (byte) 0; for (; ; ) { - int i_191_ = buffer.get1U(); + int i_191_ = buffer.read8U(); if (i_191_ == 0) { if (i_187_ == 0) { levelHeightmap[0][i_186_][i] = -method172(932731 + i_186_ + i_190_, 556238 + i + i_185_) * 8; @@ -1246,7 +1246,7 @@ public class SceneBuilder { break; } if (i_191_ == 1) { - int i_192_ = buffer.get1U(); + int i_192_ = buffer.read8U(); if (i_192_ == 1) { i_192_ = 0; } @@ -1259,7 +1259,7 @@ public class SceneBuilder { break; } if (i_191_ <= 49) { - aByteArrayArrayArray130[i_187_][i_186_][i] = buffer.get1(); + aByteArrayArrayArray130[i_187_][i_186_][i] = buffer.read8(); aByteArrayArrayArray136[i_187_][i_186_][i] = (byte) ((i_191_ - 2) / 4); aByteArrayArrayArray148[i_187_][i_186_][i] = (byte) (((i_191_ - 2) + i_188_) & 0x3); } else if (i_191_ <= 81) { @@ -1270,16 +1270,16 @@ public class SceneBuilder { } } else { for (; ; ) { - int i_193_ = buffer.get1U(); + int i_193_ = buffer.read8U(); if (i_193_ == 0) { break; } if (i_193_ == 1) { - buffer.get1U(); + buffer.read8U(); break; } if (i_193_ <= 49) { - buffer.get1U(); + buffer.read8U(); } } } @@ -1299,14 +1299,14 @@ public class SceneBuilder { Buffer buffer = new Buffer(is); int i_203_ = -1; for (; ; ) { - int i_204_ = buffer.getSmartU(); + int i_204_ = buffer.readSmartU(); if (i_204_ == 0) { break; } i_203_ += i_204_; int i_205_ = 0; for (; ; ) { - int i_206_ = buffer.getSmartU(); + int i_206_ = buffer.readSmartU(); if (i_206_ == 0) { break; } @@ -1314,7 +1314,7 @@ public class SceneBuilder { int i_207_ = i_205_ & 0x3f; int i_208_ = (i_205_ >> 6) & 0x3f; int i_209_ = i_205_ >> 12; - int i_210_ = buffer.get1U(); + int i_210_ = buffer.read8U(); int i_211_ = i_210_ >> 2; int i_212_ = i_210_ & 0x3; if ((i_209_ == i) && (i_208_ >= i_200_) && (i_208_ < (i_200_ + 8)) && (i_207_ >= i_198_) && (i_207_ < (i_198_ + 8))) { @@ -1367,14 +1367,14 @@ public class SceneBuilder { Buffer buffer = new Buffer(is); int i_265_ = -1; for (; ; ) { - int i_266_ = buffer.getSmartU(); + int i_266_ = buffer.readSmartU(); if (i_266_ == 0) { break; } i_265_ += i_266_; int i_267_ = 0; for (; ; ) { - int i_268_ = buffer.getSmartU(); + int i_268_ = buffer.readSmartU(); if (i_268_ == 0) { break; } @@ -1382,7 +1382,7 @@ public class SceneBuilder { int i_269_ = i_267_ & 0x3f; int i_270_ = (i_267_ >> 6) & 0x3f; int i_271_ = i_267_ >> 12; - int i_272_ = buffer.get1U(); + int i_272_ = buffer.read8U(); int i_273_ = i_272_ >> 2; int i_274_ = i_272_ & 0x3; int i_275_ = i_270_ + i; diff --git a/src/main/java/SeqSkeleton.java b/src/main/java/SeqSkeleton.java index 55f5578..26a82fe 100644 --- a/src/main/java/SeqSkeleton.java +++ b/src/main/java/SeqSkeleton.java @@ -36,17 +36,17 @@ public class SeqSkeleton { * @param in the input */ public SeqSkeleton(Buffer in) { - final int length = in.get1U(); + final int length = in.read8U(); baseTypes = new int[length]; baseLabels = new int[length][]; for (int group = 0; group < length; group++) { - baseTypes[group] = in.get1U(); + baseTypes[group] = in.read8U(); } for (int group = 0; group < length; group++) { - int count = in.get1U(); + int count = in.read8U(); baseLabels[group] = new int[count]; for (int child = 0; child < count; child++) { - baseLabels[group][child] = in.get1U(); + baseLabels[group][child] = in.read8U(); } } } diff --git a/src/main/java/SeqTransform.java b/src/main/java/SeqTransform.java index c7fd5a2..00c99d2 100644 --- a/src/main/java/SeqTransform.java +++ b/src/main/java/SeqTransform.java @@ -67,38 +67,38 @@ public class SeqTransform { int offset = 0; header.position = offset; - offset += offsets.get2U() + 2; + offset += offsets.read16U() + 2; tran1.position = offset; - offset += offsets.get2U(); + offset += offsets.read16U(); tran2.position = offset; - offset += offsets.get2U(); + offset += offsets.read16U(); del.position = offset; - offset += offsets.get2U(); + offset += offsets.read16U(); skel.position = offset; SeqSkeleton skeleton = new SeqSkeleton(skel); - int frameCount = header.get2U(); + int frameCount = header.read16U(); int[] bases = new int[500]; int[] x = new int[500]; int[] y = new int[500]; int[] z = new int[500]; for (int i = 0; i < frameCount; i++) { - SeqTransform transform = instances[header.get2U()] = new SeqTransform(); - transform.delay = del.get1U(); + SeqTransform transform = instances[header.read16U()] = new SeqTransform(); + transform.delay = del.read8U(); transform.skeleton = skeleton; - int baseCount = header.get1U(); + int baseCount = header.read8U(); int lastBase = -1; int length = 0; for (int base = 0; base < baseCount; base++) { - int flags = tran1.get1U(); + int flags = tran1.read8U(); if (flags <= 0) { continue; @@ -127,19 +127,19 @@ public class SeqTransform { } if ((flags & 1) != 0) { - x[length] = tran2.getSmart(); + x[length] = tran2.readSmart(); } else { x[length] = defaultValue; } if ((flags & 2) != 0) { - y[length] = tran2.getSmart(); + y[length] = tran2.readSmart(); } else { y[length] = defaultValue; } if ((flags & 4) != 0) { - z[length] = tran2.getSmart(); + z[length] = tran2.readSmart(); } else { z[length] = defaultValue; } diff --git a/src/main/java/SeqType.java b/src/main/java/SeqType.java index 1169b98..07bf7de 100644 --- a/src/main/java/SeqType.java +++ b/src/main/java/SeqType.java @@ -11,7 +11,7 @@ public class SeqType { public static void unpack(FileArchive archive) throws IOException { Buffer buffer = new Buffer(archive.read("seq.dat")); - count = buffer.get2U(); + count = buffer.read16U(); if (instances == null) { instances = new SeqType[count]; } @@ -131,49 +131,49 @@ public class SeqType { public void load(Buffer buffer) { do { - int op = buffer.get1U(); + int op = buffer.read8U(); if (op == 0) { break; } else if (op == 1) { - frameCount = buffer.get1U(); + frameCount = buffer.read8U(); transformIndices = new int[frameCount]; auxiliaryTransformIndices = new int[frameCount]; frameDuration = new int[frameCount]; for (int f = 0; f < frameCount; f++) { - transformIndices[f] = buffer.get2U(); - auxiliaryTransformIndices[f] = buffer.get2U(); + transformIndices[f] = buffer.read16U(); + auxiliaryTransformIndices[f] = buffer.read16U(); if (auxiliaryTransformIndices[f] == 65535) { auxiliaryTransformIndices[f] = -1; } - frameDuration[f] = buffer.get2U(); + frameDuration[f] = buffer.read16U(); } } else if (op == 2) { - loopFrameCount = buffer.get2U(); + loopFrameCount = buffer.read16U(); } else if (op == 3) { - int count = buffer.get1U(); + int count = buffer.read8U(); mask = new int[count + 1]; for (int l = 0; l < count; l++) { - mask[l] = buffer.get1U(); + mask[l] = buffer.read8U(); } mask[count] = 9999999; } else if (op == 4) { forwardRenderPadding = true; } else if (op == 5) { - priority = buffer.get1U(); + priority = buffer.read8U(); } else if (op == 6) { - rightHandOverride = buffer.get2U(); + rightHandOverride = buffer.read16U(); } else if (op == 7) { - leftHandOverride = buffer.get2U(); + leftHandOverride = buffer.read16U(); } else if (op == 8) { - loopCount = buffer.get1U(); + loopCount = buffer.read8U(); } else if (op == 9) { - moveStyle = buffer.get1U(); + moveStyle = buffer.read8U(); } else if (op == 10) { - idleStyle = buffer.get1U(); + idleStyle = buffer.read8U(); } else if (op == 11) { - replayStyle = buffer.get1U(); + replayStyle = buffer.read8U(); } else if (op == 12) { - unusedInt = buffer.get4(); + unusedInt = buffer.read32(); } else { System.out.println("Error unrecognised seq config code: " + op); } diff --git a/src/main/java/SoundEnvelope.java b/src/main/java/SoundEnvelope.java index 42b9a1b..7346a24 100644 --- a/src/main/java/SoundEnvelope.java +++ b/src/main/java/SoundEnvelope.java @@ -22,19 +22,19 @@ public class SoundEnvelope { } public void read(Buffer buffer) { - form = buffer.get1U(); - start = buffer.get4(); - end = buffer.get4(); + form = buffer.read8U(); + start = buffer.read32(); + end = buffer.read32(); readShape(buffer); } public void readShape(Buffer buffer) { - length = buffer.get1U(); + length = buffer.read8U(); shapeDelta = new int[length]; shapePeak = new int[length]; for (int i = 0; i < length; i++) { - shapeDelta[i] = buffer.get2U(); - shapePeak[i] = buffer.get2U(); + shapeDelta[i] = buffer.read16U(); + shapePeak[i] = buffer.read16U(); } } diff --git a/src/main/java/SoundFilter.java b/src/main/java/SoundFilter.java index 2c0f287..84be3e9 100644 --- a/src/main/java/SoundFilter.java +++ b/src/main/java/SoundFilter.java @@ -80,28 +80,28 @@ public class SoundFilter { } public void read(Buffer buffer, SoundEnvelope envelope) { - int count = buffer.get1U(); + int count = buffer.read8U(); pairs[0] = count >> 4; pairs[1] = count & 0xf; if (count != 0) { - unities[0] = buffer.get2U(); - unities[1] = buffer.get2U(); + unities[0] = buffer.read16U(); + unities[1] = buffer.read16U(); - int migration = buffer.get1U(); + int migration = buffer.read8U(); for (int direction = 0; direction < 2; direction++) { for (int pair = 0; pair < pairs[direction]; pair++) { - frequencies[direction][0][pair] = buffer.get2U(); - ranges[direction][0][pair] = buffer.get2U(); + frequencies[direction][0][pair] = buffer.read16U(); + ranges[direction][0][pair] = buffer.read16U(); } } for (int direction = 0; direction < 2; direction++) { for (int pair = 0; pair < pairs[direction]; pair++) { if ((migration & (1 << (direction * 4) << pair)) != 0) { - frequencies[direction][1][pair] = buffer.get2U(); - ranges[direction][1][pair] = buffer.get2U(); + frequencies[direction][1][pair] = buffer.read16U(); + ranges[direction][1][pair] = buffer.read16U(); } else { frequencies[direction][1][pair] = frequencies[direction][0][pair]; ranges[direction][1][pair] = ranges[direction][0][pair]; diff --git a/src/main/java/SoundTone.java b/src/main/java/SoundTone.java index 184e35b..79e8bcf 100644 --- a/src/main/java/SoundTone.java +++ b/src/main/java/SoundTone.java @@ -277,7 +277,7 @@ public class SoundTone { amplitudeBase = new SoundEnvelope(); amplitudeBase.read(buffer); - if (buffer.get1U() != 0) { + if (buffer.read8U() != 0) { buffer.position--; frequencyModRate = new SoundEnvelope(); frequencyModRate.read(buffer); @@ -285,7 +285,7 @@ public class SoundTone { frequencyModRange.read(buffer); } - if (buffer.get1U() != 0) { + if (buffer.read8U() != 0) { buffer.position--; amplitudeModRate = new SoundEnvelope(); amplitudeModRate.read(buffer); @@ -293,7 +293,7 @@ public class SoundTone { amplitudeModRange.read(buffer); } - if (buffer.get1U() != 0) { + if (buffer.read8U() != 0) { buffer.position--; release = new SoundEnvelope(); release.read(buffer); @@ -302,22 +302,22 @@ public class SoundTone { } for (int i = 0; i < 10; i++) { - int volume = buffer.getSmartU(); + int volume = buffer.readSmartU(); if (volume == 0) { break; } harmonicVolume[i] = volume; - harmonicSemitone[i] = buffer.getSmart(); - harmonicDelay[i] = buffer.getSmartU(); + harmonicSemitone[i] = buffer.readSmart(); + harmonicDelay[i] = buffer.readSmartU(); } - reverbDelay = buffer.getSmartU(); - reverbVolume = buffer.getSmartU(); + reverbDelay = buffer.readSmartU(); + reverbVolume = buffer.readSmartU(); - length = buffer.get2U(); - start = buffer.get2U(); + length = buffer.read16U(); + start = buffer.read16U(); filter = new SoundFilter(); filterRange = new SoundEnvelope(); diff --git a/src/main/java/SoundTrack.java b/src/main/java/SoundTrack.java index aea24c1..4d7f061 100644 --- a/src/main/java/SoundTrack.java +++ b/src/main/java/SoundTrack.java @@ -12,7 +12,7 @@ public class SoundTrack { SoundTone.init(); do { - int id = src.get2U(); + int id = src.read16U(); if (id == 65535) { return; } @@ -41,14 +41,14 @@ public class SoundTrack { public void read(Buffer buffer) { for (int tone = 0; tone < 10; tone++) { - if (buffer.get1U() != 0) { + if (buffer.read8U() != 0) { buffer.position--; tones[tone] = new SoundTone(); tones[tone].read(buffer); } } - loopBegin = buffer.get2U(); - loopEnd = buffer.get2U(); + loopBegin = buffer.read16U(); + loopEnd = buffer.read16U(); } public int trim() { @@ -88,19 +88,19 @@ public class SoundTrack { public Buffer getWaveform(int loopCount) { int length = generate(loopCount); buffer.position = 0; - buffer.put4(0x52494646); // "RIFF" ChunkID - buffer.put4LE(36 + length); // ChunkSize - buffer.put4(0x57415645); // "WAVE" format - buffer.put4(0x666d7420); // "fmt " chunk id - buffer.put4LE(16); // chunk size - buffer.put2LE(1); // audio format - buffer.put2LE(1); // num channels - buffer.put4LE(22050); // sample rate - buffer.put4LE(22050); // byte rate - buffer.put2LE(1); // block align - buffer.put2LE(8); // bits per sample - buffer.put4(0x64617461); // "data" - buffer.put4LE(length); + buffer.write32(0x52494646); // "RIFF" ChunkID + buffer.write32LE(36 + length); // ChunkSize + buffer.write32(0x57415645); // "WAVE" format + buffer.write32(0x666d7420); // "fmt " chunk id + buffer.write32LE(16); // chunk size + buffer.write16LE(1); // audio format + buffer.write16LE(1); // num channels + buffer.write32LE(22050); // sample rate + buffer.write32LE(22050); // byte rate + buffer.write16LE(1); // block align + buffer.write16LE(8); // bits per sample + buffer.write32(0x64617461); // "data" + buffer.write32LE(length); buffer.position += length; return buffer; } diff --git a/src/main/java/SpotAnimType.java b/src/main/java/SpotAnimType.java index ae44671..17b7413 100644 --- a/src/main/java/SpotAnimType.java +++ b/src/main/java/SpotAnimType.java @@ -14,7 +14,7 @@ public class SpotAnimType { public static void unpack(FileArchive archive) throws IOException { Buffer buffer = new Buffer(archive.read("spotanim.dat")); - count = buffer.get2U(); + count = buffer.read16U(); if (instances == null) { instances = new SpotAnimType[count]; @@ -46,31 +46,31 @@ public class SpotAnimType { public void read(Buffer buffer) { do { - int i = buffer.get1U(); + int i = buffer.read8U(); if (i == 0) { return; } if (i == 1) { - modelID = buffer.get2U(); + modelID = buffer.read16U(); } else if (i == 2) { - seqID = buffer.get2U(); + seqID = buffer.read16U(); if (SeqType.instances != null) { seq = SeqType.instances[seqID]; } } else if (i == 4) { - scaleXY = buffer.get2U(); + scaleXY = buffer.read16U(); } else if (i == 5) { - scaleZ = buffer.get2U(); + scaleZ = buffer.read16U(); } else if (i == 6) { - rotation = buffer.get2U(); + rotation = buffer.read16U(); } else if (i == 7) { - lightAmbient = buffer.get1U(); + lightAmbient = buffer.read8U(); } else if (i == 8) { - lightAttenuation = buffer.get1U(); + lightAttenuation = buffer.read8U(); } else if ((i >= 40) && (i < 50)) { - colorSrc[i - 40] = buffer.get2U(); + colorSrc[i - 40] = buffer.read16U(); } else if ((i >= 50) && (i < 60)) { - colorDst[i - 50] = buffer.get2U(); + colorDst[i - 50] = buffer.read16U(); } else { System.out.println("Error unrecognised spotanim config code: " + i); } diff --git a/src/main/java/VarbitType.java b/src/main/java/VarbitType.java index ac6d257..7bf13fb 100644 --- a/src/main/java/VarbitType.java +++ b/src/main/java/VarbitType.java @@ -10,7 +10,7 @@ public class VarbitType { public static void unpack(FileArchive archive) throws IOException { Buffer buffer = new Buffer(archive.read("varbit.dat")); - int count = buffer.get2U(); + int count = buffer.read16U(); if (instances == null) { instances = new VarbitType[count]; @@ -49,21 +49,21 @@ public class VarbitType { public void read(Buffer buffer) { do { - int op = buffer.get1U(); + int op = buffer.read8U(); if (op == 0) { return; } else if (op == 1) { - varp = buffer.get2U(); - lsb = buffer.get1U(); - msb = buffer.get1U(); + varp = buffer.read16U(); + lsb = buffer.read8U(); + msb = buffer.read8U(); } else if (op == 10) { - unusedString = buffer.getString(); + unusedString = buffer.readString(); } else if (op == 2) { unusedBool = true; } else if (op == 3) { - unusedInt0 = buffer.get4(); + unusedInt0 = buffer.read32(); } else if (op == 4) { - unusedInt1 = buffer.get4(); + unusedInt1 = buffer.read32(); } else { System.out.println("Error unrecognised config code: " + op); } diff --git a/src/main/java/VarpType.java b/src/main/java/VarpType.java index ff72827..bcd4c9d 100644 --- a/src/main/java/VarpType.java +++ b/src/main/java/VarpType.java @@ -14,7 +14,7 @@ public class VarpType { public static void unpack(FileArchive archive) throws IOException { Buffer buffer = new Buffer(archive.read("varp.dat")); anInt702 = 0; - anInt700 = buffer.get2U(); + anInt700 = buffer.read16U(); if (instances == null) { instances = new VarpType[anInt700]; } @@ -49,33 +49,33 @@ public class VarpType { public void read(Buffer buffer, int i) { do { - int op = buffer.get1U(); + int op = buffer.read8U(); if (op == 0) { return; } else if (op == 1) { - unusedInt0 = buffer.get1U(); + unusedInt0 = buffer.read8U(); } else if (op == 2) { - unusedInt1 = buffer.get1U(); + unusedInt1 = buffer.read8U(); } else if (op == 3) { unusedBool0 = true; anIntArray703[anInt702++] = i; } else if (op == 4) { unusedBool1 = false; } else if (op == 5) { - anInt709 = buffer.get2U(); + anInt709 = buffer.read16U(); } else if (op == 6) { unusedBool2 = true; } else if (op == 7) { - unusedInt2 = buffer.get4(); + unusedInt2 = buffer.read32(); } else if (op == 8) { unusedInt3 = 1; unusedBool3 = true; } else if (op == 10) { - unusedString = buffer.getString(); + unusedString = buffer.readString(); } else if (op == 11) { unusedBool3 = true; } else if (op == 12) { - unusedInt4 = buffer.get4(); + unusedInt4 = buffer.read32(); } else if (op == 13) { unusedInt3 = 2; } else {