diff --git a/.gitignore b/.gitignore index 09810f9..7e8a5c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -target/ \ No newline at end of file +target/ +out/ \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..059361f --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +317 \ No newline at end of file diff --git a/.idea/artifacts/317_jar.xml b/.idea/artifacts/317_jar.xml new file mode 100644 index 0000000..cc8b7d5 --- /dev/null +++ b/.idea/artifacts/317_jar.xml @@ -0,0 +1,11 @@ + + + $PROJECT_DIR$/out/artifacts/317_jar + + + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..363ec27 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..427cfa4 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file 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/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..4361200 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..814348e --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/317.iml b/317.iml index d04ccda..fa4dc61 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..89d2072 100644 --- a/src/main/java/BZip2.java +++ b/src/main/java/BZip2.java @@ -1,493 +1,77 @@ -// 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; +import org.apache.commons.compress.utils.IOUtils; -public class BZip2 { +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; - private static final BZip2Stream stream = new BZip2Stream(); +/** + * {@link BZip2} itself is an implementation of {@link InputStream} to feed the header magic to a {@link BZip2CompressorInputStream}. + * + * @see #decompress(byte[], int, int, byte[]) + */ +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'}; + + /** + * Decompresses the source. + * + * @param src the source data. + * @param off the source offset. + * @param len the source length. + * @param dst the destination or null to create a new one. + * @throws IOException if the stream content is malformed or an I/O error occurs. + */ + public static byte[] decompress(byte[] src, int off, int len, byte[] dst) throws IOException { + ByteArrayOutputStream tmp = null; + + if (dst == null) { + tmp = new ByteArrayOutputStream(); } + + try(BZip2CompressorInputStream in = new BZip2CompressorInputStream(new BZip2(src, off, len))) { + if (tmp != null) { + IOUtils.copy(in, tmp); + } else { + IOUtils.readFully(in, dst); + } + } + + if (tmp != null) { + return tmp.toByteArray(); + } + + return dst; } - 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; + /** + * The input. + */ + private final ByteArrayInputStream in; + /** + * The position. + */ + private int position; + + /** + * Constructs a new helper class to fool that silly compressor. + * + * @param src the source. + * @param off the source offset. + * @param len the source length. + */ + 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 8129036..76f5a99 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)
@@ -24,37 +26,11 @@ import java.nio.charset.StandardCharsets; * C — put(-v) — get returns (-v)
* S — put(128 - v) — get returns (128 - v)
*/ -public class Buffer extends DoublyLinkedListNode { +public class Buffer extends DoublyLinkedList.Node { - public static final LinkedList pool0 = new LinkedList(); - public static final LinkedList pool1 = new LinkedList(); - public static final LinkedList pool2 = new LinkedList(); private static final int[] BITMASK = {0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 0x1ffff, 0x3ffff, 0x7ffff, 0xfffff, 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff, 0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, -1}; - public static int poolSize0; - public static int poolSize1; - public static int poolSize2; public static Buffer create(int sizeType) { - synchronized (pool1) { - Buffer buffer = null; - - if ((sizeType == 0) && (poolSize0 > 0)) { - poolSize0--; - buffer = (Buffer) pool0.method251(); - } else if ((sizeType == 1) && (poolSize1 > 0)) { - poolSize1--; - buffer = (Buffer) pool1.method251(); - } else if ((sizeType == 2) && (poolSize2 > 0)) { - poolSize2--; - buffer = (Buffer) pool2.method251(); - } - - if (buffer != null) { - buffer.position = 0; - return buffer; - } - } - Buffer buffer = new Buffer(); buffer.position = 0; @@ -72,7 +48,7 @@ public class Buffer extends DoublyLinkedListNode { public byte[] data; public int position; public int bitPosition; - public ISAACCipher cipher; + public ISAACRandom random; public Buffer() { } @@ -83,7 +59,7 @@ public class Buffer extends DoublyLinkedListNode { } 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 edbb805..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]; @@ -279,13 +281,13 @@ public class Component { public static Image24 method207(int i, FileArchive archive, String s) { long l = (StringUtil.hashCode(s) << 8) + (long) i; - Image24 image = (Image24) aCache_238.method222(l); + Image24 image = (Image24) aCache_238.get(l); if (image != null) { return image; } try { image = new Image24(archive, s, i); - aCache_238.method223(image, l); + aCache_238.put(l, image); } catch (Exception _ex) { return null; } @@ -293,9 +295,9 @@ public class Component { } public static void method208(int i, int j, Model model) { - A_CACHE___264.method224(); + A_CACHE___264.clear(); if ((model != null) && (j != 4)) { - A_CACHE___264.method223(model, ((long) j << 16) + i); + A_CACHE___264.put(((long) j << 16) + i, model); } } @@ -309,7 +311,7 @@ public class Component { } public Model method206(int i, int j) { - Model model = (Model) A_CACHE___264.method222(((long) i << 16) + j); + Model model = (Model) A_CACHE___264.get(((long) i << 16) + j); if (model != null) { return model; } @@ -329,7 +331,7 @@ public class Component { model = null; } if (model != null) { - A_CACHE___264.method223(model, (i << 16) + j); + A_CACHE___264.put((i << 16) + j, model); } return model; } diff --git a/src/main/java/DoublyLinkedList.java b/src/main/java/DoublyLinkedList.java index f397a2c..6df4e96 100644 --- a/src/main/java/DoublyLinkedList.java +++ b/src/main/java/DoublyLinkedList.java @@ -1,66 +1,114 @@ -// 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 DoublyLinkedList { - public final DoublyLinkedListNode aNode_43; - public DoublyLinkedListNode aNode_44; + public static class Node { + + public Node prev; + public Node next; + + public void unlink() { + if (next != null) { + next.prev = prev; + prev.next = next; + prev = null; + next = null; + } + } + + } + + public final Node head; + public Node peeked; public DoublyLinkedList() { - aNode_43 = new DoublyLinkedListNode(); - aNode_43.aNode_1303 = aNode_43; - aNode_43.aNode_1304 = aNode_43; + head = new Node(); + head.prev = head; + head.next = head; } - public void method150(DoublyLinkedListNode node) { - if (node.aNode_1304 != null) { - node.method330(); + public void pushBack(Node node) { + if (node.next != null) { + node.unlink(); } - node.aNode_1304 = aNode_43.aNode_1304; - node.aNode_1303 = aNode_43; - node.aNode_1304.aNode_1303 = node; - node.aNode_1303.aNode_1304 = node; + node.next = head.next; + node.prev = head; + node.next.prev = node; + node.prev.next = node; } - public DoublyLinkedListNode method151() { - DoublyLinkedListNode node = aNode_43.aNode_1303; - if (node == aNode_43) { + public void pushFront(Node node) { + if (node.next != null) { + node.unlink(); + } + node.next = head; + node.prev = head.prev; + node.next.prev = node; + node.prev.next = node; + } + + public Node pollFront() { + Node node = head.prev; + if (node == head) { return null; } else { - node.method330(); + node.unlink(); return node; } } - public DoublyLinkedListNode method152() { - DoublyLinkedListNode node = aNode_43.aNode_1303; - if (node == aNode_43) { - aNode_44 = null; + public Node peekFront() { + Node node = head.prev; + if (node == head) { + peeked = null; return null; } else { - aNode_44 = node.aNode_1303; + peeked = node.prev; return node; } } - public DoublyLinkedListNode method153() { - DoublyLinkedListNode node = aNode_44; - if (node == aNode_43) { - aNode_44 = null; + public Node peekBack() { + Node node = head.next; + if (node == head) { + peeked = null; return null; } else { - aNode_44 = node.aNode_1303; + peeked = node.next; return node; } } - public int method154() { - int i = 0; - for (DoublyLinkedListNode node = aNode_43.aNode_1303; node != aNode_43; node = node.aNode_1303) { - i++; + public Node prev() { + Node node = peeked; + if (node == head) { + peeked = null; + return null; + } else { + peeked = node.prev; + return node; } - return i; + } + + public Node next() { + Node node = peeked; + if (node == head) { + peeked = null; + return null; + } + peeked = node.next; + return node; + } + + public void clear() { + if (head.prev == head) { + return; + } + do { + Node node = head.prev; + if (node == head) { + return; + } + node.unlink(); + } while (true); } } diff --git a/src/main/java/DoublyLinkedListNode.java b/src/main/java/DoublyLinkedListNode.java deleted file mode 100644 index cb03274..0000000 --- a/src/main/java/DoublyLinkedListNode.java +++ /dev/null @@ -1,22 +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 DoublyLinkedListNode extends LinkedListNode { - - public DoublyLinkedListNode aNode_1303; - public DoublyLinkedListNode aNode_1304; - - public DoublyLinkedListNode() { - } - - public void method330() { - if (aNode_1304 != null) { - aNode_1304.aNode_1303 = aNode_1303; - aNode_1303.aNode_1304 = aNode_1304; - aNode_1303 = null; - aNode_1304 = null; - } - } - -} diff --git a/src/main/java/Draw2D.java b/src/main/java/Draw2D.java index 394207e..454c93a 100644 --- a/src/main/java/Draw2D.java +++ b/src/main/java/Draw2D.java @@ -1,6 +1,6 @@ import java.util.Arrays; -public class Draw2D extends DoublyLinkedListNode { +public class Draw2D { public static int[] pixels; public static int width; diff --git a/src/main/java/Entity.java b/src/main/java/Entity.java index ec23c91..6fef21d 100644 --- a/src/main/java/Entity.java +++ b/src/main/java/Entity.java @@ -1,4 +1,4 @@ -public class Entity extends DoublyLinkedListNode { +public class Entity extends DoublyLinkedList.Node { public VertexNormal[] vertexNormal; public int minY = 1000; diff --git a/src/main/java/FileArchive.java b/src/main/java/FileArchive.java index 9e95fb6..76e1143 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(src, 6, packedSize, data); 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,16 +61,13 @@ public class FileArchive { if (fileHash[file] != hash) { continue; } - if (dst == null) { - dst = new byte[fileSizeInflated[file]]; - } + + byte[] dst = new byte[fileSizeInflated[file]]; if (!unpacked) { - BZip2.decompress(dst, fileSizeInflated[file], data, fileOffset[file], fileSizeDeflated[file]); + BZip2.decompress(data, fileOffset[file], fileSizeDeflated[file], dst); } else { - for (int i = 0; i < fileSizeInflated[file]; i++) { - dst[i] = data[fileOffset[file] + i]; - } + System.arraycopy(data, fileOffset[file], dst, 0, fileSizeInflated[file]); } return dst; } diff --git a/src/main/java/FileStore.java b/src/main/java/FileStore.java index 4be2b96..2cc67f3 100644 --- a/src/main/java/FileStore.java +++ b/src/main/java/FileStore.java @@ -30,7 +30,7 @@ public class FileStore { int size = ((buf[0] & 0xff) << 16) + ((buf[1] & 0xff) << 8) + (buf[2] & 0xff); int sector = ((buf[3] & 0xff) << 16) + ((buf[4] & 0xff) << 8) + (buf[5] & 0xff); - if ((size < 0) || (size > maxFileSize)) { + if (size > maxFileSize) { 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 9b9ed17..d3c9a2b 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,12 +57,158 @@ 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]; public int[] anIntArray826 = new int[200]; - public LinkedList[][][] aListArrayArrayArray827 = new LinkedList[4][104][104]; + public DoublyLinkedList[][][] aListArrayArrayArray827 = new DoublyLinkedList[4][104][104]; public int[] anIntArray828; public int[] anIntArray829; public volatile boolean aBoolean831 = false; @@ -88,8 +238,7 @@ public class Game extends GameShell { public int anInt860; public int anInt861; public int anInt862; - public int anInt863; - public final int[] anIntArray864 = new int[SkillConstants.anInt733]; + public int rights; public Image8 aImage_865; public Image8 aImage_866; public Image8 aImage_867; @@ -98,9 +247,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 +256,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 +266,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 +282,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 +292,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 +307,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; @@ -210,7 +331,7 @@ public class Game extends GameShell { public int anInt1009; public int anInt1010; public int anInt1011; - public LinkedList aList_1013 = new LinkedList(); + public DoublyLinkedList aList_1013 = new DoublyLinkedList(); public int anInt1014; public int anInt1015; public int anInt1016; @@ -225,7 +346,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 +357,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 LinkedList aList_1056 = new LinkedList(); - public final int[] anIntArray1057 = new int[33]; - public final Component aComponent_1059 = new Component(); + public DoublyLinkedList aList_1056 = new DoublyLinkedList(); 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 +391,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 +418,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; @@ -330,7 +438,7 @@ public class Game extends GameShell { public Image8[] aImageArray1152; public boolean aBoolean1153 = false; public int anInt1154; - public boolean aBoolean1157 = false; + public boolean ingame = false; public boolean aBoolean1158 = false; public boolean sceneInstanced = false; public boolean aBoolean1160 = false; @@ -347,7 +455,7 @@ public class Game extends GameShell { public String aString1174 = ""; public boolean errInvalidHost = false; public int anInt1178 = -1; - public LinkedList listTemporaryLocs = new LinkedList(); + public DoublyLinkedList listTemporaryLocs = new DoublyLinkedList(); public int[] anIntArray1180; public int[] anIntArray1181; public int[] anIntArray1182; @@ -368,8 +476,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 +484,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 +491,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 +498,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 +506,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 +600,7 @@ public class Game extends GameShell { } @Override - public void load() { + public void load() throws IOException { showProgress(20, "Starting up"); if (Signlink.sunjava) { @@ -588,7 +689,7 @@ public class Game extends GameShell { ondemand = new OnDemand(); ondemand.load(archiveVersionlist, this); - SeqFrame.init(ondemand.method557()); + SeqFrame.init(ondemand.getSeqFrameCount()); Model.init(ondemand.getFileCount(0), ondemand); if (!lowmem) { @@ -731,7 +832,7 @@ public class Game extends GameShell { byte0 = 3; } if (byte0 != 0) { - ondemand.method563(byte0, 0, k2); + ondemand.prefetch(byte0, 0, k2); } } ondemand.prefetchMaps(members); @@ -739,7 +840,7 @@ public class Game extends GameShell { int l = ondemand.getFileCount(2); for (int i3 = 1; i3 < l; i3++) { if (ondemand.method569(i3)) { - ondemand.method563((byte) 1, 2, i3); + ondemand.prefetch((byte) 1, 2, i3); } } } @@ -870,7 +971,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 +1040,7 @@ public class Game extends GameShell { return; } catch (Exception exception) { Signlink.reporterror("loaderror " + aString1049 + " " + anInt1079); + exception.printStackTrace(); } aBoolean926 = true; } @@ -949,7 +1051,7 @@ public class Game extends GameShell { return; } loopCycle++; - if (!aBoolean1157) { + if (!ingame) { method140(); } else { method62(); @@ -970,10 +1072,12 @@ public class Game extends GameShell { method15(); if (aMouseRecorder_879 != null) { aMouseRecorder_879.aBoolean808 = false; + aMouseRecorder_879 = null; + } + if (ondemand != null) { + ondemand.stop(); + ondemand = null; } - aMouseRecorder_879 = null; - ondemand.stop(); - ondemand = null; aBuffer_834 = null; aBuffer_1192 = null; aBuffer_847 = null; @@ -1090,13 +1194,13 @@ public class Game extends GameShell { } @Override - public void draw() { + public void draw() throws IOException { if (errAlreadyStarted || aBoolean926 || errInvalidHost) { method94(); return; } drawCycle++; - if (!aBoolean1157) { + if (!ingame) { method135(false); } else { method102(); @@ -1134,7 +1238,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 +1273,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 +1353,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); @@ -1606,8 +1604,8 @@ public class Game extends GameShell { public void method22() { try { anInt985 = -1; - aList_1056.method256(); - aList_1013.method256(); + aList_1056.clear(); + aList_1013.clear(); Draw3D.disposePool(); method23(); scene.method274(); @@ -1728,7 +1726,7 @@ public class Game extends GameShell { method63(); } catch (Exception ignored) { } - LocType.aCache_785.method224(); + LocType.aCache_785.clear(); if (super.frame != null) { aBuffer_1192.putOp(210); aBuffer_1192.put4(0x3f008edd); @@ -1776,13 +1774,13 @@ public class Game extends GameShell { } public void method23() { - LocType.aCache_785.method224(); - LocType.aCache_780.method224(); - NPCType.aCache_95.method224(); - ObjType.aCache_159.method224(); - ObjType.aCache_158.method224(); - PlayerEntity.modelCache.method224(); - SpotAnimType.modelCache.method224(); + LocType.aCache_785.clear(); + LocType.aCache_780.clear(); + NPCType.aCache_95.clear(); + ObjType.aCache_159.clear(); + ObjType.aCache_158.clear(); + PlayerEntity.modelCache.clear(); + SpotAnimType.modelCache.clear(); } public void method24(int i) { @@ -1858,14 +1856,14 @@ public class Game extends GameShell { } public void method25(int i, int j) { - LinkedList list = aListArrayArrayArray827[anInt918][i][j]; + DoublyLinkedList list = aListArrayArrayArray827[anInt918][i][j]; if (list == null) { scene.method295(anInt918, i, j); return; } int k = 0xfa0a1f01; ObjStackEntity obj = null; - for (ObjStackEntity objStack = (ObjStackEntity) list.method252(); objStack != null; objStack = (ObjStackEntity) list.method254()) { + for (ObjStackEntity objStack = (ObjStackEntity) list.peekFront(); objStack != null; objStack = (ObjStackEntity) list.prev()) { ObjType type = ObjType.method198(objStack.anInt1558); int l = type.anInt155; if (type.aBoolean176) { @@ -1876,10 +1874,10 @@ public class Game extends GameShell { obj = objStack; } } - list.method250(obj); + list.pushFront(obj); ObjStackEntity obj1 = null; Entity obj2 = null; - for (ObjStackEntity objStack_1 = (ObjStackEntity) list.method252(); objStack_1 != null; objStack_1 = (ObjStackEntity) list.method254()) { + for (ObjStackEntity objStack_1 = (ObjStackEntity) list.peekFront(); objStack_1 != null; objStack_1 = (ObjStackEntity) list.prev()) { if ((objStack_1.anInt1558 != obj.anInt1558) && (obj1 == null)) { obj1 = objStack_1; } @@ -2250,7 +2248,7 @@ public class Game extends GameShell { if (k == 4) { Draw3D.setBrightness(0.59999999999999998D); } - ObjType.aCache_158.method224(); + ObjType.aCache_158.clear(); aBoolean1255 = true; } if (j == 3) { @@ -2840,7 +2838,7 @@ public class Game extends GameShell { } catch (Exception ignored) { } connection = null; - aBoolean1157 = false; + ingame = false; anInt833 = 0; aString1173 = ""; aString1174 = ""; @@ -3195,7 +3193,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]; @@ -3335,9 +3333,9 @@ public class Game extends GameShell { } public void method55() { - for (ProjectileEntity projectile = (ProjectileEntity) aList_1013.method252(); projectile != null; projectile = (ProjectileEntity) aList_1013.method254()) { + for (ProjectileEntity projectile = (ProjectileEntity) aList_1013.peekFront(); projectile != null; projectile = (ProjectileEntity) aList_1013.prev()) { if ((projectile.anInt1597 != anInt918) || (loopCycle > projectile.anInt1572)) { - projectile.method329(); + projectile.unlink(); } else if (loopCycle >= projectile.anInt1571) { if (projectile.anInt1590 > 0) { NPCEntity npc = npcs[projectile.anInt1590 - 1]; @@ -3363,8 +3361,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); @@ -3570,7 +3568,7 @@ public class Game extends GameShell { break; } } - if (!aBoolean1157) { + if (!ingame) { return; } synchronized (aMouseRecorder_879.lock) { @@ -3839,18 +3837,18 @@ public class Game extends GameShell { } public void method63() { - SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.method252(); - for (; loc != null; loc = (SceneLocTemporary) listTemporaryLocs.method254()) { + SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.peekFront(); + for (; loc != null; loc = (SceneLocTemporary) listTemporaryLocs.prev()) { if (loc.anInt1294 == -1) { loc.anInt1302 = 0; method89(loc); } else { - loc.method329(); + loc.unlink(); } } } - public void method64() { + public void method64() throws IOException { if (aArea_1107 != null) { return; } @@ -3952,7 +3950,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 { @@ -4085,10 +4083,10 @@ public class Game extends GameShell { anInt1021 = 0; anInt1261 = 0; Connection connection = this.connection; - aBoolean1157 = false; + ingame = false; anInt1038 = 0; method84(aString1173, aString1174, true); - if (!aBoolean1157) { + if (!ingame) { method44(); } try { @@ -4999,9 +4997,9 @@ public class Game extends GameShell { method88(i1, l1, player, j1); } if (k1 == 3) { - LinkedList list = aListArrayArrayArray827[anInt918][i1][j1]; + DoublyLinkedList list = aListArrayArrayArray827[anInt918][i1][j1]; if (list != null) { - for (ObjStackEntity objStack = (ObjStackEntity) list.method253(); objStack != null; objStack = (ObjStackEntity) list.method255()) { + for (ObjStackEntity objStack = (ObjStackEntity) list.peekBack(); objStack != null; objStack = (ObjStackEntity) list.next()) { ObjType type = ObjType.method198(objStack.anInt1558); if (anInt1282 == 1) { aStringArray1199[anInt1133] = "Use " + aString1286 + " with @lre@" + type.aString170; @@ -5069,11 +5067,17 @@ public class Game extends GameShell { System.out.println("flame-cycle:" + flameCycle); if (ondemand != null) { System.out.println("Od-cycle:" + ondemand.cycle); + System.out.println("Od-remaining:" + ondemand.remaining()); + for (OnDemandRequest request : ondemand.requests) { + System.out.println(request); + } } System.out.println("loop-cycle:" + loopCycle); System.out.println("draw-cycle:" + drawCycle); System.out.println("ptype:" + ptype); System.out.println("psize:" + psize); + System.out.println("scene-state:" + sceneState); + System.out.println("draw-state:" + method54()); if (connection != null) { connection.method272(); } @@ -5191,7 +5195,7 @@ public class Game extends GameShell { aBoolean1223 = true; } if (((j == 13) || (j == 10)) && (aString887.length() > 0)) { - if (anInt863 == 2) { + if (rights == 0) { if (aString887.equals("::clientdrop")) { method68(); } @@ -5200,7 +5204,7 @@ public class Game extends GameShell { } if (aString887.equals("::prefetchmusic")) { for (int j1 = 0; j1 < ondemand.getFileCount(2); j1++) { - ondemand.method563((byte) 1, 2, j1); + ondemand.prefetch((byte) 1, 2, j1); } } if (aString887.equals("::fpson")) { @@ -5296,9 +5300,9 @@ public class Game extends GameShell { aPlayer_1126.anInt1513 = j2; aPlayer_1126.anInt1531 = i3; aPlayer_1126.anInt1535 = 150; - if (anInt863 == 2) { + if (rights == 2) { method77(2, "@cr2@" + aPlayer_1126.aString1703, aPlayer_1126.aString1506); - } else if (anInt863 == 1) { + } else if (rights == 1) { method77(2, "@cr1@" + aPlayer_1126.aString1703, aPlayer_1126.aString1506); } else { method77(2, aPlayer_1126.aString1703, aPlayer_1126.aString1506); @@ -5342,7 +5346,7 @@ public class Game extends GameShell { } if (((j1 == 1) || (j1 == 2)) && ((j1 == 1) || (anInt1287 == 0) || ((anInt1287 == 1) && method109(s)))) { if ((j > (k1 - 14)) && (j <= k1) && !s.equals(aPlayer_1126.aString1703)) { - if (anInt863 >= 1) { + if (rights >= 1) { aStringArray1199[anInt1133] = "Report abuse @whi@" + s; anIntArray1093[anInt1133] = 606; anInt1133++; @@ -5358,7 +5362,7 @@ public class Game extends GameShell { } if (((j1 == 3) || (j1 == 7)) && (anInt1195 == 0) && ((j1 == 7) || (anInt845 == 0) || ((anInt845 == 1) && method109(s)))) { if ((j > (k1 - 14)) && (j <= k1)) { - if (anInt863 >= 1) { + if (rights >= 1) { aStringArray1199[anInt1133] = "Report abuse @whi@" + s; anIntArray1093[anInt1133] = 606; anInt1133++; @@ -5568,7 +5572,7 @@ public class Game extends GameShell { return; } if (j == 613) { - if (anInt863 >= 1) { + if (rights >= 1) { if (aBoolean1158) { component.anInt232 = 0xff0000; component.aString248 = "Moderator option: Mute player for 48 hours: "; @@ -5969,17 +5973,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 +6005,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(); } @@ -6015,14 +6022,14 @@ public class Game extends GameShell { return; } if (k == 2) { - anInt863 = connection.method268(); + rights = connection.method268(); aBoolean1205 = connection.method268() == 1; aLong1220 = 0L; anInt1022 = 0; aMouseRecorder_879.anInt810 = 0; super.aBoolean17 = true; aBoolean954 = true; - aBoolean1157 = true; + ingame = true; aBuffer_1192.position = 0; in.position = 0; ptype = -1; @@ -6064,8 +6071,8 @@ public class Game extends GameShell { npcs[k2] = null; } aPlayer_1126 = players[LOCAL_PLAYER_INDEX] = new PlayerEntity(); - aList_1013.method256(); - aList_1056.method256(); + aList_1013.clear(); + aList_1056.clear(); for (int l2 = 0; l2 < 4; l2++) { for (int i3 = 0; i3 < 104; i3++) { for (int k3 = 0; k3 < 104; k3++) { @@ -6073,7 +6080,7 @@ public class Game extends GameShell { } } } - listTemporaryLocs = new LinkedList(); + listTemporaryLocs = new DoublyLinkedList(); anInt900 = 0; anInt899 = 0; anInt1042 = -1; @@ -6162,7 +6169,7 @@ public class Game extends GameShell { return; } if (k == 15) { - aBoolean1157 = true; + ingame = true; aBuffer_1192.position = 0; in.position = 0; ptype = -1; @@ -7474,14 +7481,14 @@ public class Game extends GameShell { } public void method104() { - SpotAnimEntity spotAnim = (SpotAnimEntity) aList_1056.method252(); - for (; spotAnim != null; spotAnim = (SpotAnimEntity) aList_1056.method254()) { + SpotAnimEntity spotAnim = (SpotAnimEntity) aList_1056.peekFront(); + for (; spotAnim != null; spotAnim = (SpotAnimEntity) aList_1056.prev()) { if ((spotAnim.anInt1560 != anInt918) || spotAnim.aBoolean1567) { - spotAnim.method329(); + spotAnim.unlink(); } else if (loopCycle >= spotAnim.anInt1564) { spotAnim.method454(anInt945); if (spotAnim.aBoolean1567) { - spotAnim.method329(); + spotAnim.unlink(); } else { scene.method285(spotAnim.anInt1560, 0, spotAnim.anInt1563, -1, spotAnim.anInt1562, 60, spotAnim.anInt1561, spotAnim, false); } @@ -8136,14 +8143,14 @@ public class Game extends GameShell { public void method115() { if (sceneState == 2) { - for (SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.method252(); loc != null; loc = (SceneLocTemporary) listTemporaryLocs.method254()) { + for (SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.peekFront(); loc != null; loc = (SceneLocTemporary) listTemporaryLocs.prev()) { if (loc.anInt1294 > 0) { loc.anInt1294--; } if (loc.anInt1294 == 0) { if ((loc.anInt1299 < 0) || SceneBuilder.method178(loc.anInt1299, loc.anInt1301)) { method142(loc.sceneTileZ, loc.anInt1295, loc.anInt1300, loc.anInt1301, loc.sceneTileX, loc.anInt1296, loc.anInt1299); - loc.method329(); + loc.unlink(); } } else { if (loc.anInt1302 > 0) { @@ -8153,9 +8160,9 @@ public class Game extends GameShell { method142(loc.sceneTileZ, loc.anInt1295, loc.anInt1292, loc.anInt1293, loc.sceneTileX, loc.anInt1296, loc.anInt1291); loc.anInt1302 = -1; if ((loc.anInt1291 == loc.anInt1299) && (loc.anInt1299 == -1)) { - loc.method329(); + loc.unlink(); } else if ((loc.anInt1291 == loc.anInt1299) && (loc.anInt1292 == loc.anInt1300) && (loc.anInt1293 == loc.anInt1301)) { - loc.method329(); + loc.unlink(); } } } @@ -8631,7 +8638,7 @@ public class Game extends GameShell { } for (int k5 = 0; k5 < 104; k5++) { for (int l5 = 0; l5 < 104; l5++) { - LinkedList list = aListArrayArrayArray827[anInt918][k5][l5]; + DoublyLinkedList list = aListArrayArrayArray827[anInt918][k5][l5]; if (list != null) { int l = ((k5 * 4) + 2) - (aPlayer_1126.x / 32); int j3 = ((l5 * 4) + 2) - (aPlayer_1126.z / 32); @@ -8771,7 +8778,7 @@ public class Game extends GameShell { i1 = 450; } if (super.anInt20 < (4 + i1)) { - if (anInt863 >= 1) { + if (rights >= 1) { aStringArray1199[anInt1133] = "Report abuse @whi@" + s; anIntArray1093[anInt1133] = 2606; anInt1133++; @@ -8797,7 +8804,7 @@ public class Game extends GameShell { public void method130(int j, int k, int l, int i1, int j1, int k1, int l1, int i2, int j2) { SceneLocTemporary loc = null; - for (SceneLocTemporary loc_1 = (SceneLocTemporary) listTemporaryLocs.method252(); loc_1 != null; loc_1 = (SceneLocTemporary) listTemporaryLocs.method254()) { + for (SceneLocTemporary loc_1 = (SceneLocTemporary) listTemporaryLocs.peekFront(); loc_1 != null; loc_1 = (SceneLocTemporary) listTemporaryLocs.prev()) { if ((loc_1.anInt1295 != l1) || (loc_1.sceneTileX != i2) || (loc_1.sceneTileZ != j1) || (loc_1.anInt1296 != i1)) { continue; } @@ -8811,7 +8818,7 @@ public class Game extends GameShell { loc.sceneTileX = i2; loc.sceneTileZ = j1; method89(loc); - listTemporaryLocs.method249(loc); + listTemporaryLocs.pushBack(loc); } loc.anInt1291 = k; loc.anInt1293 = k1; @@ -9002,7 +9009,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); @@ -9010,7 +9017,7 @@ public class Game extends GameShell { char c1 = '\310'; if (anInt833 == 0) { int i = (c1 / 2) + 80; - fontPlain11.drawStringTaggableCenter(ondemand.aString1333, c / 2, i, 0x75a9a9, true); + fontPlain11.drawStringTaggableCenter(ondemand.message, c / 2, i, 0x75a9a9, true); i = (c1 / 2) - 20; fontBold12.drawStringTaggableCenter("Welcome to RuneScape", c / 2, i, 0xffff00, true); int l = (c / 2) - 80; @@ -9110,9 +9117,9 @@ public class Game extends GameShell { int k11 = buffer.get2U(); int l13 = buffer.get2U(); if ((j3 >= 0) && (i6 >= 0) && (j3 < 104) && (i6 < 104)) { - LinkedList list_1 = aListArrayArrayArray827[anInt918][j3][i6]; + DoublyLinkedList list_1 = aListArrayArrayArray827[anInt918][j3][i6]; if (list_1 != null) { - for (ObjStackEntity objStack_3 = (ObjStackEntity) list_1.method252(); objStack_3 != null; objStack_3 = (ObjStackEntity) list_1.method254()) { + for (ObjStackEntity objStack_3 = (ObjStackEntity) list_1.peekFront(); objStack_3 != null; objStack_3 = (ObjStackEntity) list_1.prev()) { if ((objStack_3.anInt1558 != (l8 & 0x7fff)) || (objStack_3.anInt1559 != k11)) { continue; } @@ -9151,9 +9158,9 @@ public class Game extends GameShell { class30_sub2_sub4_sub2_2.anInt1558 = i1; class30_sub2_sub4_sub2_2.anInt1559 = j14; if (aListArrayArrayArray827[anInt918][k6][j9] == null) { - aListArrayArrayArray827[anInt918][k6][j9] = new LinkedList(); + aListArrayArrayArray827[anInt918][k6][j9] = new DoublyLinkedList(); } - aListArrayArrayArray827[anInt918][k6][j9].method249(class30_sub2_sub4_sub2_2); + aListArrayArrayArray827[anInt918][k6][j9].pushBack(class30_sub2_sub4_sub2_2); method25(k6, j9); } return; @@ -9164,16 +9171,16 @@ public class Game extends GameShell { int l6 = anInt1269 + (j1 & 7); int k9 = buffer.get2U(); if ((i4 >= 0) && (l6 >= 0) && (i4 < 104) && (l6 < 104)) { - LinkedList list = aListArrayArrayArray827[anInt918][i4][l6]; + DoublyLinkedList list = aListArrayArrayArray827[anInt918][i4][l6]; if (list != null) { - for (ObjStackEntity objStack = (ObjStackEntity) list.method252(); objStack != null; objStack = (ObjStackEntity) list.method254()) { + for (ObjStackEntity objStack = (ObjStackEntity) list.peekFront(); objStack != null; objStack = (ObjStackEntity) list.prev()) { if (objStack.anInt1558 != (k9 & 0x7fff)) { continue; } - objStack.method329(); + objStack.unlink(); break; } - if (list.method252() == null) { + if (list.peekFront() == null) { aListArrayArrayArray827[anInt918][i4][l6] = null; } method25(i4, l6); @@ -9316,7 +9323,7 @@ public class Game extends GameShell { i5 = (i5 * 128) + 64; l7 = (l7 * 128) + 64; SpotAnimEntity spotAnim = new SpotAnimEntity(anInt918, loopCycle, j15, k10, method42(anInt918, l7, i5) - l12, l7, i5); - aList_1056.method249(spotAnim); + aList_1056.pushBack(spotAnim); } return; } @@ -9331,9 +9338,9 @@ public class Game extends GameShell { objStack_1.anInt1558 = k2; objStack_1.anInt1559 = j5; if (aListArrayArrayArray827[anInt918][l10][i13] == null) { - aListArrayArrayArray827[anInt918][l10][i13] = new LinkedList(); + aListArrayArrayArray827[anInt918][l10][i13] = new DoublyLinkedList(); } - aListArrayArrayArray827[anInt918][l10][i13].method249(objStack_1); + aListArrayArrayArray827[anInt918][l10][i13].pushBack(objStack_1); method25(l10, i13); } return; @@ -9372,7 +9379,7 @@ public class Game extends GameShell { k13 = (k13 * 128) + 64; ProjectileEntity projectile = new ProjectileEntity(i21, l18, k19 + loopCycle, j20 + loopCycle, j21, anInt918, method42(anInt918, k8, l5) - i18, k8, l5, l15, i17); projectile.method455(k19 + loopCycle, k13, method42(anInt918, k13, j11) - l18, j11); - aList_1013.method249(projectile); + aList_1013.pushBack(projectile); } } } @@ -9465,7 +9472,7 @@ public class Game extends GameShell { if ((super.mousePressButton == 1) && (super.mousePressX >= (i1 - 75)) && (super.mousePressX <= (i1 + 75)) && (super.mousePressY >= (k1 - 20)) && (super.mousePressY <= (k1 + 20))) { anInt1038 = 0; method84(aString1173, aString1174, false); - if (aBoolean1157) { + if (ingame) { return; } } @@ -9676,8 +9683,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--; @@ -9758,7 +9765,7 @@ public class Game extends GameShell { } } } - for (SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.method252(); loc != null; loc = (SceneLocTemporary) listTemporaryLocs.method254()) { + for (SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.peekFront(); loc != null; loc = (SceneLocTemporary) listTemporaryLocs.prev()) { if ((loc.sceneTileX >= anInt1268) && (loc.sceneTileX < (anInt1268 + 8)) && (loc.sceneTileZ >= anInt1269) && (loc.sceneTileZ < (anInt1269 + 8)) && (loc.anInt1295 == anInt918)) { loc.anInt1294 = 0; } @@ -10109,11 +10116,11 @@ public class Game extends GameShell { } } - for (SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.method252(); loc != null; loc = (SceneLocTemporary) listTemporaryLocs.method254()) { + for (SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.peekFront(); loc != null; loc = (SceneLocTemporary) listTemporaryLocs.prev()) { loc.sceneTileX -= dtx; loc.sceneTileZ -= dtz; if ((loc.sceneTileX < 0) || (loc.sceneTileZ < 0) || (loc.sceneTileX >= 104) || (loc.sceneTileZ >= 104)) { - loc.method329(); + loc.unlink(); } } 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/Hashtable.java b/src/main/java/Hashtable.java deleted file mode 100644 index 3bf8ee8..0000000 --- a/src/main/java/Hashtable.java +++ /dev/null @@ -1,42 +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 Hashtable { - - public final int anInt39; - public final LinkedListNode[] aNodeArray40; - - public Hashtable(int j) { - anInt39 = j; - aNodeArray40 = new LinkedListNode[j]; - for (int k = 0; k < j; k++) { - LinkedListNode node = aNodeArray40[k] = new LinkedListNode(); - node.aNode_549 = node; - node.aNode_550 = node; - } - } - - public LinkedListNode method148(long l) { - LinkedListNode node = aNodeArray40[(int) (l & (long) (anInt39 - 1))]; - for (LinkedListNode node_1 = node.aNode_549; node_1 != node; node_1 = node_1.aNode_549) { - if (node_1.aLong548 == l) { - return node_1; - } - } - return null; - } - - public void method149(LinkedListNode node, long l) { - if (node.aNode_550 != null) { - node.method329(); - } - LinkedListNode node_1 = aNodeArray40[(int) (l & (long) (anInt39 - 1))]; - node.aNode_550 = node_1.aNode_550; - node.aNode_549 = node_1; - node.aNode_550.aNode_549 = node; - node.aNode_549.aNode_550 = node; - node.aLong548 = l; - } - -} 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..8de36e3 100644 --- a/src/main/java/Image24.java +++ b/src/main/java/Image24.java @@ -1,11 +1,8 @@ -// 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.awt.*; import java.awt.image.PixelGrabber; +import java.io.IOException; -public class Image24 extends Draw2D { +public class Image24 extends DoublyLinkedList.Node { public int[] anIntArray1439; public int anInt1440; @@ -42,9 +39,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..cb46508 100644 --- a/src/main/java/Image8.java +++ b/src/main/java/Image8.java @@ -1,6 +1,4 @@ -// 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.IOException; public class Image8 { @@ -13,9 +11,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/LRUCache.java b/src/main/java/LRUCache.java index 1ee0b8c..e46e1a3 100644 --- a/src/main/java/LRUCache.java +++ b/src/main/java/LRUCache.java @@ -1,61 +1,31 @@ -// 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.util.Iterator; +import java.util.LinkedHashMap; -public class LRUCache { +public class LRUCache { - public int anInt298; - public int anInt299; - public final DoublyLinkedListNode aNode_300 = new DoublyLinkedListNode(); - public final int anInt301; - public int anInt302; - public final Hashtable aHashtable_303 = new Hashtable(1024); - public final DoublyLinkedList aDoublyLinkedList_304 = new DoublyLinkedList(); + private final int capacity; + private final LinkedHashMap map; - public LRUCache(int i) { - anInt301 = i; - anInt302 = i; + public LRUCache(int capacity) { + this.capacity = capacity; + this.map = new LinkedHashMap<>(capacity); } - public DoublyLinkedListNode method222(long l) { - DoublyLinkedListNode node = (DoublyLinkedListNode) aHashtable_303.method148(l); - if (node != null) { - aDoublyLinkedList_304.method150(node); - anInt299++; - } else { - anInt298++; + public T get(long key) { + return map.get(key); + } + + public void put(long key, T value) { + if (map.containsKey(key) && map.size() == capacity) { + Iterator iter = map.keySet().iterator(); + iter.next(); + iter.remove(); } - return node; + map.put(key, value); } - public void method223(DoublyLinkedListNode node, long l) { - if (anInt302 == 0) { - DoublyLinkedListNode node_1 = aDoublyLinkedList_304.method151(); - node_1.method329(); - node_1.method330(); - if (node_1 == aNode_300) { - DoublyLinkedListNode node_2 = aDoublyLinkedList_304.method151(); - node_2.method329(); - node_2.method330(); - } - } else { - anInt302--; - } - aHashtable_303.method149(node, l); - aDoublyLinkedList_304.method150(node); - } - - public void method224() { - do { - DoublyLinkedListNode node = aDoublyLinkedList_304.method151(); - if (node != null) { - node.method329(); - node.method330(); - } else { - anInt302 = anInt301; - return; - } - } while (true); + public void clear() { + map.clear(); } } diff --git a/src/main/java/LinkedList.java b/src/main/java/LinkedList.java deleted file mode 100644 index b95f203..0000000 --- a/src/main/java/LinkedList.java +++ /dev/null @@ -1,102 +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 LinkedList { - - public final LinkedListNode aNode_346; - public LinkedListNode aNode_347; - - public LinkedList() { - aNode_346 = new LinkedListNode(); - aNode_346.aNode_549 = aNode_346; - aNode_346.aNode_550 = aNode_346; - } - - public void method249(LinkedListNode node) { - if (node.aNode_550 != null) { - node.method329(); - } - node.aNode_550 = aNode_346.aNode_550; - node.aNode_549 = aNode_346; - node.aNode_550.aNode_549 = node; - node.aNode_549.aNode_550 = node; - } - - public void method250(LinkedListNode node) { - if (node.aNode_550 != null) { - node.method329(); - } - node.aNode_550 = aNode_346; - node.aNode_549 = aNode_346.aNode_549; - node.aNode_550.aNode_549 = node; - node.aNode_549.aNode_550 = node; - } - - public LinkedListNode method251() { - LinkedListNode node = aNode_346.aNode_549; - if (node == aNode_346) { - return null; - } else { - node.method329(); - return node; - } - } - - public LinkedListNode method252() { - LinkedListNode node = aNode_346.aNode_549; - if (node == aNode_346) { - aNode_347 = null; - return null; - } else { - aNode_347 = node.aNode_549; - return node; - } - } - - public LinkedListNode method253() { - LinkedListNode node = aNode_346.aNode_550; - if (node == aNode_346) { - aNode_347 = null; - return null; - } else { - aNode_347 = node.aNode_550; - return node; - } - } - - public LinkedListNode method254() { - LinkedListNode node = aNode_347; - if (node == aNode_346) { - aNode_347 = null; - return null; - } else { - aNode_347 = node.aNode_549; - return node; - } - } - - public LinkedListNode method255() { - LinkedListNode node = aNode_347; - if (node == aNode_346) { - aNode_347 = null; - return null; - } - aNode_347 = node.aNode_550; - return node; - } - - public void method256() { - if (aNode_346.aNode_549 == aNode_346) { - return; - } - do { - LinkedListNode node = aNode_346.aNode_549; - if (node == aNode_346) { - return; - } - node.method329(); - } while (true); - } - -} diff --git a/src/main/java/LinkedListNode.java b/src/main/java/LinkedListNode.java deleted file mode 100644 index c5f9e2f..0000000 --- a/src/main/java/LinkedListNode.java +++ /dev/null @@ -1,23 +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 LinkedListNode { - - public long aLong548; - public LinkedListNode aNode_549; - public LinkedListNode aNode_550; - - public LinkedListNode() { - } - - public void method329() { - if (aNode_550 != null) { - aNode_550.aNode_549 = aNode_549; - aNode_549.aNode_550 = aNode_550; - aNode_549 = null; - aNode_550 = null; - } - } - -} diff --git a/src/main/java/LocType.java b/src/main/java/LocType.java index 25ccac5..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; @@ -226,7 +228,7 @@ public class LocType { return null; } l1 = (long) (((long) anInt754 << 6) + l) + ((long) (k + 1) << 32); - Model model_1 = (Model) aCache_780.method222(l1); + Model model_1 = (Model) aCache_780.get(l1); if (model_1 != null) { return model_1; } @@ -240,7 +242,7 @@ public class LocType { if (flag1) { l2 += 0x10000; } - model = (Model) aCache_785.method222(l2); + model = (Model) aCache_785.get(l2); if (model == null) { model = Model.tryGet(l2 & 0xffff); if (model == null) { @@ -249,7 +251,7 @@ public class LocType { if (flag1) { model.rotateY180(); } - aCache_785.method223(model, l2); + aCache_785.put(l2, model); } if (k1 > 1) { A_MODEL_ARRAY_741[i2] = model; @@ -271,7 +273,7 @@ public class LocType { return null; } l1 = (long) (((long) anInt754 << 6) + ((long) i1 << 3) + l) + ((long) (k + 1) << 32); - Model class30_sub2_sub4_sub6_2 = (Model) aCache_780.method222(l1); + Model class30_sub2_sub4_sub6_2 = (Model) aCache_780.get(l1); if (class30_sub2_sub4_sub6_2 != null) { return class30_sub2_sub4_sub6_2; } @@ -280,7 +282,7 @@ public class LocType { if (flag3) { j2 += 0x10000; } - model = (Model) aCache_785.method222(j2); + model = (Model) aCache_785.get(j2); if (model == null) { model = Model.tryGet(j2 & 0xffff); if (model == null) { @@ -289,7 +291,7 @@ public class LocType { if (flag3) { model.rotateY180(); } - aCache_785.method223(model, j2); + aCache_785.put(j2, model); } } boolean flag; @@ -321,7 +323,7 @@ public class LocType { if (anInt760 == 1) { model_3.anInt1654 = model_3.minY; } - aCache_780.method223(model_3, l1); + aCache_780.put(l1, model_3); return model_3; } 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 e790759..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; @@ -153,7 +155,7 @@ public class NPCType { return type.method164(j, k, ai); } } - Model model = (Model) aCache_95.method222(aLong78); + Model model = (Model) aCache_95.get(aLong78); if (model == null) { boolean flag = false; for (int value : anIntArray94) { @@ -180,7 +182,7 @@ public class NPCType { } model.createLabelReferences(); model.calculateNormals(64 + anInt85, 850 + anInt92, -30, -50, -30, true); - aCache_95.method223(model, aLong78); + aCache_95.put(aLong78, model); } Model model_1 = Model.EMPTY; model_1.set(model, SeqFrame.isNull(k) & SeqFrame.isNull(j)); diff --git a/src/main/java/ObjType.java b/src/main/java/ObjType.java index 53280d5..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; @@ -107,9 +109,9 @@ public class ObjType { public static Image24 method200(int i, int j, int k) { if (k == 0) { - Image24 image = (Image24) aCache_158.method222(i); + Image24 image = (Image24) aCache_158.get(i); if ((image != null) && (image.anInt1445 != j) && (image.anInt1445 != -1)) { - image.method329(); + image.unlink(); image = null; } if (image != null) { @@ -217,7 +219,7 @@ public class ObjType { class30_sub2_sub1_sub1_2.anInt1445 = j6; } if (k == 0) { - aCache_158.method223(class30_sub2_sub1_sub1_1, i); + aCache_158.put(i, class30_sub2_sub1_sub1_1); } Draw2D.bind(ai1, i2, j2); Draw2D.setBounds(j3, k2, l2, i3); @@ -420,7 +422,7 @@ public class ObjType { return method198(j).method201(1); } } - Model model = (Model) aCache_159.method222(anInt157); + Model model = (Model) aCache_159.get(anInt157); if (model != null) { return model; } @@ -438,7 +440,7 @@ public class ObjType { } model.calculateNormals(64 + anInt196, 768 + anInt184, -50, -10, -50, true); model.pickBounds = true; - aCache_159.method223(model, anInt157); + aCache_159.put(anInt157, model); return model; } diff --git a/src/main/java/OnDemand.java b/src/main/java/OnDemand.java index f1b352b..244cce9 100644 --- a/src/main/java/OnDemand.java +++ b/src/main/java/OnDemand.java @@ -1,174 +1,189 @@ -// 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; import java.io.OutputStream; import java.net.Socket; +import java.util.LinkedList; import java.util.zip.CRC32; import java.util.zip.GZIPInputStream; public class OnDemand implements Runnable { - public final LinkedList aList_1331 = new LinkedList(); + public final DoublyLinkedList pending = new DoublyLinkedList(); public final CRC32 crc32 = new CRC32(); - public final byte[] aByteArray1339 = new byte[500]; - public final byte[][] storeFilePriority = new byte[4][]; - public final LinkedList aList_1344 = new LinkedList(); - public final LinkedList aList_1358 = new LinkedList(); + public final byte[] bbuf = new byte[500]; + public final byte[][] storeFilePriorities = new byte[4][]; + public final DoublyLinkedList aList_1344 = new DoublyLinkedList(); + public final DoublyLinkedList completed = new DoublyLinkedList(); public final byte[] aByteArray1359 = new byte[65000]; - public final DoublyLinkedList aDoublyLinkedList_1361 = new DoublyLinkedList(); + public final LinkedList requests = new LinkedList<>(); public final int[][] storeFileVersions = new int[4][]; public final int[][] storeFileChecksums = new int[4][]; - public final LinkedList aList_1368 = new LinkedList(); - public final LinkedList aList_1370 = new LinkedList(); - public int anInt1330; + public final DoublyLinkedList aList_1368 = new DoublyLinkedList(); + public final DoublyLinkedList aList_1370 = new DoublyLinkedList(); + private final Object lock = new Object(); + public int totalPrefetchFiles; public int topPriority; - public String aString1333 = ""; - public int anInt1334; - public long aLong1335; + public String message = ""; + public int heartbeatCycle; + public long socketOpenTime; public int[] mapLocFile; public int cycle; public Game game; - public int anInt1346; - public int anInt1347; + public int partOffset; + public int partAvailable; public int[] midiIndex; public int anInt1349; public int[] mapLandFile; - public int anInt1351; + public int loadedPretechFiles; public boolean running = true; - public OutputStream anOutputStream1354; + public OutputStream out; public int[] mapPrefetched; public boolean aBoolean1357 = false; public int[] animIndex; - public InputStream anInputStream1362; - public Socket aSocket1363; - public int anInt1366; - public int anInt1367; - public OnDemandRequest aRequest_1369; + public InputStream in; + public Socket socket; + public int importantCount; + public int requestCount; + public OnDemandRequest current; public int[] mapIndex; public byte[] modelIndex; - public int anInt1373; + public int waitCycles; public OnDemand() { } - public boolean method549(int i, int j, byte[] abyte0) { - if ((abyte0 == null) || (abyte0.length < 2)) { + public boolean validate(int version, int crc, byte[] src) { + if ((src == null) || (src.length < 2)) { return false; } - int k = abyte0.length - 2; - int l = ((abyte0[k] & 0xff) << 8) + (abyte0[k + 1] & 0xff); + int foot = src.length - 2; + int footVersion = ((src[foot] & 0xff) << 8) + (src[foot + 1] & 0xff); crc32.reset(); - crc32.update(abyte0, 0, k); - int i1 = (int) crc32.getValue(); - if (l != i) { + crc32.update(src, 0, foot); + int srcCrc = (int) crc32.getValue(); + if (footVersion != version) { return false; } - return i1 == j; + return srcCrc == crc; } - public void method550() { + public void read() { try { - int j = anInputStream1362.available(); - if ((anInt1347 == 0) && (j >= 6)) { + int available = in.available(); + + if ((partAvailable == 0) && (available >= 6)) { aBoolean1357 = true; - for (int k = 0; k < 6; k += anInputStream1362.read(aByteArray1339, k, 6 - k)) { - } - int l = aByteArray1339[0] & 0xff; - int j1 = ((aByteArray1339[1] & 0xff) << 8) + (aByteArray1339[2] & 0xff); - int l1 = ((aByteArray1339[3] & 0xff) << 8) + (aByteArray1339[4] & 0xff); - int i2 = aByteArray1339[5] & 0xff; - aRequest_1369 = null; - for (OnDemandRequest request = (OnDemandRequest) aList_1331.method252(); request != null; request = (OnDemandRequest) aList_1331.method254()) { - if ((request.store == l) && (request.file == j1)) { - aRequest_1369 = request; + + in.read(bbuf, 0, 6); + + int store = bbuf[0] & 0xff; + int file = ((bbuf[1] & 0xff) << 8) + (bbuf[2] & 0xff); + int size = ((bbuf[3] & 0xff) << 8) + (bbuf[4] & 0xff); + int part = bbuf[5] & 0xff; + + current = null; + + for (OnDemandRequest request = (OnDemandRequest) pending.peekFront(); request != null; request = (OnDemandRequest) pending.prev()) { + if ((request.store == store) && (request.file == file)) { + current = request; } - if (aRequest_1369 != null) { - request.anInt1423 = 0; + if (current != null) { + request.cycle = 0; } } - if (aRequest_1369 != null) { - anInt1373 = 0; - if (l1 == 0) { - Signlink.reporterror("Rej: " + l + "," + j1); - aRequest_1369.data = null; - if (aRequest_1369.aBoolean1422) { - synchronized (aList_1358) { - aList_1358.method249(aRequest_1369); + + if (current != null) { + waitCycles = 0; + + if (size == 0) { + Signlink.reporterror("Rej: " + store + "," + file); + + current.data = null; + + if (current.important) { + synchronized (completed) { + completed.pushBack(current); } } else { - aRequest_1369.method329(); + current.unlink(); } - aRequest_1369 = null; + + current = null; } else { - if ((aRequest_1369.data == null) && (i2 == 0)) { - aRequest_1369.data = new byte[l1]; + if ((current.data == null) && (part == 0)) { + current.data = new byte[size]; } - if ((aRequest_1369.data == null) && (i2 != 0)) { + + if (current.data == null) { throw new IOException("missing start of file"); } } } - anInt1346 = i2 * 500; - anInt1347 = 500; - if (anInt1347 > (l1 - (i2 * 500))) { - anInt1347 = l1 - (i2 * 500); + + partOffset = part * 500; + partAvailable = 500; + + if (partAvailable > (size - (part * 500))) { + partAvailable = size - (part * 500); } } - if ((anInt1347 > 0) && (j >= anInt1347)) { + + if ((partAvailable > 0) && (available >= partAvailable)) { aBoolean1357 = true; - byte[] abyte0 = aByteArray1339; - int i1 = 0; - if (aRequest_1369 != null) { - abyte0 = aRequest_1369.data; - i1 = anInt1346; + byte[] dst = bbuf; + int offset = 0; + + if (current != null) { + dst = current.data; + offset = partOffset; } - for (int k1 = 0; k1 < anInt1347; k1 += anInputStream1362.read(abyte0, k1 + i1, anInt1347 - k1)) { - } - if (((anInt1347 + anInt1346) >= abyte0.length) && (aRequest_1369 != null)) { + + in.read(dst, offset, partAvailable); + + if (((partAvailable + partOffset) >= dst.length) && (current != null)) { if (game.filestores[0] != null) { - game.filestores[aRequest_1369.store + 1].write(abyte0, aRequest_1369.file, abyte0.length); + game.filestores[current.store + 1].write(dst, current.file, dst.length); } - if (!aRequest_1369.aBoolean1422 && (aRequest_1369.store == 3)) { - aRequest_1369.aBoolean1422 = true; - aRequest_1369.store = 93; + + if (!current.important && (current.store == 3)) { + current.important = true; + current.store = 93; } - if (aRequest_1369.aBoolean1422) { - synchronized (aList_1358) { - aList_1358.method249(aRequest_1369); + + if (current.important) { + synchronized (completed) { + completed.pushBack(current); } } else { - aRequest_1369.method329(); + current.unlink(); } } - anInt1347 = 0; + partAvailable = 0; } } catch (IOException ioexception) { try { - aSocket1363.close(); + socket.close(); } catch (Exception ignored) { } - aSocket1363 = null; - anInputStream1362 = null; - anOutputStream1354 = null; - anInt1347 = 0; + socket = null; + in = null; + out = null; + partAvailable = 0; } } - 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); storeFileVersions[i] = new int[count]; - storeFilePriority[i] = new byte[count]; + storeFilePriorities[i] = new byte[count]; for (int l = 0; l < count; l++) { storeFileVersions[i][l] = buffer.get2U(); @@ -178,7 +193,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]; @@ -187,7 +202,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]; @@ -200,7 +215,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; @@ -216,7 +231,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]; @@ -225,7 +240,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]; @@ -240,8 +255,8 @@ public class OnDemand implements Runnable { } public int remaining() { - synchronized (aDoublyLinkedList_1361) { - return aDoublyLinkedList_1361.method154(); + synchronized (lock) { + return requests.size(); } } @@ -253,8 +268,8 @@ public class OnDemand implements Runnable { int count = mapIndex.length; for (int i = 0; i < count; i++) { if (members || (mapPrefetched[i] != 0)) { - method563((byte) 2, 3, mapLocFile[i]); - method563((byte) 2, 3, mapLandFile[i]); + prefetch((byte) 2, 3, mapLocFile[i]); + prefetch((byte) 2, 3, mapLandFile[i]); } } } @@ -263,51 +278,55 @@ public class OnDemand implements Runnable { return storeFileVersions[store].length; } - public void method556(OnDemandRequest request) { + public void send(OnDemandRequest request) { try { - if (aSocket1363 == null) { - long l = System.currentTimeMillis(); - if ((l - aLong1335) < 4000L) { + if (socket == null) { + long now = System.currentTimeMillis(); + if ((now - socketOpenTime) < 4000L) { return; } - aLong1335 = l; - aSocket1363 = game.method19(43594 + Game.portOffset); - anInputStream1362 = aSocket1363.getInputStream(); - anOutputStream1354 = aSocket1363.getOutputStream(); - anOutputStream1354.write(15); + socketOpenTime = now; + socket = game.method19(43594 + Game.portOffset); + in = socket.getInputStream(); + out = socket.getOutputStream(); + out.write(15); for (int j = 0; j < 8; j++) { - anInputStream1362.read(); + in.read(); } - anInt1373 = 0; + waitCycles = 0; } - aByteArray1339[0] = (byte) request.store; - aByteArray1339[1] = (byte) (request.file >> 8); - aByteArray1339[2] = (byte) request.file; - if (request.aBoolean1422) { - aByteArray1339[3] = 2; - } else if (!game.aBoolean1157) { - aByteArray1339[3] = 1; + + bbuf[0] = (byte) request.store; + bbuf[1] = (byte) (request.file >> 8); + bbuf[2] = (byte) request.file; + + if (request.important) { + bbuf[3] = 2; + } else if (!game.ingame) { + bbuf[3] = 1; } else { - aByteArray1339[3] = 0; + bbuf[3] = 0; } - anOutputStream1354.write(aByteArray1339, 0, 4); - anInt1334 = 0; + + out.write(bbuf, 0, 4); + heartbeatCycle = 0; anInt1349 = -10000; return; } catch (IOException ignored) { } + try { - aSocket1363.close(); + socket.close(); } catch (Exception ignored) { } - aSocket1363 = null; - anInputStream1362 = null; - anOutputStream1354 = null; - anInt1347 = 0; + socket = null; + in = null; + out = null; + partAvailable = 0; anInt1349++; } - public int method557() { + public int getSeqFrameCount() { return animIndex.length; } @@ -318,20 +337,21 @@ public class OnDemand implements Runnable { if (storeFileVersions[archive][file] == 0) { return; } - synchronized (aDoublyLinkedList_1361) { - for (OnDemandRequest request = (OnDemandRequest) aDoublyLinkedList_1361.method152(); request != null; request = (OnDemandRequest) aDoublyLinkedList_1361.method153()) { - if ((request.store == archive) && (request.file == file)) { + + synchronized (lock) { + for (OnDemandRequest request : requests) { + if (request.store == archive && request.file == file) { return; } } OnDemandRequest request = new OnDemandRequest(); request.store = archive; request.file = file; - request.aBoolean1422 = true; + request.important = true; synchronized (aList_1370) { - aList_1370.method249(request); + aList_1370.pushBack(request); } - aDoublyLinkedList_1361.method150(request); + requests.addFirst(request); } } @@ -344,79 +364,99 @@ public class OnDemand implements Runnable { try { while (running) { cycle++; - int i = 20; + + int del = 20; + if ((topPriority == 0) && (game.filestores[0] != null)) { - i = 50; + del = 50; } + try { - Thread.sleep(i); + Thread.sleep(del); } catch (Exception ignored) { } + aBoolean1357 = true; + for (int j = 0; j < 100; j++) { if (!aBoolean1357) { break; } + aBoolean1357 = false; + method567(); method565(); - if ((anInt1366 == 0) && (j >= 5)) { + + if ((importantCount == 0) && (j >= 5)) { break; } + method568(); - if (anInputStream1362 != null) { - method550(); + + if (in != null) { + read(); } } - boolean flag = false; - for (OnDemandRequest request = (OnDemandRequest) aList_1331.method252(); request != null; request = (OnDemandRequest) aList_1331.method254()) { - if (request.aBoolean1422) { - flag = true; - request.anInt1423++; - if (request.anInt1423 > 50) { - request.anInt1423 = 0; - method556(request); + + boolean loading = false; + + for (OnDemandRequest request = (OnDemandRequest) pending.peekFront(); request != null; request = (OnDemandRequest) pending.prev()) { + if (request.important) { + loading = true; + request.cycle++; + + if (request.cycle > 50) { + request.cycle = 0; + send(request); } } } - if (!flag) { - for (OnDemandRequest request_1 = (OnDemandRequest) aList_1331.method252(); request_1 != null; request_1 = (OnDemandRequest) aList_1331.method254()) { - flag = true; - request_1.anInt1423++; - if (request_1.anInt1423 > 50) { - request_1.anInt1423 = 0; - method556(request_1); + + if (!loading) { + for (OnDemandRequest request = (OnDemandRequest) pending.peekFront(); request != null; request = (OnDemandRequest) pending.prev()) { + loading = true; + request.cycle++; + + if (request.cycle > 50) { + request.cycle = 0; + send(request); } } } - if (flag) { - anInt1373++; - if (anInt1373 > 750) { + + if (loading) { + waitCycles++; + + if (waitCycles > 750) { try { - aSocket1363.close(); + socket.close(); } catch (Exception ignored) { } - aSocket1363 = null; - anInputStream1362 = null; - anOutputStream1354 = null; - anInt1347 = 0; + socket = null; + in = null; + out = null; + partAvailable = 0; } } else { - anInt1373 = 0; - aString1333 = ""; + waitCycles = 0; + message = ""; } - if (game.aBoolean1157 && (aSocket1363 != null) && (anOutputStream1354 != null) && ((topPriority > 0) || (game.filestores[0] == null))) { - anInt1334++; - if (anInt1334 > 500) { - anInt1334 = 0; - aByteArray1339[0] = 0; - aByteArray1339[1] = 0; - aByteArray1339[2] = 0; - aByteArray1339[3] = 10; + + if (game.ingame && (socket != null) && (out != null) && ((topPriority > 0) || (game.filestores[0] == null))) { + heartbeatCycle++; + + if (heartbeatCycle > 500) { + heartbeatCycle = 0; + bbuf[0] = 0; + bbuf[1] = 0; + bbuf[2] = 0; + bbuf[3] = 10; + try { - anOutputStream1354.write(aByteArray1339, 0, 4); + out.write(bbuf, 0, 4); } catch (IOException _ex) { - anInt1373 = 5000; + waitCycles = 5000; } } } @@ -426,42 +466,47 @@ public class OnDemand implements Runnable { } } - public void method560(int i, int j) { + public void method560(int file, int store) { if (game.filestores[0] == null) { return; } - if (storeFileVersions[j][i] == 0) { + if (storeFileVersions[store][file] == 0) { return; } - if (storeFilePriority[j][i] == 0) { + if (storeFilePriorities[store][file] == 0) { return; } if (topPriority == 0) { return; } OnDemandRequest request = new OnDemandRequest(); - request.store = j; - request.file = i; - request.aBoolean1422 = false; + request.store = store; + request.file = file; + request.important = false; synchronized (aList_1344) { - aList_1344.method249(request); + aList_1344.pushBack(request); } } public OnDemandRequest poll() { OnDemandRequest request; - synchronized (aList_1358) { - request = (OnDemandRequest) aList_1358.method251(); + + synchronized (completed) { + request = (OnDemandRequest) completed.pollFront(); } + if (request == null) { return null; } - synchronized (aDoublyLinkedList_1361) { - request.method330(); + + synchronized (lock) { + requests.remove(request); } + if (request.data == null) { return request; } + int i = 0; try { GZIPInputStream gzipinputstream = new GZIPInputStream(new ByteArrayInputStream(request.data)); @@ -503,7 +548,7 @@ public class OnDemand implements Runnable { request(0, i); } - public void method563(byte priority, int archive, int file) { + public void prefetch(byte priority, int archive, int file) { if (game.filestores[0] == null) { return; } @@ -513,17 +558,17 @@ public class OnDemand implements Runnable { byte[] data = game.filestores[archive + 1].read(file); - if (method549(storeFileVersions[archive][file], storeFileChecksums[archive][file], data)) { + if (validate(storeFileVersions[archive][file], storeFileChecksums[archive][file], data)) { return; } - storeFilePriority[archive][file] = priority; + storeFilePriorities[archive][file] = priority; if (priority > topPriority) { topPriority = priority; } - anInt1330++; + totalPrefetchFiles++; } public boolean method564(int i) { @@ -536,114 +581,132 @@ public class OnDemand implements Runnable { } public void method565() { - anInt1366 = 0; - anInt1367 = 0; - for (OnDemandRequest request = (OnDemandRequest) aList_1331.method252(); request != null; request = (OnDemandRequest) aList_1331.method254()) { - if (request.aBoolean1422) { - anInt1366++; + importantCount = 0; + requestCount = 0; + + for (OnDemandRequest request = (OnDemandRequest) pending.peekFront(); request != null; request = (OnDemandRequest) pending.prev()) { + if (request.important) { + importantCount++; } else { - anInt1367++; + requestCount++; } } - while (anInt1366 < 10) { - OnDemandRequest request_1 = (OnDemandRequest) aList_1368.method251(); - if (request_1 == null) { + + while (importantCount < 10) { + OnDemandRequest request = (OnDemandRequest) aList_1368.pollFront(); + + if (request == null) { break; } - if (storeFilePriority[request_1.store][request_1.file] != 0) { - anInt1351++; + + if (storeFilePriorities[request.store][request.file] != 0) { + loadedPretechFiles++; } - storeFilePriority[request_1.store][request_1.file] = 0; - aList_1331.method249(request_1); - anInt1366++; - method556(request_1); + + storeFilePriorities[request.store][request.file] = 0; + pending.pushBack(request); + importantCount++; + send(request); aBoolean1357 = true; } } public void method566() { synchronized (aList_1344) { - aList_1344.method256(); + aList_1344.clear(); } } public void method567() { OnDemandRequest request; synchronized (aList_1370) { - request = (OnDemandRequest) aList_1370.method251(); + request = (OnDemandRequest) aList_1370.pollFront(); } + while (request != null) { aBoolean1357 = true; - byte[] abyte0 = null; + byte[] data = null; + if (game.filestores[0] != null) { - abyte0 = game.filestores[request.store + 1].read(request.file); + data = game.filestores[request.store + 1].read(request.file); } - if (!method549(storeFileVersions[request.store][request.file], storeFileChecksums[request.store][request.file], abyte0)) { - abyte0 = null; + + if (!validate(storeFileVersions[request.store][request.file], storeFileChecksums[request.store][request.file], data)) { + data = null; } + synchronized (aList_1370) { - if (abyte0 == null) { - aList_1368.method249(request); + if (data == null) { + aList_1368.pushBack(request); } else { - request.data = abyte0; - synchronized (aList_1358) { - aList_1358.method249(request); + request.data = data; + synchronized (completed) { + completed.pushBack(request); } } - request = (OnDemandRequest) aList_1370.method251(); + request = (OnDemandRequest) aList_1370.pollFront(); } } } public void method568() { - while ((anInt1366 == 0) && (anInt1367 < 10)) { + while ((importantCount == 0) && (requestCount < 10)) { if (topPriority == 0) { break; } - OnDemandRequest request; + + OnDemandRequest extra; + synchronized (aList_1344) { - request = (OnDemandRequest) aList_1344.method251(); + extra = (OnDemandRequest) aList_1344.pollFront(); } - while (request != null) { - if (storeFilePriority[request.store][request.file] != 0) { - storeFilePriority[request.store][request.file] = 0; - aList_1331.method249(request); - method556(request); + + while (extra != null) { + if (storeFilePriorities[extra.store][extra.file] != 0) { + storeFilePriorities[extra.store][extra.file] = 0; + pending.pushBack(extra); + send(extra); aBoolean1357 = true; - if (anInt1351 < anInt1330) { - anInt1351++; + + if (loadedPretechFiles < totalPrefetchFiles) { + loadedPretechFiles++; } - aString1333 = "Loading extra files - " + (anInt1351 * 100) / anInt1330 + "%"; - anInt1367++; - if (anInt1367 == 10) { + + message = "Loading extra files - " + (loadedPretechFiles * 100) / totalPrefetchFiles + "%"; + requestCount++; + + if (requestCount == 10) { return; } } synchronized (aList_1344) { - request = (OnDemandRequest) aList_1344.method251(); + extra = (OnDemandRequest) aList_1344.pollFront(); } } - for (int j = 0; j < 4; j++) { - byte[] abyte0 = storeFilePriority[j]; - int k = abyte0.length; - for (int l = 0; l < k; l++) { - if (abyte0[l] == topPriority) { - abyte0[l] = 0; - OnDemandRequest request_1 = new OnDemandRequest(); - request_1.store = j; - request_1.file = l; - request_1.aBoolean1422 = false; - aList_1331.method249(request_1); - method556(request_1); - aBoolean1357 = true; - if (anInt1351 < anInt1330) { - anInt1351++; - } - aString1333 = "Loading extra files - " + (anInt1351 * 100) / anInt1330 + "%"; - anInt1367++; - if (anInt1367 == 10) { - return; - } + + for (int store = 0; store < 4; store++) { + byte[] priorities = storeFilePriorities[store]; + for (int file = 0; file < priorities.length; file++) { + if (priorities[file] != topPriority) { + continue; + } + + priorities[file] = 0; + + OnDemandRequest request_1 = new OnDemandRequest(); + request_1.store = store; + request_1.file = file; + request_1.important = false; + pending.pushBack(request_1); + send(request_1); + aBoolean1357 = true; + if (loadedPretechFiles < totalPrefetchFiles) { + loadedPretechFiles++; + } + message = "Loading extra files - " + (loadedPretechFiles * 100) / totalPrefetchFiles + "%"; + requestCount++; + if (requestCount == 10) { + return; } } } diff --git a/src/main/java/OnDemandRequest.java b/src/main/java/OnDemandRequest.java index d6cd2c1..b384ed6 100644 --- a/src/main/java/OnDemandRequest.java +++ b/src/main/java/OnDemandRequest.java @@ -1,17 +1,20 @@ -// 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.util.Arrays; -public class OnDemandRequest extends DoublyLinkedListNode { +public class OnDemandRequest extends DoublyLinkedList.Node { public int store; - public byte[] data; public int file; - public boolean aBoolean1422; - public int anInt1423; + public boolean important; + public int cycle; + public byte[] data; public OnDemandRequest() { - aBoolean1422 = true; + important = true; + } + + @Override + public String toString() { + return "OnDemandRequest{" + "store=" + store + ", file=" + file + ", priority=" + important + ", cycle=" + cycle + ", data=" + Arrays.toString(data) + '}'; } } diff --git a/src/main/java/PlayerEntity.java b/src/main/java/PlayerEntity.java index e40d481..b20a506 100644 --- a/src/main/java/PlayerEntity.java +++ b/src/main/java/PlayerEntity.java @@ -218,7 +218,7 @@ public class PlayerEntity extends PathingEntity { } else if (super.anInt1517 >= 0) { k = SeqType.instances[super.anInt1517].anIntArray353[super.anInt1518]; } - Model model_1 = (Model) modelCache.method222(l); + Model model_1 = (Model) modelCache.get(l); if (model_1 == null) { boolean flag = false; for (int i2 = 0; i2 < 12; i2++) { @@ -238,7 +238,7 @@ public class PlayerEntity extends PathingEntity { } if (flag) { if (aLong1697 != -1L) { - model_1 = (Model) modelCache.method222(aLong1697); + model_1 = (Model) modelCache.get(aLong1697); } if (model_1 == null) { return null; @@ -280,7 +280,7 @@ public class PlayerEntity extends PathingEntity { } model_1.createLabelReferences(); model_1.calculateNormals(64, 850, -30, -50, -30, true); - modelCache.method223(model_1, l); + modelCache.put(l, model_1); aLong1697 = l; } if (aBoolean1699) { diff --git a/src/main/java/Scene.java b/src/main/java/Scene.java index cb922ad..71670a4 100644 --- a/src/main/java/Scene.java +++ b/src/main/java/Scene.java @@ -3,6 +3,7 @@ // Decompiler options: packimports(3) import java.util.Arrays; +import java.util.LinkedList; public class Scene { @@ -46,7 +47,7 @@ public class Scene { public static SceneOccluder[][] aOccluderArrayArray474 = new SceneOccluder[anInt472][500]; public static int anInt475; public static final SceneOccluder[] A_OCCLUDER_ARRAY_476 = new SceneOccluder[500]; - public static LinkedList aList_477 = new LinkedList(); + public static DoublyLinkedList aList_477 = new DoublyLinkedList(); public static boolean[][][][] aBooleanArrayArrayArrayArray491 = new boolean[8][32][51][51]; public static boolean[][] aBooleanArrayArray492; public static int anInt493; @@ -1038,11 +1039,11 @@ public class Scene { } public void method314(SceneTile tile, boolean flag) { - aList_477.method249(tile); + aList_477.pushBack(tile); do { SceneTile tile_1; do { - tile_1 = (SceneTile) aList_477.method251(); + tile_1 = (SceneTile) aList_477.pollFront(); if (tile_1 == null) { return; } @@ -1220,25 +1221,25 @@ public class Scene { if ((i < eyeTileX) && ((k4 & 4) != 0)) { SceneTile tile_17 = aclass30_sub3[i + 1][j]; if ((tile_17 != null) && tile_17.aBoolean1323) { - aList_477.method249(tile_17); + aList_477.pushBack(tile_17); } } if ((j < eyeTileZ) && ((k4 & 2) != 0)) { SceneTile tile_18 = aclass30_sub3[i][j + 1]; if ((tile_18 != null) && tile_18.aBoolean1323) { - aList_477.method249(tile_18); + aList_477.pushBack(tile_18); } } if ((i > eyeTileX) && ((k4 & 1) != 0)) { SceneTile tile_19 = aclass30_sub3[i - 1][j]; if ((tile_19 != null) && tile_19.aBoolean1323) { - aList_477.method249(tile_19); + aList_477.pushBack(tile_19); } } if ((j > eyeTileZ) && ((k4 & 8) != 0)) { SceneTile tile_20 = aclass30_sub3[i][j - 1]; if ((tile_20 != null) && tile_20.aBoolean1323) { - aList_477.method249(tile_20); + aList_477.pushBack(tile_20); } } } @@ -1345,9 +1346,9 @@ public class Scene { for (int l8 = loc_3.anInt525; l8 <= loc_3.anInt526; l8++) { SceneTile tile_22 = aclass30_sub3[k7][l8]; if (tile_22.anInt1325 != 0) { - aList_477.method249(tile_22); + aList_477.pushBack(tile_22); } else if (((k7 != i) || (l8 != j)) && tile_22.aBoolean1323) { - aList_477.method249(tile_22); + aList_477.pushBack(tile_22); } } } @@ -1447,31 +1448,31 @@ public class Scene { if (k < (anInt437 - 1)) { SceneTile tile_12 = aTileArrayArrayArray441[k + 1][i][j]; if ((tile_12 != null) && tile_12.aBoolean1323) { - aList_477.method249(tile_12); + aList_477.pushBack(tile_12); } } if (i < eyeTileX) { SceneTile tile_13 = aclass30_sub3[i + 1][j]; if ((tile_13 != null) && tile_13.aBoolean1323) { - aList_477.method249(tile_13); + aList_477.pushBack(tile_13); } } if (j < eyeTileZ) { SceneTile tile_14 = aclass30_sub3[i][j + 1]; if ((tile_14 != null) && tile_14.aBoolean1323) { - aList_477.method249(tile_14); + aList_477.pushBack(tile_14); } } if (i > eyeTileX) { SceneTile tile_15 = aclass30_sub3[i - 1][j]; if ((tile_15 != null) && tile_15.aBoolean1323) { - aList_477.method249(tile_15); + aList_477.pushBack(tile_15); } } if (j > eyeTileZ) { SceneTile tile_16 = aclass30_sub3[i][j - 1]; if ((tile_16 != null) && tile_16.aBoolean1323) { - aList_477.method249(tile_16); + aList_477.pushBack(tile_16); } } } while (true); diff --git a/src/main/java/SceneLocTemporary.java b/src/main/java/SceneLocTemporary.java index 169de56..bd3e70c 100644 --- a/src/main/java/SceneLocTemporary.java +++ b/src/main/java/SceneLocTemporary.java @@ -2,7 +2,7 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) -public class SceneLocTemporary extends LinkedListNode { +public class SceneLocTemporary extends DoublyLinkedList.Node { public int anInt1291; public int anInt1292; diff --git a/src/main/java/SceneTile.java b/src/main/java/SceneTile.java index 89ec6e2..97e5215 100644 --- a/src/main/java/SceneTile.java +++ b/src/main/java/SceneTile.java @@ -2,7 +2,7 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) -public class SceneTile extends LinkedListNode { +public class SceneTile extends DoublyLinkedList.Node { public int anInt1307; public final int anInt1308; 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/SoundTrack.java b/src/main/java/SoundTrack.java index 92874e9..8d8de01 100644 --- a/src/main/java/SoundTrack.java +++ b/src/main/java/SoundTrack.java @@ -2,13 +2,13 @@ public class SoundTrack { public static final SoundTrack[] tracks = new SoundTrack[5000]; public static final int[] delays = new int[5000]; - public static byte[] buffer; + public static byte[] bbuf; public static Buffer buffer; public static void method240(Buffer src) { - buffer = new byte[441000]; + bbuf = new byte[441000]; - SoundTrack.buffer = new Buffer(buffer); + SoundTrack.buffer = new Buffer(bbuf); SoundTone.init(); do { @@ -128,7 +128,7 @@ public class SoundTrack { int totalSampleCount = sampleCount + ((loopStop - loopStart) * (loopCount - 1)); for (int sample = 44; sample < (totalSampleCount + 44); sample++) { - buffer[sample] = -128; + bbuf[sample] = -128; } for (int tone = 0; tone < 10; tone++) { @@ -141,7 +141,7 @@ public class SoundTrack { int[] samples = tones[tone].generate(toneSampleCount, tones[tone].length); for (int sample = 0; sample < toneSampleCount; sample++) { - buffer[sample + start + 44] += (byte) (samples[sample] >> 8); + bbuf[sample + start + 44] += (byte) (samples[sample] >> 8); } } @@ -154,14 +154,14 @@ public class SoundTrack { // Moves the end of the sound (after the loops) to the true end of the buffer. int endOffset = (totalSampleCount += 44) - sampleCount; for (int sample = sampleCount - 1; sample >= loopStop; sample--) { - buffer[sample + endOffset] = buffer[sample]; + bbuf[sample + endOffset] = bbuf[sample]; } // Duplicates loop area. for (int loop = 1; loop < loopCount; loop++) { int offset = (loopStop - loopStart) * loop; for (int sample = loopStart; sample < loopStop; sample++) { - buffer[sample + offset] = buffer[sample]; + bbuf[sample + offset] = bbuf[sample]; } } diff --git a/src/main/java/SpotAnimType.java b/src/main/java/SpotAnimType.java index 0bc84af..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]; @@ -71,7 +73,7 @@ public class SpotAnimType { } public Model method266() { - Model model = (Model) modelCache.method222(anInt404); + Model model = (Model) modelCache.get(anInt404); if (model != null) { return model; } @@ -84,7 +86,7 @@ public class SpotAnimType { model.replaceColor(anIntArray408[i], anIntArray409[i]); } } - modelCache.method223(model, anInt404); + modelCache.put(anInt404, model); return model; } 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) { diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000..35711de --- /dev/null +++ b/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,4 @@ +Manifest-Version: 1.0 +Main-Class: Game +Class-Path: . +