Format
This commit is contained in:
1 parent
ed6390f148
commit
2e7e22aced
54 files changed
+9623
-9609
No files matched your search
+64
-64
@@ -13,79 +13,79 @@ import java.io.InputStream;
|
|||||||
*/
|
*/
|
||||||
public class BZip2 extends 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[])
|
* @see #decompress(byte[], int, int, byte[])
|
||||||
*/
|
*/
|
||||||
public static byte[] decompress(byte[] src) throws IOException {
|
public static byte[] decompress(byte[] src) throws IOException {
|
||||||
return decompress(src, 0, src.length, null);
|
return decompress(src, 0, src.length, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #decompress(byte[], int, int, byte[])
|
* @see #decompress(byte[], int, int, byte[])
|
||||||
*/
|
*/
|
||||||
public static byte[] decompress(byte[] src, int off, int len) throws IOException {
|
public static byte[] decompress(byte[] src, int off, int len) throws IOException {
|
||||||
return decompress(src, off, len, null);
|
return decompress(src, off, len, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decompresses the source.
|
* Decompresses the source.
|
||||||
*
|
*
|
||||||
* @param src the source data.
|
* @param src the source data.
|
||||||
* @param off the source offset.
|
* @param off the source offset.
|
||||||
* @param len the source length.
|
* @param len the source length.
|
||||||
* @param dst the destination or <code>null</code> to create a new one.
|
* @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.
|
* @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 {
|
public static byte[] decompress(byte[] src, int off, int len, byte[] dst) throws IOException {
|
||||||
ByteArrayOutputStream tmp = null;
|
ByteArrayOutputStream tmp = null;
|
||||||
|
|
||||||
if (dst == null) {
|
if (dst == null) {
|
||||||
tmp = new ByteArrayOutputStream();
|
tmp = new ByteArrayOutputStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
try (BZip2CompressorInputStream in = new BZip2CompressorInputStream(new BZip2(src, off, len))) {
|
try (BZip2CompressorInputStream in = new BZip2CompressorInputStream(new BZip2(src, off, len))) {
|
||||||
if (tmp != null) {
|
if (tmp != null) {
|
||||||
IOUtils.copy(in, tmp);
|
IOUtils.copy(in, tmp);
|
||||||
} else {
|
} else {
|
||||||
IOUtils.readFully(in, dst);
|
IOUtils.readFully(in, dst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmp != null) {
|
if (tmp != null) {
|
||||||
return tmp.toByteArray();
|
return tmp.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The input.
|
* The input.
|
||||||
*/
|
*/
|
||||||
private final ByteArrayInputStream in;
|
private final ByteArrayInputStream in;
|
||||||
/**
|
/**
|
||||||
* The position.
|
* The position.
|
||||||
*/
|
*/
|
||||||
private int position;
|
private int position;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new helper class to fool that silly compressor.
|
* Constructs a new helper class to fool that silly compressor.
|
||||||
*
|
*
|
||||||
* @param src the source.
|
* @param src the source.
|
||||||
* @param off the source offset.
|
* @param off the source offset.
|
||||||
* @param len the source length.
|
* @param len the source length.
|
||||||
*/
|
*/
|
||||||
private BZip2(byte[] src, int off, int len) {
|
private BZip2(byte[] src, int off, int len) {
|
||||||
this.in = new ByteArrayInputStream(src, off, len);
|
this.in = new ByteArrayInputStream(src, off, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read() throws IOException {
|
public int read() throws IOException {
|
||||||
if (position < 4) {
|
if (position < 4) {
|
||||||
return MAGIC[position++];
|
return MAGIC[position++];
|
||||||
}
|
}
|
||||||
return in.read();
|
return in.read();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+478
-478
File diff suppressed because it is too large.
Load diff
+265
-265
@@ -28,323 +28,323 @@ import java.nio.charset.StandardCharsets;
|
|||||||
*/
|
*/
|
||||||
public class Buffer extends DoublyLinkedList.Node {
|
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) {
|
public static Buffer create(int sizeType) {
|
||||||
Buffer buffer = new Buffer();
|
Buffer buffer = new Buffer();
|
||||||
buffer.position = 0;
|
buffer.position = 0;
|
||||||
|
|
||||||
if (sizeType == 0) {
|
if (sizeType == 0) {
|
||||||
buffer.data = new byte[100];
|
buffer.data = new byte[100];
|
||||||
} else if (sizeType == 1) {
|
} else if (sizeType == 1) {
|
||||||
buffer.data = new byte[5000];
|
buffer.data = new byte[5000];
|
||||||
} else {
|
} else {
|
||||||
buffer.data = new byte[30000];
|
buffer.data = new byte[30000];
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] data;
|
public byte[] data;
|
||||||
public int position;
|
public int position;
|
||||||
public int bitPosition;
|
public int bitPosition;
|
||||||
public ISAACRandom random;
|
public ISAACRandom random;
|
||||||
|
|
||||||
public Buffer() {
|
public Buffer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Buffer(byte[] src) {
|
public Buffer(byte[] src) {
|
||||||
data = src;
|
data = src;
|
||||||
position = 0;
|
position = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeOp(int i) {
|
public void writeOp(int i) {
|
||||||
data[position++] = (byte) (i + random.nextInt());
|
data[position++] = (byte) (i + random.nextInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeSize(int i) {
|
public void writeSize(int i) {
|
||||||
data[position - i - 1] = (byte) i;
|
data[position - i - 1] = (byte) i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write8(int i) {
|
public void write8(int i) {
|
||||||
data[position++] = (byte) i;
|
data[position++] = (byte) i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write8C(int i) {
|
public void write8C(int i) {
|
||||||
data[position++] = (byte) -i;
|
data[position++] = (byte) -i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write8S(int j) {
|
public void write8S(int j) {
|
||||||
data[position++] = (byte) (128 - j);
|
data[position++] = (byte) (128 - j);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write16(int i) {
|
public void write16(int i) {
|
||||||
data[position++] = (byte) (i >> 8);
|
data[position++] = (byte) (i >> 8);
|
||||||
data[position++] = (byte) i;
|
data[position++] = (byte) i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write16A(int j) {
|
public void write16A(int j) {
|
||||||
data[position++] = (byte) (j >> 8);
|
data[position++] = (byte) (j >> 8);
|
||||||
data[position++] = (byte) (j + 128);
|
data[position++] = (byte) (j + 128);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write16LE(int i) {
|
public void write16LE(int i) {
|
||||||
data[position++] = (byte) i;
|
data[position++] = (byte) i;
|
||||||
data[position++] = (byte) (i >> 8);
|
data[position++] = (byte) (i >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write16LEA(int j) {
|
public void write16LEA(int j) {
|
||||||
data[position++] = (byte) (j + 128);
|
data[position++] = (byte) (j + 128);
|
||||||
data[position++] = (byte) (j >> 8);
|
data[position++] = (byte) (j >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write24(int i) {
|
public void write24(int i) {
|
||||||
data[position++] = (byte) (i >> 16);
|
data[position++] = (byte) (i >> 16);
|
||||||
data[position++] = (byte) (i >> 8);
|
data[position++] = (byte) (i >> 8);
|
||||||
data[position++] = (byte) i;
|
data[position++] = (byte) i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write32(int i) {
|
public void write32(int i) {
|
||||||
data[position++] = (byte) (i >> 24);
|
data[position++] = (byte) (i >> 24);
|
||||||
data[position++] = (byte) (i >> 16);
|
data[position++] = (byte) (i >> 16);
|
||||||
data[position++] = (byte) (i >> 8);
|
data[position++] = (byte) (i >> 8);
|
||||||
data[position++] = (byte) i;
|
data[position++] = (byte) i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write32LE(int j) {
|
public void write32LE(int j) {
|
||||||
data[position++] = (byte) j;
|
data[position++] = (byte) j;
|
||||||
data[position++] = (byte) (j >> 8);
|
data[position++] = (byte) (j >> 8);
|
||||||
data[position++] = (byte) (j >> 16);
|
data[position++] = (byte) (j >> 16);
|
||||||
data[position++] = (byte) (j >> 24);
|
data[position++] = (byte) (j >> 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write64(long l) {
|
public void write64(long l) {
|
||||||
data[position++] = (byte) (int) (l >> 56);
|
data[position++] = (byte) (int) (l >> 56);
|
||||||
data[position++] = (byte) (int) (l >> 48);
|
data[position++] = (byte) (int) (l >> 48);
|
||||||
data[position++] = (byte) (int) (l >> 40);
|
data[position++] = (byte) (int) (l >> 40);
|
||||||
data[position++] = (byte) (int) (l >> 32);
|
data[position++] = (byte) (int) (l >> 32);
|
||||||
data[position++] = (byte) (int) (l >> 24);
|
data[position++] = (byte) (int) (l >> 24);
|
||||||
data[position++] = (byte) (int) (l >> 16);
|
data[position++] = (byte) (int) (l >> 16);
|
||||||
data[position++] = (byte) (int) (l >> 8);
|
data[position++] = (byte) (int) (l >> 8);
|
||||||
data[position++] = (byte) (int) l;
|
data[position++] = (byte) (int) l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeString(String s) {
|
public void writeString(String s) {
|
||||||
write(s.getBytes(StandardCharsets.ISO_8859_1));
|
write(s.getBytes(StandardCharsets.ISO_8859_1));
|
||||||
write8('\n');
|
write8('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(byte[] src, int off, int len) {
|
public void write(byte[] src, int off, int len) {
|
||||||
System.arraycopy(src, off, data, position, len);
|
System.arraycopy(src, off, data, position, len);
|
||||||
position += len;
|
position += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(byte[] src) {
|
public void write(byte[] src) {
|
||||||
write(src, 0, src.length);
|
write(src, 0, src.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeA(byte[] src, int off, int len) {
|
public void writeA(byte[] src, int off, int len) {
|
||||||
for (int i = (off + len) - 1; i >= off; i--) {
|
for (int i = (off + len) - 1; i >= off; i--) {
|
||||||
data[position++] = (byte) (src[i] + 128);
|
data[position++] = (byte) (src[i] + 128);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte read() {
|
public byte read() {
|
||||||
return data[position++];
|
return data[position++];
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte read8C() {
|
public byte read8C() {
|
||||||
return (byte) -data[position++];
|
return (byte) -data[position++];
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte read8S() {
|
public byte read8S() {
|
||||||
return (byte) (128 - data[position++]);
|
return (byte) (128 - data[position++]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read8U() {
|
public int read8U() {
|
||||||
return data[position++] & 0xff;
|
return data[position++] & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read8UA() {
|
public int read8UA() {
|
||||||
return (data[position++] - 128) & 0xff;
|
return (data[position++] - 128) & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read8UC() {
|
public int read8UC() {
|
||||||
return -data[position++] & 0xff;
|
return -data[position++] & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read8US() {
|
public int read8US() {
|
||||||
return (128 - data[position++]) & 0xff;
|
return (128 - data[position++]) & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a 1 or 2 byte varint which has the range [-16384...16383].
|
* Gets a 1 or 2 byte varint which has the range [-16384...16383].
|
||||||
*
|
*
|
||||||
* @return the value.
|
* @return the value.
|
||||||
*/
|
*/
|
||||||
public int readSmart() {
|
public int readSmart() {
|
||||||
int i = data[position] & 0xff;
|
int i = data[position] & 0xff;
|
||||||
if (i < 128) {
|
if (i < 128) {
|
||||||
return read8U() - 64;
|
return read8U() - 64;
|
||||||
} else {
|
} else {
|
||||||
return read16U() - 49152;
|
return read16U() - 49152;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a 1 or 2 byte varint which has the range [0...32768].
|
* Gets a 1 or 2 byte varint which has the range [0...32768].
|
||||||
*
|
*
|
||||||
* @return the value.
|
* @return the value.
|
||||||
*/
|
*/
|
||||||
public int readSmartU() {
|
public int readSmartU() {
|
||||||
int i = data[position] & 0xff;
|
int i = data[position] & 0xff;
|
||||||
if (i < 128) {
|
if (i < 128) {
|
||||||
return read8U();
|
return read8U();
|
||||||
} else {
|
} else {
|
||||||
return read16U() - 32768;
|
return read16U() - 32768;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read16U() {
|
public int read16U() {
|
||||||
position += 2;
|
position += 2;
|
||||||
return ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
|
return ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read16UA() {
|
public int read16UA() {
|
||||||
position += 2;
|
position += 2;
|
||||||
return ((data[position - 2] & 0xff) << 8) + ((data[position - 1] - 128) & 0xff);
|
return ((data[position - 2] & 0xff) << 8) + ((data[position - 1] - 128) & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read16ULE() {
|
public int read16ULE() {
|
||||||
position += 2;
|
position += 2;
|
||||||
return ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
|
return ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read16ULEA() {
|
public int read16ULEA() {
|
||||||
position += 2;
|
position += 2;
|
||||||
return ((data[position - 1] & 0xff) << 8) + ((data[position - 2] - 128) & 0xff);
|
return ((data[position - 1] & 0xff) << 8) + ((data[position - 2] - 128) & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read16() {
|
public int read16() {
|
||||||
position += 2;
|
position += 2;
|
||||||
int i = ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
|
int i = ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
|
||||||
if (i > 32767) {
|
if (i > 32767) {
|
||||||
i -= 0x10000;
|
i -= 0x10000;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read16LE() {
|
public int read16LE() {
|
||||||
position += 2;
|
position += 2;
|
||||||
int j = ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
|
int j = ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
|
||||||
if (j > 0x7fff) {
|
if (j > 0x7fff) {
|
||||||
j -= 0x10000;
|
j -= 0x10000;
|
||||||
}
|
}
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read16LEA() {
|
public int read16LEA() {
|
||||||
position += 2;
|
position += 2;
|
||||||
int j = ((data[position - 1] & 0xff) << 8) + ((data[position - 2] - 128) & 0xff);
|
int j = ((data[position - 1] & 0xff) << 8) + ((data[position - 2] - 128) & 0xff);
|
||||||
if (j > 0x7fff) {
|
if (j > 0x7fff) {
|
||||||
j -= 0x10000;
|
j -= 0x10000;
|
||||||
}
|
}
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read24() {
|
public int read24() {
|
||||||
position += 3;
|
position += 3;
|
||||||
return ((data[position - 3] & 0xff) << 16) + ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
|
return ((data[position - 3] & 0xff) << 16) + ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read32() {
|
public int read32() {
|
||||||
position += 4;
|
position += 4;
|
||||||
return ((data[position - 4] & 0xff) << 24) + ((data[position - 3] & 0xff) << 16) + ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
|
return ((data[position - 4] & 0xff) << 24) + ((data[position - 3] & 0xff) << 16) + ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read32ME() {
|
public int read32ME() {
|
||||||
position += 4;
|
position += 4;
|
||||||
return ((data[position - 3] & 0xff) << 24) + ((data[position - 4] & 0xff) << 16) + ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
|
return ((data[position - 3] & 0xff) << 24) + ((data[position - 4] & 0xff) << 16) + ((data[position - 1] & 0xff) << 8) + (data[position - 2] & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read32RME() {
|
public int read32RME() {
|
||||||
position += 4;
|
position += 4;
|
||||||
return ((data[position - 2] & 0xff) << 24) + ((data[position - 1] & 0xff) << 16) + ((data[position - 4] & 0xff) << 8) + (data[position - 3] & 0xff);
|
return ((data[position - 2] & 0xff) << 24) + ((data[position - 1] & 0xff) << 16) + ((data[position - 4] & 0xff) << 8) + (data[position - 3] & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long read64() {
|
public long read64() {
|
||||||
long l = (long) read32() & 0xffffffffL;
|
long l = (long) read32() & 0xffffffffL;
|
||||||
long l1 = (long) read32() & 0xffffffffL;
|
long l1 = (long) read32() & 0xffffffffL;
|
||||||
return (l << 32) + l1;
|
return (l << 32) + l1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String readString() {
|
public String readString() {
|
||||||
int start = position;
|
int start = position;
|
||||||
while (data[position++] != '\n') {
|
while (data[position++] != '\n') {
|
||||||
}
|
}
|
||||||
return new String(data, start, position - start - 1);
|
return new String(data, start, position - start - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] readStringRaw() {
|
public byte[] readStringRaw() {
|
||||||
int start = position;
|
int start = position;
|
||||||
while (data[position++] != '\n') {
|
while (data[position++] != '\n') {
|
||||||
}
|
}
|
||||||
byte[] raw = new byte[position - start - 1];
|
byte[] raw = new byte[position - start - 1];
|
||||||
for (int j = start; j < (position - 1); j++) {
|
for (int j = start; j < (position - 1); j++) {
|
||||||
raw[j - start] = data[j];
|
raw[j - start] = data[j];
|
||||||
}
|
}
|
||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(byte[] dst, int off, int len) {
|
public void read(byte[] dst, int off, int len) {
|
||||||
System.arraycopy(data, position, dst, off, len);
|
System.arraycopy(data, position, dst, off, len);
|
||||||
position += len;
|
position += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(byte[] dst) {
|
public void read(byte[] dst) {
|
||||||
read(dst,0,dst.length);
|
read(dst, 0, dst.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readReversed(byte[] dst, int off, int len) {
|
public void readReversed(byte[] dst, int off, int len) {
|
||||||
for (int i = (off + len) - 1; i >= off; i--) {
|
for (int i = (off + len) - 1; i >= off; i--) {
|
||||||
dst[i] = data[position++];
|
dst[i] = data[position++];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void accessBits() {
|
public void accessBits() {
|
||||||
bitPosition = position * 8;
|
bitPosition = position * 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int readN(int n) {
|
public int readN(int n) {
|
||||||
int bytePos = bitPosition >> 3;
|
int bytePos = bitPosition >> 3;
|
||||||
int remaining = 8 - (bitPosition & 7);
|
int remaining = 8 - (bitPosition & 7);
|
||||||
int value = 0;
|
int value = 0;
|
||||||
bitPosition += n;
|
bitPosition += n;
|
||||||
for (; n > remaining; remaining = 8) {
|
for (; n > remaining; remaining = 8) {
|
||||||
value += (data[bytePos++] & BITMASK[remaining]) << (n - remaining);
|
value += (data[bytePos++] & BITMASK[remaining]) << (n - remaining);
|
||||||
n -= remaining;
|
n -= remaining;
|
||||||
}
|
}
|
||||||
if (n == remaining) {
|
if (n == remaining) {
|
||||||
value += data[bytePos] & BITMASK[remaining];
|
value += data[bytePos] & BITMASK[remaining];
|
||||||
} else {
|
} else {
|
||||||
value += (data[bytePos] >> (remaining - n)) & BITMASK[n];
|
value += (data[bytePos] >> (remaining - n)) & BITMASK[n];
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void accessBytes() {
|
public void accessBytes() {
|
||||||
position = (bitPosition + 7) / 8;
|
position = (bitPosition + 7) / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void encrypt(BigInteger exponent, BigInteger modulus) {
|
public void encrypt(BigInteger exponent, BigInteger modulus) {
|
||||||
int length = position;
|
int length = position;
|
||||||
position = 0;
|
position = 0;
|
||||||
byte[] raw = new byte[length];
|
byte[] raw = new byte[length];
|
||||||
read(raw, 0, length);
|
read(raw, 0, length);
|
||||||
byte[] encrypted = new BigInteger(raw).modPow(exponent, modulus).toByteArray();
|
byte[] encrypted = new BigInteger(raw).modPow(exponent, modulus).toByteArray();
|
||||||
position = 0;
|
position = 0;
|
||||||
write8(encrypted.length);
|
write8(encrypted.length);
|
||||||
write(encrypted, 0, encrypted.length);
|
write(encrypted, 0, encrypted.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+890
-890
File diff suppressed because it is too large.
Load diff
@@ -79,19 +79,19 @@ public class CollisionMap {
|
|||||||
}
|
}
|
||||||
} else if (type == 2) {
|
} else if (type == 2) {
|
||||||
if (rotation == 0) {
|
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 - 1, z, FLAG_BLOCK_ENTITY_E);
|
||||||
add(x, z + 1, FLAG_BLOCK_ENTITY_S);
|
add(x, z + 1, FLAG_BLOCK_ENTITY_S);
|
||||||
} else if (rotation == 1) {
|
} 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, z + 1, FLAG_BLOCK_ENTITY_S);
|
||||||
add(x + 1, z, FLAG_BLOCK_ENTITY_W);
|
add(x + 1, z, FLAG_BLOCK_ENTITY_W);
|
||||||
} else if (rotation == 2) {
|
} 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 + 1, z, FLAG_BLOCK_ENTITY_W);
|
||||||
add(x, z - 1, FLAG_BLOCK_ENTITY_N);
|
add(x, z - 1, FLAG_BLOCK_ENTITY_N);
|
||||||
} else if (rotation == 3) {
|
} 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, z - 1, FLAG_BLOCK_ENTITY_N);
|
||||||
add(x - 1, z, FLAG_BLOCK_ENTITY_E);
|
add(x - 1, z, FLAG_BLOCK_ENTITY_E);
|
||||||
}
|
}
|
||||||
@@ -128,19 +128,19 @@ public class CollisionMap {
|
|||||||
}
|
}
|
||||||
} else if (type == 2) {
|
} else if (type == 2) {
|
||||||
if (rotation == 0) {
|
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 - 1, z, FLAG_BLOCK_PROJECTILE_E);
|
||||||
add(x, z + 1, FLAG_BLOCK_PROJECTILE_S);
|
add(x, z + 1, FLAG_BLOCK_PROJECTILE_S);
|
||||||
} else if (rotation == 1) {
|
} 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, z + 1, FLAG_BLOCK_PROJECTILE_S);
|
||||||
add(x + 1, z, FLAG_BLOCK_PROJECTILE_W);
|
add(x + 1, z, FLAG_BLOCK_PROJECTILE_W);
|
||||||
} else if (rotation == 2) {
|
} 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 + 1, z, FLAG_BLOCK_PROJECTILE_W);
|
||||||
add(x, z - 1, FLAG_BLOCK_PROJECTILE_N);
|
add(x, z - 1, FLAG_BLOCK_PROJECTILE_N);
|
||||||
} else if (rotation == 3) {
|
} 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, z - 1, FLAG_BLOCK_PROJECTILE_N);
|
||||||
add(x - 1, z, FLAG_BLOCK_PROJECTILE_E);
|
add(x - 1, z, FLAG_BLOCK_PROJECTILE_E);
|
||||||
}
|
}
|
||||||
@@ -211,19 +211,19 @@ public class CollisionMap {
|
|||||||
}
|
}
|
||||||
} else if (type == 2) {
|
} else if (type == 2) {
|
||||||
if (rotation == 0) {
|
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 - 1, z, FLAG_BLOCK_ENTITY_E);
|
||||||
remove(x, z + 1, FLAG_BLOCK_ENTITY_S);
|
remove(x, z + 1, FLAG_BLOCK_ENTITY_S);
|
||||||
} else if (rotation == 1) {
|
} 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, z + 1, FLAG_BLOCK_ENTITY_S);
|
||||||
remove(x + 1, z, FLAG_BLOCK_ENTITY_W);
|
remove(x + 1, z, FLAG_BLOCK_ENTITY_W);
|
||||||
} else if (rotation == 2) {
|
} 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 + 1, z, FLAG_BLOCK_ENTITY_W);
|
||||||
remove(x, z - 1, FLAG_BLOCK_ENTITY_N);
|
remove(x, z - 1, FLAG_BLOCK_ENTITY_N);
|
||||||
} else if (rotation == 3) {
|
} 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, z - 1, FLAG_BLOCK_ENTITY_N);
|
||||||
remove(x - 1, z, FLAG_BLOCK_ENTITY_E);
|
remove(x - 1, z, FLAG_BLOCK_ENTITY_E);
|
||||||
}
|
}
|
||||||
@@ -259,19 +259,19 @@ public class CollisionMap {
|
|||||||
}
|
}
|
||||||
} else if (type == 2) {
|
} else if (type == 2) {
|
||||||
if (rotation == 0) {
|
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 - 1, z, FLAG_BLOCK_PROJECTILE_E);
|
||||||
remove(x, z + 1, FLAG_BLOCK_PROJECTILE_S);
|
remove(x, z + 1, FLAG_BLOCK_PROJECTILE_S);
|
||||||
} else if (rotation == 1) {
|
} 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, z + 1, FLAG_BLOCK_PROJECTILE_S);
|
||||||
remove(x + 1, z, FLAG_BLOCK_PROJECTILE_W);
|
remove(x + 1, z, FLAG_BLOCK_PROJECTILE_W);
|
||||||
} else if (rotation == 2) {
|
} 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 + 1, z, FLAG_BLOCK_PROJECTILE_W);
|
||||||
remove(x, z - 1, FLAG_BLOCK_PROJECTILE_N);
|
remove(x, z - 1, FLAG_BLOCK_PROJECTILE_N);
|
||||||
} else if (rotation == 3) {
|
} 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, z - 1, FLAG_BLOCK_PROJECTILE_N);
|
||||||
remove(x - 1, z, FLAG_BLOCK_PROJECTILE_E);
|
remove(x - 1, z, FLAG_BLOCK_PROJECTILE_E);
|
||||||
}
|
}
|
||||||
|
|||||||
+142
-142
@@ -9,155 +9,155 @@ import java.net.Socket;
|
|||||||
|
|
||||||
public class Connection implements Runnable {
|
public class Connection implements Runnable {
|
||||||
|
|
||||||
public final Socket socket;
|
public final Socket socket;
|
||||||
public final GameShell shell;
|
public final GameShell shell;
|
||||||
public InputStream in;
|
public InputStream in;
|
||||||
public OutputStream out;
|
public OutputStream out;
|
||||||
public boolean closed = false;
|
public boolean closed = false;
|
||||||
public byte[] buf;
|
public byte[] buf;
|
||||||
public int tcycl;
|
public int tcycl;
|
||||||
public int tnum;
|
public int tnum;
|
||||||
public boolean writer = false;
|
public boolean writer = false;
|
||||||
public boolean ioerror = false;
|
public boolean ioerror = false;
|
||||||
|
|
||||||
public Connection(GameShell shell, Socket socket) throws IOException {
|
public Connection(GameShell shell, Socket socket) throws IOException {
|
||||||
this.shell = shell;
|
this.shell = shell;
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
this.socket.setSoTimeout(30000);
|
this.socket.setSoTimeout(30000);
|
||||||
this.socket.setTcpNoDelay(true);
|
this.socket.setTcpNoDelay(true);
|
||||||
in = this.socket.getInputStream();
|
in = this.socket.getInputStream();
|
||||||
out = this.socket.getOutputStream();
|
out = this.socket.getOutputStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
closed = true;
|
closed = true;
|
||||||
try {
|
try {
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
if (out != null) {
|
if (out != null) {
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
if (socket != null) {
|
if (socket != null) {
|
||||||
socket.close();
|
socket.close();
|
||||||
}
|
}
|
||||||
} catch (IOException _ex) {
|
} catch (IOException _ex) {
|
||||||
System.out.println("Error closing stream");
|
System.out.println("Error closing stream");
|
||||||
}
|
}
|
||||||
writer = false;
|
writer = false;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
notify();
|
notify();
|
||||||
}
|
}
|
||||||
buf = null;
|
buf = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read() throws IOException {
|
public int read() throws IOException {
|
||||||
if (closed) {
|
if (closed) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return in.read();
|
return in.read();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int available() throws IOException {
|
public int available() throws IOException {
|
||||||
if (closed) {
|
if (closed) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return in.available();
|
return in.available();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(byte[] dst, int off, int len) throws IOException {
|
public void read(byte[] dst, int off, int len) throws IOException {
|
||||||
if (closed) {
|
if (closed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int k;
|
int k;
|
||||||
for (; len > 0; len -= k) {
|
for (; len > 0; len -= k) {
|
||||||
k = in.read(dst, off, len);
|
k = in.read(dst, off, len);
|
||||||
if (k <= 0) {
|
if (k <= 0) {
|
||||||
throw new IOException("EOF");
|
throw new IOException("EOF");
|
||||||
}
|
}
|
||||||
off += k;
|
off += k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(byte[] src, int off, int len) throws IOException {
|
public void write(byte[] src, int off, int len) throws IOException {
|
||||||
if (closed) {
|
if (closed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ioerror) {
|
if (ioerror) {
|
||||||
ioerror = false;
|
ioerror = false;
|
||||||
throw new IOException("Error in writer thread");
|
throw new IOException("Error in writer thread");
|
||||||
}
|
}
|
||||||
if (buf == null) {
|
if (buf == null) {
|
||||||
buf = new byte[5000];
|
buf = new byte[5000];
|
||||||
}
|
}
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
buf[tnum] = src[i + off];
|
buf[tnum] = src[i + off];
|
||||||
tnum = (tnum + 1) % 5000;
|
tnum = (tnum + 1) % 5000;
|
||||||
if (tnum == ((tcycl + 4900) % 5000)) {
|
if (tnum == ((tcycl + 4900) % 5000)) {
|
||||||
throw new IOException("buffer overflow");
|
throw new IOException("buffer overflow");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!writer) {
|
if (!writer) {
|
||||||
writer = true;
|
writer = true;
|
||||||
shell.startThread(this, 3);
|
shell.startThread(this, 3);
|
||||||
}
|
}
|
||||||
notify();
|
notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (writer) {
|
while (writer) {
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (tnum == tcycl) {
|
if (tnum == tcycl) {
|
||||||
try {
|
try {
|
||||||
wait();
|
wait();
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!writer) {
|
if (!writer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
j = tcycl;
|
j = tcycl;
|
||||||
if (tnum >= tcycl) {
|
if (tnum >= tcycl) {
|
||||||
i = tnum - tcycl;
|
i = tnum - tcycl;
|
||||||
} else {
|
} else {
|
||||||
i = 5000 - tcycl;
|
i = 5000 - tcycl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
try {
|
try {
|
||||||
out.write(buf, j, i);
|
out.write(buf, j, i);
|
||||||
} catch (IOException _ex) {
|
} catch (IOException _ex) {
|
||||||
ioerror = true;
|
ioerror = true;
|
||||||
}
|
}
|
||||||
tcycl = (tcycl + i) % 5000;
|
tcycl = (tcycl + i) % 5000;
|
||||||
try {
|
try {
|
||||||
if (tnum == tcycl) {
|
if (tnum == tcycl) {
|
||||||
out.flush();
|
out.flush();
|
||||||
}
|
}
|
||||||
} catch (IOException _ex) {
|
} catch (IOException _ex) {
|
||||||
ioerror = true;
|
ioerror = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void debug() {
|
public void debug() {
|
||||||
System.out.println("closed:" + closed);
|
System.out.println("closed:" + closed);
|
||||||
System.out.println("tcycl:" + tcycl);
|
System.out.println("tcycl:" + tcycl);
|
||||||
System.out.println("tnum:" + tnum);
|
System.out.println("tnum:" + tnum);
|
||||||
System.out.println("writer:" + writer);
|
System.out.println("writer:" + writer);
|
||||||
System.out.println("ioerror:" + ioerror);
|
System.out.println("ioerror:" + ioerror);
|
||||||
try {
|
try {
|
||||||
System.out.println("available:" + available());
|
System.out.println("available:" + available());
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,114 +1,114 @@
|
|||||||
public class DoublyLinkedList {
|
public class DoublyLinkedList {
|
||||||
|
|
||||||
public static class Node {
|
public static class Node {
|
||||||
|
|
||||||
public Node prev;
|
public Node prev;
|
||||||
public Node next;
|
public Node next;
|
||||||
|
|
||||||
public void unlink() {
|
public void unlink() {
|
||||||
if (next != null) {
|
if (next != null) {
|
||||||
next.prev = prev;
|
next.prev = prev;
|
||||||
prev.next = next;
|
prev.next = next;
|
||||||
prev = null;
|
prev = null;
|
||||||
next = null;
|
next = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Node head;
|
public final Node head;
|
||||||
public Node peeked;
|
public Node peeked;
|
||||||
|
|
||||||
public DoublyLinkedList() {
|
public DoublyLinkedList() {
|
||||||
head = new Node();
|
head = new Node();
|
||||||
head.prev = head;
|
head.prev = head;
|
||||||
head.next = head;
|
head.next = head;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pushBack(Node node) {
|
public void pushBack(Node node) {
|
||||||
if (node.next != null) {
|
if (node.next != null) {
|
||||||
node.unlink();
|
node.unlink();
|
||||||
}
|
}
|
||||||
node.next = head.next;
|
node.next = head.next;
|
||||||
node.prev = head;
|
node.prev = head;
|
||||||
node.next.prev = node;
|
node.next.prev = node;
|
||||||
node.prev.next = node;
|
node.prev.next = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pushFront(Node node) {
|
public void pushFront(Node node) {
|
||||||
if (node.next != null) {
|
if (node.next != null) {
|
||||||
node.unlink();
|
node.unlink();
|
||||||
}
|
}
|
||||||
node.next = head;
|
node.next = head;
|
||||||
node.prev = head.prev;
|
node.prev = head.prev;
|
||||||
node.next.prev = node;
|
node.next.prev = node;
|
||||||
node.prev.next = node;
|
node.prev.next = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node pollFront() {
|
public Node pollFront() {
|
||||||
Node node = head.prev;
|
Node node = head.prev;
|
||||||
if (node == head) {
|
if (node == head) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
node.unlink();
|
node.unlink();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node peekFront() {
|
public Node peekFront() {
|
||||||
Node node = head.prev;
|
Node node = head.prev;
|
||||||
if (node == head) {
|
if (node == head) {
|
||||||
peeked = null;
|
peeked = null;
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
peeked = node.prev;
|
peeked = node.prev;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node peekBack() {
|
public Node peekBack() {
|
||||||
Node node = head.next;
|
Node node = head.next;
|
||||||
if (node == head) {
|
if (node == head) {
|
||||||
peeked = null;
|
peeked = null;
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
peeked = node.next;
|
peeked = node.next;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node prev() {
|
public Node prev() {
|
||||||
Node node = peeked;
|
Node node = peeked;
|
||||||
if (node == head) {
|
if (node == head) {
|
||||||
peeked = null;
|
peeked = null;
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
peeked = node.prev;
|
peeked = node.prev;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node next() {
|
public Node next() {
|
||||||
Node node = peeked;
|
Node node = peeked;
|
||||||
if (node == head) {
|
if (node == head) {
|
||||||
peeked = null;
|
peeked = null;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
peeked = node.next;
|
peeked = node.next;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
if (head.prev == head) {
|
if (head.prev == head) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
Node node = head.prev;
|
Node node = head.prev;
|
||||||
if (node == head) {
|
if (node == head) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
node.unlink();
|
node.unlink();
|
||||||
} while (true);
|
} while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+231
-230
@@ -2,286 +2,287 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
public class Draw2D {
|
public class Draw2D {
|
||||||
|
|
||||||
public static int[] pixels;
|
public static int[] pixels;
|
||||||
public static int width;
|
public static int width;
|
||||||
public static int height;
|
public static int height;
|
||||||
public static int top;
|
public static int top;
|
||||||
public static int bottom;
|
public static int bottom;
|
||||||
public static int left;
|
public static int left;
|
||||||
public static int right;
|
public static int right;
|
||||||
public static int boundX;
|
public static int boundX;
|
||||||
public static int centerX;
|
public static int centerX;
|
||||||
public static int centerY;
|
public static int centerY;
|
||||||
|
|
||||||
public static void bind(int[] pixels, int width, int height) {
|
public static void bind(int[] pixels, int width, int height) {
|
||||||
Draw2D.pixels = pixels;
|
Draw2D.pixels = pixels;
|
||||||
Draw2D.width = width;
|
Draw2D.width = width;
|
||||||
Draw2D.height = height;
|
Draw2D.height = height;
|
||||||
setBounds(0, 0, width, height);
|
setBounds(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void resetBounds() {
|
public static void resetBounds() {
|
||||||
left = 0;
|
left = 0;
|
||||||
top = 0;
|
top = 0;
|
||||||
right = width;
|
right = width;
|
||||||
bottom = height;
|
bottom = height;
|
||||||
boundX = right - 1;
|
boundX = right - 1;
|
||||||
centerX = right / 2;
|
centerX = right / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setBounds(int left, int top, int right, int bottom) {
|
public static void setBounds(int left, int top, int right, int bottom) {
|
||||||
if (left < 0) {
|
if (left < 0) {
|
||||||
left = 0;
|
left = 0;
|
||||||
}
|
}
|
||||||
if (top < 0) {
|
if (top < 0) {
|
||||||
top = 0;
|
top = 0;
|
||||||
}
|
}
|
||||||
if (right > width) {
|
if (right > width) {
|
||||||
right = width;
|
right = width;
|
||||||
}
|
}
|
||||||
if (bottom > height) {
|
if (bottom > height) {
|
||||||
bottom = height;
|
bottom = height;
|
||||||
}
|
}
|
||||||
Draw2D.left = left;
|
Draw2D.left = left;
|
||||||
Draw2D.top = top;
|
Draw2D.top = top;
|
||||||
Draw2D.right = right;
|
Draw2D.right = right;
|
||||||
Draw2D.bottom = bottom;
|
Draw2D.bottom = bottom;
|
||||||
boundX = Draw2D.right - 1;
|
boundX = Draw2D.right - 1;
|
||||||
centerX = Draw2D.right / 2;
|
centerX = Draw2D.right / 2;
|
||||||
centerY = Draw2D.bottom / 2;
|
centerY = Draw2D.bottom / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clear() {
|
public static void clear() {
|
||||||
Arrays.fill(pixels, 0);
|
Arrays.fill(pixels, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bresenham's line algorithm.
|
* Bresenham's line algorithm.
|
||||||
* @param x1 the first x coordinate.
|
*
|
||||||
* @param y1 the first y coordinate.
|
* @param x1 the first x coordinate.
|
||||||
* @param x2 the second x coordinate.
|
* @param y1 the first y coordinate.
|
||||||
* @param y2 the second y coordinate.
|
* @param x2 the second x coordinate.
|
||||||
* @param rgb the color.
|
* @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);
|
public static void drawLine(int x1, int y1, int x2, int y2, int rgb) {
|
||||||
int dy = Math.abs(y2 - y1);
|
int dx = Math.abs(x2 - x1);
|
||||||
|
int dy = Math.abs(y2 - y1);
|
||||||
|
|
||||||
int sx = (x1 < x2) ? 1 : -1;
|
int sx = (x1 < x2) ? 1 : -1;
|
||||||
int sy = (y1 < y2) ? 1 : -1;
|
int sy = (y1 < y2) ? 1 : -1;
|
||||||
|
|
||||||
int err = dx - dy;
|
int err = dx - dy;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if ((x1 >= left) && (x1 < right) && (y1 >= top) && (y1 < bottom)) {
|
if ((x1 >= left) && (x1 < right) && (y1 >= top) && (y1 < bottom)) {
|
||||||
pixels[x1 + (y1 * width)] = rgb;
|
pixels[x1 + (y1 * width)] = rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((x1 == x2) && (y1 == y2)) {
|
if ((x1 == x2) && (y1 == y2)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int e2 = 2 * err;
|
int e2 = 2 * err;
|
||||||
|
|
||||||
if (e2 > -dy) {
|
if (e2 > -dy) {
|
||||||
err = err - dy;
|
err = err - dy;
|
||||||
x1 = x1 + sx;
|
x1 = x1 + sx;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e2 < dx) {
|
if (e2 < dx) {
|
||||||
err = err + dx;
|
err = err + dx;
|
||||||
y1 = y1 + sy;
|
y1 = y1 + sy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void fillRect(int x, int y, int width, int height, int rgb, int alpha) {
|
public static void fillRect(int x, int y, int width, int height, int rgb, int alpha) {
|
||||||
if (x < left) {
|
if (x < left) {
|
||||||
width -= left - x;
|
width -= left - x;
|
||||||
x = left;
|
x = left;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y < top) {
|
if (y < top) {
|
||||||
height -= top - y;
|
height -= top - y;
|
||||||
y = top;
|
y = top;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((x + width) > right) {
|
if ((x + width) > right) {
|
||||||
width = right - x;
|
width = right - x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((y + height) > bottom) {
|
if ((y + height) > bottom) {
|
||||||
height = bottom - y;
|
height = bottom - y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int invAlpha = 256 - alpha;
|
int invAlpha = 256 - alpha;
|
||||||
int r0 = ((rgb >> 16) & 0xff) * alpha;
|
int r0 = ((rgb >> 16) & 0xff) * alpha;
|
||||||
int g0 = ((rgb >> 8) & 0xff) * alpha;
|
int g0 = ((rgb >> 8) & 0xff) * alpha;
|
||||||
int b0 = (rgb & 0xff) * alpha;
|
int b0 = (rgb & 0xff) * alpha;
|
||||||
|
|
||||||
int step = Draw2D.width - width;
|
int step = Draw2D.width - width;
|
||||||
int offset = x + (y * Draw2D.width);
|
int offset = x + (y * Draw2D.width);
|
||||||
|
|
||||||
for (int i = 0; i < height; i++) {
|
for (int i = 0; i < height; i++) {
|
||||||
for (int j = -width; j < 0; j++) {
|
for (int j = -width; j < 0; j++) {
|
||||||
int r1 = ((pixels[offset] >> 16) & 0xff) * invAlpha;
|
int r1 = ((pixels[offset] >> 16) & 0xff) * invAlpha;
|
||||||
int g1 = ((pixels[offset] >> 8) & 0xff) * invAlpha;
|
int g1 = ((pixels[offset] >> 8) & 0xff) * invAlpha;
|
||||||
int b1 = (pixels[offset] & 0xff) * invAlpha;
|
int b1 = (pixels[offset] & 0xff) * invAlpha;
|
||||||
pixels[offset++] = (((r0 + r1) >> 8) << 16) + (((g0 + g1) >> 8) << 8) + ((b0 + b1) >> 8);
|
pixels[offset++] = (((r0 + r1) >> 8) << 16) + (((g0 + g1) >> 8) << 8) + ((b0 + b1) >> 8);
|
||||||
}
|
}
|
||||||
offset += step;
|
offset += step;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void fillRect(int x, int y, int width, int height, int rgb) {
|
public static void fillRect(int x, int y, int width, int height, int rgb) {
|
||||||
if (x < left) {
|
if (x < left) {
|
||||||
width -= left - x;
|
width -= left - x;
|
||||||
x = left;
|
x = left;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y < top) {
|
if (y < top) {
|
||||||
height -= top - y;
|
height -= top - y;
|
||||||
y = top;
|
y = top;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((x + width) > right) {
|
if ((x + width) > right) {
|
||||||
width = right - x;
|
width = right - x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((y + height) > bottom) {
|
if ((y + height) > bottom) {
|
||||||
height = bottom - y;
|
height = bottom - y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int step = Draw2D.width - width;
|
int step = Draw2D.width - width;
|
||||||
int offset = x + (y * Draw2D.width);
|
int offset = x + (y * Draw2D.width);
|
||||||
|
|
||||||
for (int i = -height; i < 0; i++) {
|
for (int i = -height; i < 0; i++) {
|
||||||
for (int j = -width; j < 0; j++) {
|
for (int j = -width; j < 0; j++) {
|
||||||
pixels[offset++] = rgb;
|
pixels[offset++] = rgb;
|
||||||
}
|
}
|
||||||
offset += step;
|
offset += step;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawRect(int x, int y, int width, int height, int rgb) {
|
public static void drawRect(int x, int y, int width, int height, int rgb) {
|
||||||
drawLineX(x, y, width, rgb);
|
drawLineX(x, y, width, rgb);
|
||||||
drawLineX(x, (y + height) - 1, width, rgb);
|
drawLineX(x, (y + height) - 1, width, rgb);
|
||||||
drawLineY(x, y, height, rgb);
|
drawLineY(x, y, height, rgb);
|
||||||
drawLineY((x + width) - 1, 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) {
|
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, width, rgb, alpha);
|
||||||
drawLineX(x, (y + height) - 1, width, rgb, alpha);
|
drawLineX(x, (y + height) - 1, width, rgb, alpha);
|
||||||
if (height >= 3) {
|
if (height >= 3) {
|
||||||
drawLineY(rgb, x, alpha, y + 1, height - 2);
|
drawLineY(rgb, x, alpha, y + 1, height - 2);
|
||||||
drawLineY(rgb, (x + width) - 1, 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) {
|
public static void drawLineX(int x, int y, int length, int rgb) {
|
||||||
if ((y < top) || (y >= bottom)) {
|
if ((y < top) || (y >= bottom)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x < left) {
|
if (x < left) {
|
||||||
length -= left - x;
|
length -= left - x;
|
||||||
x = left;
|
x = left;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((x + length) > right) {
|
if ((x + length) > right) {
|
||||||
length = right - x;
|
length = right - x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int offset = x + (y * width);
|
int offset = x + (y * width);
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
pixels[offset + i] = rgb;
|
pixels[offset + i] = rgb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawLineX(int x, int y, int length, int rgb, int alpha) {
|
public static void drawLineX(int x, int y, int length, int rgb, int alpha) {
|
||||||
if ((y < top) || (y >= bottom)) {
|
if ((y < top) || (y >= bottom)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x < left) {
|
if (x < left) {
|
||||||
length -= left - x;
|
length -= left - x;
|
||||||
x = left;
|
x = left;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((x + length) > right) {
|
if ((x + length) > right) {
|
||||||
length = right - x;
|
length = right - x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int invAlpha = 256 - alpha;
|
int invAlpha = 256 - alpha;
|
||||||
int r0 = ((rgb >> 16) & 0xff) * alpha;
|
int r0 = ((rgb >> 16) & 0xff) * alpha;
|
||||||
int g0 = ((rgb >> 8) & 0xff) * alpha;
|
int g0 = ((rgb >> 8) & 0xff) * alpha;
|
||||||
int b0 = (rgb & 0xff) * alpha;
|
int b0 = (rgb & 0xff) * alpha;
|
||||||
|
|
||||||
int offset = x + (y * width);
|
int offset = x + (y * width);
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
int r1 = ((pixels[offset] >> 16) & 0xff) * invAlpha;
|
int r1 = ((pixels[offset] >> 16) & 0xff) * invAlpha;
|
||||||
int g1 = ((pixels[offset] >> 8) & 0xff) * invAlpha;
|
int g1 = ((pixels[offset] >> 8) & 0xff) * invAlpha;
|
||||||
int b1 = (pixels[offset] & 0xff) * invAlpha;
|
int b1 = (pixels[offset] & 0xff) * invAlpha;
|
||||||
pixels[offset++] = (((r0 + r1) >> 8) << 16) + (((g0 + g1) >> 8) << 8) + ((b0 + b1) >> 8);
|
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) {
|
public static void drawLineY(int x, int y, int length, int rgb) {
|
||||||
if ((x < left) || (x >= right)) {
|
if ((x < left) || (x >= right)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y < top) {
|
if (y < top) {
|
||||||
length -= top - y;
|
length -= top - y;
|
||||||
y = top;
|
y = top;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((y + length) > bottom) {
|
if ((y + length) > bottom) {
|
||||||
length = bottom - y;
|
length = bottom - y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int offset = x + (y * width);
|
int offset = x + (y * width);
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
pixels[offset + (i * width)] = rgb;
|
pixels[offset + (i * width)] = rgb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawLineY(int rgb, int x, int alpha, int y, int length) {
|
public static void drawLineY(int rgb, int x, int alpha, int y, int length) {
|
||||||
if ((x < left) || (x >= right)) {
|
if ((x < left) || (x >= right)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y < top) {
|
if (y < top) {
|
||||||
length -= top - y;
|
length -= top - y;
|
||||||
y = top;
|
y = top;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((y + length) > bottom) {
|
if ((y + length) > bottom) {
|
||||||
length = bottom - y;
|
length = bottom - y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int invAlpha = 256 - alpha;
|
int invAlpha = 256 - alpha;
|
||||||
int r0 = ((rgb >> 16) & 0xff) * alpha;
|
int r0 = ((rgb >> 16) & 0xff) * alpha;
|
||||||
int g0 = ((rgb >> 8) & 0xff) * alpha;
|
int g0 = ((rgb >> 8) & 0xff) * alpha;
|
||||||
int b0 = (rgb & 0xff) * alpha;
|
int b0 = (rgb & 0xff) * alpha;
|
||||||
|
|
||||||
int offset = x + (y * width);
|
int offset = x + (y * width);
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
int r1 = ((pixels[offset] >> 16) & 0xff) * invAlpha;
|
int r1 = ((pixels[offset] >> 16) & 0xff) * invAlpha;
|
||||||
int g1 = ((pixels[offset] >> 8) & 0xff) * invAlpha;
|
int g1 = ((pixels[offset] >> 8) & 0xff) * invAlpha;
|
||||||
int b1 = (pixels[offset] & 0xff) * invAlpha;
|
int b1 = (pixels[offset] & 0xff) * invAlpha;
|
||||||
pixels[offset] = (((r0 + r1) >> 8) << 16) + (((g0 + g1) >> 8) << 8) + ((b0 + b1) >> 8);
|
pixels[offset] = (((r0 + r1) >> 8) << 16) + (((g0 + g1) >> 8) << 8) + ((b0 + b1) >> 8);
|
||||||
offset += width;
|
offset += width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Draw2D() {
|
public Draw2D() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -405,7 +405,7 @@ public class Draw3D {
|
|||||||
/**
|
/**
|
||||||
* Returns the <code>rgb</code> with each component raised to the power of <code>gamma</code>
|
* 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.
|
* @param gamma the gamma.
|
||||||
* @return the result.
|
* @return the result.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+21
-21
@@ -8,30 +8,30 @@ import java.awt.image.DataBufferInt;
|
|||||||
|
|
||||||
public class DrawArea {
|
public class DrawArea {
|
||||||
|
|
||||||
public final int[] pixels;
|
public final int[] pixels;
|
||||||
public final int width;
|
public final int width;
|
||||||
public final int height;
|
public final int height;
|
||||||
public final BufferedImage image;
|
public final BufferedImage image;
|
||||||
|
|
||||||
public DrawArea(int width, int height) {
|
public DrawArea(int width, int height) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.image = new BufferedImage(this.width, this.height, BufferedImage.TYPE_INT_RGB);
|
this.image = new BufferedImage(this.width, this.height, BufferedImage.TYPE_INT_RGB);
|
||||||
this.pixels = ((DataBufferInt) this.image.getRaster().getDataBuffer()).getData();
|
this.pixels = ((DataBufferInt) this.image.getRaster().getDataBuffer()).getData();
|
||||||
bind();
|
bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrawArea(Image24 image) {
|
public DrawArea(Image24 image) {
|
||||||
this(image.width, image.height);
|
this(image.width, image.height);
|
||||||
image.blitOpaque(0, 0);
|
image.blitOpaque(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bind() {
|
public void bind() {
|
||||||
Draw2D.bind(pixels, width, height);
|
Draw2D.bind(pixels, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics g, int x, int y) {
|
public void draw(Graphics g, int x, int y) {
|
||||||
g.drawImage(image, x, y, null);
|
g.drawImage(image, x, y, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+14
-14
@@ -1,22 +1,22 @@
|
|||||||
public class Entity extends DoublyLinkedList.Node {
|
public class Entity extends DoublyLinkedList.Node {
|
||||||
|
|
||||||
public VertexNormal[] vertexNormal;
|
public VertexNormal[] vertexNormal;
|
||||||
public int minY = 1000;
|
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) {
|
public void draw(int yaw, int sinEyePitch, int cosEyePitch, int sinEyeYaw, int cosEyeYaw, int relativeX, int relativeY, int relativeZ, int bitset) {
|
||||||
Model model = getModel();
|
Model model = getModel();
|
||||||
|
|
||||||
if (model != null) {
|
if (model != null) {
|
||||||
minY = model.minY;
|
minY = model.minY;
|
||||||
model.draw(yaw, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, relativeX, relativeY, relativeZ, bitset);
|
model.draw(yaw, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, relativeX, relativeY, relativeZ, bitset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Model getModel() {
|
public Model getModel() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,83 +9,83 @@ import java.nio.file.Path;
|
|||||||
*/
|
*/
|
||||||
public class FileArchive {
|
public class FileArchive {
|
||||||
|
|
||||||
public byte[] data;
|
public byte[] data;
|
||||||
public int fileCount;
|
public int fileCount;
|
||||||
public int[] fileHash;
|
public int[] fileHash;
|
||||||
public int[] fileSizeInflated;
|
public int[] fileSizeInflated;
|
||||||
public int[] fileSizeDeflated;
|
public int[] fileSizeDeflated;
|
||||||
public int[] fileOffset;
|
public int[] fileOffset;
|
||||||
public boolean unpacked;
|
public boolean unpacked;
|
||||||
|
|
||||||
public FileArchive(byte[] src) throws IOException {
|
public FileArchive(byte[] src) throws IOException {
|
||||||
load(src);
|
load(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load(byte[] src) throws IOException {
|
public void load(byte[] src) throws IOException {
|
||||||
Buffer buffer = new Buffer(src);
|
Buffer buffer = new Buffer(src);
|
||||||
|
|
||||||
int unpackedSize = buffer.read24();
|
int unpackedSize = buffer.read24();
|
||||||
int packedSize = buffer.read24();
|
int packedSize = buffer.read24();
|
||||||
|
|
||||||
if (packedSize != unpackedSize) {
|
if (packedSize != unpackedSize) {
|
||||||
data = new byte[unpackedSize];
|
data = new byte[unpackedSize];
|
||||||
BZip2.decompress(src, 6, packedSize, data);
|
BZip2.decompress(src, 6, packedSize, data);
|
||||||
buffer = new Buffer(data);
|
buffer = new Buffer(data);
|
||||||
unpacked = true;
|
unpacked = true;
|
||||||
} else {
|
} else {
|
||||||
data = src;
|
data = src;
|
||||||
unpacked = false;
|
unpacked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileCount = buffer.read16U();
|
fileCount = buffer.read16U();
|
||||||
fileHash = new int[fileCount];
|
fileHash = new int[fileCount];
|
||||||
fileSizeInflated = new int[fileCount];
|
fileSizeInflated = new int[fileCount];
|
||||||
fileSizeDeflated = new int[fileCount];
|
fileSizeDeflated = new int[fileCount];
|
||||||
fileOffset = 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++) {
|
for (int file = 0; file < fileCount; file++) {
|
||||||
fileHash[file] = buffer.read32();
|
fileHash[file] = buffer.read32();
|
||||||
fileSizeInflated[file] = buffer.read24();
|
fileSizeInflated[file] = buffer.read24();
|
||||||
fileSizeDeflated[file] = buffer.read24();
|
fileSizeDeflated[file] = buffer.read24();
|
||||||
fileOffset[file] = offset;
|
fileOffset[file] = offset;
|
||||||
offset += fileSizeDeflated[file];
|
offset += fileSizeDeflated[file];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void export(String s, Path dst) throws IOException {
|
public void export(String s, Path dst) throws IOException {
|
||||||
byte[] data = read(s);
|
byte[] data = read(s);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
throw new FileNotFoundException(s);
|
throw new FileNotFoundException(s);
|
||||||
}
|
}
|
||||||
try (OutputStream out = Files.newOutputStream(dst)) {
|
try (OutputStream out = Files.newOutputStream(dst)) {
|
||||||
out.write(data);
|
out.write(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] read(String s) throws IOException {
|
public byte[] read(String s) throws IOException {
|
||||||
int hash = 0;
|
int hash = 0;
|
||||||
s = s.toUpperCase();
|
s = s.toUpperCase();
|
||||||
for (int j = 0; j < s.length(); j++) {
|
for (int j = 0; j < s.length(); j++) {
|
||||||
hash = ((hash * 61) + s.charAt(j)) - 32;
|
hash = ((hash * 61) + s.charAt(j)) - 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int file = 0; file < fileCount; file++) {
|
for (int file = 0; file < fileCount; file++) {
|
||||||
if (fileHash[file] != hash) {
|
if (fileHash[file] != hash) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] dst = new byte[fileSizeInflated[file]];
|
byte[] dst = new byte[fileSizeInflated[file]];
|
||||||
|
|
||||||
if (!unpacked) {
|
if (!unpacked) {
|
||||||
BZip2.decompress(data, fileOffset[file], fileSizeDeflated[file], dst);
|
BZip2.decompress(data, fileOffset[file], fileSizeDeflated[file], dst);
|
||||||
} else {
|
} else {
|
||||||
System.arraycopy(data, fileOffset[file], dst, 0, fileSizeInflated[file]);
|
System.arraycopy(data, fileOffset[file], dst, 0, fileSizeInflated[file]);
|
||||||
}
|
}
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+143
-143
@@ -7,186 +7,186 @@ import java.io.RandomAccessFile;
|
|||||||
|
|
||||||
public class FileStore {
|
public class FileStore {
|
||||||
|
|
||||||
public static final byte[] buf = new byte[520];
|
public static final byte[] buf = new byte[520];
|
||||||
public final RandomAccessFile dat;
|
public final RandomAccessFile dat;
|
||||||
public final RandomAccessFile idx;
|
public final RandomAccessFile idx;
|
||||||
public final int store;
|
public final int store;
|
||||||
public int maxFileSize;
|
public int maxFileSize;
|
||||||
|
|
||||||
public FileStore(int maxFileSize, RandomAccessFile dat, RandomAccessFile idx, int store) {
|
public FileStore(int maxFileSize, RandomAccessFile dat, RandomAccessFile idx, int store) {
|
||||||
this.maxFileSize = 65000;
|
this.maxFileSize = 65000;
|
||||||
this.store = store;
|
this.store = store;
|
||||||
this.dat = dat;
|
this.dat = dat;
|
||||||
this.idx = idx;
|
this.idx = idx;
|
||||||
this.maxFileSize = maxFileSize;
|
this.maxFileSize = maxFileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized long getFileCount() throws IOException {
|
public synchronized long getFileCount() throws IOException {
|
||||||
return idx.length() / 6L;
|
return idx.length() / 6L;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized byte[] read(int file) {
|
public synchronized byte[] read(int file) {
|
||||||
try {
|
try {
|
||||||
idx.seek(file * 6L);
|
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 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 sector = ((buf[3] & 0xff) << 16) + ((buf[4] & 0xff) << 8) + (buf[5] & 0xff);
|
||||||
|
|
||||||
if (size > maxFileSize) {
|
if (size > maxFileSize) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sector <= 0) || ((long) sector > (dat.length() / 520L))) {
|
if ((sector <= 0) || ((long) sector > (dat.length() / 520L))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] data = new byte[size];
|
byte[] data = new byte[size];
|
||||||
int position = 0;
|
int position = 0;
|
||||||
|
|
||||||
for (int part = 0; position < size; part++) {
|
for (int part = 0; position < size; part++) {
|
||||||
if (sector == 0) {
|
if (sector == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat.seek(sector * 520L);
|
dat.seek(sector * 520L);
|
||||||
|
|
||||||
int available = size - position;
|
int available = size - position;
|
||||||
|
|
||||||
if (available > 512) {
|
if (available > 512) {
|
||||||
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 sectorFile = ((buf[0] & 0xff) << 8) + (buf[1] & 0xff);
|
||||||
int sectorPart = ((buf[2] & 0xff) << 8) + (buf[3] & 0xff);
|
int sectorPart = ((buf[2] & 0xff) << 8) + (buf[3] & 0xff);
|
||||||
int nextSector = ((buf[4] & 0xff) << 16) + ((buf[5] & 0xff) << 8) + (buf[6] & 0xff);
|
int nextSector = ((buf[4] & 0xff) << 16) + ((buf[5] & 0xff) << 8) + (buf[6] & 0xff);
|
||||||
int sectorStore = buf[7] & 0xff;
|
int sectorStore = buf[7] & 0xff;
|
||||||
|
|
||||||
if ((sectorFile != file) || (sectorPart != part) || (sectorStore != store)) {
|
if ((sectorFile != file) || (sectorPart != part) || (sectorStore != store)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((nextSector < 0) || ((long) nextSector > (dat.length() / 520L))) {
|
if ((nextSector < 0) || ((long) nextSector > (dat.length() / 520L))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < available; i++) {
|
for (int i = 0; i < available; i++) {
|
||||||
data[position++] = buf[i + 8];
|
data[position++] = buf[i + 8];
|
||||||
}
|
}
|
||||||
|
|
||||||
sector = nextSector;
|
sector = nextSector;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void write(byte[] src, int file, int size) {
|
public synchronized void write(byte[] src, int file, int size) {
|
||||||
boolean written = write(src, file, size, true);
|
boolean written = write(src, file, size, true);
|
||||||
if (!written) {
|
if (!written) {
|
||||||
write(src, file, size, false);
|
write(src, file, size, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean write(byte[] data, int file, int size, boolean overwrite) {
|
public synchronized boolean write(byte[] data, int file, int size, boolean overwrite) {
|
||||||
try {
|
try {
|
||||||
int sector;
|
int sector;
|
||||||
|
|
||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
idx.seek(file * 6L);
|
idx.seek(file * 6L);
|
||||||
idx.read(buf, 0, 6);
|
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))) {
|
if ((sector <= 0) || ((long) sector > (dat.length() / 520L))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sector = (int) ((dat.length() + 519L) / 520L);
|
sector = (int) ((dat.length() + 519L) / 520L);
|
||||||
|
|
||||||
if (sector == 0) {
|
if (sector == 0) {
|
||||||
sector = 1;
|
sector = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[0] = (byte) (size >> 16);
|
buf[0] = (byte) (size >> 16);
|
||||||
buf[1] = (byte) (size >> 8);
|
buf[1] = (byte) (size >> 8);
|
||||||
buf[2] = (byte) size;
|
buf[2] = (byte) size;
|
||||||
buf[3] = (byte) (sector >> 16);
|
buf[3] = (byte) (sector >> 16);
|
||||||
buf[4] = (byte) (sector >> 8);
|
buf[4] = (byte) (sector >> 8);
|
||||||
buf[5] = (byte) sector;
|
buf[5] = (byte) sector;
|
||||||
|
|
||||||
idx.seek(file * 6L);
|
idx.seek(file * 6L);
|
||||||
idx.write(buf, 0, 6);
|
idx.write(buf, 0, 6);
|
||||||
|
|
||||||
int written = 0;
|
int written = 0;
|
||||||
for (int part = 0; written < size; part++) {
|
for (int part = 0; written < size; part++) {
|
||||||
int nextSector = 0;
|
int nextSector = 0;
|
||||||
|
|
||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
dat.seek(sector * 520L);
|
dat.seek(sector * 520L);
|
||||||
|
|
||||||
if (dat.read(buf, 0, 8) == 8) {
|
if (dat.read(buf, 0, 8) == 8) {
|
||||||
int sectorFile = ((buf[0] & 0xff) << 8) + (buf[1] & 0xff);
|
int sectorFile = ((buf[0] & 0xff) << 8) + (buf[1] & 0xff);
|
||||||
int sectorPart = ((buf[2] & 0xff) << 8) + (buf[3] & 0xff);
|
int sectorPart = ((buf[2] & 0xff) << 8) + (buf[3] & 0xff);
|
||||||
nextSector = ((buf[4] & 0xff) << 16) + ((buf[5] & 0xff) << 8) + (buf[6] & 0xff);
|
nextSector = ((buf[4] & 0xff) << 16) + ((buf[5] & 0xff) << 8) + (buf[6] & 0xff);
|
||||||
int sectorStore = buf[7] & 0xff;
|
int sectorStore = buf[7] & 0xff;
|
||||||
if ((sectorFile != file) || (sectorPart != part) || (sectorStore != store)) {
|
if ((sectorFile != file) || (sectorPart != part) || (sectorStore != store)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((nextSector < 0) || ((long) nextSector > (dat.length() / 520L))) {
|
if ((nextSector < 0) || ((long) nextSector > (dat.length() / 520L))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextSector == 0) {
|
if (nextSector == 0) {
|
||||||
overwrite = false;
|
overwrite = false;
|
||||||
nextSector = (int) ((dat.length() + 519L) / 520L);
|
nextSector = (int) ((dat.length() + 519L) / 520L);
|
||||||
|
|
||||||
if (nextSector == 0) {
|
if (nextSector == 0) {
|
||||||
nextSector++;
|
nextSector++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextSector == sector) {
|
if (nextSector == sector) {
|
||||||
nextSector++;
|
nextSector++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((size - written) <= 512) {
|
if ((size - written) <= 512) {
|
||||||
nextSector = 0;
|
nextSector = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[0] = (byte) (file >> 8);
|
buf[0] = (byte) (file >> 8);
|
||||||
buf[1] = (byte) file;
|
buf[1] = (byte) file;
|
||||||
buf[2] = (byte) (part >> 8);
|
buf[2] = (byte) (part >> 8);
|
||||||
buf[3] = (byte) part;
|
buf[3] = (byte) part;
|
||||||
buf[4] = (byte) (nextSector >> 16);
|
buf[4] = (byte) (nextSector >> 16);
|
||||||
buf[5] = (byte) (nextSector >> 8);
|
buf[5] = (byte) (nextSector >> 8);
|
||||||
buf[6] = (byte) nextSector;
|
buf[6] = (byte) nextSector;
|
||||||
buf[7] = (byte) store;
|
buf[7] = (byte) store;
|
||||||
|
|
||||||
dat.seek(sector * 520L);
|
dat.seek(sector * 520L);
|
||||||
dat.write(buf, 0, 8);
|
dat.write(buf, 0, 8);
|
||||||
|
|
||||||
int available = size - written;
|
int available = size - written;
|
||||||
|
|
||||||
if (available > 512) {
|
if (available > 512) {
|
||||||
available = 512;
|
available = 512;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat.write(data, written, available);
|
dat.write(data, written, available);
|
||||||
written += available;
|
written += available;
|
||||||
sector = nextSector;
|
sector = nextSector;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,18 +7,18 @@ import java.awt.*;
|
|||||||
|
|
||||||
public class GameFrame extends JFrame {
|
public class GameFrame extends JFrame {
|
||||||
|
|
||||||
public final GameShell shell;
|
public final GameShell shell;
|
||||||
|
|
||||||
public GameFrame(GameShell shell) {
|
public GameFrame(GameShell shell) {
|
||||||
this.shell = shell;
|
this.shell = shell;
|
||||||
setTitle("Jagex");
|
setTitle("Jagex");
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
add(shell, BorderLayout.CENTER);
|
add(shell, BorderLayout.CENTER);
|
||||||
pack();
|
pack();
|
||||||
setLocationRelativeTo(null);
|
setLocationRelativeTo(null);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
transferFocus();
|
transferFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+502
-502
File diff suppressed because it is too large.
Load diff
+448
-448
@@ -4,469 +4,469 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class Image24 extends DoublyLinkedList.Node {
|
public class Image24 extends DoublyLinkedList.Node {
|
||||||
|
|
||||||
public int[] pixels;
|
public int[] pixels;
|
||||||
public int width;
|
public int width;
|
||||||
public int height;
|
public int height;
|
||||||
public int cropX;
|
public int cropX;
|
||||||
public int cropY;
|
public int cropY;
|
||||||
public int cropW;
|
public int cropW;
|
||||||
public int cropH;
|
public int cropH;
|
||||||
|
|
||||||
public Image24(int i, int j) {
|
public Image24(int i, int j) {
|
||||||
pixels = new int[i * j];
|
pixels = new int[i * j];
|
||||||
width = cropW = i;
|
width = cropW = i;
|
||||||
height = cropH = j;
|
height = cropH = j;
|
||||||
cropX = cropY = 0;
|
cropX = cropY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Image24(byte[] src, java.awt.Component component) {
|
public Image24(byte[] src, java.awt.Component component) {
|
||||||
try {
|
try {
|
||||||
java.awt.Image image = Toolkit.getDefaultToolkit().createImage(src);
|
java.awt.Image image = Toolkit.getDefaultToolkit().createImage(src);
|
||||||
MediaTracker tracker = new MediaTracker(component);
|
MediaTracker tracker = new MediaTracker(component);
|
||||||
tracker.addImage(image, 0);
|
tracker.addImage(image, 0);
|
||||||
tracker.waitForAll();
|
tracker.waitForAll();
|
||||||
width = image.getWidth(component);
|
width = image.getWidth(component);
|
||||||
height = image.getHeight(component);
|
height = image.getHeight(component);
|
||||||
cropW = width;
|
cropW = width;
|
||||||
cropH = height;
|
cropH = height;
|
||||||
cropX = 0;
|
cropX = 0;
|
||||||
cropY = 0;
|
cropY = 0;
|
||||||
pixels = new int[width * height];
|
pixels = new int[width * height];
|
||||||
PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, width, height, pixels, 0, width);
|
PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, width, height, pixels, 0, width);
|
||||||
pixelgrabber.grabPixels();
|
pixelgrabber.grabPixels();
|
||||||
} catch (Exception _ex) {
|
} catch (Exception _ex) {
|
||||||
System.out.println("Error converting jpg");
|
System.out.println("Error converting jpg");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Image24(FileArchive archive, String file, int index) throws IOException {
|
public Image24(FileArchive archive, String file, int index) throws IOException {
|
||||||
Buffer dat = new Buffer(archive.read(file + ".dat"));
|
Buffer dat = new Buffer(archive.read(file + ".dat"));
|
||||||
Buffer idx = new Buffer(archive.read("index.dat"));
|
Buffer idx = new Buffer(archive.read("index.dat"));
|
||||||
idx.position = dat.read16U();
|
idx.position = dat.read16U();
|
||||||
cropW = idx.read16U();
|
cropW = idx.read16U();
|
||||||
cropH = idx.read16U();
|
cropH = idx.read16U();
|
||||||
int paletteSize = idx.read8U();
|
int paletteSize = idx.read8U();
|
||||||
int[] palette = new int[paletteSize];
|
int[] palette = new int[paletteSize];
|
||||||
for (int k = 0; k < (paletteSize - 1); k++) {
|
for (int k = 0; k < (paletteSize - 1); k++) {
|
||||||
palette[k + 1] = idx.read24();
|
palette[k + 1] = idx.read24();
|
||||||
if (palette[k + 1] == 0) {
|
if (palette[k + 1] == 0) {
|
||||||
palette[k + 1] = 1;
|
palette[k + 1] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < index; i++) {
|
for (int i = 0; i < index; i++) {
|
||||||
idx.position += 2;
|
idx.position += 2;
|
||||||
dat.position += idx.read16U() * idx.read16U();
|
dat.position += idx.read16U() * idx.read16U();
|
||||||
idx.position++;
|
idx.position++;
|
||||||
}
|
}
|
||||||
cropX = idx.read8U();
|
cropX = idx.read8U();
|
||||||
cropY = idx.read8U();
|
cropY = idx.read8U();
|
||||||
width = idx.read16U();
|
width = idx.read16U();
|
||||||
height = idx.read16U();
|
height = idx.read16U();
|
||||||
int layout = idx.read8U();
|
int layout = idx.read8U();
|
||||||
int pixelLen = width * height;
|
int pixelLen = width * height;
|
||||||
pixels = new int[pixelLen];
|
pixels = new int[pixelLen];
|
||||||
if (layout == 0) {
|
if (layout == 0) {
|
||||||
for (int i = 0; i < pixelLen; i++) {
|
for (int i = 0; i < pixelLen; i++) {
|
||||||
pixels[i] = palette[dat.read8U()];
|
pixels[i] = palette[dat.read8U()];
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (layout == 1) {
|
if (layout == 1) {
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
pixels[x + (y * width)] = palette[dat.read8U()];
|
pixels[x + (y * width)] = palette[dat.read8U()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bind() {
|
public void bind() {
|
||||||
Draw2D.bind(pixels, width, height);
|
Draw2D.bind(pixels, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void translate(int r, int g, int b) {
|
public void translate(int r, int g, int b) {
|
||||||
for (int i = 0; i < pixels.length; i++) {
|
for (int i = 0; i < pixels.length; i++) {
|
||||||
int rgb = pixels[i];
|
int rgb = pixels[i];
|
||||||
if (rgb != 0) {
|
if (rgb != 0) {
|
||||||
int red = (rgb >> 16) & 0xff;
|
int red = (rgb >> 16) & 0xff;
|
||||||
red += r;
|
red += r;
|
||||||
if (red < 1) {
|
if (red < 1) {
|
||||||
red = 1;
|
red = 1;
|
||||||
} else if (red > 255) {
|
} else if (red > 255) {
|
||||||
red = 255;
|
red = 255;
|
||||||
}
|
}
|
||||||
int green = (rgb >> 8) & 0xff;
|
int green = (rgb >> 8) & 0xff;
|
||||||
green += g;
|
green += g;
|
||||||
if (green < 1) {
|
if (green < 1) {
|
||||||
green = 1;
|
green = 1;
|
||||||
} else if (green > 255) {
|
} else if (green > 255) {
|
||||||
green = 255;
|
green = 255;
|
||||||
}
|
}
|
||||||
int blue = rgb & 0xff;
|
int blue = rgb & 0xff;
|
||||||
blue += b;
|
blue += b;
|
||||||
if (blue < 1) {
|
if (blue < 1) {
|
||||||
blue = 1;
|
blue = 1;
|
||||||
} else if (blue > 255) {
|
} else if (blue > 255) {
|
||||||
blue = 255;
|
blue = 255;
|
||||||
}
|
}
|
||||||
pixels[i] = (red << 16) + (green << 8) + blue;
|
pixels[i] = (red << 16) + (green << 8) + blue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void crop() {
|
public void crop() {
|
||||||
int[] pixels = new int[cropW * cropH];
|
int[] pixels = new int[cropW * cropH];
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
pixels[((y + cropY) * cropW) + x + cropX] = this.pixels[(y * width) + x];
|
pixels[((y + cropY) * cropW) + x + cropX] = this.pixels[(y * width) + x];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.pixels = pixels;
|
this.pixels = pixels;
|
||||||
width = cropW;
|
width = cropW;
|
||||||
height = cropH;
|
height = cropH;
|
||||||
cropX = 0;
|
cropX = 0;
|
||||||
cropY = 0;
|
cropY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void blitOpaque(int x, int y) {
|
public void blitOpaque(int x, int y) {
|
||||||
x += cropX;
|
x += cropX;
|
||||||
y += cropY;
|
y += cropY;
|
||||||
int dstOff = x + (y * Draw2D.width);
|
int dstOff = x + (y * Draw2D.width);
|
||||||
int srcOff = 0;
|
int srcOff = 0;
|
||||||
int h = height;
|
int h = height;
|
||||||
int w = width;
|
int w = width;
|
||||||
int dstStep = Draw2D.width - w;
|
int dstStep = Draw2D.width - w;
|
||||||
int srcStep = 0;
|
int srcStep = 0;
|
||||||
if (y < Draw2D.top) {
|
if (y < Draw2D.top) {
|
||||||
int trim = Draw2D.top - y;
|
int trim = Draw2D.top - y;
|
||||||
h -= trim;
|
h -= trim;
|
||||||
y = Draw2D.top;
|
y = Draw2D.top;
|
||||||
srcOff += trim * w;
|
srcOff += trim * w;
|
||||||
dstOff += trim * Draw2D.width;
|
dstOff += trim * Draw2D.width;
|
||||||
}
|
}
|
||||||
if ((y + h) > Draw2D.bottom) {
|
if ((y + h) > Draw2D.bottom) {
|
||||||
h -= (y + h) - Draw2D.bottom;
|
h -= (y + h) - Draw2D.bottom;
|
||||||
}
|
}
|
||||||
if (x < Draw2D.left) {
|
if (x < Draw2D.left) {
|
||||||
int trim = Draw2D.left - x;
|
int trim = Draw2D.left - x;
|
||||||
w -= trim;
|
w -= trim;
|
||||||
x = Draw2D.left;
|
x = Draw2D.left;
|
||||||
srcOff += trim;
|
srcOff += trim;
|
||||||
dstOff += trim;
|
dstOff += trim;
|
||||||
srcStep += trim;
|
srcStep += trim;
|
||||||
dstStep += trim;
|
dstStep += trim;
|
||||||
}
|
}
|
||||||
if ((x + w) > Draw2D.right) {
|
if ((x + w) > Draw2D.right) {
|
||||||
int trim = (x + w) - Draw2D.right;
|
int trim = (x + w) - Draw2D.right;
|
||||||
w -= trim;
|
w -= trim;
|
||||||
srcStep += trim;
|
srcStep += trim;
|
||||||
dstStep += trim;
|
dstStep += trim;
|
||||||
}
|
}
|
||||||
if ((w > 0) && (h > 0)) {
|
if ((w > 0) && (h > 0)) {
|
||||||
copyPixels(dstOff, w, h, srcStep, srcOff, dstStep, pixels, Draw2D.pixels);
|
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) {
|
public void copyPixels(int dstOff, int w, int h, int srcStep, int srcOff, int dstStep, int[] src, int[] dst) {
|
||||||
int quarterWidth = -(w >> 2);
|
int quarterWidth = -(w >> 2);
|
||||||
w = -(w & 3);
|
w = -(w & 3);
|
||||||
for (int y = -h; y < 0; y++) {
|
for (int y = -h; y < 0; y++) {
|
||||||
for (int i = quarterWidth; i < 0; i++) {
|
for (int i = quarterWidth; i < 0; i++) {
|
||||||
dst[dstOff++] = src[srcOff++];
|
dst[dstOff++] = src[srcOff++];
|
||||||
dst[dstOff++] = src[srcOff++];
|
dst[dstOff++] = src[srcOff++];
|
||||||
dst[dstOff++] = src[srcOff++];
|
dst[dstOff++] = src[srcOff++];
|
||||||
dst[dstOff++] = src[srcOff++];
|
dst[dstOff++] = src[srcOff++];
|
||||||
}
|
}
|
||||||
for (int i = w; i < 0; i++) {
|
for (int i = w; i < 0; i++) {
|
||||||
dst[dstOff++] = src[srcOff++];
|
dst[dstOff++] = src[srcOff++];
|
||||||
}
|
}
|
||||||
dstOff += dstStep;
|
dstOff += dstStep;
|
||||||
srcOff += srcStep;
|
srcOff += srcStep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(int x, int y) {
|
public void draw(int x, int y) {
|
||||||
x += cropX;
|
x += cropX;
|
||||||
y += cropY;
|
y += cropY;
|
||||||
int dstOff = x + (y * Draw2D.width);
|
int dstOff = x + (y * Draw2D.width);
|
||||||
int srcOff = 0;
|
int srcOff = 0;
|
||||||
int h = height;
|
int h = height;
|
||||||
int w = width;
|
int w = width;
|
||||||
int dstStep = Draw2D.width - w;
|
int dstStep = Draw2D.width - w;
|
||||||
int srcStep = 0;
|
int srcStep = 0;
|
||||||
if (y < Draw2D.top) {
|
if (y < Draw2D.top) {
|
||||||
int trim = Draw2D.top - y;
|
int trim = Draw2D.top - y;
|
||||||
h -= trim;
|
h -= trim;
|
||||||
y = Draw2D.top;
|
y = Draw2D.top;
|
||||||
srcOff += trim * w;
|
srcOff += trim * w;
|
||||||
dstOff += trim * Draw2D.width;
|
dstOff += trim * Draw2D.width;
|
||||||
}
|
}
|
||||||
if ((y + h) > Draw2D.bottom) {
|
if ((y + h) > Draw2D.bottom) {
|
||||||
h -= (y + h) - Draw2D.bottom;
|
h -= (y + h) - Draw2D.bottom;
|
||||||
}
|
}
|
||||||
if (x < Draw2D.left) {
|
if (x < Draw2D.left) {
|
||||||
int trim = Draw2D.left - x;
|
int trim = Draw2D.left - x;
|
||||||
w -= trim;
|
w -= trim;
|
||||||
x = Draw2D.left;
|
x = Draw2D.left;
|
||||||
srcOff += trim;
|
srcOff += trim;
|
||||||
dstOff += trim;
|
dstOff += trim;
|
||||||
srcStep += trim;
|
srcStep += trim;
|
||||||
dstStep += trim;
|
dstStep += trim;
|
||||||
}
|
}
|
||||||
if ((x + w) > Draw2D.right) {
|
if ((x + w) > Draw2D.right) {
|
||||||
int trim = (x + w) - Draw2D.right;
|
int trim = (x + w) - Draw2D.right;
|
||||||
w -= trim;
|
w -= trim;
|
||||||
srcStep += trim;
|
srcStep += trim;
|
||||||
dstStep += trim;
|
dstStep += trim;
|
||||||
}
|
}
|
||||||
if ((w > 0) && (h > 0)) {
|
if ((w > 0) && (h > 0)) {
|
||||||
copyPixels(Draw2D.pixels, pixels, srcOff, dstOff, w, h, dstStep, srcStep);
|
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) {
|
public void copyPixels(int[] dst, int[] src, int srcOff, int dstOff, int w, int h, int dstStep, int srcstep) {
|
||||||
int quarterW = -(w >> 2);
|
int quarterW = -(w >> 2);
|
||||||
w = -(w & 3);
|
w = -(w & 3);
|
||||||
for (int y = -h; y < 0; y++) {
|
for (int y = -h; y < 0; y++) {
|
||||||
int rgb;
|
int rgb;
|
||||||
for (int x = quarterW; x < 0; x++) {
|
for (int x = quarterW; x < 0; x++) {
|
||||||
rgb = src[srcOff++];
|
rgb = src[srcOff++];
|
||||||
if (rgb != 0) {
|
if (rgb != 0) {
|
||||||
dst[dstOff++] = rgb;
|
dst[dstOff++] = rgb;
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
rgb = src[srcOff++];
|
rgb = src[srcOff++];
|
||||||
if (rgb != 0) {
|
if (rgb != 0) {
|
||||||
dst[dstOff++] = rgb;
|
dst[dstOff++] = rgb;
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
rgb = src[srcOff++];
|
rgb = src[srcOff++];
|
||||||
if (rgb != 0) {
|
if (rgb != 0) {
|
||||||
dst[dstOff++] = rgb;
|
dst[dstOff++] = rgb;
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
rgb = src[srcOff++];
|
rgb = src[srcOff++];
|
||||||
if (rgb != 0) {
|
if (rgb != 0) {
|
||||||
dst[dstOff++] = rgb;
|
dst[dstOff++] = rgb;
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int k2 = w; k2 < 0; k2++) {
|
for (int k2 = w; k2 < 0; k2++) {
|
||||||
rgb = src[srcOff++];
|
rgb = src[srcOff++];
|
||||||
if (rgb != 0) {
|
if (rgb != 0) {
|
||||||
dst[dstOff++] = rgb;
|
dst[dstOff++] = rgb;
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dstOff += dstStep;
|
dstOff += dstStep;
|
||||||
srcOff += srcstep;
|
srcOff += srcstep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(int x, int y, int alpha) {
|
public void draw(int x, int y, int alpha) {
|
||||||
x += cropX;
|
x += cropX;
|
||||||
y += cropY;
|
y += cropY;
|
||||||
int dstOff = x + (y * Draw2D.width);
|
int dstOff = x + (y * Draw2D.width);
|
||||||
int srcOff = 0;
|
int srcOff = 0;
|
||||||
int h = height;
|
int h = height;
|
||||||
int w = width;
|
int w = width;
|
||||||
int dstStep = Draw2D.width - w;
|
int dstStep = Draw2D.width - w;
|
||||||
int srcStep = 0;
|
int srcStep = 0;
|
||||||
if (y < Draw2D.top) {
|
if (y < Draw2D.top) {
|
||||||
int trim = Draw2D.top - y;
|
int trim = Draw2D.top - y;
|
||||||
h -= trim;
|
h -= trim;
|
||||||
y = Draw2D.top;
|
y = Draw2D.top;
|
||||||
srcOff += trim * w;
|
srcOff += trim * w;
|
||||||
dstOff += trim * Draw2D.width;
|
dstOff += trim * Draw2D.width;
|
||||||
}
|
}
|
||||||
if ((y + h) > Draw2D.bottom) {
|
if ((y + h) > Draw2D.bottom) {
|
||||||
h -= (y + h) - Draw2D.bottom;
|
h -= (y + h) - Draw2D.bottom;
|
||||||
}
|
}
|
||||||
if (x < Draw2D.left) {
|
if (x < Draw2D.left) {
|
||||||
int trim = Draw2D.left - x;
|
int trim = Draw2D.left - x;
|
||||||
w -= trim;
|
w -= trim;
|
||||||
x = Draw2D.left;
|
x = Draw2D.left;
|
||||||
srcOff += trim;
|
srcOff += trim;
|
||||||
dstOff += trim;
|
dstOff += trim;
|
||||||
srcStep += trim;
|
srcStep += trim;
|
||||||
dstStep += trim;
|
dstStep += trim;
|
||||||
}
|
}
|
||||||
if ((x + w) > Draw2D.right) {
|
if ((x + w) > Draw2D.right) {
|
||||||
int trim = (x + w) - Draw2D.right;
|
int trim = (x + w) - Draw2D.right;
|
||||||
w -= trim;
|
w -= trim;
|
||||||
srcStep += trim;
|
srcStep += trim;
|
||||||
dstStep += trim;
|
dstStep += trim;
|
||||||
}
|
}
|
||||||
if ((w > 0) && (h > 0)) {
|
if ((w > 0) && (h > 0)) {
|
||||||
copyPixelsAlpha(srcOff, w, Draw2D.pixels, pixels, srcStep, h, dstStep, alpha, dstOff);
|
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) {
|
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;
|
int invAlpha = 256 - alpha;
|
||||||
for (int k2 = -h; k2 < 0; k2++) {
|
for (int k2 = -h; k2 < 0; k2++) {
|
||||||
for (int l2 = -w; l2 < 0; l2++) {
|
for (int l2 = -w; l2 < 0; l2++) {
|
||||||
int srcRGB = src[srcOff++];
|
int srcRGB = src[srcOff++];
|
||||||
if (srcRGB != 0) {
|
if (srcRGB != 0) {
|
||||||
int dstRGB = dst[dstOff];
|
int dstRGB = dst[dstOff];
|
||||||
dst[dstOff++] = (((((srcRGB & 0xff00ff) * alpha) + ((dstRGB & 0xff00ff) * invAlpha)) & 0xff00ff00) + ((((srcRGB & 0xff00) * alpha) + ((dstRGB & 0xff00) * invAlpha)) & 0xff0000)) >> 8;
|
dst[dstOff++] = (((((srcRGB & 0xff00ff) * alpha) + ((dstRGB & 0xff00ff) * invAlpha)) & 0xff00ff00) + ((((srcRGB & 0xff00) * alpha) + ((dstRGB & 0xff00) * invAlpha)) & 0xff0000)) >> 8;
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dstOff += dstStep;
|
dstOff += dstStep;
|
||||||
srcOff += srcStep;
|
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) {
|
public void drawRotatedMasked(int x, int y, int width, int height, int anchorX, int anchorY, int zoom, int angle, int[] lineLengths, int[] lineOffsets) {
|
||||||
try {
|
try {
|
||||||
int midX = -width / 2;
|
int midX = -width / 2;
|
||||||
int midY = -height / 2;
|
int midY = -height / 2;
|
||||||
int sin = (int) (Math.sin((double) angle / 326.11000000000001D) * 65536D);
|
int sin = (int) (Math.sin((double) angle / 326.11000000000001D) * 65536D);
|
||||||
int cos = (int) (Math.cos((double) angle / 326.11000000000001D) * 65536D);
|
int cos = (int) (Math.cos((double) angle / 326.11000000000001D) * 65536D);
|
||||||
sin = (sin * zoom) >> 8;
|
sin = (sin * zoom) >> 8;
|
||||||
cos = (cos * zoom) >> 8;
|
cos = (cos * zoom) >> 8;
|
||||||
int leftX = (anchorX << 16) + (midY * sin) + (midX * cos);
|
int leftX = (anchorX << 16) + (midY * sin) + (midX * cos);
|
||||||
int lefty = ((anchorY << 16) + (midY * cos)) - (midX * sin);
|
int lefty = ((anchorY << 16) + (midY * cos)) - (midX * sin);
|
||||||
int leftOff = x + (y * Draw2D.width);
|
int leftOff = x + (y * Draw2D.width);
|
||||||
for (y = 0; y < height; y++) {
|
for (y = 0; y < height; y++) {
|
||||||
int lineOffset = lineOffsets[y];
|
int lineOffset = lineOffsets[y];
|
||||||
int dstOff = leftOff + lineOffset;
|
int dstOff = leftOff + lineOffset;
|
||||||
int srcX = leftX + (cos * lineOffset);
|
int srcX = leftX + (cos * lineOffset);
|
||||||
int srcY = lefty - (sin * lineOffset);
|
int srcY = lefty - (sin * lineOffset);
|
||||||
for (x = -lineLengths[y]; x < 0; x++) {
|
for (x = -lineLengths[y]; x < 0; x++) {
|
||||||
Draw2D.pixels[dstOff++] = pixels[(srcX >> 16) + ((srcY >> 16) * this.width)];
|
Draw2D.pixels[dstOff++] = pixels[(srcX >> 16) + ((srcY >> 16) * this.width)];
|
||||||
srcX += cos;
|
srcX += cos;
|
||||||
srcY -= sin;
|
srcY -= sin;
|
||||||
}
|
}
|
||||||
leftX += sin;
|
leftX += sin;
|
||||||
lefty += cos;
|
lefty += cos;
|
||||||
leftOff += Draw2D.width;
|
leftOff += Draw2D.width;
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawRotated(int x, int y, int width, int height, int anchorX, int anchorY, double radians, int zoom) {
|
public void drawRotated(int x, int y, int width, int height, int anchorX, int anchorY, double radians, int zoom) {
|
||||||
try {
|
try {
|
||||||
int centerX = -width / 2;
|
int centerX = -width / 2;
|
||||||
int centerY = -height / 2;
|
int centerY = -height / 2;
|
||||||
int sin = (int) (Math.sin(radians) * 65536D);
|
int sin = (int) (Math.sin(radians) * 65536D);
|
||||||
int cos = (int) (Math.cos(radians) * 65536D);
|
int cos = (int) (Math.cos(radians) * 65536D);
|
||||||
sin = (sin * zoom) >> 8;
|
sin = (sin * zoom) >> 8;
|
||||||
cos = (cos * zoom) >> 8;
|
cos = (cos * zoom) >> 8;
|
||||||
int leftX = (anchorX << 16) + (centerY * sin) + (centerX * cos);
|
int leftX = (anchorX << 16) + (centerY * sin) + (centerX * cos);
|
||||||
int leftY = ((anchorY << 16) + (centerY * cos)) - (centerX * sin);
|
int leftY = ((anchorY << 16) + (centerY * cos)) - (centerX * sin);
|
||||||
int leftOff = x + (y * Draw2D.width);
|
int leftOff = x + (y * Draw2D.width);
|
||||||
|
|
||||||
for (y = 0; y < height; y++) {
|
for (y = 0; y < height; y++) {
|
||||||
int dstOff = leftOff;
|
int dstOff = leftOff;
|
||||||
int dstX = leftX;
|
int dstX = leftX;
|
||||||
int dstY = leftY;
|
int dstY = leftY;
|
||||||
for (x = -width; x < 0; x++) {
|
for (x = -width; x < 0; x++) {
|
||||||
int rgb = pixels[(dstX >> 16) + ((dstY >> 16) * this.width)];
|
int rgb = pixels[(dstX >> 16) + ((dstY >> 16) * this.width)];
|
||||||
if (rgb != 0) {
|
if (rgb != 0) {
|
||||||
Draw2D.pixels[dstOff++] = rgb;
|
Draw2D.pixels[dstOff++] = rgb;
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
dstX += cos;
|
dstX += cos;
|
||||||
dstY -= sin;
|
dstY -= sin;
|
||||||
}
|
}
|
||||||
leftX += sin;
|
leftX += sin;
|
||||||
leftY += cos;
|
leftY += cos;
|
||||||
leftOff += Draw2D.width;
|
leftOff += Draw2D.width;
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawMasked(Image8 mask, int y, int x) {
|
public void drawMasked(Image8 mask, int y, int x) {
|
||||||
x += cropX;
|
x += cropX;
|
||||||
y += cropY;
|
y += cropY;
|
||||||
int dstOff = x + (y * Draw2D.width);
|
int dstOff = x + (y * Draw2D.width);
|
||||||
int srcOff = 0;
|
int srcOff = 0;
|
||||||
int h = height;
|
int h = height;
|
||||||
int w = width;
|
int w = width;
|
||||||
int dstStep = Draw2D.width - w;
|
int dstStep = Draw2D.width - w;
|
||||||
int srcStep = 0;
|
int srcStep = 0;
|
||||||
if (y < Draw2D.top) {
|
if (y < Draw2D.top) {
|
||||||
int trim = Draw2D.top - y;
|
int trim = Draw2D.top - y;
|
||||||
h -= trim;
|
h -= trim;
|
||||||
y = Draw2D.top;
|
y = Draw2D.top;
|
||||||
srcOff += trim * w;
|
srcOff += trim * w;
|
||||||
dstOff += trim * Draw2D.width;
|
dstOff += trim * Draw2D.width;
|
||||||
}
|
}
|
||||||
if ((y + h) > Draw2D.bottom) {
|
if ((y + h) > Draw2D.bottom) {
|
||||||
h -= (y + h) - Draw2D.bottom;
|
h -= (y + h) - Draw2D.bottom;
|
||||||
}
|
}
|
||||||
if (x < Draw2D.left) {
|
if (x < Draw2D.left) {
|
||||||
int trim = Draw2D.left - x;
|
int trim = Draw2D.left - x;
|
||||||
w -= trim;
|
w -= trim;
|
||||||
x = Draw2D.left;
|
x = Draw2D.left;
|
||||||
srcOff += trim;
|
srcOff += trim;
|
||||||
dstOff += trim;
|
dstOff += trim;
|
||||||
srcStep += trim;
|
srcStep += trim;
|
||||||
dstStep += trim;
|
dstStep += trim;
|
||||||
}
|
}
|
||||||
if ((x + w) > Draw2D.right) {
|
if ((x + w) > Draw2D.right) {
|
||||||
int trim = (x + w) - Draw2D.right;
|
int trim = (x + w) - Draw2D.right;
|
||||||
w -= trim;
|
w -= trim;
|
||||||
srcStep += trim;
|
srcStep += trim;
|
||||||
dstStep += trim;
|
dstStep += trim;
|
||||||
}
|
}
|
||||||
if ((w > 0) && (h > 0)) {
|
if ((w > 0) && (h > 0)) {
|
||||||
copyPixelsMasked(pixels, srcOff, srcStep, mask.pixels, w, h, Draw2D.pixels, dstOff, dstStep);
|
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) {
|
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);
|
int quarterW = -(w >> 2);
|
||||||
w = -(w & 3);
|
w = -(w & 3);
|
||||||
for (int y = -h; y < 0; y++) {
|
for (int y = -h; y < 0; y++) {
|
||||||
int rgb;
|
int rgb;
|
||||||
for (int i = quarterW; i < 0; i++) {
|
for (int i = quarterW; i < 0; i++) {
|
||||||
rgb = src[srcOff++];
|
rgb = src[srcOff++];
|
||||||
if ((rgb != 0) && (mask[dstOff] == 0)) {
|
if ((rgb != 0) && (mask[dstOff] == 0)) {
|
||||||
dst[dstOff++] = rgb;
|
dst[dstOff++] = rgb;
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
rgb = src[srcOff++];
|
rgb = src[srcOff++];
|
||||||
if ((rgb != 0) && (mask[dstOff] == 0)) {
|
if ((rgb != 0) && (mask[dstOff] == 0)) {
|
||||||
dst[dstOff++] = rgb;
|
dst[dstOff++] = rgb;
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
rgb = src[srcOff++];
|
rgb = src[srcOff++];
|
||||||
if ((rgb != 0) && (mask[dstOff] == 0)) {
|
if ((rgb != 0) && (mask[dstOff] == 0)) {
|
||||||
dst[dstOff++] = rgb;
|
dst[dstOff++] = rgb;
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
rgb = src[srcOff++];
|
rgb = src[srcOff++];
|
||||||
if ((rgb != 0) && (mask[dstOff] == 0)) {
|
if ((rgb != 0) && (mask[dstOff] == 0)) {
|
||||||
dst[dstOff++] = rgb;
|
dst[dstOff++] = rgb;
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = w; i < 0; i++) {
|
for (int i = w; i < 0; i++) {
|
||||||
rgb = src[srcOff++];
|
rgb = src[srcOff++];
|
||||||
if ((rgb != 0) && (mask[dstOff] == 0)) {
|
if ((rgb != 0) && (mask[dstOff] == 0)) {
|
||||||
dst[dstOff++] = rgb;
|
dst[dstOff++] = rgb;
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dstOff += dstStep;
|
dstOff += dstStep;
|
||||||
srcOff += srcStep;
|
srcOff += srcStep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+206
-206
@@ -2,223 +2,223 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class Image8 {
|
public class Image8 {
|
||||||
|
|
||||||
public final int[] palette;
|
public final int[] palette;
|
||||||
public byte[] pixels;
|
public byte[] pixels;
|
||||||
public int width;
|
public int width;
|
||||||
public int height;
|
public int height;
|
||||||
public int cropX;
|
public int cropX;
|
||||||
public int cropY;
|
public int cropY;
|
||||||
public int cropW;
|
public int cropW;
|
||||||
public int cropH;
|
public int cropH;
|
||||||
|
|
||||||
public Image8(FileArchive archive, String name, int index) throws IOException {
|
public Image8(FileArchive archive, String name, int index) throws IOException {
|
||||||
Buffer dat = new Buffer(archive.read(name + ".dat"));
|
Buffer dat = new Buffer(archive.read(name + ".dat"));
|
||||||
Buffer idx = new Buffer(archive.read("index.dat"));
|
Buffer idx = new Buffer(archive.read("index.dat"));
|
||||||
idx.position = dat.read16U();
|
idx.position = dat.read16U();
|
||||||
cropW = idx.read16U();
|
cropW = idx.read16U();
|
||||||
cropH = idx.read16U();
|
cropH = idx.read16U();
|
||||||
int paletteSize = idx.read8U();
|
int paletteSize = idx.read8U();
|
||||||
palette = new int[paletteSize];
|
palette = new int[paletteSize];
|
||||||
for (int i = 0; i < (paletteSize - 1); i++) {
|
for (int i = 0; i < (paletteSize - 1); i++) {
|
||||||
palette[i + 1] = idx.read24();
|
palette[i + 1] = idx.read24();
|
||||||
}
|
}
|
||||||
for (int i = 0; i < index; i++) {
|
for (int i = 0; i < index; i++) {
|
||||||
idx.position += 2;
|
idx.position += 2;
|
||||||
dat.position += idx.read16U() * idx.read16U();
|
dat.position += idx.read16U() * idx.read16U();
|
||||||
idx.position++;
|
idx.position++;
|
||||||
}
|
}
|
||||||
cropX = idx.read8U();
|
cropX = idx.read8U();
|
||||||
cropY = idx.read8U();
|
cropY = idx.read8U();
|
||||||
width = idx.read16U();
|
width = idx.read16U();
|
||||||
height = idx.read16U();
|
height = idx.read16U();
|
||||||
int pixelOrder = idx.read8U();
|
int pixelOrder = idx.read8U();
|
||||||
int pixelCount = width * height;
|
int pixelCount = width * height;
|
||||||
pixels = new byte[pixelCount];
|
pixels = new byte[pixelCount];
|
||||||
|
|
||||||
if (pixelOrder == 0) {
|
if (pixelOrder == 0) {
|
||||||
for (int i = 0; i < pixelCount; i++) {
|
for (int i = 0; i < pixelCount; i++) {
|
||||||
pixels[i] = dat.read();
|
pixels[i] = dat.read();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixelOrder == 1) {
|
if (pixelOrder == 1) {
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
pixels[x + (y * width)] = dat.read();
|
pixels[x + (y * width)] = dat.read();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shrink() {
|
public void shrink() {
|
||||||
cropW /= 2;
|
cropW /= 2;
|
||||||
cropH /= 2;
|
cropH /= 2;
|
||||||
byte[] pixels = new byte[cropW * cropH];
|
byte[] pixels = new byte[cropW * cropH];
|
||||||
int off = 0;
|
int off = 0;
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
pixels[((x + cropX) >> 1) + (((y + cropY) >> 1) * cropW)] = this.pixels[off++];
|
pixels[((x + cropX) >> 1) + (((y + cropY) >> 1) * cropW)] = this.pixels[off++];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.pixels = pixels;
|
this.pixels = pixels;
|
||||||
width = cropW;
|
width = cropW;
|
||||||
height = cropH;
|
height = cropH;
|
||||||
cropX = 0;
|
cropX = 0;
|
||||||
cropY = 0;
|
cropY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void crop() {
|
public void crop() {
|
||||||
if ((width == cropW) && (height == cropH)) {
|
if ((width == cropW) && (height == cropH)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
byte[] pixels = new byte[cropW * cropH];
|
byte[] pixels = new byte[cropW * cropH];
|
||||||
int off = 0;
|
int off = 0;
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
pixels[x + cropX + ((y + cropY) * cropW)] = this.pixels[off++];
|
pixels[x + cropX + ((y + cropY) * cropW)] = this.pixels[off++];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.pixels = pixels;
|
this.pixels = pixels;
|
||||||
width = cropW;
|
width = cropW;
|
||||||
height = cropH;
|
height = cropH;
|
||||||
cropX = 0;
|
cropX = 0;
|
||||||
cropY = 0;
|
cropY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flipHorizontally() {
|
public void flipHorizontally() {
|
||||||
byte[] pixels = new byte[width * height];
|
byte[] pixels = new byte[width * height];
|
||||||
int off = 0;
|
int off = 0;
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
for (int x = width - 1; x >= 0; x--) {
|
for (int x = width - 1; x >= 0; x--) {
|
||||||
pixels[off++] = this.pixels[x + (y * width)];
|
pixels[off++] = this.pixels[x + (y * width)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.pixels = pixels;
|
this.pixels = pixels;
|
||||||
cropX = cropW - width - cropX;
|
cropX = cropW - width - cropX;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flipVertically() {
|
public void flipVertically() {
|
||||||
byte[] pixels = new byte[width * height];
|
byte[] pixels = new byte[width * height];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (int y = height - 1; y >= 0; y--) {
|
for (int y = height - 1; y >= 0; y--) {
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
pixels[i++] = this.pixels[x + (y * width)];
|
pixels[i++] = this.pixels[x + (y * width)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.pixels = pixels;
|
this.pixels = pixels;
|
||||||
cropY = cropH - height - cropY;
|
cropY = cropH - height - cropY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void translate(int r, int g, int b) {
|
public void translate(int r, int g, int b) {
|
||||||
for (int i = 0; i < palette.length; i++) {
|
for (int i = 0; i < palette.length; i++) {
|
||||||
int red = (palette[i] >> 16) & 0xff;
|
int red = (palette[i] >> 16) & 0xff;
|
||||||
red += r;
|
red += r;
|
||||||
if (red < 0) {
|
if (red < 0) {
|
||||||
red = 0;
|
red = 0;
|
||||||
} else if (red > 255) {
|
} else if (red > 255) {
|
||||||
red = 255;
|
red = 255;
|
||||||
}
|
}
|
||||||
int green = (palette[i] >> 8) & 0xff;
|
int green = (palette[i] >> 8) & 0xff;
|
||||||
green += g;
|
green += g;
|
||||||
if (green < 0) {
|
if (green < 0) {
|
||||||
green = 0;
|
green = 0;
|
||||||
} else if (green > 255) {
|
} else if (green > 255) {
|
||||||
green = 255;
|
green = 255;
|
||||||
}
|
}
|
||||||
int blue = palette[i] & 0xff;
|
int blue = palette[i] & 0xff;
|
||||||
blue += b;
|
blue += b;
|
||||||
if (blue < 0) {
|
if (blue < 0) {
|
||||||
blue = 0;
|
blue = 0;
|
||||||
} else if (blue > 255) {
|
} else if (blue > 255) {
|
||||||
blue = 255;
|
blue = 255;
|
||||||
}
|
}
|
||||||
palette[i] = (red << 16) + (green << 8) + blue;
|
palette[i] = (red << 16) + (green << 8) + blue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void blit(int x, int y) {
|
public void blit(int x, int y) {
|
||||||
x += cropX;
|
x += cropX;
|
||||||
y += cropY;
|
y += cropY;
|
||||||
int dstOff = x + (y * Draw2D.width);
|
int dstOff = x + (y * Draw2D.width);
|
||||||
int srcOff = 0;
|
int srcOff = 0;
|
||||||
int height = this.height;
|
int height = this.height;
|
||||||
int width = this.width;
|
int width = this.width;
|
||||||
int dstStep = Draw2D.width - width;
|
int dstStep = Draw2D.width - width;
|
||||||
int srcStep = 0;
|
int srcStep = 0;
|
||||||
if (y < Draw2D.top) {
|
if (y < Draw2D.top) {
|
||||||
int trim = Draw2D.top - y;
|
int trim = Draw2D.top - y;
|
||||||
height -= trim;
|
height -= trim;
|
||||||
y = Draw2D.top;
|
y = Draw2D.top;
|
||||||
srcOff += trim * width;
|
srcOff += trim * width;
|
||||||
dstOff += trim * Draw2D.width;
|
dstOff += trim * Draw2D.width;
|
||||||
}
|
}
|
||||||
if ((y + height) > Draw2D.bottom) {
|
if ((y + height) > Draw2D.bottom) {
|
||||||
height -= (y + height) - Draw2D.bottom;
|
height -= (y + height) - Draw2D.bottom;
|
||||||
}
|
}
|
||||||
if (x < Draw2D.left) {
|
if (x < Draw2D.left) {
|
||||||
int trim = Draw2D.left - x;
|
int trim = Draw2D.left - x;
|
||||||
width -= trim;
|
width -= trim;
|
||||||
x = Draw2D.left;
|
x = Draw2D.left;
|
||||||
srcOff += trim;
|
srcOff += trim;
|
||||||
dstOff += trim;
|
dstOff += trim;
|
||||||
srcStep += trim;
|
srcStep += trim;
|
||||||
dstStep += trim;
|
dstStep += trim;
|
||||||
}
|
}
|
||||||
if ((x + width) > Draw2D.right) {
|
if ((x + width) > Draw2D.right) {
|
||||||
int trim = (x + width) - Draw2D.right;
|
int trim = (x + width) - Draw2D.right;
|
||||||
width -= trim;
|
width -= trim;
|
||||||
srcStep += trim;
|
srcStep += trim;
|
||||||
dstStep += trim;
|
dstStep += trim;
|
||||||
}
|
}
|
||||||
if ((width > 0) && (height > 0)) {
|
if ((width > 0) && (height > 0)) {
|
||||||
blit(height, Draw2D.pixels, pixels, dstStep, dstOff, width, srcOff, palette, srcStep);
|
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) {
|
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);
|
int quarterWidth = -(width >> 2);
|
||||||
width = -(width & 3);
|
width = -(width & 3);
|
||||||
for (int y = -height; y < 0; y++) {
|
for (int y = -height; y < 0; y++) {
|
||||||
for (int w = quarterWidth; w < 0; w++) {
|
for (int w = quarterWidth; w < 0; w++) {
|
||||||
byte paletteIndex = src[srcOff++];
|
byte paletteIndex = src[srcOff++];
|
||||||
|
|
||||||
if (paletteIndex != 0) {
|
if (paletteIndex != 0) {
|
||||||
dst[dstOff++] = palette[paletteIndex & 0xff];
|
dst[dstOff++] = palette[paletteIndex & 0xff];
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
|
|
||||||
paletteIndex = src[srcOff++];
|
paletteIndex = src[srcOff++];
|
||||||
if (paletteIndex != 0) {
|
if (paletteIndex != 0) {
|
||||||
dst[dstOff++] = palette[paletteIndex & 0xff];
|
dst[dstOff++] = palette[paletteIndex & 0xff];
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
paletteIndex = src[srcOff++];
|
paletteIndex = src[srcOff++];
|
||||||
if (paletteIndex != 0) {
|
if (paletteIndex != 0) {
|
||||||
dst[dstOff++] = palette[paletteIndex & 0xff];
|
dst[dstOff++] = palette[paletteIndex & 0xff];
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
paletteIndex = src[srcOff++];
|
paletteIndex = src[srcOff++];
|
||||||
if (paletteIndex != 0) {
|
if (paletteIndex != 0) {
|
||||||
dst[dstOff++] = palette[paletteIndex & 0xff];
|
dst[dstOff++] = palette[paletteIndex & 0xff];
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = width; i < 0; i++) {
|
for (int i = width; i < 0; i++) {
|
||||||
byte paletteIndex = src[srcOff++];
|
byte paletteIndex = src[srcOff++];
|
||||||
if (paletteIndex != 0) {
|
if (paletteIndex != 0) {
|
||||||
dst[dstOff++] = palette[paletteIndex & 0xff];
|
dst[dstOff++] = palette[paletteIndex & 0xff];
|
||||||
} else {
|
} else {
|
||||||
dstOff++;
|
dstOff++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dstOff += dstStep;
|
dstOff += dstStep;
|
||||||
srcOff += srcStep;
|
srcOff += srcStep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,115 +4,115 @@
|
|||||||
|
|
||||||
public class LocEntity extends Entity {
|
public class LocEntity extends Entity {
|
||||||
|
|
||||||
public static Game game;
|
public static Game game;
|
||||||
public final int[] overrideTypeIDs;
|
public final int[] overrideTypeIDs;
|
||||||
public final int varbit;
|
public final int varbit;
|
||||||
public final int varp;
|
public final int varp;
|
||||||
public final int heightmapSW;
|
public final int heightmapSW;
|
||||||
public final int heightmapSE;
|
public final int heightmapSE;
|
||||||
public final int heightmapNE;
|
public final int heightmapNE;
|
||||||
public final int heightmapNW;
|
public final int heightmapNW;
|
||||||
public final int id;
|
public final int id;
|
||||||
public final int kind;
|
public final int kind;
|
||||||
public final int rotation;
|
public final int rotation;
|
||||||
public int seqFrame;
|
public int seqFrame;
|
||||||
public SeqType seq;
|
public SeqType seq;
|
||||||
public int seqCycle;
|
public int seqCycle;
|
||||||
|
|
||||||
public LocEntity(int id, int rotation, int kind, int heightmapSE, int heightmapNE, int heightmapSW, int heightmapNW, int seqID, boolean randomFrame) {
|
public LocEntity(int id, int rotation, int kind, int heightmapSE, int heightmapNE, int heightmapSW, int heightmapNW, int seqID, boolean randomFrame) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
this.heightmapSW = heightmapSW;
|
this.heightmapSW = heightmapSW;
|
||||||
this.heightmapSE = heightmapSE;
|
this.heightmapSE = heightmapSE;
|
||||||
this.heightmapNE = heightmapNE;
|
this.heightmapNE = heightmapNE;
|
||||||
this.heightmapNW = heightmapNW;
|
this.heightmapNW = heightmapNW;
|
||||||
|
|
||||||
if (seqID != -1) {
|
if (seqID != -1) {
|
||||||
seq = SeqType.instances[seqID];
|
seq = SeqType.instances[seqID];
|
||||||
seqFrame = 0;
|
seqFrame = 0;
|
||||||
seqCycle = Game.loopCycle;
|
seqCycle = Game.loopCycle;
|
||||||
|
|
||||||
if (randomFrame && (seq.loopFrameCount != -1)) {
|
if (randomFrame && (seq.loopFrameCount != -1)) {
|
||||||
seqFrame = (int) (Math.random() * (double) seq.frameCount);
|
seqFrame = (int) (Math.random() * (double) seq.frameCount);
|
||||||
seqCycle -= (int) (Math.random() * (double) seq.getFrameDuration(seqFrame));
|
seqCycle -= (int) (Math.random() * (double) seq.getFrameDuration(seqFrame));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LocType type = LocType.get(this.id);
|
LocType type = LocType.get(this.id);
|
||||||
varbit = type.varbit;
|
varbit = type.varbit;
|
||||||
varp = type.varp;
|
varp = type.varp;
|
||||||
overrideTypeIDs = type.overrideTypeIDs;
|
overrideTypeIDs = type.overrideTypeIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Model getModel() {
|
public Model getModel() {
|
||||||
int transformID = -1;
|
int transformID = -1;
|
||||||
|
|
||||||
if (seq != null) {
|
if (seq != null) {
|
||||||
int delta = Game.loopCycle - seqCycle;
|
int delta = Game.loopCycle - seqCycle;
|
||||||
|
|
||||||
if ((delta > 100) && (seq.loopFrameCount > 0)) {
|
if ((delta > 100) && (seq.loopFrameCount > 0)) {
|
||||||
delta = 100;
|
delta = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (delta > seq.getFrameDuration(seqFrame)) {
|
while (delta > seq.getFrameDuration(seqFrame)) {
|
||||||
delta -= seq.getFrameDuration(seqFrame);
|
delta -= seq.getFrameDuration(seqFrame);
|
||||||
seqFrame++;
|
seqFrame++;
|
||||||
|
|
||||||
if (seqFrame < seq.frameCount) {
|
if (seqFrame < seq.frameCount) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
seqFrame -= seq.loopFrameCount;
|
seqFrame -= seq.loopFrameCount;
|
||||||
|
|
||||||
if ((seqFrame >= 0) && (seqFrame < seq.frameCount)) {
|
if ((seqFrame >= 0) && (seqFrame < seq.frameCount)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
seq = null;
|
seq = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
seqCycle = Game.loopCycle - delta;
|
seqCycle = Game.loopCycle - delta;
|
||||||
|
|
||||||
if (seq != null) {
|
if (seq != null) {
|
||||||
transformID = seq.transformIDs[seqFrame];
|
transformID = seq.transformIDs[seqFrame];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LocType type;
|
LocType type;
|
||||||
|
|
||||||
if (overrideTypeIDs != null) {
|
if (overrideTypeIDs != null) {
|
||||||
type = getOverrideType();
|
type = getOverrideType();
|
||||||
} else {
|
} else {
|
||||||
type = LocType.get(id);
|
type = LocType.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return type.getModel(kind, rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, transformID);
|
return type.getModel(kind, rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, transformID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocType getOverrideType() {
|
public LocType getOverrideType() {
|
||||||
int value = -1;
|
int value = -1;
|
||||||
|
|
||||||
if (varbit != -1) {
|
if (varbit != -1) {
|
||||||
VarbitType varbit = VarbitType.instances[this.varbit];
|
VarbitType varbit = VarbitType.instances[this.varbit];
|
||||||
int varp = varbit.varp;
|
int varp = varbit.varp;
|
||||||
int low = varbit.lsb;
|
int low = varbit.lsb;
|
||||||
int high = varbit.msb;
|
int high = varbit.msb;
|
||||||
int mask = Game.BITMASK[high - low];
|
int mask = Game.BITMASK[high - low];
|
||||||
value = (game.varps[varp] >> low) & mask;
|
value = (game.varps[varp] >> low) & mask;
|
||||||
} else if (varp != -1) {
|
} else if (varp != -1) {
|
||||||
value = game.varps[varp];
|
value = game.varps[varp];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((value < 0) || (value >= overrideTypeIDs.length) || (overrideTypeIDs[value] == -1)) {
|
if ((value < 0) || (value >= overrideTypeIDs.length) || (overrideTypeIDs[value] == -1)) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return LocType.get(overrideTypeIDs[value]);
|
return LocType.get(overrideTypeIDs[value]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+476
-476
File diff suppressed because it is too large.
Load diff
+56
-56
@@ -4,64 +4,64 @@
|
|||||||
|
|
||||||
public class MapUtil {
|
public class MapUtil {
|
||||||
|
|
||||||
public static int rotateX(int x, int z, int rotation) {
|
public static int rotateX(int x, int z, int rotation) {
|
||||||
rotation &= 3;
|
rotation &= 3;
|
||||||
if (rotation == 0) {
|
if (rotation == 0) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
if (rotation == 1) {
|
if (rotation == 1) {
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
if (rotation == 2) {
|
if (rotation == 2) {
|
||||||
return 7 - x;
|
return 7 - x;
|
||||||
} else {
|
} else {
|
||||||
return 7 - z;
|
return 7 - z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int rotateZ(int x, int z, int rotation) {
|
public static int rotateZ(int x, int z, int rotation) {
|
||||||
rotation &= 3;
|
rotation &= 3;
|
||||||
if (rotation == 0) {
|
if (rotation == 0) {
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
if (rotation == 1) {
|
if (rotation == 1) {
|
||||||
return 7 - x;
|
return 7 - x;
|
||||||
}
|
}
|
||||||
if (rotation == 2) {
|
if (rotation == 2) {
|
||||||
return 7 - z;
|
return 7 - z;
|
||||||
} else {
|
} else {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int rotateLocX(int x, int z, int sizeX, int sizeZ, int rotation) {
|
public static int rotateLocX(int x, int z, int sizeX, int sizeZ, int rotation) {
|
||||||
rotation &= 3;
|
rotation &= 3;
|
||||||
if (rotation == 0) {
|
if (rotation == 0) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
if (rotation == 1) {
|
if (rotation == 1) {
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
if (rotation == 2) {
|
if (rotation == 2) {
|
||||||
return 7 - x - (sizeX - 1);
|
return 7 - x - (sizeX - 1);
|
||||||
} else {
|
} else {
|
||||||
return 7 - z - (sizeZ - 1);
|
return 7 - z - (sizeZ - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int rotateLocZ(int x, int z, int sizeX, int sizeZ, int rotation) {
|
public static int rotateLocZ(int x, int z, int sizeX, int sizeZ, int rotation) {
|
||||||
rotation &= 3;
|
rotation &= 3;
|
||||||
if (rotation == 0) {
|
if (rotation == 0) {
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
if (rotation == 1) {
|
if (rotation == 1) {
|
||||||
return 7 - x - (sizeX - 1);
|
return 7 - x - (sizeX - 1);
|
||||||
}
|
}
|
||||||
if (rotation == 2) {
|
if (rotation == 2) {
|
||||||
return 7 - z - (sizeZ - 1);
|
return 7 - z - (sizeZ - 1);
|
||||||
} else {
|
} else {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+2455
-2455
File diff suppressed because it is too large.
Load diff
@@ -4,32 +4,32 @@
|
|||||||
|
|
||||||
public class MouseRecorder implements Runnable {
|
public class MouseRecorder implements Runnable {
|
||||||
|
|
||||||
public final Object lock = new Object();
|
public final Object lock = new Object();
|
||||||
public final Game game;
|
public final Game game;
|
||||||
public final int[] y = new int[500];
|
public final int[] y = new int[500];
|
||||||
public final int[] x = new int[500];
|
public final int[] x = new int[500];
|
||||||
public boolean active = true;
|
public boolean active = true;
|
||||||
public int length;
|
public int length;
|
||||||
|
|
||||||
public MouseRecorder(Game game) {
|
public MouseRecorder(Game game) {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (active) {
|
while (active) {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
if (length < 500) {
|
if (length < 500) {
|
||||||
x[length] = game.mouseX;
|
x[length] = game.mouseX;
|
||||||
y[length] = game.mouseY;
|
y[length] = game.mouseY;
|
||||||
length++;
|
length++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Thread.sleep(50L);
|
Thread.sleep(50L);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,76 +4,76 @@
|
|||||||
|
|
||||||
public class NPCEntity extends PathingEntity {
|
public class NPCEntity extends PathingEntity {
|
||||||
|
|
||||||
public NPCType type;
|
public NPCType type;
|
||||||
|
|
||||||
public NPCEntity() {
|
public NPCEntity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Model getSequencedModel() {
|
public Model getSequencedModel() {
|
||||||
if ((super.primarySeqID >= 0) && (super.primarySeqDelay == 0)) {
|
if ((super.primarySeqID >= 0) && (super.primarySeqDelay == 0)) {
|
||||||
int primaryTransformID = SeqType.instances[super.primarySeqID].transformIDs[super.primarySeqFrame];
|
int primaryTransformID = SeqType.instances[super.primarySeqID].transformIDs[super.primarySeqFrame];
|
||||||
int secondaryTransformID = -1;
|
int secondaryTransformID = -1;
|
||||||
if ((super.secondarySeqID >= 0) && (super.secondarySeqID != super.seqStandID)) {
|
if ((super.secondarySeqID >= 0) && (super.secondarySeqID != super.seqStandID)) {
|
||||||
secondaryTransformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
|
secondaryTransformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
|
||||||
}
|
}
|
||||||
return type.getSequencedModel(secondaryTransformID, primaryTransformID, SeqType.instances[super.primarySeqID].mask);
|
return type.getSequencedModel(secondaryTransformID, primaryTransformID, SeqType.instances[super.primarySeqID].mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
int transformID = -1;
|
int transformID = -1;
|
||||||
|
|
||||||
if (super.secondarySeqID >= 0) {
|
if (super.secondarySeqID >= 0) {
|
||||||
transformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
|
transformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
|
||||||
}
|
}
|
||||||
|
|
||||||
return type.getSequencedModel(-1, transformID, null);
|
return type.getSequencedModel(-1, transformID, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Model getModel() {
|
public Model getModel() {
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Model model = getSequencedModel();
|
Model model = getSequencedModel();
|
||||||
|
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
super.height = model.minY;
|
super.height = model.minY;
|
||||||
|
|
||||||
if ((super.spotanimID != -1) && (super.spotanimFrame != -1)) {
|
if ((super.spotanimID != -1) && (super.spotanimFrame != -1)) {
|
||||||
SpotAnimType spotanim = SpotAnimType.instances[super.spotanimID];
|
SpotAnimType spotanim = SpotAnimType.instances[super.spotanimID];
|
||||||
Model model0 = spotanim.getModel();
|
Model model0 = spotanim.getModel();
|
||||||
|
|
||||||
if (model0 != null) {
|
if (model0 != null) {
|
||||||
int transformID = spotanim.seq.transformIDs[super.spotanimFrame];
|
int transformID = spotanim.seq.transformIDs[super.spotanimFrame];
|
||||||
|
|
||||||
// create a copy of the model
|
// create a copy of the model
|
||||||
Model model1 = new Model(true, SeqTransform.isNull(transformID), false, model0);
|
Model model1 = new Model(true, SeqTransform.isNull(transformID), false, model0);
|
||||||
model1.translate(0, -super.spotanimOffset, 0);
|
model1.translate(0, -super.spotanimOffset, 0);
|
||||||
model1.createLabelReferences();
|
model1.createLabelReferences();
|
||||||
model1.applyTransform(transformID);
|
model1.applyTransform(transformID);
|
||||||
model1.labelFaces = null;
|
model1.labelFaces = null;
|
||||||
model1.labelVertices = null;
|
model1.labelVertices = null;
|
||||||
|
|
||||||
if ((spotanim.scaleXY != 128) || (spotanim.scaleZ != 128)) {
|
if ((spotanim.scaleXY != 128) || (spotanim.scaleZ != 128)) {
|
||||||
model1.scale(spotanim.scaleXY, spotanim.scaleXY, spotanim.scaleZ);
|
model1.scale(spotanim.scaleXY, spotanim.scaleXY, spotanim.scaleZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
model1.calculateNormals(64 + spotanim.lightAmbient, 850 + spotanim.lightAttenuation, -30, -50, -30, true);
|
model1.calculateNormals(64 + spotanim.lightAmbient, 850 + spotanim.lightAttenuation, -30, -50, -30, true);
|
||||||
model = new Model(2, -819, new Model[]{model, model1});
|
model = new Model(2, -819, new Model[]{model, model1});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type.size == 1) {
|
if (type.size == 1) {
|
||||||
model.pickable = true;
|
model.pickable = true;
|
||||||
}
|
}
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisible() {
|
public boolean isVisible() {
|
||||||
return type != null;
|
return type != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,16 +4,16 @@
|
|||||||
|
|
||||||
public class ObjEntity extends Entity {
|
public class ObjEntity extends Entity {
|
||||||
|
|
||||||
public int id;
|
public int id;
|
||||||
public int count;
|
public int count;
|
||||||
|
|
||||||
public ObjEntity() {
|
public ObjEntity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Model getModel() {
|
public Model getModel() {
|
||||||
ObjType type = ObjType.get(id);
|
ObjType type = ObjType.get(id);
|
||||||
return type.getModel(count);
|
return type.getModel(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+696
-696
File diff suppressed because it is too large.
Load diff
@@ -2,19 +2,19 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
public class OnDemandRequest extends DoublyLinkedList.Node {
|
public class OnDemandRequest extends DoublyLinkedList.Node {
|
||||||
|
|
||||||
public int store;
|
public int store;
|
||||||
public int file;
|
public int file;
|
||||||
public boolean important;
|
public boolean important;
|
||||||
public int cycle;
|
public int cycle;
|
||||||
public byte[] data;
|
public byte[] data;
|
||||||
|
|
||||||
public OnDemandRequest() {
|
public OnDemandRequest() {
|
||||||
important = true;
|
important = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "OnDemandRequest{" + "store=" + store + ", file=" + file + ", priority=" + important + ", cycle=" + cycle + ", data=" + Arrays.toString(data) + '}';
|
return "OnDemandRequest{" + "store=" + store + ", file=" + file + ", priority=" + important + ", cycle=" + cycle + ", data=" + Arrays.toString(data) + '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+145
-145
@@ -1,152 +1,152 @@
|
|||||||
public final class PacketIn {
|
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
|
// 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[] SIZE = new int[256];
|
||||||
|
|
||||||
public static final int CAM_LOOKAT = 177;
|
public static final int CAM_LOOKAT = 177;
|
||||||
public static final int CAM_RESET = 107;
|
public static final int CAM_RESET = 107;
|
||||||
public static final int CAM_SETPOS = 166;
|
public static final int CAM_SETPOS = 166;
|
||||||
public static final int CAM_SHAKE = 35;
|
public static final int CAM_SHAKE = 35;
|
||||||
public static final int IF_CHAT = 164;
|
public static final int IF_CHAT = 164;
|
||||||
public static final int IF_CHAT_STICKY = 218;
|
public static final int IF_CHAT_STICKY = 218;
|
||||||
public static final int CHAT_FILTER_SETTINGS = 206;
|
public static final int CHAT_FILTER_SETTINGS = 206;
|
||||||
public static final int CLEAR_MAP_FLAG = 78;
|
public static final int CLEAR_MAP_FLAG = 78;
|
||||||
public static final int FRIENDLIST_LOADED = 221;
|
public static final int FRIENDLIST_LOADED = 221;
|
||||||
public static final int FRIEND_STATUS = 50;
|
public static final int FRIEND_STATUS = 50;
|
||||||
public static final int HINT_ARROW = 254;
|
public static final int HINT_ARROW = 254;
|
||||||
public static final int IF_CLOSE = 219;
|
public static final int IF_CLOSE = 219;
|
||||||
public static final int IF_SETANGLE = 230;
|
public static final int IF_SETANGLE = 230;
|
||||||
public static final int IF_SETANIM = 200;
|
public static final int IF_SETANIM = 200;
|
||||||
public static final int IF_SETCOLOR = 122;
|
public static final int IF_SETCOLOR = 122;
|
||||||
public static final int IF_SETHIDE = 171;
|
public static final int IF_SETHIDE = 171;
|
||||||
public static final int IF_SETMODEL = 8;
|
public static final int IF_SETMODEL = 8;
|
||||||
public static final int IF_SETNPCHEAD = 75;
|
public static final int IF_SETNPCHEAD = 75;
|
||||||
public static final int IF_SETOBJECT = 246;
|
public static final int IF_SETOBJECT = 246;
|
||||||
public static final int IF_SETPLAYERHEAD = 185;
|
public static final int IF_SETPLAYERHEAD = 185;
|
||||||
public static final int IF_SETPOSITION = 70;
|
public static final int IF_SETPOSITION = 70;
|
||||||
public static final int IF_SETSCROLLPOS = 79;
|
public static final int IF_SETSCROLLPOS = 79;
|
||||||
public static final int IF_SETTEXT = 126;
|
public static final int IF_SETTEXT = 126;
|
||||||
public static final int IF_STOPANIM = 142;
|
public static final int IF_STOPANIM = 142;
|
||||||
public static final int IF_VIEWPORT = 97;
|
public static final int IF_VIEWPORT = 97;
|
||||||
public static final int IF_VIEWPORT_AND_SIDEBAR = 248;
|
public static final int IF_VIEWPORT_AND_SIDEBAR = 248;
|
||||||
public static final int IF_VIEWPORT_OVERLAY = 208;
|
public static final int IF_VIEWPORT_OVERLAY = 208;
|
||||||
public static final int IGNORE_LIST = 214;
|
public static final int IGNORE_LIST = 214;
|
||||||
public static final int INPUT_AMOUNT = 27;
|
public static final int INPUT_AMOUNT = 27;
|
||||||
public static final int INPUT_NAME = 187;
|
public static final int INPUT_NAME = 187;
|
||||||
public static final int INV_CLEAR = 72;
|
public static final int INV_CLEAR = 72;
|
||||||
public static final int LAST_LOGIN_INFO = 176;
|
public static final int LAST_LOGIN_INFO = 176;
|
||||||
public static final int LOCAL_PLAYER = 249;
|
public static final int LOCAL_PLAYER = 249;
|
||||||
public static final int LOC_ADD = 151;
|
public static final int LOC_ADD = 151;
|
||||||
public static final int LOC_CHANGE = 160;
|
public static final int LOC_CHANGE = 160;
|
||||||
public static final int LOC_DEL = 101;
|
public static final int LOC_DEL = 101;
|
||||||
public static final int LOGOUT = 109;
|
public static final int LOGOUT = 109;
|
||||||
public static final int MESSAGE_GAME = 253;
|
public static final int MESSAGE_GAME = 253;
|
||||||
public static final int MESSAGE_PUBLIC = 196;
|
public static final int MESSAGE_PUBLIC = 196;
|
||||||
public static final int MIDI_JINGLE = 121;
|
public static final int MIDI_JINGLE = 121;
|
||||||
public static final int MIDI_SONG = 74;
|
public static final int MIDI_SONG = 74;
|
||||||
public static final int MINIMAP_TOGGLE = 99;
|
public static final int MINIMAP_TOGGLE = 99;
|
||||||
public static final int MULTIZONE = 61;
|
public static final int MULTIZONE = 61;
|
||||||
public static final int OBJ_ADD = 44;
|
public static final int OBJ_ADD = 44;
|
||||||
public static final int OBJ_COUNT = 84;
|
public static final int OBJ_COUNT = 84;
|
||||||
public static final int OBJ_DEL = 156;
|
public static final int OBJ_DEL = 156;
|
||||||
public static final int OBJ_REVEAL = 215;
|
public static final int OBJ_REVEAL = 215;
|
||||||
public static final int LOC_PLAYER = 147;
|
public static final int LOC_PLAYER = 147;
|
||||||
public static final int MAP_PROJECTILE = 117;
|
public static final int MAP_PROJECTILE = 117;
|
||||||
public static final int REBUILD_REGION = 73;
|
public static final int REBUILD_REGION = 73;
|
||||||
public static final int REBUILD_REGION_INSTANCE = 241;
|
public static final int REBUILD_REGION_INSTANCE = 241;
|
||||||
public static final int RESET_ANIMS = 1;
|
public static final int RESET_ANIMS = 1;
|
||||||
public static final int RESET_CLIENT_VARCACHE = 68;
|
public static final int RESET_CLIENT_VARCACHE = 68;
|
||||||
public static final int SET_PLAYER_OP = 104;
|
public static final int SET_PLAYER_OP = 104;
|
||||||
public static final int MAP_SOUND = 105;
|
public static final int MAP_SOUND = 105;
|
||||||
public static final int MAP_ANIM = 4;
|
public static final int MAP_ANIM = 4;
|
||||||
public static final int SYNC_NPCS = 65;
|
public static final int SYNC_NPCS = 65;
|
||||||
public static final int SYNC_PLAYERS = 81;
|
public static final int SYNC_PLAYERS = 81;
|
||||||
public static final int SYNTH_SOUND = 174;
|
public static final int SYNTH_SOUND = 174;
|
||||||
public static final int IF_TAB = 71;
|
public static final int IF_TAB = 71;
|
||||||
public static final int TAB_HINT = 24;
|
public static final int TAB_HINT = 24;
|
||||||
public static final int TAB_SELECTED = 106;
|
public static final int TAB_SELECTED = 106;
|
||||||
public static final int UPDATE_INV_FULL = 53;
|
public static final int UPDATE_INV_FULL = 53;
|
||||||
public static final int UPDATE_INV_PARTIAL = 34;
|
public static final int UPDATE_INV_PARTIAL = 34;
|
||||||
public static final int UPDATE_REBOOT_TIMER = 114;
|
public static final int UPDATE_REBOOT_TIMER = 114;
|
||||||
public static final int UPDATE_RUNENERGY = 110;
|
public static final int UPDATE_RUNENERGY = 110;
|
||||||
public static final int UPDATE_RUNWEIGHT = 240;
|
public static final int UPDATE_RUNWEIGHT = 240;
|
||||||
public static final int UPDATE_STAT = 134;
|
public static final int UPDATE_STAT = 134;
|
||||||
public static final int VARP_LARGE = 87;
|
public static final int VARP_LARGE = 87;
|
||||||
public static final int VARP_SMALL = 36;
|
public static final int VARP_SMALL = 36;
|
||||||
public static final int ZONE_BASE = 85;
|
public static final int ZONE_BASE = 85;
|
||||||
public static final int ZONE_CLEAR = 64;
|
public static final int ZONE_CLEAR = 64;
|
||||||
public static final int ZONE_UPDATE = 60;
|
public static final int ZONE_UPDATE = 60;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SIZE[MAP_ANIM] = 6;
|
SIZE[MAP_ANIM] = 6;
|
||||||
SIZE[IF_SETMODEL] = 4;
|
SIZE[IF_SETMODEL] = 4;
|
||||||
SIZE[TAB_HINT] = 1;
|
SIZE[TAB_HINT] = 1;
|
||||||
SIZE[UPDATE_INV_PARTIAL] = -2;
|
SIZE[UPDATE_INV_PARTIAL] = -2;
|
||||||
SIZE[CAM_SHAKE] = 4;
|
SIZE[CAM_SHAKE] = 4;
|
||||||
SIZE[VARP_SMALL] = 3;
|
SIZE[VARP_SMALL] = 3;
|
||||||
SIZE[OBJ_ADD] = 5;
|
SIZE[OBJ_ADD] = 5;
|
||||||
SIZE[47] = 6;
|
SIZE[47] = 6;
|
||||||
SIZE[FRIEND_STATUS] = 9;
|
SIZE[FRIEND_STATUS] = 9;
|
||||||
SIZE[UPDATE_INV_FULL] = -2;
|
SIZE[UPDATE_INV_FULL] = -2;
|
||||||
SIZE[ZONE_UPDATE] = -2;
|
SIZE[ZONE_UPDATE] = -2;
|
||||||
SIZE[MULTIZONE] = 1;
|
SIZE[MULTIZONE] = 1;
|
||||||
SIZE[ZONE_CLEAR] = 2;
|
SIZE[ZONE_CLEAR] = 2;
|
||||||
SIZE[SYNC_NPCS] = -2;
|
SIZE[SYNC_NPCS] = -2;
|
||||||
SIZE[IF_SETPOSITION] = 6;
|
SIZE[IF_SETPOSITION] = 6;
|
||||||
SIZE[IF_TAB] = 3;
|
SIZE[IF_TAB] = 3;
|
||||||
SIZE[INV_CLEAR] = 2;
|
SIZE[INV_CLEAR] = 2;
|
||||||
SIZE[REBUILD_REGION] = 4;
|
SIZE[REBUILD_REGION] = 4;
|
||||||
SIZE[MIDI_SONG] = 2;
|
SIZE[MIDI_SONG] = 2;
|
||||||
SIZE[IF_SETNPCHEAD] = 4;
|
SIZE[IF_SETNPCHEAD] = 4;
|
||||||
SIZE[IF_SETSCROLLPOS] = 4;
|
SIZE[IF_SETSCROLLPOS] = 4;
|
||||||
SIZE[SYNC_PLAYERS] = -2;
|
SIZE[SYNC_PLAYERS] = -2;
|
||||||
SIZE[OBJ_COUNT] = 7;
|
SIZE[OBJ_COUNT] = 7;
|
||||||
SIZE[ZONE_BASE] = 2;
|
SIZE[ZONE_BASE] = 2;
|
||||||
SIZE[VARP_LARGE] = 6;
|
SIZE[VARP_LARGE] = 6;
|
||||||
SIZE[IF_VIEWPORT] = 2;
|
SIZE[IF_VIEWPORT] = 2;
|
||||||
SIZE[MINIMAP_TOGGLE] = 1;
|
SIZE[MINIMAP_TOGGLE] = 1;
|
||||||
SIZE[LOC_DEL] = 2;
|
SIZE[LOC_DEL] = 2;
|
||||||
SIZE[SET_PLAYER_OP] = -1;
|
SIZE[SET_PLAYER_OP] = -1;
|
||||||
SIZE[MAP_SOUND] = 4;
|
SIZE[MAP_SOUND] = 4;
|
||||||
SIZE[TAB_SELECTED] = 1;
|
SIZE[TAB_SELECTED] = 1;
|
||||||
SIZE[UPDATE_RUNENERGY] = 1;
|
SIZE[UPDATE_RUNENERGY] = 1;
|
||||||
SIZE[UPDATE_REBOOT_TIMER] = 2;
|
SIZE[UPDATE_REBOOT_TIMER] = 2;
|
||||||
SIZE[MAP_PROJECTILE] = 15;
|
SIZE[MAP_PROJECTILE] = 15;
|
||||||
SIZE[MIDI_JINGLE] = 4;
|
SIZE[MIDI_JINGLE] = 4;
|
||||||
SIZE[IF_SETCOLOR] = 4;
|
SIZE[IF_SETCOLOR] = 4;
|
||||||
SIZE[IF_SETTEXT] = -2;
|
SIZE[IF_SETTEXT] = -2;
|
||||||
SIZE[UPDATE_STAT] = 6;
|
SIZE[UPDATE_STAT] = 6;
|
||||||
SIZE[IF_STOPANIM] = 2;
|
SIZE[IF_STOPANIM] = 2;
|
||||||
SIZE[LOC_PLAYER] = 14;
|
SIZE[LOC_PLAYER] = 14;
|
||||||
SIZE[LOC_ADD] = 4;
|
SIZE[LOC_ADD] = 4;
|
||||||
SIZE[OBJ_DEL] = 3;
|
SIZE[OBJ_DEL] = 3;
|
||||||
SIZE[LOC_CHANGE] = 4;
|
SIZE[LOC_CHANGE] = 4;
|
||||||
SIZE[IF_CHAT] = 2;
|
SIZE[IF_CHAT] = 2;
|
||||||
SIZE[CAM_SETPOS] = 6;
|
SIZE[CAM_SETPOS] = 6;
|
||||||
SIZE[IF_SETHIDE] = 3;
|
SIZE[IF_SETHIDE] = 3;
|
||||||
SIZE[SYNTH_SOUND] = 5;
|
SIZE[SYNTH_SOUND] = 5;
|
||||||
SIZE[LAST_LOGIN_INFO] = 10;
|
SIZE[LAST_LOGIN_INFO] = 10;
|
||||||
SIZE[CAM_LOOKAT] = 6;
|
SIZE[CAM_LOOKAT] = 6;
|
||||||
SIZE[IF_SETPLAYERHEAD] = 2;
|
SIZE[IF_SETPLAYERHEAD] = 2;
|
||||||
SIZE[MESSAGE_PUBLIC] = -1;
|
SIZE[MESSAGE_PUBLIC] = -1;
|
||||||
SIZE[IF_SETANIM] = 4;
|
SIZE[IF_SETANIM] = 4;
|
||||||
SIZE[CHAT_FILTER_SETTINGS] = 3;
|
SIZE[CHAT_FILTER_SETTINGS] = 3;
|
||||||
SIZE[IF_VIEWPORT_OVERLAY] = 2;
|
SIZE[IF_VIEWPORT_OVERLAY] = 2;
|
||||||
SIZE[IGNORE_LIST] = -2;
|
SIZE[IGNORE_LIST] = -2;
|
||||||
SIZE[OBJ_REVEAL] = 7;
|
SIZE[OBJ_REVEAL] = 7;
|
||||||
SIZE[IF_CHAT_STICKY] = 2;
|
SIZE[IF_CHAT_STICKY] = 2;
|
||||||
SIZE[FRIENDLIST_LOADED] = 1;
|
SIZE[FRIENDLIST_LOADED] = 1;
|
||||||
SIZE[IF_SETANGLE] = 8;
|
SIZE[IF_SETANGLE] = 8;
|
||||||
SIZE[UPDATE_RUNWEIGHT] = 2;
|
SIZE[UPDATE_RUNWEIGHT] = 2;
|
||||||
SIZE[REBUILD_REGION_INSTANCE] = -2;
|
SIZE[REBUILD_REGION_INSTANCE] = -2;
|
||||||
SIZE[IF_SETOBJECT] = 6;
|
SIZE[IF_SETOBJECT] = 6;
|
||||||
SIZE[IF_VIEWPORT_AND_SIDEBAR] = 4;
|
SIZE[IF_VIEWPORT_AND_SIDEBAR] = 4;
|
||||||
SIZE[LOCAL_PLAYER] = 3;
|
SIZE[LOCAL_PLAYER] = 3;
|
||||||
SIZE[MESSAGE_GAME] = -1;
|
SIZE[MESSAGE_GAME] = -1;
|
||||||
SIZE[HINT_ARROW] = 6;
|
SIZE[HINT_ARROW] = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PacketIn() {
|
private PacketIn() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+411
-411
@@ -6,416 +6,416 @@ import org.apache.commons.collections4.map.LRUMap;
|
|||||||
|
|
||||||
public class PlayerEntity extends PathingEntity {
|
public class PlayerEntity extends PathingEntity {
|
||||||
|
|
||||||
public static LRUMap<Long, Model> modelCache = new LRUMap<>(260);
|
public static LRUMap<Long, Model> modelCache = new LRUMap<>(260);
|
||||||
public final int[] colors = new int[5];
|
public final int[] colors = new int[5];
|
||||||
public final int[] appearances = new int[12];
|
public final int[] appearances = new int[12];
|
||||||
public long modelUID = -1L;
|
public long modelUID = -1L;
|
||||||
public NPCType transmogrify;
|
public NPCType transmogrify;
|
||||||
public boolean lowmem = false;
|
public boolean lowmem = false;
|
||||||
public int team;
|
public int team;
|
||||||
public int gender;
|
public int gender;
|
||||||
public String name;
|
public String name;
|
||||||
public int combatLevel;
|
public int combatLevel;
|
||||||
public int headicons;
|
public int headicons;
|
||||||
public int locStartCycle;
|
public int locStartCycle;
|
||||||
public int locStopCycle;
|
public int locStopCycle;
|
||||||
public int y;
|
public int y;
|
||||||
public boolean visible = false;
|
public boolean visible = false;
|
||||||
public int locOffsetX;
|
public int locOffsetX;
|
||||||
public int locOffsetY;
|
public int locOffsetY;
|
||||||
public int locOffsetZ;
|
public int locOffsetZ;
|
||||||
public Model locModel;
|
public Model locModel;
|
||||||
public long appearanceHashcode;
|
public long appearanceHashcode;
|
||||||
public int minSceneTileX;
|
public int minSceneTileX;
|
||||||
public int minSceneTileZ;
|
public int minSceneTileZ;
|
||||||
public int maxSceneTileX;
|
public int maxSceneTileX;
|
||||||
public int maxSceneTileZ;
|
public int maxSceneTileZ;
|
||||||
public int skillLevel;
|
public int skillLevel;
|
||||||
|
|
||||||
public PlayerEntity() {
|
public PlayerEntity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Model getModel() {
|
public Model getModel() {
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Model model = getSequencedModel();
|
Model model = getSequencedModel();
|
||||||
|
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
super.height = model.minY;
|
super.height = model.minY;
|
||||||
model.pickable = true;
|
model.pickable = true;
|
||||||
|
|
||||||
if (lowmem) {
|
if (lowmem) {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((super.spotanimID != -1) && (super.spotanimFrame != -1)) {
|
if ((super.spotanimID != -1) && (super.spotanimFrame != -1)) {
|
||||||
SpotAnimType spot = SpotAnimType.instances[super.spotanimID];
|
SpotAnimType spot = SpotAnimType.instances[super.spotanimID];
|
||||||
Model spotModel1 = spot.getModel();
|
Model spotModel1 = spot.getModel();
|
||||||
|
|
||||||
if (spotModel1 != null) {
|
if (spotModel1 != null) {
|
||||||
Model spotModel2 = new Model(true, SeqTransform.isNull(super.spotanimFrame), false, spotModel1);
|
Model spotModel2 = new Model(true, SeqTransform.isNull(super.spotanimFrame), false, spotModel1);
|
||||||
spotModel2.translate(0, -super.spotanimOffset, 0);
|
spotModel2.translate(0, -super.spotanimOffset, 0);
|
||||||
spotModel2.createLabelReferences();
|
spotModel2.createLabelReferences();
|
||||||
spotModel2.applyTransform(spot.seq.transformIDs[super.spotanimFrame]);
|
spotModel2.applyTransform(spot.seq.transformIDs[super.spotanimFrame]);
|
||||||
spotModel2.labelFaces = null;
|
spotModel2.labelFaces = null;
|
||||||
spotModel2.labelVertices = null;
|
spotModel2.labelVertices = null;
|
||||||
if ((spot.scaleXY != 128) || (spot.scaleZ != 128)) {
|
if ((spot.scaleXY != 128) || (spot.scaleZ != 128)) {
|
||||||
spotModel2.scale(spot.scaleXY, spot.scaleXY, spot.scaleZ);
|
spotModel2.scale(spot.scaleXY, spot.scaleXY, spot.scaleZ);
|
||||||
}
|
}
|
||||||
spotModel2.calculateNormals(64 + spot.lightAmbient, 850 + spot.lightAttenuation, -30, -50, -30, true);
|
spotModel2.calculateNormals(64 + spot.lightAmbient, 850 + spot.lightAttenuation, -30, -50, -30, true);
|
||||||
model = new Model(2, -819, new Model[]{model, spotModel2});
|
model = new Model(2, -819, new Model[]{model, spotModel2});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.locModel != null) {
|
if (this.locModel != null) {
|
||||||
if (Game.loopCycle >= locStopCycle) {
|
if (Game.loopCycle >= locStopCycle) {
|
||||||
this.locModel = null;
|
this.locModel = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Game.loopCycle >= locStartCycle) && (Game.loopCycle < locStopCycle)) {
|
if ((Game.loopCycle >= locStartCycle) && (Game.loopCycle < locStopCycle)) {
|
||||||
Model locModel = this.locModel;
|
Model locModel = this.locModel;
|
||||||
locModel.translate(locOffsetX - super.x, locOffsetY - y, locOffsetZ - super.z);
|
locModel.translate(locOffsetX - super.x, locOffsetY - y, locOffsetZ - super.z);
|
||||||
|
|
||||||
if (super.dstYaw == 512) {
|
if (super.dstYaw == 512) {
|
||||||
locModel.rotateY90();
|
locModel.rotateY90();
|
||||||
locModel.rotateY90();
|
locModel.rotateY90();
|
||||||
locModel.rotateY90();
|
locModel.rotateY90();
|
||||||
} else if (super.dstYaw == 1024) {
|
} else if (super.dstYaw == 1024) {
|
||||||
locModel.rotateY90();
|
locModel.rotateY90();
|
||||||
locModel.rotateY90();
|
locModel.rotateY90();
|
||||||
} else if (super.dstYaw == 1536) {
|
} else if (super.dstYaw == 1536) {
|
||||||
locModel.rotateY90();
|
locModel.rotateY90();
|
||||||
}
|
}
|
||||||
|
|
||||||
model = new Model(2, -819, new Model[]{model, locModel});
|
model = new Model(2, -819, new Model[]{model, locModel});
|
||||||
|
|
||||||
if (super.dstYaw == 512) {
|
if (super.dstYaw == 512) {
|
||||||
locModel.rotateY90();
|
locModel.rotateY90();
|
||||||
} else if (super.dstYaw == 1024) {
|
} else if (super.dstYaw == 1024) {
|
||||||
locModel.rotateY90();
|
locModel.rotateY90();
|
||||||
locModel.rotateY90();
|
locModel.rotateY90();
|
||||||
} else if (super.dstYaw == 1536) {
|
} else if (super.dstYaw == 1536) {
|
||||||
locModel.rotateY90();
|
locModel.rotateY90();
|
||||||
locModel.rotateY90();
|
locModel.rotateY90();
|
||||||
locModel.rotateY90();
|
locModel.rotateY90();
|
||||||
}
|
}
|
||||||
|
|
||||||
locModel.translate(super.x - locOffsetX, y - locOffsetY, super.z - locOffsetZ);
|
locModel.translate(super.x - locOffsetX, y - locOffsetY, super.z - locOffsetZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
model.pickable = true;
|
model.pickable = true;
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(Buffer buffer) {
|
public void read(Buffer buffer) {
|
||||||
buffer.position = 0;
|
buffer.position = 0;
|
||||||
gender = buffer.read8U();
|
gender = buffer.read8U();
|
||||||
headicons = buffer.read8U();
|
headicons = buffer.read8U();
|
||||||
transmogrify = null;
|
transmogrify = null;
|
||||||
team = 0;
|
team = 0;
|
||||||
|
|
||||||
for (int part = 0; part < 12; part++) {
|
for (int part = 0; part < 12; part++) {
|
||||||
int msb = buffer.read8U();
|
int msb = buffer.read8U();
|
||||||
|
|
||||||
if (msb == 0) {
|
if (msb == 0) {
|
||||||
appearances[part] = 0;
|
appearances[part] = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lsb = buffer.read8U();
|
int lsb = buffer.read8U();
|
||||||
appearances[part] = (msb << 8) + lsb;
|
appearances[part] = (msb << 8) + lsb;
|
||||||
|
|
||||||
if ((part == 0) && (appearances[0] == 65535)) {
|
if ((part == 0) && (appearances[0] == 65535)) {
|
||||||
transmogrify = NPCType.get(buffer.read16U());
|
transmogrify = NPCType.get(buffer.read16U());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((appearances[part] >= 512) && ((appearances[part] - 512) < ObjType.count)) {
|
if ((appearances[part] >= 512) && ((appearances[part] - 512) < ObjType.count)) {
|
||||||
int team = ObjType.get(appearances[part] - 512).team;
|
int team = ObjType.get(appearances[part] - 512).team;
|
||||||
|
|
||||||
if (team != 0) {
|
if (team != 0) {
|
||||||
this.team = team;
|
this.team = team;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int part = 0; part < 5; part++) {
|
for (int part = 0; part < 5; part++) {
|
||||||
int color = buffer.read8U();
|
int color = buffer.read8U();
|
||||||
|
|
||||||
if ((color < 0) || (color >= Game.designPartColor[part].length)) {
|
if ((color < 0) || (color >= Game.designPartColor[part].length)) {
|
||||||
color = 0;
|
color = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
colors[part] = color;
|
colors[part] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
super.seqStandID = buffer.read16U();
|
super.seqStandID = buffer.read16U();
|
||||||
if (super.seqStandID == 65535) {
|
if (super.seqStandID == 65535) {
|
||||||
super.seqStandID = -1;
|
super.seqStandID = -1;
|
||||||
}
|
}
|
||||||
super.seqTurnID = buffer.read16U();
|
super.seqTurnID = buffer.read16U();
|
||||||
if (super.seqTurnID == 65535) {
|
if (super.seqTurnID == 65535) {
|
||||||
super.seqTurnID = -1;
|
super.seqTurnID = -1;
|
||||||
}
|
}
|
||||||
super.seqWalkID = buffer.read16U();
|
super.seqWalkID = buffer.read16U();
|
||||||
if (super.seqWalkID == 65535) {
|
if (super.seqWalkID == 65535) {
|
||||||
super.seqWalkID = -1;
|
super.seqWalkID = -1;
|
||||||
}
|
}
|
||||||
super.seqTurnAroundID = buffer.read16U();
|
super.seqTurnAroundID = buffer.read16U();
|
||||||
if (super.seqTurnAroundID == 65535) {
|
if (super.seqTurnAroundID == 65535) {
|
||||||
super.seqTurnAroundID = -1;
|
super.seqTurnAroundID = -1;
|
||||||
}
|
}
|
||||||
super.seqTurnLeftID = buffer.read16U();
|
super.seqTurnLeftID = buffer.read16U();
|
||||||
if (super.seqTurnLeftID == 65535) {
|
if (super.seqTurnLeftID == 65535) {
|
||||||
super.seqTurnLeftID = -1;
|
super.seqTurnLeftID = -1;
|
||||||
}
|
}
|
||||||
super.seqTurnRightID = buffer.read16U();
|
super.seqTurnRightID = buffer.read16U();
|
||||||
if (super.seqTurnRightID == 65535) {
|
if (super.seqTurnRightID == 65535) {
|
||||||
super.seqTurnRightID = -1;
|
super.seqTurnRightID = -1;
|
||||||
}
|
}
|
||||||
super.seqRunID = buffer.read16U();
|
super.seqRunID = buffer.read16U();
|
||||||
if (super.seqRunID == 65535) {
|
if (super.seqRunID == 65535) {
|
||||||
super.seqRunID = -1;
|
super.seqRunID = -1;
|
||||||
}
|
}
|
||||||
name = StringUtil.formatName(StringUtil.fromBase37(buffer.read64()));
|
name = StringUtil.formatName(StringUtil.fromBase37(buffer.read64()));
|
||||||
combatLevel = buffer.read8U();
|
combatLevel = buffer.read8U();
|
||||||
skillLevel = buffer.read16U();
|
skillLevel = buffer.read16U();
|
||||||
visible = true;
|
visible = true;
|
||||||
|
|
||||||
appearanceHashcode = 0L;
|
appearanceHashcode = 0L;
|
||||||
|
|
||||||
for (int part = 0; part < 12; part++) {
|
for (int part = 0; part < 12; part++) {
|
||||||
appearanceHashcode <<= 4;
|
appearanceHashcode <<= 4;
|
||||||
if (appearances[part] >= 256) {
|
if (appearances[part] >= 256) {
|
||||||
appearanceHashcode += appearances[part] - 256;
|
appearanceHashcode += appearances[part] - 256;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appearances[0] >= 256) {
|
if (appearances[0] >= 256) {
|
||||||
appearanceHashcode += (appearances[0] - 256) >> 4;
|
appearanceHashcode += (appearances[0] - 256) >> 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appearances[1] >= 256) {
|
if (appearances[1] >= 256) {
|
||||||
appearanceHashcode += (appearances[1] - 256) >> 8;
|
appearanceHashcode += (appearances[1] - 256) >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i2 = 0; i2 < 5; i2++) {
|
for (int i2 = 0; i2 < 5; i2++) {
|
||||||
appearanceHashcode <<= 3;
|
appearanceHashcode <<= 3;
|
||||||
appearanceHashcode += colors[i2];
|
appearanceHashcode += colors[i2];
|
||||||
}
|
}
|
||||||
|
|
||||||
appearanceHashcode <<= 1;
|
appearanceHashcode <<= 1;
|
||||||
appearanceHashcode += gender;
|
appearanceHashcode += gender;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Model getSequencedModel() {
|
public Model getSequencedModel() {
|
||||||
if (transmogrify != null) {
|
if (transmogrify != null) {
|
||||||
int transformID = -1;
|
int transformID = -1;
|
||||||
if ((super.primarySeqID >= 0) && (super.primarySeqDelay == 0)) {
|
if ((super.primarySeqID >= 0) && (super.primarySeqDelay == 0)) {
|
||||||
transformID = SeqType.instances[super.primarySeqID].transformIDs[super.primarySeqFrame];
|
transformID = SeqType.instances[super.primarySeqID].transformIDs[super.primarySeqFrame];
|
||||||
} else if (super.secondarySeqID >= 0) {
|
} else if (super.secondarySeqID >= 0) {
|
||||||
transformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
|
transformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
|
||||||
}
|
}
|
||||||
return transmogrify.getSequencedModel(-1, transformID, null);
|
return transmogrify.getSequencedModel(-1, transformID, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
long hashCode = this.appearanceHashcode;
|
long hashCode = this.appearanceHashcode;
|
||||||
int primaryTransformID = -1;
|
int primaryTransformID = -1;
|
||||||
int secondaryTransformID = -1;
|
int secondaryTransformID = -1;
|
||||||
int rightHandValue = -1;
|
int rightHandValue = -1;
|
||||||
int leftHandValue = -1;
|
int leftHandValue = -1;
|
||||||
|
|
||||||
if ((super.primarySeqID >= 0) && (super.primarySeqDelay == 0)) {
|
if ((super.primarySeqID >= 0) && (super.primarySeqDelay == 0)) {
|
||||||
SeqType type = SeqType.instances[super.primarySeqID];
|
SeqType type = SeqType.instances[super.primarySeqID];
|
||||||
primaryTransformID = type.transformIDs[super.primarySeqFrame];
|
primaryTransformID = type.transformIDs[super.primarySeqFrame];
|
||||||
|
|
||||||
if ((super.secondarySeqID >= 0) && (super.secondarySeqID != super.seqStandID)) {
|
if ((super.secondarySeqID >= 0) && (super.secondarySeqID != super.seqStandID)) {
|
||||||
secondaryTransformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
|
secondaryTransformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.rightHandOverride >= 0) {
|
if (type.rightHandOverride >= 0) {
|
||||||
rightHandValue = type.rightHandOverride;
|
rightHandValue = type.rightHandOverride;
|
||||||
hashCode += ((long) rightHandValue - appearances[5]) << 8;
|
hashCode += ((long) rightHandValue - appearances[5]) << 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.leftHandOverride >= 0) {
|
if (type.leftHandOverride >= 0) {
|
||||||
leftHandValue = type.leftHandOverride;
|
leftHandValue = type.leftHandOverride;
|
||||||
hashCode += ((long) leftHandValue - appearances[3]) << 16;
|
hashCode += ((long) leftHandValue - appearances[3]) << 16;
|
||||||
}
|
}
|
||||||
} else if (super.secondarySeqID >= 0) {
|
} else if (super.secondarySeqID >= 0) {
|
||||||
primaryTransformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
|
primaryTransformID = SeqType.instances[super.secondarySeqID].transformIDs[super.secondarySeqFrame];
|
||||||
}
|
}
|
||||||
|
|
||||||
Model model = modelCache.get(hashCode);
|
Model model = modelCache.get(hashCode);
|
||||||
|
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
boolean invalid = false;
|
boolean invalid = false;
|
||||||
|
|
||||||
for (int part = 0; part < 12; part++) {
|
for (int part = 0; part < 12; part++) {
|
||||||
int value = appearances[part];
|
int value = appearances[part];
|
||||||
|
|
||||||
if ((leftHandValue >= 0) && (part == 3)) {
|
if ((leftHandValue >= 0) && (part == 3)) {
|
||||||
value = leftHandValue;
|
value = leftHandValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rightHandValue >= 0) && (part == 5)) {
|
if ((rightHandValue >= 0) && (part == 5)) {
|
||||||
value = rightHandValue;
|
value = rightHandValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((value >= 256) && (value < 512) && !IdkType.instances[value - 256].validateModel()) {
|
if ((value >= 256) && (value < 512) && !IdkType.instances[value - 256].validateModel()) {
|
||||||
invalid = true;
|
invalid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((value >= 512) && !ObjType.get(value - 512).validateWornModel(gender)) {
|
if ((value >= 512) && !ObjType.get(value - 512).validateWornModel(gender)) {
|
||||||
invalid = true;
|
invalid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invalid) {
|
if (invalid) {
|
||||||
if (modelUID != -1L) {
|
if (modelUID != -1L) {
|
||||||
model = modelCache.get(modelUID);
|
model = modelCache.get(modelUID);
|
||||||
}
|
}
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
Model[] models = new Model[12];
|
Model[] models = new Model[12];
|
||||||
int modelCount = 0;
|
int modelCount = 0;
|
||||||
|
|
||||||
for (int part = 0; part < 12; part++) {
|
for (int part = 0; part < 12; part++) {
|
||||||
int value = appearances[part];
|
int value = appearances[part];
|
||||||
|
|
||||||
if ((leftHandValue >= 0) && (part == 3)) {
|
if ((leftHandValue >= 0) && (part == 3)) {
|
||||||
value = leftHandValue;
|
value = leftHandValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rightHandValue >= 0) && (part == 5)) {
|
if ((rightHandValue >= 0) && (part == 5)) {
|
||||||
value = rightHandValue;
|
value = rightHandValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((value >= 256) && (value < 512)) {
|
if ((value >= 256) && (value < 512)) {
|
||||||
Model kitModel = IdkType.instances[value - 256].getModel();
|
Model kitModel = IdkType.instances[value - 256].getModel();
|
||||||
if (kitModel != null) {
|
if (kitModel != null) {
|
||||||
models[modelCount++] = kitModel;
|
models[modelCount++] = kitModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value >= 512) {
|
if (value >= 512) {
|
||||||
Model objModel = ObjType.get(value - 512).getWornModel(gender);
|
Model objModel = ObjType.get(value - 512).getWornModel(gender);
|
||||||
|
|
||||||
if (objModel != null) {
|
if (objModel != null) {
|
||||||
models[modelCount++] = objModel;
|
models[modelCount++] = objModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
model = new Model(modelCount, models);
|
model = new Model(modelCount, models);
|
||||||
for (int part = 0; part < 5; part++) {
|
for (int part = 0; part < 5; part++) {
|
||||||
if (colors[part] != 0) {
|
if (colors[part] != 0) {
|
||||||
model.recolor(Game.designPartColor[part][0], Game.designPartColor[part][colors[part]]);
|
model.recolor(Game.designPartColor[part][0], Game.designPartColor[part][colors[part]]);
|
||||||
if (part == 1) {
|
if (part == 1) {
|
||||||
model.recolor(Game.designHairColor[0], Game.designHairColor[colors[part]]);
|
model.recolor(Game.designHairColor[0], Game.designHairColor[colors[part]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
model.createLabelReferences();
|
model.createLabelReferences();
|
||||||
model.calculateNormals(64, 850, -30, -50, -30, true);
|
model.calculateNormals(64, 850, -30, -50, -30, true);
|
||||||
modelCache.put(hashCode, model);
|
modelCache.put(hashCode, model);
|
||||||
modelUID = hashCode;
|
modelUID = hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lowmem) {
|
if (lowmem) {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
Model tmp = Model.EMPTY;
|
Model tmp = Model.EMPTY;
|
||||||
tmp.set(model, SeqTransform.isNull(primaryTransformID) & SeqTransform.isNull(secondaryTransformID));
|
tmp.set(model, SeqTransform.isNull(primaryTransformID) & SeqTransform.isNull(secondaryTransformID));
|
||||||
|
|
||||||
if ((primaryTransformID != -1) && (secondaryTransformID != -1)) {
|
if ((primaryTransformID != -1) && (secondaryTransformID != -1)) {
|
||||||
tmp.applyTransforms(primaryTransformID, secondaryTransformID, SeqType.instances[super.primarySeqID].mask);
|
tmp.applyTransforms(primaryTransformID, secondaryTransformID, SeqType.instances[super.primarySeqID].mask);
|
||||||
} else if (primaryTransformID != -1) {
|
} else if (primaryTransformID != -1) {
|
||||||
tmp.applyTransform(primaryTransformID);
|
tmp.applyTransform(primaryTransformID);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp.calculateBoundsCylinder();
|
tmp.calculateBoundsCylinder();
|
||||||
tmp.labelFaces = null;
|
tmp.labelFaces = null;
|
||||||
tmp.labelVertices = null;
|
tmp.labelVertices = null;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisible() {
|
public boolean isVisible() {
|
||||||
return visible;
|
return visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Model getHeadModel() {
|
public Model getHeadModel() {
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transmogrify != null) {
|
if (transmogrify != null) {
|
||||||
return transmogrify.getHeadModel();
|
return transmogrify.getHeadModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean invalid = false;
|
boolean invalid = false;
|
||||||
|
|
||||||
for (int part = 0; part < 12; part++) {
|
for (int part = 0; part < 12; part++) {
|
||||||
int value = appearances[part];
|
int value = appearances[part];
|
||||||
|
|
||||||
if ((value >= 256) && (value < 512) && !IdkType.instances[value - 256].validateHeadModel()) {
|
if ((value >= 256) && (value < 512) && !IdkType.instances[value - 256].validateHeadModel()) {
|
||||||
invalid = true;
|
invalid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((value >= 512) && !ObjType.get(value - 512).validateHeadModel(gender)) {
|
if ((value >= 512) && !ObjType.get(value - 512).validateHeadModel(gender)) {
|
||||||
invalid = true;
|
invalid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invalid) {
|
if (invalid) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Model[] models = new Model[12];
|
Model[] models = new Model[12];
|
||||||
int modelCount = 0;
|
int modelCount = 0;
|
||||||
for (int part = 0; part < 12; part++) {
|
for (int part = 0; part < 12; part++) {
|
||||||
int value = appearances[part];
|
int value = appearances[part];
|
||||||
|
|
||||||
if ((value >= 256) && (value < 512)) {
|
if ((value >= 256) && (value < 512)) {
|
||||||
Model model = IdkType.instances[value - 256].getHeadModel();
|
Model model = IdkType.instances[value - 256].getHeadModel();
|
||||||
if (model != null) {
|
if (model != null) {
|
||||||
models[modelCount++] = model;
|
models[modelCount++] = model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (value >= 512) {
|
if (value >= 512) {
|
||||||
Model model = ObjType.get(value - 512).getHeadModel(gender);
|
Model model = ObjType.get(value - 512).getHeadModel(gender);
|
||||||
if (model != null) {
|
if (model != null) {
|
||||||
models[modelCount++] = model;
|
models[modelCount++] = model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Model model = new Model(modelCount, models);
|
Model model = new Model(modelCount, models);
|
||||||
|
|
||||||
for (int part = 0; part < 5; part++) {
|
for (int part = 0; part < 5; part++) {
|
||||||
if (colors[part] != 0) {
|
if (colors[part] != 0) {
|
||||||
model.recolor(Game.designPartColor[part][0], Game.designPartColor[part][colors[part]]);
|
model.recolor(Game.designPartColor[part][0], Game.designPartColor[part][colors[part]]);
|
||||||
if (part == 1) {
|
if (part == 1) {
|
||||||
model.recolor(Game.designHairColor[0], Game.designHairColor[colors[part]]);
|
model.recolor(Game.designHairColor[0], Game.designHairColor[colors[part]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,109 +4,109 @@
|
|||||||
|
|
||||||
public class ProjectileEntity extends Entity {
|
public class ProjectileEntity extends Entity {
|
||||||
|
|
||||||
public final int startCycle;
|
public final int startCycle;
|
||||||
public final int lastCycle;
|
public final int lastCycle;
|
||||||
public final int srcX;
|
public final int srcX;
|
||||||
public final int srcZ;
|
public final int srcZ;
|
||||||
public final int srcY;
|
public final int srcY;
|
||||||
public final int offsetY;
|
public final int offsetY;
|
||||||
public final int peakPitch;
|
public final int peakPitch;
|
||||||
public final int arc;
|
public final int arc;
|
||||||
public final int target;
|
public final int target;
|
||||||
public final SpotAnimType spotanim;
|
public final SpotAnimType spotanim;
|
||||||
public final int level;
|
public final int level;
|
||||||
public double velocityX;
|
public double velocityX;
|
||||||
public double velocityZ;
|
public double velocityZ;
|
||||||
public double velocity;
|
public double velocity;
|
||||||
public double velocityY;
|
public double velocityY;
|
||||||
public double accelerationY;
|
public double accelerationY;
|
||||||
public boolean mobile = false;
|
public boolean mobile = false;
|
||||||
public double x;
|
public double x;
|
||||||
public double z;
|
public double z;
|
||||||
public double y;
|
public double y;
|
||||||
public int seqFrame;
|
public int seqFrame;
|
||||||
public int seqCycle;
|
public int seqCycle;
|
||||||
public int yaw;
|
public int yaw;
|
||||||
public int pitch;
|
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) {
|
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.spotanim = SpotAnimType.instances[spotanim];
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.srcX = srcX;
|
this.srcX = srcX;
|
||||||
this.srcZ = srcZ;
|
this.srcZ = srcZ;
|
||||||
this.srcY = srcY;
|
this.srcY = srcY;
|
||||||
this.startCycle = startCycle;
|
this.startCycle = startCycle;
|
||||||
this.lastCycle = lastCycle;
|
this.lastCycle = lastCycle;
|
||||||
this.peakPitch = peakPitch;
|
this.peakPitch = peakPitch;
|
||||||
this.arc = arc;
|
this.arc = arc;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.offsetY = offsetY;
|
this.offsetY = offsetY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateVelocity(int cycle, int dstZ, int dstY, int dstX) {
|
public void updateVelocity(int cycle, int dstZ, int dstY, int dstX) {
|
||||||
if (!mobile) {
|
if (!mobile) {
|
||||||
double dx = dstX - srcX;
|
double dx = dstX - srcX;
|
||||||
double dz = dstZ - srcZ;
|
double dz = dstZ - srcZ;
|
||||||
double d = Math.sqrt((dx * dx) + (dz * dz));
|
double d = Math.sqrt((dx * dx) + (dz * dz));
|
||||||
x = (double) srcX + ((dx * (double) arc) / d);
|
x = (double) srcX + ((dx * (double) arc) / d);
|
||||||
z = (double) srcZ + ((dz * (double) arc) / d);
|
z = (double) srcZ + ((dz * (double) arc) / d);
|
||||||
y = srcY;
|
y = srcY;
|
||||||
}
|
}
|
||||||
double dt = (lastCycle + 1) - cycle;
|
double dt = (lastCycle + 1) - cycle;
|
||||||
velocityX = ((double) dstX - x) / dt;
|
velocityX = ((double) dstX - x) / dt;
|
||||||
velocityZ = ((double) dstZ - z) / dt;
|
velocityZ = ((double) dstZ - z) / dt;
|
||||||
velocity = Math.sqrt((velocityX * velocityX) + (velocityZ * velocityZ));
|
velocity = Math.sqrt((velocityX * velocityX) + (velocityZ * velocityZ));
|
||||||
if (!mobile) {
|
if (!mobile) {
|
||||||
velocityY = -velocity * Math.tan((double) peakPitch * 0.02454369D);
|
velocityY = -velocity * Math.tan((double) peakPitch * 0.02454369D);
|
||||||
}
|
}
|
||||||
accelerationY = (2D * ((double) dstY - y - (velocityY * dt))) / (dt * dt);
|
accelerationY = (2D * ((double) dstY - y - (velocityY * dt))) / (dt * dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Model getModel() {
|
public Model getModel() {
|
||||||
Model tmp = spotanim.getModel();
|
Model tmp = spotanim.getModel();
|
||||||
if (tmp == null) {
|
if (tmp == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
int transformID = -1;
|
int transformID = -1;
|
||||||
|
|
||||||
if (spotanim.seq != null) {
|
if (spotanim.seq != null) {
|
||||||
transformID = spotanim.seq.transformIDs[seqFrame];
|
transformID = spotanim.seq.transformIDs[seqFrame];
|
||||||
}
|
}
|
||||||
|
|
||||||
Model model = new Model(true, SeqTransform.isNull(transformID), false, tmp);
|
Model model = new Model(true, SeqTransform.isNull(transformID), false, tmp);
|
||||||
if (transformID != -1) {
|
if (transformID != -1) {
|
||||||
model.createLabelReferences();
|
model.createLabelReferences();
|
||||||
model.applyTransform(transformID);
|
model.applyTransform(transformID);
|
||||||
model.labelFaces = null;
|
model.labelFaces = null;
|
||||||
model.labelVertices = null;
|
model.labelVertices = null;
|
||||||
}
|
}
|
||||||
if ((spotanim.scaleXY != 128) || (spotanim.scaleZ != 128)) {
|
if ((spotanim.scaleXY != 128) || (spotanim.scaleZ != 128)) {
|
||||||
model.scale(spotanim.scaleXY, spotanim.scaleXY, spotanim.scaleZ);
|
model.scale(spotanim.scaleXY, spotanim.scaleXY, spotanim.scaleZ);
|
||||||
}
|
}
|
||||||
model.rotateX(pitch);
|
model.rotateX(pitch);
|
||||||
model.calculateNormals(64 + spotanim.lightAmbient, 850 + spotanim.lightAttenuation, -30, -50, -30, true);
|
model.calculateNormals(64 + spotanim.lightAmbient, 850 + spotanim.lightAttenuation, -30, -50, -30, true);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(int delta) {
|
public void update(int delta) {
|
||||||
mobile = true;
|
mobile = true;
|
||||||
x += velocityX * (double) delta;
|
x += velocityX * (double) delta;
|
||||||
z += velocityZ * (double) delta;
|
z += velocityZ * (double) delta;
|
||||||
y += (velocityY * (double) delta) + (0.5D * accelerationY * (double) delta * (double) delta);
|
y += (velocityY * (double) delta) + (0.5D * accelerationY * (double) delta * (double) delta);
|
||||||
velocityY += accelerationY * (double) delta;
|
velocityY += accelerationY * (double) delta;
|
||||||
yaw = ((int) (Math.atan2(velocityX, velocityZ) * 325.94900000000001D) + 1024) & 0x7ff;
|
yaw = ((int) (Math.atan2(velocityX, velocityZ) * 325.94900000000001D) + 1024) & 0x7ff;
|
||||||
pitch = (int) (Math.atan2(velocityY, velocity) * 325.94900000000001D) & 0x7ff;
|
pitch = (int) (Math.atan2(velocityY, velocity) * 325.94900000000001D) & 0x7ff;
|
||||||
|
|
||||||
if (spotanim.seq != null) {
|
if (spotanim.seq != null) {
|
||||||
for (seqCycle += delta; seqCycle > spotanim.seq.getFrameDuration(seqFrame); ) {
|
for (seqCycle += delta; seqCycle > spotanim.seq.getFrameDuration(seqFrame); ) {
|
||||||
seqCycle -= spotanim.seq.getFrameDuration(seqFrame) + 1;
|
seqCycle -= spotanim.seq.getFrameDuration(seqFrame) + 1;
|
||||||
seqFrame++;
|
seqFrame++;
|
||||||
if (seqFrame >= spotanim.seq.frameCount) {
|
if (seqFrame >= spotanim.seq.frameCount) {
|
||||||
seqFrame = 0;
|
seqFrame = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1599,8 +1599,8 @@ public class Scene {
|
|||||||
SceneLoc farthest = locBuffer[farthestIndex];
|
SceneLoc farthest = locBuffer[farthestIndex];
|
||||||
farthest.cycle = cycle;
|
farthest.cycle = cycle;
|
||||||
|
|
||||||
if (!occluded(occludeLevel, farthest.minSceneTileX, farthest.maxSceneTileX, farthest.minSceneTileZ, farthest.maxSceneTileZ, farthest.entity.minY)) {
|
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);
|
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++) {
|
for (int x = farthest.minSceneTileX; x <= farthest.maxSceneTileX; x++) {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class SceneBuilder {
|
|||||||
* Used to determine if a LocType's models have been loaded.
|
* Used to determine if a LocType's models have been loaded.
|
||||||
*
|
*
|
||||||
* @param locID the loc type id.
|
* @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.
|
* @return <code>true</code> if the loc models are ready.
|
||||||
*/
|
*/
|
||||||
public static boolean isLocReady(int locID, int kind) {
|
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
|
* 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
|
* 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.
|
* 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 originX the region origin x in the scene.
|
||||||
* @param originZ the region origin z in the scene.
|
* @param originZ the region origin z in the scene.
|
||||||
* @return <code>true</code> if all locs are valid.
|
* @return <code>true</code> if all locs are valid.
|
||||||
@@ -890,8 +891,9 @@ public class SceneBuilder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Flattens the perimeter of the provided area.
|
* 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 tileSizeX the area size x.
|
||||||
* @param tileSizeZ the area size z.
|
* @param tileSizeZ the area size z.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,14 +4,14 @@
|
|||||||
|
|
||||||
public class SceneGroundDecoration {
|
public class SceneGroundDecoration {
|
||||||
|
|
||||||
public int y;
|
public int y;
|
||||||
public int x;
|
public int x;
|
||||||
public int z;
|
public int z;
|
||||||
public Entity entity;
|
public Entity entity;
|
||||||
public int bitset;
|
public int bitset;
|
||||||
public byte info;
|
public byte info;
|
||||||
|
|
||||||
public SceneGroundDecoration() {
|
public SceneGroundDecoration() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+19
-19
@@ -4,26 +4,26 @@
|
|||||||
|
|
||||||
public class SceneLoc {
|
public class SceneLoc {
|
||||||
|
|
||||||
public int level;
|
public int level;
|
||||||
public int y;
|
public int y;
|
||||||
public int x;
|
public int x;
|
||||||
public int z;
|
public int z;
|
||||||
public Entity entity;
|
public Entity entity;
|
||||||
public int yaw;
|
public int yaw;
|
||||||
public int minSceneTileX;
|
public int minSceneTileX;
|
||||||
public int maxSceneTileX;
|
public int maxSceneTileX;
|
||||||
public int minSceneTileZ;
|
public int minSceneTileZ;
|
||||||
public int maxSceneTileZ;
|
public int maxSceneTileZ;
|
||||||
public int distance;
|
public int distance;
|
||||||
public int cycle;
|
public int cycle;
|
||||||
public int bitset;
|
public int bitset;
|
||||||
public byte info;
|
public byte info;
|
||||||
|
|
||||||
public boolean drawn() {
|
public boolean drawn() {
|
||||||
return cycle == Scene.cycle;
|
return cycle == Scene.cycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SceneLoc() {
|
public SceneLoc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,21 +4,21 @@
|
|||||||
|
|
||||||
public class SceneLocTemporary extends DoublyLinkedList.Node {
|
public class SceneLocTemporary extends DoublyLinkedList.Node {
|
||||||
|
|
||||||
public int id;
|
public int id;
|
||||||
public int rotation;
|
public int rotation;
|
||||||
public int kind;
|
public int kind;
|
||||||
public int duration;
|
public int duration;
|
||||||
public int level;
|
public int level;
|
||||||
public int classID;
|
public int classID;
|
||||||
public int localX;
|
public int localX;
|
||||||
public int localZ;
|
public int localZ;
|
||||||
public int previousLocID;
|
public int previousLocID;
|
||||||
public int previousRotation;
|
public int previousRotation;
|
||||||
public int previousKind;
|
public int previousKind;
|
||||||
public int delay;
|
public int delay;
|
||||||
|
|
||||||
public SceneLocTemporary() {
|
public SceneLocTemporary() {
|
||||||
duration = -1;
|
duration = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,16 +4,16 @@
|
|||||||
|
|
||||||
public class SceneObjStack {
|
public class SceneObjStack {
|
||||||
|
|
||||||
public int y;
|
public int y;
|
||||||
public int x;
|
public int x;
|
||||||
public int z;
|
public int z;
|
||||||
public Entity topObj;
|
public Entity topObj;
|
||||||
public Entity bottomObj;
|
public Entity bottomObj;
|
||||||
public Entity middleObj;
|
public Entity middleObj;
|
||||||
public int bitset;
|
public int bitset;
|
||||||
public int offset;
|
public int offset;
|
||||||
|
|
||||||
public SceneObjStack() {
|
public SceneObjStack() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,39 +4,39 @@
|
|||||||
|
|
||||||
public class SceneOccluder {
|
public class SceneOccluder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wall occluder which runs along the X axis.
|
* A wall occluder which runs along the X axis.
|
||||||
*/
|
*/
|
||||||
public static final int TYPE_WALL_X = 1;
|
public static final int TYPE_WALL_X = 1;
|
||||||
/**
|
/**
|
||||||
* A wall occluder which runs along the Z axis.
|
* A wall occluder which runs along the Z axis.
|
||||||
*/
|
*/
|
||||||
public static final int TYPE_WALL_Z = 2;
|
public static final int TYPE_WALL_Z = 2;
|
||||||
/**
|
/**
|
||||||
* A ground occluder which covers the XZ plane.
|
* A ground occluder which covers the XZ plane.
|
||||||
*/
|
*/
|
||||||
public static final int TYPE_GROUND = 4;
|
public static final int TYPE_GROUND = 4;
|
||||||
|
|
||||||
public int minTileX;
|
public int minTileX;
|
||||||
public int maxTileX;
|
public int maxTileX;
|
||||||
public int minTileZ;
|
public int minTileZ;
|
||||||
public int maxTileZ;
|
public int maxTileZ;
|
||||||
public int type;
|
public int type;
|
||||||
public int minX;
|
public int minX;
|
||||||
public int maxX;
|
public int maxX;
|
||||||
public int minZ;
|
public int minZ;
|
||||||
public int maxZ;
|
public int maxZ;
|
||||||
public int minY;
|
public int minY;
|
||||||
public int maxY;
|
public int maxY;
|
||||||
public int mode;
|
public int mode;
|
||||||
public int minDeltaX;
|
public int minDeltaX;
|
||||||
public int maxDeltaX;
|
public int maxDeltaX;
|
||||||
public int minDeltaZ;
|
public int minDeltaZ;
|
||||||
public int maxDeltaZ;
|
public int maxDeltaZ;
|
||||||
public int minDeltaY;
|
public int minDeltaY;
|
||||||
public int maxDeltaY;
|
public int maxDeltaY;
|
||||||
|
|
||||||
public SceneOccluder() {
|
public SceneOccluder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,50 +4,51 @@
|
|||||||
|
|
||||||
public class SceneTile extends DoublyLinkedList.Node {
|
public class SceneTile extends DoublyLinkedList.Node {
|
||||||
|
|
||||||
public final int x;
|
public final int x;
|
||||||
public final int z;
|
public final int z;
|
||||||
/**
|
/**
|
||||||
* Which level to sample when testing against this tile for occlusion.
|
* Which level to sample when testing against this tile for occlusion.
|
||||||
*/
|
*/
|
||||||
public final int occludeLevel;
|
public final int occludeLevel;
|
||||||
public final SceneLoc[] locs = new SceneLoc[5];
|
public final SceneLoc[] locs = new SceneLoc[5];
|
||||||
public final int[] locSpan = new int[5];
|
public final int[] locSpan = new int[5];
|
||||||
public int level;
|
public int level;
|
||||||
public SceneTileUnderlay underlay;
|
public SceneTileUnderlay underlay;
|
||||||
public SceneTileOverlay overlay;
|
public SceneTileOverlay overlay;
|
||||||
public SceneWall wall;
|
public SceneWall wall;
|
||||||
public SceneWallDecoration wallDecoration;
|
public SceneWallDecoration wallDecoration;
|
||||||
public SceneGroundDecoration groundDecoration;
|
public SceneGroundDecoration groundDecoration;
|
||||||
public SceneObjStack objStack;
|
public SceneObjStack objStack;
|
||||||
public int locCount;
|
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
|
* 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.
|
* cull it.
|
||||||
* <p>
|
* <p>
|
||||||
* 0b0001 = x > loc.minSceneTileX
|
* 0b0001 = x > loc.minSceneTileX
|
||||||
* 0b0010 = z < loc.maxSceneTileZ
|
* 0b0010 = z < loc.maxSceneTileZ
|
||||||
* 0b0100 = x < loc.maxSceneTileX
|
* 0b0100 = x < loc.maxSceneTileX
|
||||||
* 0b1000 = z > loc.minSceneTileZ
|
* 0b1000 = z > loc.minSceneTileZ
|
||||||
*/
|
*/
|
||||||
public int locSpans;
|
public int locSpans;
|
||||||
/**
|
/**
|
||||||
* Used as a short circuit to prevent drawing tiles above the top level. Mostly applies to lowmem.
|
* 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)
|
*
|
||||||
*/
|
* @see Scene#draw(int, int, int, int, int, int)
|
||||||
public int drawLevel;
|
*/
|
||||||
public boolean visible;
|
public int drawLevel;
|
||||||
public boolean update;
|
public boolean visible;
|
||||||
public boolean containsLocs;
|
public boolean update;
|
||||||
public int checkLocSpans;
|
public boolean containsLocs;
|
||||||
public int blockLocSpans;
|
public int checkLocSpans;
|
||||||
public int inverseBlockLocSpans;
|
public int blockLocSpans;
|
||||||
public int backWallTypes;
|
public int inverseBlockLocSpans;
|
||||||
public SceneTile bridge;
|
public int backWallTypes;
|
||||||
|
public SceneTile bridge;
|
||||||
|
|
||||||
public SceneTile(int level, int x, int z) {
|
public SceneTile(int level, int x, int z) {
|
||||||
this.occludeLevel = this.level = level;
|
this.occludeLevel = this.level = level;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,20 +5,20 @@
|
|||||||
public class SceneTileOverlay {
|
public class SceneTileOverlay {
|
||||||
|
|
||||||
public static final int[][] SHAPE_POINTS = {
|
public static final int[][] SHAPE_POINTS = {
|
||||||
{1, 3, 5, 7},
|
{1, 3, 5, 7},
|
||||||
{1, 3, 5, 7},
|
{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, 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, 6},
|
||||||
{1, 3, 5, 7, 2, 8},
|
{1, 3, 5, 7, 2, 8},
|
||||||
{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, 11, 12},
|
{1, 3, 5, 7, 11, 12},
|
||||||
{1, 3, 5, 7, 13, 14},
|
{1, 3, 5, 7, 13, 14},
|
||||||
};
|
};
|
||||||
public static final int[][] SHAPE_PATHS = {
|
public static final int[][] SHAPE_PATHS = {
|
||||||
{0, 1, 2, 3, 0, 0, 1, 3},
|
{0, 1, 2, 3, 0, 0, 1, 3},
|
||||||
{1, 1, 2, 3, 1, 0, 1, 3},
|
{1, 1, 2, 3, 1, 0, 1, 3},
|
||||||
|
|||||||
@@ -4,22 +4,22 @@
|
|||||||
|
|
||||||
public class SceneTileUnderlay {
|
public class SceneTileUnderlay {
|
||||||
|
|
||||||
public final int southwestColor;
|
public final int southwestColor;
|
||||||
public final int southeastColor;
|
public final int southeastColor;
|
||||||
public final int northeastColor;
|
public final int northeastColor;
|
||||||
public final int northwestColor;
|
public final int northwestColor;
|
||||||
public final int textureID;
|
public final int textureID;
|
||||||
public final int rgb;
|
public final int rgb;
|
||||||
public boolean flat;
|
public boolean flat;
|
||||||
|
|
||||||
public SceneTileUnderlay(int southwestColor, int southeastColor, int northeastColor, int northwestColor, int textureID, int rgb, boolean flat) {
|
public SceneTileUnderlay(int southwestColor, int southeastColor, int northeastColor, int northwestColor, int textureID, int rgb, boolean flat) {
|
||||||
this.southwestColor = southwestColor;
|
this.southwestColor = southwestColor;
|
||||||
this.southeastColor = southeastColor;
|
this.southeastColor = southeastColor;
|
||||||
this.northeastColor = northeastColor;
|
this.northeastColor = northeastColor;
|
||||||
this.northwestColor = northwestColor;
|
this.northwestColor = northwestColor;
|
||||||
this.textureID = textureID;
|
this.textureID = textureID;
|
||||||
this.rgb = rgb;
|
this.rgb = rgb;
|
||||||
this.flat = flat;
|
this.flat = flat;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,17 +4,17 @@
|
|||||||
|
|
||||||
public class SceneWall {
|
public class SceneWall {
|
||||||
|
|
||||||
public int y;
|
public int y;
|
||||||
public int x;
|
public int x;
|
||||||
public int z;
|
public int z;
|
||||||
public int typeA;
|
public int typeA;
|
||||||
public int typeB;
|
public int typeB;
|
||||||
public Entity entityA;
|
public Entity entityA;
|
||||||
public Entity entityB;
|
public Entity entityB;
|
||||||
public int bitset;
|
public int bitset;
|
||||||
public byte info;
|
public byte info;
|
||||||
|
|
||||||
public SceneWall() {
|
public SceneWall() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
public class SceneWallDecoration {
|
public class SceneWallDecoration {
|
||||||
|
|
||||||
public int y;
|
public int y;
|
||||||
public int x;
|
public int x;
|
||||||
public int z;
|
public int z;
|
||||||
public int type;
|
public int type;
|
||||||
public int rotation;
|
public int rotation;
|
||||||
public Entity entity;
|
public Entity entity;
|
||||||
public int bitset;
|
public int bitset;
|
||||||
public byte info;
|
public byte info;
|
||||||
|
|
||||||
public SceneWallDecoration() {
|
public SceneWallDecoration() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,7 @@ public class SeqSkeleton {
|
|||||||
public final int[] baseTypes;
|
public final int[] baseTypes;
|
||||||
/**
|
/**
|
||||||
* The labels belonging to the base.
|
* The labels belonging to the base.
|
||||||
|
*
|
||||||
* @see Model#createLabelReferences()
|
* @see Model#createLabelReferences()
|
||||||
*/
|
*/
|
||||||
public final int[][] baseLabels;
|
public final int[][] baseLabels;
|
||||||
|
|||||||
+149
-149
@@ -6,182 +6,182 @@
|
|||||||
*/
|
*/
|
||||||
public class SeqTransform {
|
public class SeqTransform {
|
||||||
|
|
||||||
public static SeqTransform[] instances;
|
public static SeqTransform[] instances;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Syntax sugar.
|
* Syntax sugar.
|
||||||
*
|
*
|
||||||
* @param id the id
|
* @param id the id
|
||||||
* @return <code>id == -1</code>
|
* @return <code>id == -1</code>
|
||||||
*/
|
*/
|
||||||
public static boolean isNull(int id) {
|
public static boolean isNull(int id) {
|
||||||
return id == -1;
|
return id == -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the array of instances.
|
* Initializes the array of instances.
|
||||||
*
|
*
|
||||||
* @param count the count
|
* @param count the count
|
||||||
*/
|
*/
|
||||||
public static void init(int count) {
|
public static void init(int count) {
|
||||||
instances = new SeqTransform[count + 1];
|
instances = new SeqTransform[count + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nullifies the array of instances.
|
* Nullifies the array of instances.
|
||||||
*/
|
*/
|
||||||
public static void unload() {
|
public static void unload() {
|
||||||
instances = null;
|
instances = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link SeqTransform}
|
* Gets the {@link SeqTransform}
|
||||||
*
|
*
|
||||||
* @param id the transform id.
|
* @param id the transform id.
|
||||||
* @return the {@link SeqTransform} or <code>null</code> if it does not exist.
|
* @return the {@link SeqTransform} or <code>null</code> if it does not exist.
|
||||||
*/
|
*/
|
||||||
public static SeqTransform get(int id) {
|
public static SeqTransform get(int id) {
|
||||||
if ((instances == null) || (id < 0) || (id >= instances.length)) {
|
if ((instances == null) || (id < 0) || (id >= instances.length)) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return instances[id];
|
return instances[id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method can read <i>multiple</i> {@link SeqTransform}s which means the input data can be all the transforms
|
* 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.
|
* related to the loaded skeleton.
|
||||||
*
|
*
|
||||||
* @param src the animation data.
|
* @param src the animation data.
|
||||||
* @see #get(int)
|
* @see #get(int)
|
||||||
*/
|
*/
|
||||||
public static void unpack(byte[] src) {
|
public static void unpack(byte[] src) {
|
||||||
Buffer offsets = new Buffer(src);
|
Buffer offsets = new Buffer(src);
|
||||||
offsets.position = src.length - 8;
|
offsets.position = src.length - 8;
|
||||||
|
|
||||||
Buffer header = new Buffer(src);
|
Buffer header = new Buffer(src);
|
||||||
Buffer tran1 = new Buffer(src);
|
Buffer tran1 = new Buffer(src);
|
||||||
Buffer tran2 = new Buffer(src);
|
Buffer tran2 = new Buffer(src);
|
||||||
Buffer del = new Buffer(src);
|
Buffer del = new Buffer(src);
|
||||||
Buffer skel = new Buffer(src);
|
Buffer skel = new Buffer(src);
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
header.position = offset;
|
header.position = offset;
|
||||||
offset += offsets.read16U() + 2;
|
offset += offsets.read16U() + 2;
|
||||||
|
|
||||||
tran1.position = offset;
|
tran1.position = offset;
|
||||||
offset += offsets.read16U();
|
offset += offsets.read16U();
|
||||||
|
|
||||||
tran2.position = offset;
|
tran2.position = offset;
|
||||||
offset += offsets.read16U();
|
offset += offsets.read16U();
|
||||||
|
|
||||||
del.position = offset;
|
del.position = offset;
|
||||||
offset += offsets.read16U();
|
offset += offsets.read16U();
|
||||||
|
|
||||||
skel.position = offset;
|
skel.position = offset;
|
||||||
|
|
||||||
SeqSkeleton skeleton = new SeqSkeleton(skel);
|
SeqSkeleton skeleton = new SeqSkeleton(skel);
|
||||||
|
|
||||||
int frameCount = header.read16U();
|
int frameCount = header.read16U();
|
||||||
int[] bases = new int[500];
|
int[] bases = new int[500];
|
||||||
int[] x = new int[500];
|
int[] x = new int[500];
|
||||||
int[] y = new int[500];
|
int[] y = new int[500];
|
||||||
int[] z = new int[500];
|
int[] z = new int[500];
|
||||||
|
|
||||||
for (int i = 0; i < frameCount; i++) {
|
for (int i = 0; i < frameCount; i++) {
|
||||||
SeqTransform transform = instances[header.read16U()] = new SeqTransform();
|
SeqTransform transform = instances[header.read16U()] = new SeqTransform();
|
||||||
transform.delay = del.read8U();
|
transform.delay = del.read8U();
|
||||||
transform.skeleton = skeleton;
|
transform.skeleton = skeleton;
|
||||||
|
|
||||||
int baseCount = header.read8U();
|
int baseCount = header.read8U();
|
||||||
int lastBase = -1;
|
int lastBase = -1;
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
|
||||||
for (int base = 0; base < baseCount; base++) {
|
for (int base = 0; base < baseCount; base++) {
|
||||||
int flags = tran1.read8U();
|
int flags = tran1.read8U();
|
||||||
|
|
||||||
if (flags <= 0) {
|
if (flags <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skeleton.baseTypes[base] != SeqSkeleton.OP_BASE) {
|
if (skeleton.baseTypes[base] != SeqSkeleton.OP_BASE) {
|
||||||
// Look for any skipped ORIGIN bases and insert them into this transform.
|
// Look for any skipped ORIGIN bases and insert them into this transform.
|
||||||
for (int cur = base - 1; cur > lastBase; cur--) {
|
for (int cur = base - 1; cur > lastBase; cur--) {
|
||||||
if (skeleton.baseTypes[cur] == SeqSkeleton.OP_BASE) {
|
if (skeleton.baseTypes[cur] == SeqSkeleton.OP_BASE) {
|
||||||
bases[length] = cur;
|
bases[length] = cur;
|
||||||
x[length] = 0;
|
x[length] = 0;
|
||||||
y[length] = 0;
|
y[length] = 0;
|
||||||
z[length] = 0;
|
z[length] = 0;
|
||||||
length++;
|
length++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bases[length] = base;
|
bases[length] = base;
|
||||||
|
|
||||||
int defaultValue = 0;
|
int defaultValue = 0;
|
||||||
|
|
||||||
if (skeleton.baseTypes[base] == SeqSkeleton.OP_SCALE) {
|
if (skeleton.baseTypes[base] == SeqSkeleton.OP_SCALE) {
|
||||||
defaultValue = 128;
|
defaultValue = 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & 1) != 0) {
|
if ((flags & 1) != 0) {
|
||||||
x[length] = tran2.readSmart();
|
x[length] = tran2.readSmart();
|
||||||
} else {
|
} else {
|
||||||
x[length] = defaultValue;
|
x[length] = defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & 2) != 0) {
|
if ((flags & 2) != 0) {
|
||||||
y[length] = tran2.readSmart();
|
y[length] = tran2.readSmart();
|
||||||
} else {
|
} else {
|
||||||
y[length] = defaultValue;
|
y[length] = defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & 4) != 0) {
|
if ((flags & 4) != 0) {
|
||||||
z[length] = tran2.readSmart();
|
z[length] = tran2.readSmart();
|
||||||
} else {
|
} else {
|
||||||
z[length] = defaultValue;
|
z[length] = defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastBase = base;
|
lastBase = base;
|
||||||
length++;
|
length++;
|
||||||
}
|
}
|
||||||
|
|
||||||
transform.length = length;
|
transform.length = length;
|
||||||
transform.bases = new int[length];
|
transform.bases = new int[length];
|
||||||
transform.x = new int[length];
|
transform.x = new int[length];
|
||||||
transform.y = new int[length];
|
transform.y = new int[length];
|
||||||
transform.z = new int[length];
|
transform.z = new int[length];
|
||||||
|
|
||||||
for (int j = 0; j < length; j++) {
|
for (int j = 0; j < length; j++) {
|
||||||
transform.bases[j] = bases[j];
|
transform.bases[j] = bases[j];
|
||||||
transform.x[j] = x[j];
|
transform.x[j] = x[j];
|
||||||
transform.y[j] = y[j];
|
transform.y[j] = y[j];
|
||||||
transform.z[j] = z[j];
|
transform.z[j] = z[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The skeleton associated to this transform.
|
* The skeleton associated to this transform.
|
||||||
*/
|
*/
|
||||||
public SeqSkeleton skeleton;
|
public SeqSkeleton skeleton;
|
||||||
/**
|
/**
|
||||||
* The delay in <code>ticks</code>.
|
* The delay in <code>ticks</code>.
|
||||||
*/
|
*/
|
||||||
public int delay;
|
public int delay;
|
||||||
/**
|
/**
|
||||||
* The number of operations this transform performs.
|
* The number of operations this transform performs.
|
||||||
*/
|
*/
|
||||||
public int length;
|
public int length;
|
||||||
/**
|
/**
|
||||||
* The list of bases this transform uses.
|
* The list of bases this transform uses.
|
||||||
*/
|
*/
|
||||||
public int[] bases;
|
public int[] bases;
|
||||||
/**
|
/**
|
||||||
* This transforms parameters.
|
* This transforms parameters.
|
||||||
*/
|
*/
|
||||||
public int[] x, y, z;
|
public int[] x, y, z;
|
||||||
|
|
||||||
}
|
}
|
||||||
+180
-172
@@ -6,204 +6,212 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class SeqType {
|
public class SeqType {
|
||||||
|
|
||||||
public static int count;
|
public static int count;
|
||||||
public static SeqType[] instances;
|
public static SeqType[] instances;
|
||||||
|
|
||||||
public static void unpack(FileArchive archive) throws IOException {
|
public static void unpack(FileArchive archive) throws IOException {
|
||||||
Buffer buffer = new Buffer(archive.read("seq.dat"));
|
Buffer buffer = new Buffer(archive.read("seq.dat"));
|
||||||
count = buffer.read16U();
|
count = buffer.read16U();
|
||||||
if (instances == null) {
|
if (instances == null) {
|
||||||
instances = new SeqType[count];
|
instances = new SeqType[count];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
if (instances[i] == null) {
|
if (instances[i] == null) {
|
||||||
instances[i] = new SeqType();
|
instances[i] = new SeqType();
|
||||||
}
|
}
|
||||||
instances[i].load(buffer);
|
instances[i].load(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The amount of frames in this {@link SeqType}.
|
* The amount of frames in this {@link SeqType}.
|
||||||
*/
|
*/
|
||||||
public int frameCount;
|
public int frameCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of {@link SeqTransform} indices indexed by Frame ID.
|
* The list of {@link SeqTransform} indices indexed by Frame ID.
|
||||||
* @see SeqTransform
|
*
|
||||||
*/
|
* @see SeqTransform
|
||||||
public int[] transformIDs;
|
*/
|
||||||
|
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)}.
|
* 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;
|
public int[] auxiliaryTransformIDs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of durations indexed by Frame ID.
|
* A list of durations indexed by Frame ID.
|
||||||
*/
|
*/
|
||||||
public int[] frameDuration;
|
public int[] frameDuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of frames from the end of this {@link SeqType} used for looping.
|
* The number of frames from the end of this {@link SeqType} used for looping.
|
||||||
*/
|
*/
|
||||||
public int loopFrameCount = -1;
|
public int loopFrameCount = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to determine which transform bases a primary frame is allowed to use, and secondary not.
|
* Used to determine which transform bases a primary frame is allowed to use, and secondary not.
|
||||||
* @see Model#applyTransforms(int, int, int[])
|
*
|
||||||
*/
|
* @see Model#applyTransforms(int, int, int[])
|
||||||
public int[] mask;
|
*/
|
||||||
|
public int[] mask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds additional space to the render bounds.
|
* Adds additional space to the render bounds.
|
||||||
* @see Scene#addTemporary(Entity, int, int, int, int, int, int, boolean, int)
|
*
|
||||||
*/
|
* @see Scene#addTemporary(Entity, int, int, int, int, int, int, boolean, int)
|
||||||
public boolean forwardRenderPadding = false;
|
*/
|
||||||
|
public boolean forwardRenderPadding = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The priority.
|
* The priority.
|
||||||
*/
|
*/
|
||||||
public int priority = 5;
|
public int priority = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows this {@link SeqType} to override the right hand of a {@link PlayerEntity}.
|
* Allows this {@link SeqType} to override the right hand of a {@link PlayerEntity}.
|
||||||
* @see PlayerEntity#getSequencedModel()
|
*
|
||||||
*/
|
* @see PlayerEntity#getSequencedModel()
|
||||||
public int rightHandOverride = -1;
|
*/
|
||||||
|
public int rightHandOverride = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows this {@link SeqType} to override the left hand of a {@link PlayerEntity}.
|
* Allows this {@link SeqType} to override the left hand of a {@link PlayerEntity}.
|
||||||
* @see PlayerEntity#getSequencedModel()
|
*
|
||||||
*/
|
* @see PlayerEntity#getSequencedModel()
|
||||||
public int leftHandOverride = -1;
|
*/
|
||||||
|
public int leftHandOverride = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How many times this seq is allowed to loop before stopping.
|
* How many times this seq is allowed to loop before stopping.
|
||||||
*/
|
*/
|
||||||
public int loopCount = 99;
|
public int loopCount = 99;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If 0, causes faster movement, allows looking at target
|
* If 0, causes faster movement, allows looking at target
|
||||||
* If 1, pause while moving
|
* If 1, pause while moving
|
||||||
* If 2, does not look at target, continues playing during movement
|
* If 2, does not look at target, continues playing during movement
|
||||||
* @see Game#updateMovement(PathingEntity)
|
*
|
||||||
*/
|
* @see Game#updateMovement(PathingEntity)
|
||||||
public int moveStyle = -1;
|
*/
|
||||||
|
public int moveStyle = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If 0, allows looking at a target
|
* If 0, allows looking at a target
|
||||||
* If 1, stops playing on move
|
* If 1, stops playing on move
|
||||||
* If 2, does not look at target, continues playing during movement
|
* If 2, does not look at target, continues playing during movement
|
||||||
* @see Game#updateMovement(PathingEntity)
|
*
|
||||||
*/
|
* @see Game#updateMovement(PathingEntity)
|
||||||
public int idleStyle = -1;
|
*/
|
||||||
|
public int idleStyle = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If 0, restarts the sequence if already playing
|
* If 0, restarts the sequence if already playing
|
||||||
* If 1, does not restart if already playing
|
* If 1, does not restart if already playing
|
||||||
* @see Game#readNPCUpdates()
|
*
|
||||||
*/
|
* @see Game#readNPCUpdates()
|
||||||
public int replayStyle = 1;
|
*/
|
||||||
|
public int replayStyle = 1;
|
||||||
|
|
||||||
|
|
||||||
public SeqType() {
|
public SeqType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFrameDuration(int frame) {
|
public int getFrameDuration(int frame) {
|
||||||
int duration = frameDuration[frame];
|
int duration = frameDuration[frame];
|
||||||
|
|
||||||
if (duration == 0) {
|
if (duration == 0) {
|
||||||
SeqTransform transform = SeqTransform.get(transformIDs[frame]);
|
SeqTransform transform = SeqTransform.get(transformIDs[frame]);
|
||||||
if (transform != null) {
|
if (transform != null) {
|
||||||
duration = frameDuration[frame] = transform.delay;
|
duration = frameDuration[frame] = transform.delay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (duration == 0) {
|
if (duration == 0) {
|
||||||
duration = 1;
|
duration = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load(Buffer buffer) {
|
public void load(Buffer buffer) {
|
||||||
while (true) {
|
while (true) {
|
||||||
int code = buffer.read8U();
|
int code = buffer.read8U();
|
||||||
|
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
break;
|
break;
|
||||||
} else if (code == 1) {
|
} else if (code == 1) {
|
||||||
frameCount = buffer.read8U();
|
frameCount = buffer.read8U();
|
||||||
transformIDs = new int[frameCount];
|
transformIDs = new int[frameCount];
|
||||||
auxiliaryTransformIDs = new int[frameCount];
|
auxiliaryTransformIDs = new int[frameCount];
|
||||||
frameDuration = new int[frameCount];
|
frameDuration = new int[frameCount];
|
||||||
for (int f = 0; f < frameCount; f++) {
|
for (int f = 0; f < frameCount; f++) {
|
||||||
transformIDs[f] = buffer.read16U();
|
transformIDs[f] = buffer.read16U();
|
||||||
auxiliaryTransformIDs[f] = buffer.read16U();
|
auxiliaryTransformIDs[f] = buffer.read16U();
|
||||||
if (auxiliaryTransformIDs[f] == 65535) {
|
if (auxiliaryTransformIDs[f] == 65535) {
|
||||||
auxiliaryTransformIDs[f] = -1;
|
auxiliaryTransformIDs[f] = -1;
|
||||||
}
|
}
|
||||||
frameDuration[f] = buffer.read16U();
|
frameDuration[f] = buffer.read16U();
|
||||||
}
|
}
|
||||||
} else if (code == 2) {
|
} else if (code == 2) {
|
||||||
loopFrameCount = buffer.read16U();
|
loopFrameCount = buffer.read16U();
|
||||||
} else if (code == 3) {
|
} else if (code == 3) {
|
||||||
int count = buffer.read8U();
|
int count = buffer.read8U();
|
||||||
mask = new int[count + 1];
|
mask = new int[count + 1];
|
||||||
for (int l = 0; l < count; l++) {
|
for (int l = 0; l < count; l++) {
|
||||||
mask[l] = buffer.read8U();
|
mask[l] = buffer.read8U();
|
||||||
}
|
}
|
||||||
mask[count] = 9999999;
|
mask[count] = 9999999;
|
||||||
} else if (code == 4) {
|
} else if (code == 4) {
|
||||||
forwardRenderPadding = true;
|
forwardRenderPadding = true;
|
||||||
} else if (code == 5) {
|
} else if (code == 5) {
|
||||||
priority = buffer.read8U();
|
priority = buffer.read8U();
|
||||||
} else if (code == 6) {
|
} else if (code == 6) {
|
||||||
rightHandOverride = buffer.read16U();
|
rightHandOverride = buffer.read16U();
|
||||||
} else if (code == 7) {
|
} else if (code == 7) {
|
||||||
leftHandOverride = buffer.read16U();
|
leftHandOverride = buffer.read16U();
|
||||||
} else if (code == 8) {
|
} else if (code == 8) {
|
||||||
loopCount = buffer.read8U();
|
loopCount = buffer.read8U();
|
||||||
} else if (code == 9) {
|
} else if (code == 9) {
|
||||||
moveStyle = buffer.read8U();
|
moveStyle = buffer.read8U();
|
||||||
} else if (code == 10) {
|
} else if (code == 10) {
|
||||||
idleStyle = buffer.read8U();
|
idleStyle = buffer.read8U();
|
||||||
} else if (code == 11) {
|
} else if (code == 11) {
|
||||||
replayStyle = buffer.read8U();
|
replayStyle = buffer.read8U();
|
||||||
} else if (code == 12) {
|
} else if (code == 12) {
|
||||||
buffer.read32();
|
buffer.read32();
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Error unrecognised seq config code: " + code);
|
System.out.println("Error unrecognised seq config code: " + code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frameCount == 0) {
|
if (frameCount == 0) {
|
||||||
frameCount = 1;
|
frameCount = 1;
|
||||||
transformIDs = new int[1];
|
transformIDs = new int[1];
|
||||||
transformIDs[0] = -1;
|
transformIDs[0] = -1;
|
||||||
auxiliaryTransformIDs = new int[1];
|
auxiliaryTransformIDs = new int[1];
|
||||||
auxiliaryTransformIDs[0] = -1;
|
auxiliaryTransformIDs[0] = -1;
|
||||||
frameDuration = new int[1];
|
frameDuration = new int[1];
|
||||||
frameDuration[0] = -1;
|
frameDuration[0] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (moveStyle == -1) {
|
if (moveStyle == -1) {
|
||||||
if (mask != null) {
|
if (mask != null) {
|
||||||
moveStyle = 2;
|
moveStyle = 2;
|
||||||
} else {
|
} else {
|
||||||
moveStyle = 0;
|
moveStyle = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (idleStyle == -1) {
|
if (idleStyle == -1) {
|
||||||
if (mask != null) {
|
if (mask != null) {
|
||||||
idleStyle = 2;
|
idleStyle = 2;
|
||||||
} else {
|
} else {
|
||||||
idleStyle = 0;
|
idleStyle = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+251
-251
@@ -11,269 +11,269 @@ import java.net.URL;
|
|||||||
|
|
||||||
public class Signlink implements Runnable {
|
public class Signlink implements Runnable {
|
||||||
|
|
||||||
public static final RandomAccessFile[] cache_idx = new RandomAccessFile[5];
|
public static final RandomAccessFile[] cache_idx = new RandomAccessFile[5];
|
||||||
public static final Applet mainapp = null;
|
public static final Applet mainapp = null;
|
||||||
public static int uid;
|
public static int uid;
|
||||||
public static int storeid = 32;
|
public static int storeid = 32;
|
||||||
public static RandomAccessFile cache_dat = null;
|
public static RandomAccessFile cache_dat = null;
|
||||||
public static boolean sunjava;
|
public static boolean sunjava;
|
||||||
public static boolean active;
|
public static boolean active;
|
||||||
public static int threadliveid;
|
public static int threadliveid;
|
||||||
public static InetAddress socketip;
|
public static InetAddress socketip;
|
||||||
public static int socketreq;
|
public static int socketreq;
|
||||||
public static Socket socket = null;
|
public static Socket socket = null;
|
||||||
public static int threadreqpri = 1;
|
public static int threadreqpri = 1;
|
||||||
public static Runnable threadreq = null;
|
public static Runnable threadreq = null;
|
||||||
public static String dnsreq = null;
|
public static String dnsreq = null;
|
||||||
public static String dns = null;
|
public static String dns = null;
|
||||||
public static String urlreq = null;
|
public static String urlreq = null;
|
||||||
public static DataInputStream urlstream = null;
|
public static DataInputStream urlstream = null;
|
||||||
public static int savelen;
|
public static int savelen;
|
||||||
public static String savereq = null;
|
public static String savereq = null;
|
||||||
public static byte[] savebuf = null;
|
public static byte[] savebuf = null;
|
||||||
public static boolean midiplay;
|
public static boolean midiplay;
|
||||||
public static int midipos;
|
public static int midipos;
|
||||||
public static String midi = null;
|
public static String midi = null;
|
||||||
public static int midivol;
|
public static int midivol;
|
||||||
public static int midifade;
|
public static int midifade;
|
||||||
public static boolean waveplay;
|
public static boolean waveplay;
|
||||||
public static int wavepos;
|
public static int wavepos;
|
||||||
public static String wave = null;
|
public static String wave = null;
|
||||||
public static int wavevol;
|
public static int wavevol;
|
||||||
public static boolean reporterror = true;
|
public static boolean reporterror = true;
|
||||||
|
|
||||||
public static void startpriv(InetAddress inetaddress) {
|
public static void startpriv(InetAddress inetaddress) {
|
||||||
threadliveid = (int) (Math.random() * 99999999D);
|
threadliveid = (int) (Math.random() * 99999999D);
|
||||||
if (active) {
|
if (active) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(500L);
|
Thread.sleep(500L);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
active = false;
|
active = false;
|
||||||
}
|
}
|
||||||
socketreq = 0;
|
socketreq = 0;
|
||||||
threadreq = null;
|
threadreq = null;
|
||||||
dnsreq = null;
|
dnsreq = null;
|
||||||
savereq = null;
|
savereq = null;
|
||||||
urlreq = null;
|
urlreq = null;
|
||||||
socketip = inetaddress;
|
socketip = inetaddress;
|
||||||
Thread thread = new Thread(new Signlink());
|
Thread thread = new Thread(new Signlink());
|
||||||
thread.setDaemon(true);
|
thread.setDaemon(true);
|
||||||
thread.start();
|
thread.start();
|
||||||
while (!active) {
|
while (!active) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(50L);
|
Thread.sleep(50L);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String findcachedir() {
|
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"};
|
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)) {
|
if ((storeid < 32) || (storeid > 34)) {
|
||||||
storeid = 32;
|
storeid = 32;
|
||||||
}
|
}
|
||||||
String s = ".file_store_" + storeid;
|
String s = ".file_store_" + storeid;
|
||||||
for (String a : as) {
|
for (String a : as) {
|
||||||
try {
|
try {
|
||||||
if (a.length() > 0) {
|
if (a.length() > 0) {
|
||||||
File file = new File(a);
|
File file = new File(a);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File file1 = new File(a + s);
|
File file1 = new File(a + s);
|
||||||
if (file1.exists() || file1.mkdir()) {
|
if (file1.exists() || file1.mkdir()) {
|
||||||
return a + s + "/";
|
return a + s + "/";
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getuid(String s) {
|
public static int getuid(String s) {
|
||||||
try {
|
try {
|
||||||
File file = new File(s + "uid.dat");
|
File file = new File(s + "uid.dat");
|
||||||
if (!file.exists() || (file.length() < 4L)) {
|
if (!file.exists() || (file.length() < 4L)) {
|
||||||
DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(s + "uid.dat"));
|
DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(s + "uid.dat"));
|
||||||
dataoutputstream.writeInt((int) (Math.random() * 99999999D));
|
dataoutputstream.writeInt((int) (Math.random() * 99999999D));
|
||||||
dataoutputstream.close();
|
dataoutputstream.close();
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DataInputStream datainputstream = new DataInputStream(new FileInputStream(s + "uid.dat"));
|
DataInputStream datainputstream = new DataInputStream(new FileInputStream(s + "uid.dat"));
|
||||||
int i = datainputstream.readInt();
|
int i = datainputstream.readInt();
|
||||||
datainputstream.close();
|
datainputstream.close();
|
||||||
return i + 1;
|
return i + 1;
|
||||||
} catch (Exception _ex) {
|
} catch (Exception _ex) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized Socket opensocket(int i) throws IOException {
|
public static synchronized Socket opensocket(int i) throws IOException {
|
||||||
for (socketreq = i; socketreq != 0; ) {
|
for (socketreq = i; socketreq != 0; ) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(50L);
|
Thread.sleep(50L);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (socket == null) {
|
if (socket == null) {
|
||||||
throw new IOException("could not open socket");
|
throw new IOException("could not open socket");
|
||||||
} else {
|
} else {
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized DataInputStream openurl(String s) throws IOException {
|
public static synchronized DataInputStream openurl(String s) throws IOException {
|
||||||
for (urlreq = s; urlreq != null; ) {
|
for (urlreq = s; urlreq != null; ) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(50L);
|
Thread.sleep(50L);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (urlstream == null) {
|
if (urlstream == null) {
|
||||||
throw new IOException("could not open: " + s);
|
throw new IOException("could not open: " + s);
|
||||||
} else {
|
} else {
|
||||||
return urlstream;
|
return urlstream;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void dnslookup(String s) {
|
public static synchronized void dnslookup(String s) {
|
||||||
dns = s;
|
dns = s;
|
||||||
dnsreq = s;
|
dnsreq = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void startthread(Runnable runnable, int i) {
|
public static synchronized void startthread(Runnable runnable, int i) {
|
||||||
threadreqpri = i;
|
threadreqpri = i;
|
||||||
threadreq = runnable;
|
threadreq = runnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized boolean wavesave(byte[] src, int len) {
|
public static synchronized boolean wavesave(byte[] src, int len) {
|
||||||
if (len > 0x1e8480) {
|
if (len > 0x1e8480) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (savereq != null) {
|
if (savereq != null) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
wavepos = (wavepos + 1) % 5;
|
wavepos = (wavepos + 1) % 5;
|
||||||
savelen = len;
|
savelen = len;
|
||||||
savebuf = src;
|
savebuf = src;
|
||||||
waveplay = true;
|
waveplay = true;
|
||||||
savereq = "sound" + wavepos + ".wav";
|
savereq = "sound" + wavepos + ".wav";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized boolean wavereplay() {
|
public static synchronized boolean wavereplay() {
|
||||||
if (savereq != null) {
|
if (savereq != null) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
savebuf = null;
|
savebuf = null;
|
||||||
waveplay = true;
|
waveplay = true;
|
||||||
savereq = "sound" + wavepos + ".wav";
|
savereq = "sound" + wavepos + ".wav";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void midisave(byte[] data, int len) {
|
public static synchronized void midisave(byte[] data, int len) {
|
||||||
if (len > 0x1e8480) {
|
if (len > 0x1e8480) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (savereq != null) {
|
if (savereq != null) {
|
||||||
} else {
|
} else {
|
||||||
midipos = (midipos + 1) % 5;
|
midipos = (midipos + 1) % 5;
|
||||||
savelen = len;
|
savelen = len;
|
||||||
savebuf = data;
|
savebuf = data;
|
||||||
midiplay = true;
|
midiplay = true;
|
||||||
savereq = "jingle" + midipos + ".mid";
|
savereq = "jingle" + midipos + ".mid";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reporterror(String s) {
|
public static void reporterror(String s) {
|
||||||
if (!reporterror) {
|
if (!reporterror) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!active) {
|
if (!active) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
System.out.println("Error: " + s);
|
System.out.println("Error: " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Signlink() {
|
public Signlink() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
active = true;
|
active = true;
|
||||||
String s = findcachedir();
|
String s = findcachedir();
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
uid = getuid(s);
|
uid = getuid(s);
|
||||||
try {
|
try {
|
||||||
File file = new File(s + "main_file_cache.dat");
|
File file = new File(s + "main_file_cache.dat");
|
||||||
if (file.exists() && (file.length() > 0x3200000L)) {
|
if (file.exists() && (file.length() > 0x3200000L)) {
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
cache_dat = new RandomAccessFile(s + "main_file_cache.dat", "rw");
|
cache_dat = new RandomAccessFile(s + "main_file_cache.dat", "rw");
|
||||||
for (int j = 0; j < 5; j++) {
|
for (int j = 0; j < 5; j++) {
|
||||||
cache_idx[j] = new RandomAccessFile(s + "main_file_cache.idx" + j, "rw");
|
cache_idx[j] = new RandomAccessFile(s + "main_file_cache.idx" + j, "rw");
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
for (int i = threadliveid; threadliveid == i; ) {
|
for (int i = threadliveid; threadliveid == i; ) {
|
||||||
if (socketreq != 0) {
|
if (socketreq != 0) {
|
||||||
try {
|
try {
|
||||||
socket = new Socket(socketip, socketreq);
|
socket = new Socket(socketip, socketreq);
|
||||||
} catch (Exception _ex) {
|
} catch (Exception _ex) {
|
||||||
socket = null;
|
socket = null;
|
||||||
}
|
}
|
||||||
socketreq = 0;
|
socketreq = 0;
|
||||||
} else if (threadreq != null) {
|
} else if (threadreq != null) {
|
||||||
Thread thread = new Thread(threadreq);
|
Thread thread = new Thread(threadreq);
|
||||||
thread.setDaemon(true);
|
thread.setDaemon(true);
|
||||||
thread.start();
|
thread.start();
|
||||||
thread.setPriority(threadreqpri);
|
thread.setPriority(threadreqpri);
|
||||||
threadreq = null;
|
threadreq = null;
|
||||||
} else if (dnsreq != null) {
|
} else if (dnsreq != null) {
|
||||||
try {
|
try {
|
||||||
dns = InetAddress.getByName(dnsreq).getHostName();
|
dns = InetAddress.getByName(dnsreq).getHostName();
|
||||||
} catch (Exception _ex) {
|
} catch (Exception _ex) {
|
||||||
dns = "unknown";
|
dns = "unknown";
|
||||||
}
|
}
|
||||||
dnsreq = null;
|
dnsreq = null;
|
||||||
} else if (savereq != null) {
|
} else if (savereq != null) {
|
||||||
if (savebuf != null) {
|
if (savebuf != null) {
|
||||||
try {
|
try {
|
||||||
FileOutputStream fileoutputstream = new FileOutputStream(s + savereq);
|
FileOutputStream fileoutputstream = new FileOutputStream(s + savereq);
|
||||||
fileoutputstream.write(savebuf, 0, savelen);
|
fileoutputstream.write(savebuf, 0, savelen);
|
||||||
fileoutputstream.close();
|
fileoutputstream.close();
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (waveplay) {
|
if (waveplay) {
|
||||||
wave = s + savereq;
|
wave = s + savereq;
|
||||||
waveplay = false;
|
waveplay = false;
|
||||||
}
|
}
|
||||||
if (midiplay) {
|
if (midiplay) {
|
||||||
midi = s + savereq;
|
midi = s + savereq;
|
||||||
midiplay = false;
|
midiplay = false;
|
||||||
}
|
}
|
||||||
savereq = null;
|
savereq = null;
|
||||||
} else if (urlreq != null) {
|
} else if (urlreq != null) {
|
||||||
try {
|
try {
|
||||||
urlstream = new DataInputStream(new URL(mainapp.getCodeBase(), urlreq).openStream());
|
urlstream = new DataInputStream(new URL(mainapp.getCodeBase(), urlreq).openStream());
|
||||||
} catch (Exception _ex) {
|
} catch (Exception _ex) {
|
||||||
urlstream = null;
|
urlstream = null;
|
||||||
}
|
}
|
||||||
urlreq = null;
|
urlreq = null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Thread.sleep(50L);
|
Thread.sleep(50L);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
public class Skill {
|
public class Skill {
|
||||||
|
|
||||||
public static final int COUNT = 25;
|
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 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 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-"};
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,116 +5,116 @@
|
|||||||
*/
|
*/
|
||||||
public class SoundFilter {
|
public class SoundFilter {
|
||||||
|
|
||||||
public static final float[][] coefficient = new float[2][8];
|
public static final float[][] coefficient = new float[2][8];
|
||||||
public static final int[][] coefficient16 = new int[2][8];
|
public static final int[][] coefficient16 = new int[2][8];
|
||||||
public static float unity;
|
public static float unity;
|
||||||
public static int unity16;
|
public static int unity16;
|
||||||
public final int[] pairs = new int[2];
|
public final int[] pairs = new int[2];
|
||||||
public final int[][][] frequencies = new int[2][2][4];
|
public final int[][][] frequencies = new int[2][2][4];
|
||||||
public final int[][][] ranges = new int[2][2][4];
|
public final int[][][] ranges = new int[2][2][4];
|
||||||
public final int[] unities = new int[2];
|
public final int[] unities = new int[2];
|
||||||
|
|
||||||
public SoundFilter() {
|
public SoundFilter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public float gain(int direction, int pair, float delta) {
|
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]));
|
float g = (float) ranges[direction][0][pair] + (delta * (float) (ranges[direction][1][pair] - ranges[direction][0][pair]));
|
||||||
g *= 0.001525879F;
|
g *= 0.001525879F;
|
||||||
return 1.0F - (float) Math.pow(10D, -g / 20F);
|
return 1.0F - (float) Math.pow(10D, -g / 20F);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float normalize(float f) {
|
public float normalize(float f) {
|
||||||
return (32.7032F * (float) Math.pow(2D, f) * 3.141593F) / 11025F;
|
return (32.7032F * (float) Math.pow(2D, f) * 3.141593F) / 11025F;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float phase(int direction, int pair, float delta) {
|
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]));
|
float f1 = (float) frequencies[direction][0][pair] + (delta * (float) (frequencies[direction][1][pair] - frequencies[direction][0][pair]));
|
||||||
f1 *= 0.0001220703F;
|
f1 *= 0.0001220703F;
|
||||||
return normalize(f1);
|
return normalize(f1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int evaluate(int direction, float delta) {
|
public int evaluate(int direction, float delta) {
|
||||||
if (direction == 0) {
|
if (direction == 0) {
|
||||||
float u = (float) unities[0] + ((float) (unities[1] - unities[0]) * delta);
|
float u = (float) unities[0] + ((float) (unities[1] - unities[0]) * delta);
|
||||||
u *= 0.003051758F;
|
u *= 0.003051758F;
|
||||||
unity = (float) Math.pow(0.10000000000000001D, u / 20F);
|
unity = (float) Math.pow(0.10000000000000001D, u / 20F);
|
||||||
unity16 = (int) (unity * 65536F);
|
unity16 = (int) (unity * 65536F);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pairs[direction] == 0) {
|
if (pairs[direction] == 0) {
|
||||||
return 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][0] = -2F * u * (float) Math.cos(phase(direction, 0, delta));
|
||||||
coefficient[direction][1] = u * u;
|
coefficient[direction][1] = u * u;
|
||||||
|
|
||||||
for (int pair = 1; pair < pairs[direction]; pair++) {
|
for (int pair = 1; pair < pairs[direction]; pair++) {
|
||||||
float g = gain(direction, pair, delta);
|
float g = gain(direction, pair, delta);
|
||||||
float a = -2F * g * (float) Math.cos(phase(direction, pair, delta));
|
float a = -2F * g * (float) Math.cos(phase(direction, pair, delta));
|
||||||
float b = g * g;
|
float b = g * g;
|
||||||
|
|
||||||
coefficient[direction][(pair * 2) + 1] = coefficient[direction][(pair * 2) - 1] * 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);
|
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--) {
|
for (int j = (pair * 2) - 1; j >= 2; j--) {
|
||||||
coefficient[direction][j] += (coefficient[direction][j - 1] * a) + (coefficient[direction][j - 2] * b);
|
coefficient[direction][j] += (coefficient[direction][j - 1] * a) + (coefficient[direction][j - 2] * b);
|
||||||
}
|
}
|
||||||
|
|
||||||
coefficient[direction][1] += (coefficient[direction][0] * a) + b;
|
coefficient[direction][1] += (coefficient[direction][0] * a) + b;
|
||||||
coefficient[direction][0] += a;
|
coefficient[direction][0] += a;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direction == 0) {
|
if (direction == 0) {
|
||||||
for (int l = 0; l < (pairs[0] * 2); l++) {
|
for (int l = 0; l < (pairs[0] * 2); l++) {
|
||||||
coefficient[0][l] *= unity;
|
coefficient[0][l] *= unity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int pair = 0; pair < (pairs[direction] * 2); pair++) {
|
for (int pair = 0; pair < (pairs[direction] * 2); pair++) {
|
||||||
coefficient16[direction][pair] = (int) (coefficient[direction][pair] * 65536F);
|
coefficient16[direction][pair] = (int) (coefficient[direction][pair] * 65536F);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pairs[direction] * 2;
|
return pairs[direction] * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(Buffer buffer, SoundEnvelope envelope) {
|
public void read(Buffer buffer, SoundEnvelope envelope) {
|
||||||
int count = buffer.read8U();
|
int count = buffer.read8U();
|
||||||
pairs[0] = count >> 4;
|
pairs[0] = count >> 4;
|
||||||
pairs[1] = count & 0xf;
|
pairs[1] = count & 0xf;
|
||||||
|
|
||||||
if (count != 0) {
|
if (count != 0) {
|
||||||
unities[0] = buffer.read16U();
|
unities[0] = buffer.read16U();
|
||||||
unities[1] = buffer.read16U();
|
unities[1] = buffer.read16U();
|
||||||
|
|
||||||
int migration = buffer.read8U();
|
int migration = buffer.read8U();
|
||||||
|
|
||||||
for (int direction = 0; direction < 2; direction++) {
|
for (int direction = 0; direction < 2; direction++) {
|
||||||
for (int pair = 0; pair < pairs[direction]; pair++) {
|
for (int pair = 0; pair < pairs[direction]; pair++) {
|
||||||
frequencies[direction][0][pair] = buffer.read16U();
|
frequencies[direction][0][pair] = buffer.read16U();
|
||||||
ranges[direction][0][pair] = buffer.read16U();
|
ranges[direction][0][pair] = buffer.read16U();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int direction = 0; direction < 2; direction++) {
|
for (int direction = 0; direction < 2; direction++) {
|
||||||
for (int pair = 0; pair < pairs[direction]; pair++) {
|
for (int pair = 0; pair < pairs[direction]; pair++) {
|
||||||
if ((migration & (1 << (direction * 4) << pair)) != 0) {
|
if ((migration & (1 << (direction * 4) << pair)) != 0) {
|
||||||
frequencies[direction][1][pair] = buffer.read16U();
|
frequencies[direction][1][pair] = buffer.read16U();
|
||||||
ranges[direction][1][pair] = buffer.read16U();
|
ranges[direction][1][pair] = buffer.read16U();
|
||||||
} else {
|
} else {
|
||||||
frequencies[direction][1][pair] = frequencies[direction][0][pair];
|
frequencies[direction][1][pair] = frequencies[direction][0][pair];
|
||||||
ranges[direction][1][pair] = ranges[direction][0][pair];
|
ranges[direction][1][pair] = ranges[direction][0][pair];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((migration != 0) || (unities[1] != unities[0])) {
|
if ((migration != 0) || (unities[1] != unities[0])) {
|
||||||
envelope.readShape(buffer);
|
envelope.readShape(buffer);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unities[0] = unities[1] = 0;
|
unities[0] = unities[1] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+261
-261
@@ -4,324 +4,324 @@
|
|||||||
|
|
||||||
public class SoundTone {
|
public class SoundTone {
|
||||||
|
|
||||||
public static final int[] tmpPhases = new int[5];
|
public static final int[] tmpPhases = new int[5];
|
||||||
public static final int[] tmpDelays = new int[5];
|
public static final int[] tmpDelays = new int[5];
|
||||||
public static final int[] tmpVolumes = new int[5];
|
public static final int[] tmpVolumes = new int[5];
|
||||||
public static final int[] tmpSemitones = new int[5];
|
public static final int[] tmpSemitones = new int[5];
|
||||||
public static final int[] tmpStarts = new int[5];
|
public static final int[] tmpStarts = new int[5];
|
||||||
public static int[] buffer;
|
public static int[] buffer;
|
||||||
public static int[] noise;
|
public static int[] noise;
|
||||||
public static int[] sin;
|
public static int[] sin;
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
noise = new int[32768];
|
noise = new int[32768];
|
||||||
for (int i = 0; i < 32768; i++) {
|
for (int i = 0; i < 32768; i++) {
|
||||||
if (Math.random() > 0.5D) {
|
if (Math.random() > 0.5D) {
|
||||||
noise[i] = 1;
|
noise[i] = 1;
|
||||||
} else {
|
} else {
|
||||||
noise[i] = -1;
|
noise[i] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sin = new int[32768];
|
sin = new int[32768];
|
||||||
for (int j = 0; j < 32768; j++) {
|
for (int j = 0; j < 32768; j++) {
|
||||||
sin[j] = (int) (Math.sin((double) j / 5215.1903000000002D) * 16384D);
|
sin[j] = (int) (Math.sin((double) j / 5215.1903000000002D) * 16384D);
|
||||||
}
|
}
|
||||||
buffer = new int[22050 * 10]; // 10 second buffer
|
buffer = new int[22050 * 10]; // 10 second buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int[] harmonicVolume = new int[5];
|
public final int[] harmonicVolume = new int[5];
|
||||||
public final int[] harmonicSemitone = new int[5];
|
public final int[] harmonicSemitone = new int[5];
|
||||||
public final int[] harmonicDelay = new int[5];
|
public final int[] harmonicDelay = new int[5];
|
||||||
public SoundEnvelope frequencyBase;
|
public SoundEnvelope frequencyBase;
|
||||||
public SoundEnvelope amplitudeBase;
|
public SoundEnvelope amplitudeBase;
|
||||||
public SoundEnvelope frequencyModRate;
|
public SoundEnvelope frequencyModRate;
|
||||||
public SoundEnvelope frequencyModRange;
|
public SoundEnvelope frequencyModRange;
|
||||||
public SoundEnvelope amplitudeModRate;
|
public SoundEnvelope amplitudeModRate;
|
||||||
public SoundEnvelope amplitudeModRange;
|
public SoundEnvelope amplitudeModRange;
|
||||||
public SoundEnvelope release;
|
public SoundEnvelope release;
|
||||||
public SoundEnvelope attack;
|
public SoundEnvelope attack;
|
||||||
public int reverbDelay;
|
public int reverbDelay;
|
||||||
public int reverbVolume = 100;
|
public int reverbVolume = 100;
|
||||||
public SoundFilter filter;
|
public SoundFilter filter;
|
||||||
public SoundEnvelope filterRange;
|
public SoundEnvelope filterRange;
|
||||||
public int length = 500;
|
public int length = 500;
|
||||||
public int start;
|
public int start;
|
||||||
|
|
||||||
public SoundTone() {
|
public SoundTone() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] generate(int sampleCount, int length) {
|
public int[] generate(int sampleCount, int length) {
|
||||||
for (int sample = 0; sample < sampleCount; sample++) {
|
for (int sample = 0; sample < sampleCount; sample++) {
|
||||||
buffer[sample] = 0;
|
buffer[sample] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length < 10) {
|
if (length < 10) {
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
double samplesPerStep = (double) sampleCount / ((double) length + 0.0D);
|
double samplesPerStep = (double) sampleCount / ((double) length + 0.0D);
|
||||||
|
|
||||||
frequencyBase.reset();
|
frequencyBase.reset();
|
||||||
amplitudeBase.reset();
|
amplitudeBase.reset();
|
||||||
|
|
||||||
int frequencyStart = 0;
|
int frequencyStart = 0;
|
||||||
int frequencyDuration = 0;
|
int frequencyDuration = 0;
|
||||||
int frequencyPhase = 0;
|
int frequencyPhase = 0;
|
||||||
|
|
||||||
if (frequencyModRate != null) {
|
if (frequencyModRate != null) {
|
||||||
frequencyModRate.reset();
|
frequencyModRate.reset();
|
||||||
frequencyModRange.reset();
|
frequencyModRange.reset();
|
||||||
frequencyStart = (int) (((double) (frequencyModRate.end - frequencyModRate.start) * 32.768) / samplesPerStep);
|
frequencyStart = (int) (((double) (frequencyModRate.end - frequencyModRate.start) * 32.768) / samplesPerStep);
|
||||||
frequencyDuration = (int) (((double) frequencyModRate.start * 32.768) / samplesPerStep);
|
frequencyDuration = (int) (((double) frequencyModRate.start * 32.768) / samplesPerStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
int amplitudeStart = 0;
|
int amplitudeStart = 0;
|
||||||
int amplitudeDuration = 0;
|
int amplitudeDuration = 0;
|
||||||
int amplitudePhase = 0;
|
int amplitudePhase = 0;
|
||||||
|
|
||||||
if (amplitudeModRate != null) {
|
if (amplitudeModRate != null) {
|
||||||
amplitudeModRate.reset();
|
amplitudeModRate.reset();
|
||||||
amplitudeModRange.reset();
|
amplitudeModRange.reset();
|
||||||
amplitudeStart = (int) (((double) (amplitudeModRate.end - amplitudeModRate.start) * 32.768) / samplesPerStep);
|
amplitudeStart = (int) (((double) (amplitudeModRate.end - amplitudeModRate.start) * 32.768) / samplesPerStep);
|
||||||
amplitudeDuration = (int) (((double) amplitudeModRate.start * 32.768) / samplesPerStep);
|
amplitudeDuration = (int) (((double) amplitudeModRate.start * 32.768) / samplesPerStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int harmonic = 0; harmonic < 5; harmonic++) {
|
for (int harmonic = 0; harmonic < 5; harmonic++) {
|
||||||
if (harmonicVolume[harmonic] != 0) {
|
if (harmonicVolume[harmonic] != 0) {
|
||||||
tmpPhases[harmonic] = 0;
|
tmpPhases[harmonic] = 0;
|
||||||
tmpDelays[harmonic] = (int) ((double) harmonicDelay[harmonic] * samplesPerStep);
|
tmpDelays[harmonic] = (int) ((double) harmonicDelay[harmonic] * samplesPerStep);
|
||||||
tmpVolumes[harmonic] = (harmonicVolume[harmonic] << 14) / 100;
|
tmpVolumes[harmonic] = (harmonicVolume[harmonic] << 14) / 100;
|
||||||
tmpSemitones[harmonic] = (int) (((double) (frequencyBase.end - frequencyBase.start) * 32.768 * Math.pow(1.0057929410678534D, harmonicSemitone[harmonic])) / samplesPerStep);
|
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);
|
tmpStarts[harmonic] = (int) (((double) frequencyBase.start * 32.768) / samplesPerStep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int sample = 0; sample < sampleCount; sample++) {
|
for (int sample = 0; sample < sampleCount; sample++) {
|
||||||
int frequency = frequencyBase.evaluate(sampleCount);
|
int frequency = frequencyBase.evaluate(sampleCount);
|
||||||
int amplitude = amplitudeBase.evaluate(sampleCount);
|
int amplitude = amplitudeBase.evaluate(sampleCount);
|
||||||
|
|
||||||
if (frequencyModRate != null) {
|
if (frequencyModRate != null) {
|
||||||
int rate = frequencyModRate.evaluate(sampleCount);
|
int rate = frequencyModRate.evaluate(sampleCount);
|
||||||
int range = frequencyModRange.evaluate(sampleCount);
|
int range = frequencyModRange.evaluate(sampleCount);
|
||||||
frequency += generate(frequencyModRate.form, frequencyPhase, range) >> 1;
|
frequency += generate(frequencyModRate.form, frequencyPhase, range) >> 1;
|
||||||
frequencyPhase += ((rate * frequencyStart) >> 16) + frequencyDuration;
|
frequencyPhase += ((rate * frequencyStart) >> 16) + frequencyDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amplitudeModRate != null) {
|
if (amplitudeModRate != null) {
|
||||||
int rate = amplitudeModRate.evaluate(sampleCount);
|
int rate = amplitudeModRate.evaluate(sampleCount);
|
||||||
int range = amplitudeModRange.evaluate(sampleCount);
|
int range = amplitudeModRange.evaluate(sampleCount);
|
||||||
amplitude = (amplitude * ((generate(amplitudeModRate.form, amplitudePhase, range) >> 1) + 32768)) >> 15;
|
amplitude = (amplitude * ((generate(amplitudeModRate.form, amplitudePhase, range) >> 1) + 32768)) >> 15;
|
||||||
amplitudePhase += ((rate * amplitudeStart) >> 16) + amplitudeDuration;
|
amplitudePhase += ((rate * amplitudeStart) >> 16) + amplitudeDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int harmonic = 0; harmonic < 5; harmonic++) {
|
for (int harmonic = 0; harmonic < 5; harmonic++) {
|
||||||
if (harmonicVolume[harmonic] != 0) {
|
if (harmonicVolume[harmonic] != 0) {
|
||||||
int position = sample + tmpDelays[harmonic];
|
int position = sample + tmpDelays[harmonic];
|
||||||
|
|
||||||
if (position < sampleCount) {
|
if (position < sampleCount) {
|
||||||
buffer[position] += generate(frequencyBase.form, tmpPhases[harmonic], (amplitude * tmpVolumes[harmonic]) >> 15);
|
buffer[position] += generate(frequencyBase.form, tmpPhases[harmonic], (amplitude * tmpVolumes[harmonic]) >> 15);
|
||||||
tmpPhases[harmonic] += ((frequency * tmpSemitones[harmonic]) >> 16) + tmpStarts[harmonic];
|
tmpPhases[harmonic] += ((frequency * tmpSemitones[harmonic]) >> 16) + tmpStarts[harmonic];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (release != null) {
|
if (release != null) {
|
||||||
release.reset();
|
release.reset();
|
||||||
attack.reset();
|
attack.reset();
|
||||||
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
boolean muted = true;
|
boolean muted = true;
|
||||||
|
|
||||||
for (int sample = 0; sample < sampleCount; sample++) {
|
for (int sample = 0; sample < sampleCount; sample++) {
|
||||||
int releaseValue = release.evaluate(sampleCount);
|
int releaseValue = release.evaluate(sampleCount);
|
||||||
int attackValue = attack.evaluate(sampleCount);
|
int attackValue = attack.evaluate(sampleCount);
|
||||||
int threshold;
|
int threshold;
|
||||||
|
|
||||||
if (muted) {
|
if (muted) {
|
||||||
threshold = release.start + (((release.end - release.start) * releaseValue) >> 8);
|
threshold = release.start + (((release.end - release.start) * releaseValue) >> 8);
|
||||||
} else {
|
} else {
|
||||||
threshold = release.start + (((release.end - release.start) * attackValue) >> 8);
|
threshold = release.start + (((release.end - release.start) * attackValue) >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((counter += 256) >= threshold) {
|
if ((counter += 256) >= threshold) {
|
||||||
counter = 0;
|
counter = 0;
|
||||||
muted = !muted;
|
muted = !muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (muted) {
|
if (muted) {
|
||||||
buffer[sample] = 0;
|
buffer[sample] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((reverbDelay > 0) && (reverbVolume > 0)) {
|
if ((reverbDelay > 0) && (reverbVolume > 0)) {
|
||||||
int start = (int) ((double) reverbDelay * samplesPerStep);
|
int start = (int) ((double) reverbDelay * samplesPerStep);
|
||||||
|
|
||||||
for (int sample = start; sample < sampleCount; sample++) {
|
for (int sample = start; sample < sampleCount; sample++) {
|
||||||
buffer[sample] += (buffer[sample - start] * reverbVolume) / 100;
|
buffer[sample] += (buffer[sample - start] * reverbVolume) / 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((filter.pairs[0] > 0) || (filter.pairs[1] > 0)) {
|
if ((filter.pairs[0] > 0) || (filter.pairs[1] > 0)) {
|
||||||
filterRange.reset();
|
filterRange.reset();
|
||||||
|
|
||||||
int range = filterRange.evaluate(sampleCount + 1);
|
int range = filterRange.evaluate(sampleCount + 1);
|
||||||
int forward = filter.evaluate(0, (float) range / 65536F);
|
int forward = filter.evaluate(0, (float) range / 65536F);
|
||||||
int backward = filter.evaluate(1, (float) range / 65536F);
|
int backward = filter.evaluate(1, (float) range / 65536F);
|
||||||
|
|
||||||
if (sampleCount >= (forward + backward)) {
|
if (sampleCount >= (forward + backward)) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int interval = backward;
|
int interval = backward;
|
||||||
|
|
||||||
if (interval > (sampleCount - forward)) {
|
if (interval > (sampleCount - forward)) {
|
||||||
interval = sampleCount - forward;
|
interval = sampleCount - forward;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; index < interval; index++) {
|
for (; index < interval; index++) {
|
||||||
int sample = (int) (((long) buffer[index + forward] * (long) SoundFilter.unity16) >> 16);
|
int sample = (int) (((long) buffer[index + forward] * (long) SoundFilter.unity16) >> 16);
|
||||||
|
|
||||||
for (int offset = 0; offset < forward; offset++) {
|
for (int offset = 0; offset < forward; offset++) {
|
||||||
sample += (int) (((long) buffer[(index + forward) - 1 - offset] * (long) SoundFilter.coefficient16[0][offset]) >> 16);
|
sample += (int) (((long) buffer[(index + forward) - 1 - offset] * (long) SoundFilter.coefficient16[0][offset]) >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int offset = 0; offset < index; offset++) {
|
for (int offset = 0; offset < index; offset++) {
|
||||||
sample -= (int) (((long) buffer[index - 1 - offset] * (long) SoundFilter.coefficient16[1][offset]) >> 16);
|
sample -= (int) (((long) buffer[index - 1 - offset] * (long) SoundFilter.coefficient16[1][offset]) >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[index] = sample;
|
buffer[index] = sample;
|
||||||
range = filterRange.evaluate(sampleCount + 1);
|
range = filterRange.evaluate(sampleCount + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
interval = 128;
|
interval = 128;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (interval > (sampleCount - forward)) {
|
if (interval > (sampleCount - forward)) {
|
||||||
interval = sampleCount - forward;
|
interval = sampleCount - forward;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; index < interval; index++) {
|
for (; index < interval; index++) {
|
||||||
int sample = (int) (((long) buffer[index + forward] * (long) SoundFilter.unity16) >> 16);
|
int sample = (int) (((long) buffer[index + forward] * (long) SoundFilter.unity16) >> 16);
|
||||||
|
|
||||||
for (int offset = 0; offset < forward; offset++) {
|
for (int offset = 0; offset < forward; offset++) {
|
||||||
sample += (int) (((long) buffer[(index + forward) - 1 - offset] * (long) SoundFilter.coefficient16[0][offset]) >> 16);
|
sample += (int) (((long) buffer[(index + forward) - 1 - offset] * (long) SoundFilter.coefficient16[0][offset]) >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int offset = 0; offset < backward; offset++) {
|
for (int offset = 0; offset < backward; offset++) {
|
||||||
sample -= (int) (((long) buffer[index - 1 - offset] * (long) SoundFilter.coefficient16[1][offset]) >> 16);
|
sample -= (int) (((long) buffer[index - 1 - offset] * (long) SoundFilter.coefficient16[1][offset]) >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[index] = sample;
|
buffer[index] = sample;
|
||||||
range = filterRange.evaluate(sampleCount + 1);
|
range = filterRange.evaluate(sampleCount + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index >= (sampleCount - forward)) {
|
if (index >= (sampleCount - forward)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
forward = filter.evaluate(0, (float) range / 65536F);
|
forward = filter.evaluate(0, (float) range / 65536F);
|
||||||
backward = filter.evaluate(1, (float) range / 65536F);
|
backward = filter.evaluate(1, (float) range / 65536F);
|
||||||
interval += 128;
|
interval += 128;
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
for (; index < sampleCount; index++) {
|
for (; index < sampleCount; index++) {
|
||||||
int sample = 0;
|
int sample = 0;
|
||||||
|
|
||||||
for (int offset = (index + forward) - sampleCount; offset < forward; offset++) {
|
for (int offset = (index + forward) - sampleCount; offset < forward; offset++) {
|
||||||
sample += (int) (((long) buffer[(index + forward) - 1 - offset] * (long) SoundFilter.coefficient16[0][offset]) >> 16);
|
sample += (int) (((long) buffer[(index + forward) - 1 - offset] * (long) SoundFilter.coefficient16[0][offset]) >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int offset = 0; offset < backward; offset++) {
|
for (int offset = 0; offset < backward; offset++) {
|
||||||
sample -= (int) (((long) buffer[index - 1 - offset] * (long) SoundFilter.coefficient16[1][offset]) >> 16);
|
sample -= (int) (((long) buffer[index - 1 - offset] * (long) SoundFilter.coefficient16[1][offset]) >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[index] = sample;
|
buffer[index] = sample;
|
||||||
filterRange.evaluate(sampleCount + 1);
|
filterRange.evaluate(sampleCount + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int sample = 0; sample < sampleCount; sample++) {
|
for (int sample = 0; sample < sampleCount; sample++) {
|
||||||
if (buffer[sample] < -32768) {
|
if (buffer[sample] < -32768) {
|
||||||
buffer[sample] = -32768;
|
buffer[sample] = -32768;
|
||||||
}
|
}
|
||||||
if (buffer[sample] > 32767) {
|
if (buffer[sample] > 32767) {
|
||||||
buffer[sample] = 32767;
|
buffer[sample] = 32767;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int generate(int form, int phase, int amplitude) {
|
public int generate(int form, int phase, int amplitude) {
|
||||||
if (form == 1) {
|
if (form == 1) {
|
||||||
if ((phase & 0x7fff) < 16384) {
|
if ((phase & 0x7fff) < 16384) {
|
||||||
return amplitude;
|
return amplitude;
|
||||||
} else {
|
} else {
|
||||||
return -amplitude;
|
return -amplitude;
|
||||||
}
|
}
|
||||||
} else if (form == 2) {
|
} else if (form == 2) {
|
||||||
return (sin[phase & 0x7fff] * amplitude) >> 14;
|
return (sin[phase & 0x7fff] * amplitude) >> 14;
|
||||||
} else if (form == 3) {
|
} else if (form == 3) {
|
||||||
return (((phase & 0x7fff) * amplitude) >> 14) - amplitude;
|
return (((phase & 0x7fff) * amplitude) >> 14) - amplitude;
|
||||||
} else if (form == 4) {
|
} else if (form == 4) {
|
||||||
return noise[(phase / 2607) & 0x7fff] * amplitude;
|
return noise[(phase / 2607) & 0x7fff] * amplitude;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(Buffer buffer) {
|
public void read(Buffer buffer) {
|
||||||
frequencyBase = new SoundEnvelope();
|
frequencyBase = new SoundEnvelope();
|
||||||
frequencyBase.read(buffer);
|
frequencyBase.read(buffer);
|
||||||
amplitudeBase = new SoundEnvelope();
|
amplitudeBase = new SoundEnvelope();
|
||||||
amplitudeBase.read(buffer);
|
amplitudeBase.read(buffer);
|
||||||
|
|
||||||
if (buffer.read8U() != 0) {
|
if (buffer.read8U() != 0) {
|
||||||
buffer.position--;
|
buffer.position--;
|
||||||
frequencyModRate = new SoundEnvelope();
|
frequencyModRate = new SoundEnvelope();
|
||||||
frequencyModRate.read(buffer);
|
frequencyModRate.read(buffer);
|
||||||
frequencyModRange = new SoundEnvelope();
|
frequencyModRange = new SoundEnvelope();
|
||||||
frequencyModRange.read(buffer);
|
frequencyModRange.read(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer.read8U() != 0) {
|
if (buffer.read8U() != 0) {
|
||||||
buffer.position--;
|
buffer.position--;
|
||||||
amplitudeModRate = new SoundEnvelope();
|
amplitudeModRate = new SoundEnvelope();
|
||||||
amplitudeModRate.read(buffer);
|
amplitudeModRate.read(buffer);
|
||||||
amplitudeModRange = new SoundEnvelope();
|
amplitudeModRange = new SoundEnvelope();
|
||||||
amplitudeModRange.read(buffer);
|
amplitudeModRange.read(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer.read8U() != 0) {
|
if (buffer.read8U() != 0) {
|
||||||
buffer.position--;
|
buffer.position--;
|
||||||
release = new SoundEnvelope();
|
release = new SoundEnvelope();
|
||||||
release.read(buffer);
|
release.read(buffer);
|
||||||
attack = new SoundEnvelope();
|
attack = new SoundEnvelope();
|
||||||
attack.read(buffer);
|
attack.read(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
int volume = buffer.readSmartU();
|
int volume = buffer.readSmartU();
|
||||||
|
|
||||||
if (volume == 0) {
|
if (volume == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
harmonicVolume[i] = volume;
|
harmonicVolume[i] = volume;
|
||||||
harmonicSemitone[i] = buffer.readSmart();
|
harmonicSemitone[i] = buffer.readSmart();
|
||||||
harmonicDelay[i] = buffer.readSmartU();
|
harmonicDelay[i] = buffer.readSmartU();
|
||||||
}
|
}
|
||||||
|
|
||||||
reverbDelay = buffer.readSmartU();
|
reverbDelay = buffer.readSmartU();
|
||||||
reverbVolume = buffer.readSmartU();
|
reverbVolume = buffer.readSmartU();
|
||||||
|
|
||||||
length = buffer.read16U();
|
length = buffer.read16U();
|
||||||
start = buffer.read16U();
|
start = buffer.read16U();
|
||||||
|
|
||||||
filter = new SoundFilter();
|
filter = new SoundFilter();
|
||||||
filterRange = new SoundEnvelope();
|
filterRange = new SoundEnvelope();
|
||||||
filter.read(buffer, filterRange);
|
filter.read(buffer, filterRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+141
-141
@@ -1,172 +1,172 @@
|
|||||||
public class SoundTrack {
|
public class SoundTrack {
|
||||||
|
|
||||||
public static final SoundTrack[] tracks = new SoundTrack[5000];
|
public static final SoundTrack[] tracks = new SoundTrack[5000];
|
||||||
public static final int[] delays = new int[5000];
|
public static final int[] delays = new int[5000];
|
||||||
public static byte[] waveBytes = new byte[441000];
|
public static byte[] waveBytes = new byte[441000];
|
||||||
public static Buffer waveBuffer = new Buffer(waveBytes);
|
public static Buffer waveBuffer = new Buffer(waveBytes);
|
||||||
|
|
||||||
public static void unpack(Buffer in) {
|
public static void unpack(Buffer in) {
|
||||||
SoundTone.init();
|
SoundTone.init();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
int id = in.read16U();
|
int id = in.read16U();
|
||||||
|
|
||||||
if (id == 65535) {
|
if (id == 65535) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tracks[id] = new SoundTrack();
|
tracks[id] = new SoundTrack();
|
||||||
tracks[id].read(in);
|
tracks[id].read(in);
|
||||||
delays[id] = tracks[id].trim();
|
delays[id] = tracks[id].trim();
|
||||||
} while (true);
|
} while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Buffer generate(int loopCount, int id) {
|
public static Buffer generate(int loopCount, int id) {
|
||||||
if (tracks[id] != null) {
|
if (tracks[id] != null) {
|
||||||
SoundTrack track = tracks[id];
|
SoundTrack track = tracks[id];
|
||||||
return track.getWave(loopCount);
|
return track.getWave(loopCount);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final SoundTone[] tones = new SoundTone[10];
|
public final SoundTone[] tones = new SoundTone[10];
|
||||||
public int loopBegin;
|
public int loopBegin;
|
||||||
public int loopEnd;
|
public int loopEnd;
|
||||||
|
|
||||||
public SoundTrack() {
|
public SoundTrack() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(Buffer buffer) {
|
public void read(Buffer buffer) {
|
||||||
for (int tone = 0; tone < 10; tone++) {
|
for (int tone = 0; tone < 10; tone++) {
|
||||||
if (buffer.read8U() != 0) {
|
if (buffer.read8U() != 0) {
|
||||||
buffer.position--;
|
buffer.position--;
|
||||||
tones[tone] = new SoundTone();
|
tones[tone] = new SoundTone();
|
||||||
tones[tone].read(buffer);
|
tones[tone].read(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loopBegin = buffer.read16U();
|
loopBegin = buffer.read16U();
|
||||||
loopEnd = buffer.read16U();
|
loopEnd = buffer.read16U();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int trim() {
|
public int trim() {
|
||||||
int start = 9999999;
|
int start = 9999999;
|
||||||
for (int tone = 0; tone < 10; tone++) {
|
for (int tone = 0; tone < 10; tone++) {
|
||||||
if ((tones[tone] != null) && ((tones[tone].start / 20) < start)) {
|
if ((tones[tone] != null) && ((tones[tone].start / 20) < start)) {
|
||||||
start = tones[tone].start / 20;
|
start = tones[tone].start / 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((loopBegin < loopEnd) && ((loopBegin / 20) < start)) {
|
if ((loopBegin < loopEnd) && ((loopBegin / 20) < start)) {
|
||||||
start = loopBegin / 20;
|
start = loopBegin / 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((start == 9999999) || (start == 0)) {
|
if ((start == 9999999) || (start == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int tone = 0; tone < 10; tone++) {
|
for (int tone = 0; tone < 10; tone++) {
|
||||||
if (tones[tone] != null) {
|
if (tones[tone] != null) {
|
||||||
tones[tone].start -= start * 20;
|
tones[tone].start -= start * 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (loopBegin < loopEnd) {
|
if (loopBegin < loopEnd) {
|
||||||
loopBegin -= start * 20;
|
loopBegin -= start * 20;
|
||||||
loopEnd -= start * 20;
|
loopEnd -= start * 20;
|
||||||
}
|
}
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <a href="http://soundfile.sapp.org/doc/WaveFormat/">WaveFormat</a>
|
* <a href="http://soundfile.sapp.org/doc/WaveFormat/">WaveFormat</a>
|
||||||
*
|
*
|
||||||
* @param loopCount the loop count.
|
* @param loopCount the loop count.
|
||||||
* @return the {@link Buffer} containing the waveform data.
|
* @return the {@link Buffer} containing the waveform data.
|
||||||
*/
|
*/
|
||||||
public Buffer getWave(int loopCount) {
|
public Buffer getWave(int loopCount) {
|
||||||
int length = generate(loopCount);
|
int length = generate(loopCount);
|
||||||
waveBuffer.position = 0;
|
waveBuffer.position = 0;
|
||||||
waveBuffer.write32(0x52494646); // "RIFF" ChunkID
|
waveBuffer.write32(0x52494646); // "RIFF" ChunkID
|
||||||
waveBuffer.write32LE(36 + length); // ChunkSize
|
waveBuffer.write32LE(36 + length); // ChunkSize
|
||||||
waveBuffer.write32(0x57415645); // "WAVE" format
|
waveBuffer.write32(0x57415645); // "WAVE" format
|
||||||
waveBuffer.write32(0x666d7420); // "fmt " chunk id
|
waveBuffer.write32(0x666d7420); // "fmt " chunk id
|
||||||
waveBuffer.write32LE(16); // chunk size
|
waveBuffer.write32LE(16); // chunk size
|
||||||
waveBuffer.write16LE(1); // audio format
|
waveBuffer.write16LE(1); // audio format
|
||||||
waveBuffer.write16LE(1); // num channels
|
waveBuffer.write16LE(1); // num channels
|
||||||
waveBuffer.write32LE(22050); // sample rate
|
waveBuffer.write32LE(22050); // sample rate
|
||||||
waveBuffer.write32LE(22050); // byte rate
|
waveBuffer.write32LE(22050); // byte rate
|
||||||
waveBuffer.write16LE(1); // block align
|
waveBuffer.write16LE(1); // block align
|
||||||
waveBuffer.write16LE(8); // bits per sample
|
waveBuffer.write16LE(8); // bits per sample
|
||||||
waveBuffer.write32(0x64617461); // "data"
|
waveBuffer.write32(0x64617461); // "data"
|
||||||
waveBuffer.write32LE(length);
|
waveBuffer.write32LE(length);
|
||||||
waveBuffer.position += length;
|
waveBuffer.position += length;
|
||||||
return waveBuffer;
|
return waveBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int generate(int loopCount) {
|
public int generate(int loopCount) {
|
||||||
int duration = 0;
|
int duration = 0;
|
||||||
|
|
||||||
for (int tone = 0; tone < 10; tone++) {
|
for (int tone = 0; tone < 10; tone++) {
|
||||||
if ((tones[tone] != null) && ((tones[tone].length + tones[tone].start) > duration)) {
|
if ((tones[tone] != null) && ((tones[tone].length + tones[tone].start) > duration)) {
|
||||||
duration = tones[tone].length + tones[tone].start;
|
duration = tones[tone].length + tones[tone].start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (duration == 0) {
|
if (duration == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sampleCount = (22050 * duration) / 1000;
|
int sampleCount = (22050 * duration) / 1000;
|
||||||
int loopStart = (22050 * loopBegin) / 1000;
|
int loopStart = (22050 * loopBegin) / 1000;
|
||||||
int loopStop = (22050 * loopEnd) / 1000;
|
int loopStop = (22050 * loopEnd) / 1000;
|
||||||
|
|
||||||
if ((loopStart < 0) || (loopStop < 0) || (loopStop > sampleCount) || (loopStart >= loopStop)) {
|
if ((loopStart < 0) || (loopStop < 0) || (loopStop > sampleCount) || (loopStart >= loopStop)) {
|
||||||
loopCount = 0;
|
loopCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int totalSampleCount = sampleCount + ((loopStop - loopStart) * (loopCount - 1));
|
int totalSampleCount = sampleCount + ((loopStop - loopStart) * (loopCount - 1));
|
||||||
|
|
||||||
for (int sample = 44; sample < (totalSampleCount + 44); sample++) {
|
for (int sample = 44; sample < (totalSampleCount + 44); sample++) {
|
||||||
waveBytes[sample] = -128;
|
waveBytes[sample] = -128;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int tone = 0; tone < 10; tone++) {
|
for (int tone = 0; tone < 10; tone++) {
|
||||||
if (tones[tone] == null) {
|
if (tones[tone] == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int toneSampleCount = (tones[tone].length * 22050) / 1000;
|
int toneSampleCount = (tones[tone].length * 22050) / 1000;
|
||||||
int start = (tones[tone].start * 22050) / 1000;
|
int start = (tones[tone].start * 22050) / 1000;
|
||||||
int[] samples = tones[tone].generate(toneSampleCount, tones[tone].length);
|
int[] samples = tones[tone].generate(toneSampleCount, tones[tone].length);
|
||||||
|
|
||||||
for (int sample = 0; sample < toneSampleCount; sample++) {
|
for (int sample = 0; sample < toneSampleCount; sample++) {
|
||||||
waveBytes[sample + start + 44] += (byte) (samples[sample] >> 8);
|
waveBytes[sample + start + 44] += (byte) (samples[sample] >> 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loopCount > 1) {
|
if (loopCount > 1) {
|
||||||
// All of these 44's are because we're avoiding the area where the WAV header will be written.
|
// All of these 44's are because we're avoiding the area where the WAV header will be written.
|
||||||
loopStart += 44;
|
loopStart += 44;
|
||||||
loopStop += 44;
|
loopStop += 44;
|
||||||
sampleCount += 44;
|
sampleCount += 44;
|
||||||
|
|
||||||
// Moves the end of the sound (after the loops) to the true end of the buffer.
|
// Moves the end of the sound (after the loops) to the true end of the buffer.
|
||||||
int endOffset = (totalSampleCount += 44) - sampleCount;
|
int endOffset = (totalSampleCount += 44) - sampleCount;
|
||||||
for (int sample = sampleCount - 1; sample >= loopStop; sample--) {
|
for (int sample = sampleCount - 1; sample >= loopStop; sample--) {
|
||||||
waveBytes[sample + endOffset] = waveBytes[sample];
|
waveBytes[sample + endOffset] = waveBytes[sample];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Duplicates loop area.
|
// Duplicates loop area.
|
||||||
for (int loop = 1; loop < loopCount; loop++) {
|
for (int loop = 1; loop < loopCount; loop++) {
|
||||||
int offset = (loopStop - loopStart) * loop;
|
int offset = (loopStop - loopStart) * loop;
|
||||||
for (int sample = loopStart; sample < loopStop; sample++) {
|
for (int sample = loopStart; sample < loopStop; sample++) {
|
||||||
waveBytes[sample + offset] = waveBytes[sample];
|
waveBytes[sample + offset] = waveBytes[sample];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
totalSampleCount -= 44;
|
totalSampleCount -= 44;
|
||||||
}
|
}
|
||||||
return totalSampleCount;
|
return totalSampleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,76 +4,76 @@
|
|||||||
|
|
||||||
public class SpotAnimEntity extends Entity {
|
public class SpotAnimEntity extends Entity {
|
||||||
|
|
||||||
public final int level;
|
public final int level;
|
||||||
public final int x;
|
public final int x;
|
||||||
public final int z;
|
public final int z;
|
||||||
public final int y;
|
public final int y;
|
||||||
public final int startCycle;
|
public final int startCycle;
|
||||||
public final SpotAnimType type;
|
public final SpotAnimType type;
|
||||||
public boolean seqComplete = false;
|
public boolean seqComplete = false;
|
||||||
public int seqFrame;
|
public int seqFrame;
|
||||||
public int seqCycle;
|
public int seqCycle;
|
||||||
|
|
||||||
public SpotAnimEntity(int level, int cycle, int delay, int id, int y, int z, int x) {
|
public SpotAnimEntity(int level, int cycle, int delay, int id, int y, int z, int x) {
|
||||||
type = SpotAnimType.instances[id];
|
type = SpotAnimType.instances[id];
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
startCycle = cycle + delay;
|
startCycle = cycle + delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Model getModel() {
|
public Model getModel() {
|
||||||
Model base = type.getModel();
|
Model base = type.getModel();
|
||||||
|
|
||||||
if (base == null) {
|
if (base == null) {
|
||||||
return 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) {
|
if (!seqComplete) {
|
||||||
model.createLabelReferences();
|
model.createLabelReferences();
|
||||||
model.applyTransform(transformID);
|
model.applyTransform(transformID);
|
||||||
model.labelFaces = null;
|
model.labelFaces = null;
|
||||||
model.labelVertices = null;
|
model.labelVertices = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((type.scaleXY != 128) || (type.scaleZ != 128)) {
|
if ((type.scaleXY != 128) || (type.scaleZ != 128)) {
|
||||||
model.scale(type.scaleXY, type.scaleXY, type.scaleZ);
|
model.scale(type.scaleXY, type.scaleXY, type.scaleZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.rotation != 0) {
|
if (type.rotation != 0) {
|
||||||
if (type.rotation == 90) {
|
if (type.rotation == 90) {
|
||||||
model.rotateY90();
|
model.rotateY90();
|
||||||
}
|
}
|
||||||
if (type.rotation == 180) {
|
if (type.rotation == 180) {
|
||||||
model.rotateY90();
|
model.rotateY90();
|
||||||
model.rotateY90();
|
model.rotateY90();
|
||||||
}
|
}
|
||||||
if (type.rotation == 270) {
|
if (type.rotation == 270) {
|
||||||
model.rotateY90();
|
model.rotateY90();
|
||||||
model.rotateY90();
|
model.rotateY90();
|
||||||
model.rotateY90();
|
model.rotateY90();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
model.calculateNormals(64 + type.lightAmbient, 850 + type.lightAttenuation, -30, -50, -30, true);
|
model.calculateNormals(64 + type.lightAmbient, 850 + type.lightAttenuation, -30, -50, -30, true);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(int delta) {
|
public void update(int delta) {
|
||||||
for (seqCycle += delta; seqCycle > type.seq.getFrameDuration(seqFrame); ) {
|
for (seqCycle += delta; seqCycle > type.seq.getFrameDuration(seqFrame); ) {
|
||||||
seqCycle -= type.seq.getFrameDuration(seqFrame) + 1;
|
seqCycle -= type.seq.getFrameDuration(seqFrame) + 1;
|
||||||
seqFrame++;
|
seqFrame++;
|
||||||
|
|
||||||
if (seqFrame >= type.seq.frameCount) {
|
if (seqFrame >= type.seq.frameCount) {
|
||||||
seqFrame = 0;
|
seqFrame = 0;
|
||||||
seqComplete = true;
|
seqComplete = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,93 +5,94 @@ import java.util.Arrays;
|
|||||||
*/
|
*/
|
||||||
public class StringUtil {
|
public class StringUtil {
|
||||||
|
|
||||||
private static final char[] BASE37_TABLE = { //
|
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', //
|
'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' //
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9' //
|
||||||
};
|
};
|
||||||
|
|
||||||
public static long toBase37(String s) {
|
public static long toBase37(String s) {
|
||||||
long l = 0L;
|
long l = 0L;
|
||||||
for (int i = 0; (i < s.length()) && (i < 12); i++) {
|
for (int i = 0; (i < s.length()) && (i < 12); i++) {
|
||||||
char c = s.charAt(i);
|
char c = s.charAt(i);
|
||||||
l *= 37L;
|
l *= 37L;
|
||||||
if ((c >= 'A') && (c <= 'Z')) {
|
if ((c >= 'A') && (c <= 'Z')) {
|
||||||
l += (1 + c) - 'A';
|
l += (1 + c) - 'A';
|
||||||
} else if ((c >= 'a') && (c <= 'z')) {
|
} else if ((c >= 'a') && (c <= 'z')) {
|
||||||
l += (1 + c) - 'a';
|
l += (1 + c) - 'a';
|
||||||
} else if ((c >= '0') && (c <= '9')) {
|
} else if ((c >= '0') && (c <= '9')) {
|
||||||
l += (27 + c) - '0';
|
l += (27 + c) - '0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (((l % 37L) == 0L) && (l != 0L)) {
|
while (((l % 37L) == 0L) && (l != 0L)) {
|
||||||
l /= 37L;
|
l /= 37L;
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String fromBase37(long value) {
|
public static String fromBase37(long value) {
|
||||||
if ((value <= 0L) || (value >= 0x5b5b57f8a98a5dd1L)/*37^12*/) {
|
if ((value <= 0L) || (value >= 0x5b5b57f8a98a5dd1L)/*37^12*/) {
|
||||||
return "invalid_name";
|
return "invalid_name";
|
||||||
}
|
}
|
||||||
if ((value % 37L) == 0L) {
|
if ((value % 37L) == 0L) {
|
||||||
return "invalid_name";
|
return "invalid_name";
|
||||||
}
|
}
|
||||||
int len = 0;
|
int len = 0;
|
||||||
char[] tmp = new char[12];
|
char[] tmp = new char[12];
|
||||||
while (value != 0L) {
|
while (value != 0L) {
|
||||||
long last = value;
|
long last = value;
|
||||||
value /= 37L;
|
value /= 37L;
|
||||||
tmp[11 - len++] = BASE37_TABLE[(int) (last - (value * 37L))];
|
tmp[11 - len++] = BASE37_TABLE[(int) (last - (value * 37L))];
|
||||||
}
|
}
|
||||||
return new String(tmp, 12 - len, len);
|
return new String(tmp, 12 - len, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long hashCode(String s) {
|
public static long hashCode(String s) {
|
||||||
s = s.toUpperCase();
|
s = s.toUpperCase();
|
||||||
long hash = 0L;
|
long hash = 0L;
|
||||||
for (int i = 0; i < s.length(); i++) {
|
for (int i = 0; i < s.length(); i++) {
|
||||||
hash = ((hash * 61L) + (long) s.charAt(i)) - 32L;
|
hash = ((hash * 61L) + (long) s.charAt(i)) - 32L;
|
||||||
hash = (hash + (hash >> 56)) & 0xffffffffffffffL;
|
hash = (hash + (hash >> 56)) & 0xffffffffffffffL;
|
||||||
}
|
}
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatIPv4(int ipv4) {
|
public static String formatIPv4(int ipv4) {
|
||||||
return String.format("%d.%d.%d.%d", (ipv4 >> 24) & 0xff, (ipv4 >> 16) & 0xff, (ipv4 >> 8) & 0xff, ipv4 & 0xff);
|
return String.format("%d.%d.%d.%d", (ipv4 >> 24) & 0xff, (ipv4 >> 16) & 0xff, (ipv4 >> 8) & 0xff, ipv4 & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatName(long name37) {
|
public static String formatName(long name37) {
|
||||||
return formatName(fromBase37(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 toAsterisks(String s) {
|
public static String formatName(String s) {
|
||||||
char[] chars = new char[s.length()];
|
if (s.length() > 0) {
|
||||||
Arrays.fill(chars, '*');
|
char[] ac = s.toCharArray();
|
||||||
return new String(chars, 0, chars.length);
|
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() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,57 +6,57 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class VarbitType {
|
public class VarbitType {
|
||||||
|
|
||||||
public static VarbitType[] instances;
|
public static VarbitType[] instances;
|
||||||
|
|
||||||
public static void unpack(FileArchive archive) throws IOException {
|
public static void unpack(FileArchive archive) throws IOException {
|
||||||
Buffer buffer = new Buffer(archive.read("varbit.dat"));
|
Buffer buffer = new Buffer(archive.read("varbit.dat"));
|
||||||
int count = buffer.read16U();
|
int count = buffer.read16U();
|
||||||
|
|
||||||
if (instances == null) {
|
if (instances == null) {
|
||||||
instances = new VarbitType[count];
|
instances = new VarbitType[count];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < count; j++) {
|
for (int j = 0; j < count; j++) {
|
||||||
if (instances[j] == null) {
|
if (instances[j] == null) {
|
||||||
instances[j] = new VarbitType();
|
instances[j] = new VarbitType();
|
||||||
}
|
}
|
||||||
instances[j].read(buffer);
|
instances[j].read(buffer);
|
||||||
}
|
}
|
||||||
if (buffer.position != buffer.data.length) {
|
if (buffer.position != buffer.data.length) {
|
||||||
System.out.println("varbit load mismatch");
|
System.out.println("varbit load mismatch");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int varp;
|
public int varp;
|
||||||
/**
|
/**
|
||||||
* The least significant bit.
|
* The least significant bit.
|
||||||
*/
|
*/
|
||||||
public int lsb;
|
public int lsb;
|
||||||
/**
|
/**
|
||||||
* The most significant bit.
|
* The most significant bit.
|
||||||
*/
|
*/
|
||||||
public int msb;
|
public int msb;
|
||||||
|
|
||||||
public VarbitType() {
|
public VarbitType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(Buffer buffer) {
|
public void read(Buffer buffer) {
|
||||||
do {
|
do {
|
||||||
int code = buffer.read8U();
|
int code = buffer.read8U();
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
return;
|
return;
|
||||||
} else if (code == 1) {
|
} else if (code == 1) {
|
||||||
varp = buffer.read16U();
|
varp = buffer.read16U();
|
||||||
lsb = buffer.read8U();
|
lsb = buffer.read8U();
|
||||||
msb = buffer.read8U();
|
msb = buffer.read8U();
|
||||||
} else if (code == 10) {
|
} else if (code == 10) {
|
||||||
buffer.readString();
|
buffer.readString();
|
||||||
} else if (code == 3 || code == 4) {
|
} else if (code == 3 || code == 4) {
|
||||||
buffer.read32();
|
buffer.read32();
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Error unrecognised varbit config code: " + code);
|
System.out.println("Error unrecognised varbit config code: " + code);
|
||||||
}
|
}
|
||||||
} while (true);
|
} while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+39
-39
@@ -6,48 +6,48 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class VarpType {
|
public class VarpType {
|
||||||
|
|
||||||
public static int count;
|
public static int count;
|
||||||
public static VarpType[] instances;
|
public static VarpType[] instances;
|
||||||
|
|
||||||
public static void unpack(FileArchive archive) throws IOException {
|
public static void unpack(FileArchive archive) throws IOException {
|
||||||
Buffer buffer = new Buffer(archive.read("varp.dat"));
|
Buffer buffer = new Buffer(archive.read("varp.dat"));
|
||||||
count = buffer.read16U();
|
count = buffer.read16U();
|
||||||
if (instances == null) {
|
if (instances == null) {
|
||||||
instances = new VarpType[count];
|
instances = new VarpType[count];
|
||||||
}
|
}
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
if (instances[i] == null) {
|
if (instances[i] == null) {
|
||||||
instances[i] = new VarpType();
|
instances[i] = new VarpType();
|
||||||
}
|
}
|
||||||
instances[i].read(buffer);
|
instances[i].read(buffer);
|
||||||
}
|
}
|
||||||
if (buffer.position != buffer.data.length) {
|
if (buffer.position != buffer.data.length) {
|
||||||
System.out.println("varptype load mismatch");
|
System.out.println("varptype load mismatch");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int type;
|
public int type;
|
||||||
|
|
||||||
public VarpType() {
|
public VarpType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(Buffer in) {
|
public void read(Buffer in) {
|
||||||
while (true) {
|
while (true) {
|
||||||
int code = in.read8U();
|
int code = in.read8U();
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
return;
|
return;
|
||||||
} else if (code == 1 || code == 2) {
|
} else if (code == 1 || code == 2) {
|
||||||
in.read8U();
|
in.read8U();
|
||||||
} else if (code == 5) {
|
} else if (code == 5) {
|
||||||
type = in.read16U();
|
type = in.read16U();
|
||||||
} else if (code == 7 || code == 12) {
|
} else if (code == 7 || code == 12) {
|
||||||
in.read32();
|
in.read32();
|
||||||
} else if (code == 10) {
|
} else if (code == 10) {
|
||||||
in.readString();
|
in.readString();
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Error unrecognised varp config code: " + code);
|
System.out.println("Error unrecognised varp config code: " + code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,12 +4,12 @@
|
|||||||
|
|
||||||
public class VertexNormal {
|
public class VertexNormal {
|
||||||
|
|
||||||
public int x;
|
public int x;
|
||||||
public int y;
|
public int y;
|
||||||
public int z;
|
public int z;
|
||||||
public int w;
|
public int w;
|
||||||
|
|
||||||
public VertexNormal() {
|
public VertexNormal() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user