Switched from 4 spaces to tabs
This commit is contained in:
1 parent
3965827f25
commit
bb8fa3c5e0
15 files changed
+13467
-13470
No files matched your search
+262
-263
@@ -2,7 +2,6 @@ import org.apache.commons.math3.random.ISAACRandom;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* A {@link Buffer} encapsulates a finite amount of data and provides methods for reading and writing to that data.
|
||||
@@ -29,319 +28,319 @@ import java.util.Arrays;
|
||||
*/
|
||||
public class Buffer extends DoublyLinkedList.Node {
|
||||
|
||||
private static final int[] BITMASK = {0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 0x1ffff, 0x3ffff, 0x7ffff, 0xfffff, 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff, 0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, -1};
|
||||
private static final int[] BITMASK = {0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 0x1ffff, 0x3ffff, 0x7ffff, 0xfffff, 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff, 0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, -1};
|
||||
|
||||
public static Buffer create(int sizeType) {
|
||||
Buffer buffer = new Buffer();
|
||||
buffer.position = 0;
|
||||
public static Buffer create(int sizeType) {
|
||||
Buffer buffer = new Buffer();
|
||||
buffer.position = 0;
|
||||
|
||||
if (sizeType == 0) {
|
||||
buffer.data = new byte[100];
|
||||
} else if (sizeType == 1) {
|
||||
buffer.data = new byte[5000];
|
||||
} else {
|
||||
buffer.data = new byte[30000];
|
||||
}
|
||||
if (sizeType == 0) {
|
||||
buffer.data = new byte[100];
|
||||
} else if (sizeType == 1) {
|
||||
buffer.data = new byte[5000];
|
||||
} else {
|
||||
buffer.data = new byte[30000];
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public byte[] data;
|
||||
public int position;
|
||||
public int bitPosition;
|
||||
public ISAACRandom random;
|
||||
public byte[] data;
|
||||
public int position;
|
||||
public int bitPosition;
|
||||
public ISAACRandom random;
|
||||
|
||||
public Buffer() {
|
||||
}
|
||||
public Buffer() {
|
||||
}
|
||||
|
||||
public Buffer(byte[] src) {
|
||||
data = src;
|
||||
position = 0;
|
||||
}
|
||||
public Buffer(byte[] src) {
|
||||
data = src;
|
||||
position = 0;
|
||||
}
|
||||
|
||||
public void putOp(int i) {
|
||||
data[position++] = (byte) (i + random.nextInt());
|
||||
}
|
||||
public void putOp(int i) {
|
||||
data[position++] = (byte) (i + random.nextInt());
|
||||
}
|
||||
|
||||
public void putSize1(int i) {
|
||||
data[position - i - 1] = (byte) i;
|
||||
}
|
||||
public void putSize1(int i) {
|
||||
data[position - i - 1] = (byte) i;
|
||||
}
|
||||
|
||||
public void put1(int i) {
|
||||
data[position++] = (byte) i;
|
||||
}
|
||||
public void put1(int i) {
|
||||
data[position++] = (byte) i;
|
||||
}
|
||||
|
||||
public void put1C(int i) {
|
||||
data[position++] = (byte) (-i);
|
||||
}
|
||||
public void put1C(int i) {
|
||||
data[position++] = (byte) (-i);
|
||||
}
|
||||
|
||||
public void put1S(int j) {
|
||||
data[position++] = (byte) (128 - j);
|
||||
}
|
||||
public void put1S(int j) {
|
||||
data[position++] = (byte) (128 - j);
|
||||
}
|
||||
|
||||
public void put2(int i) {
|
||||
data[position++] = (byte) (i >> 8);
|
||||
data[position++] = (byte) i;
|
||||
}
|
||||
public void put2(int i) {
|
||||
data[position++] = (byte) (i >> 8);
|
||||
data[position++] = (byte) i;
|
||||
}
|
||||
|
||||
public void put2A(int j) {
|
||||
data[position++] = (byte) (j >> 8);
|
||||
data[position++] = (byte) (j + 128);
|
||||
}
|
||||
public void put2A(int j) {
|
||||
data[position++] = (byte) (j >> 8);
|
||||
data[position++] = (byte) (j + 128);
|
||||
}
|
||||
|
||||
public void put2LE(int i) {
|
||||
data[position++] = (byte) i;
|
||||
data[position++] = (byte) (i >> 8);
|
||||
}
|
||||
public void put2LE(int i) {
|
||||
data[position++] = (byte) i;
|
||||
data[position++] = (byte) (i >> 8);
|
||||
}
|
||||
|
||||
public void put2LEA(int j) {
|
||||
data[position++] = (byte) (j + 128);
|
||||
data[position++] = (byte) (j >> 8);
|
||||
}
|
||||
public void put2LEA(int j) {
|
||||
data[position++] = (byte) (j + 128);
|
||||
data[position++] = (byte) (j >> 8);
|
||||
}
|
||||
|
||||
public void put3(int i) {
|
||||
data[position++] = (byte) (i >> 16);
|
||||
data[position++] = (byte) (i >> 8);
|
||||
data[position++] = (byte) i;
|
||||
}
|
||||
public void put3(int i) {
|
||||
data[position++] = (byte) (i >> 16);
|
||||
data[position++] = (byte) (i >> 8);
|
||||
data[position++] = (byte) i;
|
||||
}
|
||||
|
||||
public void put4(int i) {
|
||||
data[position++] = (byte) (i >> 24);
|
||||
data[position++] = (byte) (i >> 16);
|
||||
data[position++] = (byte) (i >> 8);
|
||||
data[position++] = (byte) i;
|
||||
}
|
||||
public void put4(int i) {
|
||||
data[position++] = (byte) (i >> 24);
|
||||
data[position++] = (byte) (i >> 16);
|
||||
data[position++] = (byte) (i >> 8);
|
||||
data[position++] = (byte) i;
|
||||
}
|
||||
|
||||
public void put4LE(int j) {
|
||||
data[position++] = (byte) j;
|
||||
data[position++] = (byte) (j >> 8);
|
||||
data[position++] = (byte) (j >> 16);
|
||||
data[position++] = (byte) (j >> 24);
|
||||
}
|
||||
public void put4LE(int j) {
|
||||
data[position++] = (byte) j;
|
||||
data[position++] = (byte) (j >> 8);
|
||||
data[position++] = (byte) (j >> 16);
|
||||
data[position++] = (byte) (j >> 24);
|
||||
}
|
||||
|
||||
public void put8(long l) {
|
||||
data[position++] = (byte) (int) (l >> 56);
|
||||
data[position++] = (byte) (int) (l >> 48);
|
||||
data[position++] = (byte) (int) (l >> 40);
|
||||
data[position++] = (byte) (int) (l >> 32);
|
||||
data[position++] = (byte) (int) (l >> 24);
|
||||
data[position++] = (byte) (int) (l >> 16);
|
||||
data[position++] = (byte) (int) (l >> 8);
|
||||
data[position++] = (byte) (int) l;
|
||||
}
|
||||
public void put8(long l) {
|
||||
data[position++] = (byte) (int) (l >> 56);
|
||||
data[position++] = (byte) (int) (l >> 48);
|
||||
data[position++] = (byte) (int) (l >> 40);
|
||||
data[position++] = (byte) (int) (l >> 32);
|
||||
data[position++] = (byte) (int) (l >> 24);
|
||||
data[position++] = (byte) (int) (l >> 16);
|
||||
data[position++] = (byte) (int) (l >> 8);
|
||||
data[position++] = (byte) (int) l;
|
||||
}
|
||||
|
||||
public void put(String s) {
|
||||
put(s.getBytes(StandardCharsets.ISO_8859_1));
|
||||
put1('\n');
|
||||
}
|
||||
public void put(String s) {
|
||||
put(s.getBytes(StandardCharsets.ISO_8859_1));
|
||||
put1('\n');
|
||||
}
|
||||
|
||||
public void put(byte[] src, int off, int len) {
|
||||
System.arraycopy(src, off, data, position, len);
|
||||
position += len;
|
||||
}
|
||||
public void put(byte[] src, int off, int len) {
|
||||
System.arraycopy(src, off, data, position, len);
|
||||
position += len;
|
||||
}
|
||||
|
||||
public void put(byte[] src) {
|
||||
put(src, 0, src.length);
|
||||
}
|
||||
public void put(byte[] src) {
|
||||
put(src, 0, src.length);
|
||||
}
|
||||
|
||||
public void putA(byte[] src, int off, int len) {
|
||||
for (int i = (off + len) - 1; i >= off; i--) {
|
||||
data[position++] = (byte) (src[i] + 128);
|
||||
}
|
||||
}
|
||||
public void putA(byte[] src, int off, int len) {
|
||||
for (int i = (off + len) - 1; i >= off; i--) {
|
||||
data[position++] = (byte) (src[i] + 128);
|
||||
}
|
||||
}
|
||||
|
||||
public byte get1() {
|
||||
return data[position++];
|
||||
}
|
||||
public byte get1() {
|
||||
return data[position++];
|
||||
}
|
||||
|
||||
public byte get1C() {
|
||||
return (byte) (-data[position++]);
|
||||
}
|
||||
public byte get1C() {
|
||||
return (byte) (-data[position++]);
|
||||
}
|
||||
|
||||
public byte get1S() {
|
||||
return (byte) (128 - data[position++]);
|
||||
}
|
||||
public byte get1S() {
|
||||
return (byte) (128 - data[position++]);
|
||||
}
|
||||
|
||||
public int get1U() {
|
||||
return data[position++] & 0xff;
|
||||
}
|
||||
public int get1U() {
|
||||
return data[position++] & 0xff;
|
||||
}
|
||||
|
||||
public int get1UA() {
|
||||
return (data[position++] - 128) & 0xff;
|
||||
}
|
||||
public int get1UA() {
|
||||
return (data[position++] - 128) & 0xff;
|
||||
}
|
||||
|
||||
public int get1UC() {
|
||||
return -data[position++] & 0xff;
|
||||
}
|
||||
public int get1UC() {
|
||||
return -data[position++] & 0xff;
|
||||
}
|
||||
|
||||
public int get1US() {
|
||||
return (128 - data[position++]) & 0xff;
|
||||
}
|
||||
public int get1US() {
|
||||
return (128 - data[position++]) & 0xff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a 1 or 2 byte varint which has the range [-16384...16383].
|
||||
*
|
||||
* @return the value.
|
||||
*/
|
||||
public int getSmart() {
|
||||
int i = data[position] & 0xff;
|
||||
if (i < 0x80) {
|
||||
return get1U() - 0x40;
|
||||
} else {
|
||||
return get2U() - 0xC000;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets a 1 or 2 byte varint which has the range [-16384...16383].
|
||||
*
|
||||
* @return the value.
|
||||
*/
|
||||
public int getSmart() {
|
||||
int i = data[position] & 0xff;
|
||||
if (i < 0x80) {
|
||||
return get1U() - 0x40;
|
||||
} else {
|
||||
return get2U() - 0xC000;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a 1 or 2 byte varint which has the range [0...32768].
|
||||
*
|
||||
* @return the value.
|
||||
*/
|
||||
public int getSmartU() {
|
||||
int i = data[position] & 0xff;
|
||||
if (i < 0x80) {
|
||||
return get1U();
|
||||
} else {
|
||||
return get2U() - 0x8000;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets a 1 or 2 byte varint which has the range [0...32768].
|
||||
*
|
||||
* @return the value.
|
||||
*/
|
||||
public int getSmartU() {
|
||||
int i = data[position] & 0xff;
|
||||
if (i < 0x80) {
|
||||
return get1U();
|
||||
} else {
|
||||
return get2U() - 0x8000;
|
||||
}
|
||||
}
|
||||
|
||||
public int get2U() {
|
||||
position += 2;
|
||||
return ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
|
||||
}
|
||||
public int get2U() {
|
||||
position += 2;
|
||||
return ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
|
||||
}
|
||||
|
||||
public int get2UA() {
|
||||
position += 2;
|
||||
return ((data[position - 2] & 0xff) << 8) + ((data[position - 1] - 128) & 0xff);
|
||||
}
|
||||
public int get2UA() {
|
||||
position += 2;
|
||||
return ((data[position - 2] & 0xff) << 8) + ((data[position - 1] - 128) & 0xff);
|
||||
}
|
||||
|
||||
public int get2ULE() {
|
||||
position += 2;
|
||||
return ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
|
||||
}
|
||||
public int get2ULE() {
|
||||
position += 2;
|
||||
return ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
|
||||
}
|
||||
|
||||
public int get2ULEA() {
|
||||
position += 2;
|
||||
return ((data[position - 1] & 0xff) << 8) + ((data[position - 2] - 128) & 0xff);
|
||||
}
|
||||
public int get2ULEA() {
|
||||
position += 2;
|
||||
return ((data[position - 1] & 0xff) << 8) + ((data[position - 2] - 128) & 0xff);
|
||||
}
|
||||
|
||||
public int get2() {
|
||||
position += 2;
|
||||
int i = ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
|
||||
if (i > 32767) {
|
||||
i -= 0x10000;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
public int get2() {
|
||||
position += 2;
|
||||
int i = ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
|
||||
if (i > 32767) {
|
||||
i -= 0x10000;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public int get2LE() {
|
||||
position += 2;
|
||||
int j = ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
|
||||
if (j > 0x7fff) {
|
||||
j -= 0x10000;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
public int get2LE() {
|
||||
position += 2;
|
||||
int j = ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
|
||||
if (j > 0x7fff) {
|
||||
j -= 0x10000;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
public int get2LEA() {
|
||||
position += 2;
|
||||
int j = ((data[position - 1] & 0xff) << 8) + ((data[position - 2] - 128) & 0xff);
|
||||
if (j > 0x7fff) {
|
||||
j -= 0x10000;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
public int get2LEA() {
|
||||
position += 2;
|
||||
int j = ((data[position - 1] & 0xff) << 8) + ((data[position - 2] - 128) & 0xff);
|
||||
if (j > 0x7fff) {
|
||||
j -= 0x10000;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
public int get3() {
|
||||
position += 3;
|
||||
return ((data[position - 3] & 0xff) << 16) + ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
|
||||
}
|
||||
public int get3() {
|
||||
position += 3;
|
||||
return ((data[position - 3] & 0xff) << 16) + ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
|
||||
}
|
||||
|
||||
public int get4() {
|
||||
position += 4;
|
||||
return ((data[position - 4] & 0xff) << 24) + ((data[position - 3] & 0xff) << 16) + ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
|
||||
}
|
||||
public int get4() {
|
||||
position += 4;
|
||||
return ((data[position - 4] & 0xff) << 24) + ((data[position - 3] & 0xff) << 16) + ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
|
||||
}
|
||||
|
||||
public int get4ME() {
|
||||
position += 4;
|
||||
return ((data[position - 3] & 0xff) << 24) + ((data[position - 4] & 0xff) << 16) + ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
|
||||
}
|
||||
public int get4ME() {
|
||||
position += 4;
|
||||
return ((data[position - 3] & 0xff) << 24) + ((data[position - 4] & 0xff) << 16) + ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
|
||||
}
|
||||
|
||||
public int get4RME() {
|
||||
position += 4;
|
||||
return ((data[position - 2] & 0xff) << 24) + ((data[position - 1] & 0xff) << 16) + ((data[position - 4] & 0xff) << 8) + (data[position - 3] & 0xff);
|
||||
}
|
||||
public int get4RME() {
|
||||
position += 4;
|
||||
return ((data[position - 2] & 0xff) << 24) + ((data[position - 1] & 0xff) << 16) + ((data[position - 4] & 0xff) << 8) + (data[position - 3] & 0xff);
|
||||
}
|
||||
|
||||
public long get8() {
|
||||
long l = (long) get4() & 0xffffffffL;
|
||||
long l1 = (long) get4() & 0xffffffffL;
|
||||
return (l << 32) + l1;
|
||||
}
|
||||
public long get8() {
|
||||
long l = (long) get4() & 0xffffffffL;
|
||||
long l1 = (long) get4() & 0xffffffffL;
|
||||
return (l << 32) + l1;
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
int start = position;
|
||||
while (data[position++] != '\n') {
|
||||
}
|
||||
return new String(data, start, position - start - 1);
|
||||
}
|
||||
public String getString() {
|
||||
int start = position;
|
||||
while (data[position++] != '\n') {
|
||||
}
|
||||
return new String(data, start, position - start - 1);
|
||||
}
|
||||
|
||||
public byte[] getStringRaw() {
|
||||
int start = position;
|
||||
while (data[position++] != '\n') {
|
||||
}
|
||||
byte[] raw = new byte[position - start - 1];
|
||||
for (int j = start; j < (position - 1); j++) {
|
||||
raw[j - start] = data[j];
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
public byte[] getStringRaw() {
|
||||
int start = position;
|
||||
while (data[position++] != '\n') {
|
||||
}
|
||||
byte[] raw = new byte[position - start - 1];
|
||||
for (int j = start; j < (position - 1); j++) {
|
||||
raw[j - start] = data[j];
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
|
||||
public void get(byte[] dst, int off, int len) {
|
||||
System.arraycopy(data, position, dst, off, len);
|
||||
position += len;
|
||||
}
|
||||
public void get(byte[] dst, int off, int len) {
|
||||
System.arraycopy(data, position, dst, off, len);
|
||||
position += len;
|
||||
}
|
||||
|
||||
public void getReversed(byte[] dst, int off, int len) {
|
||||
for (int i = (off + len) - 1; i >= off; i--) {
|
||||
dst[i] = data[position++];
|
||||
}
|
||||
}
|
||||
public void getReversed(byte[] dst, int off, int len) {
|
||||
for (int i = (off + len) - 1; i >= off; i--) {
|
||||
dst[i] = data[position++];
|
||||
}
|
||||
}
|
||||
|
||||
public void accessBits() {
|
||||
bitPosition = position * 8;
|
||||
}
|
||||
public void accessBits() {
|
||||
bitPosition = position * 8;
|
||||
}
|
||||
|
||||
public int getBits(int n) {
|
||||
int bytePos = bitPosition >> 3;
|
||||
int remaining = 8 - (bitPosition & 7);
|
||||
int value = 0;
|
||||
bitPosition += n;
|
||||
for (; n > remaining; remaining = 8) {
|
||||
value += (data[bytePos++] & BITMASK[remaining]) << (n - remaining);
|
||||
n -= remaining;
|
||||
}
|
||||
if (n == remaining) {
|
||||
value += data[bytePos] & BITMASK[remaining];
|
||||
} else {
|
||||
value += (data[bytePos] >> (remaining - n)) & BITMASK[n];
|
||||
}
|
||||
return value;
|
||||
}
|
||||
public int getBits(int n) {
|
||||
int bytePos = bitPosition >> 3;
|
||||
int remaining = 8 - (bitPosition & 7);
|
||||
int value = 0;
|
||||
bitPosition += n;
|
||||
for (; n > remaining; remaining = 8) {
|
||||
value += (data[bytePos++] & BITMASK[remaining]) << (n - remaining);
|
||||
n -= remaining;
|
||||
}
|
||||
if (n == remaining) {
|
||||
value += data[bytePos] & BITMASK[remaining];
|
||||
} else {
|
||||
value += (data[bytePos] >> (remaining - n)) & BITMASK[n];
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public void accessBytes() {
|
||||
position = (bitPosition + 7) / 8;
|
||||
}
|
||||
public void accessBytes() {
|
||||
position = (bitPosition + 7) / 8;
|
||||
}
|
||||
|
||||
public void encrypt(BigInteger exponent, BigInteger modulus) {
|
||||
int length = position;
|
||||
position = 0;
|
||||
byte[] raw = new byte[length];
|
||||
get(raw, 0, length);
|
||||
byte[] encrypted = new BigInteger(raw).modPow(exponent, modulus).toByteArray();
|
||||
position = 0;
|
||||
put1(encrypted.length);
|
||||
put(encrypted, 0, encrypted.length);
|
||||
}
|
||||
public void encrypt(BigInteger exponent, BigInteger modulus) {
|
||||
int length = position;
|
||||
position = 0;
|
||||
byte[] raw = new byte[length];
|
||||
get(raw, 0, length);
|
||||
byte[] encrypted = new BigInteger(raw).modPow(exponent, modulus).toByteArray();
|
||||
position = 0;
|
||||
put1(encrypted.length);
|
||||
put(encrypted, 0, encrypted.length);
|
||||
}
|
||||
|
||||
}
|
||||
+356
-356
@@ -8,370 +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.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 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).getModelUnlit(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;
|
||||
}
|
||||
|
||||
}
|
||||
+142
-142
@@ -9,155 +9,155 @@ import java.net.Socket;
|
||||
|
||||
public class Connection implements Runnable {
|
||||
|
||||
public final Socket socket;
|
||||
public final GameShell shell;
|
||||
public InputStream in;
|
||||
public OutputStream out;
|
||||
public boolean closed = false;
|
||||
public byte[] buf;
|
||||
public int tcycl;
|
||||
public int tnum;
|
||||
public boolean writer = false;
|
||||
public boolean ioerror = false;
|
||||
public final Socket socket;
|
||||
public final GameShell shell;
|
||||
public InputStream in;
|
||||
public OutputStream out;
|
||||
public boolean closed = false;
|
||||
public byte[] buf;
|
||||
public int tcycl;
|
||||
public int tnum;
|
||||
public boolean writer = false;
|
||||
public boolean ioerror = false;
|
||||
|
||||
public Connection(GameShell shell, Socket socket) throws IOException {
|
||||
this.shell = shell;
|
||||
this.socket = socket;
|
||||
this.socket.setSoTimeout(30000);
|
||||
this.socket.setTcpNoDelay(true);
|
||||
in = this.socket.getInputStream();
|
||||
out = this.socket.getOutputStream();
|
||||
}
|
||||
public Connection(GameShell shell, Socket socket) throws IOException {
|
||||
this.shell = shell;
|
||||
this.socket = socket;
|
||||
this.socket.setSoTimeout(30000);
|
||||
this.socket.setTcpNoDelay(true);
|
||||
in = this.socket.getInputStream();
|
||||
out = this.socket.getOutputStream();
|
||||
}
|
||||
|
||||
public void close() {
|
||||
closed = true;
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
if (socket != null) {
|
||||
socket.close();
|
||||
}
|
||||
} catch (IOException _ex) {
|
||||
System.out.println("Error closing stream");
|
||||
}
|
||||
writer = false;
|
||||
synchronized (this) {
|
||||
notify();
|
||||
}
|
||||
buf = null;
|
||||
}
|
||||
public void close() {
|
||||
closed = true;
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
if (socket != null) {
|
||||
socket.close();
|
||||
}
|
||||
} catch (IOException _ex) {
|
||||
System.out.println("Error closing stream");
|
||||
}
|
||||
writer = false;
|
||||
synchronized (this) {
|
||||
notify();
|
||||
}
|
||||
buf = null;
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
if (closed) {
|
||||
return 0;
|
||||
} else {
|
||||
return in.read();
|
||||
}
|
||||
}
|
||||
public int read() throws IOException {
|
||||
if (closed) {
|
||||
return 0;
|
||||
} else {
|
||||
return in.read();
|
||||
}
|
||||
}
|
||||
|
||||
public int available() throws IOException {
|
||||
if (closed) {
|
||||
return 0;
|
||||
} else {
|
||||
return in.available();
|
||||
}
|
||||
}
|
||||
public int available() throws IOException {
|
||||
if (closed) {
|
||||
return 0;
|
||||
} else {
|
||||
return in.available();
|
||||
}
|
||||
}
|
||||
|
||||
public void read(byte[] dst, int off, int len) throws IOException {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
int k;
|
||||
for (; len > 0; len -= k) {
|
||||
k = in.read(dst, off, len);
|
||||
if (k <= 0) {
|
||||
throw new IOException("EOF");
|
||||
}
|
||||
off += k;
|
||||
}
|
||||
}
|
||||
public void read(byte[] dst, int off, int len) throws IOException {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
int k;
|
||||
for (; len > 0; len -= k) {
|
||||
k = in.read(dst, off, len);
|
||||
if (k <= 0) {
|
||||
throw new IOException("EOF");
|
||||
}
|
||||
off += k;
|
||||
}
|
||||
}
|
||||
|
||||
public void write(byte[] src, int off, int len) throws IOException {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
if (ioerror) {
|
||||
ioerror = false;
|
||||
throw new IOException("Error in writer thread");
|
||||
}
|
||||
if (buf == null) {
|
||||
buf = new byte[5000];
|
||||
}
|
||||
synchronized (this) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
buf[tnum] = src[i + off];
|
||||
tnum = (tnum + 1) % 5000;
|
||||
if (tnum == ((tcycl + 4900) % 5000)) {
|
||||
throw new IOException("buffer overflow");
|
||||
}
|
||||
}
|
||||
if (!writer) {
|
||||
writer = true;
|
||||
shell.startThread(this, 3);
|
||||
}
|
||||
notify();
|
||||
}
|
||||
}
|
||||
public void write(byte[] src, int off, int len) throws IOException {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
if (ioerror) {
|
||||
ioerror = false;
|
||||
throw new IOException("Error in writer thread");
|
||||
}
|
||||
if (buf == null) {
|
||||
buf = new byte[5000];
|
||||
}
|
||||
synchronized (this) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
buf[tnum] = src[i + off];
|
||||
tnum = (tnum + 1) % 5000;
|
||||
if (tnum == ((tcycl + 4900) % 5000)) {
|
||||
throw new IOException("buffer overflow");
|
||||
}
|
||||
}
|
||||
if (!writer) {
|
||||
writer = true;
|
||||
shell.startThread(this, 3);
|
||||
}
|
||||
notify();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (writer) {
|
||||
int i;
|
||||
int j;
|
||||
synchronized (this) {
|
||||
if (tnum == tcycl) {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
if (!writer) {
|
||||
return;
|
||||
}
|
||||
j = tcycl;
|
||||
if (tnum >= tcycl) {
|
||||
i = tnum - tcycl;
|
||||
} else {
|
||||
i = 5000 - tcycl;
|
||||
}
|
||||
}
|
||||
if (i > 0) {
|
||||
try {
|
||||
out.write(buf, j, i);
|
||||
} catch (IOException _ex) {
|
||||
ioerror = true;
|
||||
}
|
||||
tcycl = (tcycl + i) % 5000;
|
||||
try {
|
||||
if (tnum == tcycl) {
|
||||
out.flush();
|
||||
}
|
||||
} catch (IOException _ex) {
|
||||
ioerror = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
while (writer) {
|
||||
int i;
|
||||
int j;
|
||||
synchronized (this) {
|
||||
if (tnum == tcycl) {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
if (!writer) {
|
||||
return;
|
||||
}
|
||||
j = tcycl;
|
||||
if (tnum >= tcycl) {
|
||||
i = tnum - tcycl;
|
||||
} else {
|
||||
i = 5000 - tcycl;
|
||||
}
|
||||
}
|
||||
if (i > 0) {
|
||||
try {
|
||||
out.write(buf, j, i);
|
||||
} catch (IOException _ex) {
|
||||
ioerror = true;
|
||||
}
|
||||
tcycl = (tcycl + i) % 5000;
|
||||
try {
|
||||
if (tnum == tcycl) {
|
||||
out.flush();
|
||||
}
|
||||
} catch (IOException _ex) {
|
||||
ioerror = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void debug() {
|
||||
System.out.println("closed:" + closed);
|
||||
System.out.println("tcycl:" + tcycl);
|
||||
System.out.println("tnum:" + tnum);
|
||||
System.out.println("writer:" + writer);
|
||||
System.out.println("ioerror:" + ioerror);
|
||||
try {
|
||||
System.out.println("available:" + available());
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
public void debug() {
|
||||
System.out.println("closed:" + closed);
|
||||
System.out.println("tcycl:" + tcycl);
|
||||
System.out.println("tnum:" + tnum);
|
||||
System.out.println("writer:" + writer);
|
||||
System.out.println("ioerror:" + ioerror);
|
||||
try {
|
||||
System.out.println("available:" + available());
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,7 @@ public class FloType {
|
||||
instances[j].method261(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
public String unusedString;
|
||||
public int anInt390;
|
||||
public int textureId = -1;
|
||||
|
||||
+11082
-11079
File diff suppressed because it is too large.
Load diff
@@ -14,7 +14,7 @@ public class GameFrame extends JFrame {
|
||||
setTitle("Jagex");
|
||||
setResizable(false);
|
||||
setLayout(new BorderLayout());
|
||||
add(shell,BorderLayout.CENTER);
|
||||
add(shell, BorderLayout.CENTER);
|
||||
pack();
|
||||
setLocationRelativeTo(null);
|
||||
setVisible(true);
|
||||
|
||||
+495
-495
@@ -9,500 +9,500 @@ import java.io.IOException;
|
||||
|
||||
public abstract class GameShell extends JComponent implements Runnable, MouseListener, MouseMotionListener, KeyListener, FocusListener, WindowListener {
|
||||
|
||||
public final long[] otim = new long[10];
|
||||
public final int[] actionKey = new int[128];
|
||||
public final int[] anIntArray31 = new int[128];
|
||||
public int state;
|
||||
public int deltime = 20;
|
||||
public int mindel = 1;
|
||||
public int fps;
|
||||
public boolean debug = false;
|
||||
public int screenWidth;
|
||||
public int screenHeight;
|
||||
public Graphics graphics;
|
||||
public GameFrame frame;
|
||||
public boolean refresh = true;
|
||||
public boolean aBoolean17 = true;
|
||||
public int idleCycles;
|
||||
public int mouseButton;
|
||||
public int mouseX;
|
||||
public int mouseY;
|
||||
public int lastMousePressButton;
|
||||
public int lastMousePressX;
|
||||
public int lastMousePressY;
|
||||
public long lastMousePressTime;
|
||||
public int mousePressButton;
|
||||
public int mousePressX;
|
||||
public int mousePressY;
|
||||
public long mousePressTime;
|
||||
public int anInt32;
|
||||
public int anInt33;
|
||||
|
||||
public void init(int width, int height) {
|
||||
screenWidth = width;
|
||||
screenHeight = height;
|
||||
setSize(width,height);
|
||||
setPreferredSize(getSize());
|
||||
frame = new GameFrame(this);
|
||||
graphics = this.getGraphics();
|
||||
startThread(this, 1);
|
||||
requestFocus();
|
||||
}
|
||||
|
||||
public void initApplet(int width, int height) {
|
||||
screenWidth = width;
|
||||
screenHeight = height;
|
||||
graphics = this.getGraphics();
|
||||
startThread(this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
this.addMouseListener(this);
|
||||
this.addMouseMotionListener(this);
|
||||
this.addKeyListener(this);
|
||||
this.addFocusListener(this);
|
||||
|
||||
if (frame != null) {
|
||||
frame.addWindowListener(this);
|
||||
}
|
||||
|
||||
showProgress(0, "Loading...");
|
||||
load();
|
||||
|
||||
int opos = 0;
|
||||
int ratio = 256;
|
||||
int delta = 1;
|
||||
int count = 0;
|
||||
int intex = 0; // interrupt exceptions
|
||||
|
||||
for (int k1 = 0; k1 < 10; k1++) {
|
||||
otim[k1] = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
while (state >= 0) {
|
||||
if (state > 0) {
|
||||
state--;
|
||||
if (state == 0) {
|
||||
shutdown();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int lastRatio = ratio;
|
||||
int lastDelta = delta;
|
||||
|
||||
ratio = 300;
|
||||
delta = 1;
|
||||
|
||||
long ntime = System.currentTimeMillis();
|
||||
|
||||
if (otim[opos] == 0L) {
|
||||
ratio = lastRatio;
|
||||
delta = lastDelta;
|
||||
} else if (ntime > otim[opos]) {
|
||||
ratio = (int) ((2560L * deltime) / (ntime - otim[opos]));
|
||||
}
|
||||
|
||||
if (ratio < 25) {
|
||||
ratio = 25;
|
||||
}
|
||||
|
||||
if (ratio > 256) {
|
||||
ratio = 256;
|
||||
delta = (int) ((long) deltime - ((ntime - otim[opos]) / 10L));
|
||||
}
|
||||
|
||||
if (delta > deltime) {
|
||||
delta = deltime;
|
||||
}
|
||||
|
||||
otim[opos] = ntime;
|
||||
opos = (opos + 1) % 10;
|
||||
|
||||
if (delta > 1) {
|
||||
for (int k2 = 0; k2 < 10; k2++) {
|
||||
if (otim[k2] != 0L) {
|
||||
otim[k2] += delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (delta < mindel) {
|
||||
delta = mindel;
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(delta);
|
||||
} catch (InterruptedException e) {
|
||||
intex++;
|
||||
}
|
||||
|
||||
for (; count < 256; count += ratio) {
|
||||
mousePressButton = lastMousePressButton;
|
||||
mousePressX = lastMousePressX;
|
||||
mousePressY = lastMousePressY;
|
||||
mousePressTime = lastMousePressTime;
|
||||
lastMousePressButton = 0;
|
||||
update();
|
||||
anInt32 = anInt33;
|
||||
}
|
||||
|
||||
count &= 0xff;
|
||||
|
||||
if (deltime > 0) {
|
||||
fps = (1000 * ratio) / (deltime * 256);
|
||||
}
|
||||
|
||||
draw();
|
||||
|
||||
if (debug) {
|
||||
System.out.println("ntime:" + ntime);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int o = ((opos - i - 1) + 20) % 10;
|
||||
System.out.println("otim" + o + ":" + otim[o]);
|
||||
}
|
||||
System.out.println("fps:" + fps + " ratio:" + ratio + " count:" + count);
|
||||
System.out.println("del:" + delta + " deltime:" + deltime + " mindel:" + mindel);
|
||||
System.out.println("intex:" + intex + " opos:" + opos);
|
||||
debug = false;
|
||||
intex = 0;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
state = -1;
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (state == -1) {
|
||||
shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
state = -2;
|
||||
unload();
|
||||
|
||||
if (frame != null) {
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
System.exit(0);
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setFrameRate(int fps) {
|
||||
deltime = 1000 / fps;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
state = -1;
|
||||
|
||||
try {
|
||||
Thread.sleep(5000L);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
if (state == -1) {
|
||||
shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Graphics g) {
|
||||
if (graphics == null) {
|
||||
graphics = g;
|
||||
}
|
||||
refresh = true;
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
if (graphics == null) {
|
||||
graphics = g;
|
||||
}
|
||||
refresh = true;
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
int x = e.getX();
|
||||
int y = e.getY();
|
||||
|
||||
idleCycles = 0;
|
||||
lastMousePressX = x;
|
||||
lastMousePressY = y;
|
||||
lastMousePressTime = System.currentTimeMillis();
|
||||
|
||||
if (SwingUtilities.isRightMouseButton(e)) {
|
||||
lastMousePressButton = 2;
|
||||
mouseButton = 2;
|
||||
} else {
|
||||
lastMousePressButton = 1;
|
||||
mouseButton = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
idleCycles = 0;
|
||||
mouseButton = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
idleCycles = 0;
|
||||
mouseX = -1;
|
||||
mouseY = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
int x = e.getX();
|
||||
int y = e.getY();
|
||||
idleCycles = 0;
|
||||
mouseX = x;
|
||||
mouseY = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
int x = e.getX();
|
||||
int y = e.getY();
|
||||
idleCycles = 0;
|
||||
mouseX = x;
|
||||
mouseY = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
idleCycles = 0;
|
||||
int code = e.getKeyCode();
|
||||
int ch = e.getKeyChar();
|
||||
|
||||
if (ch < 30) {
|
||||
ch = 0;
|
||||
}
|
||||
|
||||
if (code == KeyEvent.VK_LEFT) {
|
||||
ch = 1;
|
||||
} else if (code == KeyEvent.VK_RIGHT) {
|
||||
ch = 2;
|
||||
} else if (code == KeyEvent.VK_UP) {
|
||||
ch = 3;
|
||||
} else if (code == KeyEvent.VK_DOWN) {
|
||||
ch = 4;
|
||||
} else if (code == KeyEvent.VK_CONTROL) {
|
||||
ch = 5;
|
||||
} else if (code == KeyEvent.VK_BACK_SPACE) {
|
||||
ch = 8;
|
||||
} else if (code == KeyEvent.VK_DELETE) {
|
||||
ch = 8;
|
||||
} else if (code == KeyEvent.VK_TAB) {
|
||||
ch = 9;
|
||||
} else if (code == KeyEvent.VK_ENTER) {
|
||||
ch = 10;
|
||||
} else if ((code >= KeyEvent.VK_F1) && (code <= KeyEvent.VK_F12)) {
|
||||
ch = (1008 + code) - KeyEvent.VK_F1;
|
||||
} else if (code == KeyEvent.VK_HOME) {
|
||||
ch = 1000;
|
||||
} else if (code == KeyEvent.VK_END) {
|
||||
ch = 1001;
|
||||
} else if (code == KeyEvent.VK_PAGE_UP) {
|
||||
ch = 1002;
|
||||
} else if (code == KeyEvent.VK_PAGE_DOWN) {
|
||||
ch = 1003;
|
||||
}
|
||||
|
||||
if ((ch > 0) && (ch < 128)) {
|
||||
actionKey[ch] = 1;
|
||||
}
|
||||
|
||||
if (ch > 4) {
|
||||
anIntArray31[anInt33] = ch;
|
||||
anInt33 = (anInt33 + 1) & 0x7f;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
idleCycles = 0;
|
||||
|
||||
int code = e.getKeyCode();
|
||||
char action = e.getKeyChar();
|
||||
|
||||
if (action < 30) {
|
||||
action = 0;
|
||||
}
|
||||
|
||||
if (code == KeyEvent.VK_LEFT) {
|
||||
action = 1;
|
||||
} else if (code == KeyEvent.VK_RIGHT) {
|
||||
action = 2;
|
||||
} else if (code == KeyEvent.VK_UP) {
|
||||
action = 3;
|
||||
} else if (code == KeyEvent.VK_DOWN) {
|
||||
action = 4;
|
||||
} else if (code == KeyEvent.VK_CONTROL) {
|
||||
action = 5;
|
||||
} else if (code == KeyEvent.VK_BACK_SPACE) {
|
||||
action = 8;
|
||||
} else if (code == KeyEvent.VK_DELETE) {
|
||||
action = 8;
|
||||
} else if (code == KeyEvent.VK_TAB) {
|
||||
action = 9;
|
||||
} else if (code == KeyEvent.VK_ENTER) {
|
||||
action = 10;
|
||||
}
|
||||
|
||||
if ((action > 0) && (action < 128)) {
|
||||
actionKey[action] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
|
||||
public int method5() {
|
||||
int k = -1;
|
||||
if (anInt33 != anInt32) {
|
||||
k = anIntArray31[anInt32];
|
||||
anInt32 = (anInt32 + 1) & 0x7f;
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
aBoolean17 = true;
|
||||
refresh = true;
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
aBoolean17 = false;
|
||||
for (int i = 0; i < 128; i++) {
|
||||
actionKey[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowActivated(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosed(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeiconified(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowIconified(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowOpened(WindowEvent e) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the {@link GameShell} thread starts.
|
||||
*
|
||||
* @see #run()
|
||||
*/
|
||||
public abstract void load() throws IOException;
|
||||
|
||||
/**
|
||||
* @see #run()
|
||||
*/
|
||||
public abstract void update() throws IOException;
|
||||
|
||||
/**
|
||||
* @see #run()
|
||||
*/
|
||||
public abstract void unload();
|
||||
|
||||
/**
|
||||
* @see #run()
|
||||
*/
|
||||
public abstract void draw() throws IOException;
|
||||
|
||||
/**
|
||||
* Refresh is invoked whenever the shell is expected to potentially lost its display image.
|
||||
*
|
||||
* @see #update(Graphics)
|
||||
* @see #paint(Graphics)
|
||||
* @see #focusGained(FocusEvent)
|
||||
*/
|
||||
public abstract void refresh();
|
||||
|
||||
public void startThread(Runnable runnable, int priority) {
|
||||
Thread thread = new Thread(runnable);
|
||||
thread.start();
|
||||
thread.setPriority(priority);
|
||||
}
|
||||
|
||||
public void showProgress(int percent, String message) throws IOException {
|
||||
while (graphics == null) {
|
||||
graphics = this.getGraphics();
|
||||
try {
|
||||
this.repaint();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
java.awt.Font helvetica = new java.awt.Font("Helvetica", java.awt.Font.BOLD, 13);
|
||||
FontMetrics metrics = this.getFontMetrics(helvetica);
|
||||
|
||||
if (refresh) {
|
||||
graphics.setColor(Color.black);
|
||||
graphics.fillRect(0, 0, screenWidth, screenHeight);
|
||||
refresh = false;
|
||||
}
|
||||
|
||||
int y = (screenHeight / 2) - 18;
|
||||
|
||||
graphics.setColor(new Color(140, 17, 17));
|
||||
graphics.drawRect((screenWidth / 2) - 152, y, 304, 34);
|
||||
graphics.fillRect((screenWidth / 2) - 150, y + 2, percent * 3, 30);
|
||||
|
||||
graphics.setColor(Color.black);
|
||||
graphics.fillRect(((screenWidth / 2) - 150) + (percent * 3), y + 2, 300 - (percent * 3), 30);
|
||||
|
||||
graphics.setFont(helvetica);
|
||||
graphics.setColor(Color.white);
|
||||
graphics.drawString(message, (screenWidth - metrics.stringWidth(message)) / 2, y + 22);
|
||||
}
|
||||
public final long[] otim = new long[10];
|
||||
public final int[] actionKey = new int[128];
|
||||
public final int[] anIntArray31 = new int[128];
|
||||
public int state;
|
||||
public int deltime = 20;
|
||||
public int mindel = 1;
|
||||
public int fps;
|
||||
public boolean debug = false;
|
||||
public int screenWidth;
|
||||
public int screenHeight;
|
||||
public Graphics graphics;
|
||||
public GameFrame frame;
|
||||
public boolean refresh = true;
|
||||
public boolean aBoolean17 = true;
|
||||
public int idleCycles;
|
||||
public int mouseButton;
|
||||
public int mouseX;
|
||||
public int mouseY;
|
||||
public int lastMousePressButton;
|
||||
public int lastMousePressX;
|
||||
public int lastMousePressY;
|
||||
public long lastMousePressTime;
|
||||
public int mousePressButton;
|
||||
public int mousePressX;
|
||||
public int mousePressY;
|
||||
public long mousePressTime;
|
||||
public int anInt32;
|
||||
public int anInt33;
|
||||
|
||||
public void init(int width, int height) {
|
||||
screenWidth = width;
|
||||
screenHeight = height;
|
||||
setSize(width, height);
|
||||
setPreferredSize(getSize());
|
||||
frame = new GameFrame(this);
|
||||
graphics = this.getGraphics();
|
||||
startThread(this, 1);
|
||||
requestFocus();
|
||||
}
|
||||
|
||||
public void initApplet(int width, int height) {
|
||||
screenWidth = width;
|
||||
screenHeight = height;
|
||||
graphics = this.getGraphics();
|
||||
startThread(this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
this.addMouseListener(this);
|
||||
this.addMouseMotionListener(this);
|
||||
this.addKeyListener(this);
|
||||
this.addFocusListener(this);
|
||||
|
||||
if (frame != null) {
|
||||
frame.addWindowListener(this);
|
||||
}
|
||||
|
||||
showProgress(0, "Loading...");
|
||||
load();
|
||||
|
||||
int opos = 0;
|
||||
int ratio = 256;
|
||||
int delta = 1;
|
||||
int count = 0;
|
||||
int intex = 0; // interrupt exceptions
|
||||
|
||||
for (int k1 = 0; k1 < 10; k1++) {
|
||||
otim[k1] = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
while (state >= 0) {
|
||||
if (state > 0) {
|
||||
state--;
|
||||
if (state == 0) {
|
||||
shutdown();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int lastRatio = ratio;
|
||||
int lastDelta = delta;
|
||||
|
||||
ratio = 300;
|
||||
delta = 1;
|
||||
|
||||
long ntime = System.currentTimeMillis();
|
||||
|
||||
if (otim[opos] == 0L) {
|
||||
ratio = lastRatio;
|
||||
delta = lastDelta;
|
||||
} else if (ntime > otim[opos]) {
|
||||
ratio = (int) ((2560L * deltime) / (ntime - otim[opos]));
|
||||
}
|
||||
|
||||
if (ratio < 25) {
|
||||
ratio = 25;
|
||||
}
|
||||
|
||||
if (ratio > 256) {
|
||||
ratio = 256;
|
||||
delta = (int) ((long) deltime - ((ntime - otim[opos]) / 10L));
|
||||
}
|
||||
|
||||
if (delta > deltime) {
|
||||
delta = deltime;
|
||||
}
|
||||
|
||||
otim[opos] = ntime;
|
||||
opos = (opos + 1) % 10;
|
||||
|
||||
if (delta > 1) {
|
||||
for (int k2 = 0; k2 < 10; k2++) {
|
||||
if (otim[k2] != 0L) {
|
||||
otim[k2] += delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (delta < mindel) {
|
||||
delta = mindel;
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(delta);
|
||||
} catch (InterruptedException e) {
|
||||
intex++;
|
||||
}
|
||||
|
||||
for (; count < 256; count += ratio) {
|
||||
mousePressButton = lastMousePressButton;
|
||||
mousePressX = lastMousePressX;
|
||||
mousePressY = lastMousePressY;
|
||||
mousePressTime = lastMousePressTime;
|
||||
lastMousePressButton = 0;
|
||||
update();
|
||||
anInt32 = anInt33;
|
||||
}
|
||||
|
||||
count &= 0xff;
|
||||
|
||||
if (deltime > 0) {
|
||||
fps = (1000 * ratio) / (deltime * 256);
|
||||
}
|
||||
|
||||
draw();
|
||||
|
||||
if (debug) {
|
||||
System.out.println("ntime:" + ntime);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int o = ((opos - i - 1) + 20) % 10;
|
||||
System.out.println("otim" + o + ":" + otim[o]);
|
||||
}
|
||||
System.out.println("fps:" + fps + " ratio:" + ratio + " count:" + count);
|
||||
System.out.println("del:" + delta + " deltime:" + deltime + " mindel:" + mindel);
|
||||
System.out.println("intex:" + intex + " opos:" + opos);
|
||||
debug = false;
|
||||
intex = 0;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
state = -1;
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (state == -1) {
|
||||
shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
state = -2;
|
||||
unload();
|
||||
|
||||
if (frame != null) {
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
System.exit(0);
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setFrameRate(int fps) {
|
||||
deltime = 1000 / fps;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
state = -1;
|
||||
|
||||
try {
|
||||
Thread.sleep(5000L);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
if (state == -1) {
|
||||
shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Graphics g) {
|
||||
if (graphics == null) {
|
||||
graphics = g;
|
||||
}
|
||||
refresh = true;
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
if (graphics == null) {
|
||||
graphics = g;
|
||||
}
|
||||
refresh = true;
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
int x = e.getX();
|
||||
int y = e.getY();
|
||||
|
||||
idleCycles = 0;
|
||||
lastMousePressX = x;
|
||||
lastMousePressY = y;
|
||||
lastMousePressTime = System.currentTimeMillis();
|
||||
|
||||
if (SwingUtilities.isRightMouseButton(e)) {
|
||||
lastMousePressButton = 2;
|
||||
mouseButton = 2;
|
||||
} else {
|
||||
lastMousePressButton = 1;
|
||||
mouseButton = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
idleCycles = 0;
|
||||
mouseButton = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
idleCycles = 0;
|
||||
mouseX = -1;
|
||||
mouseY = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
int x = e.getX();
|
||||
int y = e.getY();
|
||||
idleCycles = 0;
|
||||
mouseX = x;
|
||||
mouseY = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
int x = e.getX();
|
||||
int y = e.getY();
|
||||
idleCycles = 0;
|
||||
mouseX = x;
|
||||
mouseY = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
idleCycles = 0;
|
||||
int code = e.getKeyCode();
|
||||
int ch = e.getKeyChar();
|
||||
|
||||
if (ch < 30) {
|
||||
ch = 0;
|
||||
}
|
||||
|
||||
if (code == KeyEvent.VK_LEFT) {
|
||||
ch = 1;
|
||||
} else if (code == KeyEvent.VK_RIGHT) {
|
||||
ch = 2;
|
||||
} else if (code == KeyEvent.VK_UP) {
|
||||
ch = 3;
|
||||
} else if (code == KeyEvent.VK_DOWN) {
|
||||
ch = 4;
|
||||
} else if (code == KeyEvent.VK_CONTROL) {
|
||||
ch = 5;
|
||||
} else if (code == KeyEvent.VK_BACK_SPACE) {
|
||||
ch = 8;
|
||||
} else if (code == KeyEvent.VK_DELETE) {
|
||||
ch = 8;
|
||||
} else if (code == KeyEvent.VK_TAB) {
|
||||
ch = 9;
|
||||
} else if (code == KeyEvent.VK_ENTER) {
|
||||
ch = 10;
|
||||
} else if ((code >= KeyEvent.VK_F1) && (code <= KeyEvent.VK_F12)) {
|
||||
ch = (1008 + code) - KeyEvent.VK_F1;
|
||||
} else if (code == KeyEvent.VK_HOME) {
|
||||
ch = 1000;
|
||||
} else if (code == KeyEvent.VK_END) {
|
||||
ch = 1001;
|
||||
} else if (code == KeyEvent.VK_PAGE_UP) {
|
||||
ch = 1002;
|
||||
} else if (code == KeyEvent.VK_PAGE_DOWN) {
|
||||
ch = 1003;
|
||||
}
|
||||
|
||||
if ((ch > 0) && (ch < 128)) {
|
||||
actionKey[ch] = 1;
|
||||
}
|
||||
|
||||
if (ch > 4) {
|
||||
anIntArray31[anInt33] = ch;
|
||||
anInt33 = (anInt33 + 1) & 0x7f;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
idleCycles = 0;
|
||||
|
||||
int code = e.getKeyCode();
|
||||
char action = e.getKeyChar();
|
||||
|
||||
if (action < 30) {
|
||||
action = 0;
|
||||
}
|
||||
|
||||
if (code == KeyEvent.VK_LEFT) {
|
||||
action = 1;
|
||||
} else if (code == KeyEvent.VK_RIGHT) {
|
||||
action = 2;
|
||||
} else if (code == KeyEvent.VK_UP) {
|
||||
action = 3;
|
||||
} else if (code == KeyEvent.VK_DOWN) {
|
||||
action = 4;
|
||||
} else if (code == KeyEvent.VK_CONTROL) {
|
||||
action = 5;
|
||||
} else if (code == KeyEvent.VK_BACK_SPACE) {
|
||||
action = 8;
|
||||
} else if (code == KeyEvent.VK_DELETE) {
|
||||
action = 8;
|
||||
} else if (code == KeyEvent.VK_TAB) {
|
||||
action = 9;
|
||||
} else if (code == KeyEvent.VK_ENTER) {
|
||||
action = 10;
|
||||
}
|
||||
|
||||
if ((action > 0) && (action < 128)) {
|
||||
actionKey[action] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
|
||||
public int method5() {
|
||||
int k = -1;
|
||||
if (anInt33 != anInt32) {
|
||||
k = anIntArray31[anInt32];
|
||||
anInt32 = (anInt32 + 1) & 0x7f;
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
aBoolean17 = true;
|
||||
refresh = true;
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
aBoolean17 = false;
|
||||
for (int i = 0; i < 128; i++) {
|
||||
actionKey[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowActivated(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosed(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeiconified(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowIconified(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowOpened(WindowEvent e) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the {@link GameShell} thread starts.
|
||||
*
|
||||
* @see #run()
|
||||
*/
|
||||
public abstract void load() throws IOException;
|
||||
|
||||
/**
|
||||
* @see #run()
|
||||
*/
|
||||
public abstract void update() throws IOException;
|
||||
|
||||
/**
|
||||
* @see #run()
|
||||
*/
|
||||
public abstract void unload();
|
||||
|
||||
/**
|
||||
* @see #run()
|
||||
*/
|
||||
public abstract void draw() throws IOException;
|
||||
|
||||
/**
|
||||
* Refresh is invoked whenever the shell is expected to potentially lost its display image.
|
||||
*
|
||||
* @see #update(Graphics)
|
||||
* @see #paint(Graphics)
|
||||
* @see #focusGained(FocusEvent)
|
||||
*/
|
||||
public abstract void refresh();
|
||||
|
||||
public void startThread(Runnable runnable, int priority) {
|
||||
Thread thread = new Thread(runnable);
|
||||
thread.start();
|
||||
thread.setPriority(priority);
|
||||
}
|
||||
|
||||
public void showProgress(int percent, String message) throws IOException {
|
||||
while (graphics == null) {
|
||||
graphics = this.getGraphics();
|
||||
try {
|
||||
this.repaint();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
java.awt.Font helvetica = new java.awt.Font("Helvetica", java.awt.Font.BOLD, 13);
|
||||
FontMetrics metrics = this.getFontMetrics(helvetica);
|
||||
|
||||
if (refresh) {
|
||||
graphics.setColor(Color.black);
|
||||
graphics.fillRect(0, 0, screenWidth, screenHeight);
|
||||
refresh = false;
|
||||
}
|
||||
|
||||
int y = (screenHeight / 2) - 18;
|
||||
|
||||
graphics.setColor(new Color(140, 17, 17));
|
||||
graphics.drawRect((screenWidth / 2) - 152, y, 304, 34);
|
||||
graphics.fillRect((screenWidth / 2) - 150, y + 2, percent * 3, 30);
|
||||
|
||||
graphics.setColor(Color.black);
|
||||
graphics.fillRect(((screenWidth / 2) - 150) + (percent * 3), y + 2, 300 - (percent * 3), 30);
|
||||
|
||||
graphics.setFont(helvetica);
|
||||
graphics.setColor(Color.white);
|
||||
graphics.drawString(message, (screenWidth - metrics.stringWidth(message)) / 2, y + 22);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,7 @@ public class IDKType {
|
||||
instances[j].method536(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
public final int[] anIntArray659 = new int[6];
|
||||
public final int[] anIntArray660 = new int[6];
|
||||
public final int[] anIntArray661 = {-1, -1, -1, -1, -1};
|
||||
|
||||
+467
-470
@@ -5,503 +5,500 @@
|
||||
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) {
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+280
-280
@@ -8,301 +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 int count;
|
||||
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) {
|
||||
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"));
|
||||
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 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 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.pickable = 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) {
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,11 +5,6 @@
|
||||
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 {
|
||||
|
||||
|
||||
@@ -348,6 +348,7 @@ public class SceneBuilder {
|
||||
}
|
||||
return bool;
|
||||
}
|
||||
|
||||
public final int[] anIntArray124;
|
||||
public final int[] anIntArray125;
|
||||
public final int[] anIntArray126;
|
||||
|
||||
+150
-150
@@ -6,182 +6,182 @@
|
||||
*/
|
||||
public class SeqFrame {
|
||||
|
||||
public 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];
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
}
|
||||
+150
-150
@@ -5,184 +5,184 @@ 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;
|
||||
}
|
||||
do {
|
||||
int id = src.get2U();
|
||||
if (id == 65535) {
|
||||
return;
|
||||
}
|
||||
|
||||
int start = src.position;
|
||||
tracks[id] = new SoundTrack();
|
||||
tracks[id].read(src);
|
||||
int end = src.position;
|
||||
int start = src.position;
|
||||
tracks[id] = new SoundTrack();
|
||||
tracks[id].read(src);
|
||||
int end = src.position;
|
||||
|
||||
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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
delays[id] = tracks[id].trim();
|
||||
} while (true);
|
||||
}
|
||||
delays[id] = tracks[id].trim();
|
||||
} while (true);
|
||||
}
|
||||
|
||||
public static Buffer generate(int loopCount, int id) {
|
||||
if (tracks[id] != null) {
|
||||
SoundTrack track = tracks[id];
|
||||
return track.getWaveform(loopCount);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static Buffer generate(int loopCount, int id) {
|
||||
if (tracks[id] != null) {
|
||||
SoundTrack track = tracks[id];
|
||||
return track.getWaveform(loopCount);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public final SoundTone[] tones = new SoundTone[10];
|
||||
public int loopBegin;
|
||||
public int loopEnd;
|
||||
public final SoundTone[] tones = new SoundTone[10];
|
||||
public int loopBegin;
|
||||
public int loopEnd;
|
||||
|
||||
public SoundTrack() {
|
||||
}
|
||||
public SoundTrack() {
|
||||
}
|
||||
|
||||
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 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 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 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;
|
||||
}
|
||||
}
|
||||
|
||||
if ((loopBegin < loopEnd) && ((loopBegin / 20) < start)) {
|
||||
start = loopBegin / 20;
|
||||
}
|
||||
if ((loopBegin < loopEnd) && ((loopBegin / 20) < start)) {
|
||||
start = loopBegin / 20;
|
||||
}
|
||||
|
||||
if ((start == 9999999) || (start == 0)) {
|
||||
return 0;
|
||||
}
|
||||
if ((start == 9999999) || (start == 0)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* <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;
|
||||
}
|
||||
/**
|
||||
* <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;
|
||||
}
|
||||
|
||||
public int generate(int loopCount) {
|
||||
int duration = 0;
|
||||
public int generate(int loopCount) {
|
||||
int duration = 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].length + tones[tone].start) > duration)) {
|
||||
duration = tones[tone].length + tones[tone].start;
|
||||
}
|
||||
}
|
||||
|
||||
if (duration == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (duration == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sampleCount = (22050 * duration) / 1000;
|
||||
int loopStart = (22050 * loopBegin) / 1000;
|
||||
int loopStop = (22050 * loopEnd) / 1000;
|
||||
int sampleCount = (22050 * duration) / 1000;
|
||||
int loopStart = (22050 * loopBegin) / 1000;
|
||||
int loopStop = (22050 * loopEnd) / 1000;
|
||||
|
||||
if ((loopStart < 0) || (loopStop < 0) || (loopStop > sampleCount) || (loopStart >= loopStop)) {
|
||||
loopCount = 0;
|
||||
}
|
||||
if ((loopStart < 0) || (loopStop < 0) || (loopStop > sampleCount) || (loopStart >= loopStop)) {
|
||||
loopCount = 0;
|
||||
}
|
||||
|
||||
int totalSampleCount = sampleCount + ((loopStop - loopStart) * (loopCount - 1));
|
||||
int totalSampleCount = sampleCount + ((loopStop - loopStart) * (loopCount - 1));
|
||||
|
||||
for (int sample = 44; sample < (totalSampleCount + 44); sample++) {
|
||||
bbuf[sample] = -128;
|
||||
}
|
||||
for (int sample = 44; sample < (totalSampleCount + 44); sample++) {
|
||||
bbuf[sample] = -128;
|
||||
}
|
||||
|
||||
for (int tone = 0; tone < 10; tone++) {
|
||||
if (tones[tone] == null) {
|
||||
continue;
|
||||
}
|
||||
for (int tone = 0; tone < 10; tone++) {
|
||||
if (tones[tone] == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int toneSampleCount = (tones[tone].length * 22050) / 1000;
|
||||
int start = (tones[tone].start * 22050) / 1000;
|
||||
int[] samples = tones[tone].generate(toneSampleCount, tones[tone].length);
|
||||
int toneSampleCount = (tones[tone].length * 22050) / 1000;
|
||||
int start = (tones[tone].start * 22050) / 1000;
|
||||
int[] samples = tones[tone].generate(toneSampleCount, tones[tone].length);
|
||||
|
||||
for (int sample = 0; sample < toneSampleCount; sample++) {
|
||||
bbuf[sample + start + 44] += (byte) (samples[sample] >> 8);
|
||||
}
|
||||
}
|
||||
for (int sample = 0; sample < toneSampleCount; sample++) {
|
||||
bbuf[sample + start + 44] += (byte) (samples[sample] >> 8);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
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];
|
||||
}
|
||||
// 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];
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
totalSampleCount -= 44;
|
||||
}
|
||||
return totalSampleCount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,89 +8,89 @@ import java.io.IOException;
|
||||
|
||||
public class SpotAnimType {
|
||||
|
||||
public static int count;
|
||||
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"));
|
||||
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 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 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 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 SpotAnimType() {
|
||||
}
|
||||
public SpotAnimType() {
|
||||
}
|
||||
|
||||
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 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user