blob: 79e8e7b4ed14d52aae48f74647a37d5e66f553b5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
package NET.worlds.network;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.UTFDataFormatException;
class netData {
private byte[] _data;
private int _packetSize;
private int _offset;
public netData(DataInputStream in) {
try {
this._packetSize = in.readUnsignedByte();
this._data = new byte[256];
in.readFully(this._data, 1, this._packetSize - 1);
this._data[0] = (byte)this._packetSize;
} catch (Exception var3) {
this._data = null;
this._packetSize = 0;
}
this._offset = 1;
}
public final int packetSize() {
return this._packetSize;
}
public final boolean isEmpty() {
return this._offset >= this._packetSize;
}
public final byte getByte() {
assert this._offset < this._packetSize;
return this._data[this._offset++];
}
public final short getShort() {
assert this._offset < this._packetSize;
assert this._offset + 1 < this._packetSize;
short retVal = (short)(this._data[this._offset] << 8 | this._data[this._offset + 1] & 255);
this._offset += 2;
return retVal;
}
public String getUTFString(int utflen) {
char[] str = new char[utflen];
int count = 0;
int strlen = 0;
try {
while (count < utflen) {
int c = this.getByte() & 255;
switch (c >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
count++;
str[strlen++] = (char)c;
break;
case 12:
case 13:
count += 2;
if (count > utflen) {
throw new UTFDataFormatException();
}
int char2 = this.getByte() & 255;
if ((char2 & 192) != 128) {
throw new UTFDataFormatException();
}
str[strlen++] = (char)((c & 31) << 6 | char2 & 63);
break;
case 14:
count += 3;
if (count > utflen) {
throw new UTFDataFormatException();
}
char2 = this.getByte() & 255;
int char3 = this.getByte() & 255;
if ((char2 & 192) != 128 || (char3 & 192) != 128) {
throw new UTFDataFormatException();
}
str[strlen++] = (char)((c & 15) << 12 | (char2 & 63) << 6 | (char3 & 63) << 0);
case 8:
case 9:
case 10:
case 11:
default:
throw new UTFDataFormatException();
}
}
} catch (IOException var8) {
System.err.println("Exception: " + var8.getMessage());
var8.printStackTrace();
assert false;
}
return new String(str, 0, strlen);
}
}
|