This commit is contained in:
thedaneeffect committed 2023-01-07 20:15:43 -05:00
1 parent ed6390f148
commit 2e7e22aced
55 files changed
+9627 -9613

No files matched your search

+64 -64
View File
@@ -13,79 +13,79 @@ import java.io.InputStream;
*/
public class BZip2 extends InputStream {
private static final byte[] MAGIC = {'B', 'Z', 'h', '1'};
private static final byte[] MAGIC = {'B', 'Z', 'h', '1'};
/**
* @see #decompress(byte[], int, int, byte[])
*/
public static byte[] decompress(byte[] src) throws IOException {
return decompress(src, 0, src.length, null);
}
/**
* @see #decompress(byte[], int, int, byte[])
*/
public static byte[] decompress(byte[] src) throws IOException {
return decompress(src, 0, src.length, null);
}
/**
* @see #decompress(byte[], int, int, byte[])
*/
public static byte[] decompress(byte[] src, int off, int len) throws IOException {
return decompress(src, off, len, null);
}
/**
* @see #decompress(byte[], int, int, byte[])
*/
public static byte[] decompress(byte[] src, int off, int len) throws IOException {
return decompress(src, off, len, null);
}
/**
* Decompresses the source.
*
* @param src the source data.
* @param off the source offset.
* @param len the source length.
* @param dst the destination or <code>null</code> to create a new one.
* @throws IOException if the stream content is malformed or an I/O error occurs.
*/
public static byte[] decompress(byte[] src, int off, int len, byte[] dst) throws IOException {
ByteArrayOutputStream tmp = null;
/**
* Decompresses the source.
*
* @param src the source data.
* @param off the source offset.
* @param len the source length.
* @param dst the destination or <code>null</code> to create a new one.
* @throws IOException if the stream content is malformed or an I/O error occurs.
*/
public static byte[] decompress(byte[] src, int off, int len, byte[] dst) throws IOException {
ByteArrayOutputStream tmp = null;
if (dst == null) {
tmp = new ByteArrayOutputStream();
}
if (dst == null) {
tmp = new ByteArrayOutputStream();
}
try (BZip2CompressorInputStream in = new BZip2CompressorInputStream(new BZip2(src, off, len))) {
if (tmp != null) {
IOUtils.copy(in, tmp);
} else {
IOUtils.readFully(in, dst);
}
}
try (BZip2CompressorInputStream in = new BZip2CompressorInputStream(new BZip2(src, off, len))) {
if (tmp != null) {
IOUtils.copy(in, tmp);
} else {
IOUtils.readFully(in, dst);
}
}
if (tmp != null) {
return tmp.toByteArray();
}
if (tmp != null) {
return tmp.toByteArray();
}
return dst;
}
return dst;
}
/**
* The input.
*/
private final ByteArrayInputStream in;
/**
* The position.
*/
private int position;
/**
* The input.
*/
private final ByteArrayInputStream in;
/**
* The position.
*/
private int position;
/**
* Constructs a new helper class to fool that silly compressor.
*
* @param src the source.
* @param off the source offset.
* @param len the source length.
*/
private BZip2(byte[] src, int off, int len) {
this.in = new ByteArrayInputStream(src, off, len);
}
/**
* Constructs a new helper class to fool that silly compressor.
*
* @param src the source.
* @param off the source offset.
* @param len the source length.
*/
private BZip2(byte[] src, int off, int len) {
this.in = new ByteArrayInputStream(src, off, len);
}
@Override
public int read() throws IOException {
if (position < 4) {
return MAGIC[position++];
}
return in.read();
}
@Override
public int read() throws IOException {
if (position < 4) {
return MAGIC[position++];
}
return in.read();
}
}
File diff suppressed because it is too large. Load diff
+265 -265
View File
@@ -28,323 +28,323 @@ import java.nio.charset.StandardCharsets;
*/
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 writeOp(int i) {
data[position++] = (byte) (i + random.nextInt());
}
public void writeOp(int i) {
data[position++] = (byte) (i + random.nextInt());
}
public void writeSize(int i) {
data[position - i - 1] = (byte) i;
}
public void writeSize(int i) {
data[position - i - 1] = (byte) i;
}
public void write8(int i) {
data[position++] = (byte) i;
}
public void write8(int i) {
data[position++] = (byte) i;
}
public void write8C(int i) {
data[position++] = (byte) -i;
}
public void write8C(int i) {
data[position++] = (byte) -i;
}
public void write8S(int j) {
data[position++] = (byte) (128 - j);
}
public void write8S(int j) {
data[position++] = (byte) (128 - j);
}
public void write16(int i) {
data[position++] = (byte) (i >> 8);
data[position++] = (byte) i;
}
public void write16(int i) {
data[position++] = (byte) (i >> 8);
data[position++] = (byte) i;
}
public void write16A(int j) {
data[position++] = (byte) (j >> 8);
data[position++] = (byte) (j + 128);
}
public void write16A(int j) {
data[position++] = (byte) (j >> 8);
data[position++] = (byte) (j + 128);
}
public void write16LE(int i) {
data[position++] = (byte) i;
data[position++] = (byte) (i >> 8);
}
public void write16LE(int i) {
data[position++] = (byte) i;
data[position++] = (byte) (i >> 8);
}
public void write16LEA(int j) {
data[position++] = (byte) (j + 128);
data[position++] = (byte) (j >> 8);
}
public void write16LEA(int j) {
data[position++] = (byte) (j + 128);
data[position++] = (byte) (j >> 8);
}
public void write24(int i) {
data[position++] = (byte) (i >> 16);
data[position++] = (byte) (i >> 8);
data[position++] = (byte) i;
}
public void write24(int i) {
data[position++] = (byte) (i >> 16);
data[position++] = (byte) (i >> 8);
data[position++] = (byte) i;
}
public void write32(int i) {
data[position++] = (byte) (i >> 24);
data[position++] = (byte) (i >> 16);
data[position++] = (byte) (i >> 8);
data[position++] = (byte) i;
}
public void write32(int i) {
data[position++] = (byte) (i >> 24);
data[position++] = (byte) (i >> 16);
data[position++] = (byte) (i >> 8);
data[position++] = (byte) i;
}
public void write32LE(int j) {
data[position++] = (byte) j;
data[position++] = (byte) (j >> 8);
data[position++] = (byte) (j >> 16);
data[position++] = (byte) (j >> 24);
}
public void write32LE(int j) {
data[position++] = (byte) j;
data[position++] = (byte) (j >> 8);
data[position++] = (byte) (j >> 16);
data[position++] = (byte) (j >> 24);
}
public void write64(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 write64(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 writeString(String s) {
write(s.getBytes(StandardCharsets.ISO_8859_1));
write8('\n');
}
public void writeString(String s) {
write(s.getBytes(StandardCharsets.ISO_8859_1));
write8('\n');
}
public void write(byte[] src, int off, int len) {
System.arraycopy(src, off, data, position, len);
position += len;
}
public void write(byte[] src, int off, int len) {
System.arraycopy(src, off, data, position, len);
position += len;
}
public void write(byte[] src) {
write(src, 0, src.length);
}
public void write(byte[] src) {
write(src, 0, src.length);
}
public void writeA(byte[] src, int off, int len) {
for (int i = (off + len) - 1; i >= off; i--) {
data[position++] = (byte) (src[i] + 128);
}
}
public void writeA(byte[] src, int off, int len) {
for (int i = (off + len) - 1; i >= off; i--) {
data[position++] = (byte) (src[i] + 128);
}
}
public byte read() {
return data[position++];
}
public byte read() {
return data[position++];
}
public byte read8C() {
return (byte) -data[position++];
}
public byte read8C() {
return (byte) -data[position++];
}
public byte read8S() {
return (byte) (128 - data[position++]);
}
public byte read8S() {
return (byte) (128 - data[position++]);
}
public int read8U() {
return data[position++] & 0xff;
}
public int read8U() {
return data[position++] & 0xff;
}
public int read8UA() {
return (data[position++] - 128) & 0xff;
}
public int read8UA() {
return (data[position++] - 128) & 0xff;
}
public int read8UC() {
return -data[position++] & 0xff;
}
public int read8UC() {
return -data[position++] & 0xff;
}
public int read8US() {
return (128 - data[position++]) & 0xff;
}
public int read8US() {
return (128 - data[position++]) & 0xff;
}
/**
* Gets a 1 or 2 byte varint which has the range [-16384...16383].
*
* @return the value.
*/
public int readSmart() {
int i = data[position] & 0xff;
if (i < 128) {
return read8U() - 64;
} else {
return read16U() - 49152;
}
}
/**
* Gets a 1 or 2 byte varint which has the range [-16384...16383].
*
* @return the value.
*/
public int readSmart() {
int i = data[position] & 0xff;
if (i < 128) {
return read8U() - 64;
} else {
return read16U() - 49152;
}
}
/**
* Gets a 1 or 2 byte varint which has the range [0...32768].
*
* @return the value.
*/
public int readSmartU() {
int i = data[position] & 0xff;
if (i < 128) {
return read8U();
} else {
return read16U() - 32768;
}
}
/**
* Gets a 1 or 2 byte varint which has the range [0...32768].
*
* @return the value.
*/
public int readSmartU() {
int i = data[position] & 0xff;
if (i < 128) {
return read8U();
} else {
return read16U() - 32768;
}
}
public int read16U() {
position += 2;
return ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
}
public int read16U() {
position += 2;
return ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
}
public int read16UA() {
position += 2;
return ((data[position - 2] & 0xff) << 8) + ((data[position - 1] - 128) & 0xff);
}
public int read16UA() {
position += 2;
return ((data[position - 2] & 0xff) << 8) + ((data[position - 1] - 128) & 0xff);
}
public int read16ULE() {
position += 2;
return ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
}
public int read16ULE() {
position += 2;
return ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
}
public int read16ULEA() {
position += 2;
return ((data[position - 1] & 0xff) << 8) + ((data[position - 2] - 128) & 0xff);
}
public int read16ULEA() {
position += 2;
return ((data[position - 1] & 0xff) << 8) + ((data[position - 2] - 128) & 0xff);
}
public int read16() {
position += 2;
int i = ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
if (i > 32767) {
i -= 0x10000;
}
return i;
}
public int read16() {
position += 2;
int i = ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
if (i > 32767) {
i -= 0x10000;
}
return i;
}
public int read16LE() {
position += 2;
int j = ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
if (j > 0x7fff) {
j -= 0x10000;
}
return j;
}
public int read16LE() {
position += 2;
int j = ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
if (j > 0x7fff) {
j -= 0x10000;
}
return j;
}
public int read16LEA() {
position += 2;
int j = ((data[position - 1] & 0xff) << 8) + ((data[position - 2] - 128) & 0xff);
if (j > 0x7fff) {
j -= 0x10000;
}
return j;
}
public int read16LEA() {
position += 2;
int j = ((data[position - 1] & 0xff) << 8) + ((data[position - 2] - 128) & 0xff);
if (j > 0x7fff) {
j -= 0x10000;
}
return j;
}
public int read24() {
position += 3;
return ((data[position - 3] & 0xff) << 16) + ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
}
public int read24() {
position += 3;
return ((data[position - 3] & 0xff) << 16) + ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
}
public int read32() {
position += 4;
return ((data[position - 4] & 0xff) << 24) + ((data[position - 3] & 0xff) << 16) + ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
}
public int read32() {
position += 4;
return ((data[position - 4] & 0xff) << 24) + ((data[position - 3] & 0xff) << 16) + ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
}
public int read32ME() {
position += 4;
return ((data[position - 3] & 0xff) << 24) + ((data[position - 4] & 0xff) << 16) + ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
}
public int read32ME() {
position += 4;
return ((data[position - 3] & 0xff) << 24) + ((data[position - 4] & 0xff) << 16) + ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
}
public int read32RME() {
position += 4;
return ((data[position - 2] & 0xff) << 24) + ((data[position - 1] & 0xff) << 16) + ((data[position - 4] & 0xff) << 8) + (data[position - 3] & 0xff);
}
public int read32RME() {
position += 4;
return ((data[position - 2] & 0xff) << 24) + ((data[position - 1] & 0xff) << 16) + ((data[position - 4] & 0xff) << 8) + (data[position - 3] & 0xff);
}
public long read64() {
long l = (long) read32() & 0xffffffffL;
long l1 = (long) read32() & 0xffffffffL;
return (l << 32) + l1;
}
public long read64() {
long l = (long) read32() & 0xffffffffL;
long l1 = (long) read32() & 0xffffffffL;
return (l << 32) + l1;
}
public String readString() {
int start = position;
while (data[position++] != '\n') {
}
return new String(data, start, position - start - 1);
}
public String readString() {
int start = position;
while (data[position++] != '\n') {
}
return new String(data, start, position - start - 1);
}
public byte[] readStringRaw() {
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[] readStringRaw() {
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 read(byte[] dst, int off, int len) {
System.arraycopy(data, position, dst, off, len);
position += len;
}
public void read(byte[] dst, int off, int len) {
System.arraycopy(data, position, dst, off, len);
position += len;
}
public void read(byte[] dst) {
read(dst,0,dst.length);
}
public void read(byte[] dst) {
read(dst, 0, dst.length);
}
public void readReversed(byte[] dst, int off, int len) {
for (int i = (off + len) - 1; i >= off; i--) {
dst[i] = data[position++];
}
}
public void readReversed(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 readN(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 readN(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];
read(raw, 0, length);
byte[] encrypted = new BigInteger(raw).modPow(exponent, modulus).toByteArray();
position = 0;
write8(encrypted.length);
write(encrypted, 0, encrypted.length);
}
public void encrypt(BigInteger exponent, BigInteger modulus) {
int length = position;
position = 0;
byte[] raw = new byte[length];
read(raw, 0, length);
byte[] encrypted = new BigInteger(raw).modPow(exponent, modulus).toByteArray();
position = 0;
write8(encrypted.length);
write(encrypted, 0, encrypted.length);
}
}
+890 -890
View File
File diff suppressed because it is too large. Load diff
+16 -16
View File
@@ -79,19 +79,19 @@ public class CollisionMap {
}
} else if (type == 2) {
if (rotation == 0) {
add(x, z, FLAG_BLOCK_ENTITY_W|FLAG_BLOCK_ENTITY_N);
add(x, z, FLAG_BLOCK_ENTITY_W | FLAG_BLOCK_ENTITY_N);
add(x - 1, z, FLAG_BLOCK_ENTITY_E);
add(x, z + 1, FLAG_BLOCK_ENTITY_S);
} else if (rotation == 1) {
add(x, z, FLAG_BLOCK_ENTITY_E|FLAG_BLOCK_ENTITY_N);
add(x, z, FLAG_BLOCK_ENTITY_E | FLAG_BLOCK_ENTITY_N);
add(x, z + 1, FLAG_BLOCK_ENTITY_S);
add(x + 1, z, FLAG_BLOCK_ENTITY_W);
} else if (rotation == 2) {
add(x, z, FLAG_BLOCK_ENTITY_E|FLAG_BLOCK_ENTITY_S);
add(x, z, FLAG_BLOCK_ENTITY_E | FLAG_BLOCK_ENTITY_S);
add(x + 1, z, FLAG_BLOCK_ENTITY_W);
add(x, z - 1, FLAG_BLOCK_ENTITY_N);
} else if (rotation == 3) {
add(x, z, FLAG_BLOCK_ENTITY_W|FLAG_BLOCK_ENTITY_S);
add(x, z, FLAG_BLOCK_ENTITY_W | FLAG_BLOCK_ENTITY_S);
add(x, z - 1, FLAG_BLOCK_ENTITY_N);
add(x - 1, z, FLAG_BLOCK_ENTITY_E);
}
@@ -128,19 +128,19 @@ public class CollisionMap {
}
} else if (type == 2) {
if (rotation == 0) {
add(x, z, FLAG_BLOCK_PROJECTILE_W|FLAG_BLOCK_PROJECTILE_N);
add(x, z, FLAG_BLOCK_PROJECTILE_W | FLAG_BLOCK_PROJECTILE_N);
add(x - 1, z, FLAG_BLOCK_PROJECTILE_E);
add(x, z + 1, FLAG_BLOCK_PROJECTILE_S);
} else if (rotation == 1) {
add(x, z, FLAG_BLOCK_PROJECTILE_E|FLAG_BLOCK_PROJECTILE_N);
add(x, z, FLAG_BLOCK_PROJECTILE_E | FLAG_BLOCK_PROJECTILE_N);
add(x, z + 1, FLAG_BLOCK_PROJECTILE_S);
add(x + 1, z, FLAG_BLOCK_PROJECTILE_W);
} else if (rotation == 2) {
add(x, z, FLAG_BLOCK_PROJECTILE_E|FLAG_BLOCK_PROJECTILE_S);
add(x, z, FLAG_BLOCK_PROJECTILE_E | FLAG_BLOCK_PROJECTILE_S);
add(x + 1, z, FLAG_BLOCK_PROJECTILE_W);
add(x, z - 1, FLAG_BLOCK_PROJECTILE_N);
} else if (rotation == 3) {
add(x, z, FLAG_BLOCK_PROJECTILE_W|FLAG_BLOCK_PROJECTILE_S);
add(x, z, FLAG_BLOCK_PROJECTILE_W | FLAG_BLOCK_PROJECTILE_S);
add(x, z - 1, FLAG_BLOCK_PROJECTILE_N);
add(x - 1, z, FLAG_BLOCK_PROJECTILE_E);
}
@@ -211,19 +211,19 @@ public class CollisionMap {
}
} else if (type == 2) {
if (rotation == 0) {
remove(x, z, FLAG_BLOCK_ENTITY_W|FLAG_BLOCK_ENTITY_N);
remove(x, z, FLAG_BLOCK_ENTITY_W | FLAG_BLOCK_ENTITY_N);
remove(x - 1, z, FLAG_BLOCK_ENTITY_E);
remove(x, z + 1, FLAG_BLOCK_ENTITY_S);
} else if (rotation == 1) {
remove(x, z, FLAG_BLOCK_ENTITY_E|FLAG_BLOCK_ENTITY_N);
remove(x, z, FLAG_BLOCK_ENTITY_E | FLAG_BLOCK_ENTITY_N);
remove(x, z + 1, FLAG_BLOCK_ENTITY_S);
remove(x + 1, z, FLAG_BLOCK_ENTITY_W);
} else if (rotation == 2) {
remove(x, z, FLAG_BLOCK_ENTITY_E|FLAG_BLOCK_ENTITY_S);
remove(x, z, FLAG_BLOCK_ENTITY_E | FLAG_BLOCK_ENTITY_S);
remove(x + 1, z, FLAG_BLOCK_ENTITY_W);
remove(x, z - 1, FLAG_BLOCK_ENTITY_N);
} else if (rotation == 3) {
remove(x, z, FLAG_BLOCK_ENTITY_W|FLAG_BLOCK_ENTITY_S);
remove(x, z, FLAG_BLOCK_ENTITY_W | FLAG_BLOCK_ENTITY_S);
remove(x, z - 1, FLAG_BLOCK_ENTITY_N);
remove(x - 1, z, FLAG_BLOCK_ENTITY_E);
}
@@ -259,19 +259,19 @@ public class CollisionMap {
}
} else if (type == 2) {
if (rotation == 0) {
remove(x, z, FLAG_BLOCK_PROJECTILE_W|FLAG_BLOCK_PROJECTILE_N);
remove(x, z, FLAG_BLOCK_PROJECTILE_W | FLAG_BLOCK_PROJECTILE_N);
remove(x - 1, z, FLAG_BLOCK_PROJECTILE_E);
remove(x, z + 1, FLAG_BLOCK_PROJECTILE_S);
} else if (rotation == 1) {
remove(x, z, FLAG_BLOCK_PROJECTILE_E|FLAG_BLOCK_PROJECTILE_N);
remove(x, z, FLAG_BLOCK_PROJECTILE_E | FLAG_BLOCK_PROJECTILE_N);
remove(x, z + 1, FLAG_BLOCK_PROJECTILE_S);
remove(x + 1, z, FLAG_BLOCK_PROJECTILE_W);
} else if (rotation == 2) {
remove(x, z, FLAG_BLOCK_PROJECTILE_E|FLAG_BLOCK_PROJECTILE_S);
remove(x, z, FLAG_BLOCK_PROJECTILE_E | FLAG_BLOCK_PROJECTILE_S);
remove(x + 1, z, FLAG_BLOCK_PROJECTILE_W);
remove(x, z - 1, FLAG_BLOCK_PROJECTILE_N);
} else if (rotation == 3) {
remove(x, z, FLAG_BLOCK_PROJECTILE_W|FLAG_BLOCK_PROJECTILE_S);
remove(x, z, FLAG_BLOCK_PROJECTILE_W | FLAG_BLOCK_PROJECTILE_S);
remove(x, z - 1, FLAG_BLOCK_PROJECTILE_N);
remove(x - 1, z, FLAG_BLOCK_PROJECTILE_E);
}
+142 -142
View File
@@ -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) {
}
}
}
+97 -97
View File
@@ -1,114 +1,114 @@
public class DoublyLinkedList {
public static class Node {
public static class Node {
public Node prev;
public Node next;
public Node prev;
public Node next;
public void unlink() {
if (next != null) {
next.prev = prev;
prev.next = next;
prev = null;
next = null;
}
}
public void unlink() {
if (next != null) {
next.prev = prev;
prev.next = next;
prev = null;
next = null;
}
}
}
}
public final Node head;
public Node peeked;
public final Node head;
public Node peeked;
public DoublyLinkedList() {
head = new Node();
head.prev = head;
head.next = head;
}
public DoublyLinkedList() {
head = new Node();
head.prev = head;
head.next = head;
}
public void pushBack(Node node) {
if (node.next != null) {
node.unlink();
}
node.next = head.next;
node.prev = head;
node.next.prev = node;
node.prev.next = node;
}
public void pushBack(Node node) {
if (node.next != null) {
node.unlink();
}
node.next = head.next;
node.prev = head;
node.next.prev = node;
node.prev.next = node;
}
public void pushFront(Node node) {
if (node.next != null) {
node.unlink();
}
node.next = head;
node.prev = head.prev;
node.next.prev = node;
node.prev.next = node;
}
public void pushFront(Node node) {
if (node.next != null) {
node.unlink();
}
node.next = head;
node.prev = head.prev;
node.next.prev = node;
node.prev.next = node;
}
public Node pollFront() {
Node node = head.prev;
if (node == head) {
return null;
} else {
node.unlink();
return node;
}
}
public Node pollFront() {
Node node = head.prev;
if (node == head) {
return null;
} else {
node.unlink();
return node;
}
}
public Node peekFront() {
Node node = head.prev;
if (node == head) {
peeked = null;
return null;
} else {
peeked = node.prev;
return node;
}
}
public Node peekFront() {
Node node = head.prev;
if (node == head) {
peeked = null;
return null;
} else {
peeked = node.prev;
return node;
}
}
public Node peekBack() {
Node node = head.next;
if (node == head) {
peeked = null;
return null;
} else {
peeked = node.next;
return node;
}
}
public Node peekBack() {
Node node = head.next;
if (node == head) {
peeked = null;
return null;
} else {
peeked = node.next;
return node;
}
}
public Node prev() {
Node node = peeked;
if (node == head) {
peeked = null;
return null;
} else {
peeked = node.prev;
return node;
}
}
public Node prev() {
Node node = peeked;
if (node == head) {
peeked = null;
return null;
} else {
peeked = node.prev;
return node;
}
}
public Node next() {
Node node = peeked;
if (node == head) {
peeked = null;
return null;
}
peeked = node.next;
return node;
}
public Node next() {
Node node = peeked;
if (node == head) {
peeked = null;
return null;
}
peeked = node.next;
return node;
}
public void clear() {
if (head.prev == head) {
return;
}
do {
Node node = head.prev;
if (node == head) {
return;
}
node.unlink();
} while (true);
}
public void clear() {
if (head.prev == head) {
return;
}
do {
Node node = head.prev;
if (node == head) {
return;
}
node.unlink();
} while (true);
}
}
+231 -230
View File
@@ -2,286 +2,287 @@ import java.util.Arrays;
public class Draw2D {
public static int[] pixels;
public static int width;
public static int height;
public static int top;
public static int bottom;
public static int left;
public static int right;
public static int boundX;
public static int centerX;
public static int centerY;
public static int[] pixels;
public static int width;
public static int height;
public static int top;
public static int bottom;
public static int left;
public static int right;
public static int boundX;
public static int centerX;
public static int centerY;
public static void bind(int[] pixels, int width, int height) {
Draw2D.pixels = pixels;
Draw2D.width = width;
Draw2D.height = height;
setBounds(0, 0, width, height);
}
public static void bind(int[] pixels, int width, int height) {
Draw2D.pixels = pixels;
Draw2D.width = width;
Draw2D.height = height;
setBounds(0, 0, width, height);
}
public static void resetBounds() {
left = 0;
top = 0;
right = width;
bottom = height;
boundX = right - 1;
centerX = right / 2;
}
public static void resetBounds() {
left = 0;
top = 0;
right = width;
bottom = height;
boundX = right - 1;
centerX = right / 2;
}
public static void setBounds(int left, int top, int right, int bottom) {
if (left < 0) {
left = 0;
}
if (top < 0) {
top = 0;
}
if (right > width) {
right = width;
}
if (bottom > height) {
bottom = height;
}
Draw2D.left = left;
Draw2D.top = top;
Draw2D.right = right;
Draw2D.bottom = bottom;
boundX = Draw2D.right - 1;
centerX = Draw2D.right / 2;
centerY = Draw2D.bottom / 2;
}
public static void setBounds(int left, int top, int right, int bottom) {
if (left < 0) {
left = 0;
}
if (top < 0) {
top = 0;
}
if (right > width) {
right = width;
}
if (bottom > height) {
bottom = height;
}
Draw2D.left = left;
Draw2D.top = top;
Draw2D.right = right;
Draw2D.bottom = bottom;
boundX = Draw2D.right - 1;
centerX = Draw2D.right / 2;
centerY = Draw2D.bottom / 2;
}
public static void clear() {
Arrays.fill(pixels, 0);
}
public static void clear() {
Arrays.fill(pixels, 0);
}
/**
* Bresenham's line algorithm.
* @param x1 the first x coordinate.
* @param y1 the first y coordinate.
* @param x2 the second x coordinate.
* @param y2 the second y coordinate.
* @param rgb the color.
*/
public static void drawLine(int x1, int y1, int x2, int y2, int rgb) {
int dx = Math.abs(x2 - x1);
int dy = Math.abs(y2 - y1);
/**
* Bresenham's line algorithm.
*
* @param x1 the first x coordinate.
* @param y1 the first y coordinate.
* @param x2 the second x coordinate.
* @param y2 the second y coordinate.
* @param rgb the color.
*/
public static void drawLine(int x1, int y1, int x2, int y2, int rgb) {
int dx = Math.abs(x2 - x1);
int dy = Math.abs(y2 - y1);
int sx = (x1 < x2) ? 1 : -1;
int sy = (y1 < y2) ? 1 : -1;
int sx = (x1 < x2) ? 1 : -1;
int sy = (y1 < y2) ? 1 : -1;
int err = dx - dy;
int err = dx - dy;
while (true) {
if ((x1 >= left) && (x1 < right) && (y1 >= top) && (y1 < bottom)) {
pixels[x1 + (y1 * width)] = rgb;
}
while (true) {
if ((x1 >= left) && (x1 < right) && (y1 >= top) && (y1 < bottom)) {
pixels[x1 + (y1 * width)] = rgb;
}
if ((x1 == x2) && (y1 == y2)) {
break;
}
if ((x1 == x2) && (y1 == y2)) {
break;
}
int e2 = 2 * err;
int e2 = 2 * err;
if (e2 > -dy) {
err = err - dy;
x1 = x1 + sx;
}
if (e2 > -dy) {
err = err - dy;
x1 = x1 + sx;
}
if (e2 < dx) {
err = err + dx;
y1 = y1 + sy;
}
}
if (e2 < dx) {
err = err + dx;
y1 = y1 + sy;
}
}
}
}
public static void fillRect(int x, int y, int width, int height, int rgb, int alpha) {
if (x < left) {
width -= left - x;
x = left;
}
public static void fillRect(int x, int y, int width, int height, int rgb, int alpha) {
if (x < left) {
width -= left - x;
x = left;
}
if (y < top) {
height -= top - y;
y = top;
}
if (y < top) {
height -= top - y;
y = top;
}
if ((x + width) > right) {
width = right - x;
}
if ((x + width) > right) {
width = right - x;
}
if ((y + height) > bottom) {
height = bottom - y;
}
if ((y + height) > bottom) {
height = bottom - y;
}
int invAlpha = 256 - alpha;
int r0 = ((rgb >> 16) & 0xff) * alpha;
int g0 = ((rgb >> 8) & 0xff) * alpha;
int b0 = (rgb & 0xff) * alpha;
int invAlpha = 256 - alpha;
int r0 = ((rgb >> 16) & 0xff) * alpha;
int g0 = ((rgb >> 8) & 0xff) * alpha;
int b0 = (rgb & 0xff) * alpha;
int step = Draw2D.width - width;
int offset = x + (y * Draw2D.width);
int step = Draw2D.width - width;
int offset = x + (y * Draw2D.width);
for (int i = 0; i < height; i++) {
for (int j = -width; j < 0; j++) {
int r1 = ((pixels[offset] >> 16) & 0xff) * invAlpha;
int g1 = ((pixels[offset] >> 8) & 0xff) * invAlpha;
int b1 = (pixels[offset] & 0xff) * invAlpha;
pixels[offset++] = (((r0 + r1) >> 8) << 16) + (((g0 + g1) >> 8) << 8) + ((b0 + b1) >> 8);
}
offset += step;
}
}
for (int i = 0; i < height; i++) {
for (int j = -width; j < 0; j++) {
int r1 = ((pixels[offset] >> 16) & 0xff) * invAlpha;
int g1 = ((pixels[offset] >> 8) & 0xff) * invAlpha;
int b1 = (pixels[offset] & 0xff) * invAlpha;
pixels[offset++] = (((r0 + r1) >> 8) << 16) + (((g0 + g1) >> 8) << 8) + ((b0 + b1) >> 8);
}
offset += step;
}
}
public static void fillRect(int x, int y, int width, int height, int rgb) {
if (x < left) {
width -= left - x;
x = left;
}
public static void fillRect(int x, int y, int width, int height, int rgb) {
if (x < left) {
width -= left - x;
x = left;
}
if (y < top) {
height -= top - y;
y = top;
}
if (y < top) {
height -= top - y;
y = top;
}
if ((x + width) > right) {
width = right - x;
}
if ((x + width) > right) {
width = right - x;
}
if ((y + height) > bottom) {
height = bottom - y;
}
if ((y + height) > bottom) {
height = bottom - y;
}
int step = Draw2D.width - width;
int offset = x + (y * Draw2D.width);
int step = Draw2D.width - width;
int offset = x + (y * Draw2D.width);
for (int i = -height; i < 0; i++) {
for (int j = -width; j < 0; j++) {
pixels[offset++] = rgb;
}
offset += step;
}
}
for (int i = -height; i < 0; i++) {
for (int j = -width; j < 0; j++) {
pixels[offset++] = rgb;
}
offset += step;
}
}
public static void drawRect(int x, int y, int width, int height, int rgb) {
drawLineX(x, y, width, rgb);
drawLineX(x, (y + height) - 1, width, rgb);
drawLineY(x, y, height, rgb);
drawLineY((x + width) - 1, y, height, rgb);
}
public static void drawRect(int x, int y, int width, int height, int rgb) {
drawLineX(x, y, width, rgb);
drawLineX(x, (y + height) - 1, width, rgb);
drawLineY(x, y, height, rgb);
drawLineY((x + width) - 1, y, height, rgb);
}
public static void drawRect(int x, int y, int width, int height, int rgb, int alpha) {
drawLineX(x, y, width, rgb, alpha);
drawLineX(x, (y + height) - 1, width, rgb, alpha);
if (height >= 3) {
drawLineY(rgb, x, alpha, y + 1, height - 2);
drawLineY(rgb, (x + width) - 1, alpha, y + 1, height - 2);
}
}
public static void drawRect(int x, int y, int width, int height, int rgb, int alpha) {
drawLineX(x, y, width, rgb, alpha);
drawLineX(x, (y + height) - 1, width, rgb, alpha);
if (height >= 3) {
drawLineY(rgb, x, alpha, y + 1, height - 2);
drawLineY(rgb, (x + width) - 1, alpha, y + 1, height - 2);
}
}
public static void drawLineX(int x, int y, int length, int rgb) {
if ((y < top) || (y >= bottom)) {
return;
}
public static void drawLineX(int x, int y, int length, int rgb) {
if ((y < top) || (y >= bottom)) {
return;
}
if (x < left) {
length -= left - x;
x = left;
}
if (x < left) {
length -= left - x;
x = left;
}
if ((x + length) > right) {
length = right - x;
}
if ((x + length) > right) {
length = right - x;
}
int offset = x + (y * width);
int offset = x + (y * width);
for (int i = 0; i < length; i++) {
pixels[offset + i] = rgb;
}
}
for (int i = 0; i < length; i++) {
pixels[offset + i] = rgb;
}
}
public static void drawLineX(int x, int y, int length, int rgb, int alpha) {
if ((y < top) || (y >= bottom)) {
return;
}
public static void drawLineX(int x, int y, int length, int rgb, int alpha) {
if ((y < top) || (y >= bottom)) {
return;
}
if (x < left) {
length -= left - x;
x = left;
}
if (x < left) {
length -= left - x;
x = left;
}
if ((x + length) > right) {
length = right - x;
}
if ((x + length) > right) {
length = right - x;
}
int invAlpha = 256 - alpha;
int r0 = ((rgb >> 16) & 0xff) * alpha;
int g0 = ((rgb >> 8) & 0xff) * alpha;
int b0 = (rgb & 0xff) * alpha;
int invAlpha = 256 - alpha;
int r0 = ((rgb >> 16) & 0xff) * alpha;
int g0 = ((rgb >> 8) & 0xff) * alpha;
int b0 = (rgb & 0xff) * alpha;
int offset = x + (y * width);
int offset = x + (y * width);
for (int i = 0; i < length; i++) {
int r1 = ((pixels[offset] >> 16) & 0xff) * invAlpha;
int g1 = ((pixels[offset] >> 8) & 0xff) * invAlpha;
int b1 = (pixels[offset] & 0xff) * invAlpha;
pixels[offset++] = (((r0 + r1) >> 8) << 16) + (((g0 + g1) >> 8) << 8) + ((b0 + b1) >> 8);
}
}
for (int i = 0; i < length; i++) {
int r1 = ((pixels[offset] >> 16) & 0xff) * invAlpha;
int g1 = ((pixels[offset] >> 8) & 0xff) * invAlpha;
int b1 = (pixels[offset] & 0xff) * invAlpha;
pixels[offset++] = (((r0 + r1) >> 8) << 16) + (((g0 + g1) >> 8) << 8) + ((b0 + b1) >> 8);
}
}
public static void drawLineY(int x, int y, int length, int rgb) {
if ((x < left) || (x >= right)) {
return;
}
public static void drawLineY(int x, int y, int length, int rgb) {
if ((x < left) || (x >= right)) {
return;
}
if (y < top) {
length -= top - y;
y = top;
}
if (y < top) {
length -= top - y;
y = top;
}
if ((y + length) > bottom) {
length = bottom - y;
}
if ((y + length) > bottom) {
length = bottom - y;
}
int offset = x + (y * width);
int offset = x + (y * width);
for (int i = 0; i < length; i++) {
pixels[offset + (i * width)] = rgb;
}
}
for (int i = 0; i < length; i++) {
pixels[offset + (i * width)] = rgb;
}
}
public static void drawLineY(int rgb, int x, int alpha, int y, int length) {
if ((x < left) || (x >= right)) {
return;
}
public static void drawLineY(int rgb, int x, int alpha, int y, int length) {
if ((x < left) || (x >= right)) {
return;
}
if (y < top) {
length -= top - y;
y = top;
}
if (y < top) {
length -= top - y;
y = top;
}
if ((y + length) > bottom) {
length = bottom - y;
}
if ((y + length) > bottom) {
length = bottom - y;
}
int invAlpha = 256 - alpha;
int r0 = ((rgb >> 16) & 0xff) * alpha;
int g0 = ((rgb >> 8) & 0xff) * alpha;
int b0 = (rgb & 0xff) * alpha;
int invAlpha = 256 - alpha;
int r0 = ((rgb >> 16) & 0xff) * alpha;
int g0 = ((rgb >> 8) & 0xff) * alpha;
int b0 = (rgb & 0xff) * alpha;
int offset = x + (y * width);
int offset = x + (y * width);
for (int i = 0; i < length; i++) {
int r1 = ((pixels[offset] >> 16) & 0xff) * invAlpha;
int g1 = ((pixels[offset] >> 8) & 0xff) * invAlpha;
int b1 = (pixels[offset] & 0xff) * invAlpha;
pixels[offset] = (((r0 + r1) >> 8) << 16) + (((g0 + g1) >> 8) << 8) + ((b0 + b1) >> 8);
offset += width;
}
}
for (int i = 0; i < length; i++) {
int r1 = ((pixels[offset] >> 16) & 0xff) * invAlpha;
int g1 = ((pixels[offset] >> 8) & 0xff) * invAlpha;
int b1 = (pixels[offset] & 0xff) * invAlpha;
pixels[offset] = (((r0 + r1) >> 8) << 16) + (((g0 + g1) >> 8) << 8) + ((b0 + b1) >> 8);
offset += width;
}
}
public Draw2D() {
}
public Draw2D() {
}
}
+1 -1
View File
@@ -405,7 +405,7 @@ public class Draw3D {
/**
* Returns the <code>rgb</code> with each component raised to the power of <code>gamma</code>
*
* @param rgb the input rgb.
* @param rgb the input rgb.
* @param gamma the gamma.
* @return the result.
*/
+21 -21
View File
@@ -8,30 +8,30 @@ import java.awt.image.DataBufferInt;
public class DrawArea {
public final int[] pixels;
public final int width;
public final int height;
public final BufferedImage image;
public final int[] pixels;
public final int width;
public final int height;
public final BufferedImage image;
public DrawArea(int width, int height) {
this.width = width;
this.height = height;
this.image = new BufferedImage(this.width, this.height, BufferedImage.TYPE_INT_RGB);
this.pixels = ((DataBufferInt) this.image.getRaster().getDataBuffer()).getData();
bind();
}
public DrawArea(int width, int height) {
this.width = width;
this.height = height;
this.image = new BufferedImage(this.width, this.height, BufferedImage.TYPE_INT_RGB);
this.pixels = ((DataBufferInt) this.image.getRaster().getDataBuffer()).getData();
bind();
}
public DrawArea(Image24 image) {
this(image.width, image.height);
image.blitOpaque(0, 0);
}
public DrawArea(Image24 image) {
this(image.width, image.height);
image.blitOpaque(0, 0);
}
public void bind() {
Draw2D.bind(pixels, width, height);
}
public void bind() {
Draw2D.bind(pixels, width, height);
}
public void draw(Graphics g, int x, int y) {
g.drawImage(image, x, y, null);
}
public void draw(Graphics g, int x, int y) {
g.drawImage(image, x, y, null);
}
}
+14 -14
View File
@@ -1,22 +1,22 @@
public class Entity extends DoublyLinkedList.Node {
public VertexNormal[] vertexNormal;
public int minY = 1000;
public VertexNormal[] vertexNormal;
public int minY = 1000;
public Entity() {
}
public Entity() {
}
public void draw(int yaw, int sinEyePitch, int cosEyePitch, int sinEyeYaw, int cosEyeYaw, int relativeX, int relativeY, int relativeZ, int bitset) {
Model model = getModel();
public void draw(int yaw, int sinEyePitch, int cosEyePitch, int sinEyeYaw, int cosEyeYaw, int relativeX, int relativeY, int relativeZ, int bitset) {
Model model = getModel();
if (model != null) {
minY = model.minY;
model.draw(yaw, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, relativeX, relativeY, relativeZ, bitset);
}
}
if (model != null) {
minY = model.minY;
model.draw(yaw, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, relativeX, relativeY, relativeZ, bitset);
}
}
public Model getModel() {
return null;
}
public Model getModel() {
return null;
}
}
+66 -66
View File
@@ -9,83 +9,83 @@ import java.nio.file.Path;
*/
public class FileArchive {
public byte[] data;
public int fileCount;
public int[] fileHash;
public int[] fileSizeInflated;
public int[] fileSizeDeflated;
public int[] fileOffset;
public boolean unpacked;
public byte[] data;
public int fileCount;
public int[] fileHash;
public int[] fileSizeInflated;
public int[] fileSizeDeflated;
public int[] fileOffset;
public boolean unpacked;
public FileArchive(byte[] src) throws IOException {
load(src);
}
public FileArchive(byte[] src) throws IOException {
load(src);
}
public void load(byte[] src) throws IOException {
Buffer buffer = new Buffer(src);
public void load(byte[] src) throws IOException {
Buffer buffer = new Buffer(src);
int unpackedSize = buffer.read24();
int packedSize = buffer.read24();
int unpackedSize = buffer.read24();
int packedSize = buffer.read24();
if (packedSize != unpackedSize) {
data = new byte[unpackedSize];
BZip2.decompress(src, 6, packedSize, data);
buffer = new Buffer(data);
unpacked = true;
} else {
data = src;
unpacked = false;
}
if (packedSize != unpackedSize) {
data = new byte[unpackedSize];
BZip2.decompress(src, 6, packedSize, data);
buffer = new Buffer(data);
unpacked = true;
} else {
data = src;
unpacked = false;
}
fileCount = buffer.read16U();
fileHash = new int[fileCount];
fileSizeInflated = new int[fileCount];
fileSizeDeflated = new int[fileCount];
fileOffset = new int[fileCount];
fileCount = buffer.read16U();
fileHash = new int[fileCount];
fileSizeInflated = new int[fileCount];
fileSizeDeflated = new int[fileCount];
fileOffset = new int[fileCount];
int offset = buffer.position + (fileCount * 10);
int offset = buffer.position + (fileCount * 10);
for (int file = 0; file < fileCount; file++) {
fileHash[file] = buffer.read32();
fileSizeInflated[file] = buffer.read24();
fileSizeDeflated[file] = buffer.read24();
fileOffset[file] = offset;
offset += fileSizeDeflated[file];
}
}
for (int file = 0; file < fileCount; file++) {
fileHash[file] = buffer.read32();
fileSizeInflated[file] = buffer.read24();
fileSizeDeflated[file] = buffer.read24();
fileOffset[file] = offset;
offset += fileSizeDeflated[file];
}
}
public void export(String s, Path dst) throws IOException {
byte[] data = read(s);
if (data == null) {
throw new FileNotFoundException(s);
}
try (OutputStream out = Files.newOutputStream(dst)) {
out.write(data);
}
}
public void export(String s, Path dst) throws IOException {
byte[] data = read(s);
if (data == null) {
throw new FileNotFoundException(s);
}
try (OutputStream out = Files.newOutputStream(dst)) {
out.write(data);
}
}
public byte[] read(String s) throws IOException {
int hash = 0;
s = s.toUpperCase();
for (int j = 0; j < s.length(); j++) {
hash = ((hash * 61) + s.charAt(j)) - 32;
}
public byte[] read(String s) throws IOException {
int hash = 0;
s = s.toUpperCase();
for (int j = 0; j < s.length(); j++) {
hash = ((hash * 61) + s.charAt(j)) - 32;
}
for (int file = 0; file < fileCount; file++) {
if (fileHash[file] != hash) {
continue;
}
for (int file = 0; file < fileCount; file++) {
if (fileHash[file] != hash) {
continue;
}
byte[] dst = new byte[fileSizeInflated[file]];
byte[] dst = new byte[fileSizeInflated[file]];
if (!unpacked) {
BZip2.decompress(data, fileOffset[file], fileSizeDeflated[file], dst);
} else {
System.arraycopy(data, fileOffset[file], dst, 0, fileSizeInflated[file]);
}
return dst;
}
return null;
}
if (!unpacked) {
BZip2.decompress(data, fileOffset[file], fileSizeDeflated[file], dst);
} else {
System.arraycopy(data, fileOffset[file], dst, 0, fileSizeInflated[file]);
}
return dst;
}
return null;
}
}
+143 -143
View File
@@ -7,186 +7,186 @@ import java.io.RandomAccessFile;
public class FileStore {
public static final byte[] buf = new byte[520];
public final RandomAccessFile dat;
public final RandomAccessFile idx;
public final int store;
public int maxFileSize;
public static final byte[] buf = new byte[520];
public final RandomAccessFile dat;
public final RandomAccessFile idx;
public final int store;
public int maxFileSize;
public FileStore(int maxFileSize, RandomAccessFile dat, RandomAccessFile idx, int store) {
this.maxFileSize = 65000;
this.store = store;
this.dat = dat;
this.idx = idx;
this.maxFileSize = maxFileSize;
}
public FileStore(int maxFileSize, RandomAccessFile dat, RandomAccessFile idx, int store) {
this.maxFileSize = 65000;
this.store = store;
this.dat = dat;
this.idx = idx;
this.maxFileSize = maxFileSize;
}
public synchronized long getFileCount() throws IOException {
return idx.length() / 6L;
}
public synchronized long getFileCount() throws IOException {
return idx.length() / 6L;
}
public synchronized byte[] read(int file) {
try {
idx.seek(file * 6L);
public synchronized byte[] read(int file) {
try {
idx.seek(file * 6L);
idx.read(buf, 0, 6);
idx.read(buf, 0, 6);
int size = ((buf[0] & 0xff) << 16) + ((buf[1] & 0xff) << 8) + (buf[2] & 0xff);
int sector = ((buf[3] & 0xff) << 16) + ((buf[4] & 0xff) << 8) + (buf[5] & 0xff);
int size = ((buf[0] & 0xff) << 16) + ((buf[1] & 0xff) << 8) + (buf[2] & 0xff);
int sector = ((buf[3] & 0xff) << 16) + ((buf[4] & 0xff) << 8) + (buf[5] & 0xff);
if (size > maxFileSize) {
return null;
}
if (size > maxFileSize) {
return null;
}
if ((sector <= 0) || ((long) sector > (dat.length() / 520L))) {
return null;
}
if ((sector <= 0) || ((long) sector > (dat.length() / 520L))) {
return null;
}
byte[] data = new byte[size];
int position = 0;
byte[] data = new byte[size];
int position = 0;
for (int part = 0; position < size; part++) {
if (sector == 0) {
return null;
}
for (int part = 0; position < size; part++) {
if (sector == 0) {
return null;
}
dat.seek(sector * 520L);
dat.seek(sector * 520L);
int available = size - position;
int available = size - position;
if (available > 512) {
available = 512;
}
if (available > 512) {
available = 512;
}
dat.read(buf, 0, available + 8);
dat.read(buf, 0, available + 8);
int sectorFile = ((buf[0] & 0xff) << 8) + (buf[1] & 0xff);
int sectorPart = ((buf[2] & 0xff) << 8) + (buf[3] & 0xff);
int nextSector = ((buf[4] & 0xff) << 16) + ((buf[5] & 0xff) << 8) + (buf[6] & 0xff);
int sectorStore = buf[7] & 0xff;
int sectorFile = ((buf[0] & 0xff) << 8) + (buf[1] & 0xff);
int sectorPart = ((buf[2] & 0xff) << 8) + (buf[3] & 0xff);
int nextSector = ((buf[4] & 0xff) << 16) + ((buf[5] & 0xff) << 8) + (buf[6] & 0xff);
int sectorStore = buf[7] & 0xff;
if ((sectorFile != file) || (sectorPart != part) || (sectorStore != store)) {
return null;
}
if ((sectorFile != file) || (sectorPart != part) || (sectorStore != store)) {
return null;
}
if ((nextSector < 0) || ((long) nextSector > (dat.length() / 520L))) {
return null;
}
if ((nextSector < 0) || ((long) nextSector > (dat.length() / 520L))) {
return null;
}
for (int i = 0; i < available; i++) {
data[position++] = buf[i + 8];
}
for (int i = 0; i < available; i++) {
data[position++] = buf[i + 8];
}
sector = nextSector;
}
return data;
} catch (IOException e) {
return null;
}
}
sector = nextSector;
}
return data;
} catch (IOException e) {
return null;
}
}
public synchronized void write(byte[] src, int file, int size) {
boolean written = write(src, file, size, true);
if (!written) {
write(src, file, size, false);
}
}
public synchronized void write(byte[] src, int file, int size) {
boolean written = write(src, file, size, true);
if (!written) {
write(src, file, size, false);
}
}
public synchronized boolean write(byte[] data, int file, int size, boolean overwrite) {
try {
int sector;
public synchronized boolean write(byte[] data, int file, int size, boolean overwrite) {
try {
int sector;
if (overwrite) {
idx.seek(file * 6L);
idx.read(buf, 0, 6);
if (overwrite) {
idx.seek(file * 6L);
idx.read(buf, 0, 6);
sector = ((buf[3] & 0xff) << 16) + ((buf[4] & 0xff) << 8) + (buf[5] & 0xff);
sector = ((buf[3] & 0xff) << 16) + ((buf[4] & 0xff) << 8) + (buf[5] & 0xff);
if ((sector <= 0) || ((long) sector > (dat.length() / 520L))) {
return false;
}
} else {
sector = (int) ((dat.length() + 519L) / 520L);
if ((sector <= 0) || ((long) sector > (dat.length() / 520L))) {
return false;
}
} else {
sector = (int) ((dat.length() + 519L) / 520L);
if (sector == 0) {
sector = 1;
}
}
if (sector == 0) {
sector = 1;
}
}
buf[0] = (byte) (size >> 16);
buf[1] = (byte) (size >> 8);
buf[2] = (byte) size;
buf[3] = (byte) (sector >> 16);
buf[4] = (byte) (sector >> 8);
buf[5] = (byte) sector;
buf[0] = (byte) (size >> 16);
buf[1] = (byte) (size >> 8);
buf[2] = (byte) size;
buf[3] = (byte) (sector >> 16);
buf[4] = (byte) (sector >> 8);
buf[5] = (byte) sector;
idx.seek(file * 6L);
idx.write(buf, 0, 6);
idx.seek(file * 6L);
idx.write(buf, 0, 6);
int written = 0;
for (int part = 0; written < size; part++) {
int nextSector = 0;
int written = 0;
for (int part = 0; written < size; part++) {
int nextSector = 0;
if (overwrite) {
dat.seek(sector * 520L);
if (overwrite) {
dat.seek(sector * 520L);
if (dat.read(buf, 0, 8) == 8) {
int sectorFile = ((buf[0] & 0xff) << 8) + (buf[1] & 0xff);
int sectorPart = ((buf[2] & 0xff) << 8) + (buf[3] & 0xff);
nextSector = ((buf[4] & 0xff) << 16) + ((buf[5] & 0xff) << 8) + (buf[6] & 0xff);
int sectorStore = buf[7] & 0xff;
if ((sectorFile != file) || (sectorPart != part) || (sectorStore != store)) {
return false;
}
if ((nextSector < 0) || ((long) nextSector > (dat.length() / 520L))) {
return false;
}
}
}
if (dat.read(buf, 0, 8) == 8) {
int sectorFile = ((buf[0] & 0xff) << 8) + (buf[1] & 0xff);
int sectorPart = ((buf[2] & 0xff) << 8) + (buf[3] & 0xff);
nextSector = ((buf[4] & 0xff) << 16) + ((buf[5] & 0xff) << 8) + (buf[6] & 0xff);
int sectorStore = buf[7] & 0xff;
if ((sectorFile != file) || (sectorPart != part) || (sectorStore != store)) {
return false;
}
if ((nextSector < 0) || ((long) nextSector > (dat.length() / 520L))) {
return false;
}
}
}
if (nextSector == 0) {
overwrite = false;
nextSector = (int) ((dat.length() + 519L) / 520L);
if (nextSector == 0) {
overwrite = false;
nextSector = (int) ((dat.length() + 519L) / 520L);
if (nextSector == 0) {
nextSector++;
}
if (nextSector == 0) {
nextSector++;
}
if (nextSector == sector) {
nextSector++;
}
}
if (nextSector == sector) {
nextSector++;
}
}
if ((size - written) <= 512) {
nextSector = 0;
}
if ((size - written) <= 512) {
nextSector = 0;
}
buf[0] = (byte) (file >> 8);
buf[1] = (byte) file;
buf[2] = (byte) (part >> 8);
buf[3] = (byte) part;
buf[4] = (byte) (nextSector >> 16);
buf[5] = (byte) (nextSector >> 8);
buf[6] = (byte) nextSector;
buf[7] = (byte) store;
buf[0] = (byte) (file >> 8);
buf[1] = (byte) file;
buf[2] = (byte) (part >> 8);
buf[3] = (byte) part;
buf[4] = (byte) (nextSector >> 16);
buf[5] = (byte) (nextSector >> 8);
buf[6] = (byte) nextSector;
buf[7] = (byte) store;
dat.seek(sector * 520L);
dat.write(buf, 0, 8);
dat.seek(sector * 520L);
dat.write(buf, 0, 8);
int available = size - written;
int available = size - written;
if (available > 512) {
available = 512;
}
if (available > 512) {
available = 512;
}
dat.write(data, written, available);
written += available;
sector = nextSector;
}
return true;
} catch (IOException e) {
return false;
}
}
dat.write(data, written, available);
written += available;
sector = nextSector;
}
return true;
} catch (IOException e) {
return false;
}
}
}
+12 -12
View File
@@ -7,18 +7,18 @@ import java.awt.*;
public class GameFrame extends JFrame {
public final GameShell shell;
public final GameShell shell;
public GameFrame(GameShell shell) {
this.shell = shell;
setTitle("Jagex");
setResizable(false);
setLayout(new BorderLayout());
add(shell, BorderLayout.CENTER);
pack();
setLocationRelativeTo(null);
setVisible(true);
transferFocus();
}
public GameFrame(GameShell shell) {
this.shell = shell;
setTitle("Jagex");
setResizable(false);
setLayout(new BorderLayout());
add(shell, BorderLayout.CENTER);
pack();
setLocationRelativeTo(null);
setVisible(true);
transferFocus();
}
}
File diff suppressed because it is too large. Load diff
+448 -448
View File
@@ -4,469 +4,469 @@ import java.io.IOException;
public class Image24 extends DoublyLinkedList.Node {
public int[] pixels;
public int width;
public int height;
public int cropX;
public int cropY;
public int cropW;
public int cropH;
public int[] pixels;
public int width;
public int height;
public int cropX;
public int cropY;
public int cropW;
public int cropH;
public Image24(int i, int j) {
pixels = new int[i * j];
width = cropW = i;
height = cropH = j;
cropX = cropY = 0;
}
public Image24(int i, int j) {
pixels = new int[i * j];
width = cropW = i;
height = cropH = j;
cropX = cropY = 0;
}
public Image24(byte[] src, java.awt.Component component) {
try {
java.awt.Image image = Toolkit.getDefaultToolkit().createImage(src);
MediaTracker tracker = new MediaTracker(component);
tracker.addImage(image, 0);
tracker.waitForAll();
width = image.getWidth(component);
height = image.getHeight(component);
cropW = width;
cropH = height;
cropX = 0;
cropY = 0;
pixels = new int[width * height];
PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, width, height, pixels, 0, width);
pixelgrabber.grabPixels();
} catch (Exception _ex) {
System.out.println("Error converting jpg");
}
}
public Image24(byte[] src, java.awt.Component component) {
try {
java.awt.Image image = Toolkit.getDefaultToolkit().createImage(src);
MediaTracker tracker = new MediaTracker(component);
tracker.addImage(image, 0);
tracker.waitForAll();
width = image.getWidth(component);
height = image.getHeight(component);
cropW = width;
cropH = height;
cropX = 0;
cropY = 0;
pixels = new int[width * height];
PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, width, height, pixels, 0, width);
pixelgrabber.grabPixels();
} catch (Exception _ex) {
System.out.println("Error converting jpg");
}
}
public Image24(FileArchive archive, String file, int index) throws IOException {
Buffer dat = new Buffer(archive.read(file + ".dat"));
Buffer idx = new Buffer(archive.read("index.dat"));
idx.position = dat.read16U();
cropW = idx.read16U();
cropH = idx.read16U();
int paletteSize = idx.read8U();
int[] palette = new int[paletteSize];
for (int k = 0; k < (paletteSize - 1); k++) {
palette[k + 1] = idx.read24();
if (palette[k + 1] == 0) {
palette[k + 1] = 1;
}
}
for (int i = 0; i < index; i++) {
idx.position += 2;
dat.position += idx.read16U() * idx.read16U();
idx.position++;
}
cropX = idx.read8U();
cropY = idx.read8U();
width = idx.read16U();
height = idx.read16U();
int layout = idx.read8U();
int pixelLen = width * height;
pixels = new int[pixelLen];
if (layout == 0) {
for (int i = 0; i < pixelLen; i++) {
pixels[i] = palette[dat.read8U()];
}
return;
}
if (layout == 1) {
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
pixels[x + (y * width)] = palette[dat.read8U()];
}
}
}
}
public Image24(FileArchive archive, String file, int index) throws IOException {
Buffer dat = new Buffer(archive.read(file + ".dat"));
Buffer idx = new Buffer(archive.read("index.dat"));
idx.position = dat.read16U();
cropW = idx.read16U();
cropH = idx.read16U();
int paletteSize = idx.read8U();
int[] palette = new int[paletteSize];
for (int k = 0; k < (paletteSize - 1); k++) {
palette[k + 1] = idx.read24();
if (palette[k + 1] == 0) {
palette[k + 1] = 1;
}
}
for (int i = 0; i < index; i++) {
idx.position += 2;
dat.position += idx.read16U() * idx.read16U();
idx.position++;
}
cropX = idx.read8U();
cropY = idx.read8U();
width = idx.read16U();
height = idx.read16U();
int layout = idx.read8U();
int pixelLen = width * height;
pixels = new int[pixelLen];
if (layout == 0) {
for (int i = 0; i < pixelLen; i++) {
pixels[i] = palette[dat.read8U()];
}
return;
}
if (layout == 1) {
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
pixels[x + (y * width)] = palette[dat.read8U()];
}
}
}
}
public void bind() {
Draw2D.bind(pixels, width, height);
}
public void bind() {
Draw2D.bind(pixels, width, height);
}
public void translate(int r, int g, int b) {
for (int i = 0; i < pixels.length; i++) {
int rgb = pixels[i];
if (rgb != 0) {
int red = (rgb >> 16) & 0xff;
red += r;
if (red < 1) {
red = 1;
} else if (red > 255) {
red = 255;
}
int green = (rgb >> 8) & 0xff;
green += g;
if (green < 1) {
green = 1;
} else if (green > 255) {
green = 255;
}
int blue = rgb & 0xff;
blue += b;
if (blue < 1) {
blue = 1;
} else if (blue > 255) {
blue = 255;
}
pixels[i] = (red << 16) + (green << 8) + blue;
}
}
}
public void translate(int r, int g, int b) {
for (int i = 0; i < pixels.length; i++) {
int rgb = pixels[i];
if (rgb != 0) {
int red = (rgb >> 16) & 0xff;
red += r;
if (red < 1) {
red = 1;
} else if (red > 255) {
red = 255;
}
int green = (rgb >> 8) & 0xff;
green += g;
if (green < 1) {
green = 1;
} else if (green > 255) {
green = 255;
}
int blue = rgb & 0xff;
blue += b;
if (blue < 1) {
blue = 1;
} else if (blue > 255) {
blue = 255;
}
pixels[i] = (red << 16) + (green << 8) + blue;
}
}
}
public void crop() {
int[] pixels = new int[cropW * cropH];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
pixels[((y + cropY) * cropW) + x + cropX] = this.pixels[(y * width) + x];
}
}
this.pixels = pixels;
width = cropW;
height = cropH;
cropX = 0;
cropY = 0;
}
public void crop() {
int[] pixels = new int[cropW * cropH];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
pixels[((y + cropY) * cropW) + x + cropX] = this.pixels[(y * width) + x];
}
}
this.pixels = pixels;
width = cropW;
height = cropH;
cropX = 0;
cropY = 0;
}
public void blitOpaque(int x, int y) {
x += cropX;
y += cropY;
int dstOff = x + (y * Draw2D.width);
int srcOff = 0;
int h = height;
int w = width;
int dstStep = Draw2D.width - w;
int srcStep = 0;
if (y < Draw2D.top) {
int trim = Draw2D.top - y;
h -= trim;
y = Draw2D.top;
srcOff += trim * w;
dstOff += trim * Draw2D.width;
}
if ((y + h) > Draw2D.bottom) {
h -= (y + h) - Draw2D.bottom;
}
if (x < Draw2D.left) {
int trim = Draw2D.left - x;
w -= trim;
x = Draw2D.left;
srcOff += trim;
dstOff += trim;
srcStep += trim;
dstStep += trim;
}
if ((x + w) > Draw2D.right) {
int trim = (x + w) - Draw2D.right;
w -= trim;
srcStep += trim;
dstStep += trim;
}
if ((w > 0) && (h > 0)) {
copyPixels(dstOff, w, h, srcStep, srcOff, dstStep, pixels, Draw2D.pixels);
}
}
public void blitOpaque(int x, int y) {
x += cropX;
y += cropY;
int dstOff = x + (y * Draw2D.width);
int srcOff = 0;
int h = height;
int w = width;
int dstStep = Draw2D.width - w;
int srcStep = 0;
if (y < Draw2D.top) {
int trim = Draw2D.top - y;
h -= trim;
y = Draw2D.top;
srcOff += trim * w;
dstOff += trim * Draw2D.width;
}
if ((y + h) > Draw2D.bottom) {
h -= (y + h) - Draw2D.bottom;
}
if (x < Draw2D.left) {
int trim = Draw2D.left - x;
w -= trim;
x = Draw2D.left;
srcOff += trim;
dstOff += trim;
srcStep += trim;
dstStep += trim;
}
if ((x + w) > Draw2D.right) {
int trim = (x + w) - Draw2D.right;
w -= trim;
srcStep += trim;
dstStep += trim;
}
if ((w > 0) && (h > 0)) {
copyPixels(dstOff, w, h, srcStep, srcOff, dstStep, pixels, Draw2D.pixels);
}
}
public void copyPixels(int dstOff, int w, int h, int srcStep, int srcOff, int dstStep, int[] src, int[] dst) {
int quarterWidth = -(w >> 2);
w = -(w & 3);
for (int y = -h; y < 0; y++) {
for (int i = quarterWidth; i < 0; i++) {
dst[dstOff++] = src[srcOff++];
dst[dstOff++] = src[srcOff++];
dst[dstOff++] = src[srcOff++];
dst[dstOff++] = src[srcOff++];
}
for (int i = w; i < 0; i++) {
dst[dstOff++] = src[srcOff++];
}
dstOff += dstStep;
srcOff += srcStep;
}
}
public void copyPixels(int dstOff, int w, int h, int srcStep, int srcOff, int dstStep, int[] src, int[] dst) {
int quarterWidth = -(w >> 2);
w = -(w & 3);
for (int y = -h; y < 0; y++) {
for (int i = quarterWidth; i < 0; i++) {
dst[dstOff++] = src[srcOff++];
dst[dstOff++] = src[srcOff++];
dst[dstOff++] = src[srcOff++];
dst[dstOff++] = src[srcOff++];
}
for (int i = w; i < 0; i++) {
dst[dstOff++] = src[srcOff++];
}
dstOff += dstStep;
srcOff += srcStep;
}
}
public void draw(int x, int y) {
x += cropX;
y += cropY;
int dstOff = x + (y * Draw2D.width);
int srcOff = 0;
int h = height;
int w = width;
int dstStep = Draw2D.width - w;
int srcStep = 0;
if (y < Draw2D.top) {
int trim = Draw2D.top - y;
h -= trim;
y = Draw2D.top;
srcOff += trim * w;
dstOff += trim * Draw2D.width;
}
if ((y + h) > Draw2D.bottom) {
h -= (y + h) - Draw2D.bottom;
}
if (x < Draw2D.left) {
int trim = Draw2D.left - x;
w -= trim;
x = Draw2D.left;
srcOff += trim;
dstOff += trim;
srcStep += trim;
dstStep += trim;
}
if ((x + w) > Draw2D.right) {
int trim = (x + w) - Draw2D.right;
w -= trim;
srcStep += trim;
dstStep += trim;
}
if ((w > 0) && (h > 0)) {
copyPixels(Draw2D.pixels, pixels, srcOff, dstOff, w, h, dstStep, srcStep);
}
}
public void draw(int x, int y) {
x += cropX;
y += cropY;
int dstOff = x + (y * Draw2D.width);
int srcOff = 0;
int h = height;
int w = width;
int dstStep = Draw2D.width - w;
int srcStep = 0;
if (y < Draw2D.top) {
int trim = Draw2D.top - y;
h -= trim;
y = Draw2D.top;
srcOff += trim * w;
dstOff += trim * Draw2D.width;
}
if ((y + h) > Draw2D.bottom) {
h -= (y + h) - Draw2D.bottom;
}
if (x < Draw2D.left) {
int trim = Draw2D.left - x;
w -= trim;
x = Draw2D.left;
srcOff += trim;
dstOff += trim;
srcStep += trim;
dstStep += trim;
}
if ((x + w) > Draw2D.right) {
int trim = (x + w) - Draw2D.right;
w -= trim;
srcStep += trim;
dstStep += trim;
}
if ((w > 0) && (h > 0)) {
copyPixels(Draw2D.pixels, pixels, srcOff, dstOff, w, h, dstStep, srcStep);
}
}
public void copyPixels(int[] dst, int[] src, int srcOff, int dstOff, int w, int h, int dstStep, int srcstep) {
int quarterW = -(w >> 2);
w = -(w & 3);
for (int y = -h; y < 0; y++) {
int rgb;
for (int x = quarterW; x < 0; x++) {
rgb = src[srcOff++];
if (rgb != 0) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
rgb = src[srcOff++];
if (rgb != 0) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
rgb = src[srcOff++];
if (rgb != 0) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
rgb = src[srcOff++];
if (rgb != 0) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
}
for (int k2 = w; k2 < 0; k2++) {
rgb = src[srcOff++];
if (rgb != 0) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
}
dstOff += dstStep;
srcOff += srcstep;
}
}
public void copyPixels(int[] dst, int[] src, int srcOff, int dstOff, int w, int h, int dstStep, int srcstep) {
int quarterW = -(w >> 2);
w = -(w & 3);
for (int y = -h; y < 0; y++) {
int rgb;
for (int x = quarterW; x < 0; x++) {
rgb = src[srcOff++];
if (rgb != 0) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
rgb = src[srcOff++];
if (rgb != 0) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
rgb = src[srcOff++];
if (rgb != 0) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
rgb = src[srcOff++];
if (rgb != 0) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
}
for (int k2 = w; k2 < 0; k2++) {
rgb = src[srcOff++];
if (rgb != 0) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
}
dstOff += dstStep;
srcOff += srcstep;
}
}
public void draw(int x, int y, int alpha) {
x += cropX;
y += cropY;
int dstOff = x + (y * Draw2D.width);
int srcOff = 0;
int h = height;
int w = width;
int dstStep = Draw2D.width - w;
int srcStep = 0;
if (y < Draw2D.top) {
int trim = Draw2D.top - y;
h -= trim;
y = Draw2D.top;
srcOff += trim * w;
dstOff += trim * Draw2D.width;
}
if ((y + h) > Draw2D.bottom) {
h -= (y + h) - Draw2D.bottom;
}
if (x < Draw2D.left) {
int trim = Draw2D.left - x;
w -= trim;
x = Draw2D.left;
srcOff += trim;
dstOff += trim;
srcStep += trim;
dstStep += trim;
}
if ((x + w) > Draw2D.right) {
int trim = (x + w) - Draw2D.right;
w -= trim;
srcStep += trim;
dstStep += trim;
}
if ((w > 0) && (h > 0)) {
copyPixelsAlpha(srcOff, w, Draw2D.pixels, pixels, srcStep, h, dstStep, alpha, dstOff);
}
}
public void draw(int x, int y, int alpha) {
x += cropX;
y += cropY;
int dstOff = x + (y * Draw2D.width);
int srcOff = 0;
int h = height;
int w = width;
int dstStep = Draw2D.width - w;
int srcStep = 0;
if (y < Draw2D.top) {
int trim = Draw2D.top - y;
h -= trim;
y = Draw2D.top;
srcOff += trim * w;
dstOff += trim * Draw2D.width;
}
if ((y + h) > Draw2D.bottom) {
h -= (y + h) - Draw2D.bottom;
}
if (x < Draw2D.left) {
int trim = Draw2D.left - x;
w -= trim;
x = Draw2D.left;
srcOff += trim;
dstOff += trim;
srcStep += trim;
dstStep += trim;
}
if ((x + w) > Draw2D.right) {
int trim = (x + w) - Draw2D.right;
w -= trim;
srcStep += trim;
dstStep += trim;
}
if ((w > 0) && (h > 0)) {
copyPixelsAlpha(srcOff, w, Draw2D.pixels, pixels, srcStep, h, dstStep, alpha, dstOff);
}
}
public void copyPixelsAlpha(int srcOff, int w, int[] dst, int[] src, int srcStep, int h, int dstStep, int alpha, int dstOff) {
int invAlpha = 256 - alpha;
for (int k2 = -h; k2 < 0; k2++) {
for (int l2 = -w; l2 < 0; l2++) {
int srcRGB = src[srcOff++];
if (srcRGB != 0) {
int dstRGB = dst[dstOff];
dst[dstOff++] = (((((srcRGB & 0xff00ff) * alpha) + ((dstRGB & 0xff00ff) * invAlpha)) & 0xff00ff00) + ((((srcRGB & 0xff00) * alpha) + ((dstRGB & 0xff00) * invAlpha)) & 0xff0000)) >> 8;
} else {
dstOff++;
}
}
dstOff += dstStep;
srcOff += srcStep;
}
}
public void copyPixelsAlpha(int srcOff, int w, int[] dst, int[] src, int srcStep, int h, int dstStep, int alpha, int dstOff) {
int invAlpha = 256 - alpha;
for (int k2 = -h; k2 < 0; k2++) {
for (int l2 = -w; l2 < 0; l2++) {
int srcRGB = src[srcOff++];
if (srcRGB != 0) {
int dstRGB = dst[dstOff];
dst[dstOff++] = (((((srcRGB & 0xff00ff) * alpha) + ((dstRGB & 0xff00ff) * invAlpha)) & 0xff00ff00) + ((((srcRGB & 0xff00) * alpha) + ((dstRGB & 0xff00) * invAlpha)) & 0xff0000)) >> 8;
} else {
dstOff++;
}
}
dstOff += dstStep;
srcOff += srcStep;
}
}
public void drawRotatedMasked(int x, int y, int width, int height, int anchorX, int anchorY, int zoom, int angle, int[] lineLengths, int[] lineOffsets) {
try {
int midX = -width / 2;
int midY = -height / 2;
int sin = (int) (Math.sin((double) angle / 326.11000000000001D) * 65536D);
int cos = (int) (Math.cos((double) angle / 326.11000000000001D) * 65536D);
sin = (sin * zoom) >> 8;
cos = (cos * zoom) >> 8;
int leftX = (anchorX << 16) + (midY * sin) + (midX * cos);
int lefty = ((anchorY << 16) + (midY * cos)) - (midX * sin);
int leftOff = x + (y * Draw2D.width);
for (y = 0; y < height; y++) {
int lineOffset = lineOffsets[y];
int dstOff = leftOff + lineOffset;
int srcX = leftX + (cos * lineOffset);
int srcY = lefty - (sin * lineOffset);
for (x = -lineLengths[y]; x < 0; x++) {
Draw2D.pixels[dstOff++] = pixels[(srcX >> 16) + ((srcY >> 16) * this.width)];
srcX += cos;
srcY -= sin;
}
leftX += sin;
lefty += cos;
leftOff += Draw2D.width;
}
} catch (Exception ignored) {
}
}
public void drawRotatedMasked(int x, int y, int width, int height, int anchorX, int anchorY, int zoom, int angle, int[] lineLengths, int[] lineOffsets) {
try {
int midX = -width / 2;
int midY = -height / 2;
int sin = (int) (Math.sin((double) angle / 326.11000000000001D) * 65536D);
int cos = (int) (Math.cos((double) angle / 326.11000000000001D) * 65536D);
sin = (sin * zoom) >> 8;
cos = (cos * zoom) >> 8;
int leftX = (anchorX << 16) + (midY * sin) + (midX * cos);
int lefty = ((anchorY << 16) + (midY * cos)) - (midX * sin);
int leftOff = x + (y * Draw2D.width);
for (y = 0; y < height; y++) {
int lineOffset = lineOffsets[y];
int dstOff = leftOff + lineOffset;
int srcX = leftX + (cos * lineOffset);
int srcY = lefty - (sin * lineOffset);
for (x = -lineLengths[y]; x < 0; x++) {
Draw2D.pixels[dstOff++] = pixels[(srcX >> 16) + ((srcY >> 16) * this.width)];
srcX += cos;
srcY -= sin;
}
leftX += sin;
lefty += cos;
leftOff += Draw2D.width;
}
} catch (Exception ignored) {
}
}
public void drawRotated(int x, int y, int width, int height, int anchorX, int anchorY, double radians, int zoom) {
try {
int centerX = -width / 2;
int centerY = -height / 2;
int sin = (int) (Math.sin(radians) * 65536D);
int cos = (int) (Math.cos(radians) * 65536D);
sin = (sin * zoom) >> 8;
cos = (cos * zoom) >> 8;
int leftX = (anchorX << 16) + (centerY * sin) + (centerX * cos);
int leftY = ((anchorY << 16) + (centerY * cos)) - (centerX * sin);
int leftOff = x + (y * Draw2D.width);
public void drawRotated(int x, int y, int width, int height, int anchorX, int anchorY, double radians, int zoom) {
try {
int centerX = -width / 2;
int centerY = -height / 2;
int sin = (int) (Math.sin(radians) * 65536D);
int cos = (int) (Math.cos(radians) * 65536D);
sin = (sin * zoom) >> 8;
cos = (cos * zoom) >> 8;
int leftX = (anchorX << 16) + (centerY * sin) + (centerX * cos);
int leftY = ((anchorY << 16) + (centerY * cos)) - (centerX * sin);
int leftOff = x + (y * Draw2D.width);
for (y = 0; y < height; y++) {
int dstOff = leftOff;
int dstX = leftX;
int dstY = leftY;
for (x = -width; x < 0; x++) {
int rgb = pixels[(dstX >> 16) + ((dstY >> 16) * this.width)];
if (rgb != 0) {
Draw2D.pixels[dstOff++] = rgb;
} else {
dstOff++;
}
dstX += cos;
dstY -= sin;
}
leftX += sin;
leftY += cos;
leftOff += Draw2D.width;
}
} catch (Exception ignored) {
}
}
for (y = 0; y < height; y++) {
int dstOff = leftOff;
int dstX = leftX;
int dstY = leftY;
for (x = -width; x < 0; x++) {
int rgb = pixels[(dstX >> 16) + ((dstY >> 16) * this.width)];
if (rgb != 0) {
Draw2D.pixels[dstOff++] = rgb;
} else {
dstOff++;
}
dstX += cos;
dstY -= sin;
}
leftX += sin;
leftY += cos;
leftOff += Draw2D.width;
}
} catch (Exception ignored) {
}
}
public void drawMasked(Image8 mask, int y, int x) {
x += cropX;
y += cropY;
int dstOff = x + (y * Draw2D.width);
int srcOff = 0;
int h = height;
int w = width;
int dstStep = Draw2D.width - w;
int srcStep = 0;
if (y < Draw2D.top) {
int trim = Draw2D.top - y;
h -= trim;
y = Draw2D.top;
srcOff += trim * w;
dstOff += trim * Draw2D.width;
}
if ((y + h) > Draw2D.bottom) {
h -= (y + h) - Draw2D.bottom;
}
if (x < Draw2D.left) {
int trim = Draw2D.left - x;
w -= trim;
x = Draw2D.left;
srcOff += trim;
dstOff += trim;
srcStep += trim;
dstStep += trim;
}
if ((x + w) > Draw2D.right) {
int trim = (x + w) - Draw2D.right;
w -= trim;
srcStep += trim;
dstStep += trim;
}
if ((w > 0) && (h > 0)) {
copyPixelsMasked(pixels, srcOff, srcStep, mask.pixels, w, h, Draw2D.pixels, dstOff, dstStep);
}
}
public void drawMasked(Image8 mask, int y, int x) {
x += cropX;
y += cropY;
int dstOff = x + (y * Draw2D.width);
int srcOff = 0;
int h = height;
int w = width;
int dstStep = Draw2D.width - w;
int srcStep = 0;
if (y < Draw2D.top) {
int trim = Draw2D.top - y;
h -= trim;
y = Draw2D.top;
srcOff += trim * w;
dstOff += trim * Draw2D.width;
}
if ((y + h) > Draw2D.bottom) {
h -= (y + h) - Draw2D.bottom;
}
if (x < Draw2D.left) {
int trim = Draw2D.left - x;
w -= trim;
x = Draw2D.left;
srcOff += trim;
dstOff += trim;
srcStep += trim;
dstStep += trim;
}
if ((x + w) > Draw2D.right) {
int trim = (x + w) - Draw2D.right;
w -= trim;
srcStep += trim;
dstStep += trim;
}
if ((w > 0) && (h > 0)) {
copyPixelsMasked(pixels, srcOff, srcStep, mask.pixels, w, h, Draw2D.pixels, dstOff, dstStep);
}
}
public void copyPixelsMasked(int[] src, int srcOff, int srcStep, byte[] mask, int w, int h, int[] dst, int dstOff, int dstStep) {
int quarterW = -(w >> 2);
w = -(w & 3);
for (int y = -h; y < 0; y++) {
int rgb;
for (int i = quarterW; i < 0; i++) {
rgb = src[srcOff++];
if ((rgb != 0) && (mask[dstOff] == 0)) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
rgb = src[srcOff++];
if ((rgb != 0) && (mask[dstOff] == 0)) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
rgb = src[srcOff++];
if ((rgb != 0) && (mask[dstOff] == 0)) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
rgb = src[srcOff++];
if ((rgb != 0) && (mask[dstOff] == 0)) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
}
for (int i = w; i < 0; i++) {
rgb = src[srcOff++];
if ((rgb != 0) && (mask[dstOff] == 0)) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
}
dstOff += dstStep;
srcOff += srcStep;
}
}
public void copyPixelsMasked(int[] src, int srcOff, int srcStep, byte[] mask, int w, int h, int[] dst, int dstOff, int dstStep) {
int quarterW = -(w >> 2);
w = -(w & 3);
for (int y = -h; y < 0; y++) {
int rgb;
for (int i = quarterW; i < 0; i++) {
rgb = src[srcOff++];
if ((rgb != 0) && (mask[dstOff] == 0)) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
rgb = src[srcOff++];
if ((rgb != 0) && (mask[dstOff] == 0)) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
rgb = src[srcOff++];
if ((rgb != 0) && (mask[dstOff] == 0)) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
rgb = src[srcOff++];
if ((rgb != 0) && (mask[dstOff] == 0)) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
}
for (int i = w; i < 0; i++) {
rgb = src[srcOff++];
if ((rgb != 0) && (mask[dstOff] == 0)) {
dst[dstOff++] = rgb;
} else {
dstOff++;
}
}
dstOff += dstStep;
srcOff += srcStep;
}
}
}
+206 -206
View File
@@ -2,223 +2,223 @@ import java.io.IOException;
public class Image8 {
public final int[] palette;
public byte[] pixels;
public int width;
public int height;
public int cropX;
public int cropY;
public int cropW;
public int cropH;
public final int[] palette;
public byte[] pixels;
public int width;
public int height;
public int cropX;
public int cropY;
public int cropW;
public int cropH;
public Image8(FileArchive archive, String name, int index) throws IOException {
Buffer dat = new Buffer(archive.read(name + ".dat"));
Buffer idx = new Buffer(archive.read("index.dat"));
idx.position = dat.read16U();
cropW = idx.read16U();
cropH = idx.read16U();
int paletteSize = idx.read8U();
palette = new int[paletteSize];
for (int i = 0; i < (paletteSize - 1); i++) {
palette[i + 1] = idx.read24();
}
for (int i = 0; i < index; i++) {
idx.position += 2;
dat.position += idx.read16U() * idx.read16U();
idx.position++;
}
cropX = idx.read8U();
cropY = idx.read8U();
width = idx.read16U();
height = idx.read16U();
int pixelOrder = idx.read8U();
int pixelCount = width * height;
pixels = new byte[pixelCount];
public Image8(FileArchive archive, String name, int index) throws IOException {
Buffer dat = new Buffer(archive.read(name + ".dat"));
Buffer idx = new Buffer(archive.read("index.dat"));
idx.position = dat.read16U();
cropW = idx.read16U();
cropH = idx.read16U();
int paletteSize = idx.read8U();
palette = new int[paletteSize];
for (int i = 0; i < (paletteSize - 1); i++) {
palette[i + 1] = idx.read24();
}
for (int i = 0; i < index; i++) {
idx.position += 2;
dat.position += idx.read16U() * idx.read16U();
idx.position++;
}
cropX = idx.read8U();
cropY = idx.read8U();
width = idx.read16U();
height = idx.read16U();
int pixelOrder = idx.read8U();
int pixelCount = width * height;
pixels = new byte[pixelCount];
if (pixelOrder == 0) {
for (int i = 0; i < pixelCount; i++) {
pixels[i] = dat.read();
}
return;
}
if (pixelOrder == 0) {
for (int i = 0; i < pixelCount; i++) {
pixels[i] = dat.read();
}
return;
}
if (pixelOrder == 1) {
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
pixels[x + (y * width)] = dat.read();
}
}
}
}
if (pixelOrder == 1) {
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
pixels[x + (y * width)] = dat.read();
}
}
}
}
public void shrink() {
cropW /= 2;
cropH /= 2;
byte[] pixels = new byte[cropW * cropH];
int off = 0;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
pixels[((x + cropX) >> 1) + (((y + cropY) >> 1) * cropW)] = this.pixels[off++];
}
}
this.pixels = pixels;
width = cropW;
height = cropH;
cropX = 0;
cropY = 0;
}
public void shrink() {
cropW /= 2;
cropH /= 2;
byte[] pixels = new byte[cropW * cropH];
int off = 0;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
pixels[((x + cropX) >> 1) + (((y + cropY) >> 1) * cropW)] = this.pixels[off++];
}
}
this.pixels = pixels;
width = cropW;
height = cropH;
cropX = 0;
cropY = 0;
}
public void crop() {
if ((width == cropW) && (height == cropH)) {
return;
}
byte[] pixels = new byte[cropW * cropH];
int off = 0;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
pixels[x + cropX + ((y + cropY) * cropW)] = this.pixels[off++];
}
}
this.pixels = pixels;
width = cropW;
height = cropH;
cropX = 0;
cropY = 0;
}
public void crop() {
if ((width == cropW) && (height == cropH)) {
return;
}
byte[] pixels = new byte[cropW * cropH];
int off = 0;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
pixels[x + cropX + ((y + cropY) * cropW)] = this.pixels[off++];
}
}
this.pixels = pixels;
width = cropW;
height = cropH;
cropX = 0;
cropY = 0;
}
public void flipHorizontally() {
byte[] pixels = new byte[width * height];
int off = 0;
for (int y = 0; y < height; y++) {
for (int x = width - 1; x >= 0; x--) {
pixels[off++] = this.pixels[x + (y * width)];
}
}
this.pixels = pixels;
cropX = cropW - width - cropX;
}
public void flipHorizontally() {
byte[] pixels = new byte[width * height];
int off = 0;
for (int y = 0; y < height; y++) {
for (int x = width - 1; x >= 0; x--) {
pixels[off++] = this.pixels[x + (y * width)];
}
}
this.pixels = pixels;
cropX = cropW - width - cropX;
}
public void flipVertically() {
byte[] pixels = new byte[width * height];
int i = 0;
for (int y = height - 1; y >= 0; y--) {
for (int x = 0; x < width; x++) {
pixels[i++] = this.pixels[x + (y * width)];
}
}
this.pixels = pixels;
cropY = cropH - height - cropY;
}
public void flipVertically() {
byte[] pixels = new byte[width * height];
int i = 0;
for (int y = height - 1; y >= 0; y--) {
for (int x = 0; x < width; x++) {
pixels[i++] = this.pixels[x + (y * width)];
}
}
this.pixels = pixels;
cropY = cropH - height - cropY;
}
public void translate(int r, int g, int b) {
for (int i = 0; i < palette.length; i++) {
int red = (palette[i] >> 16) & 0xff;
red += r;
if (red < 0) {
red = 0;
} else if (red > 255) {
red = 255;
}
int green = (palette[i] >> 8) & 0xff;
green += g;
if (green < 0) {
green = 0;
} else if (green > 255) {
green = 255;
}
int blue = palette[i] & 0xff;
blue += b;
if (blue < 0) {
blue = 0;
} else if (blue > 255) {
blue = 255;
}
palette[i] = (red << 16) + (green << 8) + blue;
}
}
public void translate(int r, int g, int b) {
for (int i = 0; i < palette.length; i++) {
int red = (palette[i] >> 16) & 0xff;
red += r;
if (red < 0) {
red = 0;
} else if (red > 255) {
red = 255;
}
int green = (palette[i] >> 8) & 0xff;
green += g;
if (green < 0) {
green = 0;
} else if (green > 255) {
green = 255;
}
int blue = palette[i] & 0xff;
blue += b;
if (blue < 0) {
blue = 0;
} else if (blue > 255) {
blue = 255;
}
palette[i] = (red << 16) + (green << 8) + blue;
}
}
public void blit(int x, int y) {
x += cropX;
y += cropY;
int dstOff = x + (y * Draw2D.width);
int srcOff = 0;
int height = this.height;
int width = this.width;
int dstStep = Draw2D.width - width;
int srcStep = 0;
if (y < Draw2D.top) {
int trim = Draw2D.top - y;
height -= trim;
y = Draw2D.top;
srcOff += trim * width;
dstOff += trim * Draw2D.width;
}
if ((y + height) > Draw2D.bottom) {
height -= (y + height) - Draw2D.bottom;
}
if (x < Draw2D.left) {
int trim = Draw2D.left - x;
width -= trim;
x = Draw2D.left;
srcOff += trim;
dstOff += trim;
srcStep += trim;
dstStep += trim;
}
if ((x + width) > Draw2D.right) {
int trim = (x + width) - Draw2D.right;
width -= trim;
srcStep += trim;
dstStep += trim;
}
if ((width > 0) && (height > 0)) {
blit(height, Draw2D.pixels, pixels, dstStep, dstOff, width, srcOff, palette, srcStep);
}
}
public void blit(int x, int y) {
x += cropX;
y += cropY;
int dstOff = x + (y * Draw2D.width);
int srcOff = 0;
int height = this.height;
int width = this.width;
int dstStep = Draw2D.width - width;
int srcStep = 0;
if (y < Draw2D.top) {
int trim = Draw2D.top - y;
height -= trim;
y = Draw2D.top;
srcOff += trim * width;
dstOff += trim * Draw2D.width;
}
if ((y + height) > Draw2D.bottom) {
height -= (y + height) - Draw2D.bottom;
}
if (x < Draw2D.left) {
int trim = Draw2D.left - x;
width -= trim;
x = Draw2D.left;
srcOff += trim;
dstOff += trim;
srcStep += trim;
dstStep += trim;
}
if ((x + width) > Draw2D.right) {
int trim = (x + width) - Draw2D.right;
width -= trim;
srcStep += trim;
dstStep += trim;
}
if ((width > 0) && (height > 0)) {
blit(height, Draw2D.pixels, pixels, dstStep, dstOff, width, srcOff, palette, srcStep);
}
}
public void blit(int height, int[] dst, byte[] src, int dstStep, int dstOff, int width, int srcOff, int[] palette, int srcStep) {
int quarterWidth = -(width >> 2);
width = -(width & 3);
for (int y = -height; y < 0; y++) {
for (int w = quarterWidth; w < 0; w++) {
byte paletteIndex = src[srcOff++];
public void blit(int height, int[] dst, byte[] src, int dstStep, int dstOff, int width, int srcOff, int[] palette, int srcStep) {
int quarterWidth = -(width >> 2);
width = -(width & 3);
for (int y = -height; y < 0; y++) {
for (int w = quarterWidth; w < 0; w++) {
byte paletteIndex = src[srcOff++];
if (paletteIndex != 0) {
dst[dstOff++] = palette[paletteIndex & 0xff];
} else {
dstOff++;
}
if (paletteIndex != 0) {
dst[dstOff++] = palette[paletteIndex & 0xff];
} else {
dstOff++;
}
paletteIndex = src[srcOff++];
if (paletteIndex != 0) {
dst[dstOff++] = palette[paletteIndex & 0xff];
} else {
dstOff++;
}
paletteIndex = src[srcOff++];
if (paletteIndex != 0) {
dst[dstOff++] = palette[paletteIndex & 0xff];
} else {
dstOff++;
}
paletteIndex = src[srcOff++];
if (paletteIndex != 0) {
dst[dstOff++] = palette[paletteIndex & 0xff];
} else {
dstOff++;
}
}
for (int i = width; i < 0; i++) {
byte paletteIndex = src[srcOff++];
if (paletteIndex != 0) {
dst[dstOff++] = palette[paletteIndex & 0xff];
} else {
dstOff++;
}
}
dstOff += dstStep;
srcOff += srcStep;
}
}
paletteIndex = src[srcOff++];
if (paletteIndex != 0) {
dst[dstOff++] = palette[paletteIndex & 0xff];
} else {
dstOff++;
}
paletteIndex = src[srcOff++];
if (paletteIndex != 0) {
dst[dstOff++] = palette[paletteIndex & 0xff];
} else {
dstOff++;
}
paletteIndex = src[srcOff++];
if (paletteIndex != 0) {
dst[dstOff++] = palette[paletteIndex & 0xff];
} else {
dstOff++;
}
}
for (int i = width; i < 0; i++) {
byte paletteIndex = src[srcOff++];
if (paletteIndex != 0) {
dst[dstOff++] = palette[paletteIndex & 0xff];
} else {
dstOff++;
}
}
dstOff += dstStep;
srcOff += srcStep;
}
}
}
+92 -92
View File
@@ -4,115 +4,115 @@
public class LocEntity extends Entity {
public static Game game;
public final int[] overrideTypeIDs;
public final int varbit;
public final int varp;
public final int heightmapSW;
public final int heightmapSE;
public final int heightmapNE;
public final int heightmapNW;
public final int id;
public final int kind;
public final int rotation;
public int seqFrame;
public SeqType seq;
public int seqCycle;
public static Game game;
public final int[] overrideTypeIDs;
public final int varbit;
public final int varp;
public final int heightmapSW;
public final int heightmapSE;
public final int heightmapNE;
public final int heightmapNW;
public final int id;
public final int kind;
public final int rotation;
public int seqFrame;
public SeqType seq;
public int seqCycle;
public LocEntity(int id, int rotation, int kind, int heightmapSE, int heightmapNE, int heightmapSW, int heightmapNW, int seqID, boolean randomFrame) {
this.id = id;
this.kind = kind;
this.rotation = rotation;
this.heightmapSW = heightmapSW;
this.heightmapSE = heightmapSE;
this.heightmapNE = heightmapNE;
this.heightmapNW = heightmapNW;
public LocEntity(int id, int rotation, int kind, int heightmapSE, int heightmapNE, int heightmapSW, int heightmapNW, int seqID, boolean randomFrame) {
this.id = id;
this.kind = kind;
this.rotation = rotation;
this.heightmapSW = heightmapSW;
this.heightmapSE = heightmapSE;
this.heightmapNE = heightmapNE;
this.heightmapNW = heightmapNW;
if (seqID != -1) {
seq = SeqType.instances[seqID];
seqFrame = 0;
seqCycle = Game.loopCycle;
if (seqID != -1) {
seq = SeqType.instances[seqID];
seqFrame = 0;
seqCycle = Game.loopCycle;
if (randomFrame && (seq.loopFrameCount != -1)) {
seqFrame = (int) (Math.random() * (double) seq.frameCount);
seqCycle -= (int) (Math.random() * (double) seq.getFrameDuration(seqFrame));
}
}
LocType type = LocType.get(this.id);
varbit = type.varbit;
varp = type.varp;
overrideTypeIDs = type.overrideTypeIDs;
}
if (randomFrame && (seq.loopFrameCount != -1)) {
seqFrame = (int) (Math.random() * (double) seq.frameCount);
seqCycle -= (int) (Math.random() * (double) seq.getFrameDuration(seqFrame));
}
}
LocType type = LocType.get(this.id);
varbit = type.varbit;
varp = type.varp;
overrideTypeIDs = type.overrideTypeIDs;
}
@Override
public Model getModel() {
int transformID = -1;
@Override
public Model getModel() {
int transformID = -1;
if (seq != null) {
int delta = Game.loopCycle - seqCycle;
if (seq != null) {
int delta = Game.loopCycle - seqCycle;
if ((delta > 100) && (seq.loopFrameCount > 0)) {
delta = 100;
}
if ((delta > 100) && (seq.loopFrameCount > 0)) {
delta = 100;
}
while (delta > seq.getFrameDuration(seqFrame)) {
delta -= seq.getFrameDuration(seqFrame);
seqFrame++;
while (delta > seq.getFrameDuration(seqFrame)) {
delta -= seq.getFrameDuration(seqFrame);
seqFrame++;
if (seqFrame < seq.frameCount) {
continue;
}
if (seqFrame < seq.frameCount) {
continue;
}
seqFrame -= seq.loopFrameCount;
seqFrame -= seq.loopFrameCount;
if ((seqFrame >= 0) && (seqFrame < seq.frameCount)) {
continue;
}
if ((seqFrame >= 0) && (seqFrame < seq.frameCount)) {
continue;
}
seq = null;
break;
}
seqCycle = Game.loopCycle - delta;
seq = null;
break;
}
seqCycle = Game.loopCycle - delta;
if (seq != null) {
transformID = seq.transformIDs[seqFrame];
}
}
if (seq != null) {
transformID = seq.transformIDs[seqFrame];
}
}
LocType type;
LocType type;
if (overrideTypeIDs != null) {
type = getOverrideType();
} else {
type = LocType.get(id);
}
if (overrideTypeIDs != null) {
type = getOverrideType();
} else {
type = LocType.get(id);
}
if (type == null) {
return null;
} else {
return type.getModel(kind, rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, transformID);
}
}
if (type == null) {
return null;
} else {
return type.getModel(kind, rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, transformID);
}
}
public LocType getOverrideType() {
int value = -1;
public LocType getOverrideType() {
int value = -1;
if (varbit != -1) {
VarbitType varbit = VarbitType.instances[this.varbit];
int varp = varbit.varp;
int low = varbit.lsb;
int high = varbit.msb;
int mask = Game.BITMASK[high - low];
value = (game.varps[varp] >> low) & mask;
} else if (varp != -1) {
value = game.varps[varp];
}
if (varbit != -1) {
VarbitType varbit = VarbitType.instances[this.varbit];
int varp = varbit.varp;
int low = varbit.lsb;
int high = varbit.msb;
int mask = Game.BITMASK[high - low];
value = (game.varps[varp] >> low) & mask;
} else if (varp != -1) {
value = game.varps[varp];
}
if ((value < 0) || (value >= overrideTypeIDs.length) || (overrideTypeIDs[value] == -1)) {
return null;
} else {
return LocType.get(overrideTypeIDs[value]);
}
}
if ((value < 0) || (value >= overrideTypeIDs.length) || (overrideTypeIDs[value] == -1)) {
return null;
} else {
return LocType.get(overrideTypeIDs[value]);
}
}
}
+476 -476
View File
File diff suppressed because it is too large. Load diff
+56 -56
View File
@@ -4,64 +4,64 @@
public class MapUtil {
public static int rotateX(int x, int z, int rotation) {
rotation &= 3;
if (rotation == 0) {
return x;
}
if (rotation == 1) {
return z;
}
if (rotation == 2) {
return 7 - x;
} else {
return 7 - z;
}
}
public static int rotateX(int x, int z, int rotation) {
rotation &= 3;
if (rotation == 0) {
return x;
}
if (rotation == 1) {
return z;
}
if (rotation == 2) {
return 7 - x;
} else {
return 7 - z;
}
}
public static int rotateZ(int x, int z, int rotation) {
rotation &= 3;
if (rotation == 0) {
return z;
}
if (rotation == 1) {
return 7 - x;
}
if (rotation == 2) {
return 7 - z;
} else {
return x;
}
}
public static int rotateZ(int x, int z, int rotation) {
rotation &= 3;
if (rotation == 0) {
return z;
}
if (rotation == 1) {
return 7 - x;
}
if (rotation == 2) {
return 7 - z;
} else {
return x;
}
}
public static int rotateLocX(int x, int z, int sizeX, int sizeZ, int rotation) {
rotation &= 3;
if (rotation == 0) {
return x;
}
if (rotation == 1) {
return z;
}
if (rotation == 2) {
return 7 - x - (sizeX - 1);
} else {
return 7 - z - (sizeZ - 1);
}
}
public static int rotateLocX(int x, int z, int sizeX, int sizeZ, int rotation) {
rotation &= 3;
if (rotation == 0) {
return x;
}
if (rotation == 1) {
return z;
}
if (rotation == 2) {
return 7 - x - (sizeX - 1);
} else {
return 7 - z - (sizeZ - 1);
}
}
public static int rotateLocZ(int x, int z, int sizeX, int sizeZ, int rotation) {
rotation &= 3;
if (rotation == 0) {
return z;
}
if (rotation == 1) {
return 7 - x - (sizeX - 1);
}
if (rotation == 2) {
return 7 - z - (sizeZ - 1);
} else {
return x;
}
}
public static int rotateLocZ(int x, int z, int sizeX, int sizeZ, int rotation) {
rotation &= 3;
if (rotation == 0) {
return z;
}
if (rotation == 1) {
return 7 - x - (sizeX - 1);
}
if (rotation == 2) {
return 7 - z - (sizeZ - 1);
} else {
return x;
}
}
}
+2455 -2455
View File
File diff suppressed because it is too large. Load diff
+25 -25
View File
@@ -4,32 +4,32 @@
public class MouseRecorder implements Runnable {
public final Object lock = new Object();
public final Game game;
public final int[] y = new int[500];
public final int[] x = new int[500];
public boolean active = true;
public int length;
public final Object lock = new Object();
public final Game game;
public final int[] y = new int[500];
public final int[] x = new int[500];
public boolean active = true;
public int length;
public MouseRecorder(Game game) {
this.game = game;
}
public MouseRecorder(Game game) {
this.game = game;
}
@Override
public void run() {
while (active) {
synchronized (lock) {
if (length < 500) {
x[length] = game.mouseX;
y[length] = game.mouseY;
length++;
}
}
try {
Thread.sleep(50L);
} catch (Exception ignored) {
}
}
}
@Override
public void run() {
while (active) {
synchronized (lock) {
if (length < 500) {
x[length] = game.mouseX;
y[length] = game.mouseY;
length++;
}
}
try {
Thread.sleep(50L);
} catch (Exception ignored) {
}
}
}
}
+56 -56
View File
@@ -4,76 +4,76 @@
public class NPCEntity extends PathingEntity {
public NPCType type;
public NPCType type;
public NPCEntity() {
}
public NPCEntity() {
}
public Model getSequencedModel() {
if ((super.primarySeqID >= 0) && (super.primarySeqDelay == 0)) {
int primaryTransformID = SeqType.instances[super.primarySeqID].transformIDs[super.primarySeqFrame];
int secondaryTransformID = -1;
if ((super.secondarySeqID >= 0) && (super.secondarySeqID != super.seqStandID)) {
secondaryTransformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
}
return type.getSequencedModel(secondaryTransformID, primaryTransformID, SeqType.instances[super.primarySeqID].mask);
}
public Model getSequencedModel() {
if ((super.primarySeqID >= 0) && (super.primarySeqDelay == 0)) {
int primaryTransformID = SeqType.instances[super.primarySeqID].transformIDs[super.primarySeqFrame];
int secondaryTransformID = -1;
if ((super.secondarySeqID >= 0) && (super.secondarySeqID != super.seqStandID)) {
secondaryTransformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
}
return type.getSequencedModel(secondaryTransformID, primaryTransformID, SeqType.instances[super.primarySeqID].mask);
}
int transformID = -1;
int transformID = -1;
if (super.secondarySeqID >= 0) {
transformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
}
if (super.secondarySeqID >= 0) {
transformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
}
return type.getSequencedModel(-1, transformID, null);
}
return type.getSequencedModel(-1, transformID, null);
}
@Override
public Model getModel() {
if (type == null) {
return null;
}
@Override
public Model getModel() {
if (type == null) {
return null;
}
Model model = getSequencedModel();
Model model = getSequencedModel();
if (model == null) {
return null;
}
if (model == null) {
return null;
}
super.height = model.minY;
super.height = model.minY;
if ((super.spotanimID != -1) && (super.spotanimFrame != -1)) {
SpotAnimType spotanim = SpotAnimType.instances[super.spotanimID];
Model model0 = spotanim.getModel();
if ((super.spotanimID != -1) && (super.spotanimFrame != -1)) {
SpotAnimType spotanim = SpotAnimType.instances[super.spotanimID];
Model model0 = spotanim.getModel();
if (model0 != null) {
int transformID = spotanim.seq.transformIDs[super.spotanimFrame];
if (model0 != null) {
int transformID = spotanim.seq.transformIDs[super.spotanimFrame];
// create a copy of the model
Model model1 = new Model(true, SeqTransform.isNull(transformID), false, model0);
model1.translate(0, -super.spotanimOffset, 0);
model1.createLabelReferences();
model1.applyTransform(transformID);
model1.labelFaces = null;
model1.labelVertices = null;
// create a copy of the model
Model model1 = new Model(true, SeqTransform.isNull(transformID), false, model0);
model1.translate(0, -super.spotanimOffset, 0);
model1.createLabelReferences();
model1.applyTransform(transformID);
model1.labelFaces = null;
model1.labelVertices = null;
if ((spotanim.scaleXY != 128) || (spotanim.scaleZ != 128)) {
model1.scale(spotanim.scaleXY, spotanim.scaleXY, spotanim.scaleZ);
}
if ((spotanim.scaleXY != 128) || (spotanim.scaleZ != 128)) {
model1.scale(spotanim.scaleXY, spotanim.scaleXY, spotanim.scaleZ);
}
model1.calculateNormals(64 + spotanim.lightAmbient, 850 + spotanim.lightAttenuation, -30, -50, -30, true);
model = new Model(2, -819, new Model[]{model, model1});
}
}
if (type.size == 1) {
model.pickable = true;
}
return model;
}
model1.calculateNormals(64 + spotanim.lightAmbient, 850 + spotanim.lightAttenuation, -30, -50, -30, true);
model = new Model(2, -819, new Model[]{model, model1});
}
}
if (type.size == 1) {
model.pickable = true;
}
return model;
}
@Override
public boolean isVisible() {
return type != null;
}
@Override
public boolean isVisible() {
return type != null;
}
}
+1 -1
View File
@@ -321,7 +321,7 @@ public class NPCType {
for (int i = 0; i <= overrideCount; i++) {
overrides[i] = buffer.read16U();
if (overrides[i] == 65535) {
overrides[i] = -1;
}
+9 -9
View File
@@ -4,16 +4,16 @@
public class ObjEntity extends Entity {
public int id;
public int count;
public int id;
public int count;
public ObjEntity() {
}
public ObjEntity() {
}
@Override
public Model getModel() {
ObjType type = ObjType.get(id);
return type.getModel(count);
}
@Override
public Model getModel() {
ObjType type = ObjType.get(id);
return type.getModel(count);
}
}
File diff suppressed because it is too large. Load diff
+12 -12
View File
@@ -2,19 +2,19 @@ import java.util.Arrays;
public class OnDemandRequest extends DoublyLinkedList.Node {
public int store;
public int file;
public boolean important;
public int cycle;
public byte[] data;
public int store;
public int file;
public boolean important;
public int cycle;
public byte[] data;
public OnDemandRequest() {
important = true;
}
public OnDemandRequest() {
important = true;
}
@Override
public String toString() {
return "OnDemandRequest{" + "store=" + store + ", file=" + file + ", priority=" + important + ", cycle=" + cycle + ", data=" + Arrays.toString(data) + '}';
}
@Override
public String toString() {
return "OnDemandRequest{" + "store=" + store + ", file=" + file + ", priority=" + important + ", cycle=" + cycle + ", data=" + Arrays.toString(data) + '}';
}
}
+145 -145
View File
@@ -1,152 +1,152 @@
public final class PacketIn {
// Names based on https://www.rune-server.ee/runescape-development/rs-503-client-and-server/informative-threads/622541-great-nxt-beta-dump-thread.html
public static final int[] SIZE = new int[256];
// Names based on https://www.rune-server.ee/runescape-development/rs-503-client-and-server/informative-threads/622541-great-nxt-beta-dump-thread.html
public static final int[] SIZE = new int[256];
public static final int CAM_LOOKAT = 177;
public static final int CAM_RESET = 107;
public static final int CAM_SETPOS = 166;
public static final int CAM_SHAKE = 35;
public static final int IF_CHAT = 164;
public static final int IF_CHAT_STICKY = 218;
public static final int CHAT_FILTER_SETTINGS = 206;
public static final int CLEAR_MAP_FLAG = 78;
public static final int FRIENDLIST_LOADED = 221;
public static final int FRIEND_STATUS = 50;
public static final int HINT_ARROW = 254;
public static final int IF_CLOSE = 219;
public static final int IF_SETANGLE = 230;
public static final int IF_SETANIM = 200;
public static final int IF_SETCOLOR = 122;
public static final int IF_SETHIDE = 171;
public static final int IF_SETMODEL = 8;
public static final int IF_SETNPCHEAD = 75;
public static final int IF_SETOBJECT = 246;
public static final int IF_SETPLAYERHEAD = 185;
public static final int IF_SETPOSITION = 70;
public static final int IF_SETSCROLLPOS = 79;
public static final int IF_SETTEXT = 126;
public static final int IF_STOPANIM = 142;
public static final int IF_VIEWPORT = 97;
public static final int IF_VIEWPORT_AND_SIDEBAR = 248;
public static final int IF_VIEWPORT_OVERLAY = 208;
public static final int IGNORE_LIST = 214;
public static final int INPUT_AMOUNT = 27;
public static final int INPUT_NAME = 187;
public static final int INV_CLEAR = 72;
public static final int LAST_LOGIN_INFO = 176;
public static final int LOCAL_PLAYER = 249;
public static final int LOC_ADD = 151;
public static final int LOC_CHANGE = 160;
public static final int LOC_DEL = 101;
public static final int LOGOUT = 109;
public static final int MESSAGE_GAME = 253;
public static final int MESSAGE_PUBLIC = 196;
public static final int MIDI_JINGLE = 121;
public static final int MIDI_SONG = 74;
public static final int MINIMAP_TOGGLE = 99;
public static final int MULTIZONE = 61;
public static final int OBJ_ADD = 44;
public static final int OBJ_COUNT = 84;
public static final int OBJ_DEL = 156;
public static final int OBJ_REVEAL = 215;
public static final int LOC_PLAYER = 147;
public static final int MAP_PROJECTILE = 117;
public static final int REBUILD_REGION = 73;
public static final int REBUILD_REGION_INSTANCE = 241;
public static final int RESET_ANIMS = 1;
public static final int RESET_CLIENT_VARCACHE = 68;
public static final int SET_PLAYER_OP = 104;
public static final int MAP_SOUND = 105;
public static final int MAP_ANIM = 4;
public static final int SYNC_NPCS = 65;
public static final int SYNC_PLAYERS = 81;
public static final int SYNTH_SOUND = 174;
public static final int IF_TAB = 71;
public static final int TAB_HINT = 24;
public static final int TAB_SELECTED = 106;
public static final int UPDATE_INV_FULL = 53;
public static final int UPDATE_INV_PARTIAL = 34;
public static final int UPDATE_REBOOT_TIMER = 114;
public static final int UPDATE_RUNENERGY = 110;
public static final int UPDATE_RUNWEIGHT = 240;
public static final int UPDATE_STAT = 134;
public static final int VARP_LARGE = 87;
public static final int VARP_SMALL = 36;
public static final int ZONE_BASE = 85;
public static final int ZONE_CLEAR = 64;
public static final int ZONE_UPDATE = 60;
public static final int CAM_LOOKAT = 177;
public static final int CAM_RESET = 107;
public static final int CAM_SETPOS = 166;
public static final int CAM_SHAKE = 35;
public static final int IF_CHAT = 164;
public static final int IF_CHAT_STICKY = 218;
public static final int CHAT_FILTER_SETTINGS = 206;
public static final int CLEAR_MAP_FLAG = 78;
public static final int FRIENDLIST_LOADED = 221;
public static final int FRIEND_STATUS = 50;
public static final int HINT_ARROW = 254;
public static final int IF_CLOSE = 219;
public static final int IF_SETANGLE = 230;
public static final int IF_SETANIM = 200;
public static final int IF_SETCOLOR = 122;
public static final int IF_SETHIDE = 171;
public static final int IF_SETMODEL = 8;
public static final int IF_SETNPCHEAD = 75;
public static final int IF_SETOBJECT = 246;
public static final int IF_SETPLAYERHEAD = 185;
public static final int IF_SETPOSITION = 70;
public static final int IF_SETSCROLLPOS = 79;
public static final int IF_SETTEXT = 126;
public static final int IF_STOPANIM = 142;
public static final int IF_VIEWPORT = 97;
public static final int IF_VIEWPORT_AND_SIDEBAR = 248;
public static final int IF_VIEWPORT_OVERLAY = 208;
public static final int IGNORE_LIST = 214;
public static final int INPUT_AMOUNT = 27;
public static final int INPUT_NAME = 187;
public static final int INV_CLEAR = 72;
public static final int LAST_LOGIN_INFO = 176;
public static final int LOCAL_PLAYER = 249;
public static final int LOC_ADD = 151;
public static final int LOC_CHANGE = 160;
public static final int LOC_DEL = 101;
public static final int LOGOUT = 109;
public static final int MESSAGE_GAME = 253;
public static final int MESSAGE_PUBLIC = 196;
public static final int MIDI_JINGLE = 121;
public static final int MIDI_SONG = 74;
public static final int MINIMAP_TOGGLE = 99;
public static final int MULTIZONE = 61;
public static final int OBJ_ADD = 44;
public static final int OBJ_COUNT = 84;
public static final int OBJ_DEL = 156;
public static final int OBJ_REVEAL = 215;
public static final int LOC_PLAYER = 147;
public static final int MAP_PROJECTILE = 117;
public static final int REBUILD_REGION = 73;
public static final int REBUILD_REGION_INSTANCE = 241;
public static final int RESET_ANIMS = 1;
public static final int RESET_CLIENT_VARCACHE = 68;
public static final int SET_PLAYER_OP = 104;
public static final int MAP_SOUND = 105;
public static final int MAP_ANIM = 4;
public static final int SYNC_NPCS = 65;
public static final int SYNC_PLAYERS = 81;
public static final int SYNTH_SOUND = 174;
public static final int IF_TAB = 71;
public static final int TAB_HINT = 24;
public static final int TAB_SELECTED = 106;
public static final int UPDATE_INV_FULL = 53;
public static final int UPDATE_INV_PARTIAL = 34;
public static final int UPDATE_REBOOT_TIMER = 114;
public static final int UPDATE_RUNENERGY = 110;
public static final int UPDATE_RUNWEIGHT = 240;
public static final int UPDATE_STAT = 134;
public static final int VARP_LARGE = 87;
public static final int VARP_SMALL = 36;
public static final int ZONE_BASE = 85;
public static final int ZONE_CLEAR = 64;
public static final int ZONE_UPDATE = 60;
static {
SIZE[MAP_ANIM] = 6;
SIZE[IF_SETMODEL] = 4;
SIZE[TAB_HINT] = 1;
SIZE[UPDATE_INV_PARTIAL] = -2;
SIZE[CAM_SHAKE] = 4;
SIZE[VARP_SMALL] = 3;
SIZE[OBJ_ADD] = 5;
SIZE[47] = 6;
SIZE[FRIEND_STATUS] = 9;
SIZE[UPDATE_INV_FULL] = -2;
SIZE[ZONE_UPDATE] = -2;
SIZE[MULTIZONE] = 1;
SIZE[ZONE_CLEAR] = 2;
SIZE[SYNC_NPCS] = -2;
SIZE[IF_SETPOSITION] = 6;
SIZE[IF_TAB] = 3;
SIZE[INV_CLEAR] = 2;
SIZE[REBUILD_REGION] = 4;
SIZE[MIDI_SONG] = 2;
SIZE[IF_SETNPCHEAD] = 4;
SIZE[IF_SETSCROLLPOS] = 4;
SIZE[SYNC_PLAYERS] = -2;
SIZE[OBJ_COUNT] = 7;
SIZE[ZONE_BASE] = 2;
SIZE[VARP_LARGE] = 6;
SIZE[IF_VIEWPORT] = 2;
SIZE[MINIMAP_TOGGLE] = 1;
SIZE[LOC_DEL] = 2;
SIZE[SET_PLAYER_OP] = -1;
SIZE[MAP_SOUND] = 4;
SIZE[TAB_SELECTED] = 1;
SIZE[UPDATE_RUNENERGY] = 1;
SIZE[UPDATE_REBOOT_TIMER] = 2;
SIZE[MAP_PROJECTILE] = 15;
SIZE[MIDI_JINGLE] = 4;
SIZE[IF_SETCOLOR] = 4;
SIZE[IF_SETTEXT] = -2;
SIZE[UPDATE_STAT] = 6;
SIZE[IF_STOPANIM] = 2;
SIZE[LOC_PLAYER] = 14;
SIZE[LOC_ADD] = 4;
SIZE[OBJ_DEL] = 3;
SIZE[LOC_CHANGE] = 4;
SIZE[IF_CHAT] = 2;
SIZE[CAM_SETPOS] = 6;
SIZE[IF_SETHIDE] = 3;
SIZE[SYNTH_SOUND] = 5;
SIZE[LAST_LOGIN_INFO] = 10;
SIZE[CAM_LOOKAT] = 6;
SIZE[IF_SETPLAYERHEAD] = 2;
SIZE[MESSAGE_PUBLIC] = -1;
SIZE[IF_SETANIM] = 4;
SIZE[CHAT_FILTER_SETTINGS] = 3;
SIZE[IF_VIEWPORT_OVERLAY] = 2;
SIZE[IGNORE_LIST] = -2;
SIZE[OBJ_REVEAL] = 7;
SIZE[IF_CHAT_STICKY] = 2;
SIZE[FRIENDLIST_LOADED] = 1;
SIZE[IF_SETANGLE] = 8;
SIZE[UPDATE_RUNWEIGHT] = 2;
SIZE[REBUILD_REGION_INSTANCE] = -2;
SIZE[IF_SETOBJECT] = 6;
SIZE[IF_VIEWPORT_AND_SIDEBAR] = 4;
SIZE[LOCAL_PLAYER] = 3;
SIZE[MESSAGE_GAME] = -1;
SIZE[HINT_ARROW] = 6;
}
static {
SIZE[MAP_ANIM] = 6;
SIZE[IF_SETMODEL] = 4;
SIZE[TAB_HINT] = 1;
SIZE[UPDATE_INV_PARTIAL] = -2;
SIZE[CAM_SHAKE] = 4;
SIZE[VARP_SMALL] = 3;
SIZE[OBJ_ADD] = 5;
SIZE[47] = 6;
SIZE[FRIEND_STATUS] = 9;
SIZE[UPDATE_INV_FULL] = -2;
SIZE[ZONE_UPDATE] = -2;
SIZE[MULTIZONE] = 1;
SIZE[ZONE_CLEAR] = 2;
SIZE[SYNC_NPCS] = -2;
SIZE[IF_SETPOSITION] = 6;
SIZE[IF_TAB] = 3;
SIZE[INV_CLEAR] = 2;
SIZE[REBUILD_REGION] = 4;
SIZE[MIDI_SONG] = 2;
SIZE[IF_SETNPCHEAD] = 4;
SIZE[IF_SETSCROLLPOS] = 4;
SIZE[SYNC_PLAYERS] = -2;
SIZE[OBJ_COUNT] = 7;
SIZE[ZONE_BASE] = 2;
SIZE[VARP_LARGE] = 6;
SIZE[IF_VIEWPORT] = 2;
SIZE[MINIMAP_TOGGLE] = 1;
SIZE[LOC_DEL] = 2;
SIZE[SET_PLAYER_OP] = -1;
SIZE[MAP_SOUND] = 4;
SIZE[TAB_SELECTED] = 1;
SIZE[UPDATE_RUNENERGY] = 1;
SIZE[UPDATE_REBOOT_TIMER] = 2;
SIZE[MAP_PROJECTILE] = 15;
SIZE[MIDI_JINGLE] = 4;
SIZE[IF_SETCOLOR] = 4;
SIZE[IF_SETTEXT] = -2;
SIZE[UPDATE_STAT] = 6;
SIZE[IF_STOPANIM] = 2;
SIZE[LOC_PLAYER] = 14;
SIZE[LOC_ADD] = 4;
SIZE[OBJ_DEL] = 3;
SIZE[LOC_CHANGE] = 4;
SIZE[IF_CHAT] = 2;
SIZE[CAM_SETPOS] = 6;
SIZE[IF_SETHIDE] = 3;
SIZE[SYNTH_SOUND] = 5;
SIZE[LAST_LOGIN_INFO] = 10;
SIZE[CAM_LOOKAT] = 6;
SIZE[IF_SETPLAYERHEAD] = 2;
SIZE[MESSAGE_PUBLIC] = -1;
SIZE[IF_SETANIM] = 4;
SIZE[CHAT_FILTER_SETTINGS] = 3;
SIZE[IF_VIEWPORT_OVERLAY] = 2;
SIZE[IGNORE_LIST] = -2;
SIZE[OBJ_REVEAL] = 7;
SIZE[IF_CHAT_STICKY] = 2;
SIZE[FRIENDLIST_LOADED] = 1;
SIZE[IF_SETANGLE] = 8;
SIZE[UPDATE_RUNWEIGHT] = 2;
SIZE[REBUILD_REGION_INSTANCE] = -2;
SIZE[IF_SETOBJECT] = 6;
SIZE[IF_VIEWPORT_AND_SIDEBAR] = 4;
SIZE[LOCAL_PLAYER] = 3;
SIZE[MESSAGE_GAME] = -1;
SIZE[HINT_ARROW] = 6;
}
private PacketIn() {
private PacketIn() {
}
}
}
+411 -411
View File
@@ -6,416 +6,416 @@ import org.apache.commons.collections4.map.LRUMap;
public class PlayerEntity extends PathingEntity {
public static LRUMap<Long, Model> modelCache = new LRUMap<>(260);
public final int[] colors = new int[5];
public final int[] appearances = new int[12];
public long modelUID = -1L;
public NPCType transmogrify;
public boolean lowmem = false;
public int team;
public int gender;
public String name;
public int combatLevel;
public int headicons;
public int locStartCycle;
public int locStopCycle;
public int y;
public boolean visible = false;
public int locOffsetX;
public int locOffsetY;
public int locOffsetZ;
public Model locModel;
public long appearanceHashcode;
public int minSceneTileX;
public int minSceneTileZ;
public int maxSceneTileX;
public int maxSceneTileZ;
public int skillLevel;
public PlayerEntity() {
}
@Override
public Model getModel() {
if (!visible) {
return null;
}
Model model = getSequencedModel();
if (model == null) {
return null;
}
super.height = model.minY;
model.pickable = true;
if (lowmem) {
return model;
}
if ((super.spotanimID != -1) && (super.spotanimFrame != -1)) {
SpotAnimType spot = SpotAnimType.instances[super.spotanimID];
Model spotModel1 = spot.getModel();
if (spotModel1 != null) {
Model spotModel2 = new Model(true, SeqTransform.isNull(super.spotanimFrame), false, spotModel1);
spotModel2.translate(0, -super.spotanimOffset, 0);
spotModel2.createLabelReferences();
spotModel2.applyTransform(spot.seq.transformIDs[super.spotanimFrame]);
spotModel2.labelFaces = null;
spotModel2.labelVertices = null;
if ((spot.scaleXY != 128) || (spot.scaleZ != 128)) {
spotModel2.scale(spot.scaleXY, spot.scaleXY, spot.scaleZ);
}
spotModel2.calculateNormals(64 + spot.lightAmbient, 850 + spot.lightAttenuation, -30, -50, -30, true);
model = new Model(2, -819, new Model[]{model, spotModel2});
}
}
if (this.locModel != null) {
if (Game.loopCycle >= locStopCycle) {
this.locModel = null;
}
if ((Game.loopCycle >= locStartCycle) && (Game.loopCycle < locStopCycle)) {
Model locModel = this.locModel;
locModel.translate(locOffsetX - super.x, locOffsetY - y, locOffsetZ - super.z);
if (super.dstYaw == 512) {
locModel.rotateY90();
locModel.rotateY90();
locModel.rotateY90();
} else if (super.dstYaw == 1024) {
locModel.rotateY90();
locModel.rotateY90();
} else if (super.dstYaw == 1536) {
locModel.rotateY90();
}
model = new Model(2, -819, new Model[]{model, locModel});
if (super.dstYaw == 512) {
locModel.rotateY90();
} else if (super.dstYaw == 1024) {
locModel.rotateY90();
locModel.rotateY90();
} else if (super.dstYaw == 1536) {
locModel.rotateY90();
locModel.rotateY90();
locModel.rotateY90();
}
locModel.translate(super.x - locOffsetX, y - locOffsetY, super.z - locOffsetZ);
}
}
model.pickable = true;
return model;
}
public void read(Buffer buffer) {
buffer.position = 0;
gender = buffer.read8U();
headicons = buffer.read8U();
transmogrify = null;
team = 0;
for (int part = 0; part < 12; part++) {
int msb = buffer.read8U();
if (msb == 0) {
appearances[part] = 0;
continue;
}
int lsb = buffer.read8U();
appearances[part] = (msb << 8) + lsb;
if ((part == 0) && (appearances[0] == 65535)) {
transmogrify = NPCType.get(buffer.read16U());
break;
}
if ((appearances[part] >= 512) && ((appearances[part] - 512) < ObjType.count)) {
int team = ObjType.get(appearances[part] - 512).team;
if (team != 0) {
this.team = team;
}
}
}
for (int part = 0; part < 5; part++) {
int color = buffer.read8U();
if ((color < 0) || (color >= Game.designPartColor[part].length)) {
color = 0;
}
colors[part] = color;
}
super.seqStandID = buffer.read16U();
if (super.seqStandID == 65535) {
super.seqStandID = -1;
}
super.seqTurnID = buffer.read16U();
if (super.seqTurnID == 65535) {
super.seqTurnID = -1;
}
super.seqWalkID = buffer.read16U();
if (super.seqWalkID == 65535) {
super.seqWalkID = -1;
}
super.seqTurnAroundID = buffer.read16U();
if (super.seqTurnAroundID == 65535) {
super.seqTurnAroundID = -1;
}
super.seqTurnLeftID = buffer.read16U();
if (super.seqTurnLeftID == 65535) {
super.seqTurnLeftID = -1;
}
super.seqTurnRightID = buffer.read16U();
if (super.seqTurnRightID == 65535) {
super.seqTurnRightID = -1;
}
super.seqRunID = buffer.read16U();
if (super.seqRunID == 65535) {
super.seqRunID = -1;
}
name = StringUtil.formatName(StringUtil.fromBase37(buffer.read64()));
combatLevel = buffer.read8U();
skillLevel = buffer.read16U();
visible = true;
appearanceHashcode = 0L;
for (int part = 0; part < 12; part++) {
appearanceHashcode <<= 4;
if (appearances[part] >= 256) {
appearanceHashcode += appearances[part] - 256;
}
}
if (appearances[0] >= 256) {
appearanceHashcode += (appearances[0] - 256) >> 4;
}
if (appearances[1] >= 256) {
appearanceHashcode += (appearances[1] - 256) >> 8;
}
for (int i2 = 0; i2 < 5; i2++) {
appearanceHashcode <<= 3;
appearanceHashcode += colors[i2];
}
appearanceHashcode <<= 1;
appearanceHashcode += gender;
}
public Model getSequencedModel() {
if (transmogrify != null) {
int transformID = -1;
if ((super.primarySeqID >= 0) && (super.primarySeqDelay == 0)) {
transformID = SeqType.instances[super.primarySeqID].transformIDs[super.primarySeqFrame];
} else if (super.secondarySeqID >= 0) {
transformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
}
return transmogrify.getSequencedModel(-1, transformID, null);
}
long hashCode = this.appearanceHashcode;
int primaryTransformID = -1;
int secondaryTransformID = -1;
int rightHandValue = -1;
int leftHandValue = -1;
if ((super.primarySeqID >= 0) && (super.primarySeqDelay == 0)) {
SeqType type = SeqType.instances[super.primarySeqID];
primaryTransformID = type.transformIDs[super.primarySeqFrame];
if ((super.secondarySeqID >= 0) && (super.secondarySeqID != super.seqStandID)) {
secondaryTransformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
}
if (type.rightHandOverride >= 0) {
rightHandValue = type.rightHandOverride;
hashCode += ((long) rightHandValue - appearances[5]) << 8;
}
if (type.leftHandOverride >= 0) {
leftHandValue = type.leftHandOverride;
hashCode += ((long) leftHandValue - appearances[3]) << 16;
}
} else if (super.secondarySeqID >= 0) {
primaryTransformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
}
Model model = modelCache.get(hashCode);
if (model == null) {
boolean invalid = false;
for (int part = 0; part < 12; part++) {
int value = appearances[part];
if ((leftHandValue >= 0) && (part == 3)) {
value = leftHandValue;
}
if ((rightHandValue >= 0) && (part == 5)) {
value = rightHandValue;
}
if ((value >= 256) && (value < 512) && !IdkType.instances[value - 256].validateModel()) {
invalid = true;
}
if ((value >= 512) && !ObjType.get(value - 512).validateWornModel(gender)) {
invalid = true;
}
}
if (invalid) {
if (modelUID != -1L) {
model = modelCache.get(modelUID);
}
if (model == null) {
return null;
}
}
}
if (model == null) {
Model[] models = new Model[12];
int modelCount = 0;
for (int part = 0; part < 12; part++) {
int value = appearances[part];
if ((leftHandValue >= 0) && (part == 3)) {
value = leftHandValue;
}
if ((rightHandValue >= 0) && (part == 5)) {
value = rightHandValue;
}
if ((value >= 256) && (value < 512)) {
Model kitModel = IdkType.instances[value - 256].getModel();
if (kitModel != null) {
models[modelCount++] = kitModel;
}
}
if (value >= 512) {
Model objModel = ObjType.get(value - 512).getWornModel(gender);
if (objModel != null) {
models[modelCount++] = objModel;
}
}
}
model = new Model(modelCount, models);
for (int part = 0; part < 5; part++) {
if (colors[part] != 0) {
model.recolor(Game.designPartColor[part][0], Game.designPartColor[part][colors[part]]);
if (part == 1) {
model.recolor(Game.designHairColor[0], Game.designHairColor[colors[part]]);
}
}
}
model.createLabelReferences();
model.calculateNormals(64, 850, -30, -50, -30, true);
modelCache.put(hashCode, model);
modelUID = hashCode;
}
if (lowmem) {
return model;
}
Model tmp = Model.EMPTY;
tmp.set(model, SeqTransform.isNull(primaryTransformID) & SeqTransform.isNull(secondaryTransformID));
if ((primaryTransformID != -1) && (secondaryTransformID != -1)) {
tmp.applyTransforms(primaryTransformID, secondaryTransformID, SeqType.instances[super.primarySeqID].mask);
} else if (primaryTransformID != -1) {
tmp.applyTransform(primaryTransformID);
}
tmp.calculateBoundsCylinder();
tmp.labelFaces = null;
tmp.labelVertices = null;
return tmp;
}
@Override
public boolean isVisible() {
return visible;
}
public Model getHeadModel() {
if (!visible) {
return null;
}
if (transmogrify != null) {
return transmogrify.getHeadModel();
}
boolean invalid = false;
for (int part = 0; part < 12; part++) {
int value = appearances[part];
if ((value >= 256) && (value < 512) && !IdkType.instances[value - 256].validateHeadModel()) {
invalid = true;
}
if ((value >= 512) && !ObjType.get(value - 512).validateHeadModel(gender)) {
invalid = true;
}
}
if (invalid) {
return null;
}
Model[] models = new Model[12];
int modelCount = 0;
for (int part = 0; part < 12; part++) {
int value = appearances[part];
if ((value >= 256) && (value < 512)) {
Model model = IdkType.instances[value - 256].getHeadModel();
if (model != null) {
models[modelCount++] = model;
}
}
if (value >= 512) {
Model model = ObjType.get(value - 512).getHeadModel(gender);
if (model != null) {
models[modelCount++] = model;
}
}
}
Model model = new Model(modelCount, models);
for (int part = 0; part < 5; part++) {
if (colors[part] != 0) {
model.recolor(Game.designPartColor[part][0], Game.designPartColor[part][colors[part]]);
if (part == 1) {
model.recolor(Game.designHairColor[0], Game.designHairColor[colors[part]]);
}
}
}
return model;
}
public static LRUMap<Long, Model> modelCache = new LRUMap<>(260);
public final int[] colors = new int[5];
public final int[] appearances = new int[12];
public long modelUID = -1L;
public NPCType transmogrify;
public boolean lowmem = false;
public int team;
public int gender;
public String name;
public int combatLevel;
public int headicons;
public int locStartCycle;
public int locStopCycle;
public int y;
public boolean visible = false;
public int locOffsetX;
public int locOffsetY;
public int locOffsetZ;
public Model locModel;
public long appearanceHashcode;
public int minSceneTileX;
public int minSceneTileZ;
public int maxSceneTileX;
public int maxSceneTileZ;
public int skillLevel;
public PlayerEntity() {
}
@Override
public Model getModel() {
if (!visible) {
return null;
}
Model model = getSequencedModel();
if (model == null) {
return null;
}
super.height = model.minY;
model.pickable = true;
if (lowmem) {
return model;
}
if ((super.spotanimID != -1) && (super.spotanimFrame != -1)) {
SpotAnimType spot = SpotAnimType.instances[super.spotanimID];
Model spotModel1 = spot.getModel();
if (spotModel1 != null) {
Model spotModel2 = new Model(true, SeqTransform.isNull(super.spotanimFrame), false, spotModel1);
spotModel2.translate(0, -super.spotanimOffset, 0);
spotModel2.createLabelReferences();
spotModel2.applyTransform(spot.seq.transformIDs[super.spotanimFrame]);
spotModel2.labelFaces = null;
spotModel2.labelVertices = null;
if ((spot.scaleXY != 128) || (spot.scaleZ != 128)) {
spotModel2.scale(spot.scaleXY, spot.scaleXY, spot.scaleZ);
}
spotModel2.calculateNormals(64 + spot.lightAmbient, 850 + spot.lightAttenuation, -30, -50, -30, true);
model = new Model(2, -819, new Model[]{model, spotModel2});
}
}
if (this.locModel != null) {
if (Game.loopCycle >= locStopCycle) {
this.locModel = null;
}
if ((Game.loopCycle >= locStartCycle) && (Game.loopCycle < locStopCycle)) {
Model locModel = this.locModel;
locModel.translate(locOffsetX - super.x, locOffsetY - y, locOffsetZ - super.z);
if (super.dstYaw == 512) {
locModel.rotateY90();
locModel.rotateY90();
locModel.rotateY90();
} else if (super.dstYaw == 1024) {
locModel.rotateY90();
locModel.rotateY90();
} else if (super.dstYaw == 1536) {
locModel.rotateY90();
}
model = new Model(2, -819, new Model[]{model, locModel});
if (super.dstYaw == 512) {
locModel.rotateY90();
} else if (super.dstYaw == 1024) {
locModel.rotateY90();
locModel.rotateY90();
} else if (super.dstYaw == 1536) {
locModel.rotateY90();
locModel.rotateY90();
locModel.rotateY90();
}
locModel.translate(super.x - locOffsetX, y - locOffsetY, super.z - locOffsetZ);
}
}
model.pickable = true;
return model;
}
public void read(Buffer buffer) {
buffer.position = 0;
gender = buffer.read8U();
headicons = buffer.read8U();
transmogrify = null;
team = 0;
for (int part = 0; part < 12; part++) {
int msb = buffer.read8U();
if (msb == 0) {
appearances[part] = 0;
continue;
}
int lsb = buffer.read8U();
appearances[part] = (msb << 8) + lsb;
if ((part == 0) && (appearances[0] == 65535)) {
transmogrify = NPCType.get(buffer.read16U());
break;
}
if ((appearances[part] >= 512) && ((appearances[part] - 512) < ObjType.count)) {
int team = ObjType.get(appearances[part] - 512).team;
if (team != 0) {
this.team = team;
}
}
}
for (int part = 0; part < 5; part++) {
int color = buffer.read8U();
if ((color < 0) || (color >= Game.designPartColor[part].length)) {
color = 0;
}
colors[part] = color;
}
super.seqStandID = buffer.read16U();
if (super.seqStandID == 65535) {
super.seqStandID = -1;
}
super.seqTurnID = buffer.read16U();
if (super.seqTurnID == 65535) {
super.seqTurnID = -1;
}
super.seqWalkID = buffer.read16U();
if (super.seqWalkID == 65535) {
super.seqWalkID = -1;
}
super.seqTurnAroundID = buffer.read16U();
if (super.seqTurnAroundID == 65535) {
super.seqTurnAroundID = -1;
}
super.seqTurnLeftID = buffer.read16U();
if (super.seqTurnLeftID == 65535) {
super.seqTurnLeftID = -1;
}
super.seqTurnRightID = buffer.read16U();
if (super.seqTurnRightID == 65535) {
super.seqTurnRightID = -1;
}
super.seqRunID = buffer.read16U();
if (super.seqRunID == 65535) {
super.seqRunID = -1;
}
name = StringUtil.formatName(StringUtil.fromBase37(buffer.read64()));
combatLevel = buffer.read8U();
skillLevel = buffer.read16U();
visible = true;
appearanceHashcode = 0L;
for (int part = 0; part < 12; part++) {
appearanceHashcode <<= 4;
if (appearances[part] >= 256) {
appearanceHashcode += appearances[part] - 256;
}
}
if (appearances[0] >= 256) {
appearanceHashcode += (appearances[0] - 256) >> 4;
}
if (appearances[1] >= 256) {
appearanceHashcode += (appearances[1] - 256) >> 8;
}
for (int i2 = 0; i2 < 5; i2++) {
appearanceHashcode <<= 3;
appearanceHashcode += colors[i2];
}
appearanceHashcode <<= 1;
appearanceHashcode += gender;
}
public Model getSequencedModel() {
if (transmogrify != null) {
int transformID = -1;
if ((super.primarySeqID >= 0) && (super.primarySeqDelay == 0)) {
transformID = SeqType.instances[super.primarySeqID].transformIDs[super.primarySeqFrame];
} else if (super.secondarySeqID >= 0) {
transformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
}
return transmogrify.getSequencedModel(-1, transformID, null);
}
long hashCode = this.appearanceHashcode;
int primaryTransformID = -1;
int secondaryTransformID = -1;
int rightHandValue = -1;
int leftHandValue = -1;
if ((super.primarySeqID >= 0) && (super.primarySeqDelay == 0)) {
SeqType type = SeqType.instances[super.primarySeqID];
primaryTransformID = type.transformIDs[super.primarySeqFrame];
if ((super.secondarySeqID >= 0) && (super.secondarySeqID != super.seqStandID)) {
secondaryTransformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
}
if (type.rightHandOverride >= 0) {
rightHandValue = type.rightHandOverride;
hashCode += ((long) rightHandValue - appearances[5]) << 8;
}
if (type.leftHandOverride >= 0) {
leftHandValue = type.leftHandOverride;
hashCode += ((long) leftHandValue - appearances[3]) << 16;
}
} else if (super.secondarySeqID >= 0) {
primaryTransformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
}
Model model = modelCache.get(hashCode);
if (model == null) {
boolean invalid = false;
for (int part = 0; part < 12; part++) {
int value = appearances[part];
if ((leftHandValue >= 0) && (part == 3)) {
value = leftHandValue;
}
if ((rightHandValue >= 0) && (part == 5)) {
value = rightHandValue;
}
if ((value >= 256) && (value < 512) && !IdkType.instances[value - 256].validateModel()) {
invalid = true;
}
if ((value >= 512) && !ObjType.get(value - 512).validateWornModel(gender)) {
invalid = true;
}
}
if (invalid) {
if (modelUID != -1L) {
model = modelCache.get(modelUID);
}
if (model == null) {
return null;
}
}
}
if (model == null) {
Model[] models = new Model[12];
int modelCount = 0;
for (int part = 0; part < 12; part++) {
int value = appearances[part];
if ((leftHandValue >= 0) && (part == 3)) {
value = leftHandValue;
}
if ((rightHandValue >= 0) && (part == 5)) {
value = rightHandValue;
}
if ((value >= 256) && (value < 512)) {
Model kitModel = IdkType.instances[value - 256].getModel();
if (kitModel != null) {
models[modelCount++] = kitModel;
}
}
if (value >= 512) {
Model objModel = ObjType.get(value - 512).getWornModel(gender);
if (objModel != null) {
models[modelCount++] = objModel;
}
}
}
model = new Model(modelCount, models);
for (int part = 0; part < 5; part++) {
if (colors[part] != 0) {
model.recolor(Game.designPartColor[part][0], Game.designPartColor[part][colors[part]]);
if (part == 1) {
model.recolor(Game.designHairColor[0], Game.designHairColor[colors[part]]);
}
}
}
model.createLabelReferences();
model.calculateNormals(64, 850, -30, -50, -30, true);
modelCache.put(hashCode, model);
modelUID = hashCode;
}
if (lowmem) {
return model;
}
Model tmp = Model.EMPTY;
tmp.set(model, SeqTransform.isNull(primaryTransformID) & SeqTransform.isNull(secondaryTransformID));
if ((primaryTransformID != -1) && (secondaryTransformID != -1)) {
tmp.applyTransforms(primaryTransformID, secondaryTransformID, SeqType.instances[super.primarySeqID].mask);
} else if (primaryTransformID != -1) {
tmp.applyTransform(primaryTransformID);
}
tmp.calculateBoundsCylinder();
tmp.labelFaces = null;
tmp.labelVertices = null;
return tmp;
}
@Override
public boolean isVisible() {
return visible;
}
public Model getHeadModel() {
if (!visible) {
return null;
}
if (transmogrify != null) {
return transmogrify.getHeadModel();
}
boolean invalid = false;
for (int part = 0; part < 12; part++) {
int value = appearances[part];
if ((value >= 256) && (value < 512) && !IdkType.instances[value - 256].validateHeadModel()) {
invalid = true;
}
if ((value >= 512) && !ObjType.get(value - 512).validateHeadModel(gender)) {
invalid = true;
}
}
if (invalid) {
return null;
}
Model[] models = new Model[12];
int modelCount = 0;
for (int part = 0; part < 12; part++) {
int value = appearances[part];
if ((value >= 256) && (value < 512)) {
Model model = IdkType.instances[value - 256].getHeadModel();
if (model != null) {
models[modelCount++] = model;
}
}
if (value >= 512) {
Model model = ObjType.get(value - 512).getHeadModel(gender);
if (model != null) {
models[modelCount++] = model;
}
}
}
Model model = new Model(modelCount, models);
for (int part = 0; part < 5; part++) {
if (colors[part] != 0) {
model.recolor(Game.designPartColor[part][0], Game.designPartColor[part][colors[part]]);
if (part == 1) {
model.recolor(Game.designHairColor[0], Game.designHairColor[colors[part]]);
}
}
}
return model;
}
}
+97 -97
View File
@@ -4,109 +4,109 @@
public class ProjectileEntity extends Entity {
public final int startCycle;
public final int lastCycle;
public final int srcX;
public final int srcZ;
public final int srcY;
public final int offsetY;
public final int peakPitch;
public final int arc;
public final int target;
public final SpotAnimType spotanim;
public final int level;
public double velocityX;
public double velocityZ;
public double velocity;
public double velocityY;
public double accelerationY;
public boolean mobile = false;
public double x;
public double z;
public double y;
public int seqFrame;
public int seqCycle;
public int yaw;
public int pitch;
public final int startCycle;
public final int lastCycle;
public final int srcX;
public final int srcZ;
public final int srcY;
public final int offsetY;
public final int peakPitch;
public final int arc;
public final int target;
public final SpotAnimType spotanim;
public final int level;
public double velocityX;
public double velocityZ;
public double velocity;
public double velocityY;
public double accelerationY;
public boolean mobile = false;
public double x;
public double z;
public double y;
public int seqFrame;
public int seqCycle;
public int yaw;
public int pitch;
public ProjectileEntity(int peakPitch, int offsetY, int startCycle, int lastCycle, int arc, int level, int srcY, int srcZ, int srcX, int target, int spotanim) {
this.spotanim = SpotAnimType.instances[spotanim];
this.level = level;
this.srcX = srcX;
this.srcZ = srcZ;
this.srcY = srcY;
this.startCycle = startCycle;
this.lastCycle = lastCycle;
this.peakPitch = peakPitch;
this.arc = arc;
this.target = target;
this.offsetY = offsetY;
}
public ProjectileEntity(int peakPitch, int offsetY, int startCycle, int lastCycle, int arc, int level, int srcY, int srcZ, int srcX, int target, int spotanim) {
this.spotanim = SpotAnimType.instances[spotanim];
this.level = level;
this.srcX = srcX;
this.srcZ = srcZ;
this.srcY = srcY;
this.startCycle = startCycle;
this.lastCycle = lastCycle;
this.peakPitch = peakPitch;
this.arc = arc;
this.target = target;
this.offsetY = offsetY;
}
public void updateVelocity(int cycle, int dstZ, int dstY, int dstX) {
if (!mobile) {
double dx = dstX - srcX;
double dz = dstZ - srcZ;
double d = Math.sqrt((dx * dx) + (dz * dz));
x = (double) srcX + ((dx * (double) arc) / d);
z = (double) srcZ + ((dz * (double) arc) / d);
y = srcY;
}
double dt = (lastCycle + 1) - cycle;
velocityX = ((double) dstX - x) / dt;
velocityZ = ((double) dstZ - z) / dt;
velocity = Math.sqrt((velocityX * velocityX) + (velocityZ * velocityZ));
if (!mobile) {
velocityY = -velocity * Math.tan((double) peakPitch * 0.02454369D);
}
accelerationY = (2D * ((double) dstY - y - (velocityY * dt))) / (dt * dt);
}
public void updateVelocity(int cycle, int dstZ, int dstY, int dstX) {
if (!mobile) {
double dx = dstX - srcX;
double dz = dstZ - srcZ;
double d = Math.sqrt((dx * dx) + (dz * dz));
x = (double) srcX + ((dx * (double) arc) / d);
z = (double) srcZ + ((dz * (double) arc) / d);
y = srcY;
}
double dt = (lastCycle + 1) - cycle;
velocityX = ((double) dstX - x) / dt;
velocityZ = ((double) dstZ - z) / dt;
velocity = Math.sqrt((velocityX * velocityX) + (velocityZ * velocityZ));
if (!mobile) {
velocityY = -velocity * Math.tan((double) peakPitch * 0.02454369D);
}
accelerationY = (2D * ((double) dstY - y - (velocityY * dt))) / (dt * dt);
}
@Override
public Model getModel() {
Model tmp = spotanim.getModel();
if (tmp == null) {
return null;
}
int transformID = -1;
@Override
public Model getModel() {
Model tmp = spotanim.getModel();
if (tmp == null) {
return null;
}
int transformID = -1;
if (spotanim.seq != null) {
transformID = spotanim.seq.transformIDs[seqFrame];
}
if (spotanim.seq != null) {
transformID = spotanim.seq.transformIDs[seqFrame];
}
Model model = new Model(true, SeqTransform.isNull(transformID), false, tmp);
if (transformID != -1) {
model.createLabelReferences();
model.applyTransform(transformID);
model.labelFaces = null;
model.labelVertices = null;
}
if ((spotanim.scaleXY != 128) || (spotanim.scaleZ != 128)) {
model.scale(spotanim.scaleXY, spotanim.scaleXY, spotanim.scaleZ);
}
model.rotateX(pitch);
model.calculateNormals(64 + spotanim.lightAmbient, 850 + spotanim.lightAttenuation, -30, -50, -30, true);
return model;
}
Model model = new Model(true, SeqTransform.isNull(transformID), false, tmp);
if (transformID != -1) {
model.createLabelReferences();
model.applyTransform(transformID);
model.labelFaces = null;
model.labelVertices = null;
}
if ((spotanim.scaleXY != 128) || (spotanim.scaleZ != 128)) {
model.scale(spotanim.scaleXY, spotanim.scaleXY, spotanim.scaleZ);
}
model.rotateX(pitch);
model.calculateNormals(64 + spotanim.lightAmbient, 850 + spotanim.lightAttenuation, -30, -50, -30, true);
return model;
}
public void update(int delta) {
mobile = true;
x += velocityX * (double) delta;
z += velocityZ * (double) delta;
y += (velocityY * (double) delta) + (0.5D * accelerationY * (double) delta * (double) delta);
velocityY += accelerationY * (double) delta;
yaw = ((int) (Math.atan2(velocityX, velocityZ) * 325.94900000000001D) + 1024) & 0x7ff;
pitch = (int) (Math.atan2(velocityY, velocity) * 325.94900000000001D) & 0x7ff;
public void update(int delta) {
mobile = true;
x += velocityX * (double) delta;
z += velocityZ * (double) delta;
y += (velocityY * (double) delta) + (0.5D * accelerationY * (double) delta * (double) delta);
velocityY += accelerationY * (double) delta;
yaw = ((int) (Math.atan2(velocityX, velocityZ) * 325.94900000000001D) + 1024) & 0x7ff;
pitch = (int) (Math.atan2(velocityY, velocity) * 325.94900000000001D) & 0x7ff;
if (spotanim.seq != null) {
for (seqCycle += delta; seqCycle > spotanim.seq.getFrameDuration(seqFrame); ) {
seqCycle -= spotanim.seq.getFrameDuration(seqFrame) + 1;
seqFrame++;
if (seqFrame >= spotanim.seq.frameCount) {
seqFrame = 0;
}
}
}
}
if (spotanim.seq != null) {
for (seqCycle += delta; seqCycle > spotanim.seq.getFrameDuration(seqFrame); ) {
seqCycle -= spotanim.seq.getFrameDuration(seqFrame) + 1;
seqFrame++;
if (seqFrame >= spotanim.seq.frameCount) {
seqFrame = 0;
}
}
}
}
}
+2 -2
View File
@@ -1599,8 +1599,8 @@ public class Scene {
SceneLoc farthest = locBuffer[farthestIndex];
farthest.cycle = cycle;
if (!occluded(occludeLevel, farthest.minSceneTileX, farthest.maxSceneTileX, farthest.minSceneTileZ, farthest.maxSceneTileZ, farthest.entity.minY)) {
farthest.entity.draw(farthest.yaw, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, farthest.x - eyeX, farthest.y - eyeY, farthest.z - eyeZ, farthest.bitset);
if (!occluded(occludeLevel, farthest.minSceneTileX, farthest.maxSceneTileX, farthest.minSceneTileZ, farthest.maxSceneTileZ, farthest.entity.minY)) {
farthest.entity.draw(farthest.yaw, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, farthest.x - eyeX, farthest.y - eyeY, farthest.z - eyeZ, farthest.bitset);
}
for (int x = farthest.minSceneTileX; x <= farthest.maxSceneTileX; x++) {
+6 -4
View File
@@ -72,7 +72,7 @@ public class SceneBuilder {
* Used to determine if a LocType's models have been loaded.
*
* @param locID the loc type id.
* @param kind the loc kind.
* @param kind the loc kind.
* @return <code>true</code> if the loc models are ready.
*/
public static boolean isLocReady(int locID, int kind) {
@@ -341,7 +341,8 @@ public class SceneBuilder {
* Reads the Locs from the provided data and determines if their models are available. The origin coordinate is used
* to determine if a loc would be excluded from the scene, therefor not required to be validated. The chain of calls
* eventually invokes {@link Model#validate(int)} which causes the {@link OnDemand} to do its job.
* @param data the data
*
* @param data the data
* @param originX the region origin x in the scene.
* @param originZ the region origin z in the scene.
* @return <code>true</code> if all locs are valid.
@@ -890,8 +891,9 @@ public class SceneBuilder {
/**
* Flattens the perimeter of the provided area.
* @param tileX the area x.
* @param tileZ the area z.
*
* @param tileX the area x.
* @param tileZ the area z.
* @param tileSizeX the area size x.
* @param tileSizeZ the area size z.
*/
+8 -8
View File
@@ -4,14 +4,14 @@
public class SceneGroundDecoration {
public int y;
public int x;
public int z;
public Entity entity;
public int bitset;
public byte info;
public int y;
public int x;
public int z;
public Entity entity;
public int bitset;
public byte info;
public SceneGroundDecoration() {
}
public SceneGroundDecoration() {
}
}
+19 -19
View File
@@ -4,26 +4,26 @@
public class SceneLoc {
public int level;
public int y;
public int x;
public int z;
public Entity entity;
public int yaw;
public int minSceneTileX;
public int maxSceneTileX;
public int minSceneTileZ;
public int maxSceneTileZ;
public int distance;
public int cycle;
public int bitset;
public byte info;
public int level;
public int y;
public int x;
public int z;
public Entity entity;
public int yaw;
public int minSceneTileX;
public int maxSceneTileX;
public int minSceneTileZ;
public int maxSceneTileZ;
public int distance;
public int cycle;
public int bitset;
public byte info;
public boolean drawn() {
return cycle == Scene.cycle;
}
public boolean drawn() {
return cycle == Scene.cycle;
}
public SceneLoc() {
}
public SceneLoc() {
}
}
+15 -15
View File
@@ -4,21 +4,21 @@
public class SceneLocTemporary extends DoublyLinkedList.Node {
public int id;
public int rotation;
public int kind;
public int duration;
public int level;
public int classID;
public int localX;
public int localZ;
public int previousLocID;
public int previousRotation;
public int previousKind;
public int delay;
public int id;
public int rotation;
public int kind;
public int duration;
public int level;
public int classID;
public int localX;
public int localZ;
public int previousLocID;
public int previousRotation;
public int previousKind;
public int delay;
public SceneLocTemporary() {
duration = -1;
}
public SceneLocTemporary() {
duration = -1;
}
}
+10 -10
View File
@@ -4,16 +4,16 @@
public class SceneObjStack {
public int y;
public int x;
public int z;
public Entity topObj;
public Entity bottomObj;
public Entity middleObj;
public int bitset;
public int offset;
public int y;
public int x;
public int z;
public Entity topObj;
public Entity bottomObj;
public Entity middleObj;
public int bitset;
public int offset;
public SceneObjStack() {
}
public SceneObjStack() {
}
}
+32 -32
View File
@@ -4,39 +4,39 @@
public class SceneOccluder {
/**
* A wall occluder which runs along the X axis.
*/
public static final int TYPE_WALL_X = 1;
/**
* A wall occluder which runs along the Z axis.
*/
public static final int TYPE_WALL_Z = 2;
/**
* A ground occluder which covers the XZ plane.
*/
public static final int TYPE_GROUND = 4;
/**
* A wall occluder which runs along the X axis.
*/
public static final int TYPE_WALL_X = 1;
/**
* A wall occluder which runs along the Z axis.
*/
public static final int TYPE_WALL_Z = 2;
/**
* A ground occluder which covers the XZ plane.
*/
public static final int TYPE_GROUND = 4;
public int minTileX;
public int maxTileX;
public int minTileZ;
public int maxTileZ;
public int type;
public int minX;
public int maxX;
public int minZ;
public int maxZ;
public int minY;
public int maxY;
public int mode;
public int minDeltaX;
public int maxDeltaX;
public int minDeltaZ;
public int maxDeltaZ;
public int minDeltaY;
public int maxDeltaY;
public int minTileX;
public int maxTileX;
public int minTileZ;
public int maxTileZ;
public int type;
public int minX;
public int maxX;
public int minZ;
public int maxZ;
public int minY;
public int maxY;
public int mode;
public int minDeltaX;
public int maxDeltaX;
public int minDeltaZ;
public int maxDeltaZ;
public int minDeltaY;
public int maxDeltaY;
public SceneOccluder() {
}
public SceneOccluder() {
}
}
+45 -44
View File
@@ -4,50 +4,51 @@
public class SceneTile extends DoublyLinkedList.Node {
public final int x;
public final int z;
/**
* Which level to sample when testing against this tile for occlusion.
*/
public final int occludeLevel;
public final SceneLoc[] locs = new SceneLoc[5];
public final int[] locSpan = new int[5];
public int level;
public SceneTileUnderlay underlay;
public SceneTileOverlay overlay;
public SceneWall wall;
public SceneWallDecoration wallDecoration;
public SceneGroundDecoration groundDecoration;
public SceneObjStack objStack;
public int locCount;
/**
* When larger than 1x1 locs reside on a tile, we have to know which part of it might be on this tile to properly
* cull it.
* <p>
* 0b0001 = x > loc.minSceneTileX
* 0b0010 = z < loc.maxSceneTileZ
* 0b0100 = x < loc.maxSceneTileX
* 0b1000 = z > loc.minSceneTileZ
*/
public int locSpans;
/**
* Used as a short circuit to prevent drawing tiles above the top level. Mostly applies to lowmem.
* @see Scene#draw(int, int, int, int, int, int)
*/
public int drawLevel;
public boolean visible;
public boolean update;
public boolean containsLocs;
public int checkLocSpans;
public int blockLocSpans;
public int inverseBlockLocSpans;
public int backWallTypes;
public SceneTile bridge;
public final int x;
public final int z;
/**
* Which level to sample when testing against this tile for occlusion.
*/
public final int occludeLevel;
public final SceneLoc[] locs = new SceneLoc[5];
public final int[] locSpan = new int[5];
public int level;
public SceneTileUnderlay underlay;
public SceneTileOverlay overlay;
public SceneWall wall;
public SceneWallDecoration wallDecoration;
public SceneGroundDecoration groundDecoration;
public SceneObjStack objStack;
public int locCount;
/**
* When larger than 1x1 locs reside on a tile, we have to know which part of it might be on this tile to properly
* cull it.
* <p>
* 0b0001 = x > loc.minSceneTileX
* 0b0010 = z < loc.maxSceneTileZ
* 0b0100 = x < loc.maxSceneTileX
* 0b1000 = z > loc.minSceneTileZ
*/
public int locSpans;
/**
* Used as a short circuit to prevent drawing tiles above the top level. Mostly applies to lowmem.
*
* @see Scene#draw(int, int, int, int, int, int)
*/
public int drawLevel;
public boolean visible;
public boolean update;
public boolean containsLocs;
public int checkLocSpans;
public int blockLocSpans;
public int inverseBlockLocSpans;
public int backWallTypes;
public SceneTile bridge;
public SceneTile(int level, int x, int z) {
this.occludeLevel = this.level = level;
this.x = x;
this.z = z;
}
public SceneTile(int level, int x, int z) {
this.occludeLevel = this.level = level;
this.x = x;
this.z = z;
}
}
+14 -14
View File
@@ -5,20 +5,20 @@
public class SceneTileOverlay {
public static final int[][] SHAPE_POINTS = {
{1, 3, 5, 7},
{1, 3, 5, 7},
{1, 3, 5, 7},
{1, 3, 5, 7, 6},
{1, 3, 5, 7, 6},
{1, 3, 5, 7, 6},
{1, 3, 5, 7, 6},
{1, 3, 5, 7, 2, 6},
{1, 3, 5, 7, 2, 8},
{1, 3, 5, 7, 2, 8},
{1, 3, 5, 7, 11, 12},
{1, 3, 5, 7, 11, 12},
{1, 3, 5, 7, 13, 14},
};
{1, 3, 5, 7},
{1, 3, 5, 7},
{1, 3, 5, 7},
{1, 3, 5, 7, 6},
{1, 3, 5, 7, 6},
{1, 3, 5, 7, 6},
{1, 3, 5, 7, 6},
{1, 3, 5, 7, 2, 6},
{1, 3, 5, 7, 2, 8},
{1, 3, 5, 7, 2, 8},
{1, 3, 5, 7, 11, 12},
{1, 3, 5, 7, 11, 12},
{1, 3, 5, 7, 13, 14},
};
public static final int[][] SHAPE_PATHS = {
{0, 1, 2, 3, 0, 0, 1, 3},
{1, 1, 2, 3, 1, 0, 1, 3},
+16 -16
View File
@@ -4,22 +4,22 @@
public class SceneTileUnderlay {
public final int southwestColor;
public final int southeastColor;
public final int northeastColor;
public final int northwestColor;
public final int textureID;
public final int rgb;
public boolean flat;
public final int southwestColor;
public final int southeastColor;
public final int northeastColor;
public final int northwestColor;
public final int textureID;
public final int rgb;
public boolean flat;
public SceneTileUnderlay(int southwestColor, int southeastColor, int northeastColor, int northwestColor, int textureID, int rgb, boolean flat) {
this.southwestColor = southwestColor;
this.southeastColor = southeastColor;
this.northeastColor = northeastColor;
this.northwestColor = northwestColor;
this.textureID = textureID;
this.rgb = rgb;
this.flat = flat;
}
public SceneTileUnderlay(int southwestColor, int southeastColor, int northeastColor, int northwestColor, int textureID, int rgb, boolean flat) {
this.southwestColor = southwestColor;
this.southeastColor = southeastColor;
this.northeastColor = northeastColor;
this.northwestColor = northwestColor;
this.textureID = textureID;
this.rgb = rgb;
this.flat = flat;
}
}
+11 -11
View File
@@ -4,17 +4,17 @@
public class SceneWall {
public int y;
public int x;
public int z;
public int typeA;
public int typeB;
public Entity entityA;
public Entity entityB;
public int bitset;
public byte info;
public int y;
public int x;
public int z;
public int typeA;
public int typeB;
public Entity entityA;
public Entity entityB;
public int bitset;
public byte info;
public SceneWall() {
}
public SceneWall() {
}
}
+10 -10
View File
@@ -1,15 +1,15 @@
public class SceneWallDecoration {
public int y;
public int x;
public int z;
public int type;
public int rotation;
public Entity entity;
public int bitset;
public byte info;
public int y;
public int x;
public int z;
public int type;
public int rotation;
public Entity entity;
public int bitset;
public byte info;
public SceneWallDecoration() {
}
public SceneWallDecoration() {
}
}
+2 -1
View File
@@ -26,7 +26,8 @@ public class SeqSkeleton {
public final int[] baseTypes;
/**
* The labels belonging to the base.
* @see Model#createLabelReferences()
*
* @see Model#createLabelReferences()
*/
public final int[][] baseLabels;
+149 -149
View File
@@ -6,182 +6,182 @@
*/
public class SeqTransform {
public static SeqTransform[] instances;
public static SeqTransform[] 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 SeqTransform[count + 1];
}
/**
* Initializes the array of instances.
*
* @param count the count
*/
public static void init(int count) {
instances = new SeqTransform[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 SeqTransform}
*
* @param id the transform id.
* @return the {@link SeqTransform} or <code>null</code> if it does not exist.
*/
public static SeqTransform get(int id) {
if ((instances == null) || (id < 0) || (id >= instances.length)) {
return null;
} else {
return instances[id];
}
}
/**
* Gets the {@link SeqTransform}
*
* @param id the transform id.
* @return the {@link SeqTransform} or <code>null</code> if it does not exist.
*/
public static SeqTransform get(int id) {
if ((instances == null) || (id < 0) || (id >= instances.length)) {
return null;
} else {
return instances[id];
}
}
/**
* This method can read <i>multiple</i> {@link SeqTransform}s which means the input data can be all the transforms
* related to the loaded skeleton.
*
* @param src the animation data.
* @see #get(int)
*/
public static void unpack(byte[] src) {
Buffer offsets = new Buffer(src);
offsets.position = src.length - 8;
/**
* This method can read <i>multiple</i> {@link SeqTransform}s which means the input data can be all the transforms
* related to the loaded skeleton.
*
* @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.read16U() + 2;
int offset = 0;
header.position = offset;
offset += offsets.read16U() + 2;
tran1.position = offset;
offset += offsets.read16U();
tran1.position = offset;
offset += offsets.read16U();
tran2.position = offset;
offset += offsets.read16U();
tran2.position = offset;
offset += offsets.read16U();
del.position = offset;
offset += offsets.read16U();
del.position = offset;
offset += offsets.read16U();
skel.position = offset;
skel.position = offset;
SeqSkeleton skeleton = new SeqSkeleton(skel);
SeqSkeleton skeleton = new SeqSkeleton(skel);
int frameCount = header.read16U();
int[] bases = new int[500];
int[] x = new int[500];
int[] y = new int[500];
int[] z = new int[500];
int frameCount = header.read16U();
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++) {
SeqTransform transform = instances[header.read16U()] = new SeqTransform();
transform.delay = del.read8U();
transform.skeleton = skeleton;
for (int i = 0; i < frameCount; i++) {
SeqTransform transform = instances[header.read16U()] = new SeqTransform();
transform.delay = del.read8U();
transform.skeleton = skeleton;
int baseCount = header.read8U();
int lastBase = -1;
int length = 0;
int baseCount = header.read8U();
int lastBase = -1;
int length = 0;
for (int base = 0; base < baseCount; base++) {
int flags = tran1.read8U();
for (int base = 0; base < baseCount; base++) {
int flags = tran1.read8U();
if (flags <= 0) {
continue;
}
if (flags <= 0) {
continue;
}
if (skeleton.baseTypes[base] != SeqSkeleton.OP_BASE) {
// Look for any skipped ORIGIN bases and insert them into this transform.
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) {
// Look for any skipped ORIGIN bases and insert them into this transform.
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.readSmart();
} else {
x[length] = defaultValue;
}
if ((flags & 1) != 0) {
x[length] = tran2.readSmart();
} else {
x[length] = defaultValue;
}
if ((flags & 2) != 0) {
y[length] = tran2.readSmart();
} else {
y[length] = defaultValue;
}
if ((flags & 2) != 0) {
y[length] = tran2.readSmart();
} else {
y[length] = defaultValue;
}
if ((flags & 4) != 0) {
z[length] = tran2.readSmart();
} else {
z[length] = defaultValue;
}
if ((flags & 4) != 0) {
z[length] = tran2.readSmart();
} else {
z[length] = defaultValue;
}
lastBase = base;
length++;
}
lastBase = base;
length++;
}
transform.length = length;
transform.bases = new int[length];
transform.x = new int[length];
transform.y = new int[length];
transform.z = new int[length];
transform.length = length;
transform.bases = new int[length];
transform.x = new int[length];
transform.y = new int[length];
transform.z = new int[length];
for (int j = 0; j < length; j++) {
transform.bases[j] = bases[j];
transform.x[j] = x[j];
transform.y[j] = y[j];
transform.z[j] = z[j];
}
}
}
for (int j = 0; j < length; j++) {
transform.bases[j] = bases[j];
transform.x[j] = x[j];
transform.y[j] = y[j];
transform.z[j] = z[j];
}
}
}
/**
* The skeleton associated to this transform.
*/
public SeqSkeleton skeleton;
/**
* The delay in <code>ticks</code>.
*/
public int delay;
/**
* The number of operations this transform performs.
*/
public int length;
/**
* The list of bases this transform uses.
*/
public int[] bases;
/**
* This transforms parameters.
*/
public int[] x, y, z;
/**
* The skeleton associated to this transform.
*/
public SeqSkeleton skeleton;
/**
* The delay in <code>ticks</code>.
*/
public int delay;
/**
* The number of operations this transform performs.
*/
public int length;
/**
* The list of bases this transform uses.
*/
public int[] bases;
/**
* This transforms parameters.
*/
public int[] x, y, z;
}
+181 -173
View File
@@ -6,204 +6,212 @@ import java.io.IOException;
public class SeqType {
public static int count;
public static SeqType[] instances;
public static int count;
public static SeqType[] instances;
public static void unpack(FileArchive archive) throws IOException {
Buffer buffer = new Buffer(archive.read("seq.dat"));
count = buffer.read16U();
if (instances == null) {
instances = new SeqType[count];
}
public static void unpack(FileArchive archive) throws IOException {
Buffer buffer = new Buffer(archive.read("seq.dat"));
count = buffer.read16U();
if (instances == null) {
instances = new SeqType[count];
}
for (int i = 0; i < count; i++) {
if (instances[i] == null) {
instances[i] = new SeqType();
}
instances[i].load(buffer);
}
}
for (int i = 0; i < count; i++) {
if (instances[i] == null) {
instances[i] = new SeqType();
}
instances[i].load(buffer);
}
}
/**
* The amount of frames in this {@link SeqType}.
*/
public int frameCount;
/**
* The amount of frames in this {@link SeqType}.
*/
public int frameCount;
/**
* The list of {@link SeqTransform} indices indexed by Frame ID.
* @see SeqTransform
*/
public int[] transformIDs;
/**
* The list of {@link SeqTransform} indices indexed by Frame ID.
*
* @see SeqTransform
*/
public int[] transformIDs;
/**
* Auxiliary transform indices appear to only be used by a {@link IfType} of type <code>6</code> as seen in {@link Game#drawParentInterface(IfType, int, int, int)}.
*/
public int[] auxiliaryTransformIDs;
/**
* Auxiliary transform indices appear to only be used by a {@link IfType} of type <code>6</code> as seen in {@link Game#drawParentInterface(IfType, int, int, int)}.
*/
public int[] auxiliaryTransformIDs;
/**
* A list of durations indexed by Frame ID.
*/
public int[] frameDuration;
/**
* A list of durations indexed by Frame ID.
*/
public int[] frameDuration;
/**
* The number of frames from the end of this {@link SeqType} used for looping.
*/
public int loopFrameCount = -1;
/**
* The number of frames from the end of this {@link SeqType} used for looping.
*/
public int loopFrameCount = -1;
/**
* Used to determine which transform bases a primary frame is allowed to use, and secondary not.
* @see Model#applyTransforms(int, int, int[])
*/
public int[] mask;
/**
* Used to determine which transform bases a primary frame is allowed to use, and secondary not.
*
* @see Model#applyTransforms(int, int, int[])
*/
public int[] mask;
/**
* Adds additional space to the render bounds.
* @see Scene#addTemporary(Entity, int, int, int, int, int, int, boolean, int)
*/
public boolean forwardRenderPadding = false;
/**
* Adds additional space to the render bounds.
*
* @see Scene#addTemporary(Entity, int, int, int, int, int, int, boolean, int)
*/
public boolean forwardRenderPadding = false;
/**
* The priority.
*/
public int priority = 5;
/**
* The priority.
*/
public int priority = 5;
/**
* Allows this {@link SeqType} to override the right hand of a {@link PlayerEntity}.
* @see PlayerEntity#getSequencedModel()
*/
public int rightHandOverride = -1;
/**
* Allows this {@link SeqType} to override the right hand of a {@link PlayerEntity}.
*
* @see PlayerEntity#getSequencedModel()
*/
public int rightHandOverride = -1;
/**
* Allows this {@link SeqType} to override the left hand of a {@link PlayerEntity}.
* @see PlayerEntity#getSequencedModel()
*/
public int leftHandOverride = -1;
/**
* Allows this {@link SeqType} to override the left hand of a {@link PlayerEntity}.
*
* @see PlayerEntity#getSequencedModel()
*/
public int leftHandOverride = -1;
/**
* How many times this seq is allowed to loop before stopping.
*/
public int loopCount = 99;
/**
* How many times this seq is allowed to loop before stopping.
*/
public int loopCount = 99;
/**
* If 0, causes faster movement, allows looking at target
* If 1, pause while moving
* If 2, does not look at target, continues playing during movement
* @see Game#updateMovement(PathingEntity)
*/
public int moveStyle = -1;
/**
* If 0, allows looking at a target
* If 1, stops playing on move
* If 2, does not look at target, continues playing during movement
* @see Game#updateMovement(PathingEntity)
*/
public int idleStyle = -1;
/**
* If 0, causes faster movement, allows looking at target
* If 1, pause while moving
* If 2, does not look at target, continues playing during movement
*
* @see Game#updateMovement(PathingEntity)
*/
public int moveStyle = -1;
/**
* If 0, restarts the sequence if already playing
* If 1, does not restart if already playing
* @see Game#readNPCUpdates()
*/
public int replayStyle = 1;
/**
* If 0, allows looking at a target
* If 1, stops playing on move
* If 2, does not look at target, continues playing during movement
*
* @see Game#updateMovement(PathingEntity)
*/
public int idleStyle = -1;
/**
* If 0, restarts the sequence if already playing
* If 1, does not restart if already playing
*
* @see Game#readNPCUpdates()
*/
public int replayStyle = 1;
public SeqType() {
}
public SeqType() {
}
public int getFrameDuration(int frame) {
int duration = frameDuration[frame];
public int getFrameDuration(int frame) {
int duration = frameDuration[frame];
if (duration == 0) {
SeqTransform transform = SeqTransform.get(transformIDs[frame]);
if (transform != null) {
duration = frameDuration[frame] = transform.delay;
}
}
if (duration == 0) {
SeqTransform transform = SeqTransform.get(transformIDs[frame]);
if (transform != null) {
duration = frameDuration[frame] = transform.delay;
}
}
if (duration == 0) {
duration = 1;
}
if (duration == 0) {
duration = 1;
}
return duration;
}
return duration;
}
public void load(Buffer buffer) {
while (true) {
int code = buffer.read8U();
public void load(Buffer buffer) {
while (true) {
int code = buffer.read8U();
if (code == 0) {
break;
} else if (code == 1) {
frameCount = buffer.read8U();
transformIDs = new int[frameCount];
auxiliaryTransformIDs = new int[frameCount];
frameDuration = new int[frameCount];
for (int f = 0; f < frameCount; f++) {
transformIDs[f] = buffer.read16U();
auxiliaryTransformIDs[f] = buffer.read16U();
if (auxiliaryTransformIDs[f] == 65535) {
auxiliaryTransformIDs[f] = -1;
}
frameDuration[f] = buffer.read16U();
}
} else if (code == 2) {
loopFrameCount = buffer.read16U();
} else if (code == 3) {
int count = buffer.read8U();
mask = new int[count + 1];
for (int l = 0; l < count; l++) {
mask[l] = buffer.read8U();
}
mask[count] = 9999999;
} else if (code == 4) {
forwardRenderPadding = true;
} else if (code == 5) {
priority = buffer.read8U();
} else if (code == 6) {
rightHandOverride = buffer.read16U();
} else if (code == 7) {
leftHandOverride = buffer.read16U();
} else if (code == 8) {
loopCount = buffer.read8U();
} else if (code == 9) {
moveStyle = buffer.read8U();
} else if (code == 10) {
idleStyle = buffer.read8U();
} else if (code == 11) {
replayStyle = buffer.read8U();
} else if (code == 12) {
buffer.read32();
} else {
System.out.println("Error unrecognised seq config code: " + code);
}
}
if (code == 0) {
break;
} else if (code == 1) {
frameCount = buffer.read8U();
transformIDs = new int[frameCount];
auxiliaryTransformIDs = new int[frameCount];
frameDuration = new int[frameCount];
for (int f = 0; f < frameCount; f++) {
transformIDs[f] = buffer.read16U();
auxiliaryTransformIDs[f] = buffer.read16U();
if (auxiliaryTransformIDs[f] == 65535) {
auxiliaryTransformIDs[f] = -1;
}
frameDuration[f] = buffer.read16U();
}
} else if (code == 2) {
loopFrameCount = buffer.read16U();
} else if (code == 3) {
int count = buffer.read8U();
mask = new int[count + 1];
for (int l = 0; l < count; l++) {
mask[l] = buffer.read8U();
}
mask[count] = 9999999;
} else if (code == 4) {
forwardRenderPadding = true;
} else if (code == 5) {
priority = buffer.read8U();
} else if (code == 6) {
rightHandOverride = buffer.read16U();
} else if (code == 7) {
leftHandOverride = buffer.read16U();
} else if (code == 8) {
loopCount = buffer.read8U();
} else if (code == 9) {
moveStyle = buffer.read8U();
} else if (code == 10) {
idleStyle = buffer.read8U();
} else if (code == 11) {
replayStyle = buffer.read8U();
} else if (code == 12) {
buffer.read32();
} else {
System.out.println("Error unrecognised seq config code: " + code);
}
}
if (frameCount == 0) {
frameCount = 1;
transformIDs = new int[1];
transformIDs[0] = -1;
auxiliaryTransformIDs = new int[1];
auxiliaryTransformIDs[0] = -1;
frameDuration = new int[1];
frameDuration[0] = -1;
}
if (frameCount == 0) {
frameCount = 1;
transformIDs = new int[1];
transformIDs[0] = -1;
auxiliaryTransformIDs = new int[1];
auxiliaryTransformIDs[0] = -1;
frameDuration = new int[1];
frameDuration[0] = -1;
}
if (moveStyle == -1) {
if (mask != null) {
moveStyle = 2;
} else {
moveStyle = 0;
}
}
if (moveStyle == -1) {
if (mask != null) {
moveStyle = 2;
} else {
moveStyle = 0;
}
}
if (idleStyle == -1) {
if (mask != null) {
idleStyle = 2;
} else {
idleStyle = 0;
}
}
}
if (idleStyle == -1) {
if (mask != null) {
idleStyle = 2;
} else {
idleStyle = 0;
}
}
}
}
+251 -251
View File
@@ -11,269 +11,269 @@ import java.net.URL;
public class Signlink implements Runnable {
public static final RandomAccessFile[] cache_idx = new RandomAccessFile[5];
public static final Applet mainapp = null;
public static int uid;
public static int storeid = 32;
public static RandomAccessFile cache_dat = null;
public static boolean sunjava;
public static boolean active;
public static int threadliveid;
public static InetAddress socketip;
public static int socketreq;
public static Socket socket = null;
public static int threadreqpri = 1;
public static Runnable threadreq = null;
public static String dnsreq = null;
public static String dns = null;
public static String urlreq = null;
public static DataInputStream urlstream = null;
public static int savelen;
public static String savereq = null;
public static byte[] savebuf = null;
public static boolean midiplay;
public static int midipos;
public static String midi = null;
public static int midivol;
public static int midifade;
public static boolean waveplay;
public static int wavepos;
public static String wave = null;
public static int wavevol;
public static boolean reporterror = true;
public static final RandomAccessFile[] cache_idx = new RandomAccessFile[5];
public static final Applet mainapp = null;
public static int uid;
public static int storeid = 32;
public static RandomAccessFile cache_dat = null;
public static boolean sunjava;
public static boolean active;
public static int threadliveid;
public static InetAddress socketip;
public static int socketreq;
public static Socket socket = null;
public static int threadreqpri = 1;
public static Runnable threadreq = null;
public static String dnsreq = null;
public static String dns = null;
public static String urlreq = null;
public static DataInputStream urlstream = null;
public static int savelen;
public static String savereq = null;
public static byte[] savebuf = null;
public static boolean midiplay;
public static int midipos;
public static String midi = null;
public static int midivol;
public static int midifade;
public static boolean waveplay;
public static int wavepos;
public static String wave = null;
public static int wavevol;
public static boolean reporterror = true;
public static void startpriv(InetAddress inetaddress) {
threadliveid = (int) (Math.random() * 99999999D);
if (active) {
try {
Thread.sleep(500L);
} catch (Exception ignored) {
}
active = false;
}
socketreq = 0;
threadreq = null;
dnsreq = null;
savereq = null;
urlreq = null;
socketip = inetaddress;
Thread thread = new Thread(new Signlink());
thread.setDaemon(true);
thread.start();
while (!active) {
try {
Thread.sleep(50L);
} catch (Exception ignored) {
}
}
}
public static void startpriv(InetAddress inetaddress) {
threadliveid = (int) (Math.random() * 99999999D);
if (active) {
try {
Thread.sleep(500L);
} catch (Exception ignored) {
}
active = false;
}
socketreq = 0;
threadreq = null;
dnsreq = null;
savereq = null;
urlreq = null;
socketip = inetaddress;
Thread thread = new Thread(new Signlink());
thread.setDaemon(true);
thread.start();
while (!active) {
try {
Thread.sleep(50L);
} catch (Exception ignored) {
}
}
}
public static String findcachedir() {
String[] as = {"c:/windows/", "c:/winnt/", "d:/windows/", "d:/winnt/", "e:/windows/", "e:/winnt/", "f:/windows/", "f:/winnt/", "c:/", "~/", "/tmp/", "", "c:/rscache", "/rscache"};
if ((storeid < 32) || (storeid > 34)) {
storeid = 32;
}
String s = ".file_store_" + storeid;
for (String a : as) {
try {
if (a.length() > 0) {
File file = new File(a);
if (!file.exists()) {
continue;
}
}
File file1 = new File(a + s);
if (file1.exists() || file1.mkdir()) {
return a + s + "/";
}
} catch (Exception ignored) {
}
}
return null;
}
public static String findcachedir() {
String[] as = {"c:/windows/", "c:/winnt/", "d:/windows/", "d:/winnt/", "e:/windows/", "e:/winnt/", "f:/windows/", "f:/winnt/", "c:/", "~/", "/tmp/", "", "c:/rscache", "/rscache"};
if ((storeid < 32) || (storeid > 34)) {
storeid = 32;
}
String s = ".file_store_" + storeid;
for (String a : as) {
try {
if (a.length() > 0) {
File file = new File(a);
if (!file.exists()) {
continue;
}
}
File file1 = new File(a + s);
if (file1.exists() || file1.mkdir()) {
return a + s + "/";
}
} catch (Exception ignored) {
}
}
return null;
}
public static int getuid(String s) {
try {
File file = new File(s + "uid.dat");
if (!file.exists() || (file.length() < 4L)) {
DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(s + "uid.dat"));
dataoutputstream.writeInt((int) (Math.random() * 99999999D));
dataoutputstream.close();
}
} catch (Exception ignored) {
}
try {
DataInputStream datainputstream = new DataInputStream(new FileInputStream(s + "uid.dat"));
int i = datainputstream.readInt();
datainputstream.close();
return i + 1;
} catch (Exception _ex) {
return 0;
}
}
public static int getuid(String s) {
try {
File file = new File(s + "uid.dat");
if (!file.exists() || (file.length() < 4L)) {
DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(s + "uid.dat"));
dataoutputstream.writeInt((int) (Math.random() * 99999999D));
dataoutputstream.close();
}
} catch (Exception ignored) {
}
try {
DataInputStream datainputstream = new DataInputStream(new FileInputStream(s + "uid.dat"));
int i = datainputstream.readInt();
datainputstream.close();
return i + 1;
} catch (Exception _ex) {
return 0;
}
}
public static synchronized Socket opensocket(int i) throws IOException {
for (socketreq = i; socketreq != 0; ) {
try {
Thread.sleep(50L);
} catch (Exception ignored) {
}
}
if (socket == null) {
throw new IOException("could not open socket");
} else {
return socket;
}
}
public static synchronized Socket opensocket(int i) throws IOException {
for (socketreq = i; socketreq != 0; ) {
try {
Thread.sleep(50L);
} catch (Exception ignored) {
}
}
if (socket == null) {
throw new IOException("could not open socket");
} else {
return socket;
}
}
public static synchronized DataInputStream openurl(String s) throws IOException {
for (urlreq = s; urlreq != null; ) {
try {
Thread.sleep(50L);
} catch (Exception ignored) {
}
}
if (urlstream == null) {
throw new IOException("could not open: " + s);
} else {
return urlstream;
}
}
public static synchronized DataInputStream openurl(String s) throws IOException {
for (urlreq = s; urlreq != null; ) {
try {
Thread.sleep(50L);
} catch (Exception ignored) {
}
}
if (urlstream == null) {
throw new IOException("could not open: " + s);
} else {
return urlstream;
}
}
public static synchronized void dnslookup(String s) {
dns = s;
dnsreq = s;
}
public static synchronized void dnslookup(String s) {
dns = s;
dnsreq = s;
}
public static synchronized void startthread(Runnable runnable, int i) {
threadreqpri = i;
threadreq = runnable;
}
public static synchronized void startthread(Runnable runnable, int i) {
threadreqpri = i;
threadreq = runnable;
}
public static synchronized boolean wavesave(byte[] src, int len) {
if (len > 0x1e8480) {
return false;
}
if (savereq != null) {
return false;
} else {
wavepos = (wavepos + 1) % 5;
savelen = len;
savebuf = src;
waveplay = true;
savereq = "sound" + wavepos + ".wav";
return true;
}
}
public static synchronized boolean wavesave(byte[] src, int len) {
if (len > 0x1e8480) {
return false;
}
if (savereq != null) {
return false;
} else {
wavepos = (wavepos + 1) % 5;
savelen = len;
savebuf = src;
waveplay = true;
savereq = "sound" + wavepos + ".wav";
return true;
}
}
public static synchronized boolean wavereplay() {
if (savereq != null) {
return false;
} else {
savebuf = null;
waveplay = true;
savereq = "sound" + wavepos + ".wav";
return true;
}
}
public static synchronized boolean wavereplay() {
if (savereq != null) {
return false;
} else {
savebuf = null;
waveplay = true;
savereq = "sound" + wavepos + ".wav";
return true;
}
}
public static synchronized void midisave(byte[] data, int len) {
if (len > 0x1e8480) {
return;
}
if (savereq != null) {
} else {
midipos = (midipos + 1) % 5;
savelen = len;
savebuf = data;
midiplay = true;
savereq = "jingle" + midipos + ".mid";
}
}
public static synchronized void midisave(byte[] data, int len) {
if (len > 0x1e8480) {
return;
}
if (savereq != null) {
} else {
midipos = (midipos + 1) % 5;
savelen = len;
savebuf = data;
midiplay = true;
savereq = "jingle" + midipos + ".mid";
}
}
public static void reporterror(String s) {
if (!reporterror) {
return;
}
if (!active) {
return;
}
System.out.println("Error: " + s);
}
public static void reporterror(String s) {
if (!reporterror) {
return;
}
if (!active) {
return;
}
System.out.println("Error: " + s);
}
public Signlink() {
}
public Signlink() {
}
@Override
public void run() {
active = true;
String s = findcachedir();
System.out.println(s);
uid = getuid(s);
try {
File file = new File(s + "main_file_cache.dat");
if (file.exists() && (file.length() > 0x3200000L)) {
file.delete();
}
cache_dat = new RandomAccessFile(s + "main_file_cache.dat", "rw");
for (int j = 0; j < 5; j++) {
cache_idx[j] = new RandomAccessFile(s + "main_file_cache.idx" + j, "rw");
}
} catch (Exception exception) {
exception.printStackTrace();
}
for (int i = threadliveid; threadliveid == i; ) {
if (socketreq != 0) {
try {
socket = new Socket(socketip, socketreq);
} catch (Exception _ex) {
socket = null;
}
socketreq = 0;
} else if (threadreq != null) {
Thread thread = new Thread(threadreq);
thread.setDaemon(true);
thread.start();
thread.setPriority(threadreqpri);
threadreq = null;
} else if (dnsreq != null) {
try {
dns = InetAddress.getByName(dnsreq).getHostName();
} catch (Exception _ex) {
dns = "unknown";
}
dnsreq = null;
} else if (savereq != null) {
if (savebuf != null) {
try {
FileOutputStream fileoutputstream = new FileOutputStream(s + savereq);
fileoutputstream.write(savebuf, 0, savelen);
fileoutputstream.close();
} catch (Exception ignored) {
}
}
if (waveplay) {
wave = s + savereq;
waveplay = false;
}
if (midiplay) {
midi = s + savereq;
midiplay = false;
}
savereq = null;
} else if (urlreq != null) {
try {
urlstream = new DataInputStream(new URL(mainapp.getCodeBase(), urlreq).openStream());
} catch (Exception _ex) {
urlstream = null;
}
urlreq = null;
}
try {
Thread.sleep(50L);
} catch (Exception ignored) {
}
}
}
@Override
public void run() {
active = true;
String s = findcachedir();
System.out.println(s);
uid = getuid(s);
try {
File file = new File(s + "main_file_cache.dat");
if (file.exists() && (file.length() > 0x3200000L)) {
file.delete();
}
cache_dat = new RandomAccessFile(s + "main_file_cache.dat", "rw");
for (int j = 0; j < 5; j++) {
cache_idx[j] = new RandomAccessFile(s + "main_file_cache.idx" + j, "rw");
}
} catch (Exception exception) {
exception.printStackTrace();
}
for (int i = threadliveid; threadliveid == i; ) {
if (socketreq != 0) {
try {
socket = new Socket(socketip, socketreq);
} catch (Exception _ex) {
socket = null;
}
socketreq = 0;
} else if (threadreq != null) {
Thread thread = new Thread(threadreq);
thread.setDaemon(true);
thread.start();
thread.setPriority(threadreqpri);
threadreq = null;
} else if (dnsreq != null) {
try {
dns = InetAddress.getByName(dnsreq).getHostName();
} catch (Exception _ex) {
dns = "unknown";
}
dnsreq = null;
} else if (savereq != null) {
if (savebuf != null) {
try {
FileOutputStream fileoutputstream = new FileOutputStream(s + savereq);
fileoutputstream.write(savebuf, 0, savelen);
fileoutputstream.close();
} catch (Exception ignored) {
}
}
if (waveplay) {
wave = s + savereq;
waveplay = false;
}
if (midiplay) {
midi = s + savereq;
midiplay = false;
}
savereq = null;
} else if (urlreq != null) {
try {
urlstream = new DataInputStream(new URL(mainapp.getCodeBase(), urlreq).openStream());
} catch (Exception _ex) {
urlstream = null;
}
urlreq = null;
}
try {
Thread.sleep(50L);
} catch (Exception ignored) {
}
}
}
}
+3 -3
View File
@@ -4,8 +4,8 @@
public class Skill {
public static final int COUNT = 25;
public static final boolean[] ENABLED = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, false, false, false, false};
public static final String[] NAME = {"attack", "defence", "strength", "hitpoints", "ranged", "prayer", "magic", "cooking", "woodcutting", "fletching", "fishing", "firemaking", "crafting", "smithing", "mining", "herblore", "agility", "thieving", "slayer", "farming", "runecraft", "-unused-", "-unused-", "-unused-", "-unused-"};
public static final int COUNT = 25;
public static final boolean[] ENABLED = {true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, false, false, false, false};
public static final String[] NAME = {"attack", "defence", "strength", "hitpoints", "ranged", "prayer", "magic", "cooking", "woodcutting", "fletching", "fishing", "firemaking", "crafting", "smithing", "mining", "herblore", "agility", "thieving", "slayer", "farming", "runecraft", "-unused-", "-unused-", "-unused-", "-unused-"};
}
+90 -90
View File
@@ -5,116 +5,116 @@
*/
public class SoundFilter {
public static final float[][] coefficient = new float[2][8];
public static final int[][] coefficient16 = new int[2][8];
public static float unity;
public static int unity16;
public final int[] pairs = new int[2];
public final int[][][] frequencies = new int[2][2][4];
public final int[][][] ranges = new int[2][2][4];
public final int[] unities = new int[2];
public static final float[][] coefficient = new float[2][8];
public static final int[][] coefficient16 = new int[2][8];
public static float unity;
public static int unity16;
public final int[] pairs = new int[2];
public final int[][][] frequencies = new int[2][2][4];
public final int[][][] ranges = new int[2][2][4];
public final int[] unities = new int[2];
public SoundFilter() {
}
public SoundFilter() {
}
public float gain(int direction, int pair, float delta) {
float g = (float) ranges[direction][0][pair] + (delta * (float) (ranges[direction][1][pair] - ranges[direction][0][pair]));
g *= 0.001525879F;
return 1.0F - (float) Math.pow(10D, -g / 20F);
}
public float gain(int direction, int pair, float delta) {
float g = (float) ranges[direction][0][pair] + (delta * (float) (ranges[direction][1][pair] - ranges[direction][0][pair]));
g *= 0.001525879F;
return 1.0F - (float) Math.pow(10D, -g / 20F);
}
public float normalize(float f) {
return (32.7032F * (float) Math.pow(2D, f) * 3.141593F) / 11025F;
}
public float normalize(float f) {
return (32.7032F * (float) Math.pow(2D, f) * 3.141593F) / 11025F;
}
public float phase(int direction, int pair, float delta) {
float f1 = (float) frequencies[direction][0][pair] + (delta * (float) (frequencies[direction][1][pair] - frequencies[direction][0][pair]));
f1 *= 0.0001220703F;
return normalize(f1);
}
public float phase(int direction, int pair, float delta) {
float f1 = (float) frequencies[direction][0][pair] + (delta * (float) (frequencies[direction][1][pair] - frequencies[direction][0][pair]));
f1 *= 0.0001220703F;
return normalize(f1);
}
public int evaluate(int direction, float delta) {
if (direction == 0) {
float u = (float) unities[0] + ((float) (unities[1] - unities[0]) * delta);
u *= 0.003051758F;
unity = (float) Math.pow(0.10000000000000001D, u / 20F);
unity16 = (int) (unity * 65536F);
}
public int evaluate(int direction, float delta) {
if (direction == 0) {
float u = (float) unities[0] + ((float) (unities[1] - unities[0]) * delta);
u *= 0.003051758F;
unity = (float) Math.pow(0.10000000000000001D, u / 20F);
unity16 = (int) (unity * 65536F);
}
if (pairs[direction] == 0) {
return 0;
}
if (pairs[direction] == 0) {
return 0;
}
float u = gain(direction, 0, delta);
float u = gain(direction, 0, delta);
coefficient[direction][0] = -2F * u * (float) Math.cos(phase(direction, 0, delta));
coefficient[direction][1] = u * u;
coefficient[direction][0] = -2F * u * (float) Math.cos(phase(direction, 0, delta));
coefficient[direction][1] = u * u;
for (int pair = 1; pair < pairs[direction]; pair++) {
float g = gain(direction, pair, delta);
float a = -2F * g * (float) Math.cos(phase(direction, pair, delta));
float b = g * g;
for (int pair = 1; pair < pairs[direction]; pair++) {
float g = gain(direction, pair, delta);
float a = -2F * g * (float) Math.cos(phase(direction, pair, delta));
float b = g * g;
coefficient[direction][(pair * 2) + 1] = coefficient[direction][(pair * 2) - 1] * b;
coefficient[direction][pair * 2] = (coefficient[direction][(pair * 2) - 1] * a) + (coefficient[direction][(pair * 2) - 2] * b);
coefficient[direction][(pair * 2) + 1] = coefficient[direction][(pair * 2) - 1] * b;
coefficient[direction][pair * 2] = (coefficient[direction][(pair * 2) - 1] * a) + (coefficient[direction][(pair * 2) - 2] * b);
for (int j = (pair * 2) - 1; j >= 2; j--) {
coefficient[direction][j] += (coefficient[direction][j - 1] * a) + (coefficient[direction][j - 2] * b);
}
for (int j = (pair * 2) - 1; j >= 2; j--) {
coefficient[direction][j] += (coefficient[direction][j - 1] * a) + (coefficient[direction][j - 2] * b);
}
coefficient[direction][1] += (coefficient[direction][0] * a) + b;
coefficient[direction][0] += a;
}
coefficient[direction][1] += (coefficient[direction][0] * a) + b;
coefficient[direction][0] += a;
}
if (direction == 0) {
for (int l = 0; l < (pairs[0] * 2); l++) {
coefficient[0][l] *= unity;
}
}
if (direction == 0) {
for (int l = 0; l < (pairs[0] * 2); l++) {
coefficient[0][l] *= unity;
}
}
for (int pair = 0; pair < (pairs[direction] * 2); pair++) {
coefficient16[direction][pair] = (int) (coefficient[direction][pair] * 65536F);
}
for (int pair = 0; pair < (pairs[direction] * 2); pair++) {
coefficient16[direction][pair] = (int) (coefficient[direction][pair] * 65536F);
}
return pairs[direction] * 2;
}
return pairs[direction] * 2;
}
public void read(Buffer buffer, SoundEnvelope envelope) {
int count = buffer.read8U();
pairs[0] = count >> 4;
pairs[1] = count & 0xf;
public void read(Buffer buffer, SoundEnvelope envelope) {
int count = buffer.read8U();
pairs[0] = count >> 4;
pairs[1] = count & 0xf;
if (count != 0) {
unities[0] = buffer.read16U();
unities[1] = buffer.read16U();
if (count != 0) {
unities[0] = buffer.read16U();
unities[1] = buffer.read16U();
int migration = buffer.read8U();
int migration = buffer.read8U();
for (int direction = 0; direction < 2; direction++) {
for (int pair = 0; pair < pairs[direction]; pair++) {
frequencies[direction][0][pair] = buffer.read16U();
ranges[direction][0][pair] = buffer.read16U();
}
}
for (int direction = 0; direction < 2; direction++) {
for (int pair = 0; pair < pairs[direction]; pair++) {
frequencies[direction][0][pair] = buffer.read16U();
ranges[direction][0][pair] = buffer.read16U();
}
}
for (int direction = 0; direction < 2; direction++) {
for (int pair = 0; pair < pairs[direction]; pair++) {
if ((migration & (1 << (direction * 4) << pair)) != 0) {
frequencies[direction][1][pair] = buffer.read16U();
ranges[direction][1][pair] = buffer.read16U();
} else {
frequencies[direction][1][pair] = frequencies[direction][0][pair];
ranges[direction][1][pair] = ranges[direction][0][pair];
}
}
}
for (int direction = 0; direction < 2; direction++) {
for (int pair = 0; pair < pairs[direction]; pair++) {
if ((migration & (1 << (direction * 4) << pair)) != 0) {
frequencies[direction][1][pair] = buffer.read16U();
ranges[direction][1][pair] = buffer.read16U();
} else {
frequencies[direction][1][pair] = frequencies[direction][0][pair];
ranges[direction][1][pair] = ranges[direction][0][pair];
}
}
}
if ((migration != 0) || (unities[1] != unities[0])) {
envelope.readShape(buffer);
}
} else {
unities[0] = unities[1] = 0;
}
}
if ((migration != 0) || (unities[1] != unities[0])) {
envelope.readShape(buffer);
}
} else {
unities[0] = unities[1] = 0;
}
}
}
+261 -261
View File
@@ -4,324 +4,324 @@
public class SoundTone {
public static final int[] tmpPhases = new int[5];
public static final int[] tmpDelays = new int[5];
public static final int[] tmpVolumes = new int[5];
public static final int[] tmpSemitones = new int[5];
public static final int[] tmpStarts = new int[5];
public static int[] buffer;
public static int[] noise;
public static int[] sin;
public static final int[] tmpPhases = new int[5];
public static final int[] tmpDelays = new int[5];
public static final int[] tmpVolumes = new int[5];
public static final int[] tmpSemitones = new int[5];
public static final int[] tmpStarts = new int[5];
public static int[] buffer;
public static int[] noise;
public static int[] sin;
public static void init() {
noise = new int[32768];
for (int i = 0; i < 32768; i++) {
if (Math.random() > 0.5D) {
noise[i] = 1;
} else {
noise[i] = -1;
}
}
sin = new int[32768];
for (int j = 0; j < 32768; j++) {
sin[j] = (int) (Math.sin((double) j / 5215.1903000000002D) * 16384D);
}
buffer = new int[22050 * 10]; // 10 second buffer
}
public static void init() {
noise = new int[32768];
for (int i = 0; i < 32768; i++) {
if (Math.random() > 0.5D) {
noise[i] = 1;
} else {
noise[i] = -1;
}
}
sin = new int[32768];
for (int j = 0; j < 32768; j++) {
sin[j] = (int) (Math.sin((double) j / 5215.1903000000002D) * 16384D);
}
buffer = new int[22050 * 10]; // 10 second buffer
}
public final int[] harmonicVolume = new int[5];
public final int[] harmonicSemitone = new int[5];
public final int[] harmonicDelay = new int[5];
public SoundEnvelope frequencyBase;
public SoundEnvelope amplitudeBase;
public SoundEnvelope frequencyModRate;
public SoundEnvelope frequencyModRange;
public SoundEnvelope amplitudeModRate;
public SoundEnvelope amplitudeModRange;
public SoundEnvelope release;
public SoundEnvelope attack;
public int reverbDelay;
public int reverbVolume = 100;
public SoundFilter filter;
public SoundEnvelope filterRange;
public int length = 500;
public int start;
public final int[] harmonicVolume = new int[5];
public final int[] harmonicSemitone = new int[5];
public final int[] harmonicDelay = new int[5];
public SoundEnvelope frequencyBase;
public SoundEnvelope amplitudeBase;
public SoundEnvelope frequencyModRate;
public SoundEnvelope frequencyModRange;
public SoundEnvelope amplitudeModRate;
public SoundEnvelope amplitudeModRange;
public SoundEnvelope release;
public SoundEnvelope attack;
public int reverbDelay;
public int reverbVolume = 100;
public SoundFilter filter;
public SoundEnvelope filterRange;
public int length = 500;
public int start;
public SoundTone() {
}
public SoundTone() {
}
public int[] generate(int sampleCount, int length) {
for (int sample = 0; sample < sampleCount; sample++) {
buffer[sample] = 0;
}
public int[] generate(int sampleCount, int length) {
for (int sample = 0; sample < sampleCount; sample++) {
buffer[sample] = 0;
}
if (length < 10) {
return buffer;
}
if (length < 10) {
return buffer;
}
double samplesPerStep = (double) sampleCount / ((double) length + 0.0D);
double samplesPerStep = (double) sampleCount / ((double) length + 0.0D);
frequencyBase.reset();
amplitudeBase.reset();
frequencyBase.reset();
amplitudeBase.reset();
int frequencyStart = 0;
int frequencyDuration = 0;
int frequencyPhase = 0;
int frequencyStart = 0;
int frequencyDuration = 0;
int frequencyPhase = 0;
if (frequencyModRate != null) {
frequencyModRate.reset();
frequencyModRange.reset();
frequencyStart = (int) (((double) (frequencyModRate.end - frequencyModRate.start) * 32.768) / samplesPerStep);
frequencyDuration = (int) (((double) frequencyModRate.start * 32.768) / samplesPerStep);
}
if (frequencyModRate != null) {
frequencyModRate.reset();
frequencyModRange.reset();
frequencyStart = (int) (((double) (frequencyModRate.end - frequencyModRate.start) * 32.768) / samplesPerStep);
frequencyDuration = (int) (((double) frequencyModRate.start * 32.768) / samplesPerStep);
}
int amplitudeStart = 0;
int amplitudeDuration = 0;
int amplitudePhase = 0;
int amplitudeStart = 0;
int amplitudeDuration = 0;
int amplitudePhase = 0;
if (amplitudeModRate != null) {
amplitudeModRate.reset();
amplitudeModRange.reset();
amplitudeStart = (int) (((double) (amplitudeModRate.end - amplitudeModRate.start) * 32.768) / samplesPerStep);
amplitudeDuration = (int) (((double) amplitudeModRate.start * 32.768) / samplesPerStep);
}
if (amplitudeModRate != null) {
amplitudeModRate.reset();
amplitudeModRange.reset();
amplitudeStart = (int) (((double) (amplitudeModRate.end - amplitudeModRate.start) * 32.768) / samplesPerStep);
amplitudeDuration = (int) (((double) amplitudeModRate.start * 32.768) / samplesPerStep);
}
for (int harmonic = 0; harmonic < 5; harmonic++) {
if (harmonicVolume[harmonic] != 0) {
tmpPhases[harmonic] = 0;
tmpDelays[harmonic] = (int) ((double) harmonicDelay[harmonic] * samplesPerStep);
tmpVolumes[harmonic] = (harmonicVolume[harmonic] << 14) / 100;
tmpSemitones[harmonic] = (int) (((double) (frequencyBase.end - frequencyBase.start) * 32.768 * Math.pow(1.0057929410678534D, harmonicSemitone[harmonic])) / samplesPerStep);
tmpStarts[harmonic] = (int) (((double) frequencyBase.start * 32.768) / samplesPerStep);
}
}
for (int harmonic = 0; harmonic < 5; harmonic++) {
if (harmonicVolume[harmonic] != 0) {
tmpPhases[harmonic] = 0;
tmpDelays[harmonic] = (int) ((double) harmonicDelay[harmonic] * samplesPerStep);
tmpVolumes[harmonic] = (harmonicVolume[harmonic] << 14) / 100;
tmpSemitones[harmonic] = (int) (((double) (frequencyBase.end - frequencyBase.start) * 32.768 * Math.pow(1.0057929410678534D, harmonicSemitone[harmonic])) / samplesPerStep);
tmpStarts[harmonic] = (int) (((double) frequencyBase.start * 32.768) / samplesPerStep);
}
}
for (int sample = 0; sample < sampleCount; sample++) {
int frequency = frequencyBase.evaluate(sampleCount);
int amplitude = amplitudeBase.evaluate(sampleCount);
for (int sample = 0; sample < sampleCount; sample++) {
int frequency = frequencyBase.evaluate(sampleCount);
int amplitude = amplitudeBase.evaluate(sampleCount);
if (frequencyModRate != null) {
int rate = frequencyModRate.evaluate(sampleCount);
int range = frequencyModRange.evaluate(sampleCount);
frequency += generate(frequencyModRate.form, frequencyPhase, range) >> 1;
frequencyPhase += ((rate * frequencyStart) >> 16) + frequencyDuration;
}
if (frequencyModRate != null) {
int rate = frequencyModRate.evaluate(sampleCount);
int range = frequencyModRange.evaluate(sampleCount);
frequency += generate(frequencyModRate.form, frequencyPhase, range) >> 1;
frequencyPhase += ((rate * frequencyStart) >> 16) + frequencyDuration;
}
if (amplitudeModRate != null) {
int rate = amplitudeModRate.evaluate(sampleCount);
int range = amplitudeModRange.evaluate(sampleCount);
amplitude = (amplitude * ((generate(amplitudeModRate.form, amplitudePhase, range) >> 1) + 32768)) >> 15;
amplitudePhase += ((rate * amplitudeStart) >> 16) + amplitudeDuration;
}
if (amplitudeModRate != null) {
int rate = amplitudeModRate.evaluate(sampleCount);
int range = amplitudeModRange.evaluate(sampleCount);
amplitude = (amplitude * ((generate(amplitudeModRate.form, amplitudePhase, range) >> 1) + 32768)) >> 15;
amplitudePhase += ((rate * amplitudeStart) >> 16) + amplitudeDuration;
}
for (int harmonic = 0; harmonic < 5; harmonic++) {
if (harmonicVolume[harmonic] != 0) {
int position = sample + tmpDelays[harmonic];
for (int harmonic = 0; harmonic < 5; harmonic++) {
if (harmonicVolume[harmonic] != 0) {
int position = sample + tmpDelays[harmonic];
if (position < sampleCount) {
buffer[position] += generate(frequencyBase.form, tmpPhases[harmonic], (amplitude * tmpVolumes[harmonic]) >> 15);
tmpPhases[harmonic] += ((frequency * tmpSemitones[harmonic]) >> 16) + tmpStarts[harmonic];
}
}
}
}
if (position < sampleCount) {
buffer[position] += generate(frequencyBase.form, tmpPhases[harmonic], (amplitude * tmpVolumes[harmonic]) >> 15);
tmpPhases[harmonic] += ((frequency * tmpSemitones[harmonic]) >> 16) + tmpStarts[harmonic];
}
}
}
}
if (release != null) {
release.reset();
attack.reset();
if (release != null) {
release.reset();
attack.reset();
int counter = 0;
boolean muted = true;
int counter = 0;
boolean muted = true;
for (int sample = 0; sample < sampleCount; sample++) {
int releaseValue = release.evaluate(sampleCount);
int attackValue = attack.evaluate(sampleCount);
int threshold;
for (int sample = 0; sample < sampleCount; sample++) {
int releaseValue = release.evaluate(sampleCount);
int attackValue = attack.evaluate(sampleCount);
int threshold;
if (muted) {
threshold = release.start + (((release.end - release.start) * releaseValue) >> 8);
} else {
threshold = release.start + (((release.end - release.start) * attackValue) >> 8);
}
if (muted) {
threshold = release.start + (((release.end - release.start) * releaseValue) >> 8);
} else {
threshold = release.start + (((release.end - release.start) * attackValue) >> 8);
}
if ((counter += 256) >= threshold) {
counter = 0;
muted = !muted;
}
if ((counter += 256) >= threshold) {
counter = 0;
muted = !muted;
}
if (muted) {
buffer[sample] = 0;
}
}
}
if (muted) {
buffer[sample] = 0;
}
}
}
if ((reverbDelay > 0) && (reverbVolume > 0)) {
int start = (int) ((double) reverbDelay * samplesPerStep);
if ((reverbDelay > 0) && (reverbVolume > 0)) {
int start = (int) ((double) reverbDelay * samplesPerStep);
for (int sample = start; sample < sampleCount; sample++) {
buffer[sample] += (buffer[sample - start] * reverbVolume) / 100;
}
}
for (int sample = start; sample < sampleCount; sample++) {
buffer[sample] += (buffer[sample - start] * reverbVolume) / 100;
}
}
if ((filter.pairs[0] > 0) || (filter.pairs[1] > 0)) {
filterRange.reset();
if ((filter.pairs[0] > 0) || (filter.pairs[1] > 0)) {
filterRange.reset();
int range = filterRange.evaluate(sampleCount + 1);
int forward = filter.evaluate(0, (float) range / 65536F);
int backward = filter.evaluate(1, (float) range / 65536F);
int range = filterRange.evaluate(sampleCount + 1);
int forward = filter.evaluate(0, (float) range / 65536F);
int backward = filter.evaluate(1, (float) range / 65536F);
if (sampleCount >= (forward + backward)) {
int index = 0;
int interval = backward;
if (sampleCount >= (forward + backward)) {
int index = 0;
int interval = backward;
if (interval > (sampleCount - forward)) {
interval = sampleCount - forward;
}
if (interval > (sampleCount - forward)) {
interval = sampleCount - forward;
}
for (; index < interval; index++) {
int sample = (int) (((long) buffer[index + forward] * (long) SoundFilter.unity16) >> 16);
for (; index < interval; index++) {
int sample = (int) (((long) buffer[index + forward] * (long) SoundFilter.unity16) >> 16);
for (int offset = 0; offset < forward; offset++) {
sample += (int) (((long) buffer[(index + forward) - 1 - offset] * (long) SoundFilter.coefficient16[0][offset]) >> 16);
}
for (int offset = 0; offset < forward; offset++) {
sample += (int) (((long) buffer[(index + forward) - 1 - offset] * (long) SoundFilter.coefficient16[0][offset]) >> 16);
}
for (int offset = 0; offset < index; offset++) {
sample -= (int) (((long) buffer[index - 1 - offset] * (long) SoundFilter.coefficient16[1][offset]) >> 16);
}
for (int offset = 0; offset < index; offset++) {
sample -= (int) (((long) buffer[index - 1 - offset] * (long) SoundFilter.coefficient16[1][offset]) >> 16);
}
buffer[index] = sample;
range = filterRange.evaluate(sampleCount + 1);
}
buffer[index] = sample;
range = filterRange.evaluate(sampleCount + 1);
}
interval = 128;
interval = 128;
do {
if (interval > (sampleCount - forward)) {
interval = sampleCount - forward;
}
do {
if (interval > (sampleCount - forward)) {
interval = sampleCount - forward;
}
for (; index < interval; index++) {
int sample = (int) (((long) buffer[index + forward] * (long) SoundFilter.unity16) >> 16);
for (; index < interval; index++) {
int sample = (int) (((long) buffer[index + forward] * (long) SoundFilter.unity16) >> 16);
for (int offset = 0; offset < forward; offset++) {
sample += (int) (((long) buffer[(index + forward) - 1 - offset] * (long) SoundFilter.coefficient16[0][offset]) >> 16);
}
for (int offset = 0; offset < forward; offset++) {
sample += (int) (((long) buffer[(index + forward) - 1 - offset] * (long) SoundFilter.coefficient16[0][offset]) >> 16);
}
for (int offset = 0; offset < backward; offset++) {
sample -= (int) (((long) buffer[index - 1 - offset] * (long) SoundFilter.coefficient16[1][offset]) >> 16);
}
for (int offset = 0; offset < backward; offset++) {
sample -= (int) (((long) buffer[index - 1 - offset] * (long) SoundFilter.coefficient16[1][offset]) >> 16);
}
buffer[index] = sample;
range = filterRange.evaluate(sampleCount + 1);
}
buffer[index] = sample;
range = filterRange.evaluate(sampleCount + 1);
}
if (index >= (sampleCount - forward)) {
break;
}
if (index >= (sampleCount - forward)) {
break;
}
forward = filter.evaluate(0, (float) range / 65536F);
backward = filter.evaluate(1, (float) range / 65536F);
interval += 128;
} while (true);
forward = filter.evaluate(0, (float) range / 65536F);
backward = filter.evaluate(1, (float) range / 65536F);
interval += 128;
} while (true);
for (; index < sampleCount; index++) {
int sample = 0;
for (; index < sampleCount; index++) {
int sample = 0;
for (int offset = (index + forward) - sampleCount; offset < forward; offset++) {
sample += (int) (((long) buffer[(index + forward) - 1 - offset] * (long) SoundFilter.coefficient16[0][offset]) >> 16);
}
for (int offset = (index + forward) - sampleCount; offset < forward; offset++) {
sample += (int) (((long) buffer[(index + forward) - 1 - offset] * (long) SoundFilter.coefficient16[0][offset]) >> 16);
}
for (int offset = 0; offset < backward; offset++) {
sample -= (int) (((long) buffer[index - 1 - offset] * (long) SoundFilter.coefficient16[1][offset]) >> 16);
}
for (int offset = 0; offset < backward; offset++) {
sample -= (int) (((long) buffer[index - 1 - offset] * (long) SoundFilter.coefficient16[1][offset]) >> 16);
}
buffer[index] = sample;
filterRange.evaluate(sampleCount + 1);
}
}
}
buffer[index] = sample;
filterRange.evaluate(sampleCount + 1);
}
}
}
for (int sample = 0; sample < sampleCount; sample++) {
if (buffer[sample] < -32768) {
buffer[sample] = -32768;
}
if (buffer[sample] > 32767) {
buffer[sample] = 32767;
}
}
for (int sample = 0; sample < sampleCount; sample++) {
if (buffer[sample] < -32768) {
buffer[sample] = -32768;
}
if (buffer[sample] > 32767) {
buffer[sample] = 32767;
}
}
return buffer;
}
return buffer;
}
public int generate(int form, int phase, int amplitude) {
if (form == 1) {
if ((phase & 0x7fff) < 16384) {
return amplitude;
} else {
return -amplitude;
}
} else if (form == 2) {
return (sin[phase & 0x7fff] * amplitude) >> 14;
} else if (form == 3) {
return (((phase & 0x7fff) * amplitude) >> 14) - amplitude;
} else if (form == 4) {
return noise[(phase / 2607) & 0x7fff] * amplitude;
} else {
return 0;
}
}
public int generate(int form, int phase, int amplitude) {
if (form == 1) {
if ((phase & 0x7fff) < 16384) {
return amplitude;
} else {
return -amplitude;
}
} else if (form == 2) {
return (sin[phase & 0x7fff] * amplitude) >> 14;
} else if (form == 3) {
return (((phase & 0x7fff) * amplitude) >> 14) - amplitude;
} else if (form == 4) {
return noise[(phase / 2607) & 0x7fff] * amplitude;
} else {
return 0;
}
}
public void read(Buffer buffer) {
frequencyBase = new SoundEnvelope();
frequencyBase.read(buffer);
amplitudeBase = new SoundEnvelope();
amplitudeBase.read(buffer);
public void read(Buffer buffer) {
frequencyBase = new SoundEnvelope();
frequencyBase.read(buffer);
amplitudeBase = new SoundEnvelope();
amplitudeBase.read(buffer);
if (buffer.read8U() != 0) {
buffer.position--;
frequencyModRate = new SoundEnvelope();
frequencyModRate.read(buffer);
frequencyModRange = new SoundEnvelope();
frequencyModRange.read(buffer);
}
if (buffer.read8U() != 0) {
buffer.position--;
frequencyModRate = new SoundEnvelope();
frequencyModRate.read(buffer);
frequencyModRange = new SoundEnvelope();
frequencyModRange.read(buffer);
}
if (buffer.read8U() != 0) {
buffer.position--;
amplitudeModRate = new SoundEnvelope();
amplitudeModRate.read(buffer);
amplitudeModRange = new SoundEnvelope();
amplitudeModRange.read(buffer);
}
if (buffer.read8U() != 0) {
buffer.position--;
amplitudeModRate = new SoundEnvelope();
amplitudeModRate.read(buffer);
amplitudeModRange = new SoundEnvelope();
amplitudeModRange.read(buffer);
}
if (buffer.read8U() != 0) {
buffer.position--;
release = new SoundEnvelope();
release.read(buffer);
attack = new SoundEnvelope();
attack.read(buffer);
}
if (buffer.read8U() != 0) {
buffer.position--;
release = new SoundEnvelope();
release.read(buffer);
attack = new SoundEnvelope();
attack.read(buffer);
}
for (int i = 0; i < 10; i++) {
int volume = buffer.readSmartU();
for (int i = 0; i < 10; i++) {
int volume = buffer.readSmartU();
if (volume == 0) {
break;
}
if (volume == 0) {
break;
}
harmonicVolume[i] = volume;
harmonicSemitone[i] = buffer.readSmart();
harmonicDelay[i] = buffer.readSmartU();
}
harmonicVolume[i] = volume;
harmonicSemitone[i] = buffer.readSmart();
harmonicDelay[i] = buffer.readSmartU();
}
reverbDelay = buffer.readSmartU();
reverbVolume = buffer.readSmartU();
reverbDelay = buffer.readSmartU();
reverbVolume = buffer.readSmartU();
length = buffer.read16U();
start = buffer.read16U();
length = buffer.read16U();
start = buffer.read16U();
filter = new SoundFilter();
filterRange = new SoundEnvelope();
filter.read(buffer, filterRange);
}
filter = new SoundFilter();
filterRange = new SoundEnvelope();
filter.read(buffer, filterRange);
}
}
+141 -141
View File
@@ -1,172 +1,172 @@
public class SoundTrack {
public static final SoundTrack[] tracks = new SoundTrack[5000];
public static final int[] delays = new int[5000];
public static byte[] waveBytes = new byte[441000];
public static Buffer waveBuffer = new Buffer(waveBytes);
public static final SoundTrack[] tracks = new SoundTrack[5000];
public static final int[] delays = new int[5000];
public static byte[] waveBytes = new byte[441000];
public static Buffer waveBuffer = new Buffer(waveBytes);
public static void unpack(Buffer in) {
SoundTone.init();
public static void unpack(Buffer in) {
SoundTone.init();
do {
int id = in.read16U();
do {
int id = in.read16U();
if (id == 65535) {
return;
}
if (id == 65535) {
return;
}
tracks[id] = new SoundTrack();
tracks[id].read(in);
delays[id] = tracks[id].trim();
} while (true);
}
tracks[id] = new SoundTrack();
tracks[id].read(in);
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.getWave(loopCount);
} else {
return null;
}
}
public static Buffer generate(int loopCount, int id) {
if (tracks[id] != null) {
SoundTrack track = tracks[id];
return track.getWave(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.read8U() != 0) {
buffer.position--;
tones[tone] = new SoundTone();
tones[tone].read(buffer);
}
}
loopBegin = buffer.read16U();
loopEnd = buffer.read16U();
}
public void read(Buffer buffer) {
for (int tone = 0; tone < 10; tone++) {
if (buffer.read8U() != 0) {
buffer.position--;
tones[tone] = new SoundTone();
tones[tone].read(buffer);
}
}
loopBegin = buffer.read16U();
loopEnd = buffer.read16U();
}
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 getWave(int loopCount) {
int length = generate(loopCount);
waveBuffer.position = 0;
waveBuffer.write32(0x52494646); // "RIFF" ChunkID
waveBuffer.write32LE(36 + length); // ChunkSize
waveBuffer.write32(0x57415645); // "WAVE" format
waveBuffer.write32(0x666d7420); // "fmt " chunk id
waveBuffer.write32LE(16); // chunk size
waveBuffer.write16LE(1); // audio format
waveBuffer.write16LE(1); // num channels
waveBuffer.write32LE(22050); // sample rate
waveBuffer.write32LE(22050); // byte rate
waveBuffer.write16LE(1); // block align
waveBuffer.write16LE(8); // bits per sample
waveBuffer.write32(0x64617461); // "data"
waveBuffer.write32LE(length);
waveBuffer.position += length;
return waveBuffer;
}
/**
* <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 getWave(int loopCount) {
int length = generate(loopCount);
waveBuffer.position = 0;
waveBuffer.write32(0x52494646); // "RIFF" ChunkID
waveBuffer.write32LE(36 + length); // ChunkSize
waveBuffer.write32(0x57415645); // "WAVE" format
waveBuffer.write32(0x666d7420); // "fmt " chunk id
waveBuffer.write32LE(16); // chunk size
waveBuffer.write16LE(1); // audio format
waveBuffer.write16LE(1); // num channels
waveBuffer.write32LE(22050); // sample rate
waveBuffer.write32LE(22050); // byte rate
waveBuffer.write16LE(1); // block align
waveBuffer.write16LE(8); // bits per sample
waveBuffer.write32(0x64617461); // "data"
waveBuffer.write32LE(length);
waveBuffer.position += length;
return waveBuffer;
}
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++) {
waveBytes[sample] = -128;
}
for (int sample = 44; sample < (totalSampleCount + 44); sample++) {
waveBytes[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++) {
waveBytes[sample + start + 44] += (byte) (samples[sample] >> 8);
}
}
for (int sample = 0; sample < toneSampleCount; sample++) {
waveBytes[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--) {
waveBytes[sample + endOffset] = waveBytes[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--) {
waveBytes[sample + endOffset] = waveBytes[sample];
}
// Duplicates loop area.
for (int loop = 1; loop < loopCount; loop++) {
int offset = (loopStop - loopStart) * loop;
for (int sample = loopStart; sample < loopStop; sample++) {
waveBytes[sample + offset] = waveBytes[sample];
}
}
// Duplicates loop area.
for (int loop = 1; loop < loopCount; loop++) {
int offset = (loopStop - loopStart) * loop;
for (int sample = loopStart; sample < loopStop; sample++) {
waveBytes[sample + offset] = waveBytes[sample];
}
}
totalSampleCount -= 44;
}
return totalSampleCount;
}
totalSampleCount -= 44;
}
return totalSampleCount;
}
}
+62 -62
View File
@@ -4,76 +4,76 @@
public class SpotAnimEntity extends Entity {
public final int level;
public final int x;
public final int z;
public final int y;
public final int startCycle;
public final SpotAnimType type;
public boolean seqComplete = false;
public int seqFrame;
public int seqCycle;
public final int level;
public final int x;
public final int z;
public final int y;
public final int startCycle;
public final SpotAnimType type;
public boolean seqComplete = false;
public int seqFrame;
public int seqCycle;
public SpotAnimEntity(int level, int cycle, int delay, int id, int y, int z, int x) {
type = SpotAnimType.instances[id];
this.level = level;
this.x = x;
this.z = z;
this.y = y;
startCycle = cycle + delay;
}
public SpotAnimEntity(int level, int cycle, int delay, int id, int y, int z, int x) {
type = SpotAnimType.instances[id];
this.level = level;
this.x = x;
this.z = z;
this.y = y;
startCycle = cycle + delay;
}
@Override
public Model getModel() {
Model base = type.getModel();
@Override
public Model getModel() {
Model base = type.getModel();
if (base == null) {
return null;
}
if (base == null) {
return null;
}
int transformID = type.seq.transformIDs[seqFrame];
int transformID = type.seq.transformIDs[seqFrame];
Model model = new Model(true, SeqTransform.isNull(transformID), false, base);
Model model = new Model(true, SeqTransform.isNull(transformID), false, base);
if (!seqComplete) {
model.createLabelReferences();
model.applyTransform(transformID);
model.labelFaces = null;
model.labelVertices = null;
}
if (!seqComplete) {
model.createLabelReferences();
model.applyTransform(transformID);
model.labelFaces = null;
model.labelVertices = null;
}
if ((type.scaleXY != 128) || (type.scaleZ != 128)) {
model.scale(type.scaleXY, type.scaleXY, type.scaleZ);
}
if ((type.scaleXY != 128) || (type.scaleZ != 128)) {
model.scale(type.scaleXY, type.scaleXY, type.scaleZ);
}
if (type.rotation != 0) {
if (type.rotation == 90) {
model.rotateY90();
}
if (type.rotation == 180) {
model.rotateY90();
model.rotateY90();
}
if (type.rotation == 270) {
model.rotateY90();
model.rotateY90();
model.rotateY90();
}
}
model.calculateNormals(64 + type.lightAmbient, 850 + type.lightAttenuation, -30, -50, -30, true);
return model;
}
if (type.rotation != 0) {
if (type.rotation == 90) {
model.rotateY90();
}
if (type.rotation == 180) {
model.rotateY90();
model.rotateY90();
}
if (type.rotation == 270) {
model.rotateY90();
model.rotateY90();
model.rotateY90();
}
}
model.calculateNormals(64 + type.lightAmbient, 850 + type.lightAttenuation, -30, -50, -30, true);
return model;
}
public void update(int delta) {
for (seqCycle += delta; seqCycle > type.seq.getFrameDuration(seqFrame); ) {
seqCycle -= type.seq.getFrameDuration(seqFrame) + 1;
seqFrame++;
if (seqFrame >= type.seq.frameCount) {
seqFrame = 0;
seqComplete = true;
}
}
}
public void update(int delta) {
for (seqCycle += delta; seqCycle > type.seq.getFrameDuration(seqFrame); ) {
seqCycle -= type.seq.getFrameDuration(seqFrame) + 1;
seqFrame++;
if (seqFrame >= type.seq.frameCount) {
seqFrame = 0;
seqComplete = true;
}
}
}
}
+81 -80
View File
@@ -5,93 +5,94 @@ import java.util.Arrays;
*/
public class StringUtil {
private static final char[] BASE37_TABLE = { //
'_', //
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', //
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9' //
};
private static final char[] BASE37_TABLE = { //
'_', //
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', //
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9' //
};
public static long toBase37(String s) {
long l = 0L;
for (int i = 0; (i < s.length()) && (i < 12); i++) {
char c = s.charAt(i);
l *= 37L;
if ((c >= 'A') && (c <= 'Z')) {
l += (1 + c) - 'A';
} else if ((c >= 'a') && (c <= 'z')) {
l += (1 + c) - 'a';
} else if ((c >= '0') && (c <= '9')) {
l += (27 + c) - '0';
}
}
while (((l % 37L) == 0L) && (l != 0L)) {
l /= 37L;
}
return l;
}
public static long toBase37(String s) {
long l = 0L;
for (int i = 0; (i < s.length()) && (i < 12); i++) {
char c = s.charAt(i);
l *= 37L;
if ((c >= 'A') && (c <= 'Z')) {
l += (1 + c) - 'A';
} else if ((c >= 'a') && (c <= 'z')) {
l += (1 + c) - 'a';
} else if ((c >= '0') && (c <= '9')) {
l += (27 + c) - '0';
}
}
while (((l % 37L) == 0L) && (l != 0L)) {
l /= 37L;
}
return l;
}
public static String fromBase37(long value) {
if ((value <= 0L) || (value >= 0x5b5b57f8a98a5dd1L)/*37^12*/) {
return "invalid_name";
}
if ((value % 37L) == 0L) {
return "invalid_name";
}
int len = 0;
char[] tmp = new char[12];
while (value != 0L) {
long last = value;
value /= 37L;
tmp[11 - len++] = BASE37_TABLE[(int) (last - (value * 37L))];
}
return new String(tmp, 12 - len, len);
}
public static String fromBase37(long value) {
if ((value <= 0L) || (value >= 0x5b5b57f8a98a5dd1L)/*37^12*/) {
return "invalid_name";
}
if ((value % 37L) == 0L) {
return "invalid_name";
}
int len = 0;
char[] tmp = new char[12];
while (value != 0L) {
long last = value;
value /= 37L;
tmp[11 - len++] = BASE37_TABLE[(int) (last - (value * 37L))];
}
return new String(tmp, 12 - len, len);
}
public static long hashCode(String s) {
s = s.toUpperCase();
long hash = 0L;
for (int i = 0; i < s.length(); i++) {
hash = ((hash * 61L) + (long) s.charAt(i)) - 32L;
hash = (hash + (hash >> 56)) & 0xffffffffffffffL;
}
return hash;
}
public static long hashCode(String s) {
s = s.toUpperCase();
long hash = 0L;
for (int i = 0; i < s.length(); i++) {
hash = ((hash * 61L) + (long) s.charAt(i)) - 32L;
hash = (hash + (hash >> 56)) & 0xffffffffffffffL;
}
return hash;
}
public static String formatIPv4(int ipv4) {
return String.format("%d.%d.%d.%d", (ipv4 >> 24) & 0xff, (ipv4 >> 16) & 0xff, (ipv4 >> 8) & 0xff, ipv4 & 0xff);
}
public static String formatIPv4(int ipv4) {
return String.format("%d.%d.%d.%d", (ipv4 >> 24) & 0xff, (ipv4 >> 16) & 0xff, (ipv4 >> 8) & 0xff, ipv4 & 0xff);
}
public static String formatName(long name37) {
return formatName(fromBase37(name37));
}
public static String formatName(String s) {
if (s.length() > 0) {
char[] ac = s.toCharArray();
for (int j = 0; j < ac.length; j++) {
if (ac[j] == '_') {
ac[j] = ' ';
if (((j + 1) < ac.length) && (ac[j + 1] >= 'a') && (ac[j + 1] <= 'z')) {
ac[j + 1] = (char) ((ac[j + 1] + 'A') - 'a');
}
}
}
if ((ac[0] >= 'a') && (ac[0] <= 'z')) {
ac[0] = (char) ((ac[0] + 'A') - 'a');
}
return new String(ac);
} else {
return s;
}
}
public static String formatName(long name37) {
return formatName(fromBase37(name37));
}
public static String toAsterisks(String s) {
char[] chars = new char[s.length()];
Arrays.fill(chars, '*');
return new String(chars, 0, chars.length);
}
public static String formatName(String s) {
if (s.length() > 0) {
char[] ac = s.toCharArray();
for (int j = 0; j < ac.length; j++) {
if (ac[j] == '_') {
ac[j] = ' ';
if (((j + 1) < ac.length) && (ac[j + 1] >= 'a') && (ac[j + 1] <= 'z')) {
ac[j + 1] = (char) ((ac[j + 1] + 'A') - 'a');
}
}
}
if ((ac[0] >= 'a') && (ac[0] <= 'z')) {
ac[0] = (char) ((ac[0] + 'A') - 'a');
}
return new String(ac);
} else {
return s;
}
}
private StringUtil() {
public static String toAsterisks(String s) {
char[] chars = new char[s.length()];
Arrays.fill(chars, '*');
return new String(chars, 0, chars.length);
}
}
private StringUtil() {
}
}
+46 -46
View File
@@ -6,57 +6,57 @@ import java.io.IOException;
public class VarbitType {
public static VarbitType[] instances;
public static VarbitType[] instances;
public static void unpack(FileArchive archive) throws IOException {
Buffer buffer = new Buffer(archive.read("varbit.dat"));
int count = buffer.read16U();
public static void unpack(FileArchive archive) throws IOException {
Buffer buffer = new Buffer(archive.read("varbit.dat"));
int count = buffer.read16U();
if (instances == null) {
instances = new VarbitType[count];
}
if (instances == null) {
instances = new VarbitType[count];
}
for (int j = 0; j < count; j++) {
if (instances[j] == null) {
instances[j] = new VarbitType();
}
instances[j].read(buffer);
}
if (buffer.position != buffer.data.length) {
System.out.println("varbit load mismatch");
}
}
for (int j = 0; j < count; j++) {
if (instances[j] == null) {
instances[j] = new VarbitType();
}
instances[j].read(buffer);
}
if (buffer.position != buffer.data.length) {
System.out.println("varbit load mismatch");
}
}
public int varp;
/**
* The least significant bit.
*/
public int lsb;
/**
* The most significant bit.
*/
public int msb;
public int varp;
/**
* The least significant bit.
*/
public int lsb;
/**
* The most significant bit.
*/
public int msb;
public VarbitType() {
}
public VarbitType() {
}
public void read(Buffer buffer) {
do {
int code = buffer.read8U();
if (code == 0) {
return;
} else if (code == 1) {
varp = buffer.read16U();
lsb = buffer.read8U();
msb = buffer.read8U();
} else if (code == 10) {
buffer.readString();
} else if (code == 3 || code == 4) {
buffer.read32();
} else {
System.out.println("Error unrecognised varbit config code: " + code);
}
} while (true);
}
public void read(Buffer buffer) {
do {
int code = buffer.read8U();
if (code == 0) {
return;
} else if (code == 1) {
varp = buffer.read16U();
lsb = buffer.read8U();
msb = buffer.read8U();
} else if (code == 10) {
buffer.readString();
} else if (code == 3 || code == 4) {
buffer.read32();
} else {
System.out.println("Error unrecognised varbit config code: " + code);
}
} while (true);
}
}
+39 -39
View File
@@ -6,48 +6,48 @@ import java.io.IOException;
public class VarpType {
public static int count;
public static VarpType[] instances;
public static int count;
public static VarpType[] instances;
public static void unpack(FileArchive archive) throws IOException {
Buffer buffer = new Buffer(archive.read("varp.dat"));
count = buffer.read16U();
if (instances == null) {
instances = new VarpType[count];
}
for (int i = 0; i < count; i++) {
if (instances[i] == null) {
instances[i] = new VarpType();
}
instances[i].read(buffer);
}
if (buffer.position != buffer.data.length) {
System.out.println("varptype load mismatch");
}
}
public static void unpack(FileArchive archive) throws IOException {
Buffer buffer = new Buffer(archive.read("varp.dat"));
count = buffer.read16U();
if (instances == null) {
instances = new VarpType[count];
}
for (int i = 0; i < count; i++) {
if (instances[i] == null) {
instances[i] = new VarpType();
}
instances[i].read(buffer);
}
if (buffer.position != buffer.data.length) {
System.out.println("varptype load mismatch");
}
}
public int type;
public int type;
public VarpType() {
}
public VarpType() {
}
public void read(Buffer in) {
while (true) {
int code = in.read8U();
if (code == 0) {
return;
} else if (code == 1 || code == 2) {
in.read8U();
} else if (code == 5) {
type = in.read16U();
} else if (code == 7 || code == 12) {
in.read32();
} else if (code == 10) {
in.readString();
} else {
System.out.println("Error unrecognised varp config code: " + code);
}
}
}
public void read(Buffer in) {
while (true) {
int code = in.read8U();
if (code == 0) {
return;
} else if (code == 1 || code == 2) {
in.read8U();
} else if (code == 5) {
type = in.read16U();
} else if (code == 7 || code == 12) {
in.read32();
} else if (code == 10) {
in.readString();
} else {
System.out.println("Error unrecognised varp config code: " + code);
}
}
}
}
+6 -6
View File
@@ -4,12 +4,12 @@
public class VertexNormal {
public int x;
public int y;
public int z;
public int w;
public int x;
public int y;
public int z;
public int w;
public VertexNormal() {
}
public VertexNormal() {
}
}