summaryrefslogtreecommitdiff
path: root/NET/worlds/network/netData.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/network/netData.java')
-rw-r--r--NET/worlds/network/netData.java132
1 files changed, 132 insertions, 0 deletions
diff --git a/NET/worlds/network/netData.java b/NET/worlds/network/netData.java
new file mode 100644
index 0000000..9ba603e
--- /dev/null
+++ b/NET/worlds/network/netData.java
@@ -0,0 +1,132 @@
+/* */ package NET.worlds.network;
+/* */
+/* */ import java.io.DataInputStream;
+/* */ import java.io.IOException;
+/* */ import java.io.PrintStream;
+/* */ import java.io.UTFDataFormatException;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ class netData
+/* */ {
+/* */ private byte[] _data;
+/* */ private int _packetSize;
+/* */ private int _offset;
+/* */
+/* */ public netData(DataInputStream in)
+/* */ {
+/* */ try
+/* */ {
+/* 24 */ this._packetSize = in.readUnsignedByte();
+/* 25 */ this._data = new byte['Ā'];
+/* 26 */ in.readFully(this._data, 1, this._packetSize - 1);
+/* 27 */ this._data[0] = ((byte)this._packetSize);
+/* */
+/* */
+/* */ }
+/* */ catch (Exception e)
+/* */ {
+/* */
+/* 34 */ this._data = null;
+/* 35 */ this._packetSize = 0;
+/* */ }
+/* 37 */ this._offset = 1;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public final int packetSize()
+/* */ {
+/* 46 */ return this._packetSize;
+/* */ }
+/* */
+/* */ public final boolean isEmpty() {
+/* 50 */ return this._offset >= this._packetSize;
+/* */ }
+/* */
+/* */ public final byte getByte() {
+/* 54 */ assert (this._offset < this._packetSize);
+/* 55 */ return this._data[(this._offset++)];
+/* */ }
+/* */
+/* */ public final short getShort() {
+/* 59 */ assert (this._offset < this._packetSize);
+/* 60 */ assert (this._offset + 1 < this._packetSize);
+/* */
+/* 62 */ short retVal = (short)(this._data[this._offset] << 8 | this._data[(this._offset + 1)] & 0xFF);
+/* 63 */ this._offset += 2;
+/* 64 */ return retVal;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */ public String getUTFString(int utflen)
+/* */ {
+/* 72 */ char[] str = new char[utflen];
+/* 73 */ int count = 0;
+/* 74 */ int strlen = 0;
+/* */ try {
+/* 76 */ while (count < utflen) {
+/* 77 */ int c = getByte() & 0xFF;
+/* */
+/* 79 */ switch (c >> 4)
+/* */ {
+/* */ case 0:
+/* */ case 1:
+/* */ case 2:
+/* */ case 3:
+/* */ case 4:
+/* */ case 5:
+/* */ case 6:
+/* */ case 7:
+/* 89 */ count++;
+/* 90 */ str[(strlen++)] = ((char)c);
+/* 91 */ break;
+/* */
+/* */ case 12:
+/* */ case 13:
+/* 95 */ count += 2;
+/* 96 */ if (count > utflen)
+/* 97 */ throw new UTFDataFormatException();
+/* 98 */ int char2 = getByte() & 0xFF;
+/* 99 */ if ((char2 & 0xC0) != 128)
+/* 100 */ throw new UTFDataFormatException();
+/* 101 */ str[(strlen++)] = ((char)((c & 0x1F) << 6 | char2 & 0x3F));
+/* 102 */ break;
+/* */
+/* */ case 14:
+/* 105 */ count += 3;
+/* 106 */ if (count > utflen)
+/* 107 */ throw new UTFDataFormatException();
+/* 108 */ int char2 = getByte() & 0xFF;
+/* 109 */ int char3 = getByte() & 0xFF;
+/* 110 */ if (((char2 & 0xC0) != 128) || ((char3 & 0xC0) != 128))
+/* 111 */ throw new UTFDataFormatException();
+/* 112 */ str[(strlen++)] =
+/* 113 */ ((char)((c & 0xF) << 12 | (char2 & 0x3F) << 6 | (char3 & 0x3F) << 0));
+/* */ case 8: case 9: case 10:
+/* */ case 11: default:
+/* 116 */ throw new UTFDataFormatException();
+/* */ }
+/* */ }
+/* */ } catch (IOException e) {
+/* 120 */ System.err.println("Exception: " + e.getMessage());
+/* 121 */ e.printStackTrace();
+/* 122 */ if (!$assertionsDisabled) throw new AssertionError();
+/* */ }
+/* 124 */ return new String(str, 0, strlen);
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\network\netData.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file