diff --git a/.idea/libraries/Maven__org_apache_commons_commons_collections4_4_4.xml b/.idea/libraries/Maven__org_apache_commons_commons_collections4_4_4.xml new file mode 100644 index 0000000..5871c95 --- /dev/null +++ b/.idea/libraries/Maven__org_apache_commons_commons_collections4_4_4.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_apache_commons_commons_compress_1_20.xml b/.idea/libraries/Maven__org_apache_commons_commons_compress_1_20.xml new file mode 100644 index 0000000..b762f0e --- /dev/null +++ b/.idea/libraries/Maven__org_apache_commons_commons_compress_1_20.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_apache_commons_commons_math3_3_6_1.xml b/.idea/libraries/Maven__org_apache_commons_commons_math3_3_6_1.xml new file mode 100644 index 0000000..ebfe0a8 --- /dev/null +++ b/.idea/libraries/Maven__org_apache_commons_commons_math3_3_6_1.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/317.iml b/317.iml index d04ccda..093c285 100644 --- a/317.iml +++ b/317.iml @@ -11,5 +11,8 @@ + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index bbe0ce6..fb82650 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,7 @@ runescape 317 1.0-SNAPSHOT + @@ -20,4 +21,27 @@ + + + + org.apache.commons + commons-collections4 + 4.4 + + + + org.apache.commons + commons-compress + 1.20 + + + + org.apache.commons + commons-math3 + 3.6.1 + + + + + \ No newline at end of file diff --git a/src/main/java/BZip2.java b/src/main/java/BZip2.java index 98af91f..4bacf82 100644 --- a/src/main/java/BZip2.java +++ b/src/main/java/BZip2.java @@ -1,493 +1,37 @@ -// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) +import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; -public class BZip2 { +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; - private static final BZip2Stream stream = new BZip2Stream(); +public class BZip2 extends InputStream { - public static void decompress(byte[] dst, int dstLen, byte[] src, int srcOff, int srcLen) { - synchronized (stream) { - stream.aByteArray563 = src; - stream.anInt564 = srcOff; - stream.aByteArray568 = dst; - stream.anInt569 = 0; - stream.anInt565 = srcLen; - stream.anInt570 = dstLen; - stream.anInt577 = 0; - stream.anInt576 = 0; - stream.anInt566 = 0; - stream.anInt567 = 0; - stream.anInt571 = 0; - stream.anInt572 = 0; - stream.anInt579 = 0; - decompress(stream); + private static final byte[] MAGIC = {'B', 'Z', 'h', '1'}; + + public static void decompress(byte[] dst, byte[] src, int srcOff, int srcLen) throws IOException { + BZip2CompressorInputStream bz2in = new BZip2CompressorInputStream(new BZip2(src, srcOff, srcLen)); + byte[] buf = new byte[2048]; + int read; + int written = 0; + while ((read = bz2in.read(buf)) != -1) { + System.arraycopy(buf, 0, dst, written, read); + written += read; } } - public static void method226(BZip2Stream stream) { - byte byte4 = stream.aByte573; - int i = stream.anInt574; - int j = stream.anInt584; - int k = stream.anInt582; - int[] ai = BZip2Stream.anIntArray587; - int l = stream.anInt581; - byte[] abyte0 = stream.aByteArray568; - int i1 = stream.anInt569; - int j1 = stream.anInt570; - int k1 = j1; - int l1 = stream.anInt601 + 1; - label0: - do { - if (i > 0) { - do { - if (j1 == 0) { - break label0; - } - if (i == 1) { - break; - } - abyte0[i1] = byte4; - i--; - i1++; - j1--; - } while (true); - if (j1 == 0) { - i = 1; - break; - } - abyte0[i1] = byte4; - i1++; - j1--; - } - boolean flag = true; - while (flag) { - flag = false; - if (j == l1) { - i = 0; - break label0; - } - byte4 = (byte) k; - l = ai[l]; - byte byte0 = (byte) (l & 0xff); - l >>= 8; - j++; - if (byte0 != k) { - k = byte0; - if (j1 == 0) { - i = 1; - } else { - abyte0[i1] = byte4; - i1++; - j1--; - flag = true; - continue; - } - break label0; - } - if (j != l1) { - continue; - } - if (j1 == 0) { - i = 1; - break label0; - } - abyte0[i1] = byte4; - i1++; - j1--; - flag = true; - } - i = 2; - l = ai[l]; - byte byte1 = (byte) (l & 0xff); - l >>= 8; - if (++j != l1) { - if (byte1 != k) { - k = byte1; - } else { - i = 3; - l = ai[l]; - byte byte2 = (byte) (l & 0xff); - l >>= 8; - if (++j != l1) { - if (byte2 != k) { - k = byte2; - } else { - l = ai[l]; - byte byte3 = (byte) (l & 0xff); - l >>= 8; - j++; - i = (byte3 & 0xff) + 4; - l = ai[l]; - k = (byte) (l & 0xff); - l >>= 8; - j++; - } - } - } - } - } while (true); - int i2 = stream.anInt571; - stream.anInt571 += k1 - j1; - if (stream.anInt571 < i2) { - stream.anInt572++; - } - stream.aByte573 = byte4; - stream.anInt574 = i; - stream.anInt584 = j; - stream.anInt582 = k; - BZip2Stream.anIntArray587 = ai; - stream.anInt581 = l; - stream.aByteArray568 = abyte0; - stream.anInt569 = i1; - stream.anInt570 = j1; + private final ByteArrayInputStream in; + private int position; + + private BZip2(byte[] src, int off, int len) { + this.in = new ByteArrayInputStream(src, off, len); } - public static void decompress(BZip2Stream stream) { - int k8 = 0; - int[] ai = null; - int[] ai1 = null; - int[] ai2 = null; - stream.anInt578 = 1; - if (BZip2Stream.anIntArray587 == null) { - BZip2Stream.anIntArray587 = new int[stream.anInt578 * 100000]; - } - boolean flag19 = true; - while (flag19) { - byte byte0 = method228(stream); - if (byte0 == 23) { - return; - } - method228(stream); - method228(stream); - method228(stream); - method228(stream); - method228(stream); - stream.anInt579++; - method228(stream); - method228(stream); - method228(stream); - method228(stream); - byte0 = method229(stream); - stream.aBoolean575 = byte0 != 0; - if (stream.aBoolean575) { - System.out.println("PANIC! RANDOMISED BLOCK!"); - } - stream.anInt580 = 0; - byte0 = method228(stream); - stream.anInt580 = (stream.anInt580 << 8) | (byte0 & 0xff); - byte0 = method228(stream); - stream.anInt580 = (stream.anInt580 << 8) | (byte0 & 0xff); - byte0 = method228(stream); - stream.anInt580 = (stream.anInt580 << 8) | (byte0 & 0xff); - for (int j = 0; j < 16; j++) { - byte byte1 = method229(stream); - stream.aBooleanArray590[j] = byte1 == 1; - } - for (int k = 0; k < 256; k++) { - stream.aBooleanArray589[k] = false; - } - for (int l = 0; l < 16; l++) { - if (stream.aBooleanArray590[l]) { - for (int i3 = 0; i3 < 16; i3++) { - byte byte2 = method229(stream); - if (byte2 == 1) { - stream.aBooleanArray589[(l * 16) + i3] = true; - } - } - } - } - method231(stream); - int i4 = stream.anInt588 + 2; - int j4 = method230(3, stream); - int k4 = method230(15, stream); - for (int i1 = 0; i1 < k4; i1++) { - int j3 = 0; - do { - byte byte3 = method229(stream); - if (byte3 == 0) { - break; - } - j3++; - } while (true); - stream.aByteArray595[i1] = (byte) j3; - } - byte[] abyte0 = new byte[6]; - for (byte byte16 = 0; byte16 < j4; byte16++) { - abyte0[byte16] = byte16; - } - for (int j1 = 0; j1 < k4; j1++) { - byte byte17 = stream.aByteArray595[j1]; - byte byte15 = abyte0[byte17]; - for (; byte17 > 0; byte17--) { - abyte0[byte17] = abyte0[byte17 - 1]; - } - abyte0[0] = byte15; - stream.aByteArray594[j1] = byte15; - } - for (int k3 = 0; k3 < j4; k3++) { - int l6 = method230(5, stream); - for (int k1 = 0; k1 < i4; k1++) { - do { - byte byte4 = method229(stream); - if (byte4 == 0) { - break; - } - byte4 = method229(stream); - if (byte4 == 0) { - l6++; - } else { - l6--; - } - } while (true); - stream.aByteArrayArray596[k3][k1] = (byte) l6; - } - } - for (int l3 = 0; l3 < j4; l3++) { - byte byte8 = 32; - int i = 0; - for (int l1 = 0; l1 < i4; l1++) { - if (stream.aByteArrayArray596[l3][l1] > i) { - i = stream.aByteArrayArray596[l3][l1]; - } - if (stream.aByteArrayArray596[l3][l1] < byte8) { - byte8 = stream.aByteArrayArray596[l3][l1]; - } - } - method232(stream.anIntArrayArray597[l3], stream.anIntArrayArray598[l3], stream.anIntArrayArray599[l3], stream.aByteArrayArray596[l3], byte8, i, i4); - stream.anIntArray600[l3] = byte8; - } - int l4 = stream.anInt588 + 1; - int i5 = -1; - int j5 = 0; - for (int i2 = 0; i2 <= 255; i2++) { - stream.anIntArray583[i2] = 0; - } - int j9 = 4095; - for (int l8 = 15; l8 >= 0; l8--) { - for (int i9 = 15; i9 >= 0; i9--) { - stream.aByteArray592[j9] = (byte) ((l8 * 16) + i9); - j9--; - } - stream.anIntArray593[l8] = j9 + 1; - } - int i6 = 0; - if (j5 == 0) { - i5++; - j5 = 50; - byte byte12 = stream.aByteArray594[i5]; - k8 = stream.anIntArray600[byte12]; - ai = stream.anIntArrayArray597[byte12]; - ai2 = stream.anIntArrayArray599[byte12]; - ai1 = stream.anIntArrayArray598[byte12]; - } - j5--; - int i7 = k8; - int l7; - byte byte9; - for (l7 = method230(i7, stream); l7 > ai[i7]; l7 = (l7 << 1) | byte9) { - i7++; - byte9 = method229(stream); - } - for (int k5 = ai2[l7 - ai1[i7]]; k5 != l4; ) { - if ((k5 == 0) || (k5 == 1)) { - int j6 = -1; - int k6 = 1; - do { - if (k5 == 0) { - j6 += k6; - } else if (k5 == 1) { - j6 += 2 * k6; - } - k6 *= 2; - if (j5 == 0) { - i5++; - j5 = 50; - byte byte13 = stream.aByteArray594[i5]; - k8 = stream.anIntArray600[byte13]; - ai = stream.anIntArrayArray597[byte13]; - ai2 = stream.anIntArrayArray599[byte13]; - ai1 = stream.anIntArrayArray598[byte13]; - } - j5--; - int j7 = k8; - int i8; - byte byte10; - for (i8 = method230(j7, stream); i8 > ai[j7]; i8 = (i8 << 1) | byte10) { - j7++; - byte10 = method229(stream); - } - k5 = ai2[i8 - ai1[j7]]; - } while ((k5 == 0) || (k5 == 1)); - j6++; - byte byte5 = stream.aByteArray591[stream.aByteArray592[stream.anIntArray593[0]] & 0xff]; - stream.anIntArray583[byte5 & 0xff] += j6; - for (; j6 > 0; j6--) { - BZip2Stream.anIntArray587[i6] = byte5 & 0xff; - i6++; - } - } else { - int j11 = k5 - 1; - byte byte6; - if (j11 < 16) { - int j10 = stream.anIntArray593[0]; - byte6 = stream.aByteArray592[j10 + j11]; - for (; j11 > 3; j11 -= 4) { - int k11 = j10 + j11; - stream.aByteArray592[k11] = stream.aByteArray592[k11 - 1]; - stream.aByteArray592[k11 - 1] = stream.aByteArray592[k11 - 2]; - stream.aByteArray592[k11 - 2] = stream.aByteArray592[k11 - 3]; - stream.aByteArray592[k11 - 3] = stream.aByteArray592[k11 - 4]; - } - for (; j11 > 0; j11--) { - stream.aByteArray592[j10 + j11] = stream.aByteArray592[(j10 + j11) - 1]; - } - stream.aByteArray592[j10] = byte6; - } else { - int l10 = j11 / 16; - int i11 = j11 % 16; - int k10 = stream.anIntArray593[l10] + i11; - byte6 = stream.aByteArray592[k10]; - for (; k10 > stream.anIntArray593[l10]; k10--) { - stream.aByteArray592[k10] = stream.aByteArray592[k10 - 1]; - } - stream.anIntArray593[l10]++; - for (; l10 > 0; l10--) { - stream.anIntArray593[l10]--; - stream.aByteArray592[stream.anIntArray593[l10]] = stream.aByteArray592[(stream.anIntArray593[l10 - 1] + 16) - 1]; - } - stream.anIntArray593[0]--; - stream.aByteArray592[stream.anIntArray593[0]] = byte6; - if (stream.anIntArray593[0] == 0) { - int i10 = 4095; - for (int k9 = 15; k9 >= 0; k9--) { - for (int l9 = 15; l9 >= 0; l9--) { - stream.aByteArray592[i10] = stream.aByteArray592[stream.anIntArray593[k9] + l9]; - i10--; - } - stream.anIntArray593[k9] = i10 + 1; - } - } - } - stream.anIntArray583[stream.aByteArray591[byte6 & 0xff] & 0xff]++; - BZip2Stream.anIntArray587[i6] = stream.aByteArray591[byte6 & 0xff] & 0xff; - i6++; - if (j5 == 0) { - i5++; - j5 = 50; - byte byte14 = stream.aByteArray594[i5]; - k8 = stream.anIntArray600[byte14]; - ai = stream.anIntArrayArray597[byte14]; - ai2 = stream.anIntArrayArray599[byte14]; - ai1 = stream.anIntArrayArray598[byte14]; - } - j5--; - int k7 = k8; - int j8; - byte byte11; - for (j8 = method230(k7, stream); j8 > ai[k7]; j8 = (j8 << 1) | byte11) { - k7++; - byte11 = method229(stream); - } - k5 = ai2[j8 - ai1[k7]]; - } - } - stream.anInt574 = 0; - stream.aByte573 = 0; - stream.anIntArray585[0] = 0; - for (int j2 = 1; j2 <= 256; j2++) { - stream.anIntArray585[j2] = stream.anIntArray583[j2 - 1]; - } - for (int k2 = 1; k2 <= 256; k2++) { - stream.anIntArray585[k2] += stream.anIntArray585[k2 - 1]; - } - for (int l2 = 0; l2 < i6; l2++) { - byte byte7 = (byte) (BZip2Stream.anIntArray587[l2] & 0xff); - BZip2Stream.anIntArray587[stream.anIntArray585[byte7 & 0xff]] |= l2 << 8; - stream.anIntArray585[byte7 & 0xff]++; - } - stream.anInt581 = BZip2Stream.anIntArray587[stream.anInt580] >> 8; - stream.anInt584 = 0; - stream.anInt581 = BZip2Stream.anIntArray587[stream.anInt581]; - stream.anInt582 = (byte) (stream.anInt581 & 0xff); - stream.anInt581 >>= 8; - stream.anInt584++; - stream.anInt601 = i6; - method226(stream); - flag19 = (stream.anInt584 == (stream.anInt601 + 1)) && (stream.anInt574 == 0); - } - } - - public static byte method228(BZip2Stream stream) { - return (byte) method230(8, stream); - } - - public static byte method229(BZip2Stream stream) { - return (byte) method230(1, stream); - } - - public static int method230(int i, BZip2Stream stream) { - int j; - do { - if (stream.anInt577 >= i) { - int k = (stream.anInt576 >> (stream.anInt577 - i)) & ((1 << i) - 1); - stream.anInt577 -= i; - j = k; - break; - } - stream.anInt576 = (stream.anInt576 << 8) | (stream.aByteArray563[stream.anInt564] & 0xff); - stream.anInt577 += 8; - stream.anInt564++; - stream.anInt565--; - stream.anInt566++; - if (stream.anInt566 == 0) { - stream.anInt567++; - } - } while (true); - return j; - } - - public static void method231(BZip2Stream stream) { - stream.anInt588 = 0; - for (int i = 0; i < 256; i++) { - if (stream.aBooleanArray589[i]) { - stream.aByteArray591[stream.anInt588] = (byte) i; - stream.anInt588++; - } - } - } - - public static void method232(int[] ai, int[] ai1, int[] ai2, byte[] abyte0, int i, int j, int k) { - int l = 0; - for (int i1 = i; i1 <= j; i1++) { - for (int l2 = 0; l2 < k; l2++) { - if (abyte0[l2] == i1) { - ai2[l] = l2; - l++; - } - } - } - for (int j1 = 0; j1 < 23; j1++) { - ai1[j1] = 0; - } - for (int k1 = 0; k1 < k; k1++) { - ai1[abyte0[k1] + 1]++; - } - for (int l1 = 1; l1 < 23; l1++) { - ai1[l1] += ai1[l1 - 1]; - } - for (int i2 = 0; i2 < 23; i2++) { - ai[i2] = 0; - } - int i3 = 0; - for (int j2 = i; j2 <= j; j2++) { - i3 += ai1[j2 + 1] - ai1[j2]; - ai[j2] = i3 - 1; - i3 <<= 1; - } - for (int k2 = i + 1; k2 <= j; k2++) { - ai1[k2] = ((ai[k2 - 1] + 1) << 1) - ai1[k2]; + @Override + public int read() throws IOException { + if (position < 4) { + return MAGIC[position++]; } + return in.read(); } } diff --git a/src/main/java/BZip2Stream.java b/src/main/java/BZip2Stream.java deleted file mode 100644 index dda9f90..0000000 --- a/src/main/java/BZip2Stream.java +++ /dev/null @@ -1,49 +0,0 @@ -// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) - -public class BZip2Stream { - - public static int[] anIntArray587; - public byte[] aByteArray563; - public int anInt564; - public int anInt565; - public int anInt566; - public int anInt567; - public byte[] aByteArray568; - public int anInt569; - public int anInt570; - public int anInt571; - public int anInt572; - public byte aByte573; - public int anInt574; - public boolean aBoolean575; - public int anInt576; - public int anInt577; - public int anInt578; - public int anInt579; - public int anInt580; - public int anInt581; - public int anInt582; - public final int[] anIntArray583 = new int[256]; - public int anInt584; - public final int[] anIntArray585 = new int[257]; - public int anInt588; - public final boolean[] aBooleanArray589 = new boolean[256]; - public final boolean[] aBooleanArray590 = new boolean[16]; - public final byte[] aByteArray591 = new byte[256]; - public final byte[] aByteArray592 = new byte[4096]; - public final int[] anIntArray593 = new int[16]; - public final byte[] aByteArray594 = new byte[18002]; - public final byte[] aByteArray595 = new byte[18002]; - public final byte[][] aByteArrayArray596 = new byte[6][258]; - public final int[][] anIntArrayArray597 = new int[6][258]; - public final int[][] anIntArrayArray598 = new int[6][258]; - public final int[][] anIntArrayArray599 = new int[6][258]; - public final int[] anIntArray600 = new int[6]; - public int anInt601; - - public BZip2Stream() { - } - -} diff --git a/src/main/java/BitmapFont.java b/src/main/java/BitmapFont.java index f234640..cae0bcc 100644 --- a/src/main/java/BitmapFont.java +++ b/src/main/java/BitmapFont.java @@ -1,3 +1,4 @@ +import java.io.IOException; import java.util.Random; public class BitmapFont { @@ -12,9 +13,9 @@ public class BitmapFont { public int height; public boolean strikethrough = false; - public BitmapFont(FileArchive archive, String name, boolean quill) { - Buffer dat = new Buffer(archive.read(name + ".dat", null)); - Buffer idx = new Buffer(archive.read("index.dat", null)); + public BitmapFont(FileArchive archive, String name, boolean quill) throws IOException { + Buffer dat = new Buffer(archive.read(name + ".dat")); + Buffer idx = new Buffer(archive.read("index.dat")); idx.position = dat.get2U() + 4; int k = idx.get1U(); diff --git a/src/main/java/Buffer.java b/src/main/java/Buffer.java index ab8f613..6dc7f04 100644 --- a/src/main/java/Buffer.java +++ b/src/main/java/Buffer.java @@ -1,3 +1,5 @@ +import org.apache.commons.math3.random.ISAACRandom; + import java.math.BigInteger; import java.nio.charset.StandardCharsets; @@ -8,7 +10,7 @@ import java.nio.charset.StandardCharsets; *

