From 6f9ff70b148cbbebcb5dabd29708212af64346a3 Mon Sep 17 00:00:00 2001 From: thedaneeffect Date: Sun, 8 Jan 2023 14:26:17 -0500 Subject: [PATCH] Renamed: Buffer#readU* Refactored: Censor (mostly) --- src/main/java/BitmapFont.java | 18 +- src/main/java/Buffer.java | 30 +- src/main/java/Censor.java | 908 +++++++++++++++-------------- src/main/java/ChatCompression.java | 2 +- src/main/java/FileArchive.java | 2 +- src/main/java/FloType.java | 6 +- src/main/java/Game.java | 396 ++++++------- src/main/java/IdkType.java | 16 +- src/main/java/IfType.java | 102 ++-- src/main/java/Image24.java | 24 +- src/main/java/Image8.java | 24 +- src/main/java/LocType.java | 58 +- src/main/java/Model.java | 46 +- src/main/java/NPCType.java | 58 +- src/main/java/ObjType.java | 72 +-- src/main/java/OnDemand.java | 14 +- src/main/java/PlayerEntity.java | 30 +- src/main/java/SceneBuilder.java | 40 +- src/main/java/SeqSkeleton.java | 8 +- src/main/java/SeqTransform.java | 18 +- src/main/java/SeqType.java | 32 +- src/main/java/SoundEnvelope.java | 8 +- src/main/java/SoundFilter.java | 16 +- src/main/java/SoundTone.java | 18 +- src/main/java/SoundTrack.java | 8 +- src/main/java/SpotAnimType.java | 22 +- src/main/java/VarbitType.java | 10 +- src/main/java/VarpType.java | 8 +- 28 files changed, 1023 insertions(+), 971 deletions(-) diff --git a/src/main/java/BitmapFont.java b/src/main/java/BitmapFont.java index 7fcfd3e..9f56a2a 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.read16U() + 4; + idx.position = dat.readU16() + 4; - int k = idx.read8U(); + int k = idx.readU8(); if (k > 0) { idx.position += 3 * (k - 1); } for (int c = 0; c < 256; c++) { - charOffsetX[c] = idx.read8U(); - charOffsetY[c] = idx.read8U(); + charOffsetX[c] = idx.readU8(); + charOffsetY[c] = idx.readU8(); - int w = charMaskWidth[c] = idx.read16U(); - int h = charMaskHeight[c] = idx.read16U(); - int storeOrder = idx.read8U(); + int w = charMaskWidth[c] = idx.readU16(); + int h = charMaskHeight[c] = idx.readU16(); + int storeOrder = idx.readU8(); int len = w * h; charMask[c] = new byte[len]; if (storeOrder == 0) { for (int i = 0; i < len; i++) { - charMask[c][i] = dat.read(); + 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.read(); + charMask[c][x + (y * w)] = dat.read8(); } } } diff --git a/src/main/java/Buffer.java b/src/main/java/Buffer.java index f2f62d2..27f0ab0 100644 --- a/src/main/java/Buffer.java +++ b/src/main/java/Buffer.java @@ -6,7 +6,7 @@ /** * A {@link Buffer} encapsulates a finite amount of data and provides methods for reading and writing to that data. * 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]. + * suffix. The naming convention is (read[U:unsigned]|write)[type][endianness][modifier]. *

