Restored Archive validating, misc naming...

This commit is contained in:
thedaneeffect committed 2021-06-22 07:09:55 -04:00
1 parent 256220ce51
commit 3965827f25
24 files changed
+2320 -2286

No files matched your search

+16 -1
View File
@@ -1,2 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4" />
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_9">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-compress:1.20" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
</component>
</module>
+1 -1
View File
@@ -229,7 +229,7 @@ public class Buffer extends DoublyLinkedList.Node {
public int get2() {
position += 2;
int i = ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
if (i > 0x7fff) {
if (i > 32767) {
i -= 0x10000;
}
return i;
+2 -2
View File
@@ -9,10 +9,10 @@ public class ChatCompression {
// the rest are just 'accepted' values.
'm', 'w', 'c', 'y', 'f', 'g', 'p', 'b', 'v', 'k', 'x', 'j', 'q', 'z', //
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', //
' ', '!', '?', '.', ',', ':', ';', '(', ')', '-', '&', '*', '\\', '\'', '@', '#', '+', '=', '£', '$', '%', '"', '[', ']' //
' ', '!', '?', '.', ',', ':', ';', '(', ')', '-', '&', '*', '\\', '\'', '@', '#', '+', '=', '\u00A3', '$', '%', '"', '[', ']' //
};
private static final int RANGE = ' ' + '£'; // least significant char + most significant char (in terms of value)
private static final int RANGE = ' ' + '\u00A3'; // least significant char + most significant char (in terms of value)
public static String unpack(int expectedLength, Buffer buffer) {
int length = 0;
+356 -353
View File
@@ -8,367 +8,370 @@ import java.io.IOException;
public class Component {
public static final LRUMap<Long, Model> modelCache = new LRUMap<>(30);
public static LRUMap<Long, Image24> imageCache;
public static Component[] instances;
public static final LRUMap<Long, Model> modelCache = new LRUMap<>(30);
public static LRUMap<Long, Image24> imageCache;
public static Component[] instances;
public static void unpack(FileArchive archive, BitmapFont[] aclass30_sub2_sub1_sub4, FileArchive archive_1) throws IOException {
imageCache = new LRUMap<>(500);
Buffer buffer = new Buffer(archive.read("data"));
int parentId = -1;
int j = buffer.get2U();
instances = new Component[j];
while (buffer.position < buffer.data.length) {
int id = buffer.get2U();
if (id == 65535) {
parentId = buffer.get2U();
id = buffer.get2U();
}
Component component = instances[id] = new Component();
component.id = id;
component.parentId = parentId;
component.type = buffer.get1U();
component.optionType = buffer.get1U();
component.contentType = buffer.get2U();
component.width = buffer.get2U();
component.height = buffer.get2U();
component.aByte254 = (byte) buffer.get1U();
component.anInt230 = buffer.get1U();
if (component.anInt230 != 0) {
component.anInt230 = ((component.anInt230 - 1) << 8) + buffer.get1U();
} else {
component.anInt230 = -1;
}
int i1 = buffer.get1U();
if (i1 > 0) {
component.anIntArray245 = new int[i1];
component.anIntArray212 = new int[i1];
for (int j1 = 0; j1 < i1; j1++) {
component.anIntArray245[j1] = buffer.get1U();
component.anIntArray212[j1] = buffer.get2U();
}
}
int k1 = buffer.get1U();
if (k1 > 0) {
component.anIntArrayArray226 = new int[k1][];
for (int l1 = 0; l1 < k1; l1++) {
int i3 = buffer.get2U();
component.anIntArrayArray226[l1] = new int[i3];
for (int l4 = 0; l4 < i3; l4++) {
component.anIntArrayArray226[l1][l4] = buffer.get2U();
}
}
}
if (component.type == 0) {
component.innerHeight = buffer.get2U();
component.aBoolean266 = buffer.get1U() == 1;
int i2 = buffer.get2U();
component.children = new int[i2];
component.childX = new int[i2];
component.childY = new int[i2];
for (int j3 = 0; j3 < i2; j3++) {
component.children[j3] = buffer.get2U();
component.childX[j3] = buffer.get2();
component.childY[j3] = buffer.get2();
}
}
if (component.type == 1) {
component.unusedInt = buffer.get2U();
component.unusedBool = buffer.get1U() == 1;
}
if (component.type == 2) {
component.slotObjId = new int[component.width * component.height];
component.slotAmount = new int[component.width * component.height];
component.aBoolean259 = buffer.get1U() == 1;
component.aBoolean249 = buffer.get1U() == 1;
component.aBoolean242 = buffer.get1U() == 1;
component.objMoveReplaces = buffer.get1U() == 1;
component.slotMarginX = buffer.get1U();
component.slotMarginY = buffer.get1U();
component.slotX = new int[20];
component.slotY = new int[20];
component.aImageArray209 = new Image24[20];
for (int j2 = 0; j2 < 20; j2++) {
int k3 = buffer.get1U();
if (k3 == 1) {
component.slotX[j2] = buffer.get2();
component.slotY[j2] = buffer.get2();
String s1 = buffer.getString();
if ((archive_1 != null) && (s1.length() > 0)) {
int i5 = s1.lastIndexOf(",");
component.aImageArray209[j2] = method207(Integer.parseInt(s1.substring(i5 + 1)), archive_1, s1.substring(0, i5));
}
}
}
component.aStringArray225 = new String[5];
for (int l3 = 0; l3 < 5; l3++) {
component.aStringArray225[l3] = buffer.getString();
if (component.aStringArray225[l3].length() == 0) {
component.aStringArray225[l3] = null;
}
}
}
if (component.type == 3) {
component.aBoolean227 = buffer.get1U() == 1;
}
if ((component.type == 4) || (component.type == 1)) {
component.aBoolean223 = buffer.get1U() == 1;
int k2 = buffer.get1U();
if (aclass30_sub2_sub1_sub4 != null) {
component.aFont_243 = aclass30_sub2_sub1_sub4[k2];
}
component.aBoolean268 = buffer.get1U() == 1;
}
if (component.type == 4) {
component.aString248 = buffer.getString();
component.aString228 = buffer.getString();
}
if ((component.type == 1) || (component.type == 3) || (component.type == 4)) {
component.anInt232 = buffer.get4();
}
if ((component.type == 3) || (component.type == 4)) {
component.anInt219 = buffer.get4();
component.anInt216 = buffer.get4();
component.anInt239 = buffer.get4();
}
if (component.type == 5) {
String s = buffer.getString();
if ((archive_1 != null) && (s.length() > 0)) {
int i4 = s.lastIndexOf(",");
component.aImage_207 = method207(Integer.parseInt(s.substring(i4 + 1)), archive_1, s.substring(0, i4));
}
s = buffer.getString();
if ((archive_1 != null) && (s.length() > 0)) {
int j4 = s.lastIndexOf(",");
component.aImage_260 = method207(Integer.parseInt(s.substring(j4 + 1)), archive_1, s.substring(0, j4));
}
}
if (component.type == 6) {
int l = buffer.get1U();
if (l != 0) {
component.anInt233 = 1;
component.anInt234 = ((l - 1) << 8) + buffer.get1U();
}
l = buffer.get1U();
if (l != 0) {
component.anInt255 = 1;
component.anInt256 = ((l - 1) << 8) + buffer.get1U();
}
l = buffer.get1U();
if (l != 0) {
component.seqId = ((l - 1) << 8) + buffer.get1U();
} else {
component.seqId = -1;
}
l = buffer.get1U();
if (l != 0) {
component.scriptSeqId = ((l - 1) << 8) + buffer.get1U();
} else {
component.scriptSeqId = -1;
}
component.anInt269 = buffer.get2U();
component.anInt270 = buffer.get2U();
component.anInt271 = buffer.get2U();
}
if (component.type == 7) {
component.slotObjId = new int[component.width * component.height];
component.slotAmount = new int[component.width * component.height];
component.aBoolean223 = buffer.get1U() == 1;
int l2 = buffer.get1U();
if (aclass30_sub2_sub1_sub4 != null) {
component.aFont_243 = aclass30_sub2_sub1_sub4[l2];
}
component.aBoolean268 = buffer.get1U() == 1;
component.anInt232 = buffer.get4();
component.slotMarginX = buffer.get2();
component.slotMarginY = buffer.get2();
component.aBoolean249 = buffer.get1U() == 1;
component.aStringArray225 = new String[5];
for (int k4 = 0; k4 < 5; k4++) {
component.aStringArray225[k4] = buffer.getString();
if (component.aStringArray225[k4].length() == 0) {
component.aStringArray225[k4] = null;
}
}
}
if ((component.optionType == 2) || (component.type == 2)) {
component.aString222 = buffer.getString();
component.aString218 = buffer.getString();
component.anInt237 = buffer.get2U();
}
if ((component.optionType == 1) || (component.optionType == 4) || (component.optionType == 5) || (component.optionType == 6)) {
component.aString221 = buffer.getString();
if (component.aString221.length() == 0) {
if (component.optionType == 1) {
component.aString221 = "Ok";
}
if (component.optionType == 4) {
component.aString221 = "Select";
}
if (component.optionType == 5) {
component.aString221 = "Select";
}
if (component.optionType == 6) {
component.aString221 = "Continue";
}
}
}
}
imageCache = null;
}
public static void unpack(FileArchive archive, BitmapFont[] aclass30_sub2_sub1_sub4, FileArchive archive_1) throws IOException {
imageCache = new LRUMap<>(500);
Buffer buffer = new Buffer(archive.read("data"));
int parentId = -1;
int j = buffer.get2U();
instances = new Component[j];
while (buffer.position < buffer.data.length) {
int id = buffer.get2U();
if (id == 65535) {
parentId = buffer.get2U();
id = buffer.get2U();
}
Component component = instances[id] = new Component();
component.id = id;
component.parentId = parentId;
component.type = buffer.get1U();
component.optionType = buffer.get1U();
component.contentType = buffer.get2U();
component.width = buffer.get2U();
component.height = buffer.get2U();
component.aByte254 = (byte) buffer.get1U();
component.anInt230 = buffer.get1U();
if (component.anInt230 != 0) {
component.anInt230 = ((component.anInt230 - 1) << 8) + buffer.get1U();
} else {
component.anInt230 = -1;
}
int i1 = buffer.get1U();
if (i1 > 0) {
component.anIntArray245 = new int[i1];
component.anIntArray212 = new int[i1];
for (int j1 = 0; j1 < i1; j1++) {
component.anIntArray245[j1] = buffer.get1U();
component.anIntArray212[j1] = buffer.get2U();
}
}
int k1 = buffer.get1U();
if (k1 > 0) {
component.anIntArrayArray226 = new int[k1][];
for (int l1 = 0; l1 < k1; l1++) {
int i3 = buffer.get2U();
component.anIntArrayArray226[l1] = new int[i3];
for (int l4 = 0; l4 < i3; l4++) {
component.anIntArrayArray226[l1][l4] = buffer.get2U();
}
}
}
if (component.type == 0) {
component.innerHeight = buffer.get2U();
component.aBoolean266 = buffer.get1U() == 1;
int i2 = buffer.get2U();
component.children = new int[i2];
component.childX = new int[i2];
component.childY = new int[i2];
for (int j3 = 0; j3 < i2; j3++) {
component.children[j3] = buffer.get2U();
component.childX[j3] = buffer.get2();
component.childY[j3] = buffer.get2();
}
}
if (component.type == 1) {
component.unusedInt = buffer.get2U();
component.unusedBool = buffer.get1U() == 1;
}
if (component.type == 2) {
component.slotObjId = new int[component.width * component.height];
component.slotAmount = new int[component.width * component.height];
component.aBoolean259 = buffer.get1U() == 1;
component.aBoolean249 = buffer.get1U() == 1;
component.aBoolean242 = buffer.get1U() == 1;
component.objMoveReplaces = buffer.get1U() == 1;
component.slotMarginX = buffer.get1U();
component.slotMarginY = buffer.get1U();
component.slotX = new int[20];
component.slotY = new int[20];
component.aImageArray209 = new Image24[20];
for (int j2 = 0; j2 < 20; j2++) {
int k3 = buffer.get1U();
if (k3 == 1) {
component.slotX[j2] = buffer.get2();
component.slotY[j2] = buffer.get2();
String s1 = buffer.getString();
if ((archive_1 != null) && (s1.length() > 0)) {
int i5 = s1.lastIndexOf(",");
component.aImageArray209[j2] = method207(Integer.parseInt(s1.substring(i5 + 1)), archive_1, s1.substring(0, i5));
}
}
}
component.aStringArray225 = new String[5];
for (int l3 = 0; l3 < 5; l3++) {
component.aStringArray225[l3] = buffer.getString();
if (component.aStringArray225[l3].length() == 0) {
component.aStringArray225[l3] = null;
}
}
}
if (component.type == 3) {
component.aBoolean227 = buffer.get1U() == 1;
}
if ((component.type == 4) || (component.type == 1)) {
component.aBoolean223 = buffer.get1U() == 1;
int k2 = buffer.get1U();
if (aclass30_sub2_sub1_sub4 != null) {
component.aFont_243 = aclass30_sub2_sub1_sub4[k2];
}
component.aBoolean268 = buffer.get1U() == 1;
}
if (component.type == 4) {
component.aString248 = buffer.getString();
component.aString228 = buffer.getString();
}
if ((component.type == 1) || (component.type == 3) || (component.type == 4)) {
component.anInt232 = buffer.get4();
}
if ((component.type == 3) || (component.type == 4)) {
component.anInt219 = buffer.get4();
component.anInt216 = buffer.get4();
component.anInt239 = buffer.get4();
}
if (component.type == 5) {
String s = buffer.getString();
if ((archive_1 != null) && (s.length() > 0)) {
int i4 = s.lastIndexOf(",");
component.aImage_207 = method207(Integer.parseInt(s.substring(i4 + 1)), archive_1, s.substring(0, i4));
}
s = buffer.getString();
if ((archive_1 != null) && (s.length() > 0)) {
int j4 = s.lastIndexOf(",");
component.aImage_260 = method207(Integer.parseInt(s.substring(j4 + 1)), archive_1, s.substring(0, j4));
}
}
if (component.type == 6) {
int l = buffer.get1U();
if (l != 0) {
component.anInt233 = 1;
component.anInt234 = ((l - 1) << 8) + buffer.get1U();
}
l = buffer.get1U();
if (l != 0) {
component.anInt255 = 1;
component.anInt256 = ((l - 1) << 8) + buffer.get1U();
}
l = buffer.get1U();
if (l != 0) {
component.seqId = ((l - 1) << 8) + buffer.get1U();
} else {
component.seqId = -1;
}
l = buffer.get1U();
if (l != 0) {
component.scriptSeqId = ((l - 1) << 8) + buffer.get1U();
} else {
component.scriptSeqId = -1;
}
component.anInt269 = buffer.get2U();
component.anInt270 = buffer.get2U();
component.anInt271 = buffer.get2U();
}
if (component.type == 7) {
component.slotObjId = new int[component.width * component.height];
component.slotAmount = new int[component.width * component.height];
component.aBoolean223 = buffer.get1U() == 1;
int l2 = buffer.get1U();
if (aclass30_sub2_sub1_sub4 != null) {
component.aFont_243 = aclass30_sub2_sub1_sub4[l2];
}
component.aBoolean268 = buffer.get1U() == 1;
component.anInt232 = buffer.get4();
component.slotMarginX = buffer.get2();
component.slotMarginY = buffer.get2();
component.aBoolean249 = buffer.get1U() == 1;
component.aStringArray225 = new String[5];
for (int k4 = 0; k4 < 5; k4++) {
component.aStringArray225[k4] = buffer.getString();
if (component.aStringArray225[k4].length() == 0) {
component.aStringArray225[k4] = null;
}
}
}
if (component.type == 8) {
component.aString222 = buffer.getString();
}
if ((component.optionType == 2) || (component.type == 2)) {
component.aString222 = buffer.getString();
component.aString218 = buffer.getString();
component.anInt237 = buffer.get2U();
}
if ((component.optionType == 1) || (component.optionType == 4) || (component.optionType == 5) || (component.optionType == 6)) {
component.aString221 = buffer.getString();
if (component.aString221.length() == 0) {
if (component.optionType == 1) {
component.aString221 = "Ok";
}
if (component.optionType == 4) {
component.aString221 = "Select";
}
if (component.optionType == 5) {
component.aString221 = "Select";
}
if (component.optionType == 6) {
component.aString221 = "Continue";
}
}
}
}
imageCache = null;
}
public static Image24 method207(int i, FileArchive archive, String s) {
long l = (StringUtil.hashCode(s) << 8) + (long) i;
Image24 image = imageCache.get(l);
if (image != null) {
return image;
}
try {
image = new Image24(archive, s, i);
imageCache.put(l, image);
} catch (Exception _ex) {
return null;
}
return image;
}
public static Image24 method207(int i, FileArchive archive, String s) {
long l = (StringUtil.hashCode(s) << 8) + (long) i;
Image24 image = imageCache.get(l);
if (image != null) {
return image;
}
try {
image = new Image24(archive, s, i);
imageCache.put(l, image);
} catch (Exception _ex) {
return null;
}
return image;
}
public static void method208(int i, int j, Model model) {
modelCache.clear();
if ((model != null) && (j != 4)) {
modelCache.put(((long) j << 16) + i, model);
}
}
public static void method208(int i, int j, Model model) {
modelCache.clear();
if ((model != null) && (j != 4)) {
modelCache.put(((long) j << 16) + i, model);
}
}
public Image24 aImage_207;
public int seqCycle;
public Image24[] aImageArray209;
public int unusedInt;
public int[] anIntArray212;
public int contentType;
public int[] slotX;
public int anInt216;
public int optionType;
public String aString218;
public int anInt219;
public int width;
public String aString221;
public String aString222;
public boolean aBoolean223;
public int scrollY;
public String[] aStringArray225;
public int[][] anIntArrayArray226;
public boolean aBoolean227;
public String aString228;
public int anInt230;
public int slotMarginX;
public int anInt232;
public int anInt233;
public int anInt234;
/**
* When <code>true</code> moving an <code>Obj</code> from one slot to another will simply erase the item from the
* destination slot.
*/
public boolean objMoveReplaces;
public int parentId;
public int anInt237;
public int anInt239;
public int[] children;
public int[] childX;
public boolean aBoolean242;
public BitmapFont aFont_243;
public int slotMarginY;
public int[] anIntArray245;
public int seqFrame;
public int[] slotY;
public String aString248;
public boolean aBoolean249;
public int id;
public boolean unusedBool;
public int[] slotAmount;
public int[] slotObjId;
public byte aByte254;
public int anInt255;
public int anInt256;
public int seqId;
public int scriptSeqId;
public boolean aBoolean259;
public Image24 aImage_260;
public int innerHeight;
public int type;
public int x;
public int y;
public boolean aBoolean266;
public int height;
public boolean aBoolean268;
public int anInt269;
public int anInt270;
public int anInt271;
public int[] childY;
public Image24 aImage_207;
public int seqCycle;
public Image24[] aImageArray209;
public int unusedInt;
public int[] anIntArray212;
public int contentType;
public int[] slotX;
public int anInt216;
public int optionType;
public String aString218;
public int anInt219;
public int width;
public String aString221;
public String aString222;
public boolean aBoolean223;
public int scrollY;
public String[] aStringArray225;
public int[][] anIntArrayArray226;
public boolean aBoolean227;
public String aString228;
public int anInt230;
public int slotMarginX;
public int anInt232;
public int anInt233;
public int anInt234;
/**
* When <code>true</code> moving an <code>Obj</code> from one slot to another will simply erase the item from the
* destination slot.
*/
public boolean objMoveReplaces;
public int parentId;
public int anInt237;
public int anInt239;
public int[] children;
public int[] childX;
public boolean aBoolean242;
public BitmapFont aFont_243;
public int slotMarginY;
public int[] anIntArray245;
public int seqFrame;
public int[] slotY;
public String aString248;
public boolean aBoolean249;
public int id;
public boolean unusedBool;
public int[] slotAmount;
public int[] slotObjId;
public byte aByte254;
public int anInt255;
public int anInt256;
public int seqId;
public int scriptSeqId;
public boolean aBoolean259;
public Image24 aImage_260;
public int innerHeight;
public int type;
public int x;
public int y;
public boolean aBoolean266;
public int height;
public boolean aBoolean268;
public int anInt269;
public int anInt270;
public int anInt271;
public int[] childY;
public Component() {
}
public Component() {
}
public void swapSlots(int src, int dst) {
int tmp = slotObjId[src];
slotObjId[src] = slotObjId[dst];
slotObjId[dst] = tmp;
public void swapSlots(int src, int dst) {
int tmp = slotObjId[src];
slotObjId[src] = slotObjId[dst];
slotObjId[dst] = tmp;
tmp = slotAmount[src];
slotAmount[src] = slotAmount[dst];
slotAmount[dst] = tmp;
}
tmp = slotAmount[src];
slotAmount[src] = slotAmount[dst];
slotAmount[dst] = tmp;
}
public Model method206(int i, int j) {
Model model = modelCache.get(((long) i << 16) + j);
if (model != null) {
return model;
}
if (i == 1) {
model = Model.tryGet(j);
}
if (i == 2) {
model = NPCType.get(j).method160();
}
if (i == 3) {
model = Game.self.method453();
}
if (i == 4) {
model = ObjType.get(j).method202(50);
}
if (i == 5) {
model = null;
}
if (model != null) {
modelCache.put((long) ((i << 16) + j), model);
}
return model;
}
public Model method206(int i, int j) {
Model model = modelCache.get(((long) i << 16) + j);
if (model != null) {
return model;
}
if (i == 1) {
model = Model.tryGet(j);
}
if (i == 2) {
model = NPCType.get(j).method160();
}
if (i == 3) {
model = Game.self.method453();
}
if (i == 4) {
model = ObjType.get(j).getModelUnlit(50);
}
if (i == 5) {
model = null;
}
if (model != null) {
modelCache.put((long) ((i << 16) + j), model);
}
return model;
}
public Model method209(int j, int k, boolean flag) {
Model model;
if (flag) {
model = method206(anInt255, anInt256);
} else {
model = method206(anInt233, anInt234);
}
if (model == null) {
return null;
}
if ((k == -1) && (j == -1) && (model.faceColor == null)) {
return model;
}
Model model_1 = new Model(true, SeqFrame.isNull(k) & SeqFrame.isNull(j), false, model);
if ((k != -1) || (j != -1)) {
model_1.createLabelReferences();
}
if (k != -1) {
model_1.applySequenceFrame(k);
}
if (j != -1) {
model_1.applySequenceFrame(j);
}
model_1.calculateNormals(64, 768, -50, -10, -50, true);
return model_1;
}
public Model method209(int j, int k, boolean flag) {
Model model;
if (flag) {
model = method206(anInt255, anInt256);
} else {
model = method206(anInt233, anInt234);
}
if (model == null) {
return null;
}
if ((k == -1) && (j == -1) && (model.faceColor == null)) {
return model;
}
Model model_1 = new Model(true, SeqFrame.isNull(k) & SeqFrame.isNull(j), false, model);
if ((k != -1) || (j != -1)) {
model_1.createLabelReferences();
}
if (k != -1) {
model_1.applySequenceFrame(k);
}
if (j != -1) {
model_1.applySequenceFrame(j);
}
model_1.calculateNormals(64, 768, -50, -10, -50, true);
return model_1;
}
}
+14
View File
@@ -1,4 +1,8 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
/**
* A simple file archive format.
@@ -50,6 +54,16 @@ public class FileArchive {
}
}
public void export(String s, Path dst) throws IOException {
byte[] data = read(s);
if (data == null) {
throw new FileNotFoundException(s);
}
try (OutputStream out = Files.newOutputStream(dst)) {
out.write(data);
}
}
public byte[] read(String s) throws IOException {
int hash = 0;
s = s.toUpperCase();
+2 -2
View File
@@ -24,7 +24,7 @@ public class FloType {
}
public String unusedString;
public int anInt390;
public int anInt391 = -1;
public int textureId = -1;
public boolean unusedBool = false;
public boolean aBoolean393 = true;
public int anInt394;
@@ -47,7 +47,7 @@ public class FloType {
anInt390 = buffer.get3();
method262(anInt390);
} else if (i == 2) {
anInt391 = buffer.get1U();
textureId = buffer.get1U();
} else if (i == 3) {
unusedBool = true;
} else if (i == 5) {
+444 -462
View File
File diff suppressed because it is too large. Load diff
+470 -463
View File
@@ -5,496 +5,503 @@
import org.apache.commons.collections4.map.LRUMap;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
public class LocType {
public static final Model[] TMP_MODELS = new Model[4];
public static boolean lowmem;
public static Buffer dat;
public static int[] offsets;
public static int count;
public static Game game;
public static int anInt771;
public static LRUMap<Long, Model> aCache_780 = new LRUMap(30);
public static LocType[] cache;
public static LRUMap<Long, Model> modelCache = new LRUMap(500);
public static final Model[] TMP_MODELS = new Model[4];
public static boolean lowmem;
public static Buffer dat;
public static int[] offsets;
public static int count;
public static Game game;
public static int anInt771;
public static LRUMap<Long, Model> aCache_780 = new LRUMap(30);
public static LocType[] cache;
public static LRUMap<Long, Model> modelCache = new LRUMap(500);
public static LocType get(int i) {
for (int j = 0; j < 20; j++) {
if (cache[j].index == i) {
return cache[j];
}
}
anInt771 = (anInt771 + 1) % 20;
LocType type = cache[anInt771];
dat.position = offsets[i];
type.index = i;
type.reset();
type.method582(dat);
return type;
}
public static LocType get(int i) {
if (i >= count) {
i = 0;
}
for (int j = 0; j < 20; j++) {
if (cache[j].index == i) {
return cache[j];
}
}
anInt771 = (anInt771 + 1) % 20;
LocType type = cache[anInt771];
dat.position = offsets[i];
type.index = i;
type.reset();
type.method582(dat);
return type;
}
public static void unload() {
modelCache = null;
aCache_780 = null;
offsets = null;
cache = null;
dat = null;
}
public static void unload() {
modelCache = null;
aCache_780 = null;
offsets = null;
cache = null;
dat = null;
}
public static void unpack(FileArchive archive) throws IOException {
dat = new Buffer(archive.read("loc.dat"));
Buffer buffer = new Buffer(archive.read("loc.idx"));
count = buffer.get2U();
offsets = new int[count];
int i = 2;
for (int j = 0; j < count; j++) {
offsets[j] = i;
i += buffer.get2U();
}
cache = new LocType[20];
for (int k = 0; k < 20; k++) {
cache[k] = new LocType();
}
}
public static void unpack(FileArchive archive) throws IOException {
dat = new Buffer(archive.read("loc.dat"));
Buffer buffer = new Buffer(archive.read("loc.idx"));
count = buffer.get2U();
offsets = new int[count];
int i = 2;
for (int j = 0; j < count; j++) {
offsets[j] = i;
i += buffer.get2U();
}
cache = new LocType[20];
for (int k = 0; k < 20; k++) {
cache[k] = new LocType();
}
}
public boolean important;
public byte lightAmbient;
public int translateX;
public String name;
public int scaleY;
public byte lightAttenuation;
public int sizeX;
public int translateY;
public int mapfunctionIcon;
public int[] dstColor;
public int scaleX;
public int varp;
public boolean invert;
public int index = -1;
public boolean blocksProjectiles;
public int mapsceneIcon;
public int[] overrideIds;
public int supportsObj;
public int sizeZ;
public boolean adjustToTerrain;
public boolean occludes;
public boolean decorative;
public boolean solid;
public int interactionSideFlags;
/**
* Models flagged as <code>dynamic</code> will <b>always</b> copy their models face information by making <code>copyFaces</code>
* equal <code>true</code>.
* @see Model#Model(boolean, boolean, Model)
*/
public boolean dynamic;
public int scaleZ;
public int[] modelIds;
public int varbit;
public int decorationPadding;
public int[] modelTypes;
public String description;
public boolean interactable;
public boolean castShadow;
public int seqId;
public int translateZ;
public int[] srcColor;
public String[] actions;
public boolean important;
public byte lightAmbient;
public int translateX;
public String name;
public int scaleY;
public byte lightAttenuation;
public int sizeX;
public int translateY;
public int mapfunctionIcon;
public int[] dstColor;
public int scaleX;
public int varp;
public boolean invert;
public int index = -1;
public boolean blocksProjectiles;
public int mapsceneIcon;
public int[] overrideIds;
public int supportsObj;
public int sizeZ;
public boolean adjustToTerrain;
public boolean occludes;
public boolean decorative;
public boolean solid;
public int interactionSideFlags;
/**
* Models flagged as <code>dynamic</code> will <b>always</b> copy their models face information by making <code>copyFaces</code>
* equal <code>true</code>.
*
* @see Model#Model(boolean, boolean, Model)
*/
public boolean dynamic;
public int scaleZ;
public int[] modelIds;
public int varbit;
public int decorationPadding;
public int[] modelTypes;
public String description;
public boolean interactable;
public boolean castShadow;
public int seqId;
public int translateZ;
public int[] srcColor;
public String[] actions;
public LocType() {
}
public LocType() {
}
public void reset() {
modelIds = null;
modelTypes = null;
name = null;
description = null;
srcColor = null;
dstColor = null;
sizeX = 1;
sizeZ = 1;
solid = true;
blocksProjectiles = true;
interactable = false;
adjustToTerrain = false;
dynamic = false;
occludes = false;
seqId = -1;
decorationPadding = 16;
lightAmbient = 0;
lightAttenuation = 0;
actions = null;
mapfunctionIcon = -1;
mapsceneIcon = -1;
invert = false;
castShadow = true;
scaleX = 128;
scaleZ = 128;
scaleY = 128;
interactionSideFlags = 0;
translateX = 0;
translateY = 0;
translateZ = 0;
important = false;
decorative = false;
supportsObj = -1;
varbit = -1;
varp = -1;
overrideIds = null;
}
public void reset() {
modelIds = null;
modelTypes = null;
name = null;
description = null;
srcColor = null;
dstColor = null;
sizeX = 1;
sizeZ = 1;
solid = true;
blocksProjectiles = true;
interactable = false;
adjustToTerrain = false;
dynamic = false;
occludes = false;
seqId = -1;
decorationPadding = 16;
lightAmbient = 0;
lightAttenuation = 0;
actions = null;
mapfunctionIcon = -1;
mapsceneIcon = -1;
invert = false;
castShadow = true;
scaleX = 128;
scaleZ = 128;
scaleY = 128;
interactionSideFlags = 0;
translateX = 0;
translateY = 0;
translateZ = 0;
important = false;
decorative = false;
supportsObj = -1;
varbit = -1;
varp = -1;
overrideIds = null;
}
public void method574(OnDemand onDemand) {
if (modelIds == null) {
return;
}
for (int k : modelIds) {
onDemand.method560(k & 0xffff, 0);
}
}
public void method574(OnDemand onDemand) {
if (modelIds == null) {
return;
}
for (int k : modelIds) {
onDemand.method560(k & 0xffff, 0);
}
}
public boolean method577(int i) {
if (modelTypes == null) {
if (modelIds == null) {
return true;
}
if (i != 10) {
return true;
}
boolean flag1 = true;
for (int j : modelIds) {
flag1 &= Model.validate(j & 0xffff);
}
return flag1;
}
for (int j = 0; j < modelTypes.length; j++) {
if (modelTypes[j] == i) {
return Model.validate(modelIds[j] & 0xffff);
}
}
return true;
}
public boolean method577(int i) {
if (modelTypes == null) {
if (modelIds == null) {
return true;
}
if (i != 10) {
return true;
}
boolean flag1 = true;
for (int j : modelIds) {
flag1 &= Model.validate(j & 0xffff);
}
return flag1;
}
for (int j = 0; j < modelTypes.length; j++) {
if (modelTypes[j] == i) {
return Model.validate(modelIds[j] & 0xffff);
}
}
return true;
}
public Model method578(int i, int j, int k, int l, int i1, int j1, int k1) {
Model model = method581(i, k1, j);
if (model == null) {
return null;
}
if (adjustToTerrain || dynamic) {
model = new Model(adjustToTerrain, dynamic, model);
}
if (adjustToTerrain) {
int l1 = (k + l + i1 + j1) / 4;
for (int i2 = 0; i2 < model.vertexCount; i2++) {
int j2 = model.vertexX[i2];
int k2 = model.vertexZ[i2];
int l2 = k + (((l - k) * (j2 + 64)) / 128);
int i3 = j1 + (((i1 - j1) * (j2 + 64)) / 128);
int j3 = l2 + (((i3 - l2) * (k2 + 64)) / 128);
model.vertexY[i2] += j3 - l1;
}
model.calculateBoundsY();
}
return model;
}
public Model method578(int i, int j, int k, int l, int i1, int j1, int k1) {
Model model = method581(i, k1, j);
if (model == null) {
return null;
}
if (adjustToTerrain || dynamic) {
model = new Model(adjustToTerrain, dynamic, model);
}
if (adjustToTerrain) {
int l1 = (k + l + i1 + j1) / 4;
for (int i2 = 0; i2 < model.vertexCount; i2++) {
int j2 = model.vertexX[i2];
int k2 = model.vertexZ[i2];
int l2 = k + (((l - k) * (j2 + 64)) / 128);
int i3 = j1 + (((i1 - j1) * (j2 + 64)) / 128);
int j3 = l2 + (((i3 - l2) * (k2 + 64)) / 128);
model.vertexY[i2] += j3 - l1;
}
model.calculateBoundsY();
}
return model;
}
public boolean method579() {
if (modelIds == null) {
return true;
}
boolean flag1 = true;
for (int j : modelIds) {
flag1 &= Model.validate(j & 0xffff);
}
return flag1;
}
public boolean method579() {
if (modelIds == null) {
return true;
}
boolean flag1 = true;
for (int j : modelIds) {
flag1 &= Model.validate(j & 0xffff);
}
return flag1;
}
public LocType method580() {
int i = -1;
if (varbit != -1) {
VarbitType varbit = VarbitType.instances[this.varbit];
int j = varbit.varp;
int k = varbit.lsb;
int l = varbit.msb;
int i1 = Game.BITMASK[l - k];
i = (game.variables[j] >> k) & i1;
} else if (varp != -1) {
i = game.variables[varp];
}
if ((i < 0) || (i >= overrideIds.length) || (overrideIds[i] == -1)) {
return null;
} else {
return get(overrideIds[i]);
}
}
public LocType method580() {
int i = -1;
if (varbit != -1) {
VarbitType varbit = VarbitType.instances[this.varbit];
int j = varbit.varp;
int k = varbit.lsb;
int l = varbit.msb;
int i1 = Game.BITMASK[l - k];
i = (game.variables[j] >> k) & i1;
} else if (varp != -1) {
i = game.variables[varp];
}
if ((i < 0) || (i >= overrideIds.length) || (overrideIds[i] == -1)) {
return null;
} else {
return get(overrideIds[i]);
}
}
public Model method581(int type, int seqFrame, int rotation) {
Model model = null;
long bitset;
if (modelTypes == null) {
if (type != 10) {
return null;
}
bitset = ((long) index << 6) + rotation + ((long) (seqFrame + 1) << 32);
Model model_1 = aCache_780.get(bitset);
if (model_1 != null) {
return model_1;
}
if (modelIds == null) {
return null;
}
boolean flip = invert ^ (rotation > 3);
int modelCount = modelIds.length;
public Model method581(int type, int seqFrame, int rotation) {
Model model = null;
long bitset;
if (modelTypes == null) {
if (type != 10) {
return null;
}
bitset = ((long) index << 6) + rotation + ((long) (seqFrame + 1) << 32);
Model model_1 = aCache_780.get(bitset);
if (model_1 != null) {
return model_1;
}
if (modelIds == null) {
return null;
}
boolean flip = invert ^ (rotation > 3);
int modelCount = modelIds.length;
for (int i = 0; i < modelCount; i++) {
int modelId = modelIds[i];
for (int i = 0; i < modelCount; i++) {
int modelId = modelIds[i];
if (flip) {
modelId += 0x10000;
}
if (flip) {
modelId += 0x10000;
}
model = modelCache.get(modelId);
if (model == null) {
model = Model.tryGet(modelId & 0xffff);
if (model == null) {
return null;
}
if (flip) {
model.rotateY180();
}
modelCache.put((long) modelId, model);
}
model = modelCache.get(modelId);
if (model == null) {
model = Model.tryGet(modelId & 0xffff);
if (model == null) {
return null;
}
if (flip) {
model.rotateY180();
}
modelCache.put((long) modelId, model);
}
if (modelCount > 1) {
TMP_MODELS[i] = model;
}
}
if (modelCount > 1) {
TMP_MODELS[i] = model;
}
}
if (modelCount > 1) {
model = new Model(modelCount, TMP_MODELS);
}
} else {
int typeId = -1;
for (int i = 0; i < modelTypes.length; i++) {
if (modelTypes[i] != type) {
continue;
}
typeId = i;
break;
}
if (modelCount > 1) {
model = new Model(modelCount, TMP_MODELS);
}
} else {
int typeId = -1;
for (int i = 0; i < modelTypes.length; i++) {
if (modelTypes[i] != type) {
continue;
}
typeId = i;
break;
}
if (typeId == -1) {
return null;
}
if (typeId == -1) {
return null;
}
bitset = ((long) index << 6) + ((long) typeId << 3) + rotation + ((long) (seqFrame + 1) << 32);
bitset = ((long) index << 6) + ((long) typeId << 3) + rotation + ((long) (seqFrame + 1) << 32);
Model class30_sub2_sub4_sub6_2 = aCache_780.get(bitset);
if (class30_sub2_sub4_sub6_2 != null) {
return class30_sub2_sub4_sub6_2;
}
int j2 = modelIds[typeId];
boolean flag3 = invert ^ (rotation > 3);
if (flag3) {
j2 += 0x10000;
}
model = modelCache.get(j2);
if (model == null) {
model = Model.tryGet(j2 & 0xffff);
if (model == null) {
return null;
}
if (flag3) {
model.rotateY180();
}
modelCache.put((long) j2, model);
}
}
Model class30_sub2_sub4_sub6_2 = aCache_780.get(bitset);
if (class30_sub2_sub4_sub6_2 != null) {
return class30_sub2_sub4_sub6_2;
}
int j2 = modelIds[typeId];
boolean flag3 = invert ^ (rotation > 3);
if (flag3) {
j2 += 0x10000;
}
model = modelCache.get(j2);
if (model == null) {
model = Model.tryGet(j2 & 0xffff);
if (model == null) {
return null;
}
if (flag3) {
model.rotateY180();
}
modelCache.put((long) j2, model);
}
}
boolean scaled = (scaleX != 128) || (scaleZ != 128) || (scaleY != 128);
boolean translated = (translateX != 0) || (translateY != 0) || (translateZ != 0);
boolean scaled = (scaleX != 128) || (scaleZ != 128) || (scaleY != 128);
boolean translated = (translateX != 0) || (translateY != 0) || (translateZ != 0);
Model model_3 = new Model(srcColor == null, SeqFrame.isNull(seqFrame), (rotation == 0) && (seqFrame == -1) && !scaled && !translated, model);
Model model_3 = new Model(srcColor == null, SeqFrame.isNull(seqFrame), (rotation == 0) && (seqFrame == -1) && !scaled && !translated, model);
if (seqFrame != -1) {
model_3.createLabelReferences();
model_3.applySequenceFrame(seqFrame);
model_3.labelFaces = null;
model_3.labelVertices = null;
}
if (seqFrame != -1) {
model_3.createLabelReferences();
model_3.applySequenceFrame(seqFrame);
model_3.labelFaces = null;
model_3.labelVertices = null;
}
while (rotation-- > 0) {
model_3.rotateY90();
}
if (srcColor != null) {
for (int k2 = 0; k2 < srcColor.length; k2++) {
model_3.recolor(srcColor[k2], dstColor[k2]);
}
}
if (scaled) {
model_3.scale(scaleX, scaleY, scaleZ);
}
if (translated) {
model_3.translate(translateX, translateY, translateZ);
}
model_3.calculateNormals(64 + lightAmbient, 768 + (lightAttenuation * 5), -50, -10, -50, !dynamic);
if (supportsObj == 1) {
model_3.objRaise = model_3.minY;
}
aCache_780.put(bitset, model_3);
return model_3;
}
while (rotation-- > 0) {
model_3.rotateY90();
}
if (srcColor != null) {
for (int k2 = 0; k2 < srcColor.length; k2++) {
model_3.recolor(srcColor[k2], dstColor[k2]);
}
}
if (scaled) {
model_3.scale(scaleX, scaleY, scaleZ);
}
if (translated) {
model_3.translate(translateX, translateY, translateZ);
}
model_3.calculateNormals(64 + lightAmbient, 768 + (lightAttenuation * 5), -50, -10, -50, !dynamic);
if (supportsObj == 1) {
model_3.objRaise = model_3.minY;
}
aCache_780.put(bitset, model_3);
return model_3;
}
public void method582(Buffer buffer) {
int i = -1;
label0:
do {
int j;
do {
j = buffer.get1U();
if (j == 0) {
break label0;
}
if (j == 1) {
int k = buffer.get1U();
if (k > 0) {
if ((modelIds == null) || lowmem) {
modelTypes = new int[k];
modelIds = new int[k];
for (int k1 = 0; k1 < k; k1++) {
modelIds[k1] = buffer.get2U();
modelTypes[k1] = buffer.get1U();
}
} else {
buffer.position += k * 3;
}
}
} else if (j == 2) {
name = buffer.getString();
} else if (j == 3) {
description = buffer.getString();
} else if (j == 5) {
int l = buffer.get1U();
if (l > 0) {
if ((modelIds == null) || lowmem) {
modelTypes = null;
modelIds = new int[l];
for (int l1 = 0; l1 < l; l1++) {
modelIds[l1] = buffer.get2U();
}
} else {
buffer.position += l * 2;
}
}
} else if (j == 14) {
sizeX = buffer.get1U();
} else if (j == 15) {
sizeZ = buffer.get1U();
} else if (j == 17) {
solid = false;
} else if (j == 18) {
blocksProjectiles = false;
} else if (j == 19) {
i = buffer.get1U();
if (i == 1) {
interactable = true;
}
} else if (j == 21) {
adjustToTerrain = true;
} else if (j == 22) {
dynamic = true;
} else if (j == 23) {
occludes = true;
} else if (j == 24) {
seqId = buffer.get2U();
if (seqId == 65535) {
seqId = -1;
}
} else if (j == 28) {
decorationPadding = buffer.get1U();
} else if (j == 29) {
lightAmbient = buffer.get1();
} else if (j == 39) {
lightAttenuation = buffer.get1();
} else if ((j >= 30) && (j < 39)) {
if (actions == null) {
actions = new String[5];
}
actions[j - 30] = buffer.getString();
if (actions[j - 30].equalsIgnoreCase("hidden")) {
actions[j - 30] = null;
}
} else if (j == 40) {
int i1 = buffer.get1U();
srcColor = new int[i1];
dstColor = new int[i1];
for (int i2 = 0; i2 < i1; i2++) {
srcColor[i2] = buffer.get2U();
dstColor[i2] = buffer.get2U();
}
} else if (j == 60) {
mapfunctionIcon = buffer.get2U();
} else if (j == 62) {
invert = true;
} else if (j == 64) {
castShadow = false;
} else if (j == 65) {
scaleX = buffer.get2U();
} else if (j == 66) {
scaleZ = buffer.get2U();
} else if (j == 67) {
scaleY = buffer.get2U();
} else if (j == 68) {
mapsceneIcon = buffer.get2U();
} else if (j == 69) {
interactionSideFlags = buffer.get1U();
} else if (j == 70) {
translateX = buffer.get2();
} else if (j == 71) {
translateY = buffer.get2();
} else if (j == 72) {
translateZ = buffer.get2();
} else if (j == 73) {
important = true;
} else if (j == 74) {
decorative = true;
} else {
if (j != 75) {
continue;
}
supportsObj = buffer.get1U();
}
continue label0;
} while (j != 77);
varbit = buffer.get2U();
if (varbit == 65535) {
varbit = -1;
}
varp = buffer.get2U();
if (varp == 65535) {
varp = -1;
}
int j1 = buffer.get1U();
overrideIds = new int[j1 + 1];
for (int j2 = 0; j2 <= j1; j2++) {
overrideIds[j2] = buffer.get2U();
if (overrideIds[j2] == 65535) {
overrideIds[j2] = -1;
}
}
} while (true);
if (i == -1) {
interactable = (modelIds != null) && ((modelTypes == null) || (modelTypes[0] == 10));
if (actions != null) {
interactable = true;
}
}
if (decorative) {
solid = false;
blocksProjectiles = false;
}
if (supportsObj == -1) {
supportsObj = solid ? 1 : 0;
}
}
public void method582(Buffer buffer) {
int i = -1;
label0:
do {
int j;
do {
j = buffer.get1U();
if (j == 0) {
break label0;
}
if (j == 1) {
int k = buffer.get1U();
if (k > 0) {
if ((modelIds == null) || lowmem) {
modelTypes = new int[k];
modelIds = new int[k];
for (int k1 = 0; k1 < k; k1++) {
modelIds[k1] = buffer.get2U();
modelTypes[k1] = buffer.get1U();
}
} else {
buffer.position += k * 3;
}
}
} else if (j == 2) {
name = buffer.getString();
} else if (j == 3) {
description = buffer.getString();
} else if (j == 5) {
int l = buffer.get1U();
if (l > 0) {
if ((modelIds == null) || lowmem) {
modelTypes = null;
modelIds = new int[l];
for (int l1 = 0; l1 < l; l1++) {
modelIds[l1] = buffer.get2U();
}
} else {
buffer.position += l * 2;
}
}
} else if (j == 14) {
sizeX = buffer.get1U();
} else if (j == 15) {
sizeZ = buffer.get1U();
} else if (j == 17) {
solid = false;
} else if (j == 18) {
blocksProjectiles = false;
} else if (j == 19) {
i = buffer.get1U();
if (i == 1) {
interactable = true;
}
} else if (j == 21) {
adjustToTerrain = true;
} else if (j == 22) {
dynamic = true;
} else if (j == 23) {
occludes = true;
} else if (j == 24) {
seqId = buffer.get2U();
if (seqId == 65535) {
seqId = -1;
}
} else if (j == 28) {
decorationPadding = buffer.get1U();
} else if (j == 29) {
lightAmbient = buffer.get1();
} else if (j == 39) {
lightAttenuation = buffer.get1();
} else if ((j >= 30) && (j < 39)) {
if (actions == null) {
actions = new String[5];
}
actions[j - 30] = buffer.getString();
if (actions[j - 30].equalsIgnoreCase("hidden")) {
actions[j - 30] = null;
}
} else if (j == 40) {
int i1 = buffer.get1U();
srcColor = new int[i1];
dstColor = new int[i1];
for (int i2 = 0; i2 < i1; i2++) {
srcColor[i2] = buffer.get2U();
dstColor[i2] = buffer.get2U();
}
} else if (j == 60) {
mapfunctionIcon = buffer.get2U();
} else if (j == 62) {
invert = true;
} else if (j == 64) {
castShadow = false;
} else if (j == 65) {
scaleX = buffer.get2U();
} else if (j == 66) {
scaleZ = buffer.get2U();
} else if (j == 67) {
scaleY = buffer.get2U();
} else if (j == 68) {
mapsceneIcon = buffer.get2U();
} else if (j == 69) {
interactionSideFlags = buffer.get1U();
} else if (j == 70) {
translateX = buffer.get2();
} else if (j == 71) {
translateY = buffer.get2();
} else if (j == 72) {
translateZ = buffer.get2();
} else if (j == 73) {
important = true;
} else if (j == 74) {
decorative = true;
} else {
if (j != 75) {
continue;
}
supportsObj = buffer.get1U();
}
continue label0;
} while (j != 77);
varbit = buffer.get2U();
if (varbit == 65535) {
varbit = -1;
}
varp = buffer.get2U();
if (varp == 65535) {
varp = -1;
}
int j1 = buffer.get1U();
overrideIds = new int[j1 + 1];
for (int j2 = 0; j2 <= j1; j2++) {
overrideIds[j2] = buffer.get2U();
if (overrideIds[j2] == 65535) {
overrideIds[j2] = -1;
}
}
} while (true);
if (i == -1) {
interactable = (modelIds != null) && ((modelTypes == null) || (modelTypes[0] == 10));
if (actions != null) {
interactable = true;
}
}
if (decorative) {
solid = false;
blocksProjectiles = false;
}
if (supportsObj == -1) {
supportsObj = solid ? 1 : 0;
}
}
}
+2 -2
View File
@@ -308,7 +308,7 @@ public class Model extends Entity {
*
* @see #draw(int, int, int, int, int, int, int, int, int)
*/
public boolean pickBounds = false;
public boolean pickable = false;
/**
* A storage for the original vertex normals to give {@link Scene#method308(Model, Model, int, int, int, boolean)}
* a reference.
@@ -1915,7 +1915,7 @@ public class Model extends Entity {
int mouseY = Model.mouseY - Draw3D.centerY;
if ((mouseX > leftX) && (mouseX < rightX) && (mouseY > topY) && (mouseY < bottomY)) {
if (pickBounds) {
if (pickable) {
pickedBitsets[pickedCount++] = bitset;
} else {
picking = true;
+1 -1
View File
@@ -55,7 +55,7 @@ public class NPCEntity extends PathingEntity {
}
}
if (type.size == 1) {
model.pickBounds = true;
model.pickable = true;
}
return model;
}
+280 -282
View File
@@ -8,303 +8,301 @@ import java.io.IOException;
public class NPCType {
private static int cachePosition;
private static Buffer dat;
public static int[] offsets;
private static NPCType[] cache;
public static Game game;
public static LRUMap<Long, Model> modelCache = new LRUMap<>(30);
private static int cachePosition;
private static Buffer dat;
public static int[] offsets;
private static NPCType[] cache;
public static Game game;
public static int count;
public static LRUMap<Long, Model> modelCache = new LRUMap<>(30);
public static NPCType get(int id) {
if (id > cache.length) {
id = 0;
}
for (int j = 0; j < 20; j++) {
if (cache[j].uid == (long) id) {
return cache[j];
}
}
cachePosition = (cachePosition + 1) % 20;
NPCType type = cache[cachePosition] = new NPCType();
dat.position = offsets[id];
type.uid = id;
type.read(dat);
return type;
}
public static NPCType get(int id) {
for (int j = 0; j < 20; j++) {
if (cache[j].uid == (long) id) {
return cache[j];
}
}
cachePosition = (cachePosition + 1) % 20;
NPCType type = cache[cachePosition] = new NPCType();
dat.position = offsets[id];
type.uid = id;
type.read(dat);
return type;
}
public static void unpack(FileArchive archive) throws IOException {
dat = new Buffer(archive.read("npc.dat"));
Buffer buffer = new Buffer(archive.read("npc.idx"));
int count = buffer.get2U();
offsets = new int[count];
public static void unpack(FileArchive archive) throws IOException {
dat = new Buffer(archive.read("npc.dat"));
Buffer buffer = new Buffer(archive.read("npc.idx"));
count = buffer.get2U();
offsets = new int[count];
int offset = 2;
for (int i = 0; i < count; i++) {
offsets[i] = offset;
offset += buffer.get2U();
}
int offset = 2;
for (int i = 0; i < count; i++) {
offsets[i] = offset;
offset += buffer.get2U();
}
cache = new NPCType[20];
cache = new NPCType[20];
for (int k = 0; k < 20; k++) {
cache[k] = new NPCType();
}
}
for (int k = 0; k < 20; k++) {
cache[k] = new NPCType();
}
}
public static void unload() {
modelCache = null;
offsets = null;
cache = null;
dat = null;
}
public static void unload() {
modelCache = null;
offsets = null;
cache = null;
dat = null;
}
public int seqTurnRight = -1;
public int varbit = -1;
public int seqTurnAround = -1;
public int varp = -1;
public int anInt61 = -1;
public String aString65;
public String[] aStringArray66;
public int seqWalk = -1;
public byte size = 1;
public int[] anIntArray70;
public int unusedInt0 = -1;
public int[] anIntArray73;
public int anInt75 = -1;
public int[] anIntArray76;
public int seqStand = -1;
public long uid = -1L;
public int turnSpeed = 32;
public int seqTurnLeft = -1;
public boolean aBoolean84 = true;
public int anInt85;
public int anInt86 = 128;
public boolean aBoolean87 = true;
public int[] overrides;
public byte[] aByteArray89;
public int unusedInt1 = -1;
public int anInt91 = 128;
public int anInt92;
public boolean aBoolean93 = false;
public int[] anIntArray94;
public int unusedInt2 = -1;
public int seqTurnRight = -1;
public int varbit = -1;
public int seqTurnAround = -1;
public int varp = -1;
public int anInt61 = -1;
public String name;
public String[] op;
public int seqWalk = -1;
public byte size = 1;
public int[] anIntArray70;
public int unusedInt0 = -1;
public int[] anIntArray73;
public int anInt75 = -1;
public int[] anIntArray76;
public int seqStand = -1;
public long uid = -1L;
public int turnSpeed = 32;
public int seqTurnLeft = -1;
public boolean aBoolean84 = true;
public int anInt85;
public int anInt86 = 128;
public boolean aBoolean87 = true;
public int[] overrides;
public byte[] desc;
public int unusedInt1 = -1;
public int anInt91 = 128;
public int anInt92;
public boolean aBoolean93 = false;
public int[] anIntArray94;
public int unusedInt2 = -1;
public NPCType() {
}
public NPCType() {
}
public Model method160() {
if (overrides != null) {
NPCType type = getOverrideType();
if (type == null) {
return null;
} else {
return type.method160();
}
}
if (anIntArray73 == null) {
return null;
}
boolean flag1 = false;
for (int value : anIntArray73) {
if (!Model.validate(value)) {
flag1 = true;
}
}
if (flag1) {
return null;
}
Model[] aclass30_sub2_sub4_sub6 = new Model[anIntArray73.length];
for (int j = 0; j < anIntArray73.length; j++) {
aclass30_sub2_sub4_sub6[j] = Model.tryGet(anIntArray73[j]);
}
Model model;
if (aclass30_sub2_sub4_sub6.length == 1) {
model = aclass30_sub2_sub4_sub6[0];
} else {
model = new Model(aclass30_sub2_sub4_sub6.length, aclass30_sub2_sub4_sub6);
}
if (anIntArray76 != null) {
for (int k = 0; k < anIntArray76.length; k++) {
model.recolor(anIntArray76[k], anIntArray70[k]);
}
}
return model;
}
public Model method160() {
if (overrides != null) {
NPCType type = getOverrideType();
if (type == null) {
return null;
} else {
return type.method160();
}
}
if (anIntArray73 == null) {
return null;
}
boolean flag1 = false;
for (int value : anIntArray73) {
if (!Model.validate(value)) {
flag1 = true;
}
}
if (flag1) {
return null;
}
Model[] aclass30_sub2_sub4_sub6 = new Model[anIntArray73.length];
for (int j = 0; j < anIntArray73.length; j++) {
aclass30_sub2_sub4_sub6[j] = Model.tryGet(anIntArray73[j]);
}
Model model;
if (aclass30_sub2_sub4_sub6.length == 1) {
model = aclass30_sub2_sub4_sub6[0];
} else {
model = new Model(aclass30_sub2_sub4_sub6.length, aclass30_sub2_sub4_sub6);
}
if (anIntArray76 != null) {
for (int k = 0; k < anIntArray76.length; k++) {
model.recolor(anIntArray76[k], anIntArray70[k]);
}
}
return model;
}
public NPCType getOverrideType() {
int value = -1;
public NPCType getOverrideType() {
int value = -1;
if (varbit != -1) {
VarbitType vb = VarbitType.instances[this.varbit];
int varp = vb.varp;
int lsb = vb.lsb;
int msb = vb.msb;
int mask = Game.BITMASK[msb - lsb];
value = (game.variables[varp] >> lsb) & mask;
} else if (varp != -1) {
value = game.variables[varp];
}
if (varbit != -1) {
VarbitType vb = VarbitType.instances[this.varbit];
int varp = vb.varp;
int lsb = vb.lsb;
int msb = vb.msb;
int mask = Game.BITMASK[msb - lsb];
value = (game.variables[varp] >> lsb) & mask;
} else if (varp != -1) {
value = game.variables[varp];
}
if ((value < 0) || (value >= overrides.length) || (overrides[value] == -1)) {
return null;
} else {
return get(overrides[value]);
}
}
if ((value < 0) || (value >= overrides.length) || (overrides[value] == -1)) {
return null;
} else {
return get(overrides[value]);
}
}
public Model method164(int j, int k, int[] ai) {
if (overrides != null) {
NPCType type = getOverrideType();
if (type == null) {
return null;
} else {
return type.method164(j, k, ai);
}
}
public Model method164(int j, int k, int[] ai) {
if (overrides != null) {
NPCType type = getOverrideType();
if (type == null) {
return null;
} else {
return type.method164(j, k, ai);
}
}
Model model = modelCache.get(uid);
Model model = modelCache.get(uid);
if (model == null) {
boolean flag = false;
for (int value : anIntArray94) {
if (!Model.validate(value)) {
flag = true;
}
}
if (flag) {
return null;
}
Model[] aclass30_sub2_sub4_sub6 = new Model[anIntArray94.length];
for (int j1 = 0; j1 < anIntArray94.length; j1++) {
aclass30_sub2_sub4_sub6[j1] = Model.tryGet(anIntArray94[j1]);
}
if (aclass30_sub2_sub4_sub6.length == 1) {
model = aclass30_sub2_sub4_sub6[0];
} else {
model = new Model(aclass30_sub2_sub4_sub6.length, aclass30_sub2_sub4_sub6);
}
if (anIntArray76 != null) {
for (int k1 = 0; k1 < anIntArray76.length; k1++) {
model.recolor(anIntArray76[k1], anIntArray70[k1]);
}
}
model.createLabelReferences();
model.calculateNormals(64 + anInt85, 850 + anInt92, -30, -50, -30, true);
modelCache.put(uid, model);
}
Model model_1 = Model.EMPTY;
model_1.set(model, SeqFrame.isNull(k) & SeqFrame.isNull(j));
if ((k != -1) && (j != -1)) {
model_1.applySequenceFrames(k, j, ai);
} else if (k != -1) {
model_1.applySequenceFrame(k);
}
if ((anInt91 != 128) || (anInt86 != 128)) {
model_1.scale(anInt91, anInt91, anInt86);
}
model_1.calculateBoundsCylinder();
model_1.labelFaces = null;
model_1.labelVertices = null;
if (size == 1) {
model_1.pickBounds = true;
}
return model_1;
}
if (model == null) {
boolean flag = false;
for (int value : anIntArray94) {
if (!Model.validate(value)) {
flag = true;
}
}
if (flag) {
return null;
}
Model[] aclass30_sub2_sub4_sub6 = new Model[anIntArray94.length];
for (int j1 = 0; j1 < anIntArray94.length; j1++) {
aclass30_sub2_sub4_sub6[j1] = Model.tryGet(anIntArray94[j1]);
}
if (aclass30_sub2_sub4_sub6.length == 1) {
model = aclass30_sub2_sub4_sub6[0];
} else {
model = new Model(aclass30_sub2_sub4_sub6.length, aclass30_sub2_sub4_sub6);
}
if (anIntArray76 != null) {
for (int k1 = 0; k1 < anIntArray76.length; k1++) {
model.recolor(anIntArray76[k1], anIntArray70[k1]);
}
}
model.createLabelReferences();
model.calculateNormals(64 + anInt85, 850 + anInt92, -30, -50, -30, true);
modelCache.put(uid, model);
}
Model model_1 = Model.EMPTY;
model_1.set(model, SeqFrame.isNull(k) & SeqFrame.isNull(j));
if ((k != -1) && (j != -1)) {
model_1.applySequenceFrames(k, j, ai);
} else if (k != -1) {
model_1.applySequenceFrame(k);
}
if ((anInt91 != 128) || (anInt86 != 128)) {
model_1.scale(anInt91, anInt91, anInt86);
}
model_1.calculateBoundsCylinder();
model_1.labelFaces = null;
model_1.labelVertices = null;
if (size == 1) {
model_1.pickable = true;
}
return model_1;
}
public void read(Buffer buffer) {
do {
int i = buffer.get1U();
if (i == 0) {
return;
}
if (i == 1) {
int j = buffer.get1U();
anIntArray94 = new int[j];
for (int j1 = 0; j1 < j; j1++) {
anIntArray94[j1] = buffer.get2U();
}
} else if (i == 2) {
aString65 = buffer.getString();
} else if (i == 3) {
aByteArray89 = buffer.getStringRaw();
} else if (i == 12) {
size = buffer.get1();
} else if (i == 13) {
seqStand = buffer.get2U();
} else if (i == 14) {
seqWalk = buffer.get2U();
} else if (i == 17) {
seqWalk = buffer.get2U();
seqTurnAround = buffer.get2U();
seqTurnLeft = buffer.get2U();
seqTurnRight = buffer.get2U();
} else if ((i >= 30) && (i < 40)) {
if (aStringArray66 == null) {
aStringArray66 = new String[5];
}
aStringArray66[i - 30] = buffer.getString();
if (aStringArray66[i - 30].equalsIgnoreCase("hidden")) {
aStringArray66[i - 30] = null;
}
} else if (i == 40) {
int k = buffer.get1U();
anIntArray76 = new int[k];
anIntArray70 = new int[k];
for (int k1 = 0; k1 < k; k1++) {
anIntArray76[k1] = buffer.get2U();
anIntArray70[k1] = buffer.get2U();
}
} else if (i == 60) {
int l = buffer.get1U();
anIntArray73 = new int[l];
for (int l1 = 0; l1 < l; l1++) {
anIntArray73[l1] = buffer.get2U();
}
} else if (i == 90) {
unusedInt2 = buffer.get2U();
} else if (i == 91) {
unusedInt0 = buffer.get2U();
} else if (i == 92) {
unusedInt1 = buffer.get2U();
} else if (i == 93) {
aBoolean87 = false;
} else if (i == 95) {
anInt61 = buffer.get2U();
} else if (i == 97) {
anInt91 = buffer.get2U();
} else if (i == 98) {
anInt86 = buffer.get2U();
} else if (i == 99) {
aBoolean93 = true;
} else if (i == 100) {
anInt85 = buffer.get1();
} else if (i == 101) {
anInt92 = buffer.get1() * 5;
} else if (i == 102) {
anInt75 = buffer.get2U();
} else if (i == 103) {
turnSpeed = buffer.get2U();
} else if (i == 106) {
varbit = buffer.get2U();
if (varbit == 65535) {
varbit = -1;
}
varp = buffer.get2U();
if (varp == 65535) {
varp = -1;
}
int i1 = buffer.get1U();
overrides = new int[i1 + 1];
for (int i2 = 0; i2 <= i1; i2++) {
overrides[i2] = buffer.get2U();
if (overrides[i2] == 65535) {
overrides[i2] = -1;
}
}
} else if (i == 107) {
aBoolean84 = false;
}
} while (true);
}
public void read(Buffer buffer) {
do {
int i = buffer.get1U();
if (i == 0) {
return;
}
if (i == 1) {
int j = buffer.get1U();
anIntArray94 = new int[j];
for (int j1 = 0; j1 < j; j1++) {
anIntArray94[j1] = buffer.get2U();
}
} else if (i == 2) {
name = buffer.getString();
} else if (i == 3) {
desc = buffer.getStringRaw();
} else if (i == 12) {
size = buffer.get1();
} else if (i == 13) {
seqStand = buffer.get2U();
} else if (i == 14) {
seqWalk = buffer.get2U();
} else if (i == 17) {
seqWalk = buffer.get2U();
seqTurnAround = buffer.get2U();
seqTurnLeft = buffer.get2U();
seqTurnRight = buffer.get2U();
} else if ((i >= 30) && (i < 40)) {
if (op == null) {
op = new String[5];
}
op[i - 30] = buffer.getString();
if (op[i - 30].equalsIgnoreCase("hidden")) {
op[i - 30] = null;
}
} else if (i == 40) {
int k = buffer.get1U();
anIntArray76 = new int[k];
anIntArray70 = new int[k];
for (int k1 = 0; k1 < k; k1++) {
anIntArray76[k1] = buffer.get2U();
anIntArray70[k1] = buffer.get2U();
}
} else if (i == 60) {
int l = buffer.get1U();
anIntArray73 = new int[l];
for (int l1 = 0; l1 < l; l1++) {
anIntArray73[l1] = buffer.get2U();
}
} else if (i == 90) {
unusedInt2 = buffer.get2U();
} else if (i == 91) {
unusedInt0 = buffer.get2U();
} else if (i == 92) {
unusedInt1 = buffer.get2U();
} else if (i == 93) {
aBoolean87 = false;
} else if (i == 95) {
anInt61 = buffer.get2U();
} else if (i == 97) {
anInt91 = buffer.get2U();
} else if (i == 98) {
anInt86 = buffer.get2U();
} else if (i == 99) {
aBoolean93 = true;
} else if (i == 100) {
anInt85 = buffer.get1();
} else if (i == 101) {
anInt92 = buffer.get1() * 5;
} else if (i == 102) {
anInt75 = buffer.get2U();
} else if (i == 103) {
turnSpeed = buffer.get2U();
} else if (i == 106) {
varbit = buffer.get2U();
if (varbit == 65535) {
varbit = -1;
}
varp = buffer.get2U();
if (varp == 65535) {
varp = -1;
}
int i1 = buffer.get1U();
overrides = new int[i1 + 1];
for (int i2 = 0; i2 <= i1; i2++) {
overrides[i2] = buffer.get2U();
if (overrides[i2] == 65535) {
overrides[i2] = -1;
}
}
} else if (i == 107) {
aBoolean84 = false;
}
} while (true);
}
}
+4 -4
View File
@@ -4,16 +4,16 @@
public class ObjStackEntity extends Entity {
public int anInt1558;
public int anInt1559;
public int id;
public int amount;
public ObjStackEntity() {
}
@Override
public Model getModel() {
ObjType type = ObjType.get(anInt1558);
return type.getModel(anInt1559);
ObjType type = ObjType.get(id);
return type.getModel(amount);
}
}
+199 -199
View File
@@ -5,6 +5,11 @@
import org.apache.commons.collections4.map.LRUMap;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import static java.nio.file.Files.*;
public class ObjType {
@@ -12,27 +17,27 @@ public class ObjType {
public static LRUMap<Integer, Model> modelCache = new LRUMap<>(50);
public static ObjType[] cached;
public static int cachePos;
public static Buffer buf;
public static Buffer dat;
public static int[] typeOffset;
public static int anInt203;
public static int count;
public static void unload() {
modelCache = null;
iconCache = null;
typeOffset = null;
cached = null;
buf = null;
dat = null;
}
public static void unpack(FileArchive archive) throws IOException {
buf = new Buffer(archive.read("obj.dat"));
Buffer buffer = new Buffer(archive.read("obj.idx"));
anInt203 = buffer.get2U();
typeOffset = new int[anInt203];
dat = new Buffer(archive.read("obj.dat"));
Buffer idx = new Buffer(archive.read("obj.idx"));
count = idx.get2U();
typeOffset = new int[count];
int i = 2;
for (int j = 0; j < anInt203; j++) {
for (int j = 0; j < count; j++) {
typeOffset[j] = i;
i += buffer.get2U();
i += idx.get2U();
}
cached = new ObjType[10];
for (int k = 0; k < 10; k++) {
@@ -48,19 +53,19 @@ public class ObjType {
}
cachePos = (cachePos + 1) % 10;
ObjType type = cached[cachePos];
buf.position = typeOffset[id];
dat.position = typeOffset[id];
type.id = id;
type.reset();
type.read(buf);
if (type.linkedId != -1) {
type.link();
type.read(dat);
if (type.certificateId != -1) {
type.toCertificate();
}
if (!Game.members && type.members) {
type.name = "Members Object";
type.description = "Login to a members' server to use this object.".getBytes();
type.aStringArray168 = null;
type.aStringArray189 = null;
type.anInt202 = 0;
type.examine = "Login to a members' server to use this object.".getBytes();
type.groundOptions = null;
type.inventoryOptions = null;
type.team = 0;
}
return type;
}
@@ -104,12 +109,12 @@ public class ObjType {
}
// this will typically be the certificate item for noted stuff
Image24 linkedIcon = null;
Image24 originalIcon = null;
if (type.linkedId != -1) {
linkedIcon = getIcon(type.anInt179, 10, -1);
if (type.certificateId != -1) {
originalIcon = getIcon(type.linkedId, 10, -1);
if (linkedIcon == null) {
if (originalIcon == null) {
return null;
}
}
@@ -196,14 +201,14 @@ public class ObjType {
}
}
if (type.linkedId != -1) {
int w = linkedIcon.cropW;
int h = linkedIcon.cropH;
linkedIcon.cropW = 32;
linkedIcon.cropH = 32;
linkedIcon.draw(0, 0);
linkedIcon.cropW = w;
linkedIcon.cropH = h;
if (type.certificateId != -1) {
int w = originalIcon.cropW;
int h = originalIcon.cropH;
originalIcon.cropW = 32;
originalIcon.cropH = 32;
originalIcon.draw(0, 0);
originalIcon.cropW = w;
originalIcon.cropH = h;
}
if (outlineColor == 0) {
@@ -218,7 +223,7 @@ public class ObjType {
Draw3D.lineOffset = _loff;
Draw3D.jagged = true;
if (type.aBoolean176) {
if (type.stackable) {
icon.cropW = 33;
} else {
icon.cropW = 32;
@@ -228,162 +233,157 @@ public class ObjType {
return icon;
}
public byte aByte154;
public int anInt155;
public byte femaleOffsetY;
public int cost;
public int[] srcColor;
public int id = -1;
public int[] dstColor;
public boolean members;
public int anInt162;
public int linkedId;
public int anInt164;
public int anInt165;
public int anInt166;
public int femaleModelId2;
public int certificateId;
public int femaleModelId1;
public int maleModelId0;
public int maleHeadModelId1;
public int scaleX;
public String[] aStringArray168;
public String[] groundOptions;
public int iconOffsetX;
public String name;
public int anInt173;
public int anInt174;
public int anInt175;
public boolean aBoolean176;
public byte[] description;
public int anInt179;
public int femaleHeadModel1;
public int modelId;
public int maleHeadModelId0;
public boolean stackable;
public byte[] examine;
public int linkedId;
public int iconZoom;
public int anInt184;
public int anInt185;
public int anInt188;
public String[] aStringArray189;
public int lightAttenuation;
public int maleModelId2;
public int maleModelId1;
public String[] inventoryOptions;
public int iconPitch;
public int scaleY;
public int scaleZ;
public int[] stackId;
public int iconOffsetY;
public int anInt196;
public int anInt197;
public int lightAmbient;
public int femaleHeadModel0;
public int iconYaw;
public int unusedInt;
public int anInt200;
public int femaleModelId0;
public int[] stackAmount;
public int anInt202;
public int team;
public int iconRoll;
public byte aByte205;
public byte maleOffsetY;
public ObjType() {
}
public boolean method192(int j) {
int k = anInt175;
int l = anInt166;
if (j == 1) {
k = anInt197;
l = anInt173;
public boolean validateHeadModel(int gender) {
int m0 = maleHeadModelId0;
int m1 = maleHeadModelId1;
if (gender == 1) {
m0 = femaleHeadModel0;
m1 = femaleHeadModel1;
}
if (k == -1) {
if (m0 == -1) {
return true;
}
boolean flag = true;
if (!Model.validate(k)) {
flag = false;
boolean valid = Model.validate(m0);
if ((m1 != -1) && !Model.validate(m1)) {
valid = false;
}
if ((l != -1) && !Model.validate(l)) {
flag = false;
}
return flag;
return valid;
}
public Model method194(int j) {
int k = anInt175;
int l = anInt166;
if (j == 1) {
k = anInt197;
l = anInt173;
public Model getHeadModel(int gender) {
int m0 = maleHeadModelId0;
int m1 = maleHeadModelId1;
if (gender == 1) {
m0 = femaleHeadModel0;
m1 = femaleHeadModel1;
}
if (k == -1) {
if (m0 == -1) {
return null;
}
Model model = Model.tryGet(k);
if (l != -1) {
Model model_1 = Model.tryGet(l);
Model[] aclass30_sub2_sub4_sub6 = {model, model_1};
model = new Model(2, aclass30_sub2_sub4_sub6);
Model model = Model.tryGet(m0);
if (m1 != -1) {
model = new Model(2, new Model[]{model, Model.tryGet(m1)});
}
if (srcColor != null) {
for (int i1 = 0; i1 < srcColor.length; i1++) {
model.recolor(srcColor[i1], dstColor[i1]);
for (int i = 0; i < srcColor.length; i++) {
model.recolor(srcColor[i], dstColor[i]);
}
}
return model;
}
public boolean method195(int j) {
int k = anInt165;
int l = anInt188;
int i1 = anInt185;
if (j == 1) {
k = anInt200;
l = anInt164;
i1 = anInt162;
public boolean validateWornModel(int gender) {
int m0 = maleModelId0;
int m1 = maleModelId1;
int m2 = maleModelId2;
if (gender == 1) {
m0 = femaleModelId0;
m1 = femaleModelId1;
m2 = femaleModelId2;
}
if (k == -1) {
if (m0 == -1) {
return true;
}
boolean flag = true;
if (!Model.validate(k)) {
flag = false;
boolean valid = Model.validate(m0);
if ((m1 != -1) && !Model.validate(m1)) {
valid = false;
}
if ((l != -1) && !Model.validate(l)) {
flag = false;
if ((m2 != -1) && !Model.validate(m2)) {
valid = false;
}
if ((i1 != -1) && !Model.validate(i1)) {
flag = false;
}
return flag;
return valid;
}
public Model method196(int i) {
int j = anInt165;
int k = anInt188;
int l = anInt185;
if (i == 1) {
j = anInt200;
k = anInt164;
l = anInt162;
public Model getWornModel(int gender) {
int m0 = maleModelId0;
int m1 = maleModelId1;
int m2 = maleModelId2;
if (gender == 1) {
m0 = femaleModelId0;
m1 = femaleModelId1;
m2 = femaleModelId2;
}
if (j == -1) {
if (m0 == -1) {
return null;
}
Model model = Model.tryGet(j);
if (k != -1) {
if (l != -1) {
Model model_1 = Model.tryGet(k);
Model model_3 = Model.tryGet(l);
Model[] aclass30_sub2_sub4_sub6_1 = {model, model_1, model_3};
model = new Model(3, aclass30_sub2_sub4_sub6_1);
Model model = Model.tryGet(m0);
if (m1 != -1) {
if (m2 != -1) {
model = new Model(3, new Model[]{model, Model.tryGet(m1), Model.tryGet(m2)});
} else {
Model class30_sub2_sub4_sub6_2 = Model.tryGet(k);
Model[] aclass30_sub2_sub4_sub6 = {model, class30_sub2_sub4_sub6_2};
model = new Model(2, aclass30_sub2_sub4_sub6);
model = new Model(2, new Model[]{model, Model.tryGet(m1)});
}
}
if ((i == 0) && (aByte205 != 0)) {
model.translate(0, aByte205, 0);
if ((gender == 0) && (maleOffsetY != 0)) {
model.translate(0, maleOffsetY, 0);
}
if ((i == 1) && (aByte154 != 0)) {
model.translate(0, aByte154, 0);
if ((gender == 1) && (femaleOffsetY != 0)) {
model.translate(0, femaleOffsetY, 0);
}
if (srcColor != null) {
for (int i1 = 0; i1 < srcColor.length; i1++) {
model.recolor(srcColor[i1], dstColor[i1]);
}
}
return model;
}
public void reset() {
anInt174 = 0;
modelId = 0;
name = null;
description = null;
examine = null;
srcColor = null;
dstColor = null;
iconZoom = 2000;
@@ -393,57 +393,57 @@ public class ObjType {
iconOffsetX = 0;
iconOffsetY = 0;
unusedInt = -1;
aBoolean176 = false;
anInt155 = 1;
stackable = false;
cost = 1;
members = false;
aStringArray168 = null;
aStringArray189 = null;
anInt165 = -1;
anInt188 = -1;
aByte205 = 0;
anInt200 = -1;
anInt164 = -1;
aByte154 = 0;
anInt185 = -1;
anInt162 = -1;
anInt175 = -1;
anInt166 = -1;
anInt197 = -1;
anInt173 = -1;
groundOptions = null;
inventoryOptions = null;
maleModelId0 = -1;
maleModelId1 = -1;
maleOffsetY = 0;
femaleModelId0 = -1;
femaleModelId1 = -1;
femaleOffsetY = 0;
maleModelId2 = -1;
femaleModelId2 = -1;
maleHeadModelId0 = -1;
maleHeadModelId1 = -1;
femaleHeadModel0 = -1;
femaleHeadModel1 = -1;
stackId = null;
stackAmount = null;
anInt179 = -1;
linkedId = -1;
certificateId = -1;
scaleX = 128;
scaleZ = 128;
scaleY = 128;
anInt196 = 0;
anInt184 = 0;
anInt202 = 0;
lightAmbient = 0;
lightAttenuation = 0;
team = 0;
}
public void link() {
ObjType type = get(linkedId);
anInt174 = type.anInt174;
iconZoom = type.iconZoom;
iconPitch = type.iconPitch;
iconYaw = type.iconYaw;
iconRoll = type.iconRoll;
iconOffsetX = type.iconOffsetX;
iconOffsetY = type.iconOffsetY;
srcColor = type.srcColor;
dstColor = type.dstColor;
ObjType type_1 = get(anInt179);
name = type_1.name;
members = type_1.members;
anInt155 = type_1.anInt155;
public void toCertificate() {
ObjType cert = get(certificateId);
modelId = cert.modelId;
iconZoom = cert.iconZoom;
iconPitch = cert.iconPitch;
iconYaw = cert.iconYaw;
iconRoll = cert.iconRoll;
iconOffsetX = cert.iconOffsetX;
iconOffsetY = cert.iconOffsetY;
srcColor = cert.srcColor;
dstColor = cert.dstColor;
ObjType linked = get(linkedId);
name = linked.name;
members = linked.members;
cost = linked.cost;
String s = "a";
char c = type_1.name.charAt(0);
char c = linked.name.charAt(0);
if ((c == 'A') || (c == 'E') || (c == 'I') || (c == 'O') || (c == 'U')) {
s = "an";
}
description = ("Swap this note at any bank for " + s + " " + type_1.name + ".").getBytes();
aBoolean176 = true;
examine = ("Swap this note at any bank for " + s + " " + linked.name + ".").getBytes();
stackable = true;
}
public Model getModel(int amount) {
@@ -465,7 +465,7 @@ public class ObjType {
return model;
}
model = Model.tryGet(anInt174);
model = Model.tryGet(modelId);
if (model == null) {
return null;
@@ -481,25 +481,25 @@ public class ObjType {
}
}
model.calculateNormals(64 + anInt196, 768 + anInt184, -50, -10, -50, true);
model.pickBounds = true;
model.calculateNormals(64 + lightAmbient, 768 + lightAttenuation, -50, -10, -50, true);
model.pickable = true;
modelCache.put(id, model);
return model;
}
public Model method202(int i) {
if ((stackId != null) && (i > 1)) {
public Model getModelUnlit(int amount) {
if ((stackId != null) && (amount > 1)) {
int j = -1;
for (int k = 0; k < 10; k++) {
if ((i >= stackAmount[k]) && (stackAmount[k] != 0)) {
if ((amount >= stackAmount[k]) && (stackAmount[k] != 0)) {
j = stackId[k];
}
}
if (j != -1) {
return get(j).method202(1);
return get(j).getModelUnlit(1);
}
}
Model model = Model.tryGet(anInt174);
Model model = Model.tryGet(modelId);
if (model == null) {
return null;
}
@@ -518,11 +518,11 @@ public class ObjType {
return;
}
if (i == 1) {
anInt174 = buffer.get2U();
modelId = buffer.get2U();
} else if (i == 2) {
name = buffer.getString();
} else if (i == 3) {
description = buffer.getStringRaw();
examine = buffer.getStringRaw();
} else if (i == 4) {
iconZoom = buffer.get2U();
} else if (i == 5) {
@@ -542,34 +542,34 @@ public class ObjType {
} else if (i == 10) {
unusedInt = buffer.get2U();
} else if (i == 11) {
aBoolean176 = true;
stackable = true;
} else if (i == 12) {
anInt155 = buffer.get4();
cost = buffer.get4();
} else if (i == 16) {
members = true;
} else if (i == 23) {
anInt165 = buffer.get2U();
aByte205 = buffer.get1();
maleModelId0 = buffer.get2U();
maleOffsetY = buffer.get1();
} else if (i == 24) {
anInt188 = buffer.get2U();
maleModelId1 = buffer.get2U();
} else if (i == 25) {
anInt200 = buffer.get2U();
aByte154 = buffer.get1();
femaleModelId0 = buffer.get2U();
femaleOffsetY = buffer.get1();
} else if (i == 26) {
anInt164 = buffer.get2U();
femaleModelId1 = buffer.get2U();
} else if ((i >= 30) && (i < 35)) {
if (aStringArray168 == null) {
aStringArray168 = new String[5];
if (groundOptions == null) {
groundOptions = new String[5];
}
aStringArray168[i - 30] = buffer.getString();
if (aStringArray168[i - 30].equalsIgnoreCase("hidden")) {
aStringArray168[i - 30] = null;
groundOptions[i - 30] = buffer.getString();
if (groundOptions[i - 30].equalsIgnoreCase("hidden")) {
groundOptions[i - 30] = null;
}
} else if ((i >= 35) && (i < 40)) {
if (aStringArray189 == null) {
aStringArray189 = new String[5];
if (inventoryOptions == null) {
inventoryOptions = new String[5];
}
aStringArray189[i - 35] = buffer.getString();
inventoryOptions[i - 35] = buffer.getString();
} else if (i == 40) {
int j = buffer.get1U();
srcColor = new int[j];
@@ -579,23 +579,23 @@ public class ObjType {
dstColor[k] = buffer.get2U();
}
} else if (i == 78) {
anInt185 = buffer.get2U();
maleModelId2 = buffer.get2U();
} else if (i == 79) {
anInt162 = buffer.get2U();
femaleModelId2 = buffer.get2U();
} else if (i == 90) {
anInt175 = buffer.get2U();
maleHeadModelId0 = buffer.get2U();
} else if (i == 91) {
anInt197 = buffer.get2U();
femaleHeadModel0 = buffer.get2U();
} else if (i == 92) {
anInt166 = buffer.get2U();
maleHeadModelId1 = buffer.get2U();
} else if (i == 93) {
anInt173 = buffer.get2U();
femaleHeadModel1 = buffer.get2U();
} else if (i == 95) {
iconRoll = buffer.get2U();
} else if (i == 97) {
anInt179 = buffer.get2U();
} else if (i == 98) {
linkedId = buffer.get2U();
} else if (i == 98) {
certificateId = buffer.get2U();
} else if ((i >= 100) && (i < 110)) {
if (stackId == null) {
stackId = new int[10];
@@ -610,11 +610,11 @@ public class ObjType {
} else if (i == 112) {
scaleY = buffer.get2U();
} else if (i == 113) {
anInt196 = buffer.get1();
lightAmbient = buffer.get1();
} else if (i == 114) {
anInt184 = buffer.get1() * 5;
lightAttenuation = buffer.get1() * 5;
} else if (i == 115) {
anInt202 = buffer.get1U();
team = buffer.get1U();
}
} while (true);
}
+11 -26
View File
@@ -1,3 +1,5 @@
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -5,7 +7,6 @@ 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 {
@@ -334,22 +335,22 @@ public class OnDemand implements Runnable {
return animIndex.length;
}
public void request(int archive, int file) {
if ((archive < 0) || (archive > storeFileVersions.length) || (file < 0) || (file > storeFileVersions[archive].length)) {
public void request(int store, int file) {
if ((store < 0) || (store > storeFileVersions.length) || (file < 0) || (file > storeFileVersions[store].length)) {
return;
}
if (storeFileVersions[archive][file] == 0) {
if (storeFileVersions[store][file] == 0) {
return;
}
synchronized (lock) {
for (OnDemandRequest request : requests) {
if (request.store == archive && request.file == file) {
if (request.store == store && request.file == file) {
return;
}
}
OnDemandRequest request = new OnDemandRequest();
request.store = archive;
request.store = store;
request.file = file;
request.important = true;
synchronized (queue) {
@@ -492,7 +493,7 @@ public class OnDemand implements Runnable {
}
}
public OnDemandRequest poll() {
public OnDemandRequest poll() throws IOException {
OnDemandRequest request;
synchronized (completed) {
@@ -511,26 +512,10 @@ public class OnDemand implements Runnable {
return request;
}
int i = 0;
try {
GZIPInputStream gzipinputstream = new GZIPInputStream(new ByteArrayInputStream(request.data));
do {
if (i == aByteArray1359.length) {
throw new RuntimeException("buffer overflow!");
}
int k = gzipinputstream.read(aByteArray1359, i, aByteArray1359.length - i);
if (k == -1) {
break;
}
i += k;
} while (true);
} catch (IOException _ex) {
throw new RuntimeException("error unzipping");
}
request.data = new byte[i];
for (int j = 0; j < i; j++) {
request.data[j] = aByteArray1359[j];
try (GzipCompressorInputStream gzis = new GzipCompressorInputStream(new ByteArrayInputStream(request.data))) {
request.data = gzis.readAllBytes();
}
return request;
}
+53 -50
View File
@@ -8,12 +8,12 @@ public class PlayerEntity extends PathingEntity {
public static LRUMap<Long, Model> modelCache = new LRUMap<>(260);
public final int[] anIntArray1700 = new int[5];
public final int[] anIntArray1717 = new int[12];
public final int[] appearance = new int[12];
public long aLong1697 = -1L;
public NPCType aType_1698;
public boolean aBoolean1699 = false;
public int anInt1701;
public int anInt1702;
public int team;
public int gender;
public String aString1703;
public int anInt1705;
public int anInt1706;
@@ -45,7 +45,7 @@ public class PlayerEntity extends PathingEntity {
return null;
}
super.anInt1507 = model.minY;
model.pickBounds = true;
model.pickable = true;
if (aBoolean1699) {
return model;
}
@@ -99,32 +99,32 @@ public class PlayerEntity extends PathingEntity {
model_1.translate(super.x - anInt1711, y - anInt1712, super.z - anInt1713);
}
}
model.pickBounds = true;
model.pickable = true;
return model;
}
public void method451(Buffer buffer) {
buffer.position = 0;
anInt1702 = buffer.get1U();
gender = buffer.get1U();
anInt1706 = buffer.get1U();
aType_1698 = null;
anInt1701 = 0;
team = 0;
for (int j = 0; j < 12; j++) {
int k = buffer.get1U();
if (k == 0) {
anIntArray1717[j] = 0;
appearance[j] = 0;
continue;
}
int i1 = buffer.get1U();
anIntArray1717[j] = (k << 8) + i1;
if ((j == 0) && (anIntArray1717[0] == 65535)) {
appearance[j] = (k << 8) + i1;
if ((j == 0) && (appearance[0] == 65535)) {
aType_1698 = NPCType.get(buffer.get2U());
break;
}
if ((anIntArray1717[j] >= 512) && ((anIntArray1717[j] - 512) < ObjType.anInt203)) {
int l1 = ObjType.get(anIntArray1717[j] - 512).anInt202;
if ((appearance[j] >= 512) && ((appearance[j] - 512) < ObjType.count)) {
int l1 = ObjType.get(appearance[j] - 512).team;
if (l1 != 0) {
anInt1701 = l1;
team = l1;
}
}
}
@@ -170,22 +170,22 @@ public class PlayerEntity extends PathingEntity {
aLong1718 = 0L;
for (int k1 = 0; k1 < 12; k1++) {
aLong1718 <<= 4;
if (anIntArray1717[k1] >= 256) {
aLong1718 += anIntArray1717[k1] - 256;
if (appearance[k1] >= 256) {
aLong1718 += appearance[k1] - 256;
}
}
if (anIntArray1717[0] >= 256) {
aLong1718 += (anIntArray1717[0] - 256) >> 4;
if (appearance[0] >= 256) {
aLong1718 += (appearance[0] - 256) >> 4;
}
if (anIntArray1717[1] >= 256) {
aLong1718 += (anIntArray1717[1] - 256) >> 8;
if (appearance[1] >= 256) {
aLong1718 += (appearance[1] - 256) >> 8;
}
for (int i2 = 0; i2 < 5; i2++) {
aLong1718 <<= 3;
aLong1718 += anIntArray1700[i2];
}
aLong1718 <<= 1;
aLong1718 += anInt1702;
aLong1718 += gender;
}
public Model method452() {
@@ -211,30 +211,32 @@ public class PlayerEntity extends PathingEntity {
}
if (type.anInt360 >= 0) {
j1 = type.anInt360;
l += ((long) j1 - anIntArray1717[5]) << 8;
l += ((long) j1 - appearance[5]) << 8;
}
if (type.anInt361 >= 0) {
k1 = type.anInt361;
l += ((long) k1 - anIntArray1717[3]) << 16;
l += ((long) k1 - appearance[3]) << 16;
}
} else if (super.seqCurrent >= 0) {
k = SeqType.instances[super.seqCurrent].primaryFrames[super.seqFrame];
}
Model model_1 = modelCache.get(l);
if (model_1 == null) {
boolean flag = false;
for (int i2 = 0; i2 < 12; i2++) {
int k2 = anIntArray1717[i2];
if ((k1 >= 0) && (i2 == 3)) {
k2 = k1;
for (int part = 0; part < 12; part++) {
int value = appearance[part];
if ((k1 >= 0) && (part == 3)) {
value = k1;
}
if ((j1 >= 0) && (i2 == 5)) {
k2 = j1;
if ((j1 >= 0) && (part == 5)) {
value = j1;
}
if ((k2 >= 256) && (k2 < 512) && !IDKType.instances[k2 - 256].method537()) {
if ((value >= 256) && (value < 512) && !IDKType.instances[value - 256].method537()) {
flag = true;
}
if ((k2 >= 512) && !ObjType.get(k2 - 512).method195(anInt1702)) {
if ((value >= 512) && !ObjType.get(value - 512).validateWornModel(gender)) {
flag = true;
}
}
@@ -247,31 +249,32 @@ public class PlayerEntity extends PathingEntity {
}
}
}
if (model_1 == null) {
Model[] aclass30_sub2_sub4_sub6 = new Model[12];
int j2 = 0;
for (int l2 = 0; l2 < 12; l2++) {
int i3 = anIntArray1717[l2];
if ((k1 >= 0) && (l2 == 3)) {
i3 = k1;
Model[] models = new Model[12];
int modelCount = 0;
for (int part = 0; part < 12; part++) {
int value = appearance[part];
if ((k1 >= 0) && (part == 3)) {
value = k1;
}
if ((j1 >= 0) && (l2 == 5)) {
i3 = j1;
if ((j1 >= 0) && (part == 5)) {
value = j1;
}
if ((i3 >= 256) && (i3 < 512)) {
Model model_3 = IDKType.instances[i3 - 256].method538();
if ((value >= 256) && (value < 512)) {
Model model_3 = IDKType.instances[value - 256].method538();
if (model_3 != null) {
aclass30_sub2_sub4_sub6[j2++] = model_3;
models[modelCount++] = model_3;
}
}
if (i3 >= 512) {
Model class30_sub2_sub4_sub6_4 = ObjType.get(i3 - 512).method196(anInt1702);
if (class30_sub2_sub4_sub6_4 != null) {
aclass30_sub2_sub4_sub6[j2++] = class30_sub2_sub4_sub6_4;
if (value >= 512) {
Model model = ObjType.get(value - 512).getWornModel(gender);
if (model != null) {
models[modelCount++] = model;
}
}
}
model_1 = new Model(j2, aclass30_sub2_sub4_sub6);
model_1 = new Model(modelCount, models);
for (int j3 = 0; j3 < 5; j3++) {
if (anIntArray1700[j3] != 0) {
model_1.recolor(Game.anIntArrayArray1003[j3][0], Game.anIntArrayArray1003[j3][anIntArray1700[j3]]);
@@ -315,11 +318,11 @@ public class PlayerEntity extends PathingEntity {
}
boolean flag = false;
for (int i = 0; i < 12; i++) {
int j = anIntArray1717[i];
int j = appearance[i];
if ((j >= 256) && (j < 512) && !IDKType.instances[j - 256].method539()) {
flag = true;
}
if ((j >= 512) && !ObjType.get(j - 512).method192(anInt1702)) {
if ((j >= 512) && !ObjType.get(j - 512).validateHeadModel(gender)) {
flag = true;
}
}
@@ -329,7 +332,7 @@ public class PlayerEntity extends PathingEntity {
Model[] aclass30_sub2_sub4_sub6 = new Model[12];
int k = 0;
for (int l = 0; l < 12; l++) {
int i1 = anIntArray1717[l];
int i1 = appearance[l];
if ((i1 >= 256) && (i1 < 512)) {
Model model_1 = IDKType.instances[i1 - 256].method540();
if (model_1 != null) {
@@ -337,7 +340,7 @@ public class PlayerEntity extends PathingEntity {
}
}
if (i1 >= 512) {
Model class30_sub2_sub4_sub6_2 = ObjType.get(i1 - 512).method194(anInt1702);
Model class30_sub2_sub4_sub6_2 = ObjType.get(i1 - 512).getHeadModel(gender);
if (class30_sub2_sub4_sub6_2 != null) {
aclass30_sub2_sub4_sub6[k++] = class30_sub2_sub4_sub6_2;
}
+44 -35
View File
@@ -166,8 +166,8 @@ public class Scene {
public final int[][][] planeTileOcclusionCycles;
public final int[] anIntArray486 = new int[10000];
public final int[] anIntArray487 = new int[10000];
public final int[][] anIntArrayArray489 = {new int[16], {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1}, {0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1}, {1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1}};
public final int[][] anIntArrayArray490 = {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {12, 8, 4, 0, 13, 9, 5, 1, 14, 10, 6, 2, 15, 11, 7, 3}, {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, {3, 7, 11, 15, 2, 6, 10, 14, 1, 5, 9, 13, 0, 4, 8, 12}};
public final int[][] MINIMAP_TILE_MASK = {new int[16], {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1}, {0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1}, {1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1}};
public final int[][] MINIMAP_TILE_ROTATION_MAP = {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {12, 8, 4, 0, 13, 9, 5, 1, 14, 10, 6, 2, 15, 11, 7, 3}, {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, {3, 7, 11, 15, 2, 6, 10, 14, 1, 5, 9, 13, 0, 4, 8, 12}};
public int minPlane;
public int temporaryLocCount;
public int anInt488;
@@ -863,61 +863,70 @@ public class Scene {
}
}
public void drawMinimapTile(int[] ai, int i, int j, int k, int l, int i1) {
SceneTile tile = planeTiles[k][l][i1];
public void drawMinimapTile(int[] dst, int offset, int step, int plane, int x, int z) {
SceneTile tile = planeTiles[plane][x][z];
if (tile == null) {
return;
}
SceneTileUnderlay underlay = tile.underlay;
if (underlay != null) {
int j1 = underlay.anInt722;
if (j1 == 0) {
int rgb = underlay.rgb;
if (rgb == 0) {
return;
}
for (int k1 = 0; k1 < 4; k1++) {
ai[i] = j1;
ai[i + 1] = j1;
ai[i + 2] = j1;
ai[i + 3] = j1;
i += j;
dst[offset] = rgb;
dst[offset + 1] = rgb;
dst[offset + 2] = rgb;
dst[offset + 3] = rgb;
offset += step;
}
return;
}
SceneTileOverlay overlay = tile.overlay;
if (overlay == null) {
return;
}
int l1 = overlay.anInt684;
int i2 = overlay.anInt685;
int j2 = overlay.anInt686;
int k2 = overlay.anInt687;
int[] ai1 = anIntArrayArray489[l1];
int[] ai2 = anIntArrayArray490[i2];
int l2 = 0;
if (j2 != 0) {
for (int i3 = 0; i3 < 4; i3++) {
ai[i] = (ai1[ai2[l2++]] != 0) ? k2 : j2;
ai[i + 1] = (ai1[ai2[l2++]] != 0) ? k2 : j2;
ai[i + 2] = (ai1[ai2[l2++]] != 0) ? k2 : j2;
ai[i + 3] = (ai1[ai2[l2++]] != 0) ? k2 : j2;
i += j;
int shape = overlay.shape;
int angle = overlay.angle;
int background = overlay.backgroundRGB;
int foreground = overlay.foregroundRGB;
int[] mask = MINIMAP_TILE_MASK[shape];
int[] rotation = MINIMAP_TILE_ROTATION_MAP[angle];
int off = 0;
if (background != 0) {
for (int i = 0; i < 4; i++) {
dst[offset] = (mask[rotation[off++]] != 0) ? foreground : background;
dst[offset + 1] = (mask[rotation[off++]] != 0) ? foreground : background;
dst[offset + 2] = (mask[rotation[off++]] != 0) ? foreground : background;
dst[offset + 3] = (mask[rotation[off++]] != 0) ? foreground : background;
offset += step;
}
return;
}
for (int j3 = 0; j3 < 4; j3++) {
if (ai1[ai2[l2++]] != 0) {
ai[i] = k2;
for (int i = 0; i < 4; i++) {
if (mask[rotation[off++]] != 0) {
dst[offset] = foreground;
}
if (ai1[ai2[l2++]] != 0) {
ai[i + 1] = k2;
if (mask[rotation[off++]] != 0) {
dst[offset + 1] = foreground;
}
if (ai1[ai2[l2++]] != 0) {
ai[i + 2] = k2;
if (mask[rotation[off++]] != 0) {
dst[offset + 2] = foreground;
}
if (ai1[ai2[l2++]] != 0) {
ai[i + 3] = k2;
if (mask[rotation[off++]] != 0) {
dst[offset + 3] = foreground;
}
i += j;
offset += step;
}
}
+5 -5
View File
@@ -547,21 +547,21 @@ public class SceneBuilder {
int i_59_ = ((aByteArrayArrayArray136[plane][i_29_][i_40_]) + 1);
byte i_60_ = (aByteArrayArrayArray148[plane][i_29_][i_40_]);
FloType type = FloType.instances[i_44_ - 1];
int i_61_ = type.anInt391;
int textureId = type.textureId;
int i_62_;
int i_63_;
if (i_61_ >= 0) {
i_62_ = Draw3D.getAverageTextureRGB(i_61_);
if (textureId >= 0) {
i_62_ = Draw3D.getAverageTextureRGB(textureId);
i_63_ = -1;
} else if (type.anInt390 == 16711935) {
i_62_ = 0;
i_63_ = -2;
i_61_ = -1;
textureId = -1;
} else {
i_63_ = method177(type.anInt394, type.anInt395, type.anInt396);
i_62_ = (Draw3D.palette[method185(type.anInt399, 96)]);
}
scene.method279(plane, i_29_, i_40_, i_59_, i_60_, i_61_, i_45_, i_46_, i_47_, i_48_, method187(i_53_, i_49_), method187(i_53_, i_50_), method187(i_53_, i_51_), method187(i_53_, i_52_), method185(i_63_, i_49_), method185(i_63_, i_50_), method185(i_63_, i_51_), method185(i_63_, i_52_), i_58_, i_62_);
scene.method279(plane, i_29_, i_40_, i_59_, i_60_, textureId, i_45_, i_46_, i_47_, i_48_, method187(i_53_, i_49_), method187(i_53_, i_50_), method187(i_53_, i_51_), method187(i_53_, i_52_), method185(i_63_, i_49_), method185(i_63_, i_50_), method185(i_63_, i_51_), method185(i_63_, i_52_), i_58_, i_62_);
}
}
}
+8 -8
View File
@@ -519,22 +519,22 @@ public class SceneCollisionMap {
return false;
}
public boolean method221(int i, int j, int k, int l, int i1, int j1, int k1) {
int l1 = (j + j1) - 1;
int i2 = (i + l) - 1;
if ((k >= j) && (k <= l1) && (k1 >= i) && (k1 <= i2)) {
public boolean method221(int z0, int x0, int x, int sizeZ, int flags, int sizeX, int z) {
int x1 = (x0 + sizeX) - 1;
int z1 = (z0 + sizeZ) - 1;
if ((x >= x0) && (x <= x1) && (z >= z0) && (z <= z1)) {
return true;
}
if ((k == (j - 1)) && (k1 >= i) && (k1 <= i2) && ((flags[k - anInt290][k1 - anInt291] & 8) == 0) && ((i1 & 8) == 0)) {
if ((x == (x0 - 1)) && (z >= z0) && (z <= z1) && ((this.flags[x - anInt290][z - anInt291] & 8) == 0) && ((flags & 8) == 0)) {
return true;
}
if ((k == (l1 + 1)) && (k1 >= i) && (k1 <= i2) && ((flags[k - anInt290][k1 - anInt291] & 0x80) == 0) && ((i1 & 2) == 0)) {
if ((x == (x1 + 1)) && (z >= z0) && (z <= z1) && ((this.flags[x - anInt290][z - anInt291] & 0x80) == 0) && ((flags & 2) == 0)) {
return true;
}
if ((k1 == (i - 1)) && (k >= j) && (k <= l1) && ((flags[k - anInt290][k1 - anInt291] & 2) == 0) && ((i1 & 4) == 0)) {
if ((z == (z0 - 1)) && (x >= x0) && (x <= x1) && ((this.flags[x - anInt290][z - anInt291] & 2) == 0) && ((flags & 4) == 0)) {
return true;
}
return (k1 == (i2 + 1)) && (k >= j) && (k <= l1) && ((flags[k - anInt290][k1 - anInt291] & 0x20) == 0) && ((i1 & 1) == 0);
return (z == (z1 + 1)) && (x >= x0) && (x <= x1) && ((this.flags[x - anInt290][z - anInt291] & 0x20) == 0) && ((flags & 1) == 0);
}
}
+8 -8
View File
@@ -21,18 +21,18 @@ public class SceneTileOverlay {
public final int[] anIntArray680;
public final int[] anIntArray681;
public final boolean aBoolean683;
public final int anInt684;
public final int anInt685;
public final int anInt686;
public final int anInt687;
public final int shape;
public final int angle;
public final int backgroundRGB;
public final int foregroundRGB;
public int[] anIntArray682;
public SceneTileOverlay(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2, int j2, int k2, int l2, int i3, int j3, int k3, int l3, int i4, int k4, int l4) {
aBoolean683 = (i3 == l2) && (i3 == l) && (i3 == k2);
anInt684 = j3;
anInt685 = k1;
anInt686 = i2;
anInt687 = l4;
shape = j3;
angle = k1;
backgroundRGB = i2;
foregroundRGB = l4;
char c = '\200';
int i5 = c / 2;
int j5 = c / 4;
+2 -2
View File
@@ -9,7 +9,7 @@ public class SceneTileUnderlay {
public final int anInt718;
public final int anInt719;
public final int anInt720;
public final int anInt722;
public final int rgb;
public boolean aBoolean721;
public SceneTileUnderlay(int i, int j, int k, int l, int i1, int j1, boolean flag) {
@@ -19,7 +19,7 @@ public class SceneTileUnderlay {
anInt718 = k;
anInt719 = l;
anInt720 = i1;
anInt722 = j1;
rgb = j1;
aBoolean721 = flag;
}
+151 -150
View File
@@ -6,181 +6,182 @@
*/
public class SeqFrame {
private static SeqFrame[] instances;
public static SeqFrame[] instances;
/**
* Syntax sugar.
*
* @param id the id
* @return <code>id == -1</code>
*/
public static boolean isNull(int id) {
return id == -1;
}
/**
* Syntax sugar.
*
* @param id the id
* @return <code>id == -1</code>
*/
public static boolean isNull(int id) {
return id == -1;
}
/**
* Initializes the array of instances.
*
* @param count the count
*/
public static void init(int count) {
instances = new SeqFrame[count + 1];
}
/**
* Initializes the array of instances.
*
* @param count the count
*/
public static void init(int count) {
instances = new SeqFrame[count + 1];
}
/**
* Nullifies the array of instances.
*/
public static void unload() {
instances = null;
}
/**
* Nullifies the array of instances.
*/
public static void unload() {
instances = null;
}
/**
* Gets the {@link SeqFrame}
*
* @param id the frame id.
* @return the {@link SeqFrame} or <code>null</code> if it does not exist.
*/
public static SeqFrame get(int id) {
if ((instances == null) || (id < 0) || (id >= instances.length)) {
return null;
} else {
return instances[id];
}
}
/**
* Gets the {@link SeqFrame}
*
* @param id the frame id.
* @return the {@link SeqFrame} or <code>null</code> if it does not exist.
*/
public static SeqFrame get(int id) {
if ((instances == null) || (id < 0) || (id >= instances.length)) {
return null;
} else {
return instances[id];
}
}
/**
* Reads the animation data and stores its frames in {@link #instances}.
* <p>
* <b>Note:</b> This method can read <i>multiple</i> {@link SeqFrame} which means the input data can be an entire working
* animation.
*
* @param src the animation data.
* @see #get(int)
*/
public static void unpack(byte[] src) {
Buffer offsets = new Buffer(src);
offsets.position = src.length - 8;
/**
* Reads the animation data and stores its frames in {@link #instances}.
* <p>
* <b>Note:</b> This method can read <i>multiple</i> {@link SeqFrame} which means the input data can be an entire working
* animation.
*
* @param src the animation data.
* @see #get(int)
*/
public static void unpack(byte[] src) {
Buffer offsets = new Buffer(src);
offsets.position = src.length - 8;
Buffer header = new Buffer(src);
Buffer tran1 = new Buffer(src);
Buffer tran2 = new Buffer(src);
Buffer del = new Buffer(src);
Buffer skel = new Buffer(src);
Buffer header = new Buffer(src);
Buffer tran1 = new Buffer(src);
Buffer tran2 = new Buffer(src);
Buffer del = new Buffer(src);
Buffer skel = new Buffer(src);
int offset = 0;
header.position = offset;
offset += offsets.get2U() + 2;
int offset = 0;
header.position = offset;
offset += offsets.get2U() + 2;
tran1.position = offset;
offset += offsets.get2U();
tran1.position = offset;
offset += offsets.get2U();
tran2.position = offset;
offset += offsets.get2U();
tran2.position = offset;
offset += offsets.get2U();
del.position = offset;
offset += offsets.get2U();
del.position = offset;
offset += offsets.get2U();
skel.position = offset;
skel.position = offset;
SeqSkeleton skeleton = new SeqSkeleton(skel);
SeqSkeleton skeleton = new SeqSkeleton(skel);
int frameCount = header.get2U();
int[] bases = new int[500];
int[] x = new int[500];
int[] y = new int[500];
int[] z = new int[500];
int frameCount = header.get2U();
int[] bases = new int[500];
int[] x = new int[500];
int[] y = new int[500];
int[] z = new int[500];
for (int i = 0; i < frameCount; i++) {
SeqFrame frame = instances[header.get2U()] = new SeqFrame();
frame.delay = del.get1U();
frame.skeleton = skeleton;
for (int i = 0; i < frameCount; i++) {
SeqFrame frame = instances[header.get2U()] = new SeqFrame();
frame.delay = del.get1U();
frame.skeleton = skeleton;
int baseCount = header.get1U();
int lastBase = -1;
int length = 0;
for (int base = 0; base < baseCount; base++) {
int flags = tran1.get1U();
int baseCount = header.get1U();
int lastBase = -1;
int length = 0;
for (int base = 0; base < baseCount; base++) {
int flags = tran1.get1U();
if (flags <= 0) {
continue;
}
if (flags <= 0) {
continue;
}
if (skeleton.baseTypes[base] != SeqSkeleton.OP_BASE) {
for (int cur = base - 1; cur > lastBase; cur--) {
if (skeleton.baseTypes[cur] == SeqSkeleton.OP_BASE) {
bases[length] = cur;
x[length] = 0;
y[length] = 0;
z[length] = 0;
length++;
break;
}
}
}
if (skeleton.baseTypes[base] != SeqSkeleton.OP_BASE) {
for (int cur = base - 1; cur > lastBase; cur--) {
if (skeleton.baseTypes[cur] == SeqSkeleton.OP_BASE) {
bases[length] = cur;
x[length] = 0;
y[length] = 0;
z[length] = 0;
length++;
break;
}
}
}
bases[length] = base;
bases[length] = base;
int defaultValue = 0;
int defaultValue = 0;
if (skeleton.baseTypes[base] == SeqSkeleton.OP_SCALE) {
defaultValue = 128;
}
if (skeleton.baseTypes[base] == SeqSkeleton.OP_SCALE) {
defaultValue = 128;
}
if ((flags & 1) != 0) {
x[length] = tran2.getSmart();
} else {
x[length] = defaultValue;
}
if ((flags & 1) != 0) {
x[length] = tran2.getSmart();
} else {
x[length] = defaultValue;
}
if ((flags & 2) != 0) {
y[length] = tran2.getSmart();
} else {
y[length] = defaultValue;
}
if ((flags & 2) != 0) {
y[length] = tran2.getSmart();
} else {
y[length] = defaultValue;
}
if ((flags & 4) != 0) {
z[length] = tran2.getSmart();
} else {
z[length] = defaultValue;
}
if ((flags & 4) != 0) {
z[length] = tran2.getSmart();
} else {
z[length] = defaultValue;
}
lastBase = base;
length++;
}
lastBase = base;
length++;
}
frame.length = length;
frame.bases = new int[length];
frame.x = new int[length];
frame.y = new int[length];
frame.z = new int[length];
frame.length = length;
frame.bases = new int[length];
frame.x = new int[length];
frame.y = new int[length];
frame.z = new int[length];
for (int j = 0; j < length; j++) {
frame.bases[j] = bases[j];
frame.x[j] = x[j];
frame.y[j] = y[j];
frame.z[j] = z[j];
}
}
}
/**
* The skeleton associated to this frame.
*/
public SeqSkeleton skeleton;
/**
* The delay in <code>ticks</code>.
*/
public int delay;
/**
* The number of operations the frame performs.
*/
public int length;
/**
* The list of bases the frame uses.
*/
public int[] bases;
/**
* The frame parameters.
*/
public int[] x, y, z;
for (int j = 0; j < length; j++) {
frame.bases[j] = bases[j];
frame.x[j] = x[j];
frame.y[j] = y[j];
frame.z[j] = z[j];
}
}
}
/**
* The skeleton associated to this frame.
*/
public SeqSkeleton skeleton;
/**
* The delay in <code>ticks</code>.
*/
public int delay;
/**
* The number of operations the frame performs.
*/
public int length;
/**
* The list of bases the frame uses.
*/
public int[] bases;
/**
* The frame parameters.
*/
public int[] x, y, z;
}
+9 -9
View File
@@ -7,8 +7,8 @@
public class SoundEnvelope {
public int length;
public int[] durations;
public int[] peaks;
public int[] shapeDelta;
public int[] shapePeak;
public int start;
public int end;
public int form;
@@ -30,11 +30,11 @@ public class SoundEnvelope {
public void readShape(Buffer buffer) {
length = buffer.get1U();
durations = new int[length];
peaks = new int[length];
shapeDelta = new int[length];
shapePeak = new int[length];
for (int i = 0; i < length; i++) {
durations[i] = buffer.get2U();
peaks[i] = buffer.get2U();
shapeDelta[i] = buffer.get2U();
shapePeak[i] = buffer.get2U();
}
}
@@ -48,13 +48,13 @@ public class SoundEnvelope {
public int evaluate(int delta) {
if (ticks >= threshold) {
amplitude = peaks[position++] << 15;
amplitude = shapePeak[position++] << 15;
if (position >= length) {
position = length - 1;
}
threshold = (int) (((double) durations[position] / 65536D) * (double) delta);
threshold = (int) (((double) shapeDelta[position] / 65536D) * (double) delta);
if (threshold > ticks) {
this.delta = ((peaks[position] << 15) - amplitude) / (threshold - ticks);
this.delta = ((shapePeak[position] << 15) - amplitude) / (threshold - ticks);
}
}
amplitude += this.delta;
+158 -143
View File
@@ -1,173 +1,188 @@
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
public class SoundTrack {
public static final SoundTrack[] tracks = new SoundTrack[5000];
public static final int[] delays = new int[5000];
public static byte[] bbuf;
public static Buffer buffer;
public static final SoundTrack[] tracks = new SoundTrack[5000];
public static final int[] delays = new int[5000];
public static byte[] bbuf;
public static Buffer buffer;
public static void method240(Buffer src) {
bbuf = new byte[441000];
public static void method240(Buffer src) {
bbuf = new byte[441000];
SoundTrack.buffer = new Buffer(bbuf);
SoundTone.init();
SoundTrack.buffer = new Buffer(bbuf);
SoundTone.init();
do {
int id = src.get2U();
if (id == 65535) {
return;
}
tracks[id] = new SoundTrack();
tracks[id].read(src);
delays[id] = tracks[id].trim();
} while (true);
}
do {
int id = src.get2U();
if (id == 65535) {
return;
}
public static Buffer generate(int loopCount, int id) {
if (tracks[id] != null) {
SoundTrack track = tracks[id];
return track.getWaveform(loopCount);
} else {
return null;
}
}
int start = src.position;
tracks[id] = new SoundTrack();
tracks[id].read(src);
int end = src.position;
public final SoundTone[] tones = new SoundTone[10];
public int loopBegin;
public int loopEnd;
try (OutputStream out = Files.newOutputStream(Paths.get(String.format("377_synth/%d.synth", id)))) {
out.write(src.data,start,end-start);
} catch (IOException e) {
e.printStackTrace();
}
public SoundTrack() {
}
delays[id] = tracks[id].trim();
} while (true);
}
public void read(Buffer buffer) {
for (int tone = 0; tone < 10; tone++) {
if (buffer.get1U() != 0) {
buffer.position--;
tones[tone] = new SoundTone();
tones[tone].read(buffer);
}
}
loopBegin = buffer.get2U();
loopEnd = buffer.get2U();
}
public static Buffer generate(int loopCount, int id) {
if (tracks[id] != null) {
SoundTrack track = tracks[id];
return track.getWaveform(loopCount);
} else {
return null;
}
}
public int trim() {
int start = 9999999;
for (int tone = 0; tone < 10; tone++) {
if ((tones[tone] != null) && ((tones[tone].start / 20) < start)) {
start = tones[tone].start / 20;
}
}
public final SoundTone[] tones = new SoundTone[10];
public int loopBegin;
public int loopEnd;
if ((loopBegin < loopEnd) && ((loopBegin / 20) < start)) {
start = loopBegin / 20;
}
public SoundTrack() {
}
if ((start == 9999999) || (start == 0)) {
return 0;
}
public void read(Buffer buffer) {
for (int tone = 0; tone < 10; tone++) {
if (buffer.get1U() != 0) {
buffer.position--;
tones[tone] = new SoundTone();
tones[tone].read(buffer);
}
}
loopBegin = buffer.get2U();
loopEnd = buffer.get2U();
}
for (int tone = 0; tone < 10; tone++) {
if (tones[tone] != null) {
tones[tone].start -= start * 20;
}
}
if (loopBegin < loopEnd) {
loopBegin -= start * 20;
loopEnd -= start * 20;
}
return start;
}
public int trim() {
int start = 9999999;
for (int tone = 0; tone < 10; tone++) {
if ((tones[tone] != null) && ((tones[tone].start / 20) < start)) {
start = tones[tone].start / 20;
}
}
/**
* <a href="http://soundfile.sapp.org/doc/WaveFormat/">WaveFormat</a>
*
* @param loopCount the loop count.
* @return the {@link Buffer} containing the waveform data.
*/
public Buffer getWaveform(int loopCount) {
int length = generate(loopCount);
buffer.position = 0;
buffer.put4(0x52494646); // "RIFF" ChunkID
buffer.put4LE(36 + length); // ChunkSize
buffer.put4(0x57415645); // "WAVE" format
buffer.put4(0x666d7420); // "fmt " chunk id
buffer.put4LE(16); // chunk size
buffer.put2LE(1); // audio format
buffer.put2LE(1); // num channels
buffer.put4LE(22050); // sample rate
buffer.put4LE(22050); // byte rate
buffer.put2LE(1); // block align
buffer.put2LE(8); // bits per sample
buffer.put4(0x64617461); // "data"
buffer.put4LE(length);
buffer.position += length;
return buffer;
}
if ((loopBegin < loopEnd) && ((loopBegin / 20) < start)) {
start = loopBegin / 20;
}
public int generate(int loopCount) {
int duration = 0;
if ((start == 9999999) || (start == 0)) {
return 0;
}
for (int tone = 0; tone < 10; tone++) {
if ((tones[tone] != null) && ((tones[tone].length + tones[tone].start) > duration)) {
duration = tones[tone].length + tones[tone].start;
}
}
for (int tone = 0; tone < 10; tone++) {
if (tones[tone] != null) {
tones[tone].start -= start * 20;
}
}
if (loopBegin < loopEnd) {
loopBegin -= start * 20;
loopEnd -= start * 20;
}
return start;
}
if (duration == 0) {
return 0;
}
/**
* <a href="http://soundfile.sapp.org/doc/WaveFormat/">WaveFormat</a>
*
* @param loopCount the loop count.
* @return the {@link Buffer} containing the waveform data.
*/
public Buffer getWaveform(int loopCount) {
int length = generate(loopCount);
buffer.position = 0;
buffer.put4(0x52494646); // "RIFF" ChunkID
buffer.put4LE(36 + length); // ChunkSize
buffer.put4(0x57415645); // "WAVE" format
buffer.put4(0x666d7420); // "fmt " chunk id
buffer.put4LE(16); // chunk size
buffer.put2LE(1); // audio format
buffer.put2LE(1); // num channels
buffer.put4LE(22050); // sample rate
buffer.put4LE(22050); // byte rate
buffer.put2LE(1); // block align
buffer.put2LE(8); // bits per sample
buffer.put4(0x64617461); // "data"
buffer.put4LE(length);
buffer.position += length;
return buffer;
}
int sampleCount = (22050 * duration) / 1000;
int loopStart = (22050 * loopBegin) / 1000;
int loopStop = (22050 * loopEnd) / 1000;
public int generate(int loopCount) {
int duration = 0;
if ((loopStart < 0) || (loopStop < 0) || (loopStop > sampleCount) || (loopStart >= loopStop)) {
loopCount = 0;
}
for (int tone = 0; tone < 10; tone++) {
if ((tones[tone] != null) && ((tones[tone].length + tones[tone].start) > duration)) {
duration = tones[tone].length + tones[tone].start;
}
}
int totalSampleCount = sampleCount + ((loopStop - loopStart) * (loopCount - 1));
if (duration == 0) {
return 0;
}
for (int sample = 44; sample < (totalSampleCount + 44); sample++) {
bbuf[sample] = -128;
}
int sampleCount = (22050 * duration) / 1000;
int loopStart = (22050 * loopBegin) / 1000;
int loopStop = (22050 * loopEnd) / 1000;
for (int tone = 0; tone < 10; tone++) {
if (tones[tone] == null) {
continue;
}
if ((loopStart < 0) || (loopStop < 0) || (loopStop > sampleCount) || (loopStart >= loopStop)) {
loopCount = 0;
}
int toneSampleCount = (tones[tone].length * 22050) / 1000;
int start = (tones[tone].start * 22050) / 1000;
int[] samples = tones[tone].generate(toneSampleCount, tones[tone].length);
int totalSampleCount = sampleCount + ((loopStop - loopStart) * (loopCount - 1));
for (int sample = 0; sample < toneSampleCount; sample++) {
bbuf[sample + start + 44] += (byte) (samples[sample] >> 8);
}
}
for (int sample = 44; sample < (totalSampleCount + 44); sample++) {
bbuf[sample] = -128;
}
if (loopCount > 1) {
// All of these 44's are because we're avoiding the area where the WAV header will be written.
loopStart += 44;
loopStop += 44;
sampleCount += 44;
for (int tone = 0; tone < 10; tone++) {
if (tones[tone] == null) {
continue;
}
// 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--) {
bbuf[sample + endOffset] = bbuf[sample];
}
int toneSampleCount = (tones[tone].length * 22050) / 1000;
int start = (tones[tone].start * 22050) / 1000;
int[] samples = tones[tone].generate(toneSampleCount, tones[tone].length);
// Duplicates loop area.
for (int loop = 1; loop < loopCount; loop++) {
int offset = (loopStop - loopStart) * loop;
for (int sample = loopStart; sample < loopStop; sample++) {
bbuf[sample + offset] = bbuf[sample];
}
}
for (int sample = 0; sample < toneSampleCount; sample++) {
bbuf[sample + start + 44] += (byte) (samples[sample] >> 8);
}
}
totalSampleCount -= 44;
}
return totalSampleCount;
}
if (loopCount > 1) {
// All of these 44's are because we're avoiding the area where the WAV header will be written.
loopStart += 44;
loopStop += 44;
sampleCount += 44;
// 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--) {
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++) {
bbuf[sample + offset] = bbuf[sample];
}
}
totalSampleCount -= 44;
}
return totalSampleCount;
}
}
+80 -78
View File
@@ -8,87 +8,89 @@ import java.io.IOException;
public class SpotAnimType {
public static SpotAnimType[] instances;
public static LRUMap<Integer, Model> modelCache = new LRUMap<>(30);
public static int count;
public static SpotAnimType[] instances;
public static LRUMap<Integer, Model> modelCache = new LRUMap<>(30);
public static void unpack(FileArchive archive) throws IOException {
Buffer buffer = new Buffer(archive.read("spotanim.dat"));
int count = buffer.get2U();
if (instances == null) {
instances = new SpotAnimType[count];
}
for (int i = 0; i < count; i++) {
if (instances[i] == null) {
instances[i] = new SpotAnimType();
}
instances[i].index = i;
instances[i].method265(buffer);
}
}
public final int[] anIntArray408 = new int[6];
public final int[] anIntArray409 = new int[6];
public int index;
public int anInt405;
public int anInt406 = -1;
public SeqType seq;
public int anInt410 = 128;
public int anInt411 = 128;
public int anInt412;
public int anInt413;
public int anInt414;
public static void unpack(FileArchive archive) throws IOException {
Buffer buffer = new Buffer(archive.read("spotanim.dat"));
count = buffer.get2U();
if (instances == null) {
instances = new SpotAnimType[count];
}
for (int i = 0; i < count; i++) {
if (instances[i] == null) {
instances[i] = new SpotAnimType();
}
instances[i].index = i;
instances[i].method265(buffer);
}
}
public SpotAnimType() {
}
public final int[] anIntArray408 = new int[6];
public final int[] anIntArray409 = new int[6];
public int index;
public int anInt405;
public int seqId = -1;
public SeqType seq;
public int anInt410 = 128;
public int anInt411 = 128;
public int anInt412;
public int anInt413;
public int anInt414;
public void method265(Buffer buffer) {
do {
int i = buffer.get1U();
if (i == 0) {
return;
}
if (i == 1) {
anInt405 = buffer.get2U();
} else if (i == 2) {
anInt406 = buffer.get2U();
if (SeqType.instances != null) {
seq = SeqType.instances[anInt406];
}
} else if (i == 4) {
anInt410 = buffer.get2U();
} else if (i == 5) {
anInt411 = buffer.get2U();
} else if (i == 6) {
anInt412 = buffer.get2U();
} else if (i == 7) {
anInt413 = buffer.get1U();
} else if (i == 8) {
anInt414 = buffer.get1U();
} else if ((i >= 40) && (i < 50)) {
anIntArray408[i - 40] = buffer.get2U();
} else if ((i >= 50) && (i < 60)) {
anIntArray409[i - 50] = buffer.get2U();
} else {
System.out.println("Error unrecognised spotanim config code: " + i);
}
} while (true);
}
public SpotAnimType() {
}
public Model method266() {
Model model = modelCache.get(index);
if (model != null) {
return model;
}
model = Model.tryGet(anInt405);
if (model == null) {
return null;
}
for (int i = 0; i < 6; i++) {
if (anIntArray408[0] != 0) {
model.recolor(anIntArray408[i], anIntArray409[i]);
}
}
modelCache.put(index, model);
return model;
}
public void method265(Buffer buffer) {
do {
int i = buffer.get1U();
if (i == 0) {
return;
}
if (i == 1) {
anInt405 = buffer.get2U();
} else if (i == 2) {
seqId = buffer.get2U();
if (SeqType.instances != null) {
seq = SeqType.instances[seqId];
}
} else if (i == 4) {
anInt410 = buffer.get2U();
} else if (i == 5) {
anInt411 = buffer.get2U();
} else if (i == 6) {
anInt412 = buffer.get2U();
} else if (i == 7) {
anInt413 = buffer.get1U();
} else if (i == 8) {
anInt414 = buffer.get1U();
} else if ((i >= 40) && (i < 50)) {
anIntArray408[i - 40] = buffer.get2U();
} else if ((i >= 50) && (i < 60)) {
anIntArray409[i - 50] = buffer.get2U();
} else {
System.out.println("Error unrecognised spotanim config code: " + i);
}
} while (true);
}
public Model method266() {
Model model = modelCache.get(index);
if (model != null) {
return model;
}
model = Model.tryGet(anInt405);
if (model == null) {
return null;
}
for (int i = 0; i < 6; i++) {
if (anIntArray408[0] != 0) {
model.recolor(anIntArray408[i], anIntArray409[i]);
}
}
modelCache.put(index, model);
return model;
}
}