* Types:
* # — the number of bytes
- * Op — 1 byte which is modified by the {@link #cipher}
+ * Op — 1 byte which is modified by the {@link #random} number generator.
* Smart — 1 or 2 byte value [-16384...16383]
* USmart — 1 or 2 byte value [0...32768]
* String — {@link StandardCharsets#ISO_8859_1} encoding delimited by a newline character (\n)
@@ -72,7 +74,7 @@ public class Buffer extends DoublyLinkedList.Node { public byte[] data; public int position; public int bitPosition; - public ISAACCipher cipher; + public ISAACRandom random; public Buffer() { } @@ -83,7 +85,7 @@ public class Buffer extends DoublyLinkedList.Node { } public void putOp(int i) { - data[position++] = (byte) (i + cipher.method246()); + data[position++] = (byte) (i + random.nextInt()); } public void putSize1(int i) { diff --git a/src/main/java/Censor.java b/src/main/java/Censor.java index 772bf63..98a21f5 100644 --- a/src/main/java/Censor.java +++ b/src/main/java/Censor.java @@ -2,6 +2,8 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) +import java.io.IOException; + public class Censor { public static final String[] aStringArray626 = {"cook", "cook's", "cooks", "seeks", "sheet", "woop", "woops", "faq", "noob", "noobs"}; @@ -12,11 +14,11 @@ public class Censor { public static char[][] aCharArrayArray624; public static int[] anIntArray625; - public static void method487(FileArchive archive) { - Buffer buffer = new Buffer(archive.read("fragmentsenc.txt", null)); - Buffer buffer_1 = new Buffer(archive.read("badenc.txt", null)); - Buffer class30_sub2_sub2_2 = new Buffer(archive.read("domainenc.txt", null)); - Buffer buffer_3 = new Buffer(archive.read("tldlist.txt", null)); + 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); } diff --git a/src/main/java/Component.java b/src/main/java/Component.java index cb6c805..f37c296 100644 --- a/src/main/java/Component.java +++ b/src/main/java/Component.java @@ -2,6 +2,8 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) +import java.io.IOException; + public class Component { public static Component[] instances; @@ -72,9 +74,9 @@ public class Component { public Component() { } - public static void unpack(FileArchive archive, BitmapFont[] aclass30_sub2_sub1_sub4, FileArchive archive_1) { + public static void unpack(FileArchive archive, BitmapFont[] aclass30_sub2_sub1_sub4, FileArchive archive_1) throws IOException { aCache_238 = new LRUCache(50000); - Buffer buffer = new Buffer(archive.read("data", null)); + Buffer buffer = new Buffer(archive.read("data")); int i = -1; int j = buffer.get2U(); instances = new Component[j]; diff --git a/src/main/java/FileArchive.java b/src/main/java/FileArchive.java index 9e95fb6..2b83e18 100644 --- a/src/main/java/FileArchive.java +++ b/src/main/java/FileArchive.java @@ -1,3 +1,5 @@ +import java.io.IOException; + /** * A simple file archive format. */ @@ -11,11 +13,11 @@ public class FileArchive { public int[] fileOffset; public boolean unpacked; - public FileArchive(byte[] src) { + public FileArchive(byte[] src) throws IOException { load(src); } - public void load(byte[] src) { + public void load(byte[] src) throws IOException { Buffer buffer = new Buffer(src); int unpackedSize = buffer.get3(); @@ -23,7 +25,7 @@ public class FileArchive { if (packedSize != unpackedSize) { data = new byte[unpackedSize]; - BZip2.decompress(data, unpackedSize, src, 6, packedSize); + BZip2.decompress(data, src, 6, packedSize); buffer = new Buffer(data); unpacked = true; } else { @@ -48,7 +50,7 @@ public class FileArchive { } } - public byte[] read(String s, byte[] dst) { + public byte[] read(String s) throws IOException { int hash = 0; s = s.toUpperCase(); for (int j = 0; j < s.length(); j++) { @@ -59,18 +61,19 @@ public class FileArchive { if (fileHash[file] != hash) { continue; } - if (dst == null) { - dst = new byte[fileSizeInflated[file]]; - } if (!unpacked) { - BZip2.decompress(dst, fileSizeInflated[file], data, fileOffset[file], fileSizeDeflated[file]); + byte[] dst = new byte[fileSizeInflated[file]]; + + + + BZip2.decompress(dst, data, fileOffset[file], fileSizeDeflated[file]); + return dst; } else { - for (int i = 0; i < fileSizeInflated[file]; i++) { - dst[i] = data[fileOffset[file] + i]; - } + byte[] dst = new byte[fileSizeInflated[file]]; + System.arraycopy(data, fileOffset[file], dst, 0, fileSizeInflated[file]); + return dst; } - return dst; } return null; } diff --git a/src/main/java/FloType.java b/src/main/java/FloType.java index 4170417..e945675 100644 --- a/src/main/java/FloType.java +++ b/src/main/java/FloType.java @@ -2,6 +2,8 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) +import java.io.IOException; + public class FloType { public static int anInt387; @@ -21,8 +23,8 @@ public class FloType { public FloType() { } - public static void unpack(FileArchive archive) { - Buffer buffer = new Buffer(archive.read("flo.dat", null)); + public static void unpack(FileArchive archive) throws IOException { + Buffer buffer = new Buffer(archive.read("flo.dat")); anInt387 = buffer.get2U(); if (instances == null) { instances = new FloType[anInt387]; diff --git a/src/main/java/Game.java b/src/main/java/Game.java index ade4e19..b7645b5 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -2,6 +2,8 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) +import org.apache.commons.math3.random.ISAACRandom; + import java.applet.AppletContext; import java.awt.*; import java.io.DataInputStream; @@ -21,20 +23,22 @@ public class Game extends GameShell { public static final int[][] anIntArrayArray1003 = {{6798, 107, 10283, 16, 4797, 7744, 5799, 4634, 33697, 22433, 2983, 54193}, {8741, 12, 64030, 43162, 7735, 8404, 1701, 38430, 24094, 10153, 56621, 4783, 1341, 16578, 35003, 25239}, {25238, 8742, 12, 64030, 43162, 7735, 8404, 1701, 38430, 24094, 10153, 56621, 4783, 1341, 16578, 35003}, {4626, 11146, 6439, 12, 4758, 10270}, {4550, 4537, 5681, 5673, 5790, 6806, 8076, 4574}}; public static final int[] anIntArray1204 = {9104, 10275, 7595, 3610, 7975, 8526, 918, 38802, 24466, 10145, 58654, 5027, 1457, 16565, 34991, 25486}; public static final BigInteger RSA_MODULUS = new BigInteger("7162900525229798032761816791230527296329313291232324290237849263501208207972894053929065636522363163621000728841182238772712427862772219676577293600221789"); + public static final int[] levelExperience; + public static final BigInteger RSA_PUBLIC_KEY = new BigInteger("58778699976184461502525193738213253649000149147835990136706041084440742975821"); + public static final String aString1162 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"\243$%^&*()-_=+[{]};:'@#~,<.>/?\\| "; + public static final int[] anIntArray1232; + public static final int MAX_PLAYER_COUNT = 2048; + public static final int LOCAL_PLAYER_INDEX = 2047; public static int nodeId = 10; public static int portOffset; public static boolean members = true; public static boolean lowmem; public static boolean started; - public static final int[] levelExperience; - public static final BigInteger RSA_PUBLIC_KEY = new BigInteger("58778699976184461502525193738213253649000149147835990136706041084440742975821"); public static int drawCycle; public static PlayerEntity aPlayer_1126; public static boolean aBoolean1156; public static int loopCycle; - public static final String aString1162 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"\243$%^&*()-_=+[{]};:'@#~,<.>/?\\| "; public static boolean aBoolean1205; - public static final int[] anIntArray1232; static { levelExperience = new int[99]; @@ -53,7 +57,152 @@ public class Game extends GameShell { } } + public static String method14(int i) { + String s = String.valueOf(i); + for (int k = s.length() - 3; k > 0; k -= 3) { + s = s.substring(0, k) + "," + s.substring(k); + } + if (s.length() > 8) { + s = "@gre@" + s.substring(0, s.length() - 8) + " million @whi@(" + s + ")"; + } else if (s.length() > 4) { + s = "@cya@" + s.substring(0, s.length() - 4) + "K @whi@(" + s + ")"; + } + return " " + s; + } + + public static String method43(int j) { + if (j < 0x186a0) { + return String.valueOf(j); + } + if (j < 0x989680) { + return (j / 1000) + "K"; + } else { + return (j / 0xf4240) + "M"; + } + } + + public static void setHighmem() { + Scene.lowmem = false; + Draw3D.lowmem = false; + lowmem = false; + SceneBuilder.lowmem = false; + LocType.lowmem = false; + } + + public static void main(String[] args) throws UnknownHostException { + System.out.println("RS2 user client - release #" + 317); + + if (args.length != 5) { + System.out.println("Usage: node-id, port-offset, [lowmem/highmem], [free/members], storeid"); + return; + } + + nodeId = Integer.parseInt(args[0]); + portOffset = Integer.parseInt(args[1]); + + if (args[2].equals("lowmem")) { + setLowmem(); + } else if (args[2].equals("highmem")) { + setHighmem(); + } else { + System.out.println("Usage: node-id, port-offset, [lowmem/highmem], [free/members], storeid"); + return; + } + + if (args[3].equals("free")) { + members = false; + } else if (args[3].equals("members")) { + members = true; + } else { + System.out.println("Usage: node-id, port-offset, [lowmem/highmem], [free/members], storeid"); + return; + } + + Signlink.storeid = Integer.parseInt(args[4]); + Signlink.startpriv(InetAddress.getLocalHost()); + + Game game = new Game(); + game.init(765, 503); + } + + public static String method110(int i, int j) { + int d = i - j; + if (d < -9) { + return "@red@"; + } else if (d < -6) { + return "@or3@"; + } else if (d < -3) { + return "@or2@"; + } else if (d < 0) { + return "@or1@"; + } else if (d > 9) { + return "@gre@"; + } else if (d > 6) { + return "@gr3@"; + } else if (d > 3) { + return "@gr2@"; + } else if (d > 0) { + return "@gr1@"; + } else { + return "@yel@"; + } + } + + public static void setLowmem() { + Scene.lowmem = true; + Draw3D.lowmem = true; + lowmem = true; + SceneBuilder.lowmem = true; + LocType.lowmem = true; + } public final int[] anIntArray1177 = {0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3}; + public final int[] anIntArray864 = new int[SkillConstants.anInt733]; + public final int[] anIntArray873 = new int[5]; + public final boolean[] aBooleanArray876 = new boolean[5]; + public final int anInt902 = 0x766654; + public final int[] anIntArray922 = new int[SkillConstants.anInt733]; + public final long[] aLongArray925 = new long[100]; + public final int anInt927 = 0x332d25; + public final int[] anIntArray928 = new int[5]; + public final CRC32 aCRC32_930 = new CRC32(); + public final int[] anIntArray942 = new int[100]; + public final String[] aStringArray943 = new String[100]; + public final String[] aStringArray944 = new String[100]; + public final int[] anIntArray965 = {0xffff00, 0xff0000, 65280, 65535, 0xff00ff, 0xffffff}; + public final int[] anIntArray968 = new int[33]; + public final int[] anIntArray969 = new int[256]; + public final FileStore[] filestores = new FileStore[5]; + public final int anInt975 = 50; + public final int[] anIntArray976 = new int[anInt975]; + public final int[] anIntArray977 = new int[anInt975]; + public final int[] anIntArray978 = new int[anInt975]; + public final int[] anIntArray979 = new int[anInt975]; + public final int[] anIntArray980 = new int[anInt975]; + public final int[] anIntArray981 = new int[anInt975]; + public final int[] anIntArray982 = new int[anInt975]; + public final String[] aStringArray983 = new String[anInt975]; + public final int[] anIntArray990 = new int[5]; + public final int anInt1002 = 0x23201b; + public final int[] anIntArray1030 = new int[5]; + public final int[] anIntArray1044 = new int[SkillConstants.anInt733]; + public final int[] anIntArray1045 = new int[2000]; + public final int[] anIntArray1052 = new int[151]; + public final int[] anIntArray1057 = new int[33]; + public final Component aComponent_1059 = new Component(); + public final int anInt1063 = 0x4d4233; + public final int[] anIntArray1065 = new int[7]; + public final int[] archiveChecksum = new int[9]; + public final String[] aStringArray1127 = new String[5]; + public final boolean[] aBooleanArray1128 = new boolean[5]; + public final int[][][] sceneInstancedChunkBitset = new int[4][13][13]; + public final int[] anIntArray1130 = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; + public final int[] anIntArray1203 = new int[5]; + public final int[] anIntArray1207 = new int[50]; + public final Image8[] aImageArray1219 = new Image8[2]; + public final int[] anIntArray1229 = new int[151]; + public final int[] anIntArray1240 = new int[100]; + public final int[] anIntArray1241 = new int[50]; + public final int[] anIntArray1250 = new int[50]; public int anInt822; public long sceneLoadStartTime; public int[][] anIntArrayArray825 = new int[104][104]; @@ -89,7 +238,6 @@ public class Game extends GameShell { public int anInt861; public int anInt862; public int anInt863; - public final int[] anIntArray864 = new int[SkillConstants.anInt733]; public Image8 aImage_865; public Image8 aImage_866; public Image8 aImage_867; @@ -98,9 +246,7 @@ public class Game extends GameShell { public Image24 imageMapmarker0; public Image24 imageMapmarker1; public boolean aBoolean872 = false; - public final int[] anIntArray873 = new int[5]; public int anInt874 = -1; - public final boolean[] aBooleanArray876 = new boolean[5]; public int anInt878; public MouseRecorder aMouseRecorder_879; public volatile boolean aBoolean880 = false; @@ -109,8 +255,6 @@ public class Game extends GameShell { public boolean aBoolean885 = false; public int anInt886; public String aString887 = ""; - public static final int MAX_PLAYER_COUNT = 2048; - public static final int LOCAL_PLAYER_INDEX = 2047; public PlayerEntity[] players = new PlayerEntity[MAX_PLAYER_COUNT]; public int anInt891; public int[] anIntArray892 = new int[MAX_PLAYER_COUNT]; @@ -121,7 +265,6 @@ public class Game extends GameShell { public int anInt899; public int anInt900; public int[][] anIntArrayArray901 = new int[104][104]; - public final int anInt902 = 0x766654; public DrawArea aArea_903; public DrawArea aArea_904; public DrawArea aArea_905; @@ -138,13 +281,8 @@ public class Game extends GameShell { public int anInt916; public int anInt917; public int anInt918; - public final int[] anIntArray922 = new int[SkillConstants.anInt733]; - public final long[] aLongArray925 = new long[100]; public boolean aBoolean926 = false; - public final int anInt927 = 0x332d25; - public final int[] anIntArray928 = new int[5]; public int[][] anIntArrayArray929 = new int[104][104]; - public final CRC32 aCRC32_930 = new CRC32(); public Image24 aImage_931; public Image24 aImage_932; public int anInt933; @@ -153,9 +291,6 @@ public class Game extends GameShell { public int anInt936; public int anInt937; public int anInt938; - public final int[] anIntArray942 = new int[100]; - public final String[] aStringArray943 = new String[100]; - public final String[] aStringArray944 = new String[100]; public int anInt945; public Scene scene; public Image8[] imageSideicons = new Image8[13]; @@ -171,38 +306,23 @@ public class Game extends GameShell { public volatile boolean aBoolean962 = false; public int anInt963 = -1; public int anInt964 = -1; - public final int[] anIntArray965 = {0xffff00, 0xff0000, 65280, 65535, 0xff00ff, 0xffffff}; public Image8 aImage_966; public Image8 aImage_967; - public final int[] anIntArray968 = new int[33]; - public final int[] anIntArray969 = new int[256]; - public final FileStore[] filestores = new FileStore[5]; public int[] anIntArray971 = new int[2000]; public boolean aBoolean972 = false; public int anInt974; - public final int anInt975 = 50; - public final int[] anIntArray976 = new int[anInt975]; - public final int[] anIntArray977 = new int[anInt975]; - public final int[] anIntArray978 = new int[anInt975]; - public final int[] anIntArray979 = new int[anInt975]; - public final int[] anIntArray980 = new int[anInt975]; - public final int[] anIntArray981 = new int[anInt975]; - public final int[] anIntArray982 = new int[anInt975]; - public final String[] aStringArray983 = new String[anInt975]; public int anInt984; public int anInt985 = -1; public Image24[] imageHitmarks = new Image24[20]; public int anInt989; - public final int[] anIntArray990 = new int[5]; public int anInt992; public int anInt995; public int anInt996; public int anInt997; public int anInt998; public int anInt999; - public ISAACCipher aISAACCipher_1000; + public ISAACRandom randomIn; public Image24 imageMapedge; - public final int anInt1002 = 0x23201b; public String aString1004 = ""; public int anInt1006; public int psize; @@ -225,7 +345,6 @@ public class Game extends GameShell { public Image8 imageBackbase1; public Image8 imageBackbase2; public Image8 imageBackhmid1; - public final int[] anIntArray1030 = new int[5]; public boolean aBoolean1031 = false; public Image24[] imageMapfunction = new Image24[100]; public int sceneBaseTileX; @@ -237,24 +356,17 @@ public class Game extends GameShell { public int anInt1040; public int anInt1041; public int anInt1042 = -1; - public final int[] anIntArray1044 = new int[SkillConstants.anInt733]; - public final int[] anIntArray1045 = new int[2000]; public int anInt1046; public boolean aBoolean1047 = true; public int anInt1048; public String aString1049; - public final int[] anIntArray1052 = new int[151]; public FileArchive archiveTitle; public int anInt1054 = -1; public int anInt1055; public DoublyLinkedList aList_1056 = new DoublyLinkedList(); - public final int[] anIntArray1057 = new int[33]; - public final Component aComponent_1059 = new Component(); public Image8[] imageMapscene = new Image8[100]; public int anInt1062; - public final int anInt1063 = 0x4d4233; public int anInt1064; - public final int[] anIntArray1065 = new int[7]; public int anInt1066; public int anInt1067; public OnDemand ondemand; @@ -278,7 +390,6 @@ public class Game extends GameShell { public int anInt1087; public int anInt1088; public int anInt1089; - public final int[] archiveChecksum = new int[9]; public int[] anIntArray1091 = new int[500]; public int[] anIntArray1092 = new int[500]; public int[] anIntArray1093 = new int[500]; @@ -306,10 +417,6 @@ public class Game extends GameShell { public DrawArea aArea_1123; public DrawArea aArea_1124; public DrawArea aArea_1125; - public final String[] aStringArray1127 = new String[5]; - public final boolean[] aBooleanArray1128 = new boolean[5]; - public final int[][][] sceneInstancedChunkBitset = new int[4][13][13]; - public final int[] anIntArray1130 = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; public int anInt1131; public int anInt1133; public int anInt1136; @@ -368,8 +475,6 @@ public class Game extends GameShell { public String[] aStringArray1199 = new String[500]; public Image24 aImage_1201; public Image24 aImage_1202; - public final int[] anIntArray1203 = new int[5]; - public final int[] anIntArray1207 = new int[50]; public int flameCycle; public int anInt1209; public int anInt1211 = 78; @@ -378,7 +483,6 @@ public class Game extends GameShell { public int[][][] anIntArrayArrayArray1214; public long aLong1215; public int anInt1216; - public final Image8[] aImageArray1219 = new Image8[2]; public long aLong1220; public int anInt1221 = 3; public int anInt1222; @@ -386,7 +490,6 @@ public class Game extends GameShell { public int anInt1225; public int music; public boolean musicFade = true; - public final int[] anIntArray1229 = new int[151]; public SceneCollisionMap[] collisions = new SceneCollisionMap[4]; public boolean aBoolean1233 = false; public int[] sceneMapIndex; @@ -394,8 +497,6 @@ public class Game extends GameShell { public int[] sceneMapLocFile; public int anInt1237; public int anInt1238; - public final int[] anIntArray1240 = new int[100]; - public final int[] anIntArray1241 = new int[50]; public boolean aBoolean1242 = false; public int anInt1243; public int anInt1244; @@ -404,7 +505,6 @@ public class Game extends GameShell { public byte[][] sceneMapLocData; public int anInt1248; public int anInt1249; - public final int[] anIntArray1250 = new int[50]; public int anInt1251; public boolean errAlreadyStarted = false; public int anInt1253; @@ -499,7 +599,7 @@ public class Game extends GameShell { } @Override - public void load() { + public void load() throws IOException { showProgress(20, "Starting up"); if (Signlink.sunjava) { @@ -870,7 +970,7 @@ public class Game extends GameShell { ObjType.aBoolean182 = members; if (!lowmem) { showProgress(90, "Unpacking sounds"); - byte[] abyte0 = archiveSounds.read("sounds.dat", null); + byte[] abyte0 = archiveSounds.read("sounds.dat"); Buffer buffer = new Buffer(abyte0); SoundTrack.method240(buffer); } @@ -939,6 +1039,7 @@ public class Game extends GameShell { return; } catch (Exception exception) { Signlink.reporterror("loaderror " + aString1049 + " " + anInt1079); + exception.printStackTrace(); } aBoolean926 = true; } @@ -970,10 +1071,12 @@ public class Game extends GameShell { method15(); if (aMouseRecorder_879 != null) { aMouseRecorder_879.aBoolean808 = false; - } aMouseRecorder_879 = null; - ondemand.stop(); - ondemand = null; + } + if (ondemand != null) { + ondemand.stop(); + ondemand = null; + } aBuffer_834 = null; aBuffer_1192 = null; aBuffer_847 = null; @@ -1090,7 +1193,7 @@ public class Game extends GameShell { } @Override - public void draw() { + public void draw() throws IOException { if (errAlreadyStarted || aBoolean926 || errInvalidHost) { method94(); return; @@ -1134,7 +1237,7 @@ public class Game extends GameShell { } @Override - public void showProgress(int percent, String message) { + public void showProgress(int percent, String message) throws IOException { anInt1079 = percent; aString1049 = message; method64(); @@ -1169,118 +1272,12 @@ public class Game extends GameShell { } } - public static String method14(int i) { - String s = String.valueOf(i); - for (int k = s.length() - 3; k > 0; k -= 3) { - s = s.substring(0, k) + "," + s.substring(k); - } - if (s.length() > 8) { - s = "@gre@" + s.substring(0, s.length() - 8) + " million @whi@(" + s + ")"; - } else if (s.length() > 4) { - s = "@cya@" + s.substring(0, s.length() - 4) + "K @whi@(" + s + ")"; - } - return " " + s; - } - - public static String method43(int j) { - if (j < 0x186a0) { - return String.valueOf(j); - } - if (j < 0x989680) { - return (j / 1000) + "K"; - } else { - return (j / 0xf4240) + "M"; - } - } - - public static void setHighmem() { - Scene.lowmem = false; - Draw3D.lowmem = false; - lowmem = false; - SceneBuilder.lowmem = false; - LocType.lowmem = false; - } - - public static void main(String[] args) throws UnknownHostException { - System.out.println("RS2 user client - release #" + 317); - - if (args.length != 5) { - System.out.println("Usage: node-id, port-offset, [lowmem/highmem], [free/members], storeid"); - return; - } - - nodeId = Integer.parseInt(args[0]); - portOffset = Integer.parseInt(args[1]); - - if (args[2].equals("lowmem")) { - setLowmem(); - } else if (args[2].equals("highmem")) { - setHighmem(); - } else { - System.out.println("Usage: node-id, port-offset, [lowmem/highmem], [free/members], storeid"); - return; - } - - if (args[3].equals("free")) { - members = false; - } else if (args[3].equals("members")) { - members = true; - } else { - System.out.println("Usage: node-id, port-offset, [lowmem/highmem], [free/members], storeid"); - return; - } - - Signlink.storeid = Integer.parseInt(args[4]); - Signlink.startpriv(InetAddress.getLocalHost()); - - Game game = new Game(); - game.init(765, 503); - } - - public static String method110(int i, int j) { - int d = i - j; - if (d < -9) { - return "@red@"; - } else - if (d < -6) { - return "@or3@"; - }else - if (d < -3) { - return "@or2@"; - } else - if (d < 0) { - return "@or1@"; - } else - if (d > 9) { - return "@gre@"; - } else - if (d > 6) { - return "@gr3@"; - } else - if (d > 3) { - return "@gr2@"; - } else - if (d > 0) { - return "@gr1@"; - } else { - return "@yel@"; - } - } - - public static void setLowmem() { - Scene.lowmem = true; - Draw3D.lowmem = true; - lowmem = true; - SceneBuilder.lowmem = true; - LocType.lowmem = true; - } - public void method15() { Signlink.midifade = 0; Signlink.midi = "stop"; } - public void loadArchiveChecksums() { + public void loadArchiveChecksums() throws IOException { int j = 5; archiveChecksum[8] = 0; int k = 0; @@ -1355,7 +1352,7 @@ public class Game extends GameShell { aArea_1166.bind(); Draw3D.lineOffset = anIntArray1180; imageChatback.method361(0, 0); - + if (aBoolean1256) { fontBold12.drawStringCenter(aString1121, 239, 40, 0); fontBold12.drawStringCenter(aString1212 + "*", 239, 60, 128); @@ -3195,7 +3192,7 @@ public class Game extends GameShell { } } - public void method51() { + public void method51() throws IOException { aImage_966 = new Image8(archiveTitle, "titlebox", 0); aImage_967 = new Image8(archiveTitle, "titlebutton", 0); aImageArray1152 = new Image8[12]; @@ -3363,8 +3360,8 @@ public class Game extends GameShell { } } - public void method56() { - byte[] abyte0 = archiveTitle.read("title.dat", null); + public void method56() throws IOException { + byte[] abyte0 = archiveTitle.read("title.dat"); Image24 image = new Image24(abyte0, this); aArea_1110.bind(); image.method346(0, 0); @@ -3850,7 +3847,7 @@ public class Game extends GameShell { } } - public void method64() { + public void method64() throws IOException { if (aArea_1107 != null) { return; } @@ -3952,7 +3949,7 @@ public class Game extends GameShell { return true; } - public FileArchive loadArchive(int i, String s, String s1, int j, int k) { + public FileArchive loadArchive(int i, String s, String s1, int j, int k) throws IOException { byte[] abyte0 = null; int l = 5; try { @@ -5969,17 +5966,20 @@ public class Game extends GameShell { connection.method270(in.data, 0, 8); in.position = 0; aLong1215 = in.get8(); - int[] ai = new int[4]; - ai[0] = (int) (Math.random() * 99999999D); - ai[1] = (int) (Math.random() * 99999999D); - ai[2] = (int) (aLong1215 >> 32); - ai[3] = (int) aLong1215; + + // apache math tries to fill the remaining 1008 bytes up with random junk if we don't give it 256 ints. + int[] seed = new int[1 << 8]; + + seed[0] = (int) (Math.random() * 99999999D); + seed[1] = (int) (Math.random() * 99999999D); + seed[2] = (int) (aLong1215 >> 32); + seed[3] = (int) aLong1215; aBuffer_1192.position = 0; aBuffer_1192.put1(10); - aBuffer_1192.put4(ai[0]); - aBuffer_1192.put4(ai[1]); - aBuffer_1192.put4(ai[2]); - aBuffer_1192.put4(ai[3]); + aBuffer_1192.put4(seed[0]); + aBuffer_1192.put4(seed[1]); + aBuffer_1192.put4(seed[2]); + aBuffer_1192.put4(seed[3]); aBuffer_1192.put4(Signlink.uid); aBuffer_1192.put(s); aBuffer_1192.put(s1); @@ -5998,11 +5998,11 @@ public class Game extends GameShell { aBuffer_847.put4(archiveChecksum[l1]); } aBuffer_847.put(aBuffer_1192.data, aBuffer_1192.position, 0); - aBuffer_1192.cipher = new ISAACCipher(ai); + aBuffer_1192.random = new ISAACRandom(seed); for (int j2 = 0; j2 < 4; j2++) { - ai[j2] += 50; + seed[j2] += 50; } - aISAACCipher_1000 = new ISAACCipher(ai); + randomIn = new ISAACRandom(seed); connection.method271(aBuffer_847.position, aBuffer_847.data, 0); k = connection.method268(); } @@ -9002,7 +9002,7 @@ public class Game extends GameShell { } } - public void method135(boolean flag) { + public void method135(boolean flag) throws IOException { method64(); aArea_1109.bind(); aImage_966.method361(0, 0); @@ -9676,8 +9676,8 @@ public class Game extends GameShell { if (ptype == -1) { connection.method270(in.data, 0, 1); ptype = in.data[0] & 0xff; - if (aISAACCipher_1000 != null) { - ptype = (ptype - aISAACCipher_1000.method246()) & 0xff; + if (randomIn != null) { + ptype = (ptype - randomIn.nextInt()) & 0xff; } psize = PacketConstants.SIZE[ptype]; available--; diff --git a/src/main/java/GameShell.java b/src/main/java/GameShell.java index df9db12..036a777 100644 --- a/src/main/java/GameShell.java +++ b/src/main/java/GameShell.java @@ -5,6 +5,7 @@ import java.applet.Applet; import java.awt.*; import java.awt.event.*; +import java.io.IOException; public abstract class GameShell extends Applet implements Runnable, MouseListener, MouseMotionListener, KeyListener, FocusListener, WindowListener { @@ -54,116 +55,121 @@ public abstract class GameShell extends Applet implements Runnable, MouseListene @Override public void run() { - getComponent().addMouseListener(this); - getComponent().addMouseMotionListener(this); - getComponent().addKeyListener(this); - getComponent().addFocusListener(this); + try { + getComponent().addMouseListener(this); + getComponent().addMouseMotionListener(this); + getComponent().addKeyListener(this); + getComponent().addFocusListener(this); - if (frame != null) { - frame.addWindowListener(this); - } - - showProgress(0, "Loading..."); - load(); - - int opos = 0; - int ratio = 256; - int delta = 1; - int count = 0; - int intex = 0; // interrupt exceptions - - for (int k1 = 0; k1 < 10; k1++) { - otim[k1] = System.currentTimeMillis(); - } - - while (state >= 0) { - if (state > 0) { - state--; - if (state == 0) { - shutdown(); - return; - } + if (frame != null) { + frame.addWindowListener(this); } - int lastRatio = ratio; - int lastDelta = delta; + showProgress(0, "Loading..."); + load(); - ratio = 300; - delta = 1; + int opos = 0; + int ratio = 256; + int delta = 1; + int count = 0; + int intex = 0; // interrupt exceptions - long ntime = System.currentTimeMillis(); - - if (otim[opos] == 0L) { - ratio = lastRatio; - delta = lastDelta; - } else if (ntime > otim[opos]) { - ratio = (int) ((long) (2560L * deltime) / (ntime - otim[opos])); + for (int k1 = 0; k1 < 10; k1++) { + otim[k1] = System.currentTimeMillis(); } - if (ratio < 25) { - ratio = 25; - } - - if (ratio > 256) { - ratio = 256; - delta = (int) ((long) deltime - ((ntime - otim[opos]) / 10L)); - } - - if (delta > deltime) { - delta = deltime; - } - - otim[opos] = ntime; - opos = (opos + 1) % 10; - - if (delta > 1) { - for (int k2 = 0; k2 < 10; k2++) { - if (otim[k2] != 0L) { - otim[k2] += delta; + while (state >= 0) { + if (state > 0) { + state--; + if (state == 0) { + shutdown(); + return; } } - } - if (delta < mindel) { - delta = mindel; - } + int lastRatio = ratio; + int lastDelta = delta; - try { - Thread.sleep(delta); - } catch (InterruptedException e) { - intex++; - } + ratio = 300; + delta = 1; - for (; count < 256; count += ratio) { - mousePressButton = lastMousePressButton; - mousePressX = lastMousePressX; - mousePressY = lastMousePressY; - mousePressTime = lastMousePressTime; - lastMousePressButton = 0; - update(); - anInt32 = anInt33; - } + long ntime = System.currentTimeMillis(); - count &= 0xff; + if (otim[opos] == 0L) { + ratio = lastRatio; + delta = lastDelta; + } else if (ntime > otim[opos]) { + ratio = (int) ((long) (2560L * deltime) / (ntime - otim[opos])); + } - if (deltime > 0) { - fps = (1000 * ratio) / (deltime * 256); - } + if (ratio < 25) { + ratio = 25; + } - draw(); + if (ratio > 256) { + ratio = 256; + delta = (int) ((long) deltime - ((ntime - otim[opos]) / 10L)); + } - if (debug) { - System.out.println("ntime:" + ntime); - for (int i = 0; i < 10; i++) { - int o = ((opos - i - 1) + 20) % 10; - System.out.println("otim" + o + ":" + otim[o]); + if (delta > deltime) { + delta = deltime; + } + + otim[opos] = ntime; + opos = (opos + 1) % 10; + + if (delta > 1) { + for (int k2 = 0; k2 < 10; k2++) { + if (otim[k2] != 0L) { + otim[k2] += delta; + } + } + } + + if (delta < mindel) { + delta = mindel; + } + + try { + Thread.sleep(delta); + } catch (InterruptedException e) { + intex++; + } + + for (; count < 256; count += ratio) { + mousePressButton = lastMousePressButton; + mousePressX = lastMousePressX; + mousePressY = lastMousePressY; + mousePressTime = lastMousePressTime; + lastMousePressButton = 0; + update(); + anInt32 = anInt33; + } + + count &= 0xff; + + if (deltime > 0) { + fps = (1000 * ratio) / (deltime * 256); + } + + draw(); + + if (debug) { + System.out.println("ntime:" + ntime); + for (int i = 0; i < 10; i++) { + int o = ((opos - i - 1) + 20) % 10; + System.out.println("otim" + o + ":" + otim[o]); + } + System.out.println("fps:" + fps + " ratio:" + ratio + " count:" + count); + System.out.println("del:" + delta + " deltime:" + deltime + " mindel:" + mindel); + System.out.println("intex:" + intex + " opos:" + opos); + debug = false; + intex = 0; } - System.out.println("fps:" + fps + " ratio:" + ratio + " count:" + count); - System.out.println("del:" + delta + " deltime:" + deltime + " mindel:" + mindel); - System.out.println("intex:" + intex + " opos:" + opos); - debug = false; - intex = 0; } + } catch (Exception e) { + state = -1; + e.printStackTrace(); } if (state == -1) { @@ -456,7 +462,7 @@ public abstract class GameShell extends Applet implements Runnable, MouseListene * * @see #run() */ - public abstract void load(); + public abstract void load() throws IOException; /** * @see #run() @@ -471,7 +477,7 @@ public abstract class GameShell extends Applet implements Runnable, MouseListene /** * @see #run() */ - public abstract void draw(); + public abstract void draw() throws IOException; /** * Refresh is invoked whenever the shell is expected to potentially lost its display image. @@ -501,7 +507,7 @@ public abstract class GameShell extends Applet implements Runnable, MouseListene thread.setPriority(priority); } - public void showProgress(int percent, String message) { + public void showProgress(int percent, String message) throws IOException { while (graphics == null) { graphics = getComponent().getGraphics(); try { diff --git a/src/main/java/IDKType.java b/src/main/java/IDKType.java index cb22495..479d343 100644 --- a/src/main/java/IDKType.java +++ b/src/main/java/IDKType.java @@ -2,6 +2,8 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) +import java.io.IOException; + public class IDKType { public static int anInt655; @@ -16,8 +18,8 @@ public class IDKType { public IDKType() { } - public static void unpack(FileArchive archive) { - Buffer buffer = new Buffer(archive.read("idk.dat", null)); + public static void unpack(FileArchive archive) throws IOException { + Buffer buffer = new Buffer(archive.read("idk.dat")); anInt655 = buffer.get2U(); if (instances == null) { instances = new IDKType[anInt655]; diff --git a/src/main/java/ISAACCipher.java b/src/main/java/ISAACCipher.java deleted file mode 100644 index ae5980a..0000000 --- a/src/main/java/ISAACCipher.java +++ /dev/null @@ -1,174 +0,0 @@ -// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) - -public class ISAACCipher { - - public int anInt334; - public final int[] anIntArray335; - public final int[] anIntArray336; - public int anInt337; - public int anInt338; - public int anInt339; - - public ISAACCipher(int[] ai) { - anIntArray336 = new int[256]; - anIntArray335 = new int[256]; - for (int j = 0; j < ai.length; j++) { - anIntArray335[j] = ai[j]; - } - method248(); - } - - public int method246() { - if (anInt334-- == 0) { - method247(); - anInt334 = 255; - } - return anIntArray335[anInt334]; - } - - public void method247() { - anInt338 += ++anInt339; - for (int i = 0; i < 256; i++) { - int j = anIntArray336[i]; - if ((i & 3) == 0) { - anInt337 ^= anInt337 << 13; - } else if ((i & 3) == 1) { - anInt337 ^= anInt337 >>> 6; - } else if ((i & 3) == 2) { - anInt337 ^= anInt337 << 2; - } else if ((i & 3) == 3) { - anInt337 ^= anInt337 >>> 16; - } - anInt337 += anIntArray336[(i + 128) & 0xff]; - int k; - anIntArray336[i] = k = anIntArray336[(j & 0x3fc) >> 2] + anInt337 + anInt338; - anIntArray335[i] = anInt338 = anIntArray336[((k >> 8) & 0x3fc) >> 2] + j; - } - } - - public void method248() { - int i1; - int j1; - int k1; - int l1; - int i2; - int j2; - int k2; - int l = i1 = j1 = k1 = l1 = i2 = j2 = k2 = 0x9e3779b9; - for (int i = 0; i < 4; i++) { - l ^= i1 << 11; - k1 += l; - i1 += j1; - i1 ^= j1 >>> 2; - l1 += i1; - j1 += k1; - j1 ^= k1 << 8; - i2 += j1; - k1 += l1; - k1 ^= l1 >>> 16; - j2 += k1; - l1 += i2; - l1 ^= i2 << 10; - k2 += l1; - i2 += j2; - i2 ^= j2 >>> 4; - l += i2; - j2 += k2; - j2 ^= k2 << 8; - i1 += j2; - k2 += l; - k2 ^= l >>> 9; - j1 += k2; - l += i1; - } - for (int j = 0; j < 256; j += 8) { - l += anIntArray335[j]; - i1 += anIntArray335[j + 1]; - j1 += anIntArray335[j + 2]; - k1 += anIntArray335[j + 3]; - l1 += anIntArray335[j + 4]; - i2 += anIntArray335[j + 5]; - j2 += anIntArray335[j + 6]; - k2 += anIntArray335[j + 7]; - l ^= i1 << 11; - k1 += l; - i1 += j1; - i1 ^= j1 >>> 2; - l1 += i1; - j1 += k1; - j1 ^= k1 << 8; - i2 += j1; - k1 += l1; - k1 ^= l1 >>> 16; - j2 += k1; - l1 += i2; - l1 ^= i2 << 10; - k2 += l1; - i2 += j2; - i2 ^= j2 >>> 4; - l += i2; - j2 += k2; - j2 ^= k2 << 8; - i1 += j2; - k2 += l; - k2 ^= l >>> 9; - j1 += k2; - l += i1; - anIntArray336[j] = l; - anIntArray336[j + 1] = i1; - anIntArray336[j + 2] = j1; - anIntArray336[j + 3] = k1; - anIntArray336[j + 4] = l1; - anIntArray336[j + 5] = i2; - anIntArray336[j + 6] = j2; - anIntArray336[j + 7] = k2; - } - for (int k = 0; k < 256; k += 8) { - l += anIntArray336[k]; - i1 += anIntArray336[k + 1]; - j1 += anIntArray336[k + 2]; - k1 += anIntArray336[k + 3]; - l1 += anIntArray336[k + 4]; - i2 += anIntArray336[k + 5]; - j2 += anIntArray336[k + 6]; - k2 += anIntArray336[k + 7]; - l ^= i1 << 11; - k1 += l; - i1 += j1; - i1 ^= j1 >>> 2; - l1 += i1; - j1 += k1; - j1 ^= k1 << 8; - i2 += j1; - k1 += l1; - k1 ^= l1 >>> 16; - j2 += k1; - l1 += i2; - l1 ^= i2 << 10; - k2 += l1; - i2 += j2; - i2 ^= j2 >>> 4; - l += i2; - j2 += k2; - j2 ^= k2 << 8; - i1 += j2; - k2 += l; - k2 ^= l >>> 9; - j1 += k2; - l += i1; - anIntArray336[k] = l; - anIntArray336[k + 1] = i1; - anIntArray336[k + 2] = j1; - anIntArray336[k + 3] = k1; - anIntArray336[k + 4] = l1; - anIntArray336[k + 5] = i2; - anIntArray336[k + 6] = j2; - anIntArray336[k + 7] = k2; - } - method247(); - anInt334 = 256; - } - -} diff --git a/src/main/java/Image24.java b/src/main/java/Image24.java index a434ba2..351821a 100644 --- a/src/main/java/Image24.java +++ b/src/main/java/Image24.java @@ -4,6 +4,7 @@ import java.awt.*; import java.awt.image.PixelGrabber; +import java.io.IOException; public class Image24 extends Draw2D { @@ -42,9 +43,9 @@ public class Image24 extends Draw2D { } } - public Image24(FileArchive archive, String s, int i) { - Buffer buffer = new Buffer(archive.read(s + ".dat", null)); - Buffer buffer_1 = new Buffer(archive.read("index.dat", null)); + public Image24(FileArchive archive, String s, int i) throws IOException { + Buffer buffer = new Buffer(archive.read(s + ".dat")); + Buffer buffer_1 = new Buffer(archive.read("index.dat")); buffer_1.position = buffer.get2U(); anInt1444 = buffer_1.get2U(); anInt1445 = buffer_1.get2U(); diff --git a/src/main/java/Image8.java b/src/main/java/Image8.java index 8b4e503..e3db305 100644 --- a/src/main/java/Image8.java +++ b/src/main/java/Image8.java @@ -2,6 +2,8 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) +import java.io.IOException; + public class Image8 { public final int[] palette; @@ -13,9 +15,9 @@ public class Image8 { public int anInt1456; public int anInt1457; - public Image8(FileArchive archive, String s, int i) { - Buffer buffer = new Buffer(archive.read(s + ".dat", null)); - Buffer buffer_1 = new Buffer(archive.read("index.dat", null)); + public Image8(FileArchive archive, String s, int i) throws IOException { + Buffer buffer = new Buffer(archive.read(s + ".dat")); + Buffer buffer_1 = new Buffer(archive.read("index.dat")); buffer_1.position = buffer.get2U(); anInt1456 = buffer_1.get2U(); anInt1457 = buffer_1.get2U(); diff --git a/src/main/java/LocType.java b/src/main/java/LocType.java index 1b2f43a..96ad6e7 100644 --- a/src/main/java/LocType.java +++ b/src/main/java/LocType.java @@ -2,6 +2,8 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) +import java.io.IOException; + public class LocType { public static final Model[] A_MODEL_ARRAY_741 = new Model[4]; @@ -79,9 +81,9 @@ public class LocType { aBuffer_753 = null; } - public static void unpack(FileArchive archive) { - aBuffer_753 = new Buffer(archive.read("loc.dat", null)); - Buffer buffer = new Buffer(archive.read("loc.idx", null)); + public static void unpack(FileArchive archive) throws IOException { + aBuffer_753 = new Buffer(archive.read("loc.dat")); + Buffer buffer = new Buffer(archive.read("loc.idx")); anInt756 = buffer.get2U(); anIntArray755 = new int[anInt756]; int i = 2; diff --git a/src/main/java/Model.java b/src/main/java/Model.java index 29b29c7..10d1db4 100644 --- a/src/main/java/Model.java +++ b/src/main/java/Model.java @@ -18,7 +18,7 @@ public class Model extends Entity { public static int[] tmpVertexZ = new int[2000]; public static int[] tmpFaceAlpha = new int[2000]; - public static ModelHeader[] headers; + public static Header[] headers; public static OnDemand ondemand; public static boolean[] faceClippedX = new boolean[4096]; @@ -51,6 +51,204 @@ public class Model extends Entity { public static int[] palette = Draw3D.palette; public static int[] reciprical16 = Draw3D.reciprical16; + public static class Header { + + public byte[] data; + public int vertexCount; + public int faceCount; + public int texturedFaceCount; + public int obPoint1Position; + public int obPoint2Position; + public int obPoint3Position; + public int obPoint4Position; + public int obPoint5Position; + public int obVertex1Position; + public int obVertex2Position; + public int obFace1Position; + public int obFace2Position; + public int obFace3Position; + public int obFace4Position; + public int obFace5Position; + public int obAxisPosition; + + } + + public static void unload() { + headers = null; + faceClippedX = null; + faceNearClipped = null; + vertexScreenX = null; + vertexScreenY = null; + vertexScreenZ = null; + vertexViewSpaceX = null; + vertexViewSpaceY = null; + vertexViewSpaceZ = null; + tmpDepthFaceCount = null; + tmpDepthFaces = null; + tmpPriorityFaceCount = null; + tmpPriorityFaces = null; + tmpPriority10FaceDepth = null; + tmpPriority11FaceDepth = null; + tmpPriorityDepthSum = null; + sin = null; + cos = null; + palette = null; + reciprical16 = null; + } + + public static void init(int count, OnDemand ondemand) { + headers = new Header[count]; + Model.ondemand = ondemand; + } + + public static void unpack(byte[] src, int id) { + if (src == null) { + Header header = headers[id] = new Header(); + header.vertexCount = 0; + header.faceCount = 0; + header.texturedFaceCount = 0; + return; + } + Buffer buffer = new Buffer(src); + buffer.position = src.length - 18; + Header header = headers[id] = new Header(); + header.data = src; + header.vertexCount = buffer.get2U(); + header.faceCount = buffer.get2U(); + header.texturedFaceCount = buffer.get1U(); + int k = buffer.get1U(); + int l = buffer.get1U(); + int i1 = buffer.get1U(); + int j1 = buffer.get1U(); + int k1 = buffer.get1U(); + int l1 = buffer.get2U(); + int i2 = buffer.get2U(); + //noinspection unused + int j2 = buffer.get2U(); + int k2 = buffer.get2U(); + int offset = 0; + header.obPoint1Position = offset; + offset += header.vertexCount; + header.obVertex2Position = offset; + offset += header.faceCount; + header.obFace3Position = offset; + if (l == 255) { + offset += header.faceCount; + } else { + header.obFace3Position = -l - 1; + } + header.obFace5Position = offset; + if (j1 == 1) { + offset += header.faceCount; + } else { + header.obFace5Position = -1; + } + header.obFace2Position = offset; + if (k == 1) { + offset += header.faceCount; + } else { + header.obFace2Position = -1; + } + header.obPoint5Position = offset; + if (k1 == 1) { + offset += header.vertexCount; + } else { + header.obPoint5Position = -1; + } + header.obFace4Position = offset; + if (i1 == 1) { + offset += header.faceCount; + } else { + header.obFace4Position = -1; + } + header.obVertex1Position = offset; + offset += k2; + header.obFace1Position = offset; + offset += header.faceCount * 2; + header.obAxisPosition = offset; + offset += header.texturedFaceCount * 6; + header.obPoint2Position = offset; + offset += l1; + header.obPoint3Position = offset; + offset += i2; + header.obPoint4Position = offset; + } + + public static void unload(int id) { + headers[id] = null; + } + + /** + * Tries to get the model. Sends a request to the ondemand service to load the model if it isn't loaded. + * + * @param id the model id. + * @return the model, or null if not loaded. + */ + public static Model tryGet(int id) { + if (headers == null) { + return null; + } + + Header header = headers[id]; + + if (header != null) { + return new Model(id); + } else { + ondemand.method548(id); + return null; + } + } + + /** + * Validates the provided model id. If the model is not loaded then a request is sent to the ondemand service. + * + * @param id the model id. + * @return true if the model is loaded. + */ + public static boolean validate(int id) { + if (headers == null) { + return false; + } + + Header header = headers[id]; + + if (header != null) { + return true; + } else { + ondemand.method548(id); + return false; + } + } + + /** + * Utility function. Multiplies the input HSL lightness component by the provided scalar. + * + * @param hsl the color value. + * @param scalar the scalar. [0...127] + * @param faceInfo Provided face info to determine the type of color to return. Textured triangles (type 2) only have + * a lightness component. + * @return the color. + * @see #palette + */ + public static int mulColorLightness(int hsl, int scalar, int faceInfo) { + if ((faceInfo & 2) == 2) { + if (scalar < 0) { + scalar = 0; + } else if (scalar > 127) { + scalar = 127; + } + scalar = 127 - scalar; + return scalar; + } + scalar = (scalar * (hsl & 0x7f)) >> 7; + if (scalar < 2) { + scalar = 2; + } else if (scalar > 126) { + scalar = 126; + } + return (hsl & 0xff80) + scalar; + } + public int vertexCount; public int[] vertexX; public int[] vertexY; @@ -84,7 +282,6 @@ public class Model extends Entity { public int radius; public int minDepth; public int maxDepth; - /** * minDepth = (int) Math.sqrt((radius * radius) + (super.minY * super.minY)); * maxDepth = minDepth + (int) Math.sqrt((radius * radius) + (maxY * maxY)); @@ -112,7 +309,6 @@ public class Model extends Entity { * @see #draw(int, int, int, int, int, int, int, int, int) */ public boolean pickBounds = false; - /** * A storage for the original vertex normals to give {@link Scene#method308(Model, Model, int, int, int, boolean)} * a reference. @@ -136,7 +332,7 @@ public class Model extends Entity { public Model(int id) { counter++; - ModelHeader header = headers[id]; + Header header = headers[id]; vertexCount = header.vertexCount; faceCount = header.faceCount; texturedFaceCount = header.texturedFaceCount; @@ -776,182 +972,6 @@ public class Model extends Entity { maxX = model.maxX; } - public static void unload() { - headers = null; - faceClippedX = null; - faceNearClipped = null; - vertexScreenX = null; - vertexScreenY = null; - vertexScreenZ = null; - vertexViewSpaceX = null; - vertexViewSpaceY = null; - vertexViewSpaceZ = null; - tmpDepthFaceCount = null; - tmpDepthFaces = null; - tmpPriorityFaceCount = null; - tmpPriorityFaces = null; - tmpPriority10FaceDepth = null; - tmpPriority11FaceDepth = null; - tmpPriorityDepthSum = null; - sin = null; - cos = null; - palette = null; - reciprical16 = null; - } - - public static void init(int count, OnDemand ondemand) { - headers = new ModelHeader[count]; - Model.ondemand = ondemand; - } - - public static void unpack(byte[] src, int id) { - if (src == null) { - ModelHeader header = headers[id] = new ModelHeader(); - header.vertexCount = 0; - header.faceCount = 0; - header.texturedFaceCount = 0; - return; - } - Buffer buffer = new Buffer(src); - buffer.position = src.length - 18; - ModelHeader header = headers[id] = new ModelHeader(); - header.data = src; - header.vertexCount = buffer.get2U(); - header.faceCount = buffer.get2U(); - header.texturedFaceCount = buffer.get1U(); - int k = buffer.get1U(); - int l = buffer.get1U(); - int i1 = buffer.get1U(); - int j1 = buffer.get1U(); - int k1 = buffer.get1U(); - int l1 = buffer.get2U(); - int i2 = buffer.get2U(); - //noinspection unused - int j2 = buffer.get2U(); - int k2 = buffer.get2U(); - int offset = 0; - header.obPoint1Position = offset; - offset += header.vertexCount; - header.obVertex2Position = offset; - offset += header.faceCount; - header.obFace3Position = offset; - if (l == 255) { - offset += header.faceCount; - } else { - header.obFace3Position = -l - 1; - } - header.obFace5Position = offset; - if (j1 == 1) { - offset += header.faceCount; - } else { - header.obFace5Position = -1; - } - header.obFace2Position = offset; - if (k == 1) { - offset += header.faceCount; - } else { - header.obFace2Position = -1; - } - header.obPoint5Position = offset; - if (k1 == 1) { - offset += header.vertexCount; - } else { - header.obPoint5Position = -1; - } - header.obFace4Position = offset; - if (i1 == 1) { - offset += header.faceCount; - } else { - header.obFace4Position = -1; - } - header.obVertex1Position = offset; - offset += k2; - header.obFace1Position = offset; - offset += header.faceCount * 2; - header.obAxisPosition = offset; - offset += header.texturedFaceCount * 6; - header.obPoint2Position = offset; - offset += l1; - header.obPoint3Position = offset; - offset += i2; - header.obPoint4Position = offset; - } - - public static void unload(int id) { - headers[id] = null; - } - - /** - * Tries to get the model. Sends a request to the ondemand service to load the model if it isn't loaded. - * - * @param id the model id. - * @return the model, or null if not loaded. - */ - public static Model tryGet(int id) { - if (headers == null) { - return null; - } - - ModelHeader header = headers[id]; - - if (header != null) { - return new Model(id); - } else { - ondemand.method548(id); - return null; - } - } - - /** - * Validates the provided model id. If the model is not loaded then a request is sent to the ondemand service. - * - * @param id the model id. - * @return true if the model is loaded. - */ - public static boolean validate(int id) { - if (headers == null) { - return false; - } - - ModelHeader header = headers[id]; - - if (header != null) { - return true; - } else { - ondemand.method548(id); - return false; - } - } - - /** - * Utility function. Multiplies the input HSL lightness component by the provided scalar. - * - * @param hsl the color value. - * @param scalar the scalar. [0...127] - * @param faceInfo Provided face info to determine the type of color to return. Textured triangles (type 2) only have - * a lightness component. - * @return the color. - * @see #palette - */ - public static int mulColorLightness(int hsl, int scalar, int faceInfo) { - if ((faceInfo & 2) == 2) { - if (scalar < 0) { - scalar = 0; - } else if (scalar > 127) { - scalar = 127; - } - scalar = 127 - scalar; - return scalar; - } - scalar = (scalar * (hsl & 0x7f)) >> 7; - if (scalar < 2) { - scalar = 2; - } else if (scalar > 126) { - scalar = 126; - } - return (hsl & 0xff80) + scalar; - } - /** * Sets this model to the provided model using a vertex pool. *

diff --git a/src/main/java/ModelHeader.java b/src/main/java/ModelHeader.java deleted file mode 100644 index 4772ed1..0000000 --- a/src/main/java/ModelHeader.java +++ /dev/null @@ -1,24 +0,0 @@ -public class ModelHeader { - - public byte[] data; - public int vertexCount; - public int faceCount; - public int texturedFaceCount; - public int obPoint1Position; - public int obPoint2Position; - public int obPoint3Position; - public int obPoint4Position; - public int obPoint5Position; - public int obVertex1Position; - public int obVertex2Position; - public int obFace1Position; - public int obFace2Position; - public int obFace3Position; - public int obFace4Position; - public int obFace5Position; - public int obAxisPosition; - - public ModelHeader() { - } - -} diff --git a/src/main/java/NPCType.java b/src/main/java/NPCType.java index 788d8f8..76c801e 100644 --- a/src/main/java/NPCType.java +++ b/src/main/java/NPCType.java @@ -2,6 +2,8 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) +import java.io.IOException; + public class NPCType { public static int anInt56; @@ -30,9 +32,9 @@ public class NPCType { return type; } - public static void unpack(FileArchive archive) { - aBuffer_60 = new Buffer(archive.read("npc.dat", null)); - Buffer buffer = new Buffer(archive.read("npc.idx", null)); + public static void unpack(FileArchive archive) throws IOException { + aBuffer_60 = new Buffer(archive.read("npc.dat")); + Buffer buffer = new Buffer(archive.read("npc.idx")); anInt62 = buffer.get2U(); anIntArray72 = new int[anInt62]; int i = 2; diff --git a/src/main/java/ObjType.java b/src/main/java/ObjType.java index 0744596..9386330 100644 --- a/src/main/java/ObjType.java +++ b/src/main/java/ObjType.java @@ -2,6 +2,8 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) +import java.io.IOException; + public class ObjType { public static LRUCache aCache_158 = new LRUCache(100); @@ -64,9 +66,9 @@ public class ObjType { aBuffer_183 = null; } - public static void unpack(FileArchive archive) { - aBuffer_183 = new Buffer(archive.read("obj.dat", null)); - Buffer buffer = new Buffer(archive.read("obj.idx", null)); + public static void unpack(FileArchive archive) throws IOException { + aBuffer_183 = new Buffer(archive.read("obj.dat")); + Buffer buffer = new Buffer(archive.read("obj.idx")); anInt203 = buffer.get2U(); anIntArray195 = new int[anInt203]; int i = 2; diff --git a/src/main/java/OnDemand.java b/src/main/java/OnDemand.java index d97811c..c23fdd9 100644 --- a/src/main/java/OnDemand.java +++ b/src/main/java/OnDemand.java @@ -1,7 +1,3 @@ -// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) - import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -160,11 +156,11 @@ public class OnDemand implements Runnable { } } - public void load(FileArchive versionlist, Game game) { + public void load(FileArchive versionlist, Game game) throws IOException { String[] versionFilenames = {"model_version", "anim_version", "midi_version", "map_version"}; for (int i = 0; i < 4; i++) { - byte[] data = versionlist.read(versionFilenames[i], null); + byte[] data = versionlist.read(versionFilenames[i]); int count = data.length / 2; Buffer buffer = new Buffer(data); @@ -180,7 +176,7 @@ public class OnDemand implements Runnable { String[] crcFilenames = {"model_crc", "anim_crc", "midi_crc", "map_crc"}; for (int i = 0; i < 4; i++) { - byte[] data = versionlist.read(crcFilenames[i], null); + byte[] data = versionlist.read(crcFilenames[i]); int count = data.length / 4; Buffer buffer = new Buffer(data); storeFileChecksums[i] = new int[count]; @@ -189,7 +185,7 @@ public class OnDemand implements Runnable { } } - byte[] data = versionlist.read("model_index", null); + byte[] data = versionlist.read("model_index"); int count = storeFileVersions[0].length; modelIndex = new byte[count]; @@ -202,7 +198,7 @@ public class OnDemand implements Runnable { } } - data = versionlist.read("map_index", null); + data = versionlist.read("map_index"); Buffer buffer = new Buffer(data); count = data.length / 7; @@ -218,7 +214,7 @@ public class OnDemand implements Runnable { mapPrefetched[i2] = buffer.get1U(); } - data = versionlist.read("anim_index", null); + data = versionlist.read("anim_index"); buffer = new Buffer(data); count = data.length / 2; animIndex = new int[count]; @@ -227,7 +223,7 @@ public class OnDemand implements Runnable { animIndex[j2] = buffer.get2U(); } - data = versionlist.read("midi_index", null); + data = versionlist.read("midi_index"); buffer = new Buffer(data); count = data.length; midiIndex = new int[count]; diff --git a/src/main/java/OnDemandRequest.java b/src/main/java/OnDemandRequest.java index 0c132a0..bd4c4d4 100644 --- a/src/main/java/OnDemandRequest.java +++ b/src/main/java/OnDemandRequest.java @@ -1,7 +1,3 @@ -// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) - public class OnDemandRequest extends DoublyLinkedList.Node { public int store; diff --git a/src/main/java/SeqType.java b/src/main/java/SeqType.java index 91dee08..33d1cf2 100644 --- a/src/main/java/SeqType.java +++ b/src/main/java/SeqType.java @@ -2,6 +2,8 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) +import java.io.IOException; + public class SeqType { public static int anInt350; @@ -25,8 +27,8 @@ public class SeqType { public SeqType() { } - public static void unpack(FileArchive archive) { - Buffer buffer = new Buffer(archive.read("seq.dat", null)); + public static void unpack(FileArchive archive) throws IOException { + Buffer buffer = new Buffer(archive.read("seq.dat")); anInt350 = buffer.get2U(); if (instances == null) { instances = new SeqType[anInt350]; diff --git a/src/main/java/SpotAnimType.java b/src/main/java/SpotAnimType.java index 72c5cd4..999254b 100644 --- a/src/main/java/SpotAnimType.java +++ b/src/main/java/SpotAnimType.java @@ -2,6 +2,8 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) +import java.io.IOException; + public class SpotAnimType { public static int anInt402; @@ -22,8 +24,8 @@ public class SpotAnimType { public SpotAnimType() { } - public static void unpack(FileArchive archive) { - Buffer buffer = new Buffer(archive.read("spotanim.dat", null)); + public static void unpack(FileArchive archive) throws IOException { + Buffer buffer = new Buffer(archive.read("spotanim.dat")); anInt402 = buffer.get2U(); if (instances == null) { instances = new SpotAnimType[anInt402]; diff --git a/src/main/java/VarbitType.java b/src/main/java/VarbitType.java index b5ac6b2..7a1f00e 100644 --- a/src/main/java/VarbitType.java +++ b/src/main/java/VarbitType.java @@ -2,6 +2,8 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) +import java.io.IOException; + public class VarbitType { public static int anInt645; @@ -17,8 +19,8 @@ public class VarbitType { public VarbitType() { } - public static void unpack(FileArchive archive) { - Buffer buffer = new Buffer(archive.read("varbit.dat", null)); + public static void unpack(FileArchive archive) throws IOException { + Buffer buffer = new Buffer(archive.read("varbit.dat")); anInt645 = buffer.get2U(); if (aVarbitArray646 == null) { aVarbitArray646 = new VarbitType[anInt645]; diff --git a/src/main/java/VarpType.java b/src/main/java/VarpType.java index f203e9f..72a75b4 100644 --- a/src/main/java/VarpType.java +++ b/src/main/java/VarpType.java @@ -2,6 +2,8 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) +import java.io.IOException; + public class VarpType { public static int anInt700; @@ -24,8 +26,8 @@ public class VarpType { public VarpType() { } - public static void unpack(FileArchive archive) { - Buffer buffer = new Buffer(archive.read("varp.dat", null)); + public static void unpack(FileArchive archive) throws IOException { + Buffer buffer = new Buffer(archive.read("varp.dat")); anInt702 = 0; anInt700 = buffer.get2U(); if (instances == null) {