diff --git a/src/main/java/Buffer.java b/src/main/java/Buffer.java index facb9de..b1d9441 100644 --- a/src/main/java/Buffer.java +++ b/src/main/java/Buffer.java @@ -3,6 +3,7 @@ // Decompiler options: packimports(3) import java.math.BigInteger; +import java.nio.charset.StandardCharsets; public class Buffer extends DoublyLinkedListNode { @@ -17,6 +18,7 @@ public class Buffer extends DoublyLinkedListNode { public static Buffer create(int sizeType) { synchronized (bufferPool1) { Buffer buffer = null; + if ((sizeType == 0) && (bufferPoolSize0 > 0)) { bufferPoolSize0--; buffer = (Buffer) bufferPool0.method251(); @@ -27,13 +29,16 @@ public class Buffer extends DoublyLinkedListNode { bufferPoolSize2--; buffer = (Buffer) bufferPool2.method251(); } + if (buffer != null) { buffer.position = 0; return buffer; } } + Buffer buffer = new Buffer(); buffer.position = 0; + if (sizeType == 0) { buffer.data = new byte[100]; } else if (sizeType == 1) { @@ -41,6 +46,7 @@ public class Buffer extends DoublyLinkedListNode { } else { buffer.data = new byte[30000]; } + return buffer; } @@ -129,18 +135,20 @@ public class Buffer extends DoublyLinkedListNode { } public void putString(String s) { - s.getBytes(0, s.length(), data, position); - position += s.length(); - data[position++] = 10; + put(s.getBytes(StandardCharsets.US_ASCII)); + put8('\n'); } - public void putBytes(byte[] src, int len, int off) { - for (int k = off; k < (off + len); k++) { - data[position++] = src[k]; - } + public void put(byte[] src, int len, int off) { + System.arraycopy(src, off, data, position, len); + position += len; } - public void putBytesA(int off, byte[] src, int len) { + public void put(byte[] src) { + put(src, 0, src.length); + } + + public void putA(byte[] src, int off, int len) { for (int i = (off + len) - 1; i >= off; i--) { data[position++] = (byte) (src[i] + 128); } @@ -283,13 +291,12 @@ public class Buffer extends DoublyLinkedListNode { return raw; } - public void getBytes(byte[] dst, int off, int len) { - for (int i = off; i < (off + len); i++) { - dst[i] = data[position++]; - } + public void get(byte[] dst, int off, int len) { + System.arraycopy(data, position, dst, off, len); + position += len; } - public void getBytesReversed(byte[] dst, int off, int len) { + public void getReversed(byte[] dst, int off, int len) { for (int i = (off + len) - 1; i >= off; i--) { dst[i] = data[position++]; } @@ -324,11 +331,11 @@ public class Buffer extends DoublyLinkedListNode { int length = position; position = 0; byte[] raw = new byte[length]; - getBytes(raw, 0, length); + get(raw, 0, length); byte[] encrypted = new BigInteger(raw).modPow(exponent, modulus).toByteArray(); position = 0; put8(encrypted.length); - putBytes(encrypted, encrypted.length, 0); + put(encrypted, encrypted.length, 0); } } diff --git a/src/main/java/Game.java b/src/main/java/Game.java index f0aabe5..84f7dbb 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -5224,7 +5224,7 @@ public class Game extends GameShell { aBuffer_1192.put8S(j2); aBuffer_834.position = 0; Huffman.method526(aString887, aBuffer_834); - aBuffer_1192.putBytesA(0, aBuffer_834.data, aBuffer_834.position); + aBuffer_1192.putA(aBuffer_834.data, 0, aBuffer_834.position); aBuffer_1192.putSize8(aBuffer_1192.position - j3); aString887 = Huffman.method527(aString887); aString887 = Censor.method497(aString887, 0); @@ -5933,7 +5933,7 @@ public class Game extends GameShell { for (int l1 = 0; l1 < 9; l1++) { aBuffer_847.put32(anIntArray1090[l1]); } - aBuffer_847.putBytes(aBuffer_1192.data, aBuffer_1192.position, 0); + aBuffer_847.put(aBuffer_1192.data, aBuffer_1192.position, 0); aBuffer_1192.cipher = new ISAACCipher(ai); for (int j2 = 0; j2 < 4; j2++) { ai[j2] += 50; @@ -7832,7 +7832,7 @@ public class Game extends GameShell { if (!flag && (anInt1251 == 0)) { try { aBuffer_834.position = 0; - buffer.getBytesReversed(aBuffer_834.data, 0, j3); + buffer.getReversed(aBuffer_834.data, 0, j3); aBuffer_834.position = 0; String s = Huffman.method525(j3, aBuffer_834); s = Censor.method497(s, 0); @@ -7864,7 +7864,7 @@ public class Game extends GameShell { int j1 = buffer.getU8C(); byte[] abyte0 = new byte[j1]; Buffer buffer_1 = new Buffer(abyte0); - buffer.getBytes(abyte0, 0, j1); + buffer.get(abyte0, 0, j1); aBufferArray895[j] = buffer_1; player.method451(buffer_1); }