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