* Types:
* # — the number of bytes
@@ -135,7 +135,7 @@ public void writeA(byte[] src, int off, int len) { } } - public byte read() { + public byte read8() { return data[position++]; } @@ -147,19 +147,19 @@ public byte read8S() { return (byte) (128 - data[position++]); } - public int read8U() { + public int readU8() { return data[position++] & 0xff; } - public int read8UA() { + public int readU8A() { return (data[position++] - 128) & 0xff; } - public int read8UC() { + public int readU8C() { return -data[position++] & 0xff; } - public int read8US() { + public int readU8S() { return (128 - data[position++]) & 0xff; } @@ -170,9 +170,9 @@ public int read8US() { */ public int readSmart() { if ((data[position] & 0xff) < 128) { - return read8U() - 64; + return readU8() - 64; } else { - return read16U() - 49152; + return readU16() - 49152; } } @@ -181,30 +181,30 @@ public int readSmart() { * * @return the value. */ - public int readSmartU() { + public int readUSmart() { if ((data[position] & 0xff) < 128) { - return read8U(); + return readU8(); } else { - return read16U() - 32768; + return readU16() - 32768; } } - public int read16U() { + public int readU16() { position += 2; return ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff); } - public int read16UA() { + public int readU16A() { position += 2; return ((data[position - 2] & 0xff) << 8) + ((data[position - 1] - 128) & 0xff); } - public int read16ULE() { + public int readU16LE() { position += 2; return ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff); } - public int read16ULEA() { + public int readU16LEA() { position += 2; return ((data[position - 1] & 0xff) << 8) + ((data[position - 2] - 128) & 0xff); } diff --git a/src/main/java/Censor.java b/src/main/java/Censor.java index 024a2fa..3e7418e 100644 --- a/src/main/java/Censor.java +++ b/src/main/java/Censor.java @@ -6,234 +6,231 @@ public class Censor { - public static final String[] aStringArray626 = {"cook", "cook's", "cooks", "seeks", "sheet", "woop", "woops", "faq", "noob", "noobs"}; - public static int[] anIntArray620; - public static char[][] aCharArrayArray621; - public static byte[][][] aByteArrayArrayArray622; - public static char[][] aCharArrayArray623; - public static char[][] aCharArrayArray624; - public static int[] anIntArray625; + public static final String[] ALLOWLIST = {"cook", "cook's", "cooks", "seeks", "sheet", "woop", "woops", "faq", "noob", "noobs"}; + public static int[] fragments; + public static char[][] badwords; + public static byte[][][] badCombinations; + public static char[][] domains; + public static char[][] tlds; + public static int[] tldType; - public static void method487(FileArchive archive) throws IOException { - Buffer buffer = new Buffer(archive.read("fragmentsenc.txt")); - Buffer buffer_1 = new Buffer(archive.read("badenc.txt")); - Buffer class30_sub2_sub2_2 = new Buffer(archive.read("domainenc.txt")); - Buffer buffer_3 = new Buffer(archive.read("tldlist.txt")); - method488(buffer, buffer_1, class30_sub2_sub2_2, buffer_3); + public static void unpack(FileArchive archive) throws IOException { + readBadWords(new Buffer(archive.read("badenc.txt"))); + readDomains(new Buffer(archive.read("domainenc.txt"))); + readFragments(new Buffer(archive.read("fragmentsenc.txt"))); + readTLD(new Buffer(archive.read("tldlist.txt"))); } - public static void method488(Buffer buffer, Buffer buffer_1, Buffer class30_sub2_sub2_2, Buffer buffer_3) { - method490(buffer_1); - method491(class30_sub2_sub2_2); - method492(buffer); - method489(buffer_3); - } + public static void readTLD(Buffer in) { + int count = in.read32(); + tlds = new char[count][]; + tldType = new int[count]; + for (int i = 0; i < count; i++) { + tldType[i] = in.readU8(); - public static void method489(Buffer buffer) { - int i = buffer.read32(); - aCharArrayArray624 = new char[i][]; - anIntArray625 = new int[i]; - for (int j = 0; j < i; j++) { - anIntArray625[j] = buffer.read8U(); - char[] ac = new char[buffer.read8U()]; - for (int k = 0; k < ac.length; k++) { - ac[k] = (char) buffer.read8U(); + char[] tld = new char[in.readU8()]; + for (int j = 0; j < tld.length; j++) { + tld[j] = (char) in.readU8(); } - aCharArrayArray624[j] = ac; + + tlds[i] = tld; } } - public static void method490(Buffer buffer) { - int j = buffer.read32(); - aCharArrayArray621 = new char[j][]; - aByteArrayArrayArray622 = new byte[j][][]; - method493(buffer, aCharArrayArray621, aByteArrayArrayArray622); - } + public static void readBadWords(Buffer in) { + int count = in.read32(); + badwords = new char[count][]; + badCombinations = new byte[count][][]; - public static void method491(Buffer buffer) { - int i = buffer.read32(); - aCharArrayArray623 = new char[i][]; - method494(aCharArrayArray623, buffer, -490); - } + for (int i = 0; i < badwords.length; i++) { + char[] badword = new char[in.readU8()]; - public static void method492(Buffer buffer) { - anIntArray620 = new int[buffer.read32()]; - for (int i = 0; i < anIntArray620.length; i++) { - 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.read8U()]; - for (int k = 0; k < ac1.length; k++) { - ac1[k] = (char) buffer.read8U(); + for (int j = 0; j < badword.length; j++) { + badword[j] = (char) in.readU8(); } - ac[j] = ac1; - byte[][] abyte1 = new byte[buffer.read8U()][2]; - for (int l = 0; l < abyte1.length; l++) { - abyte1[l][0] = (byte) buffer.read8U(); - abyte1[l][1] = (byte) buffer.read8U(); + + badwords[i] = badword; + + byte[][] combination = new byte[in.readU8()][2]; + + for (int j = 0; j < combination.length; j++) { + combination[j][0] = (byte) in.readU8(); + combination[j][1] = (byte) in.readU8(); } - if (abyte1.length > 0) { - abyte0[j] = abyte1; + + if (combination.length > 0) { + badCombinations[i] = combination; } } } - public static void method494(char[][] ac, Buffer buffer, int i) { - if (i >= 0) { - return; - } - for (int j = 0; j < ac.length; j++) { - char[] ac1 = new char[buffer.read8U()]; - for (int k = 0; k < ac1.length; k++) { - ac1[k] = (char) buffer.read8U(); + public static void readDomains(Buffer in) { + int count = in.read32(); + domains = new char[count][]; + for (int i = 0; i < domains.length; i++) { + char[] domain = new char[in.readU8()]; + for (int j = 0; j < domain.length; j++) { + domain[j] = (char) in.readU8(); } - ac[j] = ac1; + domains[i] = domain; } } - public static void method495(char[] ac) { - int i = 0; - for (int j = 0; j < ac.length; j++) { - if (method496(ac[j])) { - ac[i] = ac[j]; + public static void readFragments(Buffer buffer) { + fragments = new int[buffer.read32()]; + for (int i = 0; i < fragments.length; i++) { + fragments[i] = buffer.readU16(); + } + } + + public static void filterCharacters(char[] in) { + int pos = 0; + for (int i = 0; i < in.length; i++) { + if (allowCharacter(in[i])) { + in[pos] = in[i]; } else { - ac[i] = ' '; + in[pos] = ' '; } - if ((i == 0) || (ac[i] != ' ') || (ac[i - 1] != ' ')) { - i++; + + if ((pos == 0) || (in[pos] != ' ') || (in[pos - 1] != ' ')) { + pos++; } } - for (int k = i; k < ac.length; k++) { - ac[k] = ' '; + for (int i = pos; i < in.length; i++) { + in[i] = ' '; } } - public static boolean method496(char c) { - return ((c >= ' ') && (c <= '\177')) || (c == ' ') || (c == '\n') || (c == '\t') || (c == '\243') || (c == '\u20AC'); + public static boolean allowCharacter(char c) { + if (c >= ' ' && c <= '\u007F') return true; + if (c == ' ') return true; + if (c == '\n') return true; + if (c == '\t') return true; + if (c == '£') return true; + return c == '€'; } - public static String apply(String s) { - char[] ac = s.toCharArray(); - method495(ac); - String s1 = new String(ac).trim(); - ac = s1.toLowerCase().toCharArray(); - String s2 = s1.toLowerCase(); - method505(ac); - method500(ac); - method501(ac); - method514(ac); - for (String value : aStringArray626) { - for (int k = -1; (k = s2.indexOf(value, k + 1)) != -1; ) { - char[] ac1 = value.toCharArray(); - for (int i1 = 0; i1 < ac1.length; i1++) { - ac[i1 + k] = ac1[i1]; - } + public static String filter(String in) { + char[] output = in.toCharArray(); + filterCharacters(output); + + String trimmed = new String(output).trim(); + output = trimmed.toLowerCase().toCharArray(); + + filterTLD(output); + filterBad(output); + filterDomains(output); + filterFragments(output); + + String lowercase = trimmed.toLowerCase(); + + for (String allowed : ALLOWLIST) { + for (int i = -1; (i = lowercase.indexOf(allowed, i + 1)) != -1; ) { + char[] src = allowed.toCharArray(); + System.arraycopy(src, 0, output, i, src.length); } } - method498(s1.toCharArray(), 2, ac); - method499(0, ac); - return new String(ac).trim(); + + replaceUpperCases(trimmed.toCharArray(), output); + formatUpperCases(output); + return new String(output).trim(); } - public static void method498(char[] ac, int i, char[] ac1) { - for (int j = 0; j < ac.length; j++) { - if ((ac1[j] != '*') && method522(ac[j])) { - ac1[j] = ac[j]; + public static void replaceUpperCases(char[] unfiltered, char[] in) { + for (int i = 0; i < unfiltered.length; i++) { + if ((in[i] != '*') && isUpperCase(unfiltered[i])) { + in[i] = unfiltered[i]; } } - if (i == 2) { - } } - public static void method499(int i, char[] ac) { - boolean flag = true; - for (int j = 0; j < ac.length; j++) { - char c = ac[j]; - if (method519(c)) { - if (flag) { - if (method521(c)) { - flag = false; + public static void formatUpperCases(char[] in) { + boolean upper = true; + for (int i = 0; i < in.length; i++) { + char c = in[i]; + if (isAlpha(c)) { + if (upper) { + if (isLowerCase(c)) { + upper = false; } - } else if (method522(c)) { - ac[j] = (char) ((c + 97) - 65); + } else if (isUpperCase(c)) { + in[i] = (char) ((c + 'a') - 'A'); } } else { - flag = true; + upper = true; } } - if (i == 0) { - } } - public static void method500(char[] ac) { - for (int i = 0; i < 2; i++) { - for (int j = aCharArrayArray621.length - 1; j >= 0; j--) { - method509(aByteArrayArrayArray622[j], ac, aCharArrayArray621[j]); + public static void filterBad(char[] in) { + for (int passes = 0; passes < 2; passes++) { + for (int i = badwords.length - 1; i >= 0; i--) { + filter(badCombinations[i], in, badwords[i]); } } } - public static void method501(char[] ac) { - char[] ac1 = ac.clone(); - char[] ac2 = {'(', 'a', ')'}; - method509(null, ac1, ac2); - char[] ac3 = ac.clone(); - char[] ac4 = {'d', 'o', 't'}; - method509(null, ac3, ac4); - for (int i = aCharArrayArray623.length - 1; i >= 0; i--) { - method502(ac, aCharArrayArray623[i], ac3, ac1); + public static void filterDomains(char[] in) { + char[] filteredAt = in.clone(); + filter(null, filteredAt, new char[]{'(', 'a', ')'}); + char[] filteredDot = in.clone(); + filter(null, filteredDot, new char[]{'d', 'o', 't'}); + for (int i = domains.length - 1; i >= 0; i--) { + filterDomain(in, domains[i], filteredDot, filteredAt); } } - public static void method502(char[] ac, char[] ac1, char[] ac2, char[] ac3) { - if (ac1.length > ac.length) { + public static void filterDomain(char[] in, char[] domain, char[] filteredDot, char[] filteredAt) { + if (domain.length > in.length) { return; } - int j; - for (int k = 0; k <= (ac.length - ac1.length); k += j) { - int l = k; - int i1 = 0; - j = 1; - while (l < ac.length) { - int j1; - char c = ac[l]; - char c1 = '\0'; - if ((l + 1) < ac.length) { - c1 = ac[l + 1]; + + int stride; + for (int start = 0; start <= (in.length - domain.length); start += stride) { + int end = start; + int offset = 0; + stride = 1; + + while (end < in.length) { + int charSize; + char b = in[end]; + char c = '\0'; + + if ((end + 1) < in.length) { + c = in[end + 1]; } - if ((i1 < ac1.length) && (((j1 = method511(c, ac1[i1], c1))) > 0)) { - l += j1; - i1++; + + if ((offset < domain.length) && (((charSize = getEmulatedDomainCharSize(domain[offset], b, c))) > 0)) { + end += charSize; + offset++; continue; } - if (i1 == 0) { + + if (offset == 0) { break; } - if ((j1 = method511(c, ac1[i1 - 1], c1)) > 0) { - l += j1; - if (i1 == 1) { - j++; + if ((charSize = getEmulatedDomainCharSize(domain[offset - 1], b, c)) > 0) { + end += charSize; + if (offset == 1) { + stride++; } continue; } - if ((i1 >= ac1.length) || !method517(c)) { + if ((offset >= domain.length) || !isSymbol(b)) { break; } - l++; + end++; } - if (i1 >= ac1.length) { + if (offset >= domain.length) { boolean flag1 = false; - int k1 = method503(ac, ac3, k); - int l1 = method504(ac2, l - 1, ac); + int k1 = method503(in, filteredAt, start); + int l1 = method504(filteredDot, end - 1, in); if ((k1 > 2) || (l1 > 2)) { flag1 = true; } if (flag1) { - for (int i2 = k; i2 < l; i2++) { - ac[i2] = '*'; + for (int i2 = start; i2 < end; i2++) { + in[i2] = '*'; } } } @@ -245,7 +242,7 @@ public static int method503(char[] ac, char[] ac1, int j) { return 2; } for (int k = j - 1; k >= 0; k--) { - if (!method517(ac[k])) { + if (!isSymbol(ac[k])) { break; } if (ac[k] == '@') { @@ -254,7 +251,7 @@ public static int method503(char[] ac, char[] ac1, int j) { } int l = 0; for (int i1 = j - 1; i1 >= 0; i1--) { - if (!method517(ac1[i1])) { + if (!isSymbol(ac1[i1])) { break; } if (ac1[i1] == '*') { @@ -264,7 +261,7 @@ public static int method503(char[] ac, char[] ac1, int j) { if (l >= 3) { return 4; } - return !method517(ac[j - 1]) ? 0 : 1; + return !isSymbol(ac[j - 1]) ? 0 : 1; } public static int method504(char[] ac, int i, char[] ac1) { @@ -272,7 +269,7 @@ public static int method504(char[] ac, int i, char[] ac1) { return 2; } for (int j = i + 1; j < ac1.length; j++) { - if (!method517(ac1[j])) { + if (!isSymbol(ac1[j])) { break; } if ((ac1[j] == '.') || (ac1[j] == ',')) { @@ -281,7 +278,7 @@ public static int method504(char[] ac, int i, char[] ac1) { } int k = 0; for (int l = i + 1; l < ac1.length; l++) { - if (!method517(ac[l])) { + if (!isSymbol(ac[l])) { break; } if (ac[l] == '*') { @@ -291,22 +288,22 @@ public static int method504(char[] ac, int i, char[] ac1) { if (k >= 3) { return 4; } - return !method517(ac1[i + 1]) ? 0 : 1; + return !isSymbol(ac1[i + 1]) ? 0 : 1; } - public static void method505(char[] ac) { - char[] ac1 = ac.clone(); - char[] ac2 = {'d', 'o', 't'}; - method509(null, ac1, ac2); - char[] ac3 = ac.clone(); - char[] ac4 = {'s', 'l', 'a', 's', 'h'}; - method509(null, ac3, ac4); - for (int i = 0; i < aCharArrayArray624.length; i++) { - method506(ac3, aCharArrayArray624[i], anIntArray625[i], ac1, ac); + public static void filterTLD(char[] in) { + char[] filteredDot = in.clone(); + filter(null, filteredDot, new char[]{'d', 'o', 't'}); + + char[] filteredSlash = in.clone(); + filter(null, filteredSlash, new char[]{'s', 'l', 'a', 's', 'h'}); + + for (int i = 0; i < tlds.length; i++) { + filterTLD(filteredSlash, tlds[i], tldType[i], filteredDot, in); } } - public static void method506(char[] ac, char[] ac1, int i, char[] ac2, char[] ac3) { + public static void filterTLD(char[] ac, char[] ac1, int i, char[] ac2, char[] ac3) { if (ac1.length > ac3.length) { return; } @@ -322,7 +319,7 @@ public static void method506(char[] ac, char[] ac1, int i, char[] ac2, char[] ac if ((l + 1) < ac3.length) { c1 = ac3[l + 1]; } - if ((i1 < ac1.length) && (((j1 = method511(c, ac1[i1], c1))) > 0)) { + if ((i1 < ac1.length) && (((j1 = getEmulatedDomainCharSize(ac1[i1], c, c1))) > 0)) { l += j1; i1++; continue; @@ -330,14 +327,14 @@ public static void method506(char[] ac, char[] ac1, int i, char[] ac2, char[] ac if (i1 == 0) { break; } - if ((j1 = method511(c, ac1[i1 - 1], c1)) > 0) { + if ((j1 = getEmulatedDomainCharSize(ac1[i1 - 1], c, c1)) > 0) { l += j1; if (i1 == 1) { j++; } continue; } - if ((i1 >= ac1.length) || !method517(c)) { + if ((i1 >= ac1.length) || !isSymbol(c)) { break; } l++; @@ -376,11 +373,11 @@ public static void method506(char[] ac, char[] ac1, int i, char[] ac2, char[] ac boolean flag3 = false; for (int i3 = i2 - 1; i3 >= 0; i3--) { if (flag3) { - if (method517(ac3[i3])) { + if (isSymbol(ac3[i3])) { break; } i2 = i3; - } else if (!method517(ac3[i3])) { + } else if (!isSymbol(ac3[i3])) { flag3 = true; i2 = i3; } @@ -404,11 +401,11 @@ public static void method506(char[] ac, char[] ac1, int i, char[] ac2, char[] ac boolean flag5 = false; for (int k3 = j2 + 1; k3 < ac3.length; k3++) { if (flag5) { - if (method517(ac3[k3])) { + if (isSymbol(ac3[k3])) { break; } j2 = k3; - } else if (!method517(ac3[k3])) { + } else if (!isSymbol(ac3[k3])) { flag5 = true; j2 = k3; } @@ -427,7 +424,7 @@ public static int method507(char[] ac, int j, char[] ac1) { return 2; } for (int k = j - 1; k >= 0; k--) { - if (!method517(ac[k])) { + if (!isSymbol(ac[k])) { break; } if ((ac[k] == ',') || (ac[k] == '.')) { @@ -436,7 +433,7 @@ public static int method507(char[] ac, int j, char[] ac1) { } int l = 0; for (int i1 = j - 1; i1 >= 0; i1--) { - if (!method517(ac1[i1])) { + if (!isSymbol(ac1[i1])) { break; } if (ac1[i1] == '*') { @@ -446,7 +443,7 @@ public static int method507(char[] ac, int j, char[] ac1) { if (l >= 3) { return 4; } - return !method517(ac[j - 1]) ? 0 : 1; + return !isSymbol(ac[j - 1]) ? 0 : 1; } public static int method508(char[] ac, char[] ac1, int i) { @@ -454,7 +451,7 @@ public static int method508(char[] ac, char[] ac1, int i) { return 2; } for (int j = i + 1; j < ac.length; j++) { - if (!method517(ac[j])) { + if (!isSymbol(ac[j])) { break; } if ((ac[j] == '\\') || (ac[j] == '/')) { @@ -463,7 +460,7 @@ public static int method508(char[] ac, char[] ac1, int i) { } int k = 0; for (int l = i + 1; l < ac.length; l++) { - if (!method517(ac1[l])) { + if (!isSymbol(ac1[l])) { break; } if (ac1[l] == '*') { @@ -473,150 +470,184 @@ public static int method508(char[] ac, char[] ac1, int i) { if (k >= 5) { return 4; } - return !method517(ac[i + 1]) ? 0 : 1; + return !isSymbol(ac[i + 1]) ? 0 : 1; } - public static void method509(byte[][] abyte0, char[] ac, char[] ac1) { - if (ac1.length > ac.length) { + private static void filter(byte[][] badCombinations, char[] in, char[] fragment) { + if (fragment.length > in.length) { return; } - int j; - for (int k = 0; k <= (ac.length - ac1.length); k += j) { - int l = k; - int i1 = 0; - int j1 = 0; - j = 1; - boolean flag1 = false; - boolean flag2 = false; - boolean flag3 = false; - while ((l < ac.length) && (!flag2 || !flag3)) { - int k1; - char c = ac[l]; - char c2 = '\0'; - if ((l + 1) < ac.length) { - c2 = ac[l + 1]; - } - if ((i1 < ac1.length) && (((k1 = method512(c2, c, ac1[i1]))) > 0)) { - if ((k1 == 1) && method520(c)) { - flag2 = true; + + int stride; + for (int start = 0; start <= (in.length - fragment.length); start += stride) { + int end = start; + int fragmentOffset = 0; + int iterations = 0; + stride = 1; + + boolean isSymbol = false; + boolean isEmulated = false; // emulated is like typing @sshole + boolean isNumber = false; + + while ((end < in.length) && (!isEmulated || !isNumber)) { + int charSize; + char b = in[end]; + char c = 0; + + if ((end + 1) < in.length) { + c = in[end + 1]; + } + + if ((fragmentOffset < fragment.length) && (((charSize = getEmulatedSize(fragment[fragmentOffset], b, c))) > 0)) { + if ((charSize == 1) && isNumber(b)) { + isEmulated = true; } - if ((k1 == 2) && (method520(c) || method520(c2))) { - flag2 = true; + + if ((charSize == 2) && (isNumber(b) || isNumber(c))) { + isEmulated = true; } - l += k1; - i1++; + + end += charSize; + fragmentOffset++; continue; } - if (i1 == 0) { + + if (fragmentOffset == 0) { break; } - if ((k1 = method512(c2, c, ac1[i1 - 1])) > 0) { - l += k1; - if (i1 == 1) { - j++; + + if ((charSize = getEmulatedSize(fragment[fragmentOffset - 1], b, c)) > 0) { + end += charSize; + if (fragmentOffset == 1) { + stride++; } continue; } - if ((i1 >= ac1.length) || !method518(c)) { + + if ((fragmentOffset >= fragment.length) || !isNotLowerCaseAlpha(b)) { break; } - if (method517(c) && (c != '\'')) { - flag1 = true; + + if (isSymbol(b) && (b != '\'')) { + isSymbol = true; } - if (method520(c)) { - flag3 = true; + + if (isNumber(b)) { + isNumber = true; } - l++; - if (((++j1 * 100) / (l - k)) > 90) { + + end++; + + if (((++iterations * 100) / (end - start)) > 90) { break; } } - if ((i1 >= ac1.length) && (!flag2 || !flag3)) { - boolean flag4 = true; - if (!flag1) { - char c1 = ' '; - if ((k - 1) >= 0) { - c1 = ac[k - 1]; - } - char c3 = ' '; - if (l < ac.length) { - c3 = ac[l]; - } - byte byte0 = method513(c1); - byte byte1 = method513(c3); - if ((abyte0 != null) && method510(byte0, abyte0, byte1)) { - flag4 = false; - } - } else { - boolean flag5 = false; - boolean flag6 = false; - if (((k - 1) < 0) || (method517(ac[k - 1]) && (ac[k - 1] != '\''))) { - flag5 = true; - } - if ((l >= ac.length) || (method517(ac[l]) && (ac[l] != '\''))) { - flag6 = true; + + if ((fragmentOffset < fragment.length) || (isEmulated && isNumber)) { + continue; + } + + boolean bad = true; + + if (!isSymbol) { + char a = ' '; + char b = ' '; + + if ((start - 1) >= 0) { + a = in[start - 1]; + } + + if (end < in.length) { + b = in[end]; + } + + if ((badCombinations != null) && comboMatches(getIndex(a), badCombinations, getIndex(b))) { + bad = false; + } + } else { + boolean badCurrent = false; + boolean badNext = false; + + // if the previous is out of range or a symbol + if (((start - 1) < 0) || (isSymbol(in[start - 1]) && (in[start - 1] != '\''))) { + badCurrent = true; + } + + // if the current is out of range or a symbol + if ((end >= in.length) || (isSymbol(in[end]) && (in[end] != '\''))) { + badNext = true; + } + + if (!badCurrent || !badNext) { + boolean allow = false; + int current = start - 2; + + if (badCurrent) { + current = start; } - if (!flag5 || !flag6) { - boolean flag7 = false; - int k2 = k - 2; - if (flag5) { - k2 = k; + + for (; !allow && (current < end); current++) { + if ((current < 0) || (isSymbol(in[current]) && (in[current] != '\''))) { + continue; } - for (; !flag7 && (k2 < l); k2++) { - if ((k2 >= 0) && (!method517(ac[k2]) || (ac[k2] == '\''))) { - char[] ac2 = new char[3]; - int j3; - for (j3 = 0; j3 < 3; j3++) { - if (((k2 + j3) >= ac.length) || (method517(ac[k2 + j3]) && (ac[k2 + j3] != '\''))) { - break; - } - ac2[j3] = ac[k2 + j3]; - } - boolean flag8 = true; - if (j3 == 0) { - flag8 = false; - } - if ((j3 < 3) && ((k2 - 1) >= 0) && (!method517(ac[k2 - 1]) || (ac[k2 - 1] == '\''))) { - flag8 = false; - } - if (flag8 && !method523(ac2)) { - flag7 = true; - } + + char[] frag = new char[3]; + int offset; + for (offset = 0; offset < 3; offset++) { + if (((current + offset) >= in.length) || (isSymbol(in[current + offset]) && (in[current + offset] != '\''))) { + break; } + frag[offset] = in[current + offset]; } - if (!flag7) { - flag4 = false; + + boolean valid = offset != 0; + + if ((offset < 3) && ((current - 1) >= 0) && (!isSymbol(in[current - 1]) || (in[current - 1] == '\''))) { + valid = false; } - } - } - if (flag4) { - int l1 = 0; - int i2 = 0; - int j2 = -1; - for (int l2 = k; l2 < l; l2++) { - if (method520(ac[l2])) { - l1++; - } else if (method519(ac[l2])) { - i2++; - j2 = l2; + + if (valid && !isBadFragment(frag)) { + allow = true; } } - if (j2 > -1) { - l1 -= l - 1 - j2; - } - if (l1 <= i2) { - for (int i3 = k; i3 < l; i3++) { - ac[i3] = '*'; - } - } else { - j = 1; + if (!allow) { + bad = false; } } } + + if (!bad) { + continue; + } + + int numberCount = 0; + int alphaCount = 0; + int alphaIndex = -1; + + for (int i = start; i < end; i++) { + if (isNumber(in[i])) { + numberCount++; + } else if (isAlpha(in[i])) { + alphaCount++; + alphaIndex = i; + } + } + + if (alphaIndex > -1) { + numberCount -= end - 1 - alphaIndex; + } + + if (numberCount <= alphaCount) { + for (int i = start; i < end; i++) { + in[i] = '*'; + } + } else { + stride = 1; + } } } - public static boolean method510(byte byte0, byte[][] abyte0, byte byte2) { + public static boolean comboMatches(byte byte0, byte[][] abyte0, byte byte2) { int i = 0; if ((abyte0[i][0] == byte0) && (abyte0[i][1] == byte2)) { return true; @@ -639,156 +670,161 @@ public static boolean method510(byte byte0, byte[][] abyte0, byte byte2) { return false; } - public static int method511(char c, char c1, char c2) { - if (c1 == c) { + public static int getEmulatedDomainCharSize(char a, char b, char c) { + if (a == b) { return 1; } - if ((c1 == 'o') && (c == '0')) { + if ((a == 'o') && (b == '0')) { return 1; } - if ((c1 == 'o') && (c == '(') && (c2 == ')')) { + if ((a == 'o') && (b == '(') && (c == ')')) { return 2; } - if ((c1 == 'c') && ((c == '(') || (c == '<') || (c == '['))) { + if ((a == 'c') && ((b == '(') || (b == '<') || (b == '['))) { return 1; } - if ((c1 == 'e') && (c == '\u20AC')) { + if ((a == 'e') && (b == '€')) { return 1; } - if ((c1 == 's') && (c == '$')) { + if ((a == 's') && (b == '$')) { return 1; } - return ((c1 != 'l') || (c != 'i')) ? 0 : 1; + return ((a != 'l') || (b != 'i')) ? 0 : 1; } - public static int method512(char c, char c1, char c2) { - if (c2 == c1) { + public static int getEmulatedSize(char a, char b, char c) { + if (a == b) { return 1; } - if ((c2 >= 'a') && (c2 <= 'm')) { - if (c2 == 'a') { - if ((c1 == '4') || (c1 == '@') || (c1 == '^')) { + + if ((a >= 'a') && (a <= 'm')) { + if (a == 'a') { + if ((b == '4') || (b == '@') || (b == '^')) { return 1; } - return ((c1 != '/') || (c != '\\')) ? 0 : 2; + return ((b != '/') || (c != '\\')) ? 0 : 2; } - if (c2 == 'b') { - if ((c1 == '6') || (c1 == '8')) { + if (a == 'b') { + if ((b == '6') || (b == '8')) { return 1; } - return (((c1 != '1') || (c != '3')) && ((c1 != 'i') || (c != '3'))) ? 0 : 2; + return (((b != '1') || (c != '3')) && ((b != 'i') || (c != '3'))) ? 0 : 2; } - if (c2 == 'c') { - return ((c1 != '(') && (c1 != '<') && (c1 != '{') && (c1 != '[')) ? 0 : 1; + if (a == 'c') { + return ((b != '(') && (b != '<') && (b != '{') && (b != '[')) ? 0 : 1; } - if (c2 == 'd') { - return (((c1 != '[') || (c != ')')) && ((c1 != 'i') || (c != ')'))) ? 0 : 2; + if (a == 'd') { + return (((b != '[') || (c != ')')) && ((b != 'i') || (c != ')'))) ? 0 : 2; } - if (c2 == 'e') { - return ((c1 != '3') && (c1 != '\u20AC')) ? 0 : 1; + if (a == 'e') { + return ((b != '3') && (b != '€')) ? 0 : 1; } - if (c2 == 'f') { - if ((c1 == 'p') && (c == 'h')) { + if (a == 'f') { + if ((b == 'p') && (c == 'h')) { return 2; } - return (c1 != '\243') ? 0 : 1; + return (b != '\243') ? 0 : 1; } - if (c2 == 'g') { - return ((c1 != '9') && (c1 != '6') && (c1 != 'q')) ? 0 : 1; + if (a == 'g') { + return ((b != '9') && (b != '6') && (b != 'q')) ? 0 : 1; } - if (c2 == 'h') { - return (c1 != '#') ? 0 : 1; + if (a == 'h') { + return (b != '#') ? 0 : 1; } - if (c2 == 'i') { - return ((c1 != 'y') && (c1 != 'l') && (c1 != 'j') && (c1 != '1') && (c1 != '!') && (c1 != ':') && (c1 != ';') && (c1 != '|')) ? 0 : 1; + if (a == 'i') { + return ((b != 'y') && (b != 'l') && (b != 'j') && (b != '1') && (b != '!') && (b != ':') && (b != ';') && (b != '|')) ? 0 : 1; } - if (c2 == 'j') { + if (a == 'j') { return 0; } - if (c2 == 'k') { + if (a == 'k') { return 0; } - if (c2 == 'l') { - return ((c1 != '1') && (c1 != '|') && (c1 != 'i')) ? 0 : 1; + if (a == 'l') { + return ((b != '1') && (b != '|') && (b != 'i')) ? 0 : 1; } - if (c2 == 'm') { + if (a == 'm') { return 0; } } - if ((c2 >= 'n') && (c2 <= 'z')) { - if (c2 == 'n') { + if ((a >= 'n') && (a <= 'z')) { + if (a == 'n') { return 0; } - if (c2 == 'o') { - if ((c1 == '0') || (c1 == '*')) { + if (a == 'o') { + if ((b == '0') || (b == '*')) { return 1; } - return (((c1 != '(') || (c != ')')) && ((c1 != '[') || (c != ']')) && ((c1 != '{') || (c != '}')) && ((c1 != '<') || (c != '>'))) ? 0 : 2; + return (((b != '(') || (c != ')')) && ((b != '[') || (c != ']')) && ((b != '{') || (c != '}')) && ((b != '<') || (c != '>'))) ? 0 : 2; } - if (c2 == 'p') { + if (a == 'p') { return 0; } - if (c2 == 'q') { + if (a == 'q') { return 0; } - if (c2 == 'r') { + if (a == 'r') { return 0; } - if (c2 == 's') { - return ((c1 != '5') && (c1 != 'z') && (c1 != '$') && (c1 != '2')) ? 0 : 1; + if (a == 's') { + return ((b != '5') && (b != 'z') && (b != '$') && (b != '2')) ? 0 : 1; } - if (c2 == 't') { - return ((c1 != '7') && (c1 != '+')) ? 0 : 1; + if (a == 't') { + return ((b != '7') && (b != '+')) ? 0 : 1; } - if (c2 == 'u') { - if (c1 == 'v') { + + int v = (((b != '\\') || (c != '/')) && ((b != '\\') || (c != '|')) && ((b != '|') || (c != '/'))) ? 0 : 2; + + if (a == 'u') { + if (b == 'v') { return 1; } - return (((c1 != '\\') || (c != '/')) && ((c1 != '\\') || (c != '|')) && ((c1 != '|') || (c != '/'))) ? 0 : 2; + return v; } - if (c2 == 'v') { - return (((c1 != '\\') || (c != '/')) && ((c1 != '\\') || (c != '|')) && ((c1 != '|') || (c != '/'))) ? 0 : 2; + + if (a == 'v') { + return v; } - if (c2 == 'w') { - return ((c1 != 'v') || (c != 'v')) ? 0 : 2; + if (a == 'w') { + return ((b != 'v') || (c != 'v')) ? 0 : 2; } - if (c2 == 'x') { - return (((c1 != ')') || (c != '(')) && ((c1 != '}') || (c != '{')) && ((c1 != ']') || (c != '[')) && ((c1 != '>') || (c != '<'))) ? 0 : 2; + if (a == 'x') { + return (((b != ')') || (c != '(')) && ((b != '}') || (c != '{')) && ((b != ']') || (c != '[')) && ((b != '>') || (c != '<'))) ? 0 : 2; } - if (c2 == 'y') { + if (a == 'y') { return 0; } - if (c2 == 'z') { + if (a == 'z') { return 0; } } - if ((c2 >= '0') && (c2 <= '9')) { - if (c2 == '0') { - if ((c1 == 'o') || (c1 == 'O')) { + if ((a >= '0') && (a <= '9')) { + if (a == '0') { + if ((b == 'o') || (b == 'O')) { return 1; } - return (((c1 != '(') || (c != ')')) && ((c1 != '{') || (c != '}')) && ((c1 != '[') || (c != ']'))) ? 0 : 2; + return (((b != '(') || (c != ')')) && ((b != '{') || (c != '}')) && ((b != '[') || (c != ']'))) ? 0 : 2; } - if (c2 == '1') { - return (c1 != 'l') ? 0 : 1; + if (a == '1') { + return (b != 'l') ? 0 : 1; } else { return 0; } } - if (c2 == ',') { - return (c1 != '.') ? 0 : 1; + if (a == ',') { + return (b != '.') ? 0 : 1; } - if (c2 == '.') { - return (c1 != ',') ? 0 : 1; + if (a == '.') { + return (b != ',') ? 0 : 1; } - if (c2 == '!') { - return (c1 != 'i') ? 0 : 1; + if (a == '!') { + return (b != 'i') ? 0 : 1; } else { return 0; } } - public static byte method513(char c) { + public static byte getIndex(char c) { if ((c >= 'a') && (c <= 'z')) { return (byte) ((c - 97) + 1); } @@ -802,92 +838,107 @@ public static byte method513(char c) { } } - public static void method514(char[] ac) { - int j; - int k = 0; - int l = 0; - int i1 = 0; - while ((j = method515(ac, k)) != -1) { - boolean flag = false; - for (int j1 = k; (j1 >= 0) && (j1 < j) && !flag; j1++) { - if (!method517(ac[j1]) && !method518(ac[j1])) { - flag = true; + public static void filterFragments(char[] in) { + int index; + int end = 0; + int count = 0; + int start = 0; + + while ((index = indexOfNumber(in, end)) != -1) { + boolean foundLowercase = false; + + for (int i = end; (i >= 0) && (i < index) && !foundLowercase; i++) { + if (!isSymbol(in[i]) && !isNotLowerCaseAlpha(in[i])) { + foundLowercase = true; } } - if (flag) { - l = 0; + + if (foundLowercase) { + count = 0; } - if (l == 0) { - i1 = j; + + if (count == 0) { + start = index; } - k = method516(ac, j); - int k1 = 0; - for (int l1 = j; l1 < k; l1++) { - k1 = ((k1 * 10) + ac[l1]) - 48; + + end = indexOfNonNumber(in, index); + + // parse number from string + int value = 0; + for (int i = index; i < end; i++) { + value = ((value * 10) + in[i]) - '0'; } - if ((k1 > 255) || ((k - j) > 8)) { - l = 0; + + // if our value is over 0xFF or the number uses over 8 characters + // then reset the counter + if ((value > 255) || ((end - index) > 8)) { + count = 0; } else { - l++; + count++; } - if (l == 4) { - for (int i2 = i1; i2 < k; i2++) { - ac[i2] = '*'; + + // If we found 4 separate numbers with their parsed values under + // 255 then replace everything from start to end of these number + // with asterisks. + if (count == 4) { + for (int i2 = start; i2 < end; i2++) { + in[i2] = '*'; } - l = 0; + count = 0; } } } - public static int method515(char[] ac, int i) { - for (int k = i; (k < ac.length) && (k >= 0); k++) { - if ((ac[k] >= '0') && (ac[k] <= '9')) { - return k; + public static int indexOfNumber(char[] in, int off) { + for (int i = off; (i < in.length) && (i >= 0); i++) { + if ((in[i] >= '0') && (in[i] <= '9')) { + return i; } } return -1; } - public static int method516(char[] ac, int j) { - for (int k = j; (k < ac.length) && (k >= 0); k++) { - if ((ac[k] < '0') || (ac[k] > '9')) { - return k; + public static int indexOfNonNumber(char[] in, int off) { + for (int i = off; (i < in.length) && (i >= 0); i++) { + if ((in[i] < '0') || (in[i] > '9')) { + return i; } } - return ac.length; + return in.length; } - public static boolean method517(char c) { - return !method519(c) && !method520(c); + public static boolean isSymbol(char c) { + return !isAlpha(c) && !isNumber(c); } - public static boolean method518(char c) { + public static boolean isNotLowerCaseAlpha(char c) { if ((c < 'a') || (c > 'z')) { return true; } return (c == 'v') || (c == 'x') || (c == 'j') || (c == 'q') || (c == 'z'); } - public static boolean method519(char c) { + public static boolean isAlpha(char c) { return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')); } - public static boolean method520(char c) { + public static boolean isNumber(char c) { return (c >= '0') && (c <= '9'); } - public static boolean method521(char c) { + public static boolean isLowerCase(char c) { return (c >= 'a') && (c <= 'z'); } - public static boolean method522(char c) { + public static boolean isUpperCase(char c) { return (c >= 'A') && (c <= 'Z'); } - public static boolean method523(char[] ac) { + // I stopped caring right about here. -Dane + public static boolean isBadFragment(char[] in) { boolean flag = true; - for (char c : ac) { - if (!method520(c) && (c != 0)) { + for (char c : in) { + if (!isNumber(c) && (c != 0)) { flag = false; break; } @@ -895,21 +946,22 @@ public static boolean method523(char[] ac) { if (flag) { return true; } - int j = method524(ac); + + int index = method524(in); int k = 0; - int l = anIntArray620.length - 1; - if ((j == anIntArray620[k]) || (j == anIntArray620[l])) { + int l = fragments.length - 1; + if ((index == fragments[k]) || (index == fragments[l])) { return true; } do { - int i1 = (k + l) / 2; - if (j == anIntArray620[i1]) { + int mid = (k + l) / 2; + if (index == fragments[mid]) { return true; } - if (j < anIntArray620[i1]) { - l = i1; + if (index < fragments[mid]) { + l = mid; } else { - k = i1; + k = mid; } } while ((k != l) && ((k + 1) != l)); return false; @@ -919,20 +971,20 @@ public static int method524(char[] ac) { if (ac.length > 6) { return 0; } - int k = 0; + int index = 0; for (int l = 0; l < ac.length; l++) { char c = ac[ac.length - l - 1]; if ((c >= 'a') && (c <= 'z')) { - k = (((k * 38) + c) - 97) + 1; + index = (((index * 38) + c) - 97) + 1; } else if (c == '\'') { - k = (k * 38) + 27; + index = (index * 38) + 27; } else if ((c >= '0') && (c <= '9')) { - k = (((k * 38) + c) - 48) + 28; + index = (((index * 38) + c) - 48) + 28; } else if (c != 0) { return 0; } } - return k; + return index; } } diff --git a/src/main/java/ChatCompression.java b/src/main/java/ChatCompression.java index 320ee16..cdc41dc 100644 --- a/src/main/java/ChatCompression.java +++ b/src/main/java/ChatCompression.java @@ -19,7 +19,7 @@ public static String unpack(int length, Buffer in) { int carry = -1; for (int i = 0; i < length; i++) { - int value = in.read8U(); + int value = in.readU8(); int nibble = (value >> 4) & 0b1111; if (carry == -1) { diff --git a/src/main/java/FileArchive.java b/src/main/java/FileArchive.java index 3ebb584..3b1ef9c 100644 --- a/src/main/java/FileArchive.java +++ b/src/main/java/FileArchive.java @@ -37,7 +37,7 @@ public void load(byte[] src) throws IOException { unpacked = false; } - fileCount = buffer.read16U(); + fileCount = buffer.readU16(); fileHash = new int[fileCount]; fileSizeInflated = new int[fileCount]; fileSizeDeflated = new int[fileCount]; diff --git a/src/main/java/FloType.java b/src/main/java/FloType.java index 266a73d..fff70f5 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.read16U(); + count = buffer.readU16(); if (instances == null) { instances = new FloType[count]; } @@ -38,14 +38,14 @@ public FloType() { public void read(Buffer in) { while (true) { - int code = in.read8U(); + int code = in.readU8(); if (code == 0) { return; } else if (code == 1) { rgb = in.read24(); setColor(rgb); } else if (code == 2) { - textureID = in.read8U(); + textureID = in.readU8(); } else if (code == 3) { } else if (code == 5) { occludes = false; diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 3bfb1fd..ae71c05 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -1080,7 +1080,7 @@ public void load() throws IOException { areaViewportOffsets = Draw3D.lineOffset; Scene.init(512, 334); - Censor.method487(archiveWordenc); + Censor.unpack(archiveWordenc); mouseRecorder = new MouseRecorder(this); startThread(mouseRecorder = new MouseRecorder(this), 10); @@ -3311,10 +3311,10 @@ public void readPlayerUpdates() { for (int i = 0; i < entityUpdateCount; i++) { int playerID = entityUpdateIDs[i]; PlayerEntity player = players[playerID]; - int updates = in.read8U(); + int updates = in.readU8(); if ((updates & 0x40) != 0) { - updates += in.read8U() << 8; + updates += in.readU8() << 8; } if ((updates & 0x400) != 0) { @@ -3360,20 +3360,20 @@ public void readPlayerUpdates() { } private void readPlayerForceMovement(PlayerEntity player) { - player.forceMoveStartSceneTileX = in.read8US(); - player.forceMoveStartSceneTileZ = in.read8US(); - player.forceMoveEndSceneTileX = in.read8US(); - player.forceMoveEndSceneTileZ = in.read8US(); - player.forceMoveEndCycle = in.read16ULEA() + loopCycle; - player.forceMoveStartCycle = in.read16UA() + loopCycle; - player.forceMoveFaceDirection = in.read8US(); + player.forceMoveStartSceneTileX = in.readU8S(); + player.forceMoveStartSceneTileZ = in.readU8S(); + player.forceMoveEndSceneTileX = in.readU8S(); + player.forceMoveEndSceneTileZ = in.readU8S(); + player.forceMoveEndCycle = in.readU16LEA() + loopCycle; + player.forceMoveStartCycle = in.readU16A() + loopCycle; + player.forceMoveFaceDirection = in.readU8S(); player.resetPath(); } private void readPlayerGraphic(PlayerEntity player) { - player.spotanimID = in.read16ULE(); - player.spotanimOffset = in.read16U(); - player.spotanimLastCycle = loopCycle + in.read16U(); + player.spotanimID = in.readU16LE(); + player.spotanimOffset = in.readU16(); + player.spotanimLastCycle = loopCycle + in.readU16(); player.spotanimFrame = 0; player.spotanimCycle = 0; @@ -3387,13 +3387,13 @@ private void readPlayerGraphic(PlayerEntity player) { } private void readPlayerAnimation(PlayerEntity player) { - int seqID = in.read16ULE(); + int seqID = in.readU16LE(); if (seqID == 65535) { seqID = -1; } - int delay = in.read8UC(); + int delay = in.readU8C(); if ((seqID == player.primarySeqID) && (seqID != -1)) { int style = SeqType.instances[seqID].replayStyle; @@ -3434,9 +3434,9 @@ private void readPlayerChatForced(PlayerEntity player) { } private void readPlayerChat(PlayerEntity player) { - int colorStyle = in.read16ULE(); - int role = in.read8U(); - int length = in.read8UC(); + int colorStyle = in.readU16LE(); + int role = in.readU8(); + int length = in.readU8C(); int start = in.position; if ((player.name != null) && player.visible) { @@ -3460,7 +3460,7 @@ private void readPlayerChat(PlayerEntity player) { chatBuffer.position = 0; String chat = ChatCompression.unpack(length, chatBuffer); - chat = Censor.apply(chat); + chat = Censor.filter(chat); player.chat = chat; player.chatColor = colorStyle >> 8; @@ -3484,7 +3484,7 @@ private void readPlayerChat(PlayerEntity player) { } private void readPlayerTargetEntity(PlayerEntity player) { - player.targetID = in.read16ULE(); + player.targetID = in.readU16LE(); if (player.targetID == 65535) { player.targetID = -1; @@ -3492,33 +3492,33 @@ private void readPlayerTargetEntity(PlayerEntity player) { } private void readPlayerAppearance(int playerID, PlayerEntity player) { - Buffer buffer = new Buffer(new byte[in.read8UC()]); + Buffer buffer = new Buffer(new byte[in.readU8C()]); in.read(buffer.data); playerAppearanceBuffer[playerID] = buffer; player.read(buffer); } private void readPlayerTargetTile(PlayerEntity player) { - player.targetTileX = in.read16ULEA(); - player.targetTileZ = in.read16ULE(); + player.targetTileX = in.readU16LEA(); + player.targetTileZ = in.readU16LE(); } private void readPlayerDamage0(PlayerEntity player) { - int damage = in.read8U(); - int type = in.read8UA(); + int damage = in.readU8(); + int type = in.readU8A(); player.hit(type, damage); player.combatCycle = loopCycle + 300; - player.health = in.read8UC(); - player.totalHealth = in.read8U(); + player.health = in.readU8C(); + player.totalHealth = in.readU8(); } private void readPlayerDamage1(PlayerEntity player) { - int damage = in.read8U(); - int type = in.read8US(); + int damage = in.readU8(); + int type = in.readU8S(); player.hit(type, damage); player.combatCycle = loopCycle + 300; - player.health = in.read8U(); - player.totalHealth = in.read8UC(); + player.health = in.readU8(); + player.totalHealth = in.readU8C(); } public void drawMinimapLoc(int tileZ, int wallRGB, int tileX, int doorRGB, int level) { @@ -6095,7 +6095,7 @@ private void handleInputChatKey(int key) { out.writeA(chatBuffer.data, 0, chatBuffer.position); out.writeSize(out.position - startPosition); chatTyped = ChatCompression.format(chatTyped); - chatTyped = Censor.apply(chatTyped); + chatTyped = Censor.filter(chatTyped); localPlayer.chat = chatTyped; localPlayer.chatColor = color; localPlayer.chatStyle = style; @@ -6198,7 +6198,7 @@ private void handleInputSocialKey(int key) { ChatCompression.pack(socialInput, out); out.writeSize(out.position - start); socialInput = ChatCompression.format(socialInput); - socialInput = Censor.apply(socialInput); + socialInput = Censor.filter(socialInput); addMessage(6, StringUtil.formatName(StringUtil.fromBase37(inputFriendName37)), socialInput); if (privateChatSetting == 2) { privateChatSetting = 1; @@ -7483,7 +7483,7 @@ public void readNPCUpdates() { for (int i = 0; i < entityUpdateCount; i++) { NPCEntity npc = npcs[entityUpdateIDs[i]]; - int updates = in.read8U(); + int updates = in.readU8(); if ((updates & 0x10) != 0) { readNPCAnimation(npc); @@ -7520,9 +7520,9 @@ public void readNPCUpdates() { } private void readNPCGraphic(NPCEntity npc) { - npc.spotanimID = in.read16U(); - npc.spotanimOffset = in.read16U(); - npc.spotanimLastCycle = loopCycle + in.read16U(); + npc.spotanimID = in.readU16(); + npc.spotanimOffset = in.readU16(); + npc.spotanimLastCycle = loopCycle + in.readU16(); npc.spotanimFrame = 0; npc.spotanimCycle = 0; if (npc.spotanimLastCycle > loopCycle) { @@ -7534,15 +7534,15 @@ private void readNPCGraphic(NPCEntity npc) { } private void readNPCTargetEntity(NPCEntity npc) { - npc.targetID = in.read16U(); + npc.targetID = in.readU16(); if (npc.targetID == 65535) { npc.targetID = -1; } } private void readNPCTargetTile(NPCEntity npc) { - npc.targetTileX = in.read16ULE(); - npc.targetTileZ = in.read16ULE(); + npc.targetTileX = in.readU16LE(); + npc.targetTileZ = in.readU16LE(); } private void readNPCChat(NPCEntity npc) { @@ -7551,16 +7551,16 @@ private void readNPCChat(NPCEntity npc) { } private void readNPCDamage1(NPCEntity npc) { - int damage = in.read8UC(); - int type = in.read8US(); + int damage = in.readU8C(); + int type = in.readU8S(); npc.hit(type, damage); npc.combatCycle = loopCycle + 300; - npc.health = in.read8US(); - npc.totalHealth = in.read8UC(); + npc.health = in.readU8S(); + npc.totalHealth = in.readU8C(); } private void readNPCTransform(NPCEntity npc) { - npc.type = NPCType.get(in.read16ULEA()); + npc.type = NPCType.get(in.readU16LEA()); npc.size = npc.type.size; npc.turnSpeed = npc.type.turnSpeed; npc.seqWalkID = npc.type.seqWalkID; @@ -7571,13 +7571,13 @@ private void readNPCTransform(NPCEntity npc) { } private void readNPCAnimation(NPCEntity npc) { - int seqID = in.read16ULE(); + int seqID = in.readU16LE(); if (seqID == 65535) { seqID = -1; } - int delay = in.read8U(); + int delay = in.readU8(); if ((seqID == npc.primarySeqID) && (seqID != -1)) { int style = SeqType.instances[seqID].replayStyle; @@ -7602,12 +7602,12 @@ private void readNPCAnimation(NPCEntity npc) { } private void readNPCDamage0(NPCEntity npc) { - int damage = in.read8UA(); - int type = in.read8UC(); + int damage = in.readU8A(); + int type = in.readU8C(); npc.hit(type, damage); npc.combatCycle = loopCycle + 300; - npc.health = in.read8UA(); - npc.totalHealth = in.read8U(); + npc.health = in.readU8A(); + npc.totalHealth = in.readU8(); } public void addNPCOptions(NPCType type, int npcID, int tileZ, int tileX) { @@ -10502,9 +10502,9 @@ public void readZonePacket(int code) { } private void readObjAdd() { - int objID = in.read16ULEA(); - int objCount = in.read16U(); - int pos = in.read8U(); + int objID = in.readU16LEA(); + int objCount = in.readU16(); + int pos = in.readU8(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104)) { @@ -10520,12 +10520,12 @@ private void readObjAdd() { } private void readObjReveal() { - int objID = in.read16UA(); - int pos = in.read8US(); + int objID = in.readU16A(); + int pos = in.readU8S(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); - int ownerPID = in.read16UA(); - int objCount = in.read16U(); + int ownerPID = in.readU16A(); + int objCount = in.readU16(); if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104) && (ownerPID != localPID)) { ObjEntity obj = new ObjEntity(); obj.id = objID; @@ -10539,12 +10539,12 @@ private void readObjReveal() { } private void readObjCount() { - int pos = in.read8U(); + int pos = in.readU8(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); - int objID = in.read16U(); - int oldCount = in.read16U(); - int newCount = in.read16U(); + int objID = in.readU16(); + int oldCount = in.readU16(); + int newCount = in.readU16(); if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104)) { DoublyLinkedList stacks = levelObjStacks[currentLevel][x][z]; @@ -10562,10 +10562,10 @@ private void readObjCount() { } private void readObjDelete() { - int pos = in.read8UA(); + int pos = in.readU8A(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); - int objID = in.read16U(); + int objID = in.readU16(); if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104)) { DoublyLinkedList list = levelObjStacks[currentLevel][x][z]; if (list != null) { @@ -10585,11 +10585,11 @@ private void readObjDelete() { } private void readLocAdd() { - int pos = in.read8UA(); + int pos = in.readU8A(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); - int id = in.read16ULE(); - int info = in.read8US(); + int id = in.readU16LE(); + int info = in.readU8S(); int kind = info >> 2; int rotation = info & 3; int classID = LOC_KIND_TO_CLASS_ID[kind]; @@ -10599,14 +10599,14 @@ private void readLocAdd() { } private void readLocChange() { - int pos = in.read8US(); + int pos = in.readU8S(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); - int info = in.read8US(); + int info = in.readU8S(); int kind = info >> 2; int rotation = info & 3; int classID = LOC_KIND_TO_CLASS_ID[kind]; - int seqID = in.read16UA(); + int seqID = in.readU16A(); if ((x < 0) || (z < 0) || (x >= 103) || (z >= 103)) { return; @@ -10662,11 +10662,11 @@ private void readLocChange() { } private void readLocDelete() { - int info = in.read8UC(); + int info = in.readU8C(); int kind = info >> 2; int rotation = info & 3; int classID = LOC_KIND_TO_CLASS_ID[kind]; - int pos = in.read8U(); + int pos = in.readU8(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104)) { @@ -10675,20 +10675,20 @@ private void readLocDelete() { } private void readLocPlayer() { - int pos = in.read8US(); + int pos = in.readU8S(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); - int pid = in.read16U(); + int pid = in.readU16(); byte maxX = in.read8S(); - int delay = in.read16ULE(); + int delay = in.readU16LE(); byte maxZ = in.read8C(); - int duration = in.read16U(); - int info = in.read8US(); + int duration = in.readU16(); + int info = in.readU8S(); int kind = info >> 2; int rotation = info & 3; int classID = LOC_KIND_TO_CLASS_ID[kind]; - byte minX = in.read(); - int locID = in.read16U(); + byte minX = in.read8(); + int locID = in.readU16(); byte minZ = in.read8C(); PlayerEntity player; @@ -10746,12 +10746,12 @@ private void readLocPlayer() { } private void readMapAnim() { - int pos = in.read8U(); + int pos = in.readU8(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); - int id = in.read16U(); - int y = in.read8U(); - int delay = in.read16U(); + int id = in.readU16(); + int y = in.readU8(); + int delay = in.readU16(); if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104)) { x = (x * 128) + 64; @@ -10762,11 +10762,11 @@ private void readMapAnim() { } private void readMapSound() { - int pos = in.read8U(); + int pos = in.readU8(); int x = baseX + ((pos >> 4) & 7); int z = baseZ + (pos & 7); - int waveID = in.read16U(); - int info = in.read8U(); + int waveID = in.readU16(); + int info = in.readU8(); 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)) && waveEnabled && !lowmem && (waveCount < 50)) { @@ -10778,19 +10778,19 @@ private void readMapSound() { } private void readMapProjectile() { - int pos = in.read8U(); + int pos = in.readU8(); int srcX = baseX + ((pos >> 4) & 7); int srcZ = baseZ + (pos & 7); - int dstX = srcX + in.read(); - int dstZ = srcZ + in.read(); + int dstX = srcX + in.read8(); + int dstZ = srcZ + in.read8(); int targetID = in.read16(); - int spotanimID = in.read16U(); - int srcY = in.read8U() * 4; - int dstY = in.read8U() * 4; - int delay = in.read16U(); - int duration = in.read16U(); - int peakPitch = in.read8U(); - int arcSize = in.read8U(); + int spotanimID = in.readU16(); + int srcY = in.readU8() * 4; + int dstY = in.readU8() * 4; + int delay = in.readU16(); + int duration = in.readU16(); + int peakPitch = in.readU8(); + int arcSize = in.readU8(); 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; @@ -11167,7 +11167,7 @@ public boolean read() { if (available > 1) { connection.read(in.data, 0, 2); in.position = 0; - packetSize = in.read16U(); + packetSize = in.readU16(); bytesIn += 2; available -= 2; } else { @@ -11259,7 +11259,7 @@ public boolean read() { break; case PacketIn.MINIMAP_TOGGLE: - minimapState = in.read8U(); + minimapState = in.readU8(); break; case PacketIn.IF_SETNPCHEAD: @@ -11267,7 +11267,7 @@ public boolean read() { break; case PacketIn.UPDATE_REBOOT_TIMER: - systemUpdateTimer = in.read16ULE() * 30; + systemUpdateTimer = in.readU16LE() * 30; break; case PacketIn.ZONE_UPDATE: @@ -11327,8 +11327,8 @@ public boolean read() { break; case PacketIn.ZONE_BASE: - baseZ = in.read8UC(); - baseX = in.read8UC(); + baseZ = in.readU8C(); + baseX = in.readU8C(); break; case PacketIn.TAB_HINT: @@ -11376,13 +11376,13 @@ public boolean read() { break; case PacketIn.FRIENDLIST_LOADED: - friendlistStatus = in.read8U(); + friendlistStatus = in.readU8(); redrawSidebar = true; break; case PacketIn.LOCAL_PLAYER: - isMember = in.read8UA(); - localPID = in.read16ULEA(); + isMember = in.readU8A(); + localPID = in.readU16LEA(); break; case PacketIn.SYNC_NPCS: @@ -11415,7 +11415,7 @@ public boolean read() { break; case PacketIn.MULTIZONE: - multizone = in.read8U(); + multizone = in.readU8(); break; case PacketIn.IF_SETANIM: @@ -11475,11 +11475,11 @@ public boolean read() { } private void readLastLoginInfo() { - daysSinceRecoveriesChanged = in.read8UC(); - unreadMessages = in.read16UA(); - warnMembersInNonMembers = in.read8U(); + daysSinceRecoveriesChanged = in.readU8C(); + unreadMessages = in.readU16A(); + warnMembersInNonMembers = in.readU8(); lastAddress = in.read32ME(); - daysSinceLastLogin = in.read16U(); + daysSinceLastLogin = in.readU16(); if ((lastAddress != 0) && (viewportInterfaceID == -1)) { Signlink.dnslookup(StringUtil.formatIPv4(lastAddress)); @@ -11505,8 +11505,8 @@ private void readLastLoginInfo() { } private void readZoneClear() { - baseX = in.read8UC(); - baseZ = in.read8US(); + baseX = in.readU8C(); + baseZ = in.readU8S(); for (int x = baseX; x < (baseX + 8); x++) { for (int z = baseZ; z < (baseZ + 8); z++) { if (levelObjStacks[currentLevel][x][z] != null) { @@ -11523,7 +11523,7 @@ private void readZoneClear() { } private void readIfSetPlayerHead() { - int interfaceID = in.read16ULEA(); + int interfaceID = in.readU16LEA(); IfType iface = IfType.instances[interfaceID]; iface.modelType = IfType.MODEL_TYPE_PLAYER; @@ -11542,7 +11542,7 @@ private void readCameraReset() { } private void readInventoryClear() { - int interfaceID = in.read16ULE(); + int interfaceID = in.readU16LE(); IfType iface = IfType.instances[interfaceID]; for (int slot = 0; slot < iface.inventorySlotObjID.length; slot++) { iface.inventorySlotObjID[slot] = -1; @@ -11559,11 +11559,11 @@ private void readIgnoreList() { private void readCameraSetPos() { cutscene = true; - cutsceneSrcLocalTileX = in.read8U(); - cutsceneSrcLocalTileZ = in.read8U(); - cutsceneSrcHeight = in.read16U(); - cutsceneMoveSpeed = in.read8U(); - cutsceneMoveAcceleration = in.read8U(); + cutsceneSrcLocalTileX = in.readU8(); + cutsceneSrcLocalTileZ = in.readU8(); + cutsceneSrcHeight = in.readU16(); + cutsceneMoveSpeed = in.readU8(); + cutsceneMoveAcceleration = in.readU8(); if (cutsceneMoveAcceleration >= 100) { cameraX = (cutsceneSrcLocalTileX * 128) + 64; @@ -11574,11 +11574,11 @@ private void readCameraSetPos() { private void readCameraLookAt() { cutscene = true; - cutsceneDstLocalTileX = in.read8U(); - cutsceneDstLocalTileZ = in.read8U(); - cutsceneDstHeight = in.read16U(); - cutsceneRotateSpeed = in.read8U(); - cutsceneRotateAcceleration = in.read8U(); + cutsceneDstLocalTileX = in.readU8(); + cutsceneDstLocalTileZ = in.readU8(); + cutsceneDstHeight = in.readU16(); + cutsceneRotateSpeed = in.readU8(); + cutsceneRotateAcceleration = in.readU8(); if (cutsceneRotateAcceleration >= 100) { int sceneX = (cutsceneDstLocalTileX * 128) + 64; @@ -11601,9 +11601,9 @@ private void readCameraLookAt() { private void readUpdateStat() { redrawSidebar = true; - int skill = in.read8U(); + int skill = in.readU8(); int experience = in.read32RME(); - int level = in.read8U(); + int level = in.readU8(); skillExperience[skill] = experience; skillLevel[skill] = level; skillBaseLevel[skill] = 1; @@ -11615,8 +11615,8 @@ private void readUpdateStat() { } private void readIfTab() { - int interfaceID = in.read16U(); - int tab = in.read8UA(); + int interfaceID = in.readU16(); + int tab = in.readU8A(); if (interfaceID == 65535) { interfaceID = -1; } @@ -11626,7 +11626,7 @@ private void readIfTab() { } private void readMidiSong() { - int next = in.read16ULE(); + int next = in.readU16LE(); if (next == 65535) { next = -1; } @@ -11639,8 +11639,8 @@ private void readMidiSong() { } private void readMidiJingle() { - int next = in.read16ULEA(); - int delay = in.read16UA(); + int next = in.readU16LEA(); + int delay = in.readU16A(); if (midiEnabled && !lowmem) { song = next; songFading = false; @@ -11652,7 +11652,7 @@ private void readMidiJingle() { private void readIfSetPosition() { int x = in.read16(); int y = in.read16LE(); - int interfaceID = in.read16ULE(); + int interfaceID = in.readU16LE(); IfType iface = IfType.instances[interfaceID]; iface.x = x; iface.y = y; @@ -11663,13 +11663,13 @@ private void readRebuildRegion() { int zoneZ = sceneCenterZoneZ; if (packetType == PacketIn.REBUILD_REGION) { - zoneX = in.read16UA(); - zoneZ = in.read16U(); + zoneX = in.readU16A(); + zoneZ = in.readU16(); sceneInstanced = false; } if (packetType == PacketIn.REBUILD_REGION_INSTANCE) { - zoneZ = in.read16UA(); + zoneZ = in.readU16A(); in.accessBits(); for (int level = 0; level < 4; level++) { @@ -11685,7 +11685,7 @@ private void readRebuildRegion() { } in.accessBytes(); - zoneX = in.read16U(); + zoneX = in.readU16(); sceneInstanced = true; } @@ -11914,25 +11914,25 @@ private void readIfViewportOverlay() { } private void readIfSetNPCHead() { - int npcID = in.read16ULEA(); - int interfaceID = in.read16ULEA(); + int npcID = in.readU16LEA(); + int interfaceID = in.readU16LEA(); IfType.instances[interfaceID].modelType = IfType.MODEL_TYPE_NPC; IfType.instances[interfaceID].modelID = npcID; } private void readZoneUpdate() { - baseZ = in.read8U(); - baseX = in.read8UC(); + baseZ = in.readU8(); + baseX = in.readU8C(); while (in.position < packetSize) { - readZonePacket(in.read8U()); + readZonePacket(in.readU8()); } } private void readCameraShake() { - int type = in.read8U(); - int jitterScale = in.read8U(); - int wobbleScale = in.read8U(); - int wobbleSpeed = in.read8U(); + int type = in.readU8(); + int jitterScale = in.readU8(); + int wobbleScale = in.readU8(); + int wobbleSpeed = in.readU8(); cameraModifierEnabled[type] = true; cameraModifierJitter[type] = jitterScale; cameraModifierWobbleScale[type] = wobbleScale; @@ -11941,9 +11941,9 @@ private void readCameraShake() { } private void readSynthSound() { - int waveID = in.read16U(); - int loopCount = in.read8U(); - int delay = in.read16U(); + int waveID = in.readU16(); + int loopCount = in.readU8(); + int delay = in.readU16(); if (waveEnabled && !lowmem && (waveCount < 50)) { waveIDs[waveCount] = waveID; waveLoops[waveCount] = loopCount; @@ -11953,8 +11953,8 @@ private void readSynthSound() { } private void readSetPlayerOp() { - int option = in.read8UC(); - int priority = in.read8UA(); + int option = in.readU8C(); + int priority = in.readU8A(); String text = in.readString(); if ((option >= 1) && (option <= 5)) { if (text.equalsIgnoreCase("null")) { @@ -12035,7 +12035,7 @@ private void resetAnimations() { private void readFriendStatus() { long name37 = in.read64(); - int world = in.read8U(); + int world = in.readU8(); String name = StringUtil.formatName(StringUtil.fromBase37(name37)); for (int i = 0; i < friendCount; i++) { @@ -12090,14 +12090,14 @@ private void readUpdateRunEnergy() { if (selectedTab == 12) { redrawSidebar = true; } - energy = in.read8U(); + energy = in.readU8(); } private void readHintArrow() { - hintType = in.read8U(); + hintType = in.readU8(); if (hintType == 1) { - hintNPC = in.read16U(); + hintNPC = in.readU16(); } if ((hintType >= 2) && (hintType <= 6)) { @@ -12122,19 +12122,19 @@ private void readHintArrow() { hintOffsetZ = 128; } hintType = 2; - hintTileX = in.read16U(); - hintTileZ = in.read16U(); - hintHeight = in.read8U(); + hintTileX = in.readU16(); + hintTileZ = in.readU16(); + hintHeight = in.readU8(); } if (hintType == 10) { - hintPlayer = in.read16U(); + hintPlayer = in.readU16(); } } private void readIfViewportAndSidebar() { - int viewportInterfaceID = in.read16UA(); - int sidebarInterfaceID = in.read16U(); + int viewportInterfaceID = in.readU16A(); + int sidebarInterfaceID = in.readU16(); if (chatInterfaceID != -1) { chatInterfaceID = -1; @@ -12154,8 +12154,8 @@ private void readIfViewportAndSidebar() { } private void readIfSetScrollPos() { - int interfaceID = in.read16ULE(); - int scrollPos = in.read16UA(); + int interfaceID = in.readU16LE(); + int scrollPos = in.readU16A(); IfType iface = IfType.instances[interfaceID]; if ((iface != null) && (iface.type == IfType.TYPE_PARENT)) { if (scrollPos < 0) { @@ -12181,7 +12181,7 @@ private void restoreVarCache() { private void readMessagePublic() { long name37 = in.read64(); int messageID = in.read32(); - int role = in.read8U(); + int role = in.readU8(); boolean ignore = false; for (int i = 0; i < 100; i++) { if (messageIDs[i] == messageID) { @@ -12206,7 +12206,7 @@ private void readMessagePublic() { String message = ChatCompression.unpack(packetSize - 13, in); if (role != 3) { - message = Censor.apply(message); + message = Censor.filter(message); } if ((role == 2) || (role == 3)) { @@ -12223,7 +12223,7 @@ private void readMessagePublic() { } private void readTabHint() { - flashingTab = in.read8US(); + flashingTab = in.readU8S(); if (flashingTab == selectedTab) { if (flashingTab == 3) { selectedTab = 1; @@ -12235,9 +12235,9 @@ private void readTabHint() { } private void readIfSetObject() { - int interfaceID = in.read16ULE(); - int zoom = in.read16U(); - int objID = in.read16U(); + int interfaceID = in.readU16LE(); + int zoom = in.readU16(); + int objID = in.readU16(); if (objID != 65535) { ObjType type = ObjType.get(objID); @@ -12253,13 +12253,13 @@ private void readIfSetObject() { } private void readIfSetHide() { - boolean hide = in.read8U() == 1; - int interfaceID = in.read16U(); + boolean hide = in.readU8() == 1; + int interfaceID = in.readU16(); IfType.instances[interfaceID].hide = hide; } private void readIfStopAnim() { - int interfaceID = in.read16ULE(); + int interfaceID = in.readU16LE(); resetInterfaceAnimation(interfaceID); if (chatInterfaceID != -1) { chatInterfaceID = -1; @@ -12278,7 +12278,7 @@ private void readIfStopAnim() { private void readIfSetText() { String text = in.readString(); - int interfaceID = in.read16UA(); + int interfaceID = in.readU16A(); if ((interfaceID >= 0) && (interfaceID < IfType.instances.length)) { IfType iface = IfType.instances[interfaceID]; if (iface != null) { @@ -12291,9 +12291,9 @@ private void readIfSetText() { } private void readChatFilterSettings() { - publicChatSetting = in.read8U(); - privateChatSetting = in.read8U(); - tradeChatSetting = in.read8U(); + publicChatSetting = in.readU8(); + privateChatSetting = in.readU8(); + tradeChatSetting = in.readU8(); redrawPrivacySettings = true; redrawChatback = true; } @@ -12306,15 +12306,15 @@ private void readUpdateRunWeight() { } private void readIfSetModel() { - int interfaceID = in.read16ULEA(); - int modelID = in.read16U(); + int interfaceID = in.readU16LEA(); + int modelID = in.readU16(); IfType.instances[interfaceID].modelType = IfType.MODEL_TYPE_NORMAL; IfType.instances[interfaceID].modelID = modelID; } private void readIfSetColor() { - int interfaceID = in.read16ULEA(); - int rgb555 = in.read16ULEA(); + int interfaceID = in.readU16LEA(); + int rgb555 = in.readU16LEA(); int r = (rgb555 >> 10) & 0x1f; int g = (rgb555 >> 5) & 0x1f; int b = rgb555 & 0x1f; @@ -12323,21 +12323,21 @@ private void readIfSetColor() { private void readUpdateInvFull() { redrawSidebar = true; - int interfaceID = in.read16U(); + int interfaceID = in.readU16(); IfType iface = IfType.instances[interfaceID]; - int lastSlot = in.read16U(); + int lastSlot = in.readU16(); for (int slot = 0; slot < lastSlot; slot++) { - int objCount = in.read8U(); + int objCount = in.readU8(); if (objCount == 255) { objCount = in.read32ME(); } if (slot >= iface.inventorySlotObjID.length) { - in.read16ULEA(); + in.readU16LEA(); } else { - iface.inventorySlotObjID[slot] = in.read16ULEA(); + iface.inventorySlotObjID[slot] = in.readU16LEA(); iface.inventorySlotObjCount[slot] = objCount; } } @@ -12350,10 +12350,10 @@ private void readUpdateInvFull() { } private void readIfSetAngle() { - int zoom = in.read16UA(); - int interfaceID = in.read16U(); - int pitch = in.read16U(); - int yaw = in.read16ULEA(); + int zoom = in.readU16A(); + int interfaceID = in.readU16(); + int pitch = in.readU16(); + int yaw = in.readU16LEA(); IfType.instances[interfaceID].modelPitch = pitch; IfType.instances[interfaceID].modelYaw = yaw; IfType.instances[interfaceID].modelZoom = zoom; @@ -12385,13 +12385,13 @@ private void openViewportInterface(int interfaceID) { } private void readViewportInterface() { - int interfaceID = in.read16U(); + int interfaceID = in.readU16(); resetInterfaceAnimation(interfaceID); openViewportInterface(interfaceID); } private void readVarpLarge() { - int varpID = in.read16ULE(); + int varpID = in.readU16LE(); int value = in.read32RME(); varCache[varpID] = value; @@ -12406,8 +12406,8 @@ private void readVarpLarge() { } private void readVarpSmall() { - int varpID = in.read16ULE(); - byte value = in.read(); + int varpID = in.readU16LE(); + byte value = in.read8(); varCache[varpID] = value; if (varps[varpID] != value) { @@ -12421,7 +12421,7 @@ private void readVarpSmall() { } private void readIfSetAnim() { - int interfaceID = in.read16U(); + int interfaceID = in.readU16(); int seqID = in.read16(); IfType iface = IfType.instances[interfaceID]; iface.seqID = seqID; @@ -12433,13 +12433,13 @@ private void readIfSetAnim() { private void readUpdateInvPartial() { redrawSidebar = true; - int interfaceID = in.read16U(); + int interfaceID = in.readU16(); IfType iface = IfType.instances[interfaceID]; while (in.position < packetSize) { - int slot = in.readSmartU(); - int objID = in.read16U(); - int objCount = in.read8U(); + int slot = in.readUSmart(); + int objID = in.readU16(); + int objCount = in.readU8(); if (objCount == 255) { objCount = in.read32(); } @@ -12451,13 +12451,13 @@ private void readUpdateInvPartial() { } private void readTabSelected() { - selectedTab = in.read8UC(); + selectedTab = in.readU8C(); redrawSidebar = true; redrawSideicons = true; } private void readIfChat() { - int interfaceID = in.read16ULE(); + int interfaceID = in.readU16LE(); resetInterfaceAnimation(interfaceID); if (sidebarInterfaceID != -1) { sidebarInterfaceID = -1; diff --git a/src/main/java/IdkType.java b/src/main/java/IdkType.java index 1ab9941..67dda05 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.read16U(); + count = buffer.readU16(); if (instances == null) { instances = new IdkType[count]; } @@ -35,25 +35,25 @@ public IdkType() { public void read(Buffer in) { while (true) { - int code = in.read8U(); + int code = in.readU8(); if (code == 0) { return; } else if (code == 1) { - type = in.read8U(); + type = in.readU8(); } else if (code == 2) { - int j = in.read8U(); + int j = in.readU8(); modelIDs = new int[j]; for (int k = 0; k < j; k++) { - modelIDs[k] = in.read16U(); + modelIDs[k] = in.readU16(); } } else if (code == 3) { selectable = true; } else if ((code >= 40) && (code < 50)) { - colorSrc[code - 40] = in.read16U(); + colorSrc[code - 40] = in.readU16(); } else if ((code >= 50) && (code < 60)) { - colorDst[code - 50] = in.read16U(); + colorDst[code - 50] = in.readU16(); } else if ((code >= 60) && (code < 70)) { - headModelIDs[code - 60] = in.read16U(); + headModelIDs[code - 60] = in.readU16(); } else { System.out.println("Error unrecognised identikit config code: " + code); } diff --git a/src/main/java/IfType.java b/src/main/java/IfType.java index 9279cf5..e2a157a 100644 --- a/src/main/java/IfType.java +++ b/src/main/java/IfType.java @@ -38,91 +38,91 @@ public static void unpack(FileArchive config, BitmapFont[] fonts, FileArchive me Buffer in = new Buffer(config.read("data")); int parentID = -1; - int count = in.read16U(); + int count = in.readU16(); instances = new IfType[count]; while (in.position < in.data.length) { - int id = in.read16U(); + int id = in.readU16(); if (id == 65535) { - parentID = in.read16U(); - id = in.read16U(); + parentID = in.readU16(); + id = in.readU16(); } IfType iface = instances[id] = new IfType(); iface.id = id; iface.parentID = parentID; - iface.type = in.read8U(); - iface.optionType = in.read8U(); - iface.contentType = in.read16U(); - iface.width = in.read16U(); - iface.height = in.read16U(); - iface.transparency = (byte) in.read8U(); - iface.delegateHover = in.read8U(); + iface.type = in.readU8(); + iface.optionType = in.readU8(); + iface.contentType = in.readU16(); + iface.width = in.readU16(); + iface.height = in.readU16(); + iface.transparency = (byte) in.readU8(); + iface.delegateHover = in.readU8(); if (iface.delegateHover != 0) { - iface.delegateHover = ((iface.delegateHover - 1) << 8) + in.read8U(); + iface.delegateHover = ((iface.delegateHover - 1) << 8) + in.readU8(); } else { iface.delegateHover = -1; } - int comparatorCount = in.read8U(); + int comparatorCount = in.readU8(); if (comparatorCount > 0) { iface.scriptComparator = new int[comparatorCount]; iface.scriptOperand = new int[comparatorCount]; for (int i = 0; i < comparatorCount; i++) { - iface.scriptComparator[i] = in.read8U(); - iface.scriptOperand[i] = in.read16U(); + iface.scriptComparator[i] = in.readU8(); + iface.scriptOperand[i] = in.readU16(); } } - int scriptCount = in.read8U(); + int scriptCount = in.readU8(); if (scriptCount > 0) { iface.scripts = new int[scriptCount][]; for (int scriptID = 0; scriptID < scriptCount; scriptID++) { - int length = in.read16U(); + int length = in.readU16(); iface.scripts[scriptID] = new int[length]; for (int i = 0; i < length; i++) { - iface.scripts[scriptID][i] = in.read16U(); + iface.scripts[scriptID][i] = in.readU16(); } } } if (iface.type == TYPE_PARENT) { - iface.scrollableHeight = in.read16U(); - iface.hide = in.read8U() == 1; - int childCount = in.read16U(); + iface.scrollableHeight = in.readU16(); + iface.hide = in.readU8() == 1; + int childCount = in.readU16(); iface.childID = new int[childCount]; iface.childX = new int[childCount]; iface.childY = new int[childCount]; for (int i = 0; i < childCount; i++) { - iface.childID[i] = in.read16U(); + iface.childID[i] = in.readU16(); iface.childX[i] = in.read16(); iface.childY[i] = in.read16(); } } if (iface.type == TYPE_UNUSED) { - in.read16U(); - in.read8U(); + in.readU16(); + in.readU8(); } if (iface.type == TYPE_INVENTORY) { iface.inventorySlotObjID = new int[iface.width * iface.height]; iface.inventorySlotObjCount = new int[iface.width * iface.height]; - iface.inventoryDraggable = in.read8U() == 1; - iface.inventoryInteractable = in.read8U() == 1; - iface.inventoryUsable = in.read8U() == 1; - iface.inventoryMoveReplaces = in.read8U() == 1; - iface.inventoryMarginX = in.read8U(); - iface.inventoryMarginY = in.read8U(); + iface.inventoryDraggable = in.readU8() == 1; + iface.inventoryInteractable = in.readU8() == 1; + iface.inventoryUsable = in.readU8() == 1; + iface.inventoryMoveReplaces = in.readU8() == 1; + iface.inventoryMarginX = in.readU8(); + iface.inventoryMarginY = in.readU8(); iface.inventorySlotOffsetX = new int[20]; iface.inventorySlotOffsetY = new int[20]; iface.inventorySlotImage = new Image24[20]; for (int slot = 0; slot < 20; slot++) { - if (in.read8U() == 1) { + if (in.readU8() == 1) { iface.inventorySlotOffsetX[slot] = in.read16(); iface.inventorySlotOffsetY[slot] = in.read16(); String imageName = in.readString(); @@ -145,16 +145,16 @@ public static void unpack(FileArchive config, BitmapFont[] fonts, FileArchive me } if (iface.type == TYPE_RECT) { - iface.fill = in.read8U() == 1; + iface.fill = in.readU8() == 1; } if ((iface.type == TYPE_TEXT) || (iface.type == TYPE_UNUSED)) { - iface.center = in.read8U() == 1; - int fontID = in.read8U(); + iface.center = in.readU8() == 1; + int fontID = in.readU8(); if (fonts != null) { iface.font = fonts[fontID]; } - iface.shadow = in.read8U() == 1; + iface.shadow = in.readU8() == 1; } if (iface.type == TYPE_TEXT) { @@ -186,50 +186,50 @@ public static void unpack(FileArchive config, BitmapFont[] fonts, FileArchive me } if (iface.type == TYPE_MODEL) { - int tmp = in.read8U(); + int tmp = in.readU8(); if (tmp != 0) { iface.modelType = MODEL_TYPE_NORMAL; - iface.modelID = ((tmp - 1) << 8) + in.read8U(); + iface.modelID = ((tmp - 1) << 8) + in.readU8(); } - tmp = in.read8U(); + tmp = in.readU8(); if (tmp != 0) { iface.activeModelType = MODEL_TYPE_NORMAL; - iface.activeModelID = ((tmp - 1) << 8) + in.read8U(); + iface.activeModelID = ((tmp - 1) << 8) + in.readU8(); } - tmp = in.read8U(); + tmp = in.readU8(); if (tmp != 0) { - iface.seqID = ((tmp - 1) << 8) + in.read8U(); + iface.seqID = ((tmp - 1) << 8) + in.readU8(); } else { iface.seqID = -1; } - tmp = in.read8U(); + tmp = in.readU8(); if (tmp != 0) { - iface.activeSeqID = ((tmp - 1) << 8) + in.read8U(); + iface.activeSeqID = ((tmp - 1) << 8) + in.readU8(); } else { iface.activeSeqID = -1; } - iface.modelZoom = in.read16U(); - iface.modelPitch = in.read16U(); - iface.modelYaw = in.read16U(); + iface.modelZoom = in.readU16(); + iface.modelPitch = in.readU16(); + iface.modelYaw = in.readU16(); } if (iface.type == TYPE_INVENTORY_TEXT) { iface.inventorySlotObjID = new int[iface.width * iface.height]; iface.inventorySlotObjCount = new int[iface.width * iface.height]; - iface.center = in.read8U() == 1; - int fontID = in.read8U(); + iface.center = in.readU8() == 1; + int fontID = in.readU8(); if (fonts != null) { iface.font = fonts[fontID]; } - iface.shadow = in.read8U() == 1; + iface.shadow = in.readU8() == 1; iface.color = in.read32(); iface.inventoryMarginX = in.read16(); iface.inventoryMarginY = in.read16(); - iface.inventoryInteractable = in.read8U() == 1; + iface.inventoryInteractable = in.readU8() == 1; iface.inventoryOptions = new String[5]; for (int option = 0; option < 5; option++) { iface.inventoryOptions[option] = in.readString(); @@ -246,7 +246,7 @@ public static void unpack(FileArchive config, BitmapFont[] fonts, FileArchive me if ((iface.optionType == OPTION_TYPE_SPELL) || (iface.type == TYPE_INVENTORY)) { iface.spellAction = in.readString(); iface.spellName = in.readString(); - iface.spellFlags = in.read16U(); + iface.spellFlags = in.readU16(); } if ((iface.optionType == OPTION_TYPE_STANDARD) || (iface.optionType == OPTION_TYPE_TOGGLE) || (iface.optionType == OPTION_TYPE_SELECT) || (iface.optionType == OPTION_TYPE_CONTINUE)) { diff --git a/src/main/java/Image24.java b/src/main/java/Image24.java index d76d10c..ff5f504 100644 --- a/src/main/java/Image24.java +++ b/src/main/java/Image24.java @@ -42,10 +42,10 @@ public Image24(byte[] src, java.awt.Component component) { public Image24(FileArchive archive, String file, int index) throws IOException { Buffer dat = new Buffer(archive.read(file + ".dat")); Buffer idx = new Buffer(archive.read("index.dat")); - idx.position = dat.read16U(); - cropW = idx.read16U(); - cropH = idx.read16U(); - int paletteSize = idx.read8U(); + idx.position = dat.readU16(); + cropW = idx.readU16(); + cropH = idx.readU16(); + int paletteSize = idx.readU8(); int[] palette = new int[paletteSize]; for (int k = 0; k < (paletteSize - 1); k++) { palette[k + 1] = idx.read24(); @@ -55,26 +55,26 @@ public Image24(FileArchive archive, String file, int index) throws IOException { } for (int i = 0; i < index; i++) { idx.position += 2; - dat.position += idx.read16U() * idx.read16U(); + dat.position += idx.readU16() * idx.readU16(); idx.position++; } - cropX = idx.read8U(); - cropY = idx.read8U(); - width = idx.read16U(); - height = idx.read16U(); - int layout = idx.read8U(); + cropX = idx.readU8(); + cropY = idx.readU8(); + width = idx.readU16(); + height = idx.readU16(); + int layout = idx.readU8(); int pixelLen = width * height; pixels = new int[pixelLen]; if (layout == 0) { for (int i = 0; i < pixelLen; i++) { - pixels[i] = palette[dat.read8U()]; + pixels[i] = palette[dat.readU8()]; } return; } if (layout == 1) { for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { - pixels[x + (y * width)] = palette[dat.read8U()]; + pixels[x + (y * width)] = palette[dat.readU8()]; } } } diff --git a/src/main/java/Image8.java b/src/main/java/Image8.java index a17ec8a..38a75f7 100644 --- a/src/main/java/Image8.java +++ b/src/main/java/Image8.java @@ -14,30 +14,30 @@ public class Image8 { public Image8(FileArchive archive, String name, int index) throws IOException { Buffer dat = new Buffer(archive.read(name + ".dat")); Buffer idx = new Buffer(archive.read("index.dat")); - idx.position = dat.read16U(); - cropW = idx.read16U(); - cropH = idx.read16U(); - int paletteSize = idx.read8U(); + idx.position = dat.readU16(); + cropW = idx.readU16(); + cropH = idx.readU16(); + int paletteSize = idx.readU8(); palette = new int[paletteSize]; for (int i = 0; i < (paletteSize - 1); i++) { palette[i + 1] = idx.read24(); } for (int i = 0; i < index; i++) { idx.position += 2; - dat.position += idx.read16U() * idx.read16U(); + dat.position += idx.readU16() * idx.readU16(); idx.position++; } - cropX = idx.read8U(); - cropY = idx.read8U(); - width = idx.read16U(); - height = idx.read16U(); - int pixelOrder = idx.read8U(); + cropX = idx.readU8(); + cropY = idx.readU8(); + width = idx.readU16(); + height = idx.readU16(); + int pixelOrder = idx.readU8(); int pixelCount = width * height; pixels = new byte[pixelCount]; if (pixelOrder == 0) { for (int i = 0; i < pixelCount; i++) { - pixels[i] = dat.read(); + pixels[i] = dat.read8(); } return; } @@ -45,7 +45,7 @@ public Image8(FileArchive archive, String name, int index) throws IOException { if (pixelOrder == 1) { for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { - pixels[x + (y * width)] = dat.read(); + pixels[x + (y * width)] = dat.read8(); } } } diff --git a/src/main/java/LocType.java b/src/main/java/LocType.java index 87aa6da..0cd1e12 100644 --- a/src/main/java/LocType.java +++ b/src/main/java/LocType.java @@ -78,12 +78,12 @@ public static void unload() { 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.read16U(); + count = buffer.readU16(); offsets = new int[count]; int offset = 2; for (int j = 0; j < count; j++) { offsets[j] = offset; - offset += buffer.read16U(); + offset += buffer.readU16(); } cache = new LocType[20]; for (int i = 0; i < 20; i++) { @@ -409,19 +409,19 @@ public void method582(Buffer buffer) { do { int j; do { - j = buffer.read8U(); + j = buffer.readU8(); if (j == 0) { break label0; } if (j == 1) { - int k = buffer.read8U(); + int k = buffer.readU8(); 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.read16U(); - modelKinds[k1] = buffer.read8U(); + modelIDs[k1] = buffer.readU16(); + modelKinds[k1] = buffer.readU8(); } } else { buffer.position += k * 3; @@ -432,28 +432,28 @@ public void method582(Buffer buffer) { } else if (j == 3) { examine = buffer.readString(); } else if (j == 5) { - int l = buffer.read8U(); + int l = buffer.readU8(); if (l > 0) { if ((modelIDs == null) || lowmem) { modelKinds = null; modelIDs = new int[l]; for (int l1 = 0; l1 < l; l1++) { - modelIDs[l1] = buffer.read16U(); + modelIDs[l1] = buffer.readU16(); } } else { buffer.position += l * 2; } } } else if (j == 14) { - sizeX = buffer.read8U(); + sizeX = buffer.readU8(); } else if (j == 15) { - sizeZ = buffer.read8U(); + sizeZ = buffer.readU8(); } else if (j == 17) { solid = false; } else if (j == 18) { blocksProjectiles = false; } else if (j == 19) { - i = buffer.read8U(); + i = buffer.readU8(); if (i == 1) { interactable = true; } @@ -464,16 +464,16 @@ public void method582(Buffer buffer) { } else if (j == 23) { occludes = true; } else if (j == 24) { - seqID = buffer.read16U(); + seqID = buffer.readU16(); if (seqID == 65535) { seqID = -1; } } else if (j == 28) { - decorOffset = buffer.read8U(); + decorOffset = buffer.readU8(); } else if (j == 29) { - lightAmbient = buffer.read(); + lightAmbient = buffer.read8(); } else if (j == 39) { - lightAttenuation = buffer.read(); + lightAttenuation = buffer.read8(); } else if ((j >= 30) && (j < 39)) { if (options == null) { options = new String[5]; @@ -483,29 +483,29 @@ public void method582(Buffer buffer) { options[j - 30] = null; } } else if (j == 40) { - int i1 = buffer.read8U(); + int i1 = buffer.readU8(); srcColor = new int[i1]; dstColor = new int[i1]; for (int i2 = 0; i2 < i1; i2++) { - srcColor[i2] = buffer.read16U(); - dstColor[i2] = buffer.read16U(); + srcColor[i2] = buffer.readU16(); + dstColor[i2] = buffer.readU16(); } } else if (j == 60) { - mapfunctionIcon = buffer.read16U(); + mapfunctionIcon = buffer.readU16(); } else if (j == 62) { invert = true; } else if (j == 64) { castShadow = false; } else if (j == 65) { - scaleX = buffer.read16U(); + scaleX = buffer.readU16(); } else if (j == 66) { - scaleZ = buffer.read16U(); + scaleZ = buffer.readU16(); } else if (j == 67) { - scaleY = buffer.read16U(); + scaleY = buffer.readU16(); } else if (j == 68) { - mapsceneIcon = buffer.read16U(); + mapsceneIcon = buffer.readU16(); } else if (j == 69) { - interactionSideFlags = buffer.read8U(); + interactionSideFlags = buffer.readU8(); } else if (j == 70) { translateX = buffer.read16(); } else if (j == 71) { @@ -520,22 +520,22 @@ public void method582(Buffer buffer) { if (j != 75) { continue; } - supportsObj = buffer.read8U(); + supportsObj = buffer.readU8(); } continue label0; } while (j != 77); - varbit = buffer.read16U(); + varbit = buffer.readU16(); if (varbit == 65535) { varbit = -1; } - varp = buffer.read16U(); + varp = buffer.readU16(); if (varp == 65535) { varp = -1; } - int j1 = buffer.read8U(); + int j1 = buffer.readU8(); overrideTypeIDs = new int[j1 + 1]; for (int j2 = 0; j2 <= j1; j2++) { - overrideTypeIDs[j2] = buffer.read16U(); + overrideTypeIDs[j2] = buffer.readU16(); if (overrideTypeIDs[j2] == 65535) { overrideTypeIDs[j2] = -1; } diff --git a/src/main/java/Model.java b/src/main/java/Model.java index 27dfc04..e6277f1 100644 --- a/src/main/java/Model.java +++ b/src/main/java/Model.java @@ -108,20 +108,20 @@ public static void unpack(byte[] src, int id) { buffer.position = src.length - 18; Header header = headers[id] = new Header(); header.data = src; - header.vertexCount = buffer.read16U(); - header.faceCount = buffer.read16U(); - header.texturedFaceCount = buffer.read8U(); + header.vertexCount = buffer.readU16(); + header.faceCount = buffer.readU16(); + header.texturedFaceCount = buffer.readU8(); - int hasInfo = buffer.read8U(); - int priority = buffer.read8U(); - int hasAlpha = buffer.read8U(); - int hasFaceLabels = buffer.read8U(); - int hasVertexLabels = buffer.read8U(); + int hasInfo = buffer.readU8(); + int priority = buffer.readU8(); + int hasAlpha = buffer.readU8(); + int hasFaceLabels = buffer.readU8(); + int hasVertexLabels = buffer.readU8(); - int dataLengthX = buffer.read16U(); - int dataLengthY = buffer.read16U(); - int dataLengthZ = buffer.read16U(); - int dataLengthFaceOrientations = buffer.read16U(); + int dataLengthX = buffer.readU16(); + int dataLengthY = buffer.readU16(); + int dataLengthZ = buffer.readU16(); + int dataLengthFaceOrientations = buffer.readU16(); int offset = 0; header.vertexFlagsOffset = offset; @@ -398,7 +398,7 @@ public Model(int id) { int z = 0; for (int v = 0; v < vertexCount; v++) { - int flags = buf0.read8U(); + int flags = buf0.readU8(); int dx = 0; int dy = 0; @@ -425,7 +425,7 @@ public Model(int id) { z = vertexZ[v]; if (vertexLabel != null) { - vertexLabel[v] = buf4.read8U(); + vertexLabel[v] = buf4.readU8(); } } @@ -436,22 +436,22 @@ public Model(int id) { buf4.position = header.faceLabelsOffset; for (int face = 0; face < faceCount; face++) { - faceColor[face] = buf0.read16U(); + faceColor[face] = buf0.readU16(); if (faceInfo != null) { - faceInfo[face] = buf1.read8U(); + faceInfo[face] = buf1.readU8(); } if (facePriority != null) { - facePriority[face] = buf2.read8U(); + facePriority[face] = buf2.readU8(); } if (faceAlpha != null) { - faceAlpha[face] = buf3.read8U(); + faceAlpha[face] = buf3.readU8(); } if (faceLabel != null) { - faceLabel[face] = buf4.read8U(); + faceLabel[face] = buf4.readU8(); } } @@ -464,7 +464,7 @@ public Model(int id) { int last = 0; for (int face = 0; face < faceCount; face++) { - int orientation = buf1.read8U(); + int orientation = buf1.readU8(); // fancy shmansy compression type stuff. // vertex indices stored as deltas, with some faces @@ -519,9 +519,9 @@ public Model(int id) { buf0.position = header.faceTextureAxisOffset; for (int face = 0; face < texturedFaceCount; face++) { - texturedVertexA[face] = buf0.read16U(); - texturedVertexB[face] = buf0.read16U(); - texturedVertexC[face] = buf0.read16U(); + texturedVertexA[face] = buf0.readU16(); + texturedVertexB[face] = buf0.readU16(); + texturedVertexC[face] = buf0.readU16(); } } diff --git a/src/main/java/NPCType.java b/src/main/java/NPCType.java index 48d0c29..e6eac7a 100644 --- a/src/main/java/NPCType.java +++ b/src/main/java/NPCType.java @@ -33,13 +33,13 @@ public static NPCType get(int id) { 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.read16U(); + count = buffer.readU16(); offsets = new int[count]; int offset = 2; for (int i = 0; i < count; i++) { offsets[i] = offset; - offset += buffer.read16U(); + offset += buffer.readU16(); } cache = new NPCType[20]; @@ -233,31 +233,31 @@ public Model getSequencedModel(int secondaryTransformID, int primaryTransformID, public void read(Buffer in) { while (true) { - int code = in.read8U(); + int code = in.readU8(); if (code == 0) { return; } else if (code == 1) { - int modelCount = in.read8U(); + int modelCount = in.readU8(); modelIDs = new int[modelCount]; for (int i = 0; i < modelCount; i++) { - modelIDs[i] = in.read16U(); + modelIDs[i] = in.readU16(); } } else if (code == 2) { name = in.readString(); } else if (code == 3) { examine = in.readString(); } else if (code == 12) { - size = in.read(); + size = in.read8(); } else if (code == 13) { - seqStandID = in.read16U(); + seqStandID = in.readU16(); } else if (code == 14) { - seqWalkID = in.read16U(); + seqWalkID = in.readU16(); } else if (code == 17) { - seqWalkID = in.read16U(); - seqTurnAroundID = in.read16U(); - seqTurnLeftID = in.read16U(); - seqTurnRightID = in.read16U(); + seqWalkID = in.readU16(); + seqTurnAroundID = in.readU16(); + seqTurnLeftID = in.readU16(); + seqTurnRightID = in.readU16(); } else if ((code >= 30) && (code < 40)) { if (options == null) { options = new String[5]; @@ -269,58 +269,58 @@ public void read(Buffer in) { options[code - 30] = null; } } else if (code == 40) { - int count = in.read8U(); + int count = in.readU8(); colorSrc = new int[count]; colorDst = new int[count]; for (int i = 0; i < count; i++) { - colorSrc[i] = in.read16U(); - colorDst[i] = in.read16U(); + colorSrc[i] = in.readU16(); + colorDst[i] = in.readU16(); } } else if (code == 60) { - int count = in.read8U(); + int count = in.readU8(); headModelIDs = new int[count]; for (int l1 = 0; l1 < count; l1++) { - headModelIDs[l1] = in.read16U(); + headModelIDs[l1] = in.readU16(); } } else if ((code == 90) || (code == 91) || (code == 92)) { - in.read16U(); + in.readU16(); } else if (code == 93) { showOnMinimap = false; } else if (code == 95) { - level = in.read16U(); + level = in.readU16(); } else if (code == 97) { - scaleXY = in.read16U(); + scaleXY = in.readU16(); } else if (code == 98) { - scaleZ = in.read16U(); + scaleZ = in.readU16(); } else if (code == 99) { important = true; } else if (code == 100) { - lightAmbient = in.read(); + lightAmbient = in.read8(); } else if (code == 101) { - lightAttenuation = in.read() * 5; + lightAttenuation = in.read8() * 5; } else if (code == 102) { - headicon = in.read16U(); + headicon = in.readU16(); } else if (code == 103) { - turnSpeed = in.read16U(); + turnSpeed = in.readU16(); } else if (code == 106) { - varbitID = in.read16U(); + varbitID = in.readU16(); if (varbitID == 65535) { varbitID = -1; } - varpID = in.read16U(); + varpID = in.readU16(); if (varpID == 65535) { varpID = -1; } - int overrideCount = in.read8U(); + int overrideCount = in.readU8(); overrides = new int[overrideCount + 1]; for (int i = 0; i <= overrideCount; i++) { - overrides[i] = in.read16U(); + overrides[i] = in.readU16(); if (overrides[i] == 65535) { overrides[i] = -1; diff --git a/src/main/java/ObjType.java b/src/main/java/ObjType.java index dfe0961..69cf9af 100644 --- a/src/main/java/ObjType.java +++ b/src/main/java/ObjType.java @@ -27,12 +27,12 @@ public static void unload() { 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.read16U(); + count = idx.readU16(); typeOffset = new int[count]; int offset = 2; for (int j = 0; j < count; j++) { typeOffset[j] = offset; - offset += idx.read16U(); + offset += idx.readU16(); } recent = new ObjType[10]; for (int k = 0; k < 10; k++) { @@ -556,34 +556,34 @@ public Model getInterfaceModel(int count) { public void read(Buffer in) { while (true) { - int code = in.read8U(); + int code = in.readU8(); if (code == 0) { return; } else if (code == 1) { - modelID = in.read16U(); + modelID = in.readU16(); } else if (code == 2) { name = in.readString(); } else if (code == 3) { examine = in.readString(); } else if (code == 4) { - iconZoom = in.read16U(); + iconZoom = in.readU16(); } else if (code == 5) { - iconPitch = in.read16U(); + iconPitch = in.readU16(); } else if (code == 6) { - iconYaw = in.read16U(); + iconYaw = in.readU16(); } else if (code == 7) { - iconOffsetX = in.read16U(); + iconOffsetX = in.readU16(); if (iconOffsetX > 32767) { iconOffsetX -= 0x10000; } } else if (code == 8) { - iconOffsetY = in.read16U(); + iconOffsetY = in.readU16(); if (iconOffsetY > 32767) { iconOffsetY -= 0x10000; } } else if (code == 10) { - in.read16U(); + in.readU16(); } else if (code == 11) { stackable = true; } else if (code == 12) { @@ -591,15 +591,15 @@ public void read(Buffer in) { } else if (code == 16) { members = true; } else if (code == 23) { - maleModelID0 = in.read16U(); - maleOffsetY = in.read(); + maleModelID0 = in.readU16(); + maleOffsetY = in.read8(); } else if (code == 24) { - maleModelID1 = in.read16U(); + maleModelID1 = in.readU16(); } else if (code == 25) { - femaleModelID0 = in.read16U(); - femaleOffsetY = in.read(); + femaleModelID0 = in.readU16(); + femaleOffsetY = in.read8(); } else if (code == 26) { - femaleModelID1 = in.read16U(); + femaleModelID1 = in.readU16(); } else if ((code >= 30) && (code < 35)) { if (options == null) { options = new String[5]; @@ -614,50 +614,50 @@ public void read(Buffer in) { } inventoryOptions[code - 35] = in.readString(); } else if (code == 40) { - int recolorCount = in.read8U(); + int recolorCount = in.readU8(); srcColor = new int[recolorCount]; dstColor = new int[recolorCount]; for (int i = 0; i < recolorCount; i++) { - srcColor[i] = in.read16U(); - dstColor[i] = in.read16U(); + srcColor[i] = in.readU16(); + dstColor[i] = in.readU16(); } } else if (code == 78) { - maleModelID2 = in.read16U(); + maleModelID2 = in.readU16(); } else if (code == 79) { - femaleModelID2 = in.read16U(); + femaleModelID2 = in.readU16(); } else if (code == 90) { - maleHeadModelID0 = in.read16U(); + maleHeadModelID0 = in.readU16(); } else if (code == 91) { - femaleHeadModelID0 = in.read16U(); + femaleHeadModelID0 = in.readU16(); } else if (code == 92) { - maleHeadModelID1 = in.read16U(); + maleHeadModelID1 = in.readU16(); } else if (code == 93) { - femaleHeadModelID1 = in.read16U(); + femaleHeadModelID1 = in.readU16(); } else if (code == 95) { - iconRoll = in.read16U(); + iconRoll = in.readU16(); } else if (code == 97) { - linkedID = in.read16U(); + linkedID = in.readU16(); } else if (code == 98) { - certificateID = in.read16U(); + certificateID = in.readU16(); } else if ((code >= 100) && (code < 110)) { if (stackID == null) { stackID = new int[10]; stackCount = new int[10]; } - stackID[code - 100] = in.read16U(); - stackCount[code - 100] = in.read16U(); + stackID[code - 100] = in.readU16(); + stackCount[code - 100] = in.readU16(); } else if (code == 110) { - scaleX = in.read16U(); + scaleX = in.readU16(); } else if (code == 111) { - scaleZ = in.read16U(); + scaleZ = in.readU16(); } else if (code == 112) { - scaleY = in.read16U(); + scaleY = in.readU16(); } else if (code == 113) { - lightAmbient = in.read(); + lightAmbient = in.read8(); } else if (code == 114) { - lightAttenuation = in.read() * 5; + lightAttenuation = in.read8() * 5; } else if (code == 115) { - team = in.read8U(); + team = in.readU8(); } } } diff --git a/src/main/java/OnDemand.java b/src/main/java/OnDemand.java index cb8cb82..87608de 100644 --- a/src/main/java/OnDemand.java +++ b/src/main/java/OnDemand.java @@ -190,7 +190,7 @@ public void load(FileArchive versionlist, Game game) throws IOException { storeFilePriorities[i] = new byte[count]; for (int l = 0; l < count; l++) { - storeFileVersions[i][l] = buffer.read16U(); + storeFileVersions[i][l] = buffer.readU16(); } } @@ -229,10 +229,10 @@ public void load(FileArchive versionlist, Game game) throws IOException { mapPrefetched = new int[count]; for (int i2 = 0; i2 < count; i2++) { - mapIndex[i2] = buffer.read16U(); - mapLandFile[i2] = buffer.read16U(); - mapLocFile[i2] = buffer.read16U(); - mapPrefetched[i2] = buffer.read8U(); + mapIndex[i2] = buffer.readU16(); + mapLandFile[i2] = buffer.readU16(); + mapLocFile[i2] = buffer.readU16(); + mapPrefetched[i2] = buffer.readU8(); } data = versionlist.read("anim_index"); @@ -241,7 +241,7 @@ public void load(FileArchive versionlist, Game game) throws IOException { animIndex = new int[count]; for (int j2 = 0; j2 < count; j2++) { - animIndex[j2] = buffer.read16U(); + animIndex[j2] = buffer.readU16(); } data = versionlist.read("midi_index"); @@ -250,7 +250,7 @@ public void load(FileArchive versionlist, Game game) throws IOException { midiIndex = new int[count]; for (int k2 = 0; k2 < count; k2++) { - midiIndex[k2] = buffer.read8U(); + midiIndex[k2] = buffer.readU8(); } this.game = game; diff --git a/src/main/java/PlayerEntity.java b/src/main/java/PlayerEntity.java index 4d77d06..83e785d 100644 --- a/src/main/java/PlayerEntity.java +++ b/src/main/java/PlayerEntity.java @@ -116,24 +116,24 @@ public Model getModel() { public void read(Buffer in) { in.position = 0; - gender = in.read8U(); - headicons = in.read8U(); + gender = in.readU8(); + headicons = in.readU8(); transmogrify = null; team = 0; for (int part = 0; part < 12; part++) { - int msb = in.read8U(); + int msb = in.readU8(); if (msb == 0) { appearances[part] = 0; continue; } - int lsb = in.read8U(); + int lsb = in.readU8(); appearances[part] = (msb << 8) + lsb; if ((part == 0) && (appearances[0] == 65535)) { - transmogrify = NPCType.get(in.read16U()); + transmogrify = NPCType.get(in.readU16()); break; } @@ -147,7 +147,7 @@ public void read(Buffer in) { } for (int part = 0; part < 5; part++) { - int color = in.read8U(); + int color = in.readU8(); if ((color < 0) || (color >= Game.designPartColor[part].length)) { color = 0; @@ -156,37 +156,37 @@ public void read(Buffer in) { colors[part] = color; } - super.seqStandID = in.read16U(); + super.seqStandID = in.readU16(); if (super.seqStandID == 65535) { super.seqStandID = -1; } - super.seqTurnID = in.read16U(); + super.seqTurnID = in.readU16(); if (super.seqTurnID == 65535) { super.seqTurnID = -1; } - super.seqWalkID = in.read16U(); + super.seqWalkID = in.readU16(); if (super.seqWalkID == 65535) { super.seqWalkID = -1; } - super.seqTurnAroundID = in.read16U(); + super.seqTurnAroundID = in.readU16(); if (super.seqTurnAroundID == 65535) { super.seqTurnAroundID = -1; } - super.seqTurnLeftID = in.read16U(); + super.seqTurnLeftID = in.readU16(); if (super.seqTurnLeftID == 65535) { super.seqTurnLeftID = -1; } - super.seqTurnRightID = in.read16U(); + super.seqTurnRightID = in.readU16(); if (super.seqTurnRightID == 65535) { super.seqTurnRightID = -1; } - super.seqRunID = in.read16U(); + super.seqRunID = in.readU16(); if (super.seqRunID == 65535) { super.seqRunID = -1; } name = StringUtil.formatName(StringUtil.fromBase37(in.read64())); - combatLevel = in.read8U(); - skillLevel = in.read16U(); + combatLevel = in.readU8(); + skillLevel = in.readU16(); visible = true; appearanceHashcode = 0L; diff --git a/src/main/java/SceneBuilder.java b/src/main/java/SceneBuilder.java index 3b5f4cf..2301f9e 100644 --- a/src/main/java/SceneBuilder.java +++ b/src/main/java/SceneBuilder.java @@ -35,7 +35,7 @@ public static void prefetchLocs(Buffer buffer, OnDemand onDemand) { int locID = -1; for (; ; ) { - int deltaID = buffer.readSmartU(); + int deltaID = buffer.readUSmart(); if (deltaID == 0) { break; @@ -45,8 +45,8 @@ public static void prefetchLocs(Buffer buffer, OnDemand onDemand) { LocType type = LocType.get(locID); type.prefetch(onDemand); - while (buffer.readSmartU() != 0) { - buffer.read8U(); + while (buffer.readUSmart() != 0) { + buffer.readU8(); } } } @@ -350,7 +350,7 @@ public static boolean validateLocs(byte[] data, int originX, int originZ) { int locID = -1; for (; ; ) { - int deltaID = buffer.readSmartU(); + int deltaID = buffer.readUSmart(); if (deltaID == 0) { break; } @@ -363,12 +363,12 @@ public static boolean validateLocs(byte[] data, int originX, int originZ) { // this loop is for the same Loc ID. for (; ; ) { if (skip) { - if (buffer.readSmartU() == 0) { + if (buffer.readUSmart() == 0) { break; } - buffer.read8U(); + buffer.readU8(); } else { - int deltaPos = buffer.readSmartU(); + int deltaPos = buffer.readUSmart(); if (deltaPos == 0) { break; @@ -379,7 +379,7 @@ public static boolean validateLocs(byte[] data, int originX, int originZ) { int z = pos & 0x3f; int x = (pos >> 6) & 0x3f; - int kind = buffer.read8U() >> 2; + int kind = buffer.readU8() >> 2; int localX = x + originX; int localZ = z + originZ; @@ -1332,7 +1332,7 @@ public void readTiles(Buffer in, int originX, int originZ, int level, int x, int levelTileFlags[level][x][z] = (byte) 0; for (; ; ) { - int type = in.read8U(); + int type = in.readU8(); if (type == 0) { if (level == 0) { @@ -1345,7 +1345,7 @@ public void readTiles(Buffer in, int originX, int originZ, int level, int x, int } if (type == 1) { - int height = in.read8U(); + int height = in.readU8(); if (height == 1) { height = 0; @@ -1361,7 +1361,7 @@ public void readTiles(Buffer in, int originX, int originZ, int level, int x, int } if (type <= 49) { - levelTileOverlayIDs[level][x][z] = in.read(); + levelTileOverlayIDs[level][x][z] = in.read8(); levelTileOverlayShape[level][x][z] = (byte) ((type - 2) / 4); levelTileOverlayRotation[level][x][z] = (byte) (((type - 2) + mapRotation) & 0x3); } else if (type <= 81) { @@ -1372,16 +1372,16 @@ public void readTiles(Buffer in, int originX, int originZ, int level, int x, int } } else { for (; ; ) { - int type = in.read8U(); + int type = in.readU8(); if (type == 0) { break; } if (type == 1) { - in.read8U(); + in.readU8(); break; } if (type <= 49) { - in.read8U(); + in.readU8(); } } } @@ -1402,7 +1402,7 @@ public void readChunkLocs(CollisionMap[] collisionMaps, Scene scene, int mapLeve int locID = -1; while (true) { - int deltaID = in.readSmartU(); + int deltaID = in.readUSmart(); if (deltaID == 0) { break; @@ -1413,7 +1413,7 @@ public void readChunkLocs(CollisionMap[] collisionMaps, Scene scene, int mapLeve int locData = 0; while (true) { - int deltaData = in.readSmartU(); + int deltaData = in.readUSmart(); if (deltaData == 0) { break; @@ -1424,7 +1424,7 @@ public void readChunkLocs(CollisionMap[] collisionMaps, Scene scene, int mapLeve int locZ = locData & 0x3f; int locX = (locData >> 6) & 0x3f; int locLevel = locData >> 12; - int locInfo = in.read8U(); + int locInfo = in.readU8(); int locKind = locInfo >> 2; int locRotation = locInfo & 0x3; @@ -1487,7 +1487,7 @@ public void readLocs(CollisionMap[] collisionMaps, Scene scene, int originX, int Buffer in = new Buffer(data); int locID = -1; for (; ; ) { - int deltaID = in.readSmartU(); + int deltaID = in.readUSmart(); if (deltaID == 0) { break; @@ -1497,7 +1497,7 @@ public void readLocs(CollisionMap[] collisionMaps, Scene scene, int originX, int int locData = 0; for (; ; ) { - int deltaData = in.readSmartU(); + int deltaData = in.readUSmart(); if (deltaData == 0) { break; @@ -1507,7 +1507,7 @@ public void readLocs(CollisionMap[] collisionMaps, Scene scene, int originX, int int locZ = locData & 0x3f; int locX = (locData >> 6) & 0x3f; int locLevel = locData >> 12; - int locInfo = in.read8U(); + int locInfo = in.readU8(); int locKind = locInfo >> 2; int locRotation = locInfo & 0x3; int x = locX + originX; diff --git a/src/main/java/SeqSkeleton.java b/src/main/java/SeqSkeleton.java index fc46193..2994b50 100644 --- a/src/main/java/SeqSkeleton.java +++ b/src/main/java/SeqSkeleton.java @@ -37,17 +37,17 @@ public class SeqSkeleton { * @param in the input */ public SeqSkeleton(Buffer in) { - final int length = in.read8U(); + final int length = in.readU8(); baseTypes = new int[length]; baseLabels = new int[length][]; for (int group = 0; group < length; group++) { - baseTypes[group] = in.read8U(); + baseTypes[group] = in.readU8(); } for (int group = 0; group < length; group++) { - int count = in.read8U(); + int count = in.readU8(); baseLabels[group] = new int[count]; for (int child = 0; child < count; child++) { - baseLabels[group][child] = in.read8U(); + baseLabels[group][child] = in.readU8(); } } } diff --git a/src/main/java/SeqTransform.java b/src/main/java/SeqTransform.java index 2424dac..1c34f6e 100644 --- a/src/main/java/SeqTransform.java +++ b/src/main/java/SeqTransform.java @@ -67,38 +67,38 @@ public static void unpack(byte[] src) { int offset = 0; header.position = offset; - offset += offsets.read16U() + 2; + offset += offsets.readU16() + 2; tran1.position = offset; - offset += offsets.read16U(); + offset += offsets.readU16(); tran2.position = offset; - offset += offsets.read16U(); + offset += offsets.readU16(); del.position = offset; - offset += offsets.read16U(); + offset += offsets.readU16(); skel.position = offset; SeqSkeleton skeleton = new SeqSkeleton(skel); - int frameCount = header.read16U(); + int frameCount = header.readU16(); 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.read16U()] = new SeqTransform(); - transform.delay = del.read8U(); + SeqTransform transform = instances[header.readU16()] = new SeqTransform(); + transform.delay = del.readU8(); transform.skeleton = skeleton; - int baseCount = header.read8U(); + int baseCount = header.readU8(); int lastBase = -1; int length = 0; for (int base = 0; base < baseCount; base++) { - int flags = tran1.read8U(); + int flags = tran1.readU8(); if (flags <= 0) { continue; diff --git a/src/main/java/SeqType.java b/src/main/java/SeqType.java index b733d60..1101e62 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.read16U(); + count = buffer.readU16(); if (instances == null) { instances = new SeqType[count]; } @@ -137,48 +137,48 @@ public int getFrameDuration(int frame) { public void load(Buffer buffer) { while (true) { - int code = buffer.read8U(); + int code = buffer.readU8(); if (code == 0) { break; } else if (code == 1) { - frameCount = buffer.read8U(); + frameCount = buffer.readU8(); transformIDs = new int[frameCount]; auxiliaryTransformIDs = new int[frameCount]; frameDuration = new int[frameCount]; for (int f = 0; f < frameCount; f++) { - transformIDs[f] = buffer.read16U(); - auxiliaryTransformIDs[f] = buffer.read16U(); + transformIDs[f] = buffer.readU16(); + auxiliaryTransformIDs[f] = buffer.readU16(); if (auxiliaryTransformIDs[f] == 65535) { auxiliaryTransformIDs[f] = -1; } - frameDuration[f] = buffer.read16U(); + frameDuration[f] = buffer.readU16(); } } else if (code == 2) { - loopFrameCount = buffer.read16U(); + loopFrameCount = buffer.readU16(); } else if (code == 3) { - int count = buffer.read8U(); + int count = buffer.readU8(); mask = new int[count + 1]; for (int l = 0; l < count; l++) { - mask[l] = buffer.read8U(); + mask[l] = buffer.readU8(); } mask[count] = 9999999; } else if (code == 4) { forwardRenderPadding = true; } else if (code == 5) { - priority = buffer.read8U(); + priority = buffer.readU8(); } else if (code == 6) { - rightHandOverride = buffer.read16U(); + rightHandOverride = buffer.readU16(); } else if (code == 7) { - leftHandOverride = buffer.read16U(); + leftHandOverride = buffer.readU16(); } else if (code == 8) { - loopCount = buffer.read8U(); + loopCount = buffer.readU8(); } else if (code == 9) { - moveStyle = buffer.read8U(); + moveStyle = buffer.readU8(); } else if (code == 10) { - idleStyle = buffer.read8U(); + idleStyle = buffer.readU8(); } else if (code == 11) { - replayStyle = buffer.read8U(); + replayStyle = buffer.readU8(); } else if (code == 12) { buffer.read32(); } else { diff --git a/src/main/java/SoundEnvelope.java b/src/main/java/SoundEnvelope.java index 7db8930..4c94fa5 100644 --- a/src/main/java/SoundEnvelope.java +++ b/src/main/java/SoundEnvelope.java @@ -22,19 +22,19 @@ public SoundEnvelope() { } public void read(Buffer in) { - form = in.read8U(); + form = in.readU8(); start = in.read32(); end = in.read32(); readShape(in); } public void readShape(Buffer buffer) { - length = buffer.read8U(); + length = buffer.readU8(); shapeDelta = new int[length]; shapePeak = new int[length]; for (int i = 0; i < length; i++) { - shapeDelta[i] = buffer.read16U(); - shapePeak[i] = buffer.read16U(); + shapeDelta[i] = buffer.readU16(); + shapePeak[i] = buffer.readU16(); } } diff --git a/src/main/java/SoundFilter.java b/src/main/java/SoundFilter.java index 5a479dc..c1f5452 100644 --- a/src/main/java/SoundFilter.java +++ b/src/main/java/SoundFilter.java @@ -80,28 +80,28 @@ public int evaluate(int direction, float delta) { } public void read(Buffer in, SoundEnvelope envelope) { - int count = in.read8U(); + int count = in.readU8(); pairs[0] = count >> 4; pairs[1] = count & 0xf; if (count != 0) { - unities[0] = in.read16U(); - unities[1] = in.read16U(); + unities[0] = in.readU16(); + unities[1] = in.readU16(); - int migration = in.read8U(); + int migration = in.readU8(); for (int direction = 0; direction < 2; direction++) { for (int pair = 0; pair < pairs[direction]; pair++) { - frequencies[direction][0][pair] = in.read16U(); - ranges[direction][0][pair] = in.read16U(); + frequencies[direction][0][pair] = in.readU16(); + ranges[direction][0][pair] = in.readU16(); } } 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] = in.read16U(); - ranges[direction][1][pair] = in.read16U(); + frequencies[direction][1][pair] = in.readU16(); + ranges[direction][1][pair] = in.readU16(); } 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 2cfc6c1..3b68a03 100644 --- a/src/main/java/SoundTone.java +++ b/src/main/java/SoundTone.java @@ -277,7 +277,7 @@ public void read(Buffer in) { amplitudeBase = new SoundEnvelope(); amplitudeBase.read(in); - if (in.read8U() != 0) { + if (in.readU8() != 0) { in.position--; frequencyModRate = new SoundEnvelope(); frequencyModRate.read(in); @@ -285,7 +285,7 @@ public void read(Buffer in) { frequencyModRange.read(in); } - if (in.read8U() != 0) { + if (in.readU8() != 0) { in.position--; amplitudeModRate = new SoundEnvelope(); amplitudeModRate.read(in); @@ -293,7 +293,7 @@ public void read(Buffer in) { amplitudeModRange.read(in); } - if (in.read8U() != 0) { + if (in.readU8() != 0) { in.position--; release = new SoundEnvelope(); release.read(in); @@ -302,7 +302,7 @@ public void read(Buffer in) { } for (int i = 0; i < 10; i++) { - int volume = in.readSmartU(); + int volume = in.readUSmart(); if (volume == 0) { break; @@ -310,14 +310,14 @@ public void read(Buffer in) { harmonicVolume[i] = volume; harmonicSemitone[i] = in.readSmart(); - harmonicDelay[i] = in.readSmartU(); + harmonicDelay[i] = in.readUSmart(); } - reverbDelay = in.readSmartU(); - reverbVolume = in.readSmartU(); + reverbDelay = in.readUSmart(); + reverbVolume = in.readUSmart(); - length = in.read16U(); - start = in.read16U(); + length = in.readU16(); + start = in.readU16(); filter = new SoundFilter(); filterRange = new SoundEnvelope(); diff --git a/src/main/java/SoundTrack.java b/src/main/java/SoundTrack.java index 1d9ea6f..2a5c404 100644 --- a/src/main/java/SoundTrack.java +++ b/src/main/java/SoundTrack.java @@ -9,7 +9,7 @@ public static void unpack(Buffer in) { SoundTone.init(); do { - int id = in.read16U(); + int id = in.readU16(); if (id == 65535) { return; @@ -39,14 +39,14 @@ public SoundTrack() { public void read(Buffer in) { for (int tone = 0; tone < 10; tone++) { - if (in.read8U() != 0) { + if (in.readU8() != 0) { in.position--; tones[tone] = new SoundTone(); tones[tone].read(in); } } - loopBegin = in.read16U(); - loopEnd = in.read16U(); + loopBegin = in.readU16(); + loopEnd = in.readU16(); } public int trim() { diff --git a/src/main/java/SpotAnimType.java b/src/main/java/SpotAnimType.java index f108cee..983f49b 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.read16U(); + count = buffer.readU16(); if (instances == null) { instances = new SpotAnimType[count]; @@ -46,30 +46,30 @@ public SpotAnimType() { public void read(Buffer in) { while (true) { - int code = in.read8U(); + int code = in.readU8(); if (code == 0) { return; } else if (code == 1) { - modelID = in.read16U(); + modelID = in.readU16(); } else if (code == 2) { - seqID = in.read16U(); + seqID = in.readU16(); if (SeqType.instances != null) { seq = SeqType.instances[seqID]; } } else if (code == 4) { - scaleXY = in.read16U(); + scaleXY = in.readU16(); } else if (code == 5) { - scaleZ = in.read16U(); + scaleZ = in.readU16(); } else if (code == 6) { - rotation = in.read16U(); + rotation = in.readU16(); } else if (code == 7) { - lightAmbient = in.read8U(); + lightAmbient = in.readU8(); } else if (code == 8) { - lightAttenuation = in.read8U(); + lightAttenuation = in.readU8(); } else if ((code >= 40) && (code < 50)) { - colorSrc[code - 40] = in.read16U(); + colorSrc[code - 40] = in.readU16(); } else if ((code >= 50) && (code < 60)) { - colorDst[code - 50] = in.read16U(); + colorDst[code - 50] = in.readU16(); } else { System.out.println("Error unrecognised spotanim config code: " + code); } diff --git a/src/main/java/VarbitType.java b/src/main/java/VarbitType.java index bd9d23e..5dd2733 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.read16U(); + int count = buffer.readU16(); if (instances == null) { instances = new VarbitType[count]; @@ -42,13 +42,13 @@ public VarbitType() { public void read(Buffer in) { do { - int code = in.read8U(); + int code = in.readU8(); if (code == 0) { return; } else if (code == 1) { - varp = in.read16U(); - lsb = in.read8U(); - msb = in.read8U(); + varp = in.readU16(); + lsb = in.readU8(); + msb = in.readU8(); } else if (code == 10) { in.readString(); } else if (code == 3 || code == 4) { diff --git a/src/main/java/VarpType.java b/src/main/java/VarpType.java index c1b3c49..d02f6b0 100644 --- a/src/main/java/VarpType.java +++ b/src/main/java/VarpType.java @@ -11,7 +11,7 @@ public class VarpType { public static void unpack(FileArchive archive) throws IOException { Buffer buffer = new Buffer(archive.read("varp.dat")); - count = buffer.read16U(); + count = buffer.readU16(); if (instances == null) { instances = new VarpType[count]; } @@ -33,13 +33,13 @@ public VarpType() { public void read(Buffer in) { while (true) { - int code = in.read8U(); + int code = in.readU8(); if (code == 0) { return; } else if (code == 1 || code == 2) { - in.read8U(); + in.readU8(); } else if (code == 5) { - type = in.read16U(); + type = in.readU16(); } else if (code == 7 || code == 12) { in.read32(); } else if (code == 10) {