alpha
Login
or
Join now
sickday.tngl.sh
/
hla-client
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
A RuneTek3 client (377) that is deobfuscated, converted to Kotlin, and includes QoL improvements.
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
Readded com.jagex.runescape.cache
author
Ryan Greene
date
9 years ago
(Mar 3, 2017, 3:28 PM -0600)
commit
9cffb5b4
9cffb5b4d9e70a709b69f48b4bcc8a8ad79b8aef
parent
834d0a19
834d0a19455a4a015f4defe8e5db079e626c8076
+5623
18 changed files
Expand all
Collapse all
Unified
Split
src
com
jagex
runescape
cache
Archive.java
Index.java
bzip
BZip2Context.java
BZip2Decompressor.java
cfg
ChatCensor.java
VarBit.java
Varp.java
def
ActorDefinition.java
FloorDefinition.java
GameObjectDefinition.java
ItemDefinition.java
media
AnimationSequence.java
IdentityKit.java
ImageRGB.java
IndexedImage.java
SpotAnimation.java
TypeFace.java
Widget.java
+81
src/com/jagex/runescape/cache/Archive.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache;
2
2
+
3
3
+
import com.jagex.runescape.cache.bzip.BZip2Decompressor;
4
4
+
import com.jagex.runescape.net.Buffer;
5
5
+
import com.jagex.runescape.util.TextUtils;
6
6
+
7
7
+
/**
8
8
+
* Represents an archive in the cache.
9
9
+
*/
10
10
+
public class Archive {
11
11
+
12
12
+
public byte[] archiveBuffer;
13
13
+
public int dataSize;
14
14
+
public int[] nameHashes;
15
15
+
public int[] uncompressedSizes;
16
16
+
public int[] compressedSizes;
17
17
+
public int[] startOffsets;
18
18
+
private boolean compressed;
19
19
+
20
20
+
/**
21
21
+
* Creates the archive.
22
22
+
*
23
23
+
* @param dataBuffer
24
24
+
* The buffer of the archive.
25
25
+
*/
26
26
+
public Archive(byte[] dataBuffer) {
27
27
+
Buffer buffer = new Buffer(dataBuffer);
28
28
+
int uncompressed = buffer.get24BitInt();
29
29
+
int compressed = buffer.get24BitInt();
30
30
+
if (compressed != uncompressed) {
31
31
+
byte[] data = new byte[uncompressed];
32
32
+
BZip2Decompressor.decompress(data, uncompressed, dataBuffer, compressed, 6);
33
33
+
archiveBuffer = data;
34
34
+
buffer = new Buffer(archiveBuffer);
35
35
+
this.compressed = true;
36
36
+
} else {
37
37
+
archiveBuffer = dataBuffer;
38
38
+
this.compressed = false;
39
39
+
}
40
40
+
dataSize = buffer.getUnsignedLEShort();
41
41
+
nameHashes = new int[dataSize];
42
42
+
uncompressedSizes = new int[dataSize];
43
43
+
compressedSizes = new int[dataSize];
44
44
+
startOffsets = new int[dataSize];
45
45
+
int offset = buffer.offset + dataSize * 10;
46
46
+
for (int index = 0; index < dataSize; index++) {
47
47
+
nameHashes[index] = buffer.getInt();
48
48
+
uncompressedSizes[index] = buffer.get24BitInt();
49
49
+
compressedSizes[index] = buffer.get24BitInt();
50
50
+
startOffsets[index] = offset;
51
51
+
offset += compressedSizes[index];
52
52
+
}
53
53
+
}
54
54
+
55
55
+
/**
56
56
+
* Gets a file by its name.
57
57
+
*
58
58
+
* @param file
59
59
+
* The file name.
60
60
+
* @return The file contents.
61
61
+
*/
62
62
+
public byte[] getFile(String file) {
63
63
+
byte dataBuffer[] = null;
64
64
+
int hash = TextUtils.fileToHash(file);
65
65
+
for (int index = 0; index < dataSize; index++) {
66
66
+
if (nameHashes[index] == hash) {
67
67
+
if (dataBuffer == null) {
68
68
+
dataBuffer = new byte[uncompressedSizes[index]];
69
69
+
}
70
70
+
if (!compressed) {
71
71
+
BZip2Decompressor.decompress(dataBuffer, uncompressedSizes[index], archiveBuffer,
72
72
+
compressedSizes[index], startOffsets[index]);
73
73
+
} else {
74
74
+
System.arraycopy(archiveBuffer, startOffsets[index], dataBuffer, 0, uncompressedSizes[index]);
75
75
+
}
76
76
+
return dataBuffer;
77
77
+
}
78
78
+
}
79
79
+
return null;
80
80
+
}
81
81
+
}
+196
src/com/jagex/runescape/cache/Index.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache;
2
2
+
3
3
+
import java.io.IOException;
4
4
+
import java.io.RandomAccessFile;
5
5
+
6
6
+
public class Index {
7
7
+
8
8
+
static byte[] buffer = new byte[520];
9
9
+
protected RandomAccessFile dataFile;
10
10
+
protected RandomAccessFile indexFile;
11
11
+
protected int storeId;
12
12
+
13
13
+
public Index(RandomAccessFile dataFile, RandomAccessFile indexFile, int storeId) {
14
14
+
this.storeId = storeId;
15
15
+
this.dataFile = dataFile;
16
16
+
this.indexFile = indexFile;
17
17
+
}
18
18
+
19
19
+
public synchronized byte[] get(int index) {
20
20
+
try {
21
21
+
seek(indexFile, index * 6);
22
22
+
int fileSize;
23
23
+
for (int indexPart = 0; indexPart < 6; indexPart += fileSize) {
24
24
+
fileSize = indexFile.read(Index.buffer, indexPart, 6 - indexPart);
25
25
+
if (fileSize == -1) {
26
26
+
return null;
27
27
+
}
28
28
+
}
29
29
+
fileSize = ((Index.buffer[0] & 0xff) << 16) + ((Index.buffer[1] & 0xff) << 8) + (Index.buffer[2] & 0xff);
30
30
+
int fileBlock = ((Index.buffer[3] & 0xff) << 16) + ((Index.buffer[4] & 0xff) << 8)
31
31
+
+ (Index.buffer[5] & 0xff);
32
32
+
if (fileSize < 0) {
33
33
+
return null;
34
34
+
}
35
35
+
if (fileBlock <= 0 || fileBlock > dataFile.length() / 520L) {
36
36
+
return null;
37
37
+
}
38
38
+
byte[] fileBuffer = new byte[fileSize];
39
39
+
int read = 0;
40
40
+
int cycles = 0;
41
41
+
while (read < fileSize) {
42
42
+
if (fileBlock == 0) {
43
43
+
return null;
44
44
+
}
45
45
+
seek(dataFile, fileBlock * 520);
46
46
+
int size = 0;
47
47
+
int remaining = fileSize - read;
48
48
+
if (remaining > 512) {
49
49
+
remaining = 512;
50
50
+
}
51
51
+
int nextFileId;
52
52
+
for (; size < remaining + 8; size += nextFileId) {
53
53
+
nextFileId = dataFile.read(Index.buffer, size, remaining + 8 - size);
54
54
+
if (nextFileId == -1) {
55
55
+
return null;
56
56
+
}
57
57
+
}
58
58
+
nextFileId = ((Index.buffer[0] & 0xff) << 8) + (Index.buffer[1] & 0xff);
59
59
+
int currentPartId = ((Index.buffer[2] & 0xff) << 8) + (Index.buffer[3] & 0xff);
60
60
+
int nextBlockId = ((Index.buffer[4] & 0xff) << 16) + ((Index.buffer[5] & 0xff) << 8)
61
61
+
+ (Index.buffer[6] & 0xff);
62
62
+
int nextStoreId = Index.buffer[7] & 0xff;
63
63
+
if (nextFileId != index || currentPartId != cycles || nextStoreId != storeId) {
64
64
+
return null;
65
65
+
}
66
66
+
if (nextBlockId < 0 || nextBlockId > dataFile.length() / 520L) {
67
67
+
return null;
68
68
+
}
69
69
+
for (int offset = 0; offset < remaining; offset++) {
70
70
+
fileBuffer[read++] = Index.buffer[offset + 8];
71
71
+
}
72
72
+
fileBlock = nextBlockId;
73
73
+
cycles++;
74
74
+
}
75
75
+
return fileBuffer;
76
76
+
} catch (IOException ioexception) {
77
77
+
return null;
78
78
+
}
79
79
+
}
80
80
+
81
81
+
public synchronized boolean put(int length, byte[] buffer, int index) {
82
82
+
boolean exists = put(true, index, length, buffer);
83
83
+
if (!exists) {
84
84
+
exists = put(false, index, length, buffer);
85
85
+
}
86
86
+
return exists;
87
87
+
}
88
88
+
89
89
+
private synchronized boolean put(boolean bool, int index, int length, byte[] bs) {
90
90
+
try {
91
91
+
int sector;
92
92
+
if (bool) {
93
93
+
seek(indexFile, index * 6);
94
94
+
int len;
95
95
+
for (int offset = 0; offset < 6; offset += len) {
96
96
+
len = indexFile.read(Index.buffer, offset, 6 - offset);
97
97
+
if (len == -1) {
98
98
+
return false;
99
99
+
}
100
100
+
}
101
101
+
sector = ((Index.buffer[3] & 0xff) << 16) + ((Index.buffer[4] & 0xff) << 8) + (Index.buffer[5] & 0xff);
102
102
+
if (sector <= 0 || sector > dataFile.length() / 520L) {
103
103
+
return false;
104
104
+
}
105
105
+
} else {
106
106
+
sector = (int) ((dataFile.length() + 519L) / 520L);
107
107
+
if (sector == 0) {
108
108
+
sector = 1;
109
109
+
}
110
110
+
}
111
111
+
Index.buffer[0] = (byte) (length >> 16);
112
112
+
Index.buffer[1] = (byte) (length >> 8);
113
113
+
Index.buffer[2] = (byte) length;
114
114
+
Index.buffer[3] = (byte) (sector >> 16);
115
115
+
Index.buffer[4] = (byte) (sector >> 8);
116
116
+
Index.buffer[5] = (byte) sector;
117
117
+
seek(indexFile, index * 6);
118
118
+
indexFile.write(Index.buffer, 0, 6);
119
119
+
int written = 0;
120
120
+
int zero = 0;
121
121
+
while (written < length) {
122
122
+
int nextSector = 0;
123
123
+
if (bool) {
124
124
+
seek(dataFile, sector * 520);
125
125
+
int currentFile;
126
126
+
int idx;
127
127
+
for (idx = 0; idx < 8; idx += currentFile) {
128
128
+
currentFile = dataFile.read(Index.buffer, idx, 8 - idx);
129
129
+
if (currentFile == -1) {
130
130
+
break;
131
131
+
}
132
132
+
}
133
133
+
if (idx == 8) {
134
134
+
currentFile = ((Index.buffer[0] & 0xff) << 8) + (Index.buffer[1] & 0xff);
135
135
+
int currentPart = ((Index.buffer[2] & 0xff) << 8) + (Index.buffer[3] & 0xff);
136
136
+
nextSector = ((Index.buffer[4] & 0xff) << 16) + ((Index.buffer[5] & 0xff) << 8)
137
137
+
+ (Index.buffer[6] & 0xff);
138
138
+
int currentCache = Index.buffer[7] & 0xff;
139
139
+
if (currentFile != index || currentPart != zero || currentCache != storeId) {
140
140
+
return false;
141
141
+
}
142
142
+
if (nextSector < 0 || nextSector > dataFile.length() / 520L) {
143
143
+
return false;
144
144
+
}
145
145
+
}
146
146
+
}
147
147
+
if (nextSector == 0) {
148
148
+
bool = false;
149
149
+
nextSector = (int) ((dataFile.length() + 519L) / 520L);
150
150
+
if (nextSector == 0) {
151
151
+
nextSector++;
152
152
+
}
153
153
+
if (nextSector == sector) {
154
154
+
nextSector++;
155
155
+
}
156
156
+
}
157
157
+
if (length - written <= 512) {
158
158
+
nextSector = 0;
159
159
+
}
160
160
+
Index.buffer[0] = (byte) (index >> 8);
161
161
+
Index.buffer[1] = (byte) index;
162
162
+
Index.buffer[2] = (byte) (zero >> 8);
163
163
+
Index.buffer[3] = (byte) zero;
164
164
+
Index.buffer[4] = (byte) (nextSector >> 16);
165
165
+
Index.buffer[5] = (byte) (nextSector >> 8);
166
166
+
Index.buffer[6] = (byte) nextSector;
167
167
+
Index.buffer[7] = (byte) storeId;
168
168
+
seek(dataFile, sector * 520);
169
169
+
dataFile.write(Index.buffer, 0, 8);
170
170
+
int remaining = length - written;
171
171
+
if (remaining > 512) {
172
172
+
remaining = 512;
173
173
+
}
174
174
+
dataFile.write(bs, written, remaining);
175
175
+
written += remaining;
176
176
+
sector = nextSector;
177
177
+
}
178
178
+
return true;
179
179
+
} catch (IOException e) {
180
180
+
return false;
181
181
+
}
182
182
+
}
183
183
+
184
184
+
public synchronized void seek(RandomAccessFile dataFile, int position) throws IOException {
185
185
+
if (position < 0 || position > 62914560) {
186
186
+
System.out.println("Badseek - pos:" + position + " len:" + dataFile.length());
187
187
+
position = 62914560;
188
188
+
try {
189
189
+
Thread.sleep(1000L);
190
190
+
} catch (Exception exception) {
191
191
+
/* empty */
192
192
+
}
193
193
+
}
194
194
+
dataFile.seek(position);
195
195
+
}
196
196
+
}
+56
src/com/jagex/runescape/cache/bzip/BZip2Context.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache.bzip;
2
2
+
3
3
+
/* BZip2Context - Decompiled by JODE
4
4
+
* Visit http://jode.sourceforge.net/
5
5
+
*/
6
6
+
7
7
+
class BZip2Context {
8
8
+
final int anInt88 = 4096;
9
9
+
final int anInt89 = 16;
10
10
+
final int anInt90 = 258;
11
11
+
final int anInt91 = 23;
12
12
+
final int anInt92 = 1;
13
13
+
final int anInt93 = 6;
14
14
+
final int anInt94 = 50;
15
15
+
final int anInt95 = 4;
16
16
+
final int anInt96 = 18002;
17
17
+
protected byte[] aByteArray97;
18
18
+
protected int anInt98;
19
19
+
protected int anInt99;
20
20
+
protected int anInt100;
21
21
+
protected int anInt101;
22
22
+
protected byte[] aByteArray102;
23
23
+
protected int anInt103;
24
24
+
protected int anInt104;
25
25
+
protected int anInt105;
26
26
+
protected int anInt106;
27
27
+
protected byte aByte107;
28
28
+
protected int anInt108;
29
29
+
protected boolean aBoolean109;
30
30
+
protected int anInt110;
31
31
+
protected int anInt111;
32
32
+
protected int anInt112;
33
33
+
protected int anInt113;
34
34
+
protected int anInt114;
35
35
+
protected int anInt115;
36
36
+
protected int anInt116;
37
37
+
protected int[] anIntArray117 = new int[256];
38
38
+
protected int anInt118;
39
39
+
protected int[] anIntArray119 = new int[257];
40
40
+
protected int[] anIntArray120 = new int[257];
41
41
+
public static int[] anIntArray121;
42
42
+
protected int anInt122;
43
43
+
protected boolean[] aBooleanArray123 = new boolean[256];
44
44
+
protected boolean[] aBooleanArray124 = new boolean[16];
45
45
+
protected byte[] aByteArray125 = new byte[256];
46
46
+
protected byte[] aByteArray126 = new byte[4096];
47
47
+
protected int[] anIntArray127 = new int[16];
48
48
+
protected byte[] aByteArray128 = new byte[18002];
49
49
+
protected byte[] aByteArray129 = new byte[18002];
50
50
+
protected byte[][] aByteArrayArray130 = new byte[6][258];
51
51
+
protected int[][] anIntArrayArray131 = new int[6][258];
52
52
+
protected int[][] anIntArrayArray132 = new int[6][258];
53
53
+
protected int[][] anIntArrayArray133 = new int[6][258];
54
54
+
protected int[] anIntArray134 = new int[6];
55
55
+
protected int anInt135;
56
56
+
}
+504
src/com/jagex/runescape/cache/bzip/BZip2Decompressor.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache.bzip;
2
2
+
3
3
+
/* BZip2Decompressor - Decompiled by JODE
4
4
+
* Visit http://jode.sourceforge.net/
5
5
+
*/
6
6
+
7
7
+
public class BZip2Decompressor {
8
8
+
private static BZip2Context aBZip2Context136 = new BZip2Context();
9
9
+
10
10
+
public static int decompress(byte[] bs, int i, byte[] bs_0_, int i_1_, int i_2_) {
11
11
+
synchronized (BZip2Decompressor.aBZip2Context136) {
12
12
+
BZip2Decompressor.aBZip2Context136.aByteArray97 = bs_0_;
13
13
+
BZip2Decompressor.aBZip2Context136.anInt98 = i_2_;
14
14
+
BZip2Decompressor.aBZip2Context136.aByteArray102 = bs;
15
15
+
BZip2Decompressor.aBZip2Context136.anInt103 = 0;
16
16
+
BZip2Decompressor.aBZip2Context136.anInt99 = i_1_;
17
17
+
BZip2Decompressor.aBZip2Context136.anInt104 = i;
18
18
+
BZip2Decompressor.aBZip2Context136.anInt111 = 0;
19
19
+
BZip2Decompressor.aBZip2Context136.anInt110 = 0;
20
20
+
BZip2Decompressor.aBZip2Context136.anInt100 = 0;
21
21
+
BZip2Decompressor.aBZip2Context136.anInt101 = 0;
22
22
+
BZip2Decompressor.aBZip2Context136.anInt105 = 0;
23
23
+
BZip2Decompressor.aBZip2Context136.anInt106 = 0;
24
24
+
BZip2Decompressor.aBZip2Context136.anInt113 = 0;
25
25
+
BZip2Decompressor.method166(BZip2Decompressor.aBZip2Context136);
26
26
+
i -= BZip2Decompressor.aBZip2Context136.anInt104;
27
27
+
return i;
28
28
+
}
29
29
+
}
30
30
+
31
31
+
private static void method165(BZip2Context bzip2context) {
32
32
+
byte b = bzip2context.aByte107;
33
33
+
int i = bzip2context.anInt108;
34
34
+
int i_3_ = bzip2context.anInt118;
35
35
+
int i_4_ = bzip2context.anInt116;
36
36
+
int[] is = BZip2Context.anIntArray121;
37
37
+
int i_5_ = bzip2context.anInt115;
38
38
+
byte[] bs = bzip2context.aByteArray102;
39
39
+
int i_6_ = bzip2context.anInt103;
40
40
+
int i_7_ = bzip2context.anInt104;
41
41
+
int i_8_ = i_7_;
42
42
+
int i_9_ = bzip2context.anInt135 + 1;
43
43
+
while_0_: for (;;) {
44
44
+
if (i > 0) {
45
45
+
for (;;) {
46
46
+
if (i_7_ == 0) {
47
47
+
break while_0_;
48
48
+
}
49
49
+
if (i == 1) {
50
50
+
break;
51
51
+
}
52
52
+
bs[i_6_] = b;
53
53
+
i--;
54
54
+
i_6_++;
55
55
+
i_7_--;
56
56
+
}
57
57
+
if (i_7_ == 0) {
58
58
+
i = 1;
59
59
+
break;
60
60
+
}
61
61
+
bs[i_6_] = b;
62
62
+
i_6_++;
63
63
+
i_7_--;
64
64
+
}
65
65
+
boolean bool = true;
66
66
+
while (bool) {
67
67
+
bool = false;
68
68
+
if (i_3_ == i_9_) {
69
69
+
i = 0;
70
70
+
break while_0_;
71
71
+
}
72
72
+
b = (byte) i_4_;
73
73
+
i_5_ = is[i_5_];
74
74
+
int i_10_ = (byte) (i_5_ & 0xff);
75
75
+
i_5_ >>= 8;
76
76
+
i_3_++;
77
77
+
if (i_10_ != i_4_) {
78
78
+
i_4_ = i_10_;
79
79
+
if (i_7_ == 0) {
80
80
+
i = 1;
81
81
+
break while_0_;
82
82
+
}
83
83
+
bs[i_6_] = b;
84
84
+
i_6_++;
85
85
+
i_7_--;
86
86
+
bool = true;
87
87
+
} else if (i_3_ == i_9_) {
88
88
+
if (i_7_ == 0) {
89
89
+
i = 1;
90
90
+
break while_0_;
91
91
+
}
92
92
+
bs[i_6_] = b;
93
93
+
i_6_++;
94
94
+
i_7_--;
95
95
+
bool = true;
96
96
+
}
97
97
+
}
98
98
+
i = 2;
99
99
+
i_5_ = is[i_5_];
100
100
+
int i_11_ = (byte) (i_5_ & 0xff);
101
101
+
i_5_ >>= 8;
102
102
+
if (++i_3_ != i_9_) {
103
103
+
if (i_11_ != i_4_) {
104
104
+
i_4_ = i_11_;
105
105
+
} else {
106
106
+
i = 3;
107
107
+
i_5_ = is[i_5_];
108
108
+
i_11_ = (byte) (i_5_ & 0xff);
109
109
+
i_5_ >>= 8;
110
110
+
if (++i_3_ != i_9_) {
111
111
+
if (i_11_ != i_4_) {
112
112
+
i_4_ = i_11_;
113
113
+
} else {
114
114
+
i_5_ = is[i_5_];
115
115
+
i_11_ = (byte) (i_5_ & 0xff);
116
116
+
i_5_ >>= 8;
117
117
+
i_3_++;
118
118
+
i = (i_11_ & 0xff) + 4;
119
119
+
i_5_ = is[i_5_];
120
120
+
i_4_ = (byte) (i_5_ & 0xff);
121
121
+
i_5_ >>= 8;
122
122
+
i_3_++;
123
123
+
}
124
124
+
}
125
125
+
}
126
126
+
}
127
127
+
}
128
128
+
int i_12_ = bzip2context.anInt105;
129
129
+
bzip2context.anInt105 += i_8_ - i_7_;
130
130
+
if (bzip2context.anInt105 < i_12_) {
131
131
+
bzip2context.anInt106++;
132
132
+
}
133
133
+
bzip2context.aByte107 = b;
134
134
+
bzip2context.anInt108 = i;
135
135
+
bzip2context.anInt118 = i_3_;
136
136
+
bzip2context.anInt116 = i_4_;
137
137
+
BZip2Context.anIntArray121 = is;
138
138
+
bzip2context.anInt115 = i_5_;
139
139
+
bzip2context.aByteArray102 = bs;
140
140
+
bzip2context.anInt103 = i_6_;
141
141
+
bzip2context.anInt104 = i_7_;
142
142
+
}
143
143
+
144
144
+
private static void method166(BZip2Context bzip2context) {
145
145
+
int i = 0;
146
146
+
int[] is = null;
147
147
+
int[] is_31_ = null;
148
148
+
int[] is_32_ = null;
149
149
+
bzip2context.anInt112 = 1;
150
150
+
if (BZip2Context.anIntArray121 == null) {
151
151
+
BZip2Context.anIntArray121 = new int[bzip2context.anInt112 * 100000];
152
152
+
}
153
153
+
boolean bool_33_ = true;
154
154
+
while (bool_33_) {
155
155
+
byte b = BZip2Decompressor.method167(bzip2context);
156
156
+
if (b == 23) {
157
157
+
break;
158
158
+
}
159
159
+
b = BZip2Decompressor.method167(bzip2context);
160
160
+
b = BZip2Decompressor.method167(bzip2context);
161
161
+
b = BZip2Decompressor.method167(bzip2context);
162
162
+
b = BZip2Decompressor.method167(bzip2context);
163
163
+
b = BZip2Decompressor.method167(bzip2context);
164
164
+
bzip2context.anInt113++;
165
165
+
b = BZip2Decompressor.method167(bzip2context);
166
166
+
b = BZip2Decompressor.method167(bzip2context);
167
167
+
b = BZip2Decompressor.method167(bzip2context);
168
168
+
b = BZip2Decompressor.method167(bzip2context);
169
169
+
b = BZip2Decompressor.method168(bzip2context);
170
170
+
if (b != 0) {
171
171
+
bzip2context.aBoolean109 = true;
172
172
+
} else {
173
173
+
bzip2context.aBoolean109 = false;
174
174
+
}
175
175
+
if (bzip2context.aBoolean109) {
176
176
+
System.out.println("PANIC! RANDOMISED BLOCK!");
177
177
+
}
178
178
+
bzip2context.anInt114 = 0;
179
179
+
int i_34_ = BZip2Decompressor.method167(bzip2context);
180
180
+
bzip2context.anInt114 = bzip2context.anInt114 << 8 | i_34_ & 0xff;
181
181
+
i_34_ = BZip2Decompressor.method167(bzip2context);
182
182
+
bzip2context.anInt114 = bzip2context.anInt114 << 8 | i_34_ & 0xff;
183
183
+
i_34_ = BZip2Decompressor.method167(bzip2context);
184
184
+
bzip2context.anInt114 = bzip2context.anInt114 << 8 | i_34_ & 0xff;
185
185
+
for (int i_35_ = 0; i_35_ < 16; i_35_++) {
186
186
+
b = BZip2Decompressor.method168(bzip2context);
187
187
+
if (b == 1) {
188
188
+
bzip2context.aBooleanArray124[i_35_] = true;
189
189
+
} else {
190
190
+
bzip2context.aBooleanArray124[i_35_] = false;
191
191
+
}
192
192
+
}
193
193
+
for (int i_36_ = 0; i_36_ < 256; i_36_++) {
194
194
+
bzip2context.aBooleanArray123[i_36_] = false;
195
195
+
}
196
196
+
for (int i_37_ = 0; i_37_ < 16; i_37_++) {
197
197
+
if (bzip2context.aBooleanArray124[i_37_]) {
198
198
+
for (int i_38_ = 0; i_38_ < 16; i_38_++) {
199
199
+
b = BZip2Decompressor.method168(bzip2context);
200
200
+
if (b == 1) {
201
201
+
bzip2context.aBooleanArray123[i_37_ * 16 + i_38_] = true;
202
202
+
}
203
203
+
}
204
204
+
}
205
205
+
}
206
206
+
BZip2Decompressor.method170(bzip2context);
207
207
+
int i_39_ = bzip2context.anInt122 + 2;
208
208
+
int i_40_ = BZip2Decompressor.method169(3, bzip2context);
209
209
+
int i_41_ = BZip2Decompressor.method169(15, bzip2context);
210
210
+
for (int i_42_ = 0; i_42_ < i_41_; i_42_++) {
211
211
+
int i_43_ = 0;
212
212
+
for (;;) {
213
213
+
b = BZip2Decompressor.method168(bzip2context);
214
214
+
if (b == 0) {
215
215
+
break;
216
216
+
}
217
217
+
i_43_++;
218
218
+
}
219
219
+
bzip2context.aByteArray129[i_42_] = (byte) i_43_;
220
220
+
}
221
221
+
byte[] bs = new byte[6];
222
222
+
for (byte b_44_ = 0; b_44_ < i_40_; b_44_++) {
223
223
+
bs[b_44_] = b_44_;
224
224
+
}
225
225
+
for (int i_45_ = 0; i_45_ < i_41_; i_45_++) {
226
226
+
byte b_46_ = bzip2context.aByteArray129[i_45_];
227
227
+
byte b_47_ = bs[b_46_];
228
228
+
for (/**/; b_46_ > 0; b_46_--) {
229
229
+
bs[b_46_] = bs[b_46_ - 1];
230
230
+
}
231
231
+
bs[0] = b_47_;
232
232
+
bzip2context.aByteArray128[i_45_] = b_47_;
233
233
+
}
234
234
+
for (int i_48_ = 0; i_48_ < i_40_; i_48_++) {
235
235
+
int i_49_ = BZip2Decompressor.method169(5, bzip2context);
236
236
+
for (int i_50_ = 0; i_50_ < i_39_; i_50_++) {
237
237
+
for (;;) {
238
238
+
b = BZip2Decompressor.method168(bzip2context);
239
239
+
if (b == 0) {
240
240
+
break;
241
241
+
}
242
242
+
b = BZip2Decompressor.method168(bzip2context);
243
243
+
if (b == 0) {
244
244
+
i_49_++;
245
245
+
} else {
246
246
+
i_49_--;
247
247
+
}
248
248
+
}
249
249
+
bzip2context.aByteArrayArray130[i_48_][i_50_] = (byte) i_49_;
250
250
+
}
251
251
+
}
252
252
+
for (int i_51_ = 0; i_51_ < i_40_; i_51_++) {
253
253
+
int i_52_ = 32;
254
254
+
byte b_53_ = 0;
255
255
+
for (int i_54_ = 0; i_54_ < i_39_; i_54_++) {
256
256
+
if (bzip2context.aByteArrayArray130[i_51_][i_54_] > b_53_) {
257
257
+
b_53_ = bzip2context.aByteArrayArray130[i_51_][i_54_];
258
258
+
}
259
259
+
if (bzip2context.aByteArrayArray130[i_51_][i_54_] < i_52_) {
260
260
+
i_52_ = bzip2context.aByteArrayArray130[i_51_][i_54_];
261
261
+
}
262
262
+
}
263
263
+
BZip2Decompressor.method171(bzip2context.anIntArrayArray131[i_51_],
264
264
+
bzip2context.anIntArrayArray132[i_51_], bzip2context.anIntArrayArray133[i_51_],
265
265
+
bzip2context.aByteArrayArray130[i_51_], i_52_, b_53_, i_39_);
266
266
+
bzip2context.anIntArray134[i_51_] = i_52_;
267
267
+
}
268
268
+
int i_55_ = bzip2context.anInt122 + 1;
269
269
+
int i_57_ = -1;
270
270
+
int i_58_ = 0;
271
271
+
for (int i_59_ = 0; i_59_ <= 255; i_59_++) {
272
272
+
bzip2context.anIntArray117[i_59_] = 0;
273
273
+
}
274
274
+
int i_60_ = 4095;
275
275
+
for (int i_61_ = 15; i_61_ >= 0; i_61_--) {
276
276
+
for (int i_62_ = 15; i_62_ >= 0; i_62_--) {
277
277
+
bzip2context.aByteArray126[i_60_] = (byte) (i_61_ * 16 + i_62_);
278
278
+
i_60_--;
279
279
+
}
280
280
+
bzip2context.anIntArray127[i_61_] = i_60_ + 1;
281
281
+
}
282
282
+
int i_63_ = 0;
283
283
+
if (i_58_ == 0) {
284
284
+
i_57_++;
285
285
+
i_58_ = 50;
286
286
+
byte b_64_ = bzip2context.aByteArray128[i_57_];
287
287
+
i = bzip2context.anIntArray134[b_64_];
288
288
+
is = bzip2context.anIntArrayArray131[b_64_];
289
289
+
is_32_ = bzip2context.anIntArrayArray133[b_64_];
290
290
+
is_31_ = bzip2context.anIntArrayArray132[b_64_];
291
291
+
}
292
292
+
i_58_--;
293
293
+
int i_65_ = i;
294
294
+
int i_66_;
295
295
+
int i_67_;
296
296
+
for (i_67_ = BZip2Decompressor.method169(i_65_, bzip2context); i_67_ > is[i_65_]; i_67_ = i_67_ << 1
297
297
+
| i_66_) {
298
298
+
i_65_++;
299
299
+
i_66_ = BZip2Decompressor.method168(bzip2context);
300
300
+
}
301
301
+
int i_68_ = is_32_[i_67_ - is_31_[i_65_]];
302
302
+
while (i_68_ != i_55_) {
303
303
+
if (i_68_ == 0 || i_68_ == 1) {
304
304
+
int i_69_ = -1;
305
305
+
int i_70_ = 1;
306
306
+
do {
307
307
+
if (i_68_ == 0) {
308
308
+
i_69_ += i_70_;
309
309
+
} else if (i_68_ == 1) {
310
310
+
i_69_ += 2 * i_70_;
311
311
+
}
312
312
+
i_70_ *= 2;
313
313
+
if (i_58_ == 0) {
314
314
+
i_57_++;
315
315
+
i_58_ = 50;
316
316
+
byte b_71_ = bzip2context.aByteArray128[i_57_];
317
317
+
i = bzip2context.anIntArray134[b_71_];
318
318
+
is = bzip2context.anIntArrayArray131[b_71_];
319
319
+
is_32_ = bzip2context.anIntArrayArray133[b_71_];
320
320
+
is_31_ = bzip2context.anIntArrayArray132[b_71_];
321
321
+
}
322
322
+
i_58_--;
323
323
+
i_65_ = i;
324
324
+
for (i_67_ = BZip2Decompressor.method169(i_65_, bzip2context); i_67_ > is[i_65_]; i_67_ = i_67_ << 1
325
325
+
| i_66_) {
326
326
+
i_65_++;
327
327
+
i_66_ = BZip2Decompressor.method168(bzip2context);
328
328
+
}
329
329
+
i_68_ = is_32_[i_67_ - is_31_[i_65_]];
330
330
+
} while (i_68_ == 0 || i_68_ == 1);
331
331
+
i_69_++;
332
332
+
i_34_ = bzip2context.aByteArray125[bzip2context.aByteArray126[bzip2context.anIntArray127[0]] & 0xff];
333
333
+
bzip2context.anIntArray117[i_34_ & 0xff] += i_69_;
334
334
+
for (/**/; i_69_ > 0; i_69_--) {
335
335
+
BZip2Context.anIntArray121[i_63_] = i_34_ & 0xff;
336
336
+
i_63_++;
337
337
+
}
338
338
+
} else {
339
339
+
int i_72_ = i_68_ - 1;
340
340
+
if (i_72_ < 16) {
341
341
+
int i_73_ = bzip2context.anIntArray127[0];
342
342
+
b = bzip2context.aByteArray126[i_73_ + i_72_];
343
343
+
for (/**/; i_72_ > 3; i_72_ -= 4) {
344
344
+
int i_74_ = i_73_ + i_72_;
345
345
+
bzip2context.aByteArray126[i_74_] = bzip2context.aByteArray126[i_74_ - 1];
346
346
+
bzip2context.aByteArray126[i_74_ - 1] = bzip2context.aByteArray126[i_74_ - 2];
347
347
+
bzip2context.aByteArray126[i_74_ - 2] = bzip2context.aByteArray126[i_74_ - 3];
348
348
+
bzip2context.aByteArray126[i_74_ - 3] = bzip2context.aByteArray126[i_74_ - 4];
349
349
+
}
350
350
+
for (/**/; i_72_ > 0; i_72_--) {
351
351
+
bzip2context.aByteArray126[i_73_ + i_72_] = bzip2context.aByteArray126[i_73_ + i_72_ - 1];
352
352
+
}
353
353
+
bzip2context.aByteArray126[i_73_] = b;
354
354
+
} else {
355
355
+
int i_75_ = i_72_ / 16;
356
356
+
int i_76_ = i_72_ % 16;
357
357
+
int i_77_ = bzip2context.anIntArray127[i_75_] + i_76_;
358
358
+
b = bzip2context.aByteArray126[i_77_];
359
359
+
for (/**/; i_77_ > bzip2context.anIntArray127[i_75_]; i_77_--) {
360
360
+
bzip2context.aByteArray126[i_77_] = bzip2context.aByteArray126[i_77_ - 1];
361
361
+
}
362
362
+
bzip2context.anIntArray127[i_75_]++;
363
363
+
for (/**/; i_75_ > 0; i_75_--) {
364
364
+
bzip2context.anIntArray127[i_75_]--;
365
365
+
bzip2context.aByteArray126[bzip2context.anIntArray127[i_75_]] = bzip2context.aByteArray126[bzip2context.anIntArray127[i_75_ - 1] + 16 - 1];
366
366
+
}
367
367
+
bzip2context.anIntArray127[0]--;
368
368
+
bzip2context.aByteArray126[bzip2context.anIntArray127[0]] = b;
369
369
+
if (bzip2context.anIntArray127[0] == 0) {
370
370
+
int i_78_ = 4095;
371
371
+
for (int i_79_ = 15; i_79_ >= 0; i_79_--) {
372
372
+
for (int i_80_ = 15; i_80_ >= 0; i_80_--) {
373
373
+
bzip2context.aByteArray126[i_78_] = bzip2context.aByteArray126[bzip2context.anIntArray127[i_79_]
374
374
+
+ i_80_];
375
375
+
i_78_--;
376
376
+
}
377
377
+
bzip2context.anIntArray127[i_79_] = i_78_ + 1;
378
378
+
}
379
379
+
}
380
380
+
}
381
381
+
bzip2context.anIntArray117[bzip2context.aByteArray125[b & 0xff] & 0xff]++;
382
382
+
BZip2Context.anIntArray121[i_63_] = bzip2context.aByteArray125[b & 0xff] & 0xff;
383
383
+
i_63_++;
384
384
+
if (i_58_ == 0) {
385
385
+
i_57_++;
386
386
+
i_58_ = 50;
387
387
+
byte b_81_ = bzip2context.aByteArray128[i_57_];
388
388
+
i = bzip2context.anIntArray134[b_81_];
389
389
+
is = bzip2context.anIntArrayArray131[b_81_];
390
390
+
is_32_ = bzip2context.anIntArrayArray133[b_81_];
391
391
+
is_31_ = bzip2context.anIntArrayArray132[b_81_];
392
392
+
}
393
393
+
i_58_--;
394
394
+
i_65_ = i;
395
395
+
for (i_67_ = BZip2Decompressor.method169(i_65_, bzip2context); i_67_ > is[i_65_]; i_67_ = i_67_ << 1
396
396
+
| i_66_) {
397
397
+
i_65_++;
398
398
+
i_66_ = BZip2Decompressor.method168(bzip2context);
399
399
+
}
400
400
+
i_68_ = is_32_[i_67_ - is_31_[i_65_]];
401
401
+
}
402
402
+
}
403
403
+
bzip2context.anInt108 = 0;
404
404
+
bzip2context.aByte107 = (byte) 0;
405
405
+
bzip2context.anIntArray119[0] = 0;
406
406
+
for (int i_82_ = 1; i_82_ <= 256; i_82_++) {
407
407
+
bzip2context.anIntArray119[i_82_] = bzip2context.anIntArray117[i_82_ - 1];
408
408
+
}
409
409
+
for (int i_83_ = 1; i_83_ <= 256; i_83_++) {
410
410
+
bzip2context.anIntArray119[i_83_] += bzip2context.anIntArray119[i_83_ - 1];
411
411
+
}
412
412
+
for (int i_84_ = 0; i_84_ < i_63_; i_84_++) {
413
413
+
i_34_ = (byte) (BZip2Context.anIntArray121[i_84_] & 0xff);
414
414
+
BZip2Context.anIntArray121[bzip2context.anIntArray119[i_34_ & 0xff]] |= i_84_ << 8;
415
415
+
bzip2context.anIntArray119[i_34_ & 0xff]++;
416
416
+
}
417
417
+
bzip2context.anInt115 = BZip2Context.anIntArray121[bzip2context.anInt114] >> 8;
418
418
+
bzip2context.anInt118 = 0;
419
419
+
bzip2context.anInt115 = BZip2Context.anIntArray121[bzip2context.anInt115];
420
420
+
bzip2context.anInt116 = (byte) (bzip2context.anInt115 & 0xff);
421
421
+
bzip2context.anInt115 >>= 8;
422
422
+
bzip2context.anInt118++;
423
423
+
bzip2context.anInt135 = i_63_;
424
424
+
BZip2Decompressor.method165(bzip2context);
425
425
+
if (bzip2context.anInt118 == bzip2context.anInt135 + 1 && bzip2context.anInt108 == 0) {
426
426
+
bool_33_ = true;
427
427
+
} else {
428
428
+
bool_33_ = false;
429
429
+
}
430
430
+
}
431
431
+
}
432
432
+
433
433
+
private static byte method167(BZip2Context bzip2context) {
434
434
+
return (byte) BZip2Decompressor.method169(8, bzip2context);
435
435
+
}
436
436
+
437
437
+
private static byte method168(BZip2Context bzip2context) {
438
438
+
return (byte) BZip2Decompressor.method169(1, bzip2context);
439
439
+
}
440
440
+
441
441
+
private static int method169(int i, BZip2Context bzip2context) {
442
442
+
int i_85_;
443
443
+
for (;;) {
444
444
+
if (bzip2context.anInt111 >= i) {
445
445
+
int i_86_ = bzip2context.anInt110 >> bzip2context.anInt111 - i & (1 << i) - 1;
446
446
+
bzip2context.anInt111 -= i;
447
447
+
i_85_ = i_86_;
448
448
+
break;
449
449
+
}
450
450
+
bzip2context.anInt110 = bzip2context.anInt110 << 8 | bzip2context.aByteArray97[bzip2context.anInt98] & 0xff;
451
451
+
bzip2context.anInt111 += 8;
452
452
+
bzip2context.anInt98++;
453
453
+
bzip2context.anInt99--;
454
454
+
bzip2context.anInt100++;
455
455
+
if (bzip2context.anInt100 == 0) {
456
456
+
bzip2context.anInt101++;
457
457
+
}
458
458
+
}
459
459
+
return i_85_;
460
460
+
}
461
461
+
462
462
+
private static void method170(BZip2Context bzip2context) {
463
463
+
bzip2context.anInt122 = 0;
464
464
+
for (int i = 0; i < 256; i++) {
465
465
+
if (bzip2context.aBooleanArray123[i]) {
466
466
+
bzip2context.aByteArray125[bzip2context.anInt122] = (byte) i;
467
467
+
bzip2context.anInt122++;
468
468
+
}
469
469
+
}
470
470
+
}
471
471
+
472
472
+
private static void method171(int[] is, int[] is_87_, int[] is_88_, byte[] bs, int i, int i_89_, int i_90_) {
473
473
+
int i_91_ = 0;
474
474
+
for (int i_92_ = i; i_92_ <= i_89_; i_92_++) {
475
475
+
for (int i_93_ = 0; i_93_ < i_90_; i_93_++) {
476
476
+
if (bs[i_93_] == i_92_) {
477
477
+
is_88_[i_91_] = i_93_;
478
478
+
i_91_++;
479
479
+
}
480
480
+
}
481
481
+
}
482
482
+
for (int i_94_ = 0; i_94_ < 23; i_94_++) {
483
483
+
is_87_[i_94_] = 0;
484
484
+
}
485
485
+
for (int i_95_ = 0; i_95_ < i_90_; i_95_++) {
486
486
+
is_87_[bs[i_95_] + 1]++;
487
487
+
}
488
488
+
for (int i_96_ = 1; i_96_ < 23; i_96_++) {
489
489
+
is_87_[i_96_] += is_87_[i_96_ - 1];
490
490
+
}
491
491
+
for (int i_97_ = 0; i_97_ < 23; i_97_++) {
492
492
+
is[i_97_] = 0;
493
493
+
}
494
494
+
int i_98_ = 0;
495
495
+
for (int i_99_ = i; i_99_ <= i_89_; i_99_++) {
496
496
+
i_98_ += is_87_[i_99_ + 1] - is_87_[i_99_];
497
497
+
is[i_99_] = i_98_ - 1;
498
498
+
i_98_ <<= 1;
499
499
+
}
500
500
+
for (int i_100_ = i + 1; i_100_ <= i_89_; i_100_++) {
501
501
+
is_87_[i_100_] = (is[i_100_ - 1] + 1 << 1) - is_87_[i_100_];
502
502
+
}
503
503
+
}
504
504
+
}
+1286
src/com/jagex/runescape/cache/cfg/ChatCensor.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache.cfg;
2
2
+
3
3
+
import com.jagex.runescape.util.SignLink;
4
4
+
import com.jagex.runescape.cache.Archive;
5
5
+
import com.jagex.runescape.net.Buffer;
6
6
+
7
7
+
/* ChatCensor - Decompiled by JODE
8
8
+
* Visit http://jode.sourceforge.net/
9
9
+
*/
10
10
+
11
11
+
public class ChatCensor {
12
12
+
private static boolean aBoolean156;
13
13
+
private static int anInt157 = 748;
14
14
+
private static byte aByte161 = -117;
15
15
+
private static int anInt162 = -575;
16
16
+
private static boolean aBoolean163 = true;
17
17
+
private static int anInt164 = -720;
18
18
+
private static byte aByte166 = 4;
19
19
+
private static int anInt167 = 8801;
20
20
+
private static boolean aBoolean168 = true;
21
21
+
private static int[] fragments;
22
22
+
private static char[][] badWords;
23
23
+
private static byte[][][] badBytes;
24
24
+
private static char[][] domains;
25
25
+
private static char[][] topLevelDomains;
26
26
+
private static int[] topLevelDomainsType;
27
27
+
private static final String[] aStringArray175 = { "cook", "cook's", "cooks", "seeks", "sheet", "woop", "woops",
28
28
+
"faq", "noob", "noobs" };
29
29
+
30
30
+
public static final void load(Archive archive) {
31
31
+
Buffer fragmentsEnc = new Buffer(archive.getFile("fragmentsenc.txt"));
32
32
+
Buffer badEnc = new Buffer(archive.getFile("badenc.txt"));
33
33
+
Buffer domainEnc = new Buffer(archive.getFile("domainenc.txt"));
34
34
+
Buffer topLevelDomainsBuffer = new Buffer(archive.getFile("tldlist.txt"));
35
35
+
ChatCensor.loadDictionaries(fragmentsEnc, badEnc, domainEnc, topLevelDomainsBuffer);
36
36
+
}
37
37
+
38
38
+
private static final void loadDictionaries(Buffer fragmentsEnc, Buffer badEnc, Buffer domainEnc,
39
39
+
Buffer topLevelDomainsBuffer) {
40
40
+
ChatCensor.loadBadEnc(badEnc);
41
41
+
ChatCensor.loadDomainEnc(domainEnc);
42
42
+
ChatCensor.loadFragmentsEnc(fragmentsEnc, true);
43
43
+
ChatCensor.loadTopLevelDomains(topLevelDomainsBuffer);
44
44
+
}
45
45
+
46
46
+
private static final void loadTopLevelDomains(Buffer buffer) {
47
47
+
int length = buffer.getInt();
48
48
+
ChatCensor.topLevelDomains = new char[length][];
49
49
+
ChatCensor.topLevelDomainsType = new int[length];
50
50
+
for (int index = 0; index < length; index++) {
51
51
+
ChatCensor.topLevelDomainsType[index] = buffer.getUnsignedByte();
52
52
+
char[] topLevelDomain = new char[buffer.getUnsignedByte()];
53
53
+
for (int character = 0; character < topLevelDomain.length; character++) {
54
54
+
topLevelDomain[character] = (char) buffer.getUnsignedByte();
55
55
+
}
56
56
+
ChatCensor.topLevelDomains[index] = topLevelDomain;
57
57
+
}
58
58
+
}
59
59
+
60
60
+
private static final void loadBadEnc(Buffer buffer) {
61
61
+
int length = buffer.getInt();
62
62
+
ChatCensor.badWords = new char[length][];
63
63
+
ChatCensor.badBytes = new byte[length][][];
64
64
+
ChatCensor.loadBadWords(buffer, ChatCensor.badWords, ChatCensor.badBytes);
65
65
+
}
66
66
+
67
67
+
private static final void loadDomainEnc(Buffer buffer) {
68
68
+
int length = buffer.getInt();
69
69
+
ChatCensor.domains = new char[length][];
70
70
+
ChatCensor.loadDomains(ChatCensor.domains, buffer);
71
71
+
}
72
72
+
73
73
+
private static final void loadFragmentsEnc(Buffer buffer, boolean bool) {
74
74
+
ChatCensor.fragments = new int[buffer.getInt()];
75
75
+
for (int index = 0; index < ChatCensor.fragments.length; index++) {
76
76
+
ChatCensor.fragments[index] = buffer.getUnsignedLEShort();
77
77
+
}
78
78
+
}
79
79
+
80
80
+
private static final void loadBadWords(Buffer buffer, char[][] badWords, byte[][][] badBytes) {
81
81
+
for (int index = 0; index < badWords.length; index++) {
82
82
+
char[] badWord = new char[buffer.getUnsignedByte()];
83
83
+
for (int i_10_ = 0; i_10_ < badWord.length; i_10_++) {
84
84
+
badWord[i_10_] = (char) buffer.getUnsignedByte();
85
85
+
}
86
86
+
badWords[index] = badWord;
87
87
+
byte[][] badByte = new byte[buffer.getUnsignedByte()][2];
88
88
+
for (int i_12_ = 0; i_12_ < badByte.length; i_12_++) {
89
89
+
badByte[i_12_][0] = (byte) buffer.getUnsignedByte();
90
90
+
badByte[i_12_][1] = (byte) buffer.getUnsignedByte();
91
91
+
}
92
92
+
if (badByte.length > 0) {
93
93
+
badBytes[index] = badByte;
94
94
+
}
95
95
+
}
96
96
+
}
97
97
+
98
98
+
private static final void loadDomains(char[][] cs, Buffer buffer) {
99
99
+
for (int index = 0; index < cs.length; index++) {
100
100
+
char[] domainEnc = new char[buffer.getUnsignedByte()];
101
101
+
for (int character = 0; character < domainEnc.length; character++) {
102
102
+
domainEnc[character] = (char) buffer.getUnsignedByte();
103
103
+
}
104
104
+
cs[index] = domainEnc;
105
105
+
}
106
106
+
}
107
107
+
108
108
+
private static final void formatLegalCharacters(char[] characters) {
109
109
+
int character = 0;
110
110
+
for (int index = 0; index < characters.length; index++) {
111
111
+
if (ChatCensor.isLegalCharacter(characters[index])) {
112
112
+
characters[character] = characters[index];
113
113
+
} else {
114
114
+
characters[character] = ' ';
115
115
+
}
116
116
+
if (character == 0 || characters[character] != ' ' || characters[character - 1] != ' ') {
117
117
+
character++;
118
118
+
}
119
119
+
}
120
120
+
for (int characterIndex = character; characterIndex < characters.length; characterIndex++) {
121
121
+
characters[characterIndex] = ' ';
122
122
+
}
123
123
+
}
124
124
+
125
125
+
private static final boolean isLegalCharacter(char character) {
126
126
+
if ((character < ' ' || character > '\u007f') && character != ' ' && character != '\n' && character != '\t'
127
127
+
&& character != '\u00a3' && character != '\u20ac') {
128
128
+
return false;
129
129
+
}
130
130
+
return true;
131
131
+
}
132
132
+
133
133
+
public static final String censorString(String string) {
134
134
+
char[] censoredString = string.toCharArray();
135
135
+
ChatCensor.formatLegalCharacters(censoredString);
136
136
+
String censoredStringTrimmed = new String(censoredString).trim();
137
137
+
censoredString = censoredStringTrimmed.toLowerCase().toCharArray();
138
138
+
String censoredStringLowercased = censoredStringTrimmed.toLowerCase();
139
139
+
ChatCensor.method193(false, censoredString);
140
140
+
ChatCensor.method188(censoredString, true);
141
141
+
ChatCensor.method189((byte) 0, censoredString);
142
142
+
ChatCensor.method202(censoredString, -511);
143
143
+
for (String element : ChatCensor.aStringArray175) {
144
144
+
int i_21_ = -1;
145
145
+
while ((i_21_ = censoredStringLowercased.indexOf(element, i_21_ + 1)) != -1) {
146
146
+
char[] cs_22_ = element.toCharArray();
147
147
+
for (int i_23_ = 0; i_23_ < cs_22_.length; i_23_++) {
148
148
+
censoredString[i_23_ + i_21_] = cs_22_[i_23_];
149
149
+
}
150
150
+
}
151
151
+
}
152
152
+
ChatCensor.method186(censoredStringTrimmed.toCharArray(), 2, censoredString);
153
153
+
ChatCensor.method187(0, censoredString);
154
154
+
return new String(censoredString).trim();
155
155
+
}
156
156
+
157
157
+
private static final void method186(char[] cs, int i, char[] cs_25_) {
158
158
+
try {
159
159
+
for (int i_26_ = 0; i_26_ < cs.length; i_26_++) {
160
160
+
if (cs_25_[i_26_] != '*' && ChatCensor.method210(true, cs[i_26_])) {
161
161
+
cs_25_[i_26_] = cs[i_26_];
162
162
+
}
163
163
+
}
164
164
+
if (i != 2) {
165
165
+
return;
166
166
+
}
167
167
+
} catch (RuntimeException runtimeexception) {
168
168
+
SignLink.reportError("66493, " + new String(cs) + ", " + i + ", " + new String(cs_25_) + ", "
169
169
+
+ runtimeexception.toString());
170
170
+
throw new RuntimeException();
171
171
+
}
172
172
+
}
173
173
+
174
174
+
private static final void method187(int i, char[] cs) {
175
175
+
try {
176
176
+
boolean bool = true;
177
177
+
for (int i_27_ = 0; i_27_ < cs.length; i_27_++) {
178
178
+
char c = cs[i_27_];
179
179
+
if (ChatCensor.method207(c, -46837)) {
180
180
+
if (bool) {
181
181
+
if (ChatCensor.method209(c, 1)) {
182
182
+
bool = false;
183
183
+
}
184
184
+
} else if (ChatCensor.method210(true, c)) {
185
185
+
cs[i_27_] = (char) (c + 'a' - 'A');
186
186
+
}
187
187
+
} else {
188
188
+
bool = true;
189
189
+
}
190
190
+
}
191
191
+
if (i != 0) {
192
192
+
return;
193
193
+
}
194
194
+
} catch (RuntimeException runtimeexception) {
195
195
+
SignLink.reportError("29891, " + i + ", " + new String(cs) + ", " + runtimeexception.toString());
196
196
+
throw new RuntimeException();
197
197
+
}
198
198
+
}
199
199
+
200
200
+
private static final void method188(char[] cs, boolean bool) {
201
201
+
try {
202
202
+
if (bool) {
203
203
+
for (int i = 0; i < 2; i++) {
204
204
+
for (int i_28_ = ChatCensor.badWords.length - 1; i_28_ >= 0; i_28_--) {
205
205
+
ChatCensor.method197(ChatCensor.badBytes[i_28_], cs, ChatCensor.anInt162,
206
206
+
ChatCensor.badWords[i_28_]);
207
207
+
}
208
208
+
}
209
209
+
}
210
210
+
} catch (RuntimeException runtimeexception) {
211
211
+
SignLink.reportError("1109, " + new String(cs) + ", " + bool + ", " + runtimeexception.toString());
212
212
+
throw new RuntimeException();
213
213
+
}
214
214
+
}
215
215
+
216
216
+
private static final void method189(byte b, char[] cs) {
217
217
+
try {
218
218
+
char[] cs_29_ = cs.clone();
219
219
+
char[] cs_30_ = { '(', 'a', ')' };
220
220
+
ChatCensor.method197(null, cs_29_, ChatCensor.anInt162, cs_30_);
221
221
+
char[] cs_31_ = cs.clone();
222
222
+
char[] cs_32_ = { 'd', 'o', 't' };
223
223
+
ChatCensor.method197(null, cs_31_, ChatCensor.anInt162, cs_32_);
224
224
+
for (int i = ChatCensor.domains.length - 1; i >= 0; i--) {
225
225
+
ChatCensor.method190(29200, cs, ChatCensor.domains[i], cs_31_, cs_29_);
226
226
+
}
227
227
+
if (b != 0) {
228
228
+
return;
229
229
+
}
230
230
+
} catch (RuntimeException runtimeexception) {
231
231
+
SignLink.reportError("73832, " + b + ", " + new String(cs) + ", " + runtimeexception.toString());
232
232
+
throw new RuntimeException();
233
233
+
}
234
234
+
}
235
235
+
236
236
+
private static final void method190(int i, char[] cs, char[] cs_33_, char[] cs_34_, char[] cs_35_) {
237
237
+
try {
238
238
+
if (i == 29200 && cs_33_.length <= cs.length) {
239
239
+
int i_37_;
240
240
+
for (int i_36_ = 0; i_36_ <= cs.length - cs_33_.length; i_36_ += i_37_) {
241
241
+
int i_38_ = i_36_;
242
242
+
int i_39_ = 0;
243
243
+
i_37_ = 1;
244
244
+
while (i_38_ < cs.length) {
245
245
+
char c = cs[i_38_];
246
246
+
char c_41_ = '\0';
247
247
+
if (i_38_ + 1 < cs.length) {
248
248
+
c_41_ = cs[i_38_ + 1];
249
249
+
}
250
250
+
int i_42_;
251
251
+
if (i_39_ < cs_33_.length && (i_42_ = ChatCensor.method199(43, c, cs_33_[i_39_], c_41_)) > 0) {
252
252
+
i_38_ += i_42_;
253
253
+
i_39_++;
254
254
+
} else {
255
255
+
if (i_39_ == 0) {
256
256
+
break;
257
257
+
}
258
258
+
if ((i_42_ = ChatCensor.method199(43, c, cs_33_[i_39_ - 1], c_41_)) > 0) {
259
259
+
i_38_ += i_42_;
260
260
+
if (i_39_ == 1) {
261
261
+
i_37_++;
262
262
+
}
263
263
+
} else {
264
264
+
if (i_39_ >= cs_33_.length || !ChatCensor.method205(-12789, c)) {
265
265
+
break;
266
266
+
}
267
267
+
i_38_++;
268
268
+
}
269
269
+
}
270
270
+
}
271
271
+
if (i_39_ >= cs_33_.length) {
272
272
+
boolean bool_43_ = false;
273
273
+
int i_44_ = ChatCensor.method191(cs, 4, cs_35_, i_36_);
274
274
+
int i_45_ = ChatCensor.method192(ChatCensor.aByte161, cs_34_, i_38_ - 1, cs);
275
275
+
if (i_44_ > 2 || i_45_ > 2) {
276
276
+
bool_43_ = true;
277
277
+
}
278
278
+
if (bool_43_) {
279
279
+
for (int i_46_ = i_36_; i_46_ < i_38_; i_46_++) {
280
280
+
cs[i_46_] = '*';
281
281
+
}
282
282
+
}
283
283
+
}
284
284
+
}
285
285
+
}
286
286
+
} catch (RuntimeException runtimeexception) {
287
287
+
SignLink.reportError("48695, " + i + ", " + new String(cs) + ", " + new String(cs_33_) + ", "
288
288
+
+ new String(cs_34_) + ", " + new String(cs_35_) + ", " + runtimeexception.toString());
289
289
+
throw new RuntimeException();
290
290
+
}
291
291
+
}
292
292
+
293
293
+
private static final int method191(char[] cs, int i, char[] cs_47_, int i_48_) {
294
294
+
try {
295
295
+
if (i < 4 || i > 4) {
296
296
+
return 2;
297
297
+
}
298
298
+
if (i_48_ == 0) {
299
299
+
return 2;
300
300
+
}
301
301
+
for (int i_49_ = i_48_ - 1; i_49_ >= 0; i_49_--) {
302
302
+
if (!ChatCensor.method205(-12789, cs[i_49_])) {
303
303
+
break;
304
304
+
}
305
305
+
if (cs[i_49_] == '@') {
306
306
+
return 3;
307
307
+
}
308
308
+
}
309
309
+
int i_50_ = 0;
310
310
+
for (int i_51_ = i_48_ - 1; i_51_ >= 0; i_51_--) {
311
311
+
if (!ChatCensor.method205(-12789, cs_47_[i_51_])) {
312
312
+
break;
313
313
+
}
314
314
+
if (cs_47_[i_51_] == '*') {
315
315
+
i_50_++;
316
316
+
}
317
317
+
}
318
318
+
if (i_50_ >= 3) {
319
319
+
return 4;
320
320
+
}
321
321
+
if (ChatCensor.method205(-12789, cs[i_48_ - 1])) {
322
322
+
return 1;
323
323
+
}
324
324
+
return 0;
325
325
+
} catch (RuntimeException runtimeexception) {
326
326
+
SignLink.reportError("87152, " + new String(cs) + ", " + i + ", " + new String(cs_47_) + ", " + i_48_
327
327
+
+ ", " + runtimeexception.toString());
328
328
+
throw new RuntimeException();
329
329
+
}
330
330
+
}
331
331
+
332
332
+
private static final int method192(byte b, char[] cs, int i, char[] cs_52_) {
333
333
+
try {
334
334
+
if (i + 1 == cs_52_.length) {
335
335
+
return 2;
336
336
+
}
337
337
+
for (int i_53_ = i + 1; i_53_ < cs_52_.length; i_53_++) {
338
338
+
if (!ChatCensor.method205(-12789, cs_52_[i_53_])) {
339
339
+
break;
340
340
+
}
341
341
+
if (cs_52_[i_53_] == '.' || cs_52_[i_53_] == ',') {
342
342
+
return 3;
343
343
+
}
344
344
+
}
345
345
+
if (b != -117) {
346
346
+
return ChatCensor.anInt162;
347
347
+
}
348
348
+
int i_54_ = 0;
349
349
+
for (int i_55_ = i + 1; i_55_ < cs_52_.length; i_55_++) {
350
350
+
if (!ChatCensor.method205(-12789, cs[i_55_])) {
351
351
+
break;
352
352
+
}
353
353
+
if (cs[i_55_] == '*') {
354
354
+
i_54_++;
355
355
+
}
356
356
+
}
357
357
+
if (i_54_ >= 3) {
358
358
+
return 4;
359
359
+
}
360
360
+
if (ChatCensor.method205(-12789, cs_52_[i + 1])) {
361
361
+
return 1;
362
362
+
}
363
363
+
return 0;
364
364
+
} catch (RuntimeException runtimeexception) {
365
365
+
SignLink.reportError("50081, " + b + ", " + new String(cs) + ", " + i + ", " + new String(cs_52_) + ", "
366
366
+
+ runtimeexception.toString());
367
367
+
throw new RuntimeException();
368
368
+
}
369
369
+
}
370
370
+
371
371
+
private static final void method193(boolean bool, char[] cs) {
372
372
+
try {
373
373
+
char[] cs_56_ = cs.clone();
374
374
+
char[] cs_57_ = { 'd', 'o', 't' };
375
375
+
if (!bool) {
376
376
+
ChatCensor.method197(null, cs_56_, ChatCensor.anInt162, cs_57_);
377
377
+
char[] cs_58_ = cs.clone();
378
378
+
char[] cs_59_ = { 's', 'l', 'a', 's', 'h' };
379
379
+
ChatCensor.method197(null, cs_58_, ChatCensor.anInt162, cs_59_);
380
380
+
for (int i = 0; i < ChatCensor.topLevelDomains.length; i++) {
381
381
+
ChatCensor.method194(cs_58_, ChatCensor.topLevelDomains[i], ChatCensor.topLevelDomainsType[i],
382
382
+
(byte) 51, cs_56_, cs);
383
383
+
}
384
384
+
}
385
385
+
} catch (RuntimeException runtimeexception) {
386
386
+
SignLink.reportError("41909, " + bool + ", " + new String(cs) + ", " + runtimeexception.toString());
387
387
+
throw new RuntimeException();
388
388
+
}
389
389
+
}
390
390
+
391
391
+
private static final void method194(char[] cs, char[] cs_60_, int i, byte b, char[] cs_61_, char[] cs_62_) {
392
392
+
do {
393
393
+
try {
394
394
+
if (cs_60_.length <= cs_62_.length) {
395
395
+
int i_63_;
396
396
+
for (int i_64_ = 0; i_64_ <= cs_62_.length - cs_60_.length; i_64_ += i_63_) {
397
397
+
int i_65_ = i_64_;
398
398
+
int i_66_ = 0;
399
399
+
i_63_ = 1;
400
400
+
while (i_65_ < cs_62_.length) {
401
401
+
char c = cs_62_[i_65_];
402
402
+
char c_68_ = '\0';
403
403
+
if (i_65_ + 1 < cs_62_.length) {
404
404
+
c_68_ = cs_62_[i_65_ + 1];
405
405
+
}
406
406
+
int i_69_;
407
407
+
if (i_66_ < cs_60_.length
408
408
+
&& (i_69_ = ChatCensor.method199(43, c, cs_60_[i_66_], c_68_)) > 0) {
409
409
+
i_65_ += i_69_;
410
410
+
i_66_++;
411
411
+
} else {
412
412
+
if (i_66_ == 0) {
413
413
+
break;
414
414
+
}
415
415
+
if ((i_69_ = ChatCensor.method199(43, c, cs_60_[i_66_ - 1], c_68_)) > 0) {
416
416
+
i_65_ += i_69_;
417
417
+
if (i_66_ == 1) {
418
418
+
i_63_++;
419
419
+
}
420
420
+
} else {
421
421
+
if (i_66_ >= cs_60_.length || !ChatCensor.method205(-12789, c)) {
422
422
+
break;
423
423
+
}
424
424
+
i_65_++;
425
425
+
}
426
426
+
}
427
427
+
}
428
428
+
if (i_66_ >= cs_60_.length) {
429
429
+
boolean bool_70_ = false;
430
430
+
int i_71_ = ChatCensor.method195(36209, cs_62_, i_64_, cs_61_);
431
431
+
int i_72_ = ChatCensor.method196(false, cs_62_, cs, i_65_ - 1);
432
432
+
if (i == 1 && i_71_ > 0 && i_72_ > 0) {
433
433
+
bool_70_ = true;
434
434
+
}
435
435
+
if (i == 2 && (i_71_ > 2 && i_72_ > 0 || i_71_ > 0 && i_72_ > 2)) {
436
436
+
bool_70_ = true;
437
437
+
}
438
438
+
if (i == 3 && i_71_ > 0 && i_72_ > 2) {
439
439
+
bool_70_ = true;
440
440
+
}
441
441
+
if (i == 3 && i_71_ > 2 && i_72_ > 0) {
442
442
+
/* empty */
443
443
+
}
444
444
+
if (bool_70_) {
445
445
+
int i_73_ = i_64_;
446
446
+
int i_74_ = i_65_ - 1;
447
447
+
if (i_71_ > 2) {
448
448
+
if (i_71_ == 4) {
449
449
+
boolean bool_75_ = false;
450
450
+
for (int i_76_ = i_73_ - 1; i_76_ >= 0; i_76_--) {
451
451
+
if (bool_75_) {
452
452
+
if (cs_61_[i_76_] != '*') {
453
453
+
break;
454
454
+
}
455
455
+
i_73_ = i_76_;
456
456
+
} else if (cs_61_[i_76_] == '*') {
457
457
+
i_73_ = i_76_;
458
458
+
bool_75_ = true;
459
459
+
}
460
460
+
}
461
461
+
}
462
462
+
boolean bool_77_ = false;
463
463
+
for (int i_78_ = i_73_ - 1; i_78_ >= 0; i_78_--) {
464
464
+
if (bool_77_) {
465
465
+
if (ChatCensor.method205(-12789, cs_62_[i_78_])) {
466
466
+
break;
467
467
+
}
468
468
+
i_73_ = i_78_;
469
469
+
} else if (!ChatCensor.method205(-12789, cs_62_[i_78_])) {
470
470
+
bool_77_ = true;
471
471
+
i_73_ = i_78_;
472
472
+
}
473
473
+
}
474
474
+
}
475
475
+
if (i_72_ > 2) {
476
476
+
if (i_72_ == 4) {
477
477
+
boolean bool_79_ = false;
478
478
+
for (int i_80_ = i_74_ + 1; i_80_ < cs_62_.length; i_80_++) {
479
479
+
if (bool_79_) {
480
480
+
if (cs[i_80_] != '*') {
481
481
+
break;
482
482
+
}
483
483
+
i_74_ = i_80_;
484
484
+
} else if (cs[i_80_] == '*') {
485
485
+
i_74_ = i_80_;
486
486
+
bool_79_ = true;
487
487
+
}
488
488
+
}
489
489
+
}
490
490
+
boolean bool_81_ = false;
491
491
+
for (int i_82_ = i_74_ + 1; i_82_ < cs_62_.length; i_82_++) {
492
492
+
if (bool_81_) {
493
493
+
if (ChatCensor.method205(-12789, cs_62_[i_82_])) {
494
494
+
break;
495
495
+
}
496
496
+
i_74_ = i_82_;
497
497
+
} else if (!ChatCensor.method205(-12789, cs_62_[i_82_])) {
498
498
+
bool_81_ = true;
499
499
+
i_74_ = i_82_;
500
500
+
}
501
501
+
}
502
502
+
}
503
503
+
for (int i_83_ = i_73_; i_83_ <= i_74_; i_83_++) {
504
504
+
cs_62_[i_83_] = '*';
505
505
+
}
506
506
+
}
507
507
+
}
508
508
+
}
509
509
+
if (b == 51) {
510
510
+
break;
511
511
+
}
512
512
+
ChatCensor.aBoolean168 = !ChatCensor.aBoolean168;
513
513
+
}
514
514
+
} catch (RuntimeException runtimeexception) {
515
515
+
SignLink.reportError("17314, " + new String(cs) + ", " + new String(cs_60_) + ", " + i + ", " + b
516
516
+
+ ", " + new String(cs_61_) + ", " + new String(cs_62_) + ", " + runtimeexception.toString());
517
517
+
throw new RuntimeException();
518
518
+
}
519
519
+
break;
520
520
+
} while (false);
521
521
+
}
522
522
+
523
523
+
private static final int method195(int i, char[] cs, int i_84_, char[] cs_85_) {
524
524
+
try {
525
525
+
if (i_84_ == 0) {
526
526
+
return 2;
527
527
+
}
528
528
+
for (int i_86_ = i_84_ - 1; i_86_ >= 0; i_86_--) {
529
529
+
if (!ChatCensor.method205(-12789, cs[i_86_])) {
530
530
+
break;
531
531
+
}
532
532
+
if (cs[i_86_] == ',' || cs[i_86_] == '.') {
533
533
+
return 3;
534
534
+
}
535
535
+
}
536
536
+
int i_87_ = 0;
537
537
+
for (int i_88_ = i_84_ - 1; i_88_ >= 0; i_88_--) {
538
538
+
if (!ChatCensor.method205(-12789, cs_85_[i_88_])) {
539
539
+
break;
540
540
+
}
541
541
+
if (cs_85_[i_88_] == '*') {
542
542
+
i_87_++;
543
543
+
}
544
544
+
}
545
545
+
if (i != 36209) {
546
546
+
ChatCensor.aBoolean168 = !ChatCensor.aBoolean168;
547
547
+
}
548
548
+
if (i_87_ >= 3) {
549
549
+
return 4;
550
550
+
}
551
551
+
if (ChatCensor.method205(-12789, cs[i_84_ - 1])) {
552
552
+
return 1;
553
553
+
}
554
554
+
return 0;
555
555
+
} catch (RuntimeException runtimeexception) {
556
556
+
SignLink.reportError("50325, " + i + ", " + new String(cs) + ", " + i_84_ + ", " + new String(cs_85_)
557
557
+
+ ", " + runtimeexception.toString());
558
558
+
throw new RuntimeException();
559
559
+
}
560
560
+
}
561
561
+
562
562
+
private static final int method196(boolean bool, char[] cs, char[] cs_89_, int i) {
563
563
+
try {
564
564
+
if (bool) {
565
565
+
ChatCensor.anInt157 = 391;
566
566
+
}
567
567
+
if (i + 1 == cs.length) {
568
568
+
return 2;
569
569
+
}
570
570
+
for (int i_90_ = i + 1; i_90_ < cs.length; i_90_++) {
571
571
+
if (!ChatCensor.method205(-12789, cs[i_90_])) {
572
572
+
break;
573
573
+
}
574
574
+
if (cs[i_90_] == '\\' || cs[i_90_] == '/') {
575
575
+
return 3;
576
576
+
}
577
577
+
}
578
578
+
int i_91_ = 0;
579
579
+
for (int i_92_ = i + 1; i_92_ < cs.length; i_92_++) {
580
580
+
if (!ChatCensor.method205(-12789, cs_89_[i_92_])) {
581
581
+
break;
582
582
+
}
583
583
+
if (cs_89_[i_92_] == '*') {
584
584
+
i_91_++;
585
585
+
}
586
586
+
}
587
587
+
if (i_91_ >= 5) {
588
588
+
return 4;
589
589
+
}
590
590
+
if (ChatCensor.method205(-12789, cs[i + 1])) {
591
591
+
return 1;
592
592
+
}
593
593
+
return 0;
594
594
+
} catch (RuntimeException runtimeexception) {
595
595
+
SignLink.reportError("27208, " + bool + ", " + new String(cs) + ", " + new String(cs_89_) + ", " + i + ", "
596
596
+
+ runtimeexception.toString());
597
597
+
throw new RuntimeException();
598
598
+
}
599
599
+
}
600
600
+
601
601
+
public static final void method197(byte[][] bs, char[] cs, int i, char[] cs_93_) {
602
602
+
try {
603
603
+
if (i < 0 && cs_93_.length <= cs.length) {
604
604
+
int i_95_;
605
605
+
for (int i_94_ = 0; i_94_ <= cs.length - cs_93_.length; i_94_ += i_95_) {
606
606
+
int i_96_ = i_94_;
607
607
+
int i_97_ = 0;
608
608
+
int i_98_ = 0;
609
609
+
i_95_ = 1;
610
610
+
boolean bool_99_ = false;
611
611
+
boolean bool_100_ = false;
612
612
+
boolean bool_101_ = false;
613
613
+
while (i_96_ < cs.length && (!bool_100_ || !bool_101_)) {
614
614
+
char c = cs[i_96_];
615
615
+
char c_103_ = '\0';
616
616
+
if (i_96_ + 1 < cs.length) {
617
617
+
c_103_ = cs[i_96_ + 1];
618
618
+
}
619
619
+
int i_104_;
620
620
+
if (i_97_ < cs_93_.length
621
621
+
&& (i_104_ = ChatCensor.method200(c_103_, c, ChatCensor.aBoolean163, cs_93_[i_97_])) > 0) {
622
622
+
if (i_104_ == 1 && ChatCensor.method208(c, -976)) {
623
623
+
bool_100_ = true;
624
624
+
}
625
625
+
if (i_104_ == 2 && (ChatCensor.method208(c, -976) || ChatCensor.method208(c_103_, -976))) {
626
626
+
bool_100_ = true;
627
627
+
}
628
628
+
i_96_ += i_104_;
629
629
+
i_97_++;
630
630
+
} else {
631
631
+
if (i_97_ == 0) {
632
632
+
break;
633
633
+
}
634
634
+
if ((i_104_ = ChatCensor.method200(c_103_, c, ChatCensor.aBoolean163, cs_93_[i_97_ - 1])) > 0) {
635
635
+
i_96_ += i_104_;
636
636
+
if (i_97_ == 1) {
637
637
+
i_95_++;
638
638
+
}
639
639
+
} else {
640
640
+
if (i_97_ >= cs_93_.length || !ChatCensor.method206(false, c)) {
641
641
+
break;
642
642
+
}
643
643
+
if (ChatCensor.method205(-12789, c) && c != '\'') {
644
644
+
bool_99_ = true;
645
645
+
}
646
646
+
if (ChatCensor.method208(c, -976)) {
647
647
+
bool_101_ = true;
648
648
+
}
649
649
+
i_96_++;
650
650
+
if (++i_98_ * 100 / (i_96_ - i_94_) > 90) {
651
651
+
break;
652
652
+
}
653
653
+
}
654
654
+
}
655
655
+
}
656
656
+
if (i_97_ >= cs_93_.length && (!bool_100_ || !bool_101_)) {
657
657
+
boolean bool_105_ = true;
658
658
+
if (!bool_99_) {
659
659
+
char c = ' ';
660
660
+
if (i_94_ - 1 >= 0) {
661
661
+
c = cs[i_94_ - 1];
662
662
+
}
663
663
+
char c_106_ = ' ';
664
664
+
if (i_96_ < cs.length) {
665
665
+
c_106_ = cs[i_96_];
666
666
+
}
667
667
+
byte b = ChatCensor.method201(c, ChatCensor.anInt164);
668
668
+
byte b_107_ = ChatCensor.method201(c_106_, ChatCensor.anInt164);
669
669
+
if (bs != null && ChatCensor.method198(b, (byte) 8, bs, b_107_)) {
670
670
+
bool_105_ = false;
671
671
+
}
672
672
+
} else {
673
673
+
boolean bool_108_ = false;
674
674
+
boolean bool_109_ = false;
675
675
+
if (i_94_ - 1 < 0 || ChatCensor.method205(-12789, cs[i_94_ - 1]) && cs[i_94_ - 1] != '\'') {
676
676
+
bool_108_ = true;
677
677
+
}
678
678
+
if (i_96_ >= cs.length || ChatCensor.method205(-12789, cs[i_96_]) && cs[i_96_] != '\'') {
679
679
+
bool_109_ = true;
680
680
+
}
681
681
+
if (!bool_108_ || !bool_109_) {
682
682
+
boolean bool_110_ = false;
683
683
+
int i_111_ = i_94_ - 2;
684
684
+
if (bool_108_) {
685
685
+
i_111_ = i_94_;
686
686
+
}
687
687
+
for (/**/; !bool_110_ && i_111_ < i_96_; i_111_++) {
688
688
+
if (i_111_ >= 0
689
689
+
&& (!ChatCensor.method205(-12789, cs[i_111_]) || cs[i_111_] == '\'')) {
690
690
+
char[] cs_112_ = new char[3];
691
691
+
int i_113_;
692
692
+
for (i_113_ = 0; i_113_ < 3; i_113_++) {
693
693
+
if (i_111_ + i_113_ >= cs.length
694
694
+
|| ChatCensor.method205(-12789, cs[i_111_ + i_113_])
695
695
+
&& cs[i_111_ + i_113_] != '\'') {
696
696
+
break;
697
697
+
}
698
698
+
cs_112_[i_113_] = cs[i_111_ + i_113_];
699
699
+
}
700
700
+
boolean bool_114_ = true;
701
701
+
if (i_113_ == 0) {
702
702
+
bool_114_ = false;
703
703
+
}
704
704
+
if (i_113_ < 3
705
705
+
&& i_111_ - 1 >= 0
706
706
+
&& (!ChatCensor.method205(-12789, cs[i_111_ - 1]) || cs[i_111_ - 1] == '\'')) {
707
707
+
bool_114_ = false;
708
708
+
}
709
709
+
if (bool_114_ && !ChatCensor.method211(cs_112_, (byte) 4)) {
710
710
+
bool_110_ = true;
711
711
+
}
712
712
+
}
713
713
+
}
714
714
+
if (!bool_110_) {
715
715
+
bool_105_ = false;
716
716
+
}
717
717
+
}
718
718
+
}
719
719
+
if (bool_105_) {
720
720
+
int i_115_ = 0;
721
721
+
int i_116_ = 0;
722
722
+
int i_117_ = -1;
723
723
+
for (int i_118_ = i_94_; i_118_ < i_96_; i_118_++) {
724
724
+
if (ChatCensor.method208(cs[i_118_], -976)) {
725
725
+
i_115_++;
726
726
+
} else if (ChatCensor.method207(cs[i_118_], -46837)) {
727
727
+
i_116_++;
728
728
+
i_117_ = i_118_;
729
729
+
}
730
730
+
}
731
731
+
if (i_117_ > -1) {
732
732
+
i_115_ -= i_96_ - 1 - i_117_;
733
733
+
}
734
734
+
if (i_115_ <= i_116_) {
735
735
+
for (int i_119_ = i_94_; i_119_ < i_96_; i_119_++) {
736
736
+
cs[i_119_] = '*';
737
737
+
}
738
738
+
} else {
739
739
+
i_95_ = 1;
740
740
+
}
741
741
+
}
742
742
+
}
743
743
+
}
744
744
+
}
745
745
+
} catch (RuntimeException runtimeexception) {
746
746
+
SignLink.reportError("25459, " + bs + ", " + new String(cs) + ", " + i + ", " + new String(cs_93_) + ", "
747
747
+
+ runtimeexception.toString());
748
748
+
throw new RuntimeException();
749
749
+
}
750
750
+
}
751
751
+
752
752
+
private static final boolean method198(byte b, byte b_120_, byte[][] bs, byte b_121_) {
753
753
+
try {
754
754
+
int i = 0;
755
755
+
if (b_120_ != 8) {
756
756
+
ChatCensor.anInt162 = 308;
757
757
+
}
758
758
+
if (bs[i][0] == b && bs[i][1] == b_121_) {
759
759
+
return true;
760
760
+
}
761
761
+
int i_122_ = bs.length - 1;
762
762
+
if (bs[i_122_][0] == b && bs[i_122_][1] == b_121_) {
763
763
+
return true;
764
764
+
}
765
765
+
do {
766
766
+
int i_123_ = (i + i_122_) / 2;
767
767
+
if (bs[i_123_][0] == b && bs[i_123_][1] == b_121_) {
768
768
+
return true;
769
769
+
}
770
770
+
if (b < bs[i_123_][0] || b == bs[i_123_][0] && b_121_ < bs[i_123_][1]) {
771
771
+
i_122_ = i_123_;
772
772
+
} else {
773
773
+
i = i_123_;
774
774
+
}
775
775
+
} while (i != i_122_ && i + 1 != i_122_);
776
776
+
return false;
777
777
+
} catch (RuntimeException runtimeexception) {
778
778
+
SignLink.reportError("67276, " + b + ", " + b_120_ + ", " + bs + ", " + b_121_ + ", "
779
779
+
+ runtimeexception.toString());
780
780
+
throw new RuntimeException();
781
781
+
}
782
782
+
}
783
783
+
784
784
+
private static final int method199(int i, char c, char c_124_, char c_125_) {
785
785
+
try {
786
786
+
if (i <= 0) {
787
787
+
return ChatCensor.anInt157;
788
788
+
}
789
789
+
if (c_124_ == c) {
790
790
+
return 1;
791
791
+
}
792
792
+
if (c_124_ == 'o' && c == '0') {
793
793
+
return 1;
794
794
+
}
795
795
+
if (c_124_ == 'o' && c == '(' && c_125_ == ')') {
796
796
+
return 2;
797
797
+
}
798
798
+
if (c_124_ == 'c' && (c == '(' || c == '<' || c == '[')) {
799
799
+
return 1;
800
800
+
}
801
801
+
if (c_124_ == 'e' && c == '\u20ac') {
802
802
+
return 1;
803
803
+
}
804
804
+
if (c_124_ == 's' && c == '$') {
805
805
+
return 1;
806
806
+
}
807
807
+
if (c_124_ == 'l' && c == 'i') {
808
808
+
return 1;
809
809
+
}
810
810
+
return 0;
811
811
+
} catch (RuntimeException runtimeexception) {
812
812
+
SignLink.reportError("60577, " + i + ", " + c + ", " + c_124_ + ", " + c_125_ + ", "
813
813
+
+ runtimeexception.toString());
814
814
+
throw new RuntimeException();
815
815
+
}
816
816
+
}
817
817
+
818
818
+
private static final int method200(char c, char c_126_, boolean bool, char c_127_) {
819
819
+
try {
820
820
+
if (!bool) {
821
821
+
ChatCensor.anInt162 = -260;
822
822
+
}
823
823
+
if (c_127_ == c_126_) {
824
824
+
return 1;
825
825
+
}
826
826
+
if (c_127_ >= 'a' && c_127_ <= 'm') {
827
827
+
if (c_127_ == 'a') {
828
828
+
if (c_126_ == '4' || c_126_ == '@' || c_126_ == '^') {
829
829
+
return 1;
830
830
+
}
831
831
+
if (c_126_ == '/' && c == '\\') {
832
832
+
return 2;
833
833
+
}
834
834
+
return 0;
835
835
+
}
836
836
+
if (c_127_ == 'b') {
837
837
+
if (c_126_ == '6' || c_126_ == '8') {
838
838
+
return 1;
839
839
+
}
840
840
+
if (c_126_ == '1' && c == '3' || c_126_ == 'i' && c == '3') {
841
841
+
return 2;
842
842
+
}
843
843
+
return 0;
844
844
+
}
845
845
+
if (c_127_ == 'c') {
846
846
+
if (c_126_ == '(' || c_126_ == '<' || c_126_ == '{' || c_126_ == '[') {
847
847
+
return 1;
848
848
+
}
849
849
+
return 0;
850
850
+
}
851
851
+
if (c_127_ == 'd') {
852
852
+
if (c_126_ == '[' && c == ')' || c_126_ == 'i' && c == ')') {
853
853
+
return 2;
854
854
+
}
855
855
+
return 0;
856
856
+
}
857
857
+
if (c_127_ == 'e') {
858
858
+
if (c_126_ == '3' || c_126_ == '\u20ac') {
859
859
+
return 1;
860
860
+
}
861
861
+
return 0;
862
862
+
}
863
863
+
if (c_127_ == 'f') {
864
864
+
if (c_126_ == 'p' && c == 'h') {
865
865
+
return 2;
866
866
+
}
867
867
+
if (c_126_ == '\u00a3') {
868
868
+
return 1;
869
869
+
}
870
870
+
return 0;
871
871
+
}
872
872
+
if (c_127_ == 'g') {
873
873
+
if (c_126_ == '9' || c_126_ == '6' || c_126_ == 'q') {
874
874
+
return 1;
875
875
+
}
876
876
+
return 0;
877
877
+
}
878
878
+
if (c_127_ == 'h') {
879
879
+
if (c_126_ == '#') {
880
880
+
return 1;
881
881
+
}
882
882
+
return 0;
883
883
+
}
884
884
+
if (c_127_ == 'i') {
885
885
+
if (c_126_ == 'y' || c_126_ == 'l' || c_126_ == 'j' || c_126_ == '1' || c_126_ == '!'
886
886
+
|| c_126_ == ':' || c_126_ == ';' || c_126_ == '|') {
887
887
+
return 1;
888
888
+
}
889
889
+
return 0;
890
890
+
}
891
891
+
if (c_127_ == 'j') {
892
892
+
return 0;
893
893
+
}
894
894
+
if (c_127_ == 'k') {
895
895
+
return 0;
896
896
+
}
897
897
+
if (c_127_ == 'l') {
898
898
+
if (c_126_ == '1' || c_126_ == '|' || c_126_ == 'i') {
899
899
+
return 1;
900
900
+
}
901
901
+
return 0;
902
902
+
}
903
903
+
if (c_127_ == 'm') {
904
904
+
return 0;
905
905
+
}
906
906
+
}
907
907
+
if (c_127_ >= 'n' && c_127_ <= 'z') {
908
908
+
if (c_127_ == 'n') {
909
909
+
return 0;
910
910
+
}
911
911
+
if (c_127_ == 'o') {
912
912
+
if (c_126_ == '0' || c_126_ == '*') {
913
913
+
return 1;
914
914
+
}
915
915
+
if (c_126_ == '(' && c == ')' || c_126_ == '[' && c == ']' || c_126_ == '{' && c == '}'
916
916
+
|| c_126_ == '<' && c == '>') {
917
917
+
return 2;
918
918
+
}
919
919
+
return 0;
920
920
+
}
921
921
+
if (c_127_ == 'p') {
922
922
+
return 0;
923
923
+
}
924
924
+
if (c_127_ == 'q') {
925
925
+
return 0;
926
926
+
}
927
927
+
if (c_127_ == 'r') {
928
928
+
return 0;
929
929
+
}
930
930
+
if (c_127_ == 's') {
931
931
+
if (c_126_ == '5' || c_126_ == 'z' || c_126_ == '$' || c_126_ == '2') {
932
932
+
return 1;
933
933
+
}
934
934
+
return 0;
935
935
+
}
936
936
+
if (c_127_ == 't') {
937
937
+
if (c_126_ == '7' || c_126_ == '+') {
938
938
+
return 1;
939
939
+
}
940
940
+
return 0;
941
941
+
}
942
942
+
if (c_127_ == 'u') {
943
943
+
if (c_126_ == 'v') {
944
944
+
return 1;
945
945
+
}
946
946
+
if (c_126_ == '\\' && c == '/' || c_126_ == '\\' && c == '|' || c_126_ == '|' && c == '/') {
947
947
+
return 2;
948
948
+
}
949
949
+
return 0;
950
950
+
}
951
951
+
if (c_127_ == 'v') {
952
952
+
if (c_126_ == '\\' && c == '/' || c_126_ == '\\' && c == '|' || c_126_ == '|' && c == '/') {
953
953
+
return 2;
954
954
+
}
955
955
+
return 0;
956
956
+
}
957
957
+
if (c_127_ == 'w') {
958
958
+
if (c_126_ == 'v' && c == 'v') {
959
959
+
return 2;
960
960
+
}
961
961
+
return 0;
962
962
+
}
963
963
+
if (c_127_ == 'x') {
964
964
+
if (c_126_ == ')' && c == '(' || c_126_ == '}' && c == '{' || c_126_ == ']' && c == '['
965
965
+
|| c_126_ == '>' && c == '<') {
966
966
+
return 2;
967
967
+
}
968
968
+
return 0;
969
969
+
}
970
970
+
if (c_127_ == 'y') {
971
971
+
return 0;
972
972
+
}
973
973
+
if (c_127_ == 'z') {
974
974
+
return 0;
975
975
+
}
976
976
+
}
977
977
+
if (c_127_ >= '0' && c_127_ <= '9') {
978
978
+
if (c_127_ == '0') {
979
979
+
if (c_126_ == 'o' || c_126_ == 'O') {
980
980
+
return 1;
981
981
+
}
982
982
+
if (c_126_ == '(' && c == ')' || c_126_ == '{' && c == '}' || c_126_ == '[' && c == ']') {
983
983
+
return 2;
984
984
+
}
985
985
+
return 0;
986
986
+
}
987
987
+
if (c_127_ == '1') {
988
988
+
if (c_126_ == 'l') {
989
989
+
return 1;
990
990
+
}
991
991
+
return 0;
992
992
+
}
993
993
+
return 0;
994
994
+
}
995
995
+
if (c_127_ == ',') {
996
996
+
if (c_126_ == '.') {
997
997
+
return 1;
998
998
+
}
999
999
+
return 0;
1000
1000
+
}
1001
1001
+
if (c_127_ == '.') {
1002
1002
+
if (c_126_ == ',') {
1003
1003
+
return 1;
1004
1004
+
}
1005
1005
+
return 0;
1006
1006
+
}
1007
1007
+
if (c_127_ == '!') {
1008
1008
+
if (c_126_ == 'i') {
1009
1009
+
return 1;
1010
1010
+
}
1011
1011
+
return 0;
1012
1012
+
}
1013
1013
+
return 0;
1014
1014
+
} catch (RuntimeException runtimeexception) {
1015
1015
+
SignLink.reportError("9538, " + c + ", " + c_126_ + ", " + bool + ", " + c_127_ + ", "
1016
1016
+
+ runtimeexception.toString());
1017
1017
+
throw new RuntimeException();
1018
1018
+
}
1019
1019
+
}
1020
1020
+
1021
1021
+
private static final byte method201(char c, int i) {
1022
1022
+
try {
1023
1023
+
while (i >= 0) {
1024
1024
+
}
1025
1025
+
if (c >= 'a' && c <= 'z') {
1026
1026
+
return (byte) (c - 'a' + '\001');
1027
1027
+
}
1028
1028
+
if (c == '\'') {
1029
1029
+
return (byte) 28;
1030
1030
+
}
1031
1031
+
if (c >= '0' && c <= '9') {
1032
1032
+
return (byte) (c - '0' + '\035');
1033
1033
+
}
1034
1034
+
return (byte) 27;
1035
1035
+
} catch (RuntimeException runtimeexception) {
1036
1036
+
SignLink.reportError("52349, " + c + ", " + i + ", " + runtimeexception.toString());
1037
1037
+
throw new RuntimeException();
1038
1038
+
}
1039
1039
+
}
1040
1040
+
1041
1041
+
private static final void method202(char[] cs, int i) {
1042
1042
+
try {
1043
1043
+
int i_128_ = 0;
1044
1044
+
int i_129_ = 0;
1045
1045
+
int i_130_ = 0;
1046
1046
+
if (i >= 0) {
1047
1047
+
ChatCensor.aBoolean156 = !ChatCensor.aBoolean156;
1048
1048
+
}
1049
1049
+
int i_131_;
1050
1050
+
while ((i_131_ = ChatCensor.method203(cs, i_128_, 319)) != -1) {
1051
1051
+
boolean bool_132_ = false;
1052
1052
+
for (int i_133_ = i_128_; i_133_ >= 0 && i_133_ < i_131_ && !bool_132_; i_133_++) {
1053
1053
+
if (!ChatCensor.method205(-12789, cs[i_133_]) && !ChatCensor.method206(false, cs[i_133_])) {
1054
1054
+
bool_132_ = true;
1055
1055
+
}
1056
1056
+
}
1057
1057
+
if (bool_132_) {
1058
1058
+
i_129_ = 0;
1059
1059
+
}
1060
1060
+
if (i_129_ == 0) {
1061
1061
+
i_130_ = i_131_;
1062
1062
+
}
1063
1063
+
i_128_ = ChatCensor.method204(cs, 0, i_131_);
1064
1064
+
int i_134_ = 0;
1065
1065
+
for (int i_135_ = i_131_; i_135_ < i_128_; i_135_++) {
1066
1066
+
i_134_ = i_134_ * 10 + cs[i_135_] - 48;
1067
1067
+
}
1068
1068
+
if (i_134_ > 255 || i_128_ - i_131_ > 8) {
1069
1069
+
i_129_ = 0;
1070
1070
+
} else {
1071
1071
+
i_129_++;
1072
1072
+
}
1073
1073
+
if (i_129_ == 4) {
1074
1074
+
for (int i_136_ = i_130_; i_136_ < i_128_; i_136_++) {
1075
1075
+
cs[i_136_] = '*';
1076
1076
+
}
1077
1077
+
i_129_ = 0;
1078
1078
+
}
1079
1079
+
}
1080
1080
+
} catch (RuntimeException runtimeexception) {
1081
1081
+
SignLink.reportError("38921, " + new String(cs) + ", " + i + ", " + runtimeexception.toString());
1082
1082
+
throw new RuntimeException();
1083
1083
+
}
1084
1084
+
}
1085
1085
+
1086
1086
+
private static final int method203(char[] cs, int i, int i_137_) {
1087
1087
+
try {
1088
1088
+
i_137_ = 23 / i_137_;
1089
1089
+
for (int i_138_ = i; i_138_ < cs.length && i_138_ >= 0; i_138_++) {
1090
1090
+
if (cs[i_138_] >= '0' && cs[i_138_] <= '9') {
1091
1091
+
return i_138_;
1092
1092
+
}
1093
1093
+
}
1094
1094
+
return -1;
1095
1095
+
} catch (RuntimeException runtimeexception) {
1096
1096
+
SignLink.reportError("27983, " + new String(cs) + ", " + i + ", " + i_137_ + ", "
1097
1097
+
+ runtimeexception.toString());
1098
1098
+
throw new RuntimeException();
1099
1099
+
}
1100
1100
+
}
1101
1101
+
1102
1102
+
private static final int method204(char[] cs, int i, int i_139_) {
1103
1103
+
try {
1104
1104
+
for (int i_140_ = i_139_; i_140_ < cs.length && i_140_ >= 0; i_140_++) {
1105
1105
+
if (cs[i_140_] < '0' || cs[i_140_] > '9') {
1106
1106
+
return i_140_;
1107
1107
+
}
1108
1108
+
}
1109
1109
+
if (i != 0) {
1110
1110
+
return 3;
1111
1111
+
}
1112
1112
+
return cs.length;
1113
1113
+
} catch (RuntimeException runtimeexception) {
1114
1114
+
SignLink.reportError("1466, " + new String(cs) + ", " + i + ", " + i_139_ + ", "
1115
1115
+
+ runtimeexception.toString());
1116
1116
+
throw new RuntimeException();
1117
1117
+
}
1118
1118
+
}
1119
1119
+
1120
1120
+
private static final boolean method205(int i, char c) {
1121
1121
+
try {
1122
1122
+
if (i != -12789) {
1123
1123
+
throw new NullPointerException();
1124
1124
+
}
1125
1125
+
if (ChatCensor.method207(c, -46837) || ChatCensor.method208(c, -976)) {
1126
1126
+
return false;
1127
1127
+
}
1128
1128
+
return true;
1129
1129
+
} catch (RuntimeException runtimeexception) {
1130
1130
+
SignLink.reportError("18641, " + i + ", " + c + ", " + runtimeexception.toString());
1131
1131
+
throw new RuntimeException();
1132
1132
+
}
1133
1133
+
}
1134
1134
+
1135
1135
+
private static final boolean method206(boolean bool, char c) {
1136
1136
+
try {
1137
1137
+
if (bool) {
1138
1138
+
ChatCensor.anInt164 = -233;
1139
1139
+
}
1140
1140
+
if (c < 'a' || c > 'z') {
1141
1141
+
return true;
1142
1142
+
}
1143
1143
+
if (c == 'v' || c == 'x' || c == 'j' || c == 'q' || c == 'z') {
1144
1144
+
return true;
1145
1145
+
}
1146
1146
+
return false;
1147
1147
+
} catch (RuntimeException runtimeexception) {
1148
1148
+
SignLink.reportError("32846, " + bool + ", " + c + ", " + runtimeexception.toString());
1149
1149
+
throw new RuntimeException();
1150
1150
+
}
1151
1151
+
}
1152
1152
+
1153
1153
+
private static final boolean method207(char c, int i) {
1154
1154
+
try {
1155
1155
+
if (i != -46837) {
1156
1156
+
for (int i_141_ = 1; i_141_ > 0; i_141_++) {
1157
1157
+
/* empty */
1158
1158
+
}
1159
1159
+
}
1160
1160
+
if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z')) {
1161
1161
+
return false;
1162
1162
+
}
1163
1163
+
return true;
1164
1164
+
} catch (RuntimeException runtimeexception) {
1165
1165
+
SignLink.reportError("61160, " + c + ", " + i + ", " + runtimeexception.toString());
1166
1166
+
throw new RuntimeException();
1167
1167
+
}
1168
1168
+
}
1169
1169
+
1170
1170
+
private static final boolean method208(char c, int i) {
1171
1171
+
try {
1172
1172
+
if (i >= 0) {
1173
1173
+
ChatCensor.anInt164 = 254;
1174
1174
+
}
1175
1175
+
if (c < '0' || c > '9') {
1176
1176
+
return false;
1177
1177
+
}
1178
1178
+
return true;
1179
1179
+
} catch (RuntimeException runtimeexception) {
1180
1180
+
SignLink.reportError("30488, " + c + ", " + i + ", " + runtimeexception.toString());
1181
1181
+
throw new RuntimeException();
1182
1182
+
}
1183
1183
+
}
1184
1184
+
1185
1185
+
private static final boolean method209(char c, int i) {
1186
1186
+
try {
1187
1187
+
if (i != 1) {
1188
1188
+
for (int i_142_ = 1; i_142_ > 0; i_142_++) {
1189
1189
+
/* empty */
1190
1190
+
}
1191
1191
+
}
1192
1192
+
if (c < 'a' || c > 'z') {
1193
1193
+
return false;
1194
1194
+
}
1195
1195
+
return true;
1196
1196
+
} catch (RuntimeException runtimeexception) {
1197
1197
+
SignLink.reportError("25533, " + c + ", " + i + ", " + runtimeexception.toString());
1198
1198
+
throw new RuntimeException();
1199
1199
+
}
1200
1200
+
}
1201
1201
+
1202
1202
+
private static final boolean method210(boolean bool, char c) {
1203
1203
+
try {
1204
1204
+
if (!bool) {
1205
1205
+
throw new NullPointerException();
1206
1206
+
}
1207
1207
+
if (c < 'A' || c > 'Z') {
1208
1208
+
return false;
1209
1209
+
}
1210
1210
+
return true;
1211
1211
+
} catch (RuntimeException runtimeexception) {
1212
1212
+
SignLink.reportError("1272, " + bool + ", " + c + ", " + runtimeexception.toString());
1213
1213
+
throw new RuntimeException();
1214
1214
+
}
1215
1215
+
}
1216
1216
+
1217
1217
+
private static final boolean method211(char[] cs, byte b) {
1218
1218
+
try {
1219
1219
+
if (b == ChatCensor.aByte166) {
1220
1220
+
b = (byte) 0;
1221
1221
+
} else {
1222
1222
+
throw new NullPointerException();
1223
1223
+
}
1224
1224
+
boolean bool = true;
1225
1225
+
for (int i = 0; i < cs.length; i++) {
1226
1226
+
if (!ChatCensor.method208(cs[i], -976) && cs[i] != 0) {
1227
1227
+
bool = false;
1228
1228
+
}
1229
1229
+
}
1230
1230
+
if (bool) {
1231
1231
+
return true;
1232
1232
+
}
1233
1233
+
int i = ChatCensor.method212(cs, 8801);
1234
1234
+
int i_143_ = 0;
1235
1235
+
int i_144_ = ChatCensor.fragments.length - 1;
1236
1236
+
if (i == ChatCensor.fragments[i_143_] || i == ChatCensor.fragments[i_144_]) {
1237
1237
+
return true;
1238
1238
+
}
1239
1239
+
do {
1240
1240
+
int i_145_ = (i_143_ + i_144_) / 2;
1241
1241
+
if (i == ChatCensor.fragments[i_145_]) {
1242
1242
+
return true;
1243
1243
+
}
1244
1244
+
if (i < ChatCensor.fragments[i_145_]) {
1245
1245
+
i_144_ = i_145_;
1246
1246
+
} else {
1247
1247
+
i_143_ = i_145_;
1248
1248
+
}
1249
1249
+
} while (i_143_ != i_144_ && i_143_ + 1 != i_144_);
1250
1250
+
return false;
1251
1251
+
} catch (RuntimeException runtimeexception) {
1252
1252
+
SignLink.reportError("62482, " + new String(cs) + ", " + b + ", " + runtimeexception.toString());
1253
1253
+
throw new RuntimeException();
1254
1254
+
}
1255
1255
+
}
1256
1256
+
1257
1257
+
public static final int method212(char[] cs, int i) {
1258
1258
+
try {
1259
1259
+
if (i != ChatCensor.anInt167) {
1260
1260
+
for (int i_146_ = 1; i_146_ > 0; i_146_++) {
1261
1261
+
/* empty */
1262
1262
+
}
1263
1263
+
}
1264
1264
+
if (cs.length > 6) {
1265
1265
+
return 0;
1266
1266
+
}
1267
1267
+
int i_147_ = 0;
1268
1268
+
for (int i_148_ = 0; i_148_ < cs.length; i_148_++) {
1269
1269
+
int i_149_ = cs[cs.length - i_148_ - 1];
1270
1270
+
if (i_149_ >= 97 && i_149_ <= 122) {
1271
1271
+
i_147_ = i_147_ * 38 + (i_149_ - 97 + 1);
1272
1272
+
} else if (i_149_ == 39) {
1273
1273
+
i_147_ = i_147_ * 38 + 27;
1274
1274
+
} else if (i_149_ >= 48 && i_149_ <= 57) {
1275
1275
+
i_147_ = i_147_ * 38 + (i_149_ - 48 + 28);
1276
1276
+
} else if (i_149_ != 0) {
1277
1277
+
return 0;
1278
1278
+
}
1279
1279
+
}
1280
1280
+
return i_147_;
1281
1281
+
} catch (RuntimeException runtimeexception) {
1282
1282
+
SignLink.reportError("67682, " + new String(cs) + ", " + i + ", " + runtimeexception.toString());
1283
1283
+
throw new RuntimeException();
1284
1284
+
}
1285
1285
+
}
1286
1286
+
}
+54
src/com/jagex/runescape/cache/cfg/VarBit.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache.cfg;
2
2
+
3
3
+
import com.jagex.runescape.cache.Archive;
4
4
+
import com.jagex.runescape.net.Buffer;
5
5
+
6
6
+
public class VarBit {
7
7
+
8
8
+
public static int count;
9
9
+
public static VarBit[] cache;
10
10
+
public int configId;
11
11
+
public int leastSignificantBit;
12
12
+
public int mostSignificantBit;
13
13
+
14
14
+
public static void load(Archive archive) {
15
15
+
Buffer buffer = new Buffer(archive.getFile("varbit.dat"));
16
16
+
VarBit.count = buffer.getUnsignedLEShort();
17
17
+
if (VarBit.cache == null) {
18
18
+
VarBit.cache = new VarBit[VarBit.count];
19
19
+
}
20
20
+
for (int index = 0; index < VarBit.count; index++) {
21
21
+
if (VarBit.cache[index] == null) {
22
22
+
VarBit.cache[index] = new VarBit();
23
23
+
}
24
24
+
VarBit.cache[index].loadDefinition(buffer);
25
25
+
}
26
26
+
if (buffer.offset == buffer.payload.length) {
27
27
+
return;
28
28
+
}
29
29
+
System.out.println("varbit load mismatch");
30
30
+
}
31
31
+
32
32
+
public void loadDefinition(Buffer buffer) {
33
33
+
while (true) {
34
34
+
int attributeId = buffer.getUnsignedByte();
35
35
+
if (attributeId == 0) {
36
36
+
break;
37
37
+
}
38
38
+
if (attributeId == 1) {
39
39
+
configId = buffer.getUnsignedLEShort();
40
40
+
leastSignificantBit = buffer.getUnsignedByte();
41
41
+
mostSignificantBit = buffer.getUnsignedByte();
42
42
+
System.out.println(leastSignificantBit + ":" + mostSignificantBit);
43
43
+
} else if (attributeId == 10) {
44
44
+
buffer.getString(); // dummy
45
45
+
} else if (attributeId == 3) {
46
46
+
buffer.getInt(); // dummy
47
47
+
} else if (attributeId == 4) {
48
48
+
buffer.getInt(); // dummy
49
49
+
} else {
50
50
+
System.out.println("Error unrecognised config code: " + attributeId);
51
51
+
}
52
52
+
}
53
53
+
}
54
54
+
}
+53
src/com/jagex/runescape/cache/cfg/Varp.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache.cfg;
2
2
+
3
3
+
import com.jagex.runescape.cache.Archive;
4
4
+
import com.jagex.runescape.net.Buffer;
5
5
+
6
6
+
public class Varp {
7
7
+
8
8
+
public static int varpCount;
9
9
+
public static Varp[] cache;
10
10
+
public static int currentIndex;
11
11
+
public int type;
12
12
+
13
13
+
public static void load(Archive archive) {
14
14
+
Buffer buffer = new Buffer(archive.getFile("varp.dat"));
15
15
+
Varp.currentIndex = 0;
16
16
+
Varp.varpCount = buffer.getUnsignedLEShort();
17
17
+
if (Varp.cache == null) {
18
18
+
Varp.cache = new Varp[Varp.varpCount];
19
19
+
}
20
20
+
for (int index = 0; index < Varp.varpCount; index++) {
21
21
+
if (Varp.cache[index] == null) {
22
22
+
Varp.cache[index] = new Varp();
23
23
+
}
24
24
+
Varp.cache[index].loadDefinition(buffer, index);
25
25
+
}
26
26
+
if (buffer.offset == buffer.payload.length) {
27
27
+
return;
28
28
+
}
29
29
+
System.out.println("varptype load mismatch");
30
30
+
}
31
31
+
32
32
+
public void loadDefinition(Buffer buffer, int index) {
33
33
+
while (true) {
34
34
+
int attributeId = buffer.getUnsignedByte();
35
35
+
if (attributeId == 0) {
36
36
+
break;
37
37
+
}
38
38
+
if (attributeId == 1) {
39
39
+
buffer.getUnsignedByte(); // dummy
40
40
+
} else if (attributeId == 2) {
41
41
+
buffer.getUnsignedByte(); // dummy
42
42
+
} else if (attributeId == 5) {
43
43
+
type = buffer.getUnsignedLEShort();
44
44
+
} else if (attributeId == 7) {
45
45
+
buffer.getInt(); // dummy
46
46
+
} else if (attributeId == 10) {
47
47
+
buffer.getString(); // dummy
48
48
+
} else {
49
49
+
System.out.println("Error unrecognised config code: " + attributeId);
50
50
+
}
51
51
+
}
52
52
+
}
53
53
+
}
+292
src/com/jagex/runescape/cache/def/ActorDefinition.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache.def;
2
2
+
3
3
+
import com.jagex.runescape.cache.Archive;
4
4
+
import com.jagex.runescape.cache.cfg.VarBit;
5
5
+
import com.jagex.runescape.collection.Cache;
6
6
+
import com.jagex.runescape.media.Animation;
7
7
+
import com.jagex.runescape.media.renderable.Model;
8
8
+
import com.jagex.runescape.Game;
9
9
+
import com.jagex.runescape.net.Buffer;
10
10
+
11
11
+
public class ActorDefinition {
12
12
+
13
13
+
public int turnLeftAnimationId = -1;
14
14
+
private static int bufferIndex;
15
15
+
public int varBitId = -1;
16
16
+
public int turnAroundAnimationId = -1;
17
17
+
public int settingId = -1;
18
18
+
private static Buffer buffer;
19
19
+
public int combatLevel = -1;
20
20
+
public static int size;
21
21
+
public String name;
22
22
+
public String[] actions;
23
23
+
public int walkAnimationId = -1;
24
24
+
public byte boundaryDimension = 1;
25
25
+
private int[] originalModelColors;
26
26
+
private static int[] bufferOffsets;
27
27
+
private int[] headModelIndexes;
28
28
+
public int headIcon = -1;
29
29
+
private int[] modifiedModelColors;
30
30
+
public int standAnimationId = -1;
31
31
+
public long id = -1;
32
32
+
public int degreesToTurn = 32;
33
33
+
private static ActorDefinition[] cache;
34
34
+
public static Game client;
35
35
+
public int turnRightAnimationId = -1;
36
36
+
public boolean clickable = true;
37
37
+
private int brightness;
38
38
+
private int sizeY = 128;
39
39
+
public boolean minimapVisible = true;
40
40
+
public int[] childrenIds;
41
41
+
public byte[] description;
42
42
+
private int sizeXZ = 128;
43
43
+
private int contrast;
44
44
+
public boolean visible = false;
45
45
+
private int[] modelIds;
46
46
+
public static Cache modelCache = new Cache(30);
47
47
+
48
48
+
public static final ActorDefinition getDefinition(int id) {
49
49
+
for (int i = 0; i < 20; i++) {
50
50
+
if (ActorDefinition.cache[i].id == id) {
51
51
+
return ActorDefinition.cache[i];
52
52
+
}
53
53
+
}
54
54
+
ActorDefinition.bufferIndex = (ActorDefinition.bufferIndex + 1) % 20;
55
55
+
ActorDefinition definition = ActorDefinition.cache[ActorDefinition.bufferIndex] = new ActorDefinition();
56
56
+
ActorDefinition.buffer.offset = ActorDefinition.bufferOffsets[id];
57
57
+
definition.id = id;
58
58
+
definition.loadDefinition(true, ActorDefinition.buffer);
59
59
+
return definition;
60
60
+
}
61
61
+
62
62
+
public final Model getHeadModel() {
63
63
+
if (childrenIds != null) {
64
64
+
ActorDefinition definition = getChildDefinition();
65
65
+
if (definition == null) {
66
66
+
return null;
67
67
+
}
68
68
+
return definition.getHeadModel();
69
69
+
}
70
70
+
if (headModelIndexes == null) {
71
71
+
return null;
72
72
+
}
73
73
+
boolean cached = false;
74
74
+
for (int headModel = 0; headModel < headModelIndexes.length; headModel++) {
75
75
+
if (!Model.isCached(headModelIndexes[headModel])) {
76
76
+
cached = true;
77
77
+
}
78
78
+
}
79
79
+
if (cached) {
80
80
+
return null;
81
81
+
}
82
82
+
Model[] headModels = new Model[headModelIndexes.length];
83
83
+
for (int model = 0; model < headModelIndexes.length; model++) {
84
84
+
headModels[model] = Model.getModel(headModelIndexes[model]);
85
85
+
}
86
86
+
Model headModel;
87
87
+
if (headModels.length == 1) {
88
88
+
headModel = headModels[0];
89
89
+
} else {
90
90
+
headModel = new Model(headModels.length, headModels);
91
91
+
}
92
92
+
if (modifiedModelColors != null) {
93
93
+
for (int color = 0; color < modifiedModelColors.length; color++) {
94
94
+
headModel.recolor(modifiedModelColors[color], originalModelColors[color]);
95
95
+
}
96
96
+
}
97
97
+
return headModel;
98
98
+
}
99
99
+
100
100
+
public final ActorDefinition getChildDefinition() {
101
101
+
int childId = -1;
102
102
+
if (varBitId != -1) {
103
103
+
VarBit varbit = VarBit.cache[varBitId];
104
104
+
int configId = varbit.configId;
105
105
+
int leastSignificantBit = varbit.leastSignificantBit;
106
106
+
int mostSignificantBit = varbit.mostSignificantBit;
107
107
+
int bit = Game.BITFIELD_MAX_VALUE[mostSignificantBit - leastSignificantBit];
108
108
+
childId = ActorDefinition.client.widgetSettings[configId] >> leastSignificantBit & bit;
109
109
+
} else if (settingId != -1) {
110
110
+
childId = ActorDefinition.client.widgetSettings[settingId];
111
111
+
}
112
112
+
if (childId < 0 || childId >= childrenIds.length || childrenIds[childId] == -1) {
113
113
+
return null;
114
114
+
}
115
115
+
return ActorDefinition.getDefinition(childrenIds[childId]);
116
116
+
}
117
117
+
118
118
+
public static final void load(Archive archive) {
119
119
+
ActorDefinition.buffer = new Buffer(archive.getFile("npc.dat"));
120
120
+
Buffer buffer = new Buffer(archive.getFile("npc.idx"));
121
121
+
ActorDefinition.size = buffer.getUnsignedLEShort();
122
122
+
ActorDefinition.bufferOffsets = new int[ActorDefinition.size];
123
123
+
int offset = 2;
124
124
+
for (int bufferIndex = 0; bufferIndex < ActorDefinition.size; bufferIndex++) {
125
125
+
ActorDefinition.bufferOffsets[bufferIndex] = offset;
126
126
+
offset += buffer.getUnsignedLEShort();
127
127
+
}
128
128
+
ActorDefinition.cache = new ActorDefinition[20];
129
129
+
for (int cacheIndex = 0; cacheIndex < 20; cacheIndex++) {
130
130
+
ActorDefinition.cache[cacheIndex] = new ActorDefinition();
131
131
+
}
132
132
+
}
133
133
+
134
134
+
public static final void reset() {
135
135
+
ActorDefinition.modelCache = null;
136
136
+
ActorDefinition.bufferOffsets = null;
137
137
+
ActorDefinition.cache = null;
138
138
+
ActorDefinition.buffer = null;
139
139
+
}
140
140
+
141
141
+
public final Model getChildModel(int frameId2, int frameId, int[] framesFrom2) {
142
142
+
if (childrenIds != null) {
143
143
+
ActorDefinition childDefinition = getChildDefinition();
144
144
+
if (childDefinition == null) {
145
145
+
return null;
146
146
+
}
147
147
+
return childDefinition.getChildModel(frameId2, frameId, framesFrom2);
148
148
+
}
149
149
+
Model childIdModel = (Model) ActorDefinition.modelCache.get(id);
150
150
+
if (childIdModel == null) {
151
151
+
boolean cached = false;
152
152
+
for (int modelId : modelIds) {
153
153
+
if (Model.isCached(modelId)) {
154
154
+
cached = true;
155
155
+
}
156
156
+
}
157
157
+
if (!cached) {
158
158
+
return null;
159
159
+
}
160
160
+
Model[] childModels = new Model[modelIds.length];
161
161
+
for (int model = 0; model < modelIds.length; model++) {
162
162
+
childModels[model] = Model.getModel(modelIds[model]);
163
163
+
}
164
164
+
if (childModels.length == 1) {
165
165
+
childIdModel = childModels[0];
166
166
+
} else {
167
167
+
childIdModel = new Model(childModels.length, childModels);
168
168
+
}
169
169
+
if (modifiedModelColors != null) {
170
170
+
for (int color = 0; color < modifiedModelColors.length; color++) {
171
171
+
childIdModel.recolor(modifiedModelColors[color], originalModelColors[color]);
172
172
+
}
173
173
+
}
174
174
+
childIdModel.createBones();
175
175
+
childIdModel.applyLighting(64 + brightness, 850 + contrast, -30, -50, -30, true);
176
176
+
ActorDefinition.modelCache.put(childIdModel, id);
177
177
+
}
178
178
+
Model childModel = Model.aModel1614;
179
179
+
childModel.replaceWithModel(childIdModel, Animation.exists(frameId) & Animation.exists(frameId2));
180
180
+
if (frameId != -1 && frameId2 != -1) {
181
181
+
childModel.mixAnimationFrames(-20491, framesFrom2, frameId2, frameId);
182
182
+
} else if (frameId != -1) {
183
183
+
childModel.applyTransform(frameId);
184
184
+
}
185
185
+
if (sizeXZ != 128 || sizeY != 128) {
186
186
+
childModel.scaleT(sizeXZ, sizeXZ, sizeY);
187
187
+
}
188
188
+
childModel.calculateDiagonals();
189
189
+
childModel.triangleSkin = null;
190
190
+
childModel.vectorSkin = null;
191
191
+
if (boundaryDimension == 1) {
192
192
+
childModel.oneSquareModel = true;
193
193
+
}
194
194
+
return childModel;
195
195
+
}
196
196
+
197
197
+
private final void loadDefinition(boolean bool, Buffer buffer) {
198
198
+
while (true) {
199
199
+
int attributeId = buffer.getUnsignedByte();
200
200
+
if (attributeId == 0) {
201
201
+
break;
202
202
+
}
203
203
+
if (attributeId == 1) {
204
204
+
int modelCount = buffer.getUnsignedByte();
205
205
+
modelIds = new int[modelCount];
206
206
+
for (int model = 0; model < modelCount; model++) {
207
207
+
modelIds[model] = buffer.getUnsignedLEShort();
208
208
+
}
209
209
+
} else if (attributeId == 2) {
210
210
+
name = buffer.getString();
211
211
+
} else if (attributeId == 3) {
212
212
+
description = buffer.getStringAsBytes();
213
213
+
} else if (attributeId == 12) {
214
214
+
boundaryDimension = buffer.get();
215
215
+
} else if (attributeId == 13) {
216
216
+
standAnimationId = buffer.getUnsignedLEShort();
217
217
+
} else if (attributeId == 14) {
218
218
+
walkAnimationId = buffer.getUnsignedLEShort();
219
219
+
} else if (attributeId == 17) {
220
220
+
walkAnimationId = buffer.getUnsignedLEShort();
221
221
+
turnAroundAnimationId = buffer.getUnsignedLEShort();
222
222
+
turnRightAnimationId = buffer.getUnsignedLEShort();
223
223
+
turnLeftAnimationId = buffer.getUnsignedLEShort();
224
224
+
} else if (attributeId >= 30 && attributeId < 40) {
225
225
+
if (actions == null) {
226
226
+
actions = new String[5];
227
227
+
}
228
228
+
actions[attributeId - 30] = buffer.getString();
229
229
+
if (actions[attributeId - 30].equalsIgnoreCase("hidden")) {
230
230
+
actions[attributeId - 30] = null;
231
231
+
}
232
232
+
} else if (attributeId == 40) {
233
233
+
int modelColorCount = buffer.getUnsignedByte();
234
234
+
modifiedModelColors = new int[modelColorCount];
235
235
+
originalModelColors = new int[modelColorCount];
236
236
+
for (int color = 0; color < modelColorCount; color++) {
237
237
+
modifiedModelColors[color] = buffer.getUnsignedLEShort();
238
238
+
originalModelColors[color] = buffer.getUnsignedLEShort();
239
239
+
}
240
240
+
} else if (attributeId == 60) {
241
241
+
int additionalModelCount = buffer.getUnsignedByte();
242
242
+
headModelIndexes = new int[additionalModelCount];
243
243
+
for (int model = 0; model < additionalModelCount; model++) {
244
244
+
headModelIndexes[model] = buffer.getUnsignedLEShort();
245
245
+
}
246
246
+
} else if (attributeId == 90) {
247
247
+
buffer.getUnsignedLEShort(); // dummy
248
248
+
} else if (attributeId == 91) {
249
249
+
buffer.getUnsignedLEShort(); // dummy
250
250
+
} else if (attributeId == 92) {
251
251
+
buffer.getUnsignedLEShort(); // dummy
252
252
+
} else if (attributeId == 93) {
253
253
+
minimapVisible = false;
254
254
+
} else if (attributeId == 95) {
255
255
+
combatLevel = buffer.getUnsignedLEShort();
256
256
+
} else if (attributeId == 97) {
257
257
+
sizeXZ = buffer.getUnsignedLEShort();
258
258
+
} else if (attributeId == 98) {
259
259
+
sizeY = buffer.getUnsignedLEShort();
260
260
+
} else if (attributeId == 99) {
261
261
+
visible = true;
262
262
+
} else if (attributeId == 100) {
263
263
+
brightness = buffer.get();
264
264
+
} else if (attributeId == 101) {
265
265
+
contrast = buffer.get() * 5;
266
266
+
} else if (attributeId == 102) {
267
267
+
headIcon = buffer.getUnsignedLEShort();
268
268
+
} else if (attributeId == 103) {
269
269
+
degreesToTurn = buffer.getUnsignedLEShort();
270
270
+
} else if (attributeId == 106) {
271
271
+
varBitId = buffer.getUnsignedLEShort();
272
272
+
if (varBitId == 65535) {
273
273
+
varBitId = -1;
274
274
+
}
275
275
+
settingId = buffer.getUnsignedLEShort();
276
276
+
if (settingId == 65535) {
277
277
+
settingId = -1;
278
278
+
}
279
279
+
int childrenCount = buffer.getUnsignedByte();
280
280
+
childrenIds = new int[childrenCount + 1];
281
281
+
for (int child = 0; child <= childrenCount; child++) {
282
282
+
childrenIds[child] = buffer.getUnsignedLEShort();
283
283
+
if (childrenIds[child] == 65535) {
284
284
+
childrenIds[child] = -1;
285
285
+
}
286
286
+
}
287
287
+
} else if (attributeId == 107) {
288
288
+
clickable = false;
289
289
+
}
290
290
+
}
291
291
+
}
292
292
+
}
+166
src/com/jagex/runescape/cache/def/FloorDefinition.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache.def;
2
2
+
3
3
+
import com.jagex.runescape.cache.Archive;
4
4
+
import com.jagex.runescape.net.Buffer;
5
5
+
6
6
+
public class FloorDefinition {
7
7
+
8
8
+
public static int count;
9
9
+
public static FloorDefinition[] cache;
10
10
+
public String name;
11
11
+
public int rgbColor;
12
12
+
public int textureId = -1;
13
13
+
public boolean aBoolean227 = false;
14
14
+
public boolean occlude = true;
15
15
+
public int hue2;
16
16
+
public int saturation;
17
17
+
public int lightness;
18
18
+
public int hue;
19
19
+
public int hueDivisor;
20
20
+
public int hslColor2;
21
21
+
22
22
+
public static void load(Archive archive) {
23
23
+
Buffer buffer = new Buffer(archive.getFile("flo.dat"));
24
24
+
FloorDefinition.count = buffer.getUnsignedLEShort();
25
25
+
if (FloorDefinition.cache == null) {
26
26
+
FloorDefinition.cache = new FloorDefinition[FloorDefinition.count];
27
27
+
}
28
28
+
for (int floor = 0; floor < FloorDefinition.count; floor++) {
29
29
+
if (FloorDefinition.cache[floor] == null) {
30
30
+
FloorDefinition.cache[floor] = new FloorDefinition();
31
31
+
}
32
32
+
FloorDefinition.cache[floor].loadDefinition(true, buffer);
33
33
+
}
34
34
+
}
35
35
+
36
36
+
public void loadDefinition(boolean bool, Buffer buffer) {
37
37
+
while (true) {
38
38
+
int attributeId = buffer.getUnsignedByte();
39
39
+
if (attributeId == 0) {
40
40
+
break;
41
41
+
}
42
42
+
if (attributeId == 1) {
43
43
+
rgbColor = buffer.get24BitInt();
44
44
+
shiftRGBColors(rgbColor);
45
45
+
} else if (attributeId == 2) {
46
46
+
textureId = buffer.getUnsignedByte();
47
47
+
} else if (attributeId == 3) {
48
48
+
aBoolean227 = true;
49
49
+
} else if (attributeId == 5) {
50
50
+
occlude = false;
51
51
+
} else if (attributeId == 6) {
52
52
+
name = buffer.getString();
53
53
+
} else if (attributeId == 7) {
54
54
+
int oldHue2 = hue2;
55
55
+
int oldSaturation = saturation;
56
56
+
int oldLightness = lightness;
57
57
+
int oldHue = hue;
58
58
+
shiftRGBColors(buffer.get24BitInt());
59
59
+
hue2 = oldHue2;
60
60
+
saturation = oldSaturation;
61
61
+
lightness = oldLightness;
62
62
+
hue = oldHue;
63
63
+
hueDivisor = oldHue;
64
64
+
} else {
65
65
+
System.out.println("Error unrecognised config code: " + attributeId);
66
66
+
}
67
67
+
}
68
68
+
}
69
69
+
70
70
+
private void shiftRGBColors(int color) {
71
71
+
double r = (color >> 16 & 0xff) / 256.0;
72
72
+
double b = (color >> 8 & 0xff) / 256.0;
73
73
+
double g = (color & 0xff) / 256.0;
74
74
+
double cmin = r;
75
75
+
if (b < cmin) {
76
76
+
cmin = b;
77
77
+
}
78
78
+
if (g < cmin) {
79
79
+
cmin = g;
80
80
+
}
81
81
+
double cmax = r;
82
82
+
if (b > cmax) {
83
83
+
cmax = b;
84
84
+
}
85
85
+
if (g > cmax) {
86
86
+
cmax = g;
87
87
+
}
88
88
+
double d_11_ = 0.0;
89
89
+
double d_12_ = 0.0;
90
90
+
double d_13_ = (cmin + cmax) / 2.0;
91
91
+
if (cmin != cmax) {
92
92
+
if (d_13_ < 0.5) {
93
93
+
d_12_ = (cmax - cmin) / (cmax + cmin);
94
94
+
}
95
95
+
if (d_13_ >= 0.5) {
96
96
+
d_12_ = (cmax - cmin) / (2.0 - cmax - cmin);
97
97
+
}
98
98
+
if (r == cmax) {
99
99
+
d_11_ = (b - g) / (cmax - cmin);
100
100
+
} else if (b == cmax) {
101
101
+
d_11_ = 2.0 + (g - r) / (cmax - cmin);
102
102
+
} else if (g == cmax) {
103
103
+
d_11_ = 4.0 + (r - b) / (cmax - cmin);
104
104
+
}
105
105
+
}
106
106
+
d_11_ /= 6.0;
107
107
+
hue2 = (int) (d_11_ * 256.0);
108
108
+
saturation = (int) (d_12_ * 256.0);
109
109
+
lightness = (int) (d_13_ * 256.0);
110
110
+
if (saturation < 0) {
111
111
+
saturation = 0;
112
112
+
} else if (saturation > 255) {
113
113
+
saturation = 255;
114
114
+
}
115
115
+
if (lightness < 0) {
116
116
+
lightness = 0;
117
117
+
} else if (lightness > 255) {
118
118
+
lightness = 255;
119
119
+
}
120
120
+
if (d_13_ > 0.5) {
121
121
+
hueDivisor = (int) ((1.0 - d_13_) * d_12_ * 512.0);
122
122
+
} else {
123
123
+
hueDivisor = (int) (d_13_ * d_12_ * 512.0);
124
124
+
}
125
125
+
if (hueDivisor < 1) {
126
126
+
hueDivisor = 1;
127
127
+
}
128
128
+
hue = (int) (d_11_ * hueDivisor);
129
129
+
int huerand = hue2 + (int) (Math.random() * 16.0) - 8;
130
130
+
if (huerand < 0) {
131
131
+
huerand = 0;
132
132
+
} else if (huerand > 255) {
133
133
+
huerand = 255;
134
134
+
}
135
135
+
int satrand = saturation + (int) (Math.random() * 48.0) - 24;
136
136
+
if (satrand < 0) {
137
137
+
satrand = 0;
138
138
+
} else if (satrand > 255) {
139
139
+
satrand = 255;
140
140
+
}
141
141
+
int lightrand = lightness + (int) (Math.random() * 48.0) - 24;
142
142
+
if (lightrand < 0) {
143
143
+
lightrand = 0;
144
144
+
} else if (lightrand > 255) {
145
145
+
lightrand = 255;
146
146
+
}
147
147
+
hslColor2 = shiftHSLColors(huerand, satrand, lightrand);
148
148
+
}
149
149
+
150
150
+
private final int shiftHSLColors(int i, int i_17_, int i_18_) {
151
151
+
if (i_18_ > 179) {
152
152
+
i_17_ /= 2;
153
153
+
}
154
154
+
if (i_18_ > 192) {
155
155
+
i_17_ /= 2;
156
156
+
}
157
157
+
if (i_18_ > 217) {
158
158
+
i_17_ /= 2;
159
159
+
}
160
160
+
if (i_18_ > 243) {
161
161
+
i_17_ /= 2;
162
162
+
}
163
163
+
int i_19_ = (i / 4 << 10) + (i_17_ / 32 << 7) + i_18_ / 2;
164
164
+
return i_19_;
165
165
+
}
166
166
+
}
+486
src/com/jagex/runescape/cache/def/GameObjectDefinition.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache.def;
2
2
+
3
3
+
import com.jagex.runescape.Game;
4
4
+
import com.jagex.runescape.cache.Archive;
5
5
+
import com.jagex.runescape.cache.cfg.VarBit;
6
6
+
import com.jagex.runescape.collection.Cache;
7
7
+
import com.jagex.runescape.media.Animation;
8
8
+
import com.jagex.runescape.media.renderable.Model;
9
9
+
import com.jagex.runescape.net.Buffer;
10
10
+
import com.jagex.runescape.net.requester.OnDemandRequester;
11
11
+
12
12
+
public class GameObjectDefinition {
13
13
+
14
14
+
public boolean unknown;
15
15
+
private byte modelLightFalloff;
16
16
+
private int translateX;
17
17
+
public String name;
18
18
+
private int modelSizeZ;
19
19
+
private static Model[] models = new Model[4];
20
20
+
private byte modelLightAmbient;
21
21
+
public int sizeX;
22
22
+
private int translateY;
23
23
+
public int icon;
24
24
+
private int[] originalModelColors;
25
25
+
private int modelSizeX;
26
26
+
public int configId;
27
27
+
private boolean unknown3;
28
28
+
public static boolean lowMemory;
29
29
+
private static Buffer buffer;
30
30
+
public int id = -1;
31
31
+
private static int[] bufferOffsets;
32
32
+
private static int definitionCount;
33
33
+
public boolean walkable;
34
34
+
public int mapScene;
35
35
+
public int[] childrenIds;
36
36
+
public int solidInt;
37
37
+
public int sizeY;
38
38
+
public boolean adjustToTerrain;
39
39
+
public boolean aBoolean269;
40
40
+
public static Game client;
41
41
+
public boolean unwalkableSolid;
42
42
+
public boolean solid;
43
43
+
public int face;
44
44
+
private boolean nonFlatShading;
45
45
+
private static int cacheIndex;
46
46
+
private int modelSizeY;
47
47
+
private int[] modelIds;
48
48
+
public int varbitId;
49
49
+
public int unknown4;
50
50
+
private int[] modelTypes;
51
51
+
public byte[] description;
52
52
+
public boolean actionsBoolean;
53
53
+
public boolean unknown2;
54
54
+
public static Cache animatedModelCache = new Cache(30);
55
55
+
public int animationId;
56
56
+
private static GameObjectDefinition[] cache;
57
57
+
private int translateZ;
58
58
+
private int[] modifiedModelColors;
59
59
+
public static Cache modelCache = new Cache(500);
60
60
+
public String[] actions;
61
61
+
62
62
+
public static final GameObjectDefinition getDefinition(int id) {
63
63
+
for (int index = 0; index < 20; index++) {
64
64
+
if (GameObjectDefinition.cache[index].id == id) {
65
65
+
return GameObjectDefinition.cache[index];
66
66
+
}
67
67
+
}
68
68
+
GameObjectDefinition.cacheIndex = (GameObjectDefinition.cacheIndex + 1) % 20;
69
69
+
GameObjectDefinition definition = GameObjectDefinition.cache[GameObjectDefinition.cacheIndex];
70
70
+
GameObjectDefinition.buffer.offset = GameObjectDefinition.bufferOffsets[id];
71
71
+
definition.id = id;
72
72
+
definition.setDefaultValues();
73
73
+
definition.load(GameObjectDefinition.buffer);
74
74
+
return definition;
75
75
+
}
76
76
+
77
77
+
private final void setDefaultValues() {
78
78
+
modelIds = null;
79
79
+
modelTypes = null;
80
80
+
name = null;
81
81
+
description = null;
82
82
+
modifiedModelColors = null;
83
83
+
originalModelColors = null;
84
84
+
sizeX = 1;
85
85
+
sizeY = 1;
86
86
+
solid = true;
87
87
+
walkable = true;
88
88
+
actionsBoolean = false;
89
89
+
adjustToTerrain = false;
90
90
+
nonFlatShading = false;
91
91
+
aBoolean269 = false;
92
92
+
animationId = -1;
93
93
+
unknown4 = 16;
94
94
+
modelLightFalloff = (byte) 0;
95
95
+
modelLightAmbient = (byte) 0;
96
96
+
actions = null;
97
97
+
icon = -1;
98
98
+
mapScene = -1;
99
99
+
unknown3 = false;
100
100
+
unknown2 = true;
101
101
+
modelSizeX = 128;
102
102
+
modelSizeY = 128;
103
103
+
modelSizeZ = 128;
104
104
+
face = 0;
105
105
+
translateX = 0;
106
106
+
translateY = 0;
107
107
+
translateZ = 0;
108
108
+
unknown = false;
109
109
+
unwalkableSolid = false;
110
110
+
solidInt = -1;
111
111
+
varbitId = -1;
112
112
+
configId = -1;
113
113
+
childrenIds = null;
114
114
+
}
115
115
+
116
116
+
public final void passiveRequestModels(OnDemandRequester onDemandRequester) {
117
117
+
if (modelIds != null) {
118
118
+
for (int modelId : modelIds) {
119
119
+
onDemandRequester.passiveRequest(modelId & 0xffff, 0);
120
120
+
}
121
121
+
}
122
122
+
}
123
123
+
124
124
+
public static final void reset() {
125
125
+
GameObjectDefinition.modelCache = null;
126
126
+
GameObjectDefinition.animatedModelCache = null;
127
127
+
GameObjectDefinition.bufferOffsets = null;
128
128
+
GameObjectDefinition.cache = null;
129
129
+
GameObjectDefinition.buffer = null;
130
130
+
}
131
131
+
132
132
+
public static final void load(Archive archive) {
133
133
+
GameObjectDefinition.buffer = new Buffer(archive.getFile("loc.dat"));
134
134
+
Buffer buffer = new Buffer(archive.getFile("loc.idx"));
135
135
+
GameObjectDefinition.definitionCount = buffer.getUnsignedLEShort();
136
136
+
GameObjectDefinition.bufferOffsets = new int[GameObjectDefinition.definitionCount];
137
137
+
int offset = 2;
138
138
+
for (int index = 0; index < GameObjectDefinition.definitionCount; index++) {
139
139
+
GameObjectDefinition.bufferOffsets[index] = offset;
140
140
+
offset += buffer.getUnsignedLEShort();
141
141
+
}
142
142
+
GameObjectDefinition.cache = new GameObjectDefinition[20];
143
143
+
for (int definition = 0; definition < 20; definition++) {
144
144
+
GameObjectDefinition.cache[definition] = new GameObjectDefinition();
145
145
+
}
146
146
+
}
147
147
+
148
148
+
public final boolean hasModelType(int modelType) {
149
149
+
if (modelTypes == null) {
150
150
+
if (modelIds == null) {
151
151
+
return true;
152
152
+
}
153
153
+
if (modelType != 10) {
154
154
+
return true;
155
155
+
}
156
156
+
boolean cached = true;
157
157
+
for (int modelId : modelIds) {
158
158
+
cached &= Model.isCached(modelId & 0xffff);
159
159
+
}
160
160
+
return cached;
161
161
+
}
162
162
+
for (int model = 0; model < modelTypes.length; model++) {
163
163
+
if (modelTypes[model] == modelType) {
164
164
+
return Model.isCached(modelIds[model] & 0xffff);
165
165
+
}
166
166
+
}
167
167
+
return true;
168
168
+
}
169
169
+
170
170
+
public final Model getGameObjectModel(int type, int face, int i_8_, int i_9_, int i_10_, int i_11_, int animationId) {
171
171
+
Model model = getGameObjectAnimatedModel(type, animationId, face);
172
172
+
if (model == null) {
173
173
+
return null;
174
174
+
}
175
175
+
if (adjustToTerrain || nonFlatShading) {
176
176
+
model = new Model(adjustToTerrain, -819, nonFlatShading, model);
177
177
+
}
178
178
+
if (adjustToTerrain) {
179
179
+
int i_13_ = (i_8_ + i_9_ + i_10_ + i_11_) / 4;
180
180
+
for (int vertex = 0; vertex < model.vertexCount; vertex++) {
181
181
+
int vertexX = model.verticesX[vertex];
182
182
+
int vertexY = model.verticesZ[vertex];
183
183
+
int i_17_ = i_8_ + (i_9_ - i_8_) * (vertexX + 64) / 128;
184
184
+
int i_18_ = i_11_ + (i_10_ - i_11_) * (vertexX + 64) / 128;
185
185
+
int i_19_ = i_17_ + (i_18_ - i_17_) * (vertexY + 64) / 128;
186
186
+
model.verticesY[vertex] += i_19_ - i_13_;
187
187
+
}
188
188
+
model.normalise(false);
189
189
+
}
190
190
+
return model;
191
191
+
}
192
192
+
193
193
+
public final boolean isModelCached() {
194
194
+
if (modelIds == null) {
195
195
+
return true;
196
196
+
}
197
197
+
boolean cached = true;
198
198
+
for (int modelId : modelIds) {
199
199
+
cached &= Model.isCached(modelId & 0xffff);
200
200
+
}
201
201
+
return cached;
202
202
+
}
203
203
+
204
204
+
public final GameObjectDefinition getChildDefinition() {
205
205
+
int child = -1;
206
206
+
if (varbitId != -1) {
207
207
+
VarBit varbit = VarBit.cache[varbitId];
208
208
+
int configId = varbit.configId;
209
209
+
int leastSignificantBit = varbit.leastSignificantBit;
210
210
+
int mostSignificantBit = varbit.mostSignificantBit;
211
211
+
int bit = Game.BITFIELD_MAX_VALUE[mostSignificantBit - leastSignificantBit];
212
212
+
child = GameObjectDefinition.client.widgetSettings[configId] >> leastSignificantBit & bit;
213
213
+
} else if (configId != -1) {
214
214
+
child = GameObjectDefinition.client.widgetSettings[configId];
215
215
+
}
216
216
+
if (child < 0 || child >= childrenIds.length || childrenIds[child] == -1) {
217
217
+
return null;
218
218
+
}
219
219
+
return GameObjectDefinition.getDefinition(childrenIds[child]);
220
220
+
}
221
221
+
222
222
+
private final Model getGameObjectAnimatedModel(int type, int animationId, int face) {
223
223
+
Model subModel = null;
224
224
+
long hash;
225
225
+
if (modelTypes == null) {
226
226
+
if (type != 10) {
227
227
+
return null;
228
228
+
}
229
229
+
hash = (id << 6) + face + ((long) (animationId + 1) << 32);
230
230
+
Model cachedModel = (Model) GameObjectDefinition.animatedModelCache.get(hash);
231
231
+
if (cachedModel != null) {
232
232
+
return cachedModel;
233
233
+
}
234
234
+
if (modelIds == null) {
235
235
+
return null;
236
236
+
}
237
237
+
boolean mirror = unknown3 ^ face > 3;
238
238
+
int modelCount = modelIds.length;
239
239
+
for (int modelId = 0; modelId < modelCount; modelId++) {
240
240
+
int subModelId = modelIds[modelId];
241
241
+
if (mirror) {
242
242
+
subModelId += 65536;
243
243
+
}
244
244
+
subModel = (Model) GameObjectDefinition.modelCache.get(subModelId);
245
245
+
if (subModel == null) {
246
246
+
subModel = Model.getModel(subModelId & 0xffff);
247
247
+
if (subModel == null) {
248
248
+
return null;
249
249
+
}
250
250
+
if (mirror) {
251
251
+
subModel.mirror(0);
252
252
+
}
253
253
+
GameObjectDefinition.modelCache.put(subModel, subModelId);
254
254
+
}
255
255
+
if (modelCount > 1) {
256
256
+
GameObjectDefinition.models[modelId] = subModel;
257
257
+
}
258
258
+
}
259
259
+
if (modelCount > 1) {
260
260
+
subModel = new Model(modelCount, GameObjectDefinition.models);
261
261
+
}
262
262
+
} else {
263
263
+
int modelType = -1;
264
264
+
for (int index = 0; index < modelTypes.length; index++) {
265
265
+
if (modelTypes[index] == type) {
266
266
+
modelType = index;
267
267
+
break;
268
268
+
}
269
269
+
}
270
270
+
if (modelType == -1) {
271
271
+
return null;
272
272
+
}
273
273
+
hash = (id << 6) + (modelType << 3) + face + ((long) (animationId + 1) << 32);
274
274
+
Model model = (Model) GameObjectDefinition.animatedModelCache.get(hash);
275
275
+
if (model != null) {
276
276
+
return model;
277
277
+
}
278
278
+
int modelId = modelIds[modelType];
279
279
+
boolean mirror = unknown3 ^ face > 3;
280
280
+
if (mirror) {
281
281
+
modelId += 65536;
282
282
+
}
283
283
+
subModel = (Model) GameObjectDefinition.modelCache.get(modelId);
284
284
+
if (subModel == null) {
285
285
+
subModel = Model.getModel(modelId & 0xffff);
286
286
+
if (subModel == null) {
287
287
+
return null;
288
288
+
}
289
289
+
if (mirror) {
290
290
+
subModel.mirror(0);
291
291
+
}
292
292
+
GameObjectDefinition.modelCache.put(subModel, modelId);
293
293
+
}
294
294
+
}
295
295
+
boolean scale;
296
296
+
if (modelSizeX != 128 || modelSizeY != 128 || modelSizeZ != 128) {
297
297
+
scale = true;
298
298
+
} else {
299
299
+
scale = false;
300
300
+
}
301
301
+
boolean needsTranslation;
302
302
+
if (translateX != 0 || translateY != 0 || translateZ != 0) {
303
303
+
needsTranslation = true;
304
304
+
} else {
305
305
+
needsTranslation = false;
306
306
+
}
307
307
+
Model animtedModel = new Model(modifiedModelColors == null, Animation.exists(animationId), face == 0
308
308
+
&& animationId == -1 && !scale && !needsTranslation, subModel);
309
309
+
if (animationId != -1) {
310
310
+
animtedModel.createBones();
311
311
+
animtedModel.applyTransform(animationId);
312
312
+
animtedModel.triangleSkin = null;
313
313
+
animtedModel.vectorSkin = null;
314
314
+
}
315
315
+
while (face-- > 0) {
316
316
+
animtedModel.rotate90Degrees(360);
317
317
+
}
318
318
+
if (modifiedModelColors != null) {
319
319
+
for (int i_38_ = 0; i_38_ < modifiedModelColors.length; i_38_++) {
320
320
+
animtedModel.recolor(modifiedModelColors[i_38_], originalModelColors[i_38_]);
321
321
+
}
322
322
+
}
323
323
+
if (scale) {
324
324
+
animtedModel.scaleT(modelSizeX, modelSizeZ, modelSizeY);
325
325
+
}
326
326
+
if (needsTranslation) {
327
327
+
animtedModel.translate(translateX, translateY, translateZ);
328
328
+
}
329
329
+
animtedModel.applyLighting(64 + modelLightFalloff, 768 + modelLightAmbient * 5, -50, -10, -50, !nonFlatShading);
330
330
+
if (solidInt == 1) {
331
331
+
animtedModel.anInt1647 = animtedModel.modelHeight;
332
332
+
}
333
333
+
GameObjectDefinition.animatedModelCache.put(animtedModel, hash);
334
334
+
return animtedModel;
335
335
+
}
336
336
+
337
337
+
private final void load(Buffer buffer) {
338
338
+
int hasActionsInt = -1;
339
339
+
while (true) {
340
340
+
int attributeId = buffer.getUnsignedByte();
341
341
+
if (attributeId == 0) {
342
342
+
break;
343
343
+
}
344
344
+
if (attributeId == 1) {
345
345
+
int modelCount = buffer.getUnsignedByte();
346
346
+
if (modelCount > 0) {
347
347
+
if (modelIds == null || GameObjectDefinition.lowMemory) {
348
348
+
modelTypes = new int[modelCount];
349
349
+
modelIds = new int[modelCount];
350
350
+
for (int model = 0; model < modelCount; model++) {
351
351
+
modelIds[model] = buffer.getUnsignedLEShort();
352
352
+
modelTypes[model] = buffer.getUnsignedByte();
353
353
+
}
354
354
+
} else {
355
355
+
buffer.offset += modelCount * 3;
356
356
+
}
357
357
+
}
358
358
+
} else if (attributeId == 2) {
359
359
+
name = buffer.getString();
360
360
+
} else if (attributeId == 3) {
361
361
+
description = buffer.getStringAsBytes();
362
362
+
} else if (attributeId == 5) {
363
363
+
int modelCount = buffer.getUnsignedByte();
364
364
+
if (modelCount > 0) {
365
365
+
if (modelIds == null || GameObjectDefinition.lowMemory) {
366
366
+
modelTypes = null;
367
367
+
modelIds = new int[modelCount];
368
368
+
for (int model = 0; model < modelCount; model++) {
369
369
+
modelIds[model] = buffer.getUnsignedLEShort();
370
370
+
}
371
371
+
} else {
372
372
+
buffer.offset += modelCount * 2;
373
373
+
}
374
374
+
}
375
375
+
} else if (attributeId == 14) {
376
376
+
sizeX = buffer.getUnsignedByte();
377
377
+
} else if (attributeId == 15) {
378
378
+
sizeY = buffer.getUnsignedByte();
379
379
+
} else if (attributeId == 17) {
380
380
+
solid = false;
381
381
+
} else if (attributeId == 18) {
382
382
+
walkable = false;
383
383
+
} else if (attributeId == 19) {
384
384
+
hasActionsInt = buffer.getUnsignedByte();
385
385
+
if (hasActionsInt == 1) {
386
386
+
actionsBoolean = true;
387
387
+
}
388
388
+
} else if (attributeId == 21) {
389
389
+
adjustToTerrain = true;
390
390
+
} else if (attributeId == 22) {
391
391
+
nonFlatShading = true;
392
392
+
} else if (attributeId == 23) {
393
393
+
aBoolean269 = true;
394
394
+
} else if (attributeId == 24) {
395
395
+
animationId = buffer.getUnsignedLEShort();
396
396
+
if (animationId == 65535) {
397
397
+
animationId = -1;
398
398
+
}
399
399
+
} else if (attributeId == 28) {
400
400
+
unknown4 = buffer.getUnsignedByte();
401
401
+
} else if (attributeId == 29) {
402
402
+
modelLightFalloff = buffer.get();
403
403
+
} else if (attributeId == 39) {
404
404
+
modelLightAmbient = buffer.get();
405
405
+
} else if (attributeId >= 30 && attributeId < 39) {
406
406
+
if (actions == null) {
407
407
+
actions = new String[5];
408
408
+
}
409
409
+
actions[attributeId - 30] = buffer.getString();
410
410
+
if (actions[attributeId - 30].equalsIgnoreCase("hidden")) {
411
411
+
actions[attributeId - 30] = null;
412
412
+
}
413
413
+
} else if (attributeId == 40) {
414
414
+
int modelColorCount = buffer.getUnsignedByte();
415
415
+
modifiedModelColors = new int[modelColorCount];
416
416
+
originalModelColors = new int[modelColorCount];
417
417
+
for (int modelColor = 0; modelColor < modelColorCount; modelColor++) {
418
418
+
modifiedModelColors[modelColor] = buffer.getUnsignedLEShort();
419
419
+
originalModelColors[modelColor] = buffer.getUnsignedLEShort();
420
420
+
}
421
421
+
} else if (attributeId == 60) {
422
422
+
icon = buffer.getUnsignedLEShort();
423
423
+
} else if (attributeId == 62) {
424
424
+
unknown3 = true;
425
425
+
} else if (attributeId == 64) {
426
426
+
unknown2 = false;
427
427
+
} else if (attributeId == 65) {
428
428
+
modelSizeX = buffer.getUnsignedLEShort();
429
429
+
} else if (attributeId == 66) {
430
430
+
modelSizeY = buffer.getUnsignedLEShort();
431
431
+
} else if (attributeId == 67) {
432
432
+
modelSizeZ = buffer.getUnsignedLEShort();
433
433
+
} else if (attributeId == 68) {
434
434
+
mapScene = buffer.getUnsignedLEShort();
435
435
+
} else if (attributeId == 69) {
436
436
+
face = buffer.getUnsignedByte();
437
437
+
} else if (attributeId == 70) {
438
438
+
translateX = buffer.getShort();
439
439
+
} else if (attributeId == 71) {
440
440
+
translateY = buffer.getShort();
441
441
+
} else if (attributeId == 72) {
442
442
+
translateZ = buffer.getShort();
443
443
+
} else if (attributeId == 73) {
444
444
+
unknown = true;
445
445
+
} else if (attributeId == 74) {
446
446
+
unwalkableSolid = true;
447
447
+
} else if (attributeId == 75) {
448
448
+
solidInt = buffer.getUnsignedByte();
449
449
+
} else if (attributeId == 77) {
450
450
+
varbitId = buffer.getUnsignedLEShort();
451
451
+
if (varbitId == 65535) {
452
452
+
varbitId = -1;
453
453
+
}
454
454
+
configId = buffer.getUnsignedLEShort();
455
455
+
if (configId == 65535) {
456
456
+
configId = -1;
457
457
+
}
458
458
+
int childrenCount = buffer.getUnsignedByte();
459
459
+
childrenIds = new int[childrenCount + 1];
460
460
+
for (int child = 0; child <= childrenCount; child++) {
461
461
+
childrenIds[child] = buffer.getUnsignedLEShort();
462
462
+
if (childrenIds[child] == 65535) {
463
463
+
childrenIds[child] = -1;
464
464
+
}
465
465
+
}
466
466
+
}
467
467
+
}
468
468
+
if (hasActionsInt == -1) {
469
469
+
actionsBoolean = false;
470
470
+
if (modelIds != null && (modelTypes == null || modelTypes[0] == 10)) {
471
471
+
actionsBoolean = true;
472
472
+
}
473
473
+
if (actions != null) {
474
474
+
actionsBoolean = true;
475
475
+
}
476
476
+
}
477
477
+
if (unwalkableSolid) {
478
478
+
solid = false;
479
479
+
walkable = false;
480
480
+
}
481
481
+
if (solidInt != -1) {
482
482
+
return;
483
483
+
}
484
484
+
solidInt = solid ? 1 : 0;
485
485
+
}
486
486
+
}
+572
src/com/jagex/runescape/cache/def/ItemDefinition.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache.def;
2
2
+
3
3
+
import com.jagex.runescape.cache.Archive;
4
4
+
import com.jagex.runescape.cache.media.ImageRGB;
5
5
+
import com.jagex.runescape.collection.Cache;
6
6
+
import com.jagex.runescape.media.Rasterizer;
7
7
+
import com.jagex.runescape.media.Rasterizer3D;
8
8
+
import com.jagex.runescape.media.renderable.Model;
9
9
+
import com.jagex.runescape.net.Buffer;
10
10
+
11
11
+
public class ItemDefinition {
12
12
+
13
13
+
private byte femaleEquipOffset;
14
14
+
public int value;
15
15
+
private int[] originalModelColors;
16
16
+
public int id = -1;
17
17
+
public static Cache rgbImageCache = new Cache(100);
18
18
+
public static Cache modelCache = new Cache(50);
19
19
+
private int[] modifiedModelColors;
20
20
+
public boolean membersOnly;
21
21
+
public int femaleEmblem;
22
22
+
public int noteTemplateIndex;
23
23
+
private int femaleEquipSecondaryModel;
24
24
+
private int maleEquipPrimaryModel;
25
25
+
public int maleDialogueHat;
26
26
+
private int modelSizeX;
27
27
+
public String[] groundActions;
28
28
+
private int modelOffset1;
29
29
+
public String name;
30
30
+
private static ItemDefinition[] cache;
31
31
+
public int femaleDialogueHat;
32
32
+
private int modelIndex;
33
33
+
private int maleDialogue;
34
34
+
public boolean stackable;
35
35
+
public byte[] description;
36
36
+
public int noteIndex;
37
37
+
private static int cacheIndex;
38
38
+
public int modelZoom;
39
39
+
public static boolean playerIsMember = true;
40
40
+
private static Buffer buffer;
41
41
+
private int shadowModifier;
42
42
+
public int maleEmblem;
43
43
+
private int maleEquipSecondaryModel;
44
44
+
public String[] inventoryActions;
45
45
+
public int modelRotation1;
46
46
+
private int modelSizeZ;
47
47
+
private int modelSizeY;
48
48
+
public int[] stackableIds;
49
49
+
private int sine;
50
50
+
private static int[] bufferOffsets;
51
51
+
private int lightModifier;
52
52
+
public int femaleDialogue;
53
53
+
public int modelRotation2;
54
54
+
private int femaleEquipPrimaryModel;
55
55
+
public int[] stackableAmounts;
56
56
+
public int teamId;
57
57
+
public static int itemCount;
58
58
+
private int diagonalRotation;
59
59
+
private byte maleEquipOffset;
60
60
+
61
61
+
public static final void reset() {
62
62
+
ItemDefinition.modelCache = null;
63
63
+
ItemDefinition.rgbImageCache = null;
64
64
+
ItemDefinition.bufferOffsets = null;
65
65
+
ItemDefinition.cache = null;
66
66
+
ItemDefinition.buffer = null;
67
67
+
}
68
68
+
69
69
+
public final boolean isDialogueCached(int gender) {
70
70
+
int modelIndex = gender == 1 ? femaleDialogue : maleDialogue;
71
71
+
int hatModelIndex = gender == 1 ? femaleDialogueHat : maleDialogueHat;
72
72
+
if (modelIndex == -1) {
73
73
+
return true;
74
74
+
}
75
75
+
boolean isCached = true;
76
76
+
if (!Model.isCached(modelIndex)) {
77
77
+
isCached = false;
78
78
+
}
79
79
+
if (hatModelIndex != -1 && !Model.isCached(hatModelIndex)) {
80
80
+
isCached = false;
81
81
+
}
82
82
+
return isCached;
83
83
+
}
84
84
+
85
85
+
public static final void load(Archive archive) {
86
86
+
ItemDefinition.buffer = new Buffer(archive.getFile("obj.dat"));
87
87
+
Buffer buffer = new Buffer(archive.getFile("obj.idx"));
88
88
+
ItemDefinition.itemCount = buffer.getUnsignedLEShort();
89
89
+
ItemDefinition.bufferOffsets = new int[ItemDefinition.itemCount];
90
90
+
int offset = 2;
91
91
+
for (int item = 0; item < ItemDefinition.itemCount; item++) {
92
92
+
ItemDefinition.bufferOffsets[item] = offset;
93
93
+
offset += buffer.getUnsignedLEShort();
94
94
+
}
95
95
+
ItemDefinition.cache = new ItemDefinition[10];
96
96
+
for (int itemDefinition = 0; itemDefinition < 10; itemDefinition++) {
97
97
+
ItemDefinition.cache[itemDefinition] = new ItemDefinition();
98
98
+
}
99
99
+
}
100
100
+
101
101
+
public final Model getDialogueModel(int gender) {
102
102
+
int modelIndex = gender == 1 ? femaleDialogue : maleDialogue;
103
103
+
int hatModelIndex = gender == 1 ? femaleDialogueHat : maleDialogueHat;
104
104
+
if (modelIndex == -1) {
105
105
+
return null;
106
106
+
}
107
107
+
Model model = Model.getModel(modelIndex);
108
108
+
if (hatModelIndex != -1) {
109
109
+
Model hatModel = Model.getModel(hatModelIndex);
110
110
+
Model[] models = { model, hatModel };
111
111
+
model = new Model(2, models);
112
112
+
}
113
113
+
if (originalModelColors != null) {
114
114
+
model.recolor(originalModelColors, modifiedModelColors);
115
115
+
}
116
116
+
return model;
117
117
+
}
118
118
+
119
119
+
public final boolean isEquipModelCached(int gender) {
120
120
+
int equipPrimaryModel = maleEquipPrimaryModel;
121
121
+
int equipSecondaryModel = maleEquipSecondaryModel;
122
122
+
int emblem = maleEmblem;
123
123
+
if (gender == 1) {
124
124
+
equipPrimaryModel = femaleEquipPrimaryModel;
125
125
+
equipSecondaryModel = femaleEquipSecondaryModel;
126
126
+
emblem = femaleEmblem;
127
127
+
}
128
128
+
if (equipPrimaryModel == -1) {
129
129
+
return true;
130
130
+
}
131
131
+
boolean isCached = true;
132
132
+
if (!Model.isCached(equipPrimaryModel)) {
133
133
+
isCached = false;
134
134
+
}
135
135
+
if (equipSecondaryModel != -1 && !Model.isCached(equipSecondaryModel)) {
136
136
+
isCached = false;
137
137
+
}
138
138
+
if (emblem != -1 && !Model.isCached(emblem)) {
139
139
+
isCached = false;
140
140
+
}
141
141
+
return isCached;
142
142
+
}
143
143
+
144
144
+
public final Model getEquipModel(int gender) {
145
145
+
int equipPrimaryModel = maleEquipPrimaryModel;
146
146
+
int equipSecondaryModel = maleEquipSecondaryModel;
147
147
+
int emblem = maleEmblem;
148
148
+
if (gender == 1) {
149
149
+
equipPrimaryModel = femaleEquipPrimaryModel;
150
150
+
equipSecondaryModel = femaleEquipSecondaryModel;
151
151
+
emblem = femaleEmblem;
152
152
+
}
153
153
+
if (equipPrimaryModel == -1) {
154
154
+
return null;
155
155
+
}
156
156
+
Model modelEquip1 = Model.getModel(equipPrimaryModel);
157
157
+
if (equipSecondaryModel != -1) {
158
158
+
if (emblem != -1) {
159
159
+
Model modelEquip2 = Model.getModel(equipSecondaryModel);
160
160
+
Model modelEmblem = Model.getModel(emblem);
161
161
+
Model[] equipModelsWithEmblem = { modelEquip1, modelEquip2, modelEmblem };
162
162
+
modelEquip1 = new Model(3, equipModelsWithEmblem);
163
163
+
} else {
164
164
+
Model modelEquip2 = Model.getModel(equipSecondaryModel);
165
165
+
Model[] equipModelsWithoutEmblem = { modelEquip1, modelEquip2 };
166
166
+
modelEquip1 = new Model(2, equipModelsWithoutEmblem);
167
167
+
}
168
168
+
}
169
169
+
if (gender == 0 && maleEquipOffset != 0) {
170
170
+
modelEquip1.translate(0, maleEquipOffset, 0);
171
171
+
}
172
172
+
if (gender == 1 && femaleEquipOffset != 0) {
173
173
+
modelEquip1.translate(0, femaleEquipOffset, 0);
174
174
+
}
175
175
+
if (originalModelColors != null) {
176
176
+
for (int color = 0; color < originalModelColors.length; color++) {
177
177
+
modelEquip1.recolor(originalModelColors[color], modifiedModelColors[color]);
178
178
+
}
179
179
+
}
180
180
+
return modelEquip1;
181
181
+
}
182
182
+
183
183
+
public final void setDefaultValues() {
184
184
+
modelIndex = 0;
185
185
+
name = null;
186
186
+
description = null;
187
187
+
originalModelColors = null;
188
188
+
modifiedModelColors = null;
189
189
+
modelZoom = 2000;
190
190
+
modelRotation1 = 0;
191
191
+
modelRotation2 = 0;
192
192
+
diagonalRotation = 0;
193
193
+
modelOffset1 = 0;
194
194
+
sine = 0;
195
195
+
stackable = false;
196
196
+
value = 1;
197
197
+
membersOnly = false;
198
198
+
groundActions = null;
199
199
+
inventoryActions = null;
200
200
+
maleEquipPrimaryModel = -1;
201
201
+
maleEquipSecondaryModel = -1;
202
202
+
maleEquipOffset = (byte) 0;
203
203
+
femaleEquipPrimaryModel = -1;
204
204
+
femaleEquipSecondaryModel = -1;
205
205
+
femaleEquipOffset = (byte) 0;
206
206
+
maleEmblem = -1;
207
207
+
femaleEmblem = -1;
208
208
+
maleDialogue = -1;
209
209
+
maleDialogueHat = -1;
210
210
+
femaleDialogue = -1;
211
211
+
femaleDialogueHat = -1;
212
212
+
stackableIds = null;
213
213
+
stackableAmounts = null;
214
214
+
noteIndex = -1;
215
215
+
noteTemplateIndex = -1;
216
216
+
modelSizeX = 128;
217
217
+
modelSizeY = 128;
218
218
+
modelSizeZ = 128;
219
219
+
lightModifier = 0;
220
220
+
shadowModifier = 0;
221
221
+
teamId = 0;
222
222
+
}
223
223
+
224
224
+
public static final ItemDefinition getDefinition(int itemId) {
225
225
+
for (int i = 0; i < 10; i++) {
226
226
+
if (ItemDefinition.cache[i].id == itemId) {
227
227
+
return ItemDefinition.cache[i];
228
228
+
}
229
229
+
}
230
230
+
ItemDefinition.cacheIndex = (ItemDefinition.cacheIndex + 1) % 10;
231
231
+
ItemDefinition itemDefinition = ItemDefinition.cache[ItemDefinition.cacheIndex];
232
232
+
ItemDefinition.buffer.offset = ItemDefinition.bufferOffsets[itemId];
233
233
+
itemDefinition.id = itemId;
234
234
+
itemDefinition.setDefaultValues();
235
235
+
itemDefinition.loadDefinition(ItemDefinition.buffer);
236
236
+
if (itemDefinition.noteTemplateIndex != -1) {
237
237
+
itemDefinition.toNote();
238
238
+
}
239
239
+
if (!ItemDefinition.playerIsMember && itemDefinition.membersOnly) {
240
240
+
itemDefinition.name = "Members Object";
241
241
+
itemDefinition.description = "Login to a members' server to use this object.".getBytes();
242
242
+
itemDefinition.groundActions = null;
243
243
+
itemDefinition.inventoryActions = null;
244
244
+
itemDefinition.teamId = 0;
245
245
+
}
246
246
+
return itemDefinition;
247
247
+
}
248
248
+
249
249
+
public void toNote() {
250
250
+
ItemDefinition noteTemplateDefinition = ItemDefinition.getDefinition(noteTemplateIndex);
251
251
+
modelIndex = noteTemplateDefinition.modelIndex;
252
252
+
modelZoom = noteTemplateDefinition.modelZoom;
253
253
+
modelRotation1 = noteTemplateDefinition.modelRotation1;
254
254
+
modelRotation2 = noteTemplateDefinition.modelRotation2;
255
255
+
diagonalRotation = noteTemplateDefinition.diagonalRotation;
256
256
+
modelOffset1 = noteTemplateDefinition.modelOffset1;
257
257
+
sine = noteTemplateDefinition.sine;
258
258
+
originalModelColors = noteTemplateDefinition.originalModelColors;
259
259
+
modifiedModelColors = noteTemplateDefinition.modifiedModelColors;
260
260
+
ItemDefinition noteDefinition = ItemDefinition.getDefinition(noteIndex);
261
261
+
name = noteDefinition.name;
262
262
+
membersOnly = noteDefinition.membersOnly;
263
263
+
value = noteDefinition.value;
264
264
+
String artical = "a";
265
265
+
char firstCharacter = noteDefinition.name.charAt(0);
266
266
+
if (firstCharacter == 'A' || firstCharacter == 'E' || firstCharacter == 'I' || firstCharacter == 'O'
267
267
+
|| firstCharacter == 'U') {
268
268
+
artical = "an";
269
269
+
}
270
270
+
description = ("Swap this note at any bank for " + artical + " " + noteDefinition.name + ".").getBytes();
271
271
+
stackable = true;
272
272
+
}
273
273
+
274
274
+
public static final ImageRGB getSprite(int itemId, int itemAmount, int type) {
275
275
+
if (type == 0) {
276
276
+
ImageRGB cachedSprite = (ImageRGB) ItemDefinition.rgbImageCache.get(itemId);
277
277
+
if (cachedSprite != null && cachedSprite.maxHeight != itemAmount && cachedSprite.maxHeight != -1) {
278
278
+
cachedSprite.remove();
279
279
+
cachedSprite = null;
280
280
+
}
281
281
+
if (cachedSprite != null) {
282
282
+
return cachedSprite;
283
283
+
}
284
284
+
}
285
285
+
ItemDefinition itemDefinition = ItemDefinition.getDefinition(itemId);
286
286
+
if (itemDefinition.stackableIds == null) {
287
287
+
itemAmount = -1;
288
288
+
}
289
289
+
if (itemAmount > 1) {
290
290
+
int stackedId = -1;
291
291
+
for (int amount = 0; amount < 10; amount++) {
292
292
+
if (itemAmount >= itemDefinition.stackableAmounts[amount]
293
293
+
&& itemDefinition.stackableAmounts[amount] != 0) {
294
294
+
stackedId = itemDefinition.stackableIds[amount];
295
295
+
}
296
296
+
}
297
297
+
if (stackedId != -1) {
298
298
+
itemDefinition = ItemDefinition.getDefinition(stackedId);
299
299
+
}
300
300
+
}
301
301
+
Model model = itemDefinition.getAmountModel(1);
302
302
+
if (model == null) {
303
303
+
return null;
304
304
+
}
305
305
+
ImageRGB noteSprite = null;
306
306
+
if (itemDefinition.noteTemplateIndex != -1) {
307
307
+
noteSprite = ItemDefinition.getSprite(itemDefinition.noteIndex, 10, -1);
308
308
+
if (noteSprite == null) {
309
309
+
return null;
310
310
+
}
311
311
+
}
312
312
+
ImageRGB itemSprite = new ImageRGB(32, 32);
313
313
+
int rasterizerCenterX = Rasterizer3D.centerX;
314
314
+
int rasterizerCenterY = Rasterizer3D.centerY;
315
315
+
int[] rasterizerLineOffsets = Rasterizer3D.lineOffsets;
316
316
+
int[] rasterizerPixels = Rasterizer.pixels;
317
317
+
int rasterizerWidth = Rasterizer.width;
318
318
+
int rasterizerHeight = Rasterizer.height;
319
319
+
int rasterizerTopX = Rasterizer.topX;
320
320
+
int rasterizerBottomX = Rasterizer.bottomX;
321
321
+
int rasterizerTopY = Rasterizer.topY;
322
322
+
int rasterizerBottomY = Rasterizer.bottomY;
323
323
+
Rasterizer3D.textured = false;
324
324
+
Rasterizer.createRasterizer(itemSprite.pixels, 32, 32);
325
325
+
Rasterizer.drawFilledRectangle(0, 0, 32, 32, 0);
326
326
+
Rasterizer3D.setDefaultBoundaries();
327
327
+
int modelZoom = itemDefinition.modelZoom;
328
328
+
if (type == -1) {
329
329
+
modelZoom *= 1.5;
330
330
+
}
331
331
+
if (type > 0) {
332
332
+
modelZoom *= 1.04;
333
333
+
}
334
334
+
int sine = Rasterizer3D.SINE[itemDefinition.modelRotation1] * modelZoom >> 16;
335
335
+
int cosine = Rasterizer3D.COSINE[itemDefinition.modelRotation1] * modelZoom >> 16;
336
336
+
model.method430(0, itemDefinition.modelRotation2, itemDefinition.diagonalRotation,
337
337
+
itemDefinition.modelRotation1, itemDefinition.modelOffset1, sine + model.modelHeight / 2
338
338
+
+ itemDefinition.sine, cosine + itemDefinition.sine);
339
339
+
for (int pixel = 31; pixel >= 0; pixel--) {
340
340
+
for (cosine = 31; cosine >= 0; cosine--) {
341
341
+
if (itemSprite.pixels[pixel + cosine * 32] == 0) {
342
342
+
if (pixel > 0 && itemSprite.pixels[pixel - 1 + cosine * 32] > 1) {
343
343
+
itemSprite.pixels[pixel + cosine * 32] = 1;
344
344
+
} else if (cosine > 0 && itemSprite.pixels[pixel + (cosine - 1) * 32] > 1) {
345
345
+
itemSprite.pixels[pixel + cosine * 32] = 1;
346
346
+
} else if (pixel < 31 && itemSprite.pixels[pixel + 1 + cosine * 32] > 1) {
347
347
+
itemSprite.pixels[pixel + cosine * 32] = 1;
348
348
+
} else if (cosine < 31 && itemSprite.pixels[pixel + (cosine + 1) * 32] > 1) {
349
349
+
itemSprite.pixels[pixel + cosine * 32] = 1;
350
350
+
}
351
351
+
}
352
352
+
}
353
353
+
}
354
354
+
if (type > 0) {
355
355
+
for (int pixel = 31; pixel >= 0; pixel--) {
356
356
+
for (cosine = 31; cosine >= 0; cosine--) {
357
357
+
if (itemSprite.pixels[pixel + cosine * 32] == 0) {
358
358
+
if (pixel > 0 && itemSprite.pixels[pixel - 1 + cosine * 32] == 1) {
359
359
+
itemSprite.pixels[pixel + cosine * 32] = type;
360
360
+
} else if (cosine > 0 && itemSprite.pixels[pixel + (cosine - 1) * 32] == 1) {
361
361
+
itemSprite.pixels[pixel + cosine * 32] = type;
362
362
+
} else if (pixel < 31 && itemSprite.pixels[pixel + 1 + cosine * 32] == 1) {
363
363
+
itemSprite.pixels[pixel + cosine * 32] = type;
364
364
+
} else if (cosine < 31 && itemSprite.pixels[pixel + (cosine + 1) * 32] == 1) {
365
365
+
itemSprite.pixels[pixel + cosine * 32] = type;
366
366
+
}
367
367
+
}
368
368
+
}
369
369
+
}
370
370
+
} else if (type == 0) {
371
371
+
for (int pixel = 31; pixel >= 0; pixel--) {
372
372
+
for (cosine = 31; cosine >= 0; cosine--) {
373
373
+
if (itemSprite.pixels[pixel + cosine * 32] == 0 && pixel > 0 && cosine > 0
374
374
+
&& itemSprite.pixels[pixel - 1 + (cosine - 1) * 32] > 0) {
375
375
+
itemSprite.pixels[pixel + cosine * 32] = 3153952;
376
376
+
}
377
377
+
}
378
378
+
}
379
379
+
}
380
380
+
if (itemDefinition.noteTemplateIndex != -1) {
381
381
+
int maxWidth = noteSprite.maxWidth;
382
382
+
int maxHeight = noteSprite.maxHeight;
383
383
+
noteSprite.maxWidth = 32;
384
384
+
noteSprite.maxHeight = 32;
385
385
+
noteSprite.drawImage(0, 0);
386
386
+
noteSprite.maxWidth = maxWidth;
387
387
+
noteSprite.maxHeight = maxHeight;
388
388
+
}
389
389
+
if (type == 0) {
390
390
+
ItemDefinition.rgbImageCache.put(itemSprite, itemId);
391
391
+
}
392
392
+
Rasterizer.createRasterizer(rasterizerPixels, rasterizerWidth, rasterizerHeight);
393
393
+
Rasterizer.setCoordinates(rasterizerTopX, rasterizerTopY, rasterizerBottomX, rasterizerBottomY);
394
394
+
Rasterizer3D.centerX = rasterizerCenterX;
395
395
+
Rasterizer3D.centerY = rasterizerCenterY;
396
396
+
Rasterizer3D.lineOffsets = rasterizerLineOffsets;
397
397
+
Rasterizer3D.textured = true;
398
398
+
if (itemDefinition.stackable) {
399
399
+
itemSprite.maxWidth = 33;
400
400
+
} else {
401
401
+
itemSprite.maxWidth = 32;
402
402
+
}
403
403
+
itemSprite.maxHeight = itemAmount;
404
404
+
return itemSprite;
405
405
+
}
406
406
+
407
407
+
public final Model getAmountModel(int amount) {
408
408
+
if (stackableIds != null && amount > 1) {
409
409
+
int stackedItemId = -1;
410
410
+
for (int index = 0; index < 10; index++) {
411
411
+
if (amount >= stackableAmounts[index] && stackableAmounts[index] != 0) {
412
412
+
stackedItemId = stackableIds[index];
413
413
+
}
414
414
+
}
415
415
+
if (stackedItemId != -1) {
416
416
+
return ItemDefinition.getDefinition(stackedItemId).getAmountModel(1);
417
417
+
}
418
418
+
}
419
419
+
Model stackedModel = (Model) ItemDefinition.modelCache.get(id);
420
420
+
if (stackedModel != null) {
421
421
+
return stackedModel;
422
422
+
}
423
423
+
stackedModel = Model.getModel(modelIndex);
424
424
+
if (stackedModel == null) {
425
425
+
return null;
426
426
+
}
427
427
+
if (modelSizeX != 128 || modelSizeY != 128 || modelSizeZ != 128) {
428
428
+
stackedModel.scaleT(modelSizeX, modelSizeZ, modelSizeY);
429
429
+
}
430
430
+
if (originalModelColors != null) {
431
431
+
for (int modelColor = 0; modelColor < originalModelColors.length; modelColor++) {
432
432
+
stackedModel.recolor(originalModelColors[modelColor], modifiedModelColors[modelColor]);
433
433
+
}
434
434
+
}
435
435
+
stackedModel.applyLighting(64 + lightModifier, 768 + shadowModifier, -50, -10, -50, true);
436
436
+
stackedModel.oneSquareModel = true;
437
437
+
ItemDefinition.modelCache.put(stackedModel, id);
438
438
+
return stackedModel;
439
439
+
}
440
440
+
441
441
+
public final Model getInventoryModel(int amount) {
442
442
+
if (stackableIds != null && amount > 1) {
443
443
+
int amountItemId = -1;
444
444
+
for (int index = 0; index < 10; index++) {
445
445
+
if (amount >= stackableAmounts[index] && stackableAmounts[index] != 0) {
446
446
+
amountItemId = stackableIds[index];
447
447
+
}
448
448
+
}
449
449
+
if (amountItemId != -1) {
450
450
+
return ItemDefinition.getDefinition(amountItemId).getInventoryModel(1);
451
451
+
}
452
452
+
}
453
453
+
Model inventoryModel = Model.getModel(modelIndex);
454
454
+
if (inventoryModel == null) {
455
455
+
return null;
456
456
+
}
457
457
+
if (originalModelColors != null) {
458
458
+
for (int color = 0; color < originalModelColors.length; color++) {
459
459
+
inventoryModel.recolor(originalModelColors[color], modifiedModelColors[color]);
460
460
+
}
461
461
+
}
462
462
+
return inventoryModel;
463
463
+
}
464
464
+
465
465
+
public final void loadDefinition(Buffer buffer) {
466
466
+
while (true) {
467
467
+
int attributeId = buffer.getUnsignedByte();
468
468
+
if (attributeId == 0) {
469
469
+
break;
470
470
+
}
471
471
+
if (attributeId == 1) {
472
472
+
modelIndex = buffer.getUnsignedLEShort();
473
473
+
} else if (attributeId == 2) {
474
474
+
name = buffer.getString();
475
475
+
} else if (attributeId == 3) {
476
476
+
description = buffer.getStringAsBytes();
477
477
+
} else if (attributeId == 4) {
478
478
+
modelZoom = buffer.getUnsignedLEShort();
479
479
+
} else if (attributeId == 5) {
480
480
+
modelRotation1 = buffer.getUnsignedLEShort();
481
481
+
} else if (attributeId == 6) {
482
482
+
modelRotation2 = buffer.getUnsignedLEShort();
483
483
+
} else if (attributeId == 7) {
484
484
+
modelOffset1 = buffer.getUnsignedLEShort();
485
485
+
if (modelOffset1 > 32767) {
486
486
+
modelOffset1 -= 65536;
487
487
+
}
488
488
+
} else if (attributeId == 8) {
489
489
+
sine = buffer.getUnsignedLEShort();
490
490
+
if (sine > 32767) {
491
491
+
sine -= 65536;
492
492
+
}
493
493
+
} else if (attributeId == 10) {
494
494
+
buffer.getUnsignedLEShort(); // dummy
495
495
+
} else if (attributeId == 11) {
496
496
+
stackable = true;
497
497
+
} else if (attributeId == 12) {
498
498
+
value = buffer.getInt();
499
499
+
} else if (attributeId == 16) {
500
500
+
membersOnly = true;
501
501
+
} else if (attributeId == 23) {
502
502
+
maleEquipPrimaryModel = buffer.getUnsignedLEShort();
503
503
+
maleEquipOffset = buffer.get();
504
504
+
} else if (attributeId == 24) {
505
505
+
maleEquipSecondaryModel = buffer.getUnsignedLEShort();
506
506
+
} else if (attributeId == 25) {
507
507
+
femaleEquipPrimaryModel = buffer.getUnsignedLEShort();
508
508
+
femaleEquipOffset = buffer.get();
509
509
+
} else if (attributeId == 26) {
510
510
+
femaleEquipSecondaryModel = buffer.getUnsignedLEShort();
511
511
+
} else if (attributeId >= 30 && attributeId < 35) {
512
512
+
if (groundActions == null) {
513
513
+
groundActions = new String[5];
514
514
+
}
515
515
+
groundActions[attributeId - 30] = buffer.getString();
516
516
+
if (groundActions[attributeId - 30].equalsIgnoreCase("hidden")) {
517
517
+
groundActions[attributeId - 30] = null;
518
518
+
}
519
519
+
} else if (attributeId >= 35 && attributeId < 40) {
520
520
+
if (inventoryActions == null) {
521
521
+
inventoryActions = new String[5];
522
522
+
}
523
523
+
inventoryActions[attributeId - 35] = buffer.getString();
524
524
+
} else if (attributeId == 40) {
525
525
+
int modelColorCount = buffer.getUnsignedByte();
526
526
+
originalModelColors = new int[modelColorCount];
527
527
+
modifiedModelColors = new int[modelColorCount];
528
528
+
for (int modelColor = 0; modelColor < modelColorCount; modelColor++) {
529
529
+
originalModelColors[modelColor] = buffer.getUnsignedLEShort();
530
530
+
modifiedModelColors[modelColor] = buffer.getUnsignedLEShort();
531
531
+
}
532
532
+
} else if (attributeId == 78) {
533
533
+
maleEmblem = buffer.getUnsignedLEShort();
534
534
+
} else if (attributeId == 79) {
535
535
+
femaleEmblem = buffer.getUnsignedLEShort();
536
536
+
} else if (attributeId == 90) {
537
537
+
maleDialogue = buffer.getUnsignedLEShort();
538
538
+
} else if (attributeId == 91) {
539
539
+
femaleDialogue = buffer.getUnsignedLEShort();
540
540
+
} else if (attributeId == 92) {
541
541
+
maleDialogueHat = buffer.getUnsignedLEShort();
542
542
+
} else if (attributeId == 93) {
543
543
+
femaleDialogueHat = buffer.getUnsignedLEShort();
544
544
+
} else if (attributeId == 95) {
545
545
+
diagonalRotation = buffer.getUnsignedLEShort();
546
546
+
} else if (attributeId == 97) {
547
547
+
noteIndex = buffer.getUnsignedLEShort();
548
548
+
} else if (attributeId == 98) {
549
549
+
noteTemplateIndex = buffer.getUnsignedLEShort();
550
550
+
} else if (attributeId >= 100 && attributeId < 110) {
551
551
+
if (stackableIds == null) {
552
552
+
stackableIds = new int[10];
553
553
+
stackableAmounts = new int[10];
554
554
+
}
555
555
+
stackableIds[attributeId - 100] = buffer.getUnsignedLEShort();
556
556
+
stackableAmounts[attributeId - 100] = buffer.getUnsignedLEShort();
557
557
+
} else if (attributeId == 110) {
558
558
+
modelSizeX = buffer.getUnsignedLEShort();
559
559
+
} else if (attributeId == 111) {
560
560
+
modelSizeY = buffer.getUnsignedLEShort();
561
561
+
} else if (attributeId == 112) {
562
562
+
modelSizeZ = buffer.getUnsignedLEShort();
563
563
+
} else if (attributeId == 113) {
564
564
+
lightModifier = buffer.get();
565
565
+
} else if (attributeId == 114) {
566
566
+
shadowModifier = buffer.get() * 5;
567
567
+
} else if (attributeId == 115) {
568
568
+
teamId = buffer.getUnsignedByte();
569
569
+
}
570
570
+
}
571
571
+
}
572
572
+
}
+131
src/com/jagex/runescape/cache/media/AnimationSequence.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache.media;
2
2
+
3
3
+
import com.jagex.runescape.cache.Archive;
4
4
+
import com.jagex.runescape.media.Animation;
5
5
+
import com.jagex.runescape.net.Buffer;
6
6
+
7
7
+
public class AnimationSequence {
8
8
+
9
9
+
public static int count;
10
10
+
public static AnimationSequence[] cache;
11
11
+
public int frameCount;
12
12
+
public int[] frame2Ids;
13
13
+
public int[] frame1Ids;
14
14
+
private int[] frameLenghts;
15
15
+
public int frameStep = -1;
16
16
+
public int[] flowControl;
17
17
+
public boolean aBoolean56 = false;
18
18
+
public int anInt57 = 5;
19
19
+
public int anInt58 = -1;
20
20
+
public int anInt59 = -1;
21
21
+
public int anInt60 = 99;
22
22
+
public int anInt61 = -1;
23
23
+
public int priority = -1;
24
24
+
public int anInt63 = 2;
25
25
+
public int anInt64;
26
26
+
27
27
+
public static void load(Archive archive) {
28
28
+
Buffer buffer = new Buffer(archive.getFile("seq.dat"));
29
29
+
AnimationSequence.count = buffer.getUnsignedLEShort();
30
30
+
if (AnimationSequence.cache == null) {
31
31
+
AnimationSequence.cache = new AnimationSequence[AnimationSequence.count];
32
32
+
}
33
33
+
for (int animation = 0; animation < AnimationSequence.count; animation++) {
34
34
+
if (AnimationSequence.cache[animation] == null) {
35
35
+
AnimationSequence.cache[animation] = new AnimationSequence();
36
36
+
}
37
37
+
AnimationSequence.cache[animation].loadDefinition(true, buffer);
38
38
+
}
39
39
+
}
40
40
+
41
41
+
public int getFrameLength(int animationId) {
42
42
+
int frameLength = frameLenghts[animationId];
43
43
+
if (frameLength == 0) {
44
44
+
Animation animation = Animation.getAnimation(frame2Ids[animationId]);
45
45
+
if (animation != null) {
46
46
+
frameLength = frameLenghts[animationId] = animation.displayLength;
47
47
+
}
48
48
+
}
49
49
+
if (frameLength == 0) {
50
50
+
frameLength = 1;
51
51
+
}
52
52
+
return frameLength;
53
53
+
}
54
54
+
55
55
+
public void loadDefinition(boolean bool, Buffer buffer) {
56
56
+
while (true) {
57
57
+
int attributeId = buffer.getUnsignedByte();
58
58
+
if (attributeId == 0) {
59
59
+
break;
60
60
+
}
61
61
+
if (attributeId == 1) {
62
62
+
frameCount = buffer.getUnsignedByte();
63
63
+
frame2Ids = new int[frameCount];
64
64
+
frame1Ids = new int[frameCount];
65
65
+
frameLenghts = new int[frameCount];
66
66
+
for (int frame = 0; frame < frameCount; frame++) {
67
67
+
frame2Ids[frame] = buffer.getUnsignedLEShort();
68
68
+
frame1Ids[frame] = buffer.getUnsignedLEShort();
69
69
+
if (frame1Ids[frame] == 65535) {
70
70
+
frame1Ids[frame] = -1;
71
71
+
}
72
72
+
frameLenghts[frame] = buffer.getUnsignedLEShort();
73
73
+
}
74
74
+
} else if (attributeId == 2) {
75
75
+
frameStep = buffer.getUnsignedLEShort();
76
76
+
} else if (attributeId == 3) {
77
77
+
int flowCount = buffer.getUnsignedByte();
78
78
+
flowControl = new int[flowCount + 1];
79
79
+
for (int flow = 0; flow < flowCount; flow++) {
80
80
+
flowControl[flow] = buffer.getUnsignedByte();
81
81
+
}
82
82
+
flowControl[flowCount] = 9999999;
83
83
+
} else if (attributeId == 4) {
84
84
+
aBoolean56 = true;
85
85
+
} else if (attributeId == 5) {
86
86
+
anInt57 = buffer.getUnsignedByte();
87
87
+
} else if (attributeId == 6) {
88
88
+
anInt58 = buffer.getUnsignedLEShort();
89
89
+
} else if (attributeId == 7) {
90
90
+
anInt59 = buffer.getUnsignedLEShort();
91
91
+
} else if (attributeId == 8) {
92
92
+
anInt60 = buffer.getUnsignedByte();
93
93
+
} else if (attributeId == 9) {
94
94
+
anInt61 = buffer.getUnsignedByte();
95
95
+
} else if (attributeId == 10) {
96
96
+
priority = buffer.getUnsignedByte();
97
97
+
} else if (attributeId == 11) {
98
98
+
anInt63 = buffer.getUnsignedByte();
99
99
+
} else if (attributeId == 12) {
100
100
+
anInt64 = buffer.getInt();
101
101
+
} else {
102
102
+
System.out.println("Error unrecognised seq config code: " + attributeId);
103
103
+
}
104
104
+
}
105
105
+
if (frameCount == 0) {
106
106
+
frameCount = 1;
107
107
+
frame2Ids = new int[1];
108
108
+
frame2Ids[0] = -1;
109
109
+
frame1Ids = new int[1];
110
110
+
frame1Ids[0] = -1;
111
111
+
frameLenghts = new int[1];
112
112
+
frameLenghts[0] = -1;
113
113
+
}
114
114
+
if (anInt61 == -1) {
115
115
+
if (flowControl != null) {
116
116
+
anInt61 = 2;
117
117
+
} else {
118
118
+
anInt61 = 0;
119
119
+
}
120
120
+
}
121
121
+
if (priority != -1) {
122
122
+
return;
123
123
+
}
124
124
+
if (flowControl != null) {
125
125
+
priority = 2;
126
126
+
} else {
127
127
+
priority = 0;
128
128
+
}
129
129
+
130
130
+
}
131
131
+
}
+123
src/com/jagex/runescape/cache/media/IdentityKit.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache.media;
2
2
+
3
3
+
import com.jagex.runescape.cache.Archive;
4
4
+
import com.jagex.runescape.media.renderable.Model;
5
5
+
import com.jagex.runescape.net.Buffer;
6
6
+
7
7
+
public class IdentityKit {
8
8
+
9
9
+
public static int count;
10
10
+
public static IdentityKit[] cache;
11
11
+
public int partId = -1;
12
12
+
public int[] modelId;
13
13
+
public int[] originalModelColors = new int[6];
14
14
+
public int[] modifiedModelColors = new int[6];
15
15
+
public int[] headModelId = { -1, -1, -1, -1, -1 };
16
16
+
public boolean widgetDisplayed = false;
17
17
+
18
18
+
public static void load(Archive archive) {
19
19
+
Buffer buffer = new Buffer(archive.getFile("idk.dat"));
20
20
+
IdentityKit.count = buffer.getUnsignedLEShort();
21
21
+
if (IdentityKit.cache == null) {
22
22
+
IdentityKit.cache = new IdentityKit[IdentityKit.count];
23
23
+
}
24
24
+
for (int identityKit = 0; identityKit < IdentityKit.count; identityKit++) {
25
25
+
if (IdentityKit.cache[identityKit] == null) {
26
26
+
IdentityKit.cache[identityKit] = new IdentityKit();
27
27
+
}
28
28
+
IdentityKit.cache[identityKit].loadDefinition(buffer);
29
29
+
}
30
30
+
}
31
31
+
32
32
+
public void loadDefinition(Buffer buffer) {
33
33
+
while (true) {
34
34
+
int attributeId = buffer.getUnsignedByte();
35
35
+
if (attributeId == 0) {
36
36
+
break;
37
37
+
}
38
38
+
if (attributeId == 1) {
39
39
+
partId = buffer.getUnsignedByte();
40
40
+
} else if (attributeId == 2) {
41
41
+
int modelCount = buffer.getUnsignedByte();
42
42
+
modelId = new int[modelCount];
43
43
+
for (int model = 0; model < modelCount; model++) {
44
44
+
modelId[model] = buffer.getUnsignedLEShort();
45
45
+
}
46
46
+
} else if (attributeId == 3) {
47
47
+
widgetDisplayed = true;
48
48
+
} else if (attributeId >= 40 && attributeId < 50) {
49
49
+
originalModelColors[attributeId - 40] = buffer.getUnsignedLEShort();
50
50
+
} else if (attributeId >= 50 && attributeId < 60) {
51
51
+
modifiedModelColors[attributeId - 50] = buffer.getUnsignedLEShort();
52
52
+
} else if (attributeId >= 60 && attributeId < 70) {
53
53
+
headModelId[attributeId - 60] = buffer.getUnsignedLEShort();
54
54
+
} else {
55
55
+
System.out.println("Error unrecognised config code: " + attributeId);
56
56
+
}
57
57
+
}
58
58
+
}
59
59
+
60
60
+
public boolean isBodyModelCached() {
61
61
+
if (modelId == null) {
62
62
+
return true;
63
63
+
}
64
64
+
boolean isCached = true;
65
65
+
for (int i = 0; i < modelId.length; i++) {
66
66
+
if (!Model.isCached(modelId[i])) {
67
67
+
isCached = false;
68
68
+
}
69
69
+
}
70
70
+
return isCached;
71
71
+
}
72
72
+
73
73
+
public Model getBodyModel() {
74
74
+
if (modelId == null) {
75
75
+
return null;
76
76
+
}
77
77
+
Model[] models = new Model[modelId.length];
78
78
+
for (int model = 0; model < modelId.length; model++) {
79
79
+
models[model] = Model.getModel(modelId[model]);
80
80
+
}
81
81
+
Model model;
82
82
+
if (models.length == 1) {
83
83
+
model = models[0];
84
84
+
} else {
85
85
+
model = new Model(models.length, models);
86
86
+
}
87
87
+
for (int color = 0; color < 6; color++) {
88
88
+
if (originalModelColors[color] == 0) {
89
89
+
break;
90
90
+
}
91
91
+
model.recolor(originalModelColors[color], modifiedModelColors[color]);
92
92
+
}
93
93
+
return model;
94
94
+
}
95
95
+
96
96
+
public boolean isHeadModelCached() {
97
97
+
boolean cached = true;
98
98
+
for (int model = 0; model < 5; model++) {
99
99
+
if (headModelId[model] != -1 && !Model.isCached(headModelId[model])) {
100
100
+
cached = false;
101
101
+
}
102
102
+
}
103
103
+
return cached;
104
104
+
}
105
105
+
106
106
+
public Model getHeadModel() {
107
107
+
Model[] models = new Model[5];
108
108
+
int count = 0;
109
109
+
for (int model = 0; model < 5; model++) {
110
110
+
if (headModelId[model] != -1) {
111
111
+
models[count++] = Model.getModel(headModelId[model]);
112
112
+
}
113
113
+
}
114
114
+
Model model = new Model(count, models);
115
115
+
for (int color = 0; color < 6; color++) {
116
116
+
if (originalModelColors[color] == 0) {
117
117
+
break;
118
118
+
}
119
119
+
model.recolor(originalModelColors[color], modifiedModelColors[color]);
120
120
+
}
121
121
+
return model;
122
122
+
}
123
123
+
}
+502
src/com/jagex/runescape/cache/media/ImageRGB.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache.media;
2
2
+
3
3
+
import java.awt.Component;
4
4
+
import java.awt.Image;
5
5
+
import java.awt.MediaTracker;
6
6
+
import java.awt.Toolkit;
7
7
+
import java.awt.image.PixelGrabber;
8
8
+
9
9
+
import com.jagex.runescape.cache.Archive;
10
10
+
import com.jagex.runescape.media.Rasterizer;
11
11
+
import com.jagex.runescape.util.SignLink;
12
12
+
import com.jagex.runescape.net.Buffer;
13
13
+
14
14
+
public class ImageRGB extends Rasterizer {
15
15
+
16
16
+
public int[] pixels;
17
17
+
public int width;
18
18
+
public int height;
19
19
+
public int offsetX;
20
20
+
public int offsetY;
21
21
+
public int maxWidth;
22
22
+
public int maxHeight;
23
23
+
24
24
+
public ImageRGB(int width, int height) {
25
25
+
pixels = new int[width * height];
26
26
+
this.width = maxWidth = width;
27
27
+
this.height = maxHeight = height;
28
28
+
offsetX = offsetY = 0;
29
29
+
}
30
30
+
31
31
+
public ImageRGB(byte[] imagedata, Component component) {
32
32
+
try {
33
33
+
Image image = Toolkit.getDefaultToolkit().createImage(imagedata);
34
34
+
MediaTracker mediaTracker = new MediaTracker(component);
35
35
+
mediaTracker.addImage(image, 0);
36
36
+
mediaTracker.waitForAll();
37
37
+
width = image.getWidth(component);
38
38
+
height = image.getHeight(component);
39
39
+
maxWidth = width;
40
40
+
maxHeight = height;
41
41
+
offsetX = 0;
42
42
+
offsetY = 0;
43
43
+
pixels = new int[width * height];
44
44
+
PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, width, height, pixels, 0, width);
45
45
+
pixelgrabber.grabPixels();
46
46
+
} catch (Exception exception) {
47
47
+
System.out.println("Error converting jpg");
48
48
+
}
49
49
+
}
50
50
+
51
51
+
public ImageRGB(Archive archive, String string, int archiveIndex) {
52
52
+
Buffer dataBuffer = new Buffer(archive.getFile(string + ".dat"));
53
53
+
Buffer indexBuffer = new Buffer(archive.getFile("index.dat"));
54
54
+
indexBuffer.offset = dataBuffer.getUnsignedLEShort();
55
55
+
maxWidth = indexBuffer.getUnsignedLEShort();
56
56
+
maxHeight = indexBuffer.getUnsignedLEShort();
57
57
+
int length = indexBuffer.getUnsignedByte();
58
58
+
int[] pixels = new int[length];
59
59
+
for (int pixel = 0; pixel < length - 1; pixel++) {
60
60
+
pixels[pixel + 1] = indexBuffer.get24BitInt();
61
61
+
if (pixels[pixel + 1] == 0) {
62
62
+
pixels[pixel + 1] = 1;
63
63
+
}
64
64
+
}
65
65
+
for (int index = 0; index < archiveIndex; index++) {
66
66
+
indexBuffer.offset += 2;
67
67
+
dataBuffer.offset += indexBuffer.getUnsignedLEShort() * indexBuffer.getUnsignedLEShort();
68
68
+
indexBuffer.offset++;
69
69
+
}
70
70
+
offsetX = indexBuffer.getUnsignedByte();
71
71
+
offsetY = indexBuffer.getUnsignedByte();
72
72
+
width = indexBuffer.getUnsignedLEShort();
73
73
+
height = indexBuffer.getUnsignedLEShort();
74
74
+
int type = indexBuffer.getUnsignedByte();
75
75
+
int pixelCount = width * height;
76
76
+
this.pixels = new int[pixelCount];
77
77
+
if (type == 0) {
78
78
+
for (int pixel = 0; pixel < pixelCount; pixel++) {
79
79
+
this.pixels[pixel] = pixels[dataBuffer.getUnsignedByte()];
80
80
+
}
81
81
+
} else if (type == 1) {
82
82
+
for (int x = 0; x < width; x++) {
83
83
+
for (int y = 0; y < height; y++) {
84
84
+
this.pixels[x + y * width] = pixels[dataBuffer.getUnsignedByte()];
85
85
+
}
86
86
+
}
87
87
+
}
88
88
+
}
89
89
+
90
90
+
public void createRasterizer() {
91
91
+
Rasterizer.createRasterizer(pixels, width, height);
92
92
+
}
93
93
+
94
94
+
public void adjustRGB(int redOffset, int greenOffset, int blueOffset) {
95
95
+
for (int pixel = 0; pixel < pixels.length; pixel++) {
96
96
+
int originalColor = pixels[pixel];
97
97
+
if (originalColor != 0) {
98
98
+
int red = originalColor >> 16 & 0xff;
99
99
+
red += redOffset;
100
100
+
if (red < 1) {
101
101
+
red = 1;
102
102
+
} else if (red > 255) {
103
103
+
red = 255;
104
104
+
}
105
105
+
int green = originalColor >> 8 & 0xff;
106
106
+
green += greenOffset;
107
107
+
if (green < 1) {
108
108
+
green = 1;
109
109
+
} else if (green > 255) {
110
110
+
green = 255;
111
111
+
}
112
112
+
int blue = originalColor & 0xff;
113
113
+
blue += blueOffset;
114
114
+
if (blue < 1) {
115
115
+
blue = 1;
116
116
+
} else if (blue > 255) {
117
117
+
blue = 255;
118
118
+
}
119
119
+
pixels[pixel] = (red << 16) + (green << 8) + blue;
120
120
+
}
121
121
+
}
122
122
+
}
123
123
+
124
124
+
public void trim() {
125
125
+
int[] newPixels = new int[maxWidth * maxHeight];
126
126
+
for (int y = 0; y < height; y++) {
127
127
+
for (int x = 0; x < width; x++) {
128
128
+
newPixels[(y + offsetY) * maxWidth + (x + offsetX)] = pixels[y * width + x];
129
129
+
}
130
130
+
}
131
131
+
pixels = newPixels;
132
132
+
width = maxWidth;
133
133
+
height = maxHeight;
134
134
+
offsetX = 0;
135
135
+
offsetY = 0;
136
136
+
}
137
137
+
138
138
+
public void drawInverse(int x, int y) {
139
139
+
x += offsetX;
140
140
+
y += offsetY;
141
141
+
int rasterizerPixel = x + y * Rasterizer.width;
142
142
+
int pixel = 0;
143
143
+
int newHeight = height;
144
144
+
int newWidth = width;
145
145
+
int rasterizerPixelOffset = Rasterizer.width - newWidth;
146
146
+
int pixelOffset = 0;
147
147
+
if (y < Rasterizer.topY) {
148
148
+
int yOffset = Rasterizer.topY - y;
149
149
+
newHeight -= yOffset;
150
150
+
y = Rasterizer.topY;
151
151
+
pixel += yOffset * newWidth;
152
152
+
rasterizerPixel += yOffset * Rasterizer.width;
153
153
+
}
154
154
+
if (y + newHeight > Rasterizer.bottomY) {
155
155
+
newHeight -= y + newHeight - Rasterizer.bottomY;
156
156
+
}
157
157
+
if (x < Rasterizer.topX) {
158
158
+
int xOffset = Rasterizer.topX - x;
159
159
+
newWidth -= xOffset;
160
160
+
x = Rasterizer.topX;
161
161
+
pixel += xOffset;
162
162
+
rasterizerPixel += xOffset;
163
163
+
pixelOffset += xOffset;
164
164
+
rasterizerPixelOffset += xOffset;
165
165
+
}
166
166
+
if (x + newWidth > Rasterizer.bottomX) {
167
167
+
int widthOffset = x + newWidth - Rasterizer.bottomX;
168
168
+
newWidth -= widthOffset;
169
169
+
pixelOffset += widthOffset;
170
170
+
rasterizerPixelOffset += widthOffset;
171
171
+
}
172
172
+
if (newWidth > 0 && newHeight > 0) {
173
173
+
copyPixels(pixels, Rasterizer.pixels, pixel, rasterizerPixel, pixelOffset, rasterizerPixelOffset, newWidth,
174
174
+
newHeight);
175
175
+
}
176
176
+
}
177
177
+
178
178
+
private void copyPixels(int[] pixels, int[] rasterizerPixels, int pixel, int rasterizerPixel, int pixelOffset,
179
179
+
int rasterizerPixelOffset, int width, int height) {
180
180
+
int shiftedWidth = -(width >> 2);
181
181
+
width = -(width & 0x3);
182
182
+
for (int heightCounter = -height; heightCounter < 0; heightCounter++) {
183
183
+
for (int widthCounter = shiftedWidth; widthCounter < 0; widthCounter++) {
184
184
+
rasterizerPixels[rasterizerPixel++] = pixels[pixel++];
185
185
+
rasterizerPixels[rasterizerPixel++] = pixels[pixel++];
186
186
+
rasterizerPixels[rasterizerPixel++] = pixels[pixel++];
187
187
+
rasterizerPixels[rasterizerPixel++] = pixels[pixel++];
188
188
+
}
189
189
+
for (int widthCounter = width; widthCounter < 0; widthCounter++) {
190
190
+
rasterizerPixels[rasterizerPixel++] = pixels[pixel++];
191
191
+
}
192
192
+
rasterizerPixel += rasterizerPixelOffset;
193
193
+
pixel += pixelOffset;
194
194
+
}
195
195
+
}
196
196
+
197
197
+
public void drawImage(int x, int y) {
198
198
+
x += offsetX;
199
199
+
y += offsetY;
200
200
+
int rasterizerOffset = x + y * Rasterizer.width;
201
201
+
int pixelOffset = 0;
202
202
+
int imageHeight = height;
203
203
+
int imageWidth = width;
204
204
+
int deviation = Rasterizer.width - imageWidth;
205
205
+
int originalDeviation = 0;
206
206
+
if (y < Rasterizer.topY) {
207
207
+
int yOffset = Rasterizer.topY - y;
208
208
+
imageHeight -= yOffset;
209
209
+
y = Rasterizer.topY;
210
210
+
pixelOffset += yOffset * imageWidth;
211
211
+
rasterizerOffset += yOffset * Rasterizer.width;
212
212
+
}
213
213
+
if (y + imageHeight > Rasterizer.bottomY) {
214
214
+
imageHeight -= y + imageHeight - Rasterizer.bottomY;
215
215
+
}
216
216
+
if (x < Rasterizer.topX) {
217
217
+
int xOffset = Rasterizer.topX - x;
218
218
+
imageWidth -= xOffset;
219
219
+
x = Rasterizer.topX;
220
220
+
pixelOffset += xOffset;
221
221
+
rasterizerOffset += xOffset;
222
222
+
originalDeviation += xOffset;
223
223
+
deviation += xOffset;
224
224
+
}
225
225
+
if (x + imageWidth > Rasterizer.bottomX) {
226
226
+
int xOffset = x + imageWidth - Rasterizer.bottomX;
227
227
+
imageWidth -= xOffset;
228
228
+
originalDeviation += xOffset;
229
229
+
deviation += xOffset;
230
230
+
}
231
231
+
if (imageWidth > 0 && imageHeight > 0) {
232
232
+
shapeImageToPixels(pixels, Rasterizer.pixels, pixelOffset, rasterizerOffset, imageWidth, imageHeight,
233
233
+
originalDeviation, deviation, 0);
234
234
+
}
235
235
+
}
236
236
+
237
237
+
private void shapeImageToPixels(int[] pixels, int[] rasterizerPixels, int pixel, int rasterizerPixel, int width,
238
238
+
int height, int pixelOffset, int rasterizerPixelOffset, int pixelColor) {
239
239
+
int shiftedWidth = -(width >> 2);
240
240
+
width = -(width & 0x3);
241
241
+
for (int heightCounter = -height; heightCounter < 0; heightCounter++) {
242
242
+
for (int widthCounter = shiftedWidth; widthCounter < 0; widthCounter++) {
243
243
+
pixelColor = pixels[pixel++];
244
244
+
if (pixelColor != 0) {
245
245
+
rasterizerPixels[rasterizerPixel++] = pixelColor;
246
246
+
} else {
247
247
+
rasterizerPixel++;
248
248
+
}
249
249
+
pixelColor = pixels[pixel++];
250
250
+
if (pixelColor != 0) {
251
251
+
rasterizerPixels[rasterizerPixel++] = pixelColor;
252
252
+
} else {
253
253
+
rasterizerPixel++;
254
254
+
}
255
255
+
pixelColor = pixels[pixel++];
256
256
+
if (pixelColor != 0) {
257
257
+
rasterizerPixels[rasterizerPixel++] = pixelColor;
258
258
+
} else {
259
259
+
rasterizerPixel++;
260
260
+
}
261
261
+
pixelColor = pixels[pixel++];
262
262
+
if (pixelColor != 0) {
263
263
+
rasterizerPixels[rasterizerPixel++] = pixelColor;
264
264
+
} else {
265
265
+
rasterizerPixel++;
266
266
+
}
267
267
+
}
268
268
+
for (int widthCounter = width; widthCounter < 0; widthCounter++) {
269
269
+
pixelColor = pixels[pixel++];
270
270
+
if (pixelColor != 0) {
271
271
+
rasterizerPixels[rasterizerPixel++] = pixelColor;
272
272
+
} else {
273
273
+
rasterizerPixel++;
274
274
+
}
275
275
+
}
276
276
+
rasterizerPixel += rasterizerPixelOffset;
277
277
+
pixel += pixelOffset;
278
278
+
}
279
279
+
}
280
280
+
281
281
+
public void drawImageAlpha(int x, int y, int alpha) {
282
282
+
x += offsetX;
283
283
+
y += offsetY;
284
284
+
int rasterizerPixel = x + y * Rasterizer.width;
285
285
+
int pixel = 0;
286
286
+
int newHeight = height;
287
287
+
int newWidth = width;
288
288
+
int rasterizerPixelOffset = Rasterizer.width - newWidth;
289
289
+
int pixelOffset = 0;
290
290
+
if (y < Rasterizer.topY) {
291
291
+
int yOffset = Rasterizer.topY - y;
292
292
+
newHeight -= yOffset;
293
293
+
y = Rasterizer.topY;
294
294
+
pixel += yOffset * newWidth;
295
295
+
rasterizerPixel += yOffset * Rasterizer.width;
296
296
+
}
297
297
+
if (y + newHeight > Rasterizer.bottomY) {
298
298
+
newHeight -= y + newHeight - Rasterizer.bottomY;
299
299
+
}
300
300
+
if (x < Rasterizer.topX) {
301
301
+
int xOffset = Rasterizer.topX - x;
302
302
+
newWidth -= xOffset;
303
303
+
x = Rasterizer.topX;
304
304
+
pixel += xOffset;
305
305
+
rasterizerPixel += xOffset;
306
306
+
pixelOffset += xOffset;
307
307
+
rasterizerPixelOffset += xOffset;
308
308
+
}
309
309
+
if (x + newWidth > Rasterizer.bottomX) {
310
310
+
int xOffset = x + newWidth - Rasterizer.bottomX;
311
311
+
newWidth -= xOffset;
312
312
+
pixelOffset += xOffset;
313
313
+
rasterizerPixelOffset += xOffset;
314
314
+
}
315
315
+
if (newWidth > 0 && newHeight > 0) {
316
316
+
copyPixelsAlpha(pixels, Rasterizer.pixels, pixel, rasterizerPixel, pixelOffset, rasterizerPixelOffset,
317
317
+
newWidth, newHeight, 0, alpha);
318
318
+
}
319
319
+
}
320
320
+
321
321
+
private void copyPixelsAlpha(int[] pixels, int[] rasterizerPixels, int pixel, int rasterizerPixel, int pixelOffset,
322
322
+
int rasterizerPixelOffset, int width, int height, int color, int alpha) {
323
323
+
int alphaValue = 256 - alpha;
324
324
+
for (int heightCounter = -height; heightCounter < 0; heightCounter++) {
325
325
+
for (int widthCounter = -width; widthCounter < 0; widthCounter++) {
326
326
+
color = pixels[pixel++];
327
327
+
if (color != 0) {
328
328
+
int rasterizerPixelColor = rasterizerPixels[rasterizerPixel];
329
329
+
rasterizerPixels[rasterizerPixel++] = ((color & 0xff00ff) * alpha
330
330
+
+ (rasterizerPixelColor & 0xff00ff) * alphaValue & ~0xff00ff)
331
331
+
+ ((color & 0xff00) * alpha + (rasterizerPixelColor & 0xff00) * alphaValue & 0xff0000) >> 8;
332
332
+
} else {
333
333
+
rasterizerPixel++;
334
334
+
}
335
335
+
}
336
336
+
rasterizerPixel += rasterizerPixelOffset;
337
337
+
pixel += pixelOffset;
338
338
+
}
339
339
+
}
340
340
+
341
341
+
public void shapeImageToPixels(int i, int i_89_, int[] is, int i_90_, int[] is_91_, int i_93_, int i_94_,
342
342
+
int i_95_, int i_96_, int i_97_) {
343
343
+
int i_98_ = -i_96_ / 2;
344
344
+
int i_99_ = -i / 2;
345
345
+
int i_100_ = (int) (Math.sin(i_89_ / 326.11) * 65536.0);
346
346
+
int i_101_ = (int) (Math.cos(i_89_ / 326.11) * 65536.0);
347
347
+
i_100_ = i_100_ * i_90_ >> 8;
348
348
+
i_101_ = i_101_ * i_90_ >> 8;
349
349
+
int i_102_ = (i_97_ << 16) + (i_99_ * i_100_ + i_98_ * i_101_);
350
350
+
int i_103_ = (i_93_ << 16) + (i_99_ * i_101_ - i_98_ * i_100_);
351
351
+
int i_104_ = i_95_ + i_94_ * Rasterizer.width;
352
352
+
for (i_94_ = 0; i_94_ < i; i_94_++) {
353
353
+
int i_105_ = is_91_[i_94_];
354
354
+
int rasterizerPixel = i_104_ + i_105_;
355
355
+
int i_107_ = i_102_ + i_101_ * i_105_;
356
356
+
int i_108_ = i_103_ - i_100_ * i_105_;
357
357
+
for (i_95_ = -is[i_94_]; i_95_ < 0; i_95_++) {
358
358
+
Rasterizer.pixels[rasterizerPixel++] = pixels[(i_107_ >> 16) + (i_108_ >> 16) * width];
359
359
+
i_107_ += i_101_;
360
360
+
i_108_ -= i_100_;
361
361
+
}
362
362
+
i_102_ += i_100_;
363
363
+
i_103_ += i_101_;
364
364
+
i_104_ += Rasterizer.width;
365
365
+
}
366
366
+
}
367
367
+
368
368
+
public void method350(int i, int i_109_, int i_110_, int i_111_, int i_112_, int i_113_, int i_114_, double d,
369
369
+
int i_115_) {
370
370
+
try {
371
371
+
if (i_112_ == 41960) {
372
372
+
try {
373
373
+
int i_116_ = -i_110_ / 2;
374
374
+
int i_117_ = -i_114_ / 2;
375
375
+
int i_118_ = (int) (Math.sin(d) * 65536.0);
376
376
+
int i_119_ = (int) (Math.cos(d) * 65536.0);
377
377
+
i_118_ = i_118_ * i_113_ >> 8;
378
378
+
i_119_ = i_119_ * i_113_ >> 8;
379
379
+
int i_120_ = (i_111_ << 16) + (i_117_ * i_118_ + i_116_ * i_119_);
380
380
+
int i_121_ = (i_109_ << 16) + (i_117_ * i_119_ - i_116_ * i_118_);
381
381
+
int i_122_ = i_115_ + i * Rasterizer.width;
382
382
+
for (i = 0; i < i_114_; i++) {
383
383
+
int i_123_ = i_122_;
384
384
+
int i_124_ = i_120_;
385
385
+
int i_125_ = i_121_;
386
386
+
for (i_115_ = -i_110_; i_115_ < 0; i_115_++) {
387
387
+
int i_126_ = pixels[(i_124_ >> 16) + (i_125_ >> 16) * width];
388
388
+
if (i_126_ != 0) {
389
389
+
Rasterizer.pixels[i_123_++] = i_126_;
390
390
+
} else {
391
391
+
i_123_++;
392
392
+
}
393
393
+
i_124_ += i_119_;
394
394
+
i_125_ -= i_118_;
395
395
+
}
396
396
+
i_120_ += i_118_;
397
397
+
i_121_ += i_119_;
398
398
+
i_122_ += Rasterizer.width;
399
399
+
}
400
400
+
} catch (Exception exception) {
401
401
+
/* empty */
402
402
+
}
403
403
+
}
404
404
+
} catch (RuntimeException runtimeexception) {
405
405
+
SignLink.reportError("71953, " + i + ", " + i_109_ + ", " + i_110_ + ", " + i_111_ + ", " + i_112_ + ", "
406
406
+
+ i_113_ + ", " + i_114_ + ", " + d + ", " + i_115_ + ", " + runtimeexception.toString());
407
407
+
throw new RuntimeException();
408
408
+
}
409
409
+
}
410
410
+
411
411
+
public void method351(IndexedImage indexedimage, boolean bool, int i, int i_127_) {
412
412
+
try {
413
413
+
i_127_ += offsetX;
414
414
+
i += offsetY;
415
415
+
int i_128_ = i_127_ + i * Rasterizer.width;
416
416
+
int i_129_ = 0;
417
417
+
if (bool) {
418
418
+
}
419
419
+
int i_130_ = height;
420
420
+
int i_131_ = width;
421
421
+
int i_132_ = Rasterizer.width - i_131_;
422
422
+
int i_133_ = 0;
423
423
+
if (i < Rasterizer.topY) {
424
424
+
int i_134_ = Rasterizer.topY - i;
425
425
+
i_130_ -= i_134_;
426
426
+
i = Rasterizer.topY;
427
427
+
i_129_ += i_134_ * i_131_;
428
428
+
i_128_ += i_134_ * Rasterizer.width;
429
429
+
}
430
430
+
if (i + i_130_ > Rasterizer.bottomY) {
431
431
+
i_130_ -= i + i_130_ - Rasterizer.bottomY;
432
432
+
}
433
433
+
if (i_127_ < Rasterizer.topX) {
434
434
+
int i_135_ = Rasterizer.topX - i_127_;
435
435
+
i_131_ -= i_135_;
436
436
+
i_127_ = Rasterizer.topX;
437
437
+
i_129_ += i_135_;
438
438
+
i_128_ += i_135_;
439
439
+
i_133_ += i_135_;
440
440
+
i_132_ += i_135_;
441
441
+
}
442
442
+
if (i_127_ + i_131_ > Rasterizer.bottomX) {
443
443
+
int i_136_ = i_127_ + i_131_ - Rasterizer.bottomX;
444
444
+
i_131_ -= i_136_;
445
445
+
i_133_ += i_136_;
446
446
+
i_132_ += i_136_;
447
447
+
}
448
448
+
if (i_131_ > 0 && i_130_ > 0) {
449
449
+
method352(pixels, i_131_, indexedimage.pixels, i_130_, Rasterizer.pixels, 0, i_132_, i_128_, i_133_,
450
450
+
i_129_);
451
451
+
}
452
452
+
} catch (RuntimeException runtimeexception) {
453
453
+
SignLink.reportError("70668, " + indexedimage + ", " + bool + ", " + i + ", " + i_127_ + ", "
454
454
+
+ runtimeexception.toString());
455
455
+
throw new RuntimeException();
456
456
+
}
457
457
+
}
458
458
+
459
459
+
private void method352(int[] is, int i, byte[] bs, int i_137_, int[] is_138_, int i_139_, int i_140_, int i_141_,
460
460
+
int i_142_, int i_143_) {
461
461
+
int i_144_ = -(i >> 2);
462
462
+
i = -(i & 0x3);
463
463
+
for (int i_146_ = -i_137_; i_146_ < 0; i_146_++) {
464
464
+
for (int i_147_ = i_144_; i_147_ < 0; i_147_++) {
465
465
+
i_139_ = is[i_143_++];
466
466
+
if (i_139_ != 0 && bs[i_141_] == 0) {
467
467
+
is_138_[i_141_++] = i_139_;
468
468
+
} else {
469
469
+
i_141_++;
470
470
+
}
471
471
+
i_139_ = is[i_143_++];
472
472
+
if (i_139_ != 0 && bs[i_141_] == 0) {
473
473
+
is_138_[i_141_++] = i_139_;
474
474
+
} else {
475
475
+
i_141_++;
476
476
+
}
477
477
+
i_139_ = is[i_143_++];
478
478
+
if (i_139_ != 0 && bs[i_141_] == 0) {
479
479
+
is_138_[i_141_++] = i_139_;
480
480
+
} else {
481
481
+
i_141_++;
482
482
+
}
483
483
+
i_139_ = is[i_143_++];
484
484
+
if (i_139_ != 0 && bs[i_141_] == 0) {
485
485
+
is_138_[i_141_++] = i_139_;
486
486
+
} else {
487
487
+
i_141_++;
488
488
+
}
489
489
+
}
490
490
+
for (int i_148_ = i; i_148_ < 0; i_148_++) {
491
491
+
i_139_ = is[i_143_++];
492
492
+
if (i_139_ != 0 && bs[i_141_] == 0) {
493
493
+
is_138_[i_141_++] = i_139_;
494
494
+
} else {
495
495
+
i_141_++;
496
496
+
}
497
497
+
}
498
498
+
i_141_ += i_140_;
499
499
+
i_143_ += i_142_;
500
500
+
}
501
501
+
}
502
502
+
}
+222
src/com/jagex/runescape/cache/media/IndexedImage.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache.media;
2
2
+
3
3
+
import com.jagex.runescape.cache.Archive;
4
4
+
import com.jagex.runescape.media.Rasterizer;
5
5
+
import com.jagex.runescape.net.Buffer;
6
6
+
7
7
+
public class IndexedImage extends Rasterizer {
8
8
+
9
9
+
public byte[] pixels;
10
10
+
public int[] palette;
11
11
+
public int width;
12
12
+
public int height;
13
13
+
public int xDrawOffset;
14
14
+
public int yDrawOffset;
15
15
+
public int maxWidth;
16
16
+
public int maxHeight;
17
17
+
18
18
+
public IndexedImage(Archive archive, String archiveName, int offset) {
19
19
+
Buffer dataBuffer = new Buffer(archive.getFile(archiveName + ".dat"));
20
20
+
Buffer indexBuffer = new Buffer(archive.getFile("index.dat"));
21
21
+
indexBuffer.offset = dataBuffer.getUnsignedLEShort();
22
22
+
maxWidth = indexBuffer.getUnsignedLEShort();
23
23
+
maxHeight = indexBuffer.getUnsignedLEShort();
24
24
+
int palleteLength = indexBuffer.getUnsignedByte();
25
25
+
palette = new int[palleteLength];
26
26
+
for (int index = 0; index < palleteLength - 1; index++) {
27
27
+
palette[index + 1] = indexBuffer.get24BitInt();
28
28
+
}
29
29
+
for (int counter = 0; counter < offset; counter++) {
30
30
+
indexBuffer.offset += 2;
31
31
+
dataBuffer.offset += indexBuffer.getUnsignedLEShort() * indexBuffer.getUnsignedLEShort();
32
32
+
indexBuffer.offset++;
33
33
+
}
34
34
+
xDrawOffset = indexBuffer.getUnsignedByte();
35
35
+
yDrawOffset = indexBuffer.getUnsignedByte();
36
36
+
width = indexBuffer.getUnsignedLEShort();
37
37
+
height = indexBuffer.getUnsignedLEShort();
38
38
+
int type = indexBuffer.getUnsignedByte();
39
39
+
int pixelLength = width * height;
40
40
+
pixels = new byte[pixelLength];
41
41
+
if (type == 0) {
42
42
+
for (int pixel = 0; pixel < pixelLength; pixel++) {
43
43
+
pixels[pixel] = dataBuffer.get();
44
44
+
}
45
45
+
} else if (type == 1) {
46
46
+
for (int x = 0; x < width; x++) {
47
47
+
for (int y = 0; y < height; y++) {
48
48
+
pixels[x + y * width] = dataBuffer.get();
49
49
+
}
50
50
+
}
51
51
+
}
52
52
+
}
53
53
+
54
54
+
public void resizeToHalfMax() {
55
55
+
maxWidth /= 2;
56
56
+
maxHeight /= 2;
57
57
+
byte[] resizedPixels = new byte[maxWidth * maxHeight];
58
58
+
int pixelCount = 0;
59
59
+
for (int y = 0; y < height; y++) {
60
60
+
for (int x = 0; x < width; x++) {
61
61
+
resizedPixels[(x + xDrawOffset >> 1) + (y + yDrawOffset >> 1) * maxWidth] = pixels[pixelCount++];
62
62
+
}
63
63
+
}
64
64
+
pixels = resizedPixels;
65
65
+
width = maxWidth;
66
66
+
height = maxHeight;
67
67
+
xDrawOffset = 0;
68
68
+
yDrawOffset = 0;
69
69
+
}
70
70
+
71
71
+
public void resizeToMax() {
72
72
+
if (width != maxWidth || height != maxHeight) {
73
73
+
byte[] resizedPixels = new byte[maxWidth * maxHeight];
74
74
+
int pixelCount = 0;
75
75
+
for (int y = 0; y < height; y++) {
76
76
+
for (int x = 0; x < width; x++) {
77
77
+
resizedPixels[x + xDrawOffset + (y + yDrawOffset) * maxWidth] = pixels[pixelCount++];
78
78
+
}
79
79
+
}
80
80
+
pixels = resizedPixels;
81
81
+
width = maxWidth;
82
82
+
height = maxHeight;
83
83
+
xDrawOffset = 0;
84
84
+
yDrawOffset = 0;
85
85
+
}
86
86
+
}
87
87
+
88
88
+
public void flipHorizontal() {
89
89
+
byte[] flipedPixels = new byte[width * height];
90
90
+
int pixelCount = 0;
91
91
+
for (int y = 0; y < height; y++) {
92
92
+
for (int x = width - 1; x >= 0; x--) {
93
93
+
flipedPixels[pixelCount++] = pixels[x + y * width];
94
94
+
}
95
95
+
}
96
96
+
pixels = flipedPixels;
97
97
+
xDrawOffset = maxWidth - width - xDrawOffset;
98
98
+
}
99
99
+
100
100
+
public void flipVertical() {
101
101
+
byte[] flipedPixels = new byte[width * height];
102
102
+
int pixelCount = 0;
103
103
+
for (int y = height - 1; y >= 0; y--) {
104
104
+
for (int x = 0; x < width; x++) {
105
105
+
flipedPixels[pixelCount++] = pixels[x + y * width];
106
106
+
}
107
107
+
}
108
108
+
pixels = flipedPixels;
109
109
+
yDrawOffset = maxHeight - height - yDrawOffset;
110
110
+
}
111
111
+
112
112
+
public void mixPalette(int red, int green, int blue) {
113
113
+
for (int index = 0; index < palette.length; index++) {
114
114
+
int r = palette[index] >> 16 & 0xff;
115
115
+
r += red;
116
116
+
if (r < 0) {
117
117
+
r = 0;
118
118
+
} else if (r > 255) {
119
119
+
r = 255;
120
120
+
}
121
121
+
int g = palette[index] >> 8 & 0xff;
122
122
+
g += green;
123
123
+
if (g < 0) {
124
124
+
g = 0;
125
125
+
} else if (g > 255) {
126
126
+
g = 255;
127
127
+
}
128
128
+
int b = palette[index] & 0xff;
129
129
+
b += blue;
130
130
+
if (b < 0) {
131
131
+
b = 0;
132
132
+
} else if (b > 255) {
133
133
+
b = 255;
134
134
+
}
135
135
+
palette[index] = (r << 16) + (g << 8) + b;
136
136
+
}
137
137
+
}
138
138
+
139
139
+
public void drawImage(int x, int y) {
140
140
+
x += xDrawOffset;
141
141
+
y += yDrawOffset;
142
142
+
int offset = x + y * Rasterizer.width;
143
143
+
int originalOffset = 0;
144
144
+
int imageHeight = height;
145
145
+
int imageWidth = width;
146
146
+
int deviation = Rasterizer.width - imageWidth;
147
147
+
int originalDeviation = 0;
148
148
+
if (y < Rasterizer.topY) {
149
149
+
int yOffset = Rasterizer.topY - y;
150
150
+
imageHeight -= yOffset;
151
151
+
y = Rasterizer.topY;
152
152
+
originalOffset += yOffset * imageWidth;
153
153
+
offset += yOffset * Rasterizer.width;
154
154
+
}
155
155
+
if (y + imageHeight > Rasterizer.bottomY) {
156
156
+
imageHeight -= y + imageHeight - Rasterizer.bottomY;
157
157
+
}
158
158
+
if (x < Rasterizer.topX) {
159
159
+
int xOffset = Rasterizer.topX - x;
160
160
+
imageWidth -= xOffset;
161
161
+
x = Rasterizer.topX;
162
162
+
originalOffset += xOffset;
163
163
+
offset += xOffset;
164
164
+
originalDeviation += xOffset;
165
165
+
deviation += xOffset;
166
166
+
}
167
167
+
if (x + imageWidth > Rasterizer.bottomX) {
168
168
+
int xOffset = x + imageWidth - Rasterizer.bottomX;
169
169
+
imageWidth -= xOffset;
170
170
+
originalDeviation += xOffset;
171
171
+
deviation += xOffset;
172
172
+
}
173
173
+
if (imageWidth > 0 && imageHeight > 0) {
174
174
+
copyPixels(pixels, Rasterizer.pixels, imageWidth, imageHeight, offset, originalOffset, deviation,
175
175
+
originalDeviation, palette);
176
176
+
}
177
177
+
}
178
178
+
179
179
+
private void copyPixels(byte[] pixels, int[] rasterizerPixels, int width, int height, int offset,
180
180
+
int originalOffset, int deviation, int originalDeviation, int[] pallete) {
181
181
+
int shiftedWidth = -(width >> 2);
182
182
+
width = -(width & 0x3);
183
183
+
for (int heightCounter = -height; heightCounter < 0; heightCounter++) {
184
184
+
for (int shiftedWidthCounter = shiftedWidth; shiftedWidthCounter < 0; shiftedWidthCounter++) {
185
185
+
int pixel = pixels[originalOffset++];
186
186
+
if (pixel != 0) {
187
187
+
rasterizerPixels[offset++] = pallete[pixel & 0xff];
188
188
+
} else {
189
189
+
offset++;
190
190
+
}
191
191
+
pixel = pixels[originalOffset++];
192
192
+
if (pixel != 0) {
193
193
+
rasterizerPixels[offset++] = pallete[pixel & 0xff];
194
194
+
} else {
195
195
+
offset++;
196
196
+
}
197
197
+
pixel = pixels[originalOffset++];
198
198
+
if (pixel != 0) {
199
199
+
rasterizerPixels[offset++] = pallete[pixel & 0xff];
200
200
+
} else {
201
201
+
offset++;
202
202
+
}
203
203
+
pixel = pixels[originalOffset++];
204
204
+
if (pixel != 0) {
205
205
+
rasterizerPixels[offset++] = pallete[pixel & 0xff];
206
206
+
} else {
207
207
+
offset++;
208
208
+
}
209
209
+
}
210
210
+
for (int widthCounter = width; widthCounter < 0; widthCounter++) {
211
211
+
int pixel = pixels[originalOffset++];
212
212
+
if (pixel != 0) {
213
213
+
rasterizerPixels[offset++] = pallete[pixel & 0xff];
214
214
+
} else {
215
215
+
offset++;
216
216
+
}
217
217
+
}
218
218
+
offset += deviation;
219
219
+
originalOffset += originalDeviation;
220
220
+
}
221
221
+
}
222
222
+
}
+91
src/com/jagex/runescape/cache/media/SpotAnimation.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache.media;
2
2
+
3
3
+
import com.jagex.runescape.cache.Archive;
4
4
+
import com.jagex.runescape.collection.Cache;
5
5
+
import com.jagex.runescape.media.renderable.Model;
6
6
+
import com.jagex.runescape.net.Buffer;
7
7
+
8
8
+
// actually is graphical effects
9
9
+
public class SpotAnimation {
10
10
+
11
11
+
public static int spotAnimationCount;
12
12
+
public static SpotAnimation[] cache;
13
13
+
public int id;
14
14
+
public int modelId;
15
15
+
public int animationId = -1;
16
16
+
public AnimationSequence sequences;
17
17
+
public int[] originalModelColors = new int[6];
18
18
+
public int[] modifiedModelColors = new int[6];
19
19
+
public int resizeXY = 128;
20
20
+
public int resizeZ = 128;
21
21
+
public int rotation;
22
22
+
public int modelLightFalloff;
23
23
+
public int modelLightAmbient;
24
24
+
public static Cache modelCache = new Cache(30);
25
25
+
26
26
+
public static void load(Archive archive) {
27
27
+
Buffer buffer = new Buffer(archive.getFile("spotanim.dat"));
28
28
+
SpotAnimation.spotAnimationCount = buffer.getUnsignedLEShort();
29
29
+
if (SpotAnimation.cache == null) {
30
30
+
SpotAnimation.cache = new SpotAnimation[SpotAnimation.spotAnimationCount];
31
31
+
}
32
32
+
for (int spotAnimation = 0; spotAnimation < SpotAnimation.spotAnimationCount; spotAnimation++) {
33
33
+
if (SpotAnimation.cache[spotAnimation] == null) {
34
34
+
SpotAnimation.cache[spotAnimation] = new SpotAnimation();
35
35
+
}
36
36
+
SpotAnimation.cache[spotAnimation].id = spotAnimation;
37
37
+
SpotAnimation.cache[spotAnimation].loadDefinition(buffer);
38
38
+
}
39
39
+
}
40
40
+
41
41
+
public void loadDefinition(Buffer buffer) {
42
42
+
while (true) {
43
43
+
int attributeId = buffer.getUnsignedByte();
44
44
+
if (attributeId == 0) {
45
45
+
break;
46
46
+
}
47
47
+
if (attributeId == 1) {
48
48
+
modelId = buffer.getUnsignedLEShort();
49
49
+
} else if (attributeId == 2) {
50
50
+
animationId = buffer.getUnsignedLEShort();
51
51
+
if (AnimationSequence.cache != null) {
52
52
+
sequences = AnimationSequence.cache[animationId];
53
53
+
}
54
54
+
} else if (attributeId == 4) {
55
55
+
resizeXY = buffer.getUnsignedLEShort();
56
56
+
} else if (attributeId == 5) {
57
57
+
resizeZ = buffer.getUnsignedLEShort();
58
58
+
} else if (attributeId == 6) {
59
59
+
rotation = buffer.getUnsignedLEShort();
60
60
+
} else if (attributeId == 7) {
61
61
+
modelLightFalloff = buffer.getUnsignedByte();
62
62
+
} else if (attributeId == 8) {
63
63
+
modelLightAmbient = buffer.getUnsignedByte();
64
64
+
} else if (attributeId >= 40 && attributeId < 50) {
65
65
+
originalModelColors[attributeId - 40] = buffer.getUnsignedLEShort();
66
66
+
} else if (attributeId >= 50 && attributeId < 60) {
67
67
+
modifiedModelColors[attributeId - 50] = buffer.getUnsignedLEShort();
68
68
+
} else {
69
69
+
System.out.println("Error unrecognised spotanim config code: " + attributeId);
70
70
+
}
71
71
+
}
72
72
+
}
73
73
+
74
74
+
public Model getModel() {
75
75
+
Model model = (Model) SpotAnimation.modelCache.get(id);
76
76
+
if (model != null) {
77
77
+
return model;
78
78
+
}
79
79
+
model = Model.getModel(modelId);
80
80
+
if (model == null) {
81
81
+
return null;
82
82
+
}
83
83
+
for (int nodelColor = 0; nodelColor < 6; nodelColor++) {
84
84
+
if (originalModelColors[0] != 0) {
85
85
+
model.recolor(originalModelColors[nodelColor], modifiedModelColors[nodelColor]);
86
86
+
}
87
87
+
}
88
88
+
SpotAnimation.modelCache.put(model, id);
89
89
+
return model;
90
90
+
}
91
91
+
}
+435
src/com/jagex/runescape/cache/media/TypeFace.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache.media;
2
2
+
3
3
+
import java.util.Random;
4
4
+
5
5
+
import com.jagex.runescape.cache.Archive;
6
6
+
import com.jagex.runescape.media.Rasterizer;
7
7
+
import com.jagex.runescape.net.Buffer;
8
8
+
9
9
+
public class TypeFace extends Rasterizer {
10
10
+
11
11
+
protected byte[][] characterPixels = new byte[256][];
12
12
+
protected int[] characterWidths = new int[256];
13
13
+
protected int[] characterHeights = new int[256];
14
14
+
protected int[] characterXOffsets = new int[256];
15
15
+
protected int[] characterYOffsets = new int[256];
16
16
+
public int[] characterScreenWidths = new int[256];
17
17
+
public int characterDefaultHeight;
18
18
+
protected Random random = new Random();
19
19
+
protected boolean strikeThrough = false;
20
20
+
21
21
+
public TypeFace(boolean large, String archiveName, Archive archive) {
22
22
+
Buffer dataBuffer = new Buffer(archive.getFile(archiveName + ".dat"));
23
23
+
Buffer indexBuffer = new Buffer(archive.getFile("index.dat"));
24
24
+
indexBuffer.offset = dataBuffer.getUnsignedLEShort() + 7;
25
25
+
indexBuffer.getUnsignedByte(); // dummy
26
26
+
27
27
+
for (int character = 0; character < 256; character++) {
28
28
+
characterXOffsets[character] = indexBuffer.getUnsignedByte();
29
29
+
characterYOffsets[character] = indexBuffer.getUnsignedByte();
30
30
+
int characterWidth = characterWidths[character] = indexBuffer.getUnsignedLEShort();
31
31
+
int characterHeight = characterHeights[character] = indexBuffer.getUnsignedLEShort();
32
32
+
int characterType = indexBuffer.getUnsignedByte();
33
33
+
int characterSize = characterWidth * characterHeight;
34
34
+
characterPixels[character] = new byte[characterSize];
35
35
+
if (characterType == 0) {
36
36
+
for (int pixel = 0; pixel < characterSize; pixel++) {
37
37
+
characterPixels[character][pixel] = dataBuffer.get();
38
38
+
}
39
39
+
} else if (characterType == 1) {
40
40
+
for (int characterX = 0; characterX < characterWidth; characterX++) {
41
41
+
for (int characterY = 0; characterY < characterHeight; characterY++) {
42
42
+
characterPixels[character][characterX + characterY * characterWidth] = dataBuffer.get();
43
43
+
}
44
44
+
}
45
45
+
}
46
46
+
if (characterHeight > characterDefaultHeight && character < 128) {
47
47
+
characterDefaultHeight = characterHeight;
48
48
+
}
49
49
+
characterXOffsets[character] = 1;
50
50
+
characterScreenWidths[character] = characterWidth + 2;
51
51
+
int pixelCount = 0;
52
52
+
for (int characterY = characterHeight / 7; characterY < characterHeight; characterY++) {
53
53
+
pixelCount += characterPixels[character][characterY * characterWidth];
54
54
+
}
55
55
+
if (pixelCount <= characterHeight / 7) {
56
56
+
characterScreenWidths[character]--;
57
57
+
characterXOffsets[character] = 0;
58
58
+
}
59
59
+
pixelCount = 0;
60
60
+
for (int characterY = characterHeight / 7; characterY < characterHeight; characterY++) {
61
61
+
pixelCount += characterPixels[character][characterWidth - 1 + characterY * characterWidth];
62
62
+
}
63
63
+
if (pixelCount <= characterHeight / 7) {
64
64
+
characterScreenWidths[character]--;
65
65
+
}
66
66
+
}
67
67
+
if (large) {
68
68
+
characterScreenWidths[32] = characterScreenWidths[73];
69
69
+
} else {
70
70
+
characterScreenWidths[32] = characterScreenWidths[105];
71
71
+
}
72
72
+
}
73
73
+
74
74
+
public void drawStringRight(String string, int x, int y, int color) {
75
75
+
drawString(string, x - getStringWidth(string), y, color);
76
76
+
}
77
77
+
78
78
+
public void drawStringLeft(String string, int x, int y, int color) {
79
79
+
drawString(string, x - getStringWidth(string) / 2, y, color);
80
80
+
}
81
81
+
82
82
+
public void drawStringCenter(String string, int x, int y, int color, boolean shadowed) {
83
83
+
drawShadowedString(string, x - getStringEffectWidth(string) / 2, y, shadowed, color);
84
84
+
}
85
85
+
86
86
+
public int getStringEffectWidth(String string) {
87
87
+
if (string == null) {
88
88
+
return 0;
89
89
+
}
90
90
+
int width = 0;
91
91
+
for (int character = 0; character < string.length(); character++) {
92
92
+
if (string.charAt(character) == '@' && character + 4 < string.length()
93
93
+
&& string.charAt(character + 4) == '@') {
94
94
+
character += 4;
95
95
+
} else {
96
96
+
width += characterScreenWidths[string.charAt(character)];
97
97
+
}
98
98
+
}
99
99
+
return width;
100
100
+
}
101
101
+
102
102
+
public int getStringWidth(String string) {
103
103
+
if (string == null) {
104
104
+
return 0;
105
105
+
}
106
106
+
int width = 0;
107
107
+
for (int character = 0; character < string.length(); character++) {
108
108
+
width += characterScreenWidths[string.charAt(character)];
109
109
+
}
110
110
+
return width;
111
111
+
}
112
112
+
113
113
+
public void drawString(String string, int x, int y, int color) {
114
114
+
if (string != null) {
115
115
+
y -= characterDefaultHeight;
116
116
+
for (int index = 0; index < string.length(); index++) {
117
117
+
char character = string.charAt(index);
118
118
+
if (character != ' ') {
119
119
+
drawCharacter(characterPixels[character], x + characterXOffsets[character], y
120
120
+
+ characterYOffsets[character], characterWidths[character], characterHeights[character],
121
121
+
color);
122
122
+
}
123
123
+
x += characterScreenWidths[character];
124
124
+
}
125
125
+
}
126
126
+
}
127
127
+
128
128
+
public void drawCenteredStringWaveY(String string, int x, int y, int wave, int color) {
129
129
+
if (string != null) {
130
130
+
x -= getStringWidth(string) / 2;
131
131
+
y -= characterDefaultHeight;
132
132
+
for (int index = 0; index < string.length(); index++) {
133
133
+
char character = string.charAt(index);
134
134
+
if (character != ' ') {
135
135
+
drawCharacter(characterPixels[character], x + characterXOffsets[character], y
136
136
+
+ characterYOffsets[character] + (int) (Math.sin(index / 2.0 + wave / 5.0) * 5.0),
137
137
+
characterWidths[character], characterHeights[character], color);
138
138
+
}
139
139
+
x += characterScreenWidths[character];
140
140
+
}
141
141
+
}
142
142
+
}
143
143
+
144
144
+
public void drawCeneteredStringWaveXY(String string, int x, int y, int wave, int color) {
145
145
+
if (string != null) {
146
146
+
x -= getStringWidth(string) / 2;
147
147
+
y -= characterDefaultHeight;
148
148
+
for (int index = 0; index < string.length(); index++) {
149
149
+
char character = string.charAt(index);
150
150
+
if (character != ' ') {
151
151
+
drawCharacter(characterPixels[character],
152
152
+
x + characterXOffsets[character] + (int) (Math.sin(index / 5.0 + wave / 5.0) * 5.0), y
153
153
+
+ characterYOffsets[character] + (int) (Math.sin(index / 3.0 + wave / 5.0) * 5.0),
154
154
+
characterWidths[character], characterHeights[character], color);
155
155
+
}
156
156
+
x += characterScreenWidths[character];
157
157
+
}
158
158
+
}
159
159
+
}
160
160
+
161
161
+
public void drawCenteredStringWaveXYMove(String string, int x, int y, int waveAmount, int waveSpeed, int color) {
162
162
+
if (string != null) {
163
163
+
double speed = 7.0 - waveSpeed / 8.0;
164
164
+
if (speed < 0.0) {
165
165
+
speed = 0.0;
166
166
+
}
167
167
+
x -= getStringWidth(string) / 2;
168
168
+
y -= characterDefaultHeight;
169
169
+
for (int index = 0; index < string.length(); index++) {
170
170
+
char character = string.charAt(index);
171
171
+
if (character != ' ') {
172
172
+
drawCharacter(characterPixels[character], x + characterXOffsets[character], y
173
173
+
+ characterYOffsets[character] + (int) (Math.sin(index / 1.5 + waveAmount) * speed),
174
174
+
characterWidths[character], characterHeights[character], color);
175
175
+
}
176
176
+
x += characterScreenWidths[character];
177
177
+
}
178
178
+
}
179
179
+
}
180
180
+
181
181
+
public void drawShadowedString(String string, int x, int y, boolean shadow, int color) {
182
182
+
strikeThrough = false;
183
183
+
int originalX = x;
184
184
+
if (string != null) {
185
185
+
y -= characterDefaultHeight;
186
186
+
for (int character = 0; character < string.length(); character++) {
187
187
+
if (string.charAt(character) == '@' && character + 4 < string.length()
188
188
+
&& string.charAt(character + 4) == '@') {
189
189
+
int stringColor = getColor(string.substring(character + 1, character + 4));
190
190
+
if (stringColor != -1) {
191
191
+
color = stringColor;
192
192
+
}
193
193
+
character += 4;
194
194
+
} else {
195
195
+
char c = string.charAt(character);
196
196
+
if (c != ' ') {
197
197
+
if (shadow) {
198
198
+
drawCharacter(characterPixels[c], x + characterXOffsets[c] + 1, y + characterYOffsets[c]
199
199
+
+ 1, characterWidths[c], characterHeights[c], 0);
200
200
+
}
201
201
+
drawCharacter(characterPixels[c], x + characterXOffsets[c], y + characterYOffsets[c],
202
202
+
characterWidths[c], characterHeights[c], color);
203
203
+
}
204
204
+
x += characterScreenWidths[c];
205
205
+
}
206
206
+
}
207
207
+
if (!strikeThrough) {
208
208
+
return;
209
209
+
}
210
210
+
Rasterizer.drawHorizontalLine(originalX, y + (int) (characterDefaultHeight * 0.7), x - originalX, 8388608);
211
211
+
}
212
212
+
}
213
213
+
214
214
+
public void drawShadowedSeededAlphaString(String string, int x, int y, int seed, int color) {
215
215
+
if (string != null) {
216
216
+
random.setSeed(seed);
217
217
+
int alpha = 192 + (random.nextInt() & 0x1f);
218
218
+
y -= characterDefaultHeight;
219
219
+
for (int index = 0; index < string.length(); index++) {
220
220
+
if (string.charAt(index) == '@' && index + 4 < string.length() && string.charAt(index + 4) == '@') {
221
221
+
int stringColor = getColor(string.substring(index + 1, index + 4));
222
222
+
if (stringColor != -1) {
223
223
+
color = stringColor;
224
224
+
}
225
225
+
index += 4;
226
226
+
} else {
227
227
+
char c = string.charAt(index);
228
228
+
if (c != ' ') {
229
229
+
drawAlphaCharacter(192, x + characterXOffsets[c] + 1, characterPixels[c], characterWidths[c], y
230
230
+
+ characterYOffsets[c] + 1, characterHeights[c], 0);
231
231
+
drawAlphaCharacter(alpha, x + characterXOffsets[c], characterPixels[c], characterWidths[c], y
232
232
+
+ characterYOffsets[c], characterHeights[c], color);
233
233
+
}
234
234
+
x += characterScreenWidths[c];
235
235
+
if ((random.nextInt() & 0x3) == 0) {
236
236
+
x++;
237
237
+
}
238
238
+
}
239
239
+
}
240
240
+
}
241
241
+
}
242
242
+
243
243
+
public int getColor(String color) {
244
244
+
if (color.equals("red")) {
245
245
+
return 16711680;
246
246
+
}
247
247
+
if (color.equals("gre")) {
248
248
+
return 65280;
249
249
+
}
250
250
+
if (color.equals("blu")) {
251
251
+
return 255;
252
252
+
}
253
253
+
if (color.equals("yel")) {
254
254
+
return 16776960;
255
255
+
}
256
256
+
if (color.equals("cya")) {
257
257
+
return 65535;
258
258
+
}
259
259
+
if (color.equals("mag")) {
260
260
+
return 16711935;
261
261
+
}
262
262
+
if (color.equals("whi")) {
263
263
+
return 16777215;
264
264
+
}
265
265
+
if (color.equals("bla")) {
266
266
+
return 0;
267
267
+
}
268
268
+
if (color.equals("lre")) {
269
269
+
return 16748608;
270
270
+
}
271
271
+
if (color.equals("dre")) {
272
272
+
return 8388608;
273
273
+
}
274
274
+
if (color.equals("dbl")) {
275
275
+
return 128;
276
276
+
}
277
277
+
if (color.equals("or1")) {
278
278
+
return 16756736;
279
279
+
}
280
280
+
if (color.equals("or2")) {
281
281
+
return 16740352;
282
282
+
}
283
283
+
if (color.equals("or3")) {
284
284
+
return 16723968;
285
285
+
}
286
286
+
if (color.equals("gr1")) {
287
287
+
return 12648192;
288
288
+
}
289
289
+
if (color.equals("gr2")) {
290
290
+
return 8453888;
291
291
+
}
292
292
+
if (color.equals("gr3")) {
293
293
+
return 4259584;
294
294
+
}
295
295
+
if (color.equals("str")) {
296
296
+
strikeThrough = true;
297
297
+
}
298
298
+
if (color.equals("end")) {
299
299
+
strikeThrough = false;
300
300
+
}
301
301
+
return -1;
302
302
+
}
303
303
+
304
304
+
private void drawCharacter(byte[] pixels, int x, int y, int width, int height, int color) {
305
305
+
int rasterizerPixel = x + y * Rasterizer.width;
306
306
+
int remainingWidth = Rasterizer.width - width;
307
307
+
int characterPixelOffset = 0;
308
308
+
int characterPixel = 0;
309
309
+
if (y < Rasterizer.topY) {
310
310
+
int offsetY = Rasterizer.topY - y;
311
311
+
height -= offsetY;
312
312
+
y = Rasterizer.topY;
313
313
+
characterPixel += offsetY * width;
314
314
+
rasterizerPixel += offsetY * Rasterizer.width;
315
315
+
}
316
316
+
if (y + height >= Rasterizer.bottomY) {
317
317
+
height -= y + height - Rasterizer.bottomY + 1;
318
318
+
}
319
319
+
if (x < Rasterizer.topX) {
320
320
+
int offsetX = Rasterizer.topX - x;
321
321
+
width -= offsetX;
322
322
+
x = Rasterizer.topX;
323
323
+
characterPixel += offsetX;
324
324
+
rasterizerPixel += offsetX;
325
325
+
characterPixelOffset += offsetX;
326
326
+
remainingWidth += offsetX;
327
327
+
}
328
328
+
if (x + width >= Rasterizer.bottomX) {
329
329
+
int endOffsetX = x + width - Rasterizer.bottomX + 1;
330
330
+
width -= endOffsetX;
331
331
+
characterPixelOffset += endOffsetX;
332
332
+
remainingWidth += endOffsetX;
333
333
+
}
334
334
+
if (width > 0 && height > 0) {
335
335
+
drawCharacterPixels(pixels, Rasterizer.pixels, characterPixel, rasterizerPixel, characterPixelOffset,
336
336
+
remainingWidth, width, height, color);
337
337
+
}
338
338
+
}
339
339
+
340
340
+
private void drawCharacterPixels(byte[] characterPixels, int[] rasterizerPixels, int characterPixel,
341
341
+
int rasterizerPixel, int characterPixelOffset, int rasterizerPixelOffset, int width, int height, int color) {
342
342
+
int negativeQuaterWidth = -(width >> 2);
343
343
+
int negativeFirstTwoWidthBits = -(width & 0x3);
344
344
+
for (int heightCounter = -height; heightCounter < 0; heightCounter++) {
345
345
+
for (int widthCounter = negativeQuaterWidth; widthCounter < 0; widthCounter++) {
346
346
+
if (characterPixels[characterPixel++] != 0) {
347
347
+
rasterizerPixels[rasterizerPixel++] = color;
348
348
+
} else {
349
349
+
rasterizerPixel++;
350
350
+
}
351
351
+
if (characterPixels[characterPixel++] != 0) {
352
352
+
rasterizerPixels[rasterizerPixel++] = color;
353
353
+
} else {
354
354
+
rasterizerPixel++;
355
355
+
}
356
356
+
if (characterPixels[characterPixel++] != 0) {
357
357
+
rasterizerPixels[rasterizerPixel++] = color;
358
358
+
} else {
359
359
+
rasterizerPixel++;
360
360
+
}
361
361
+
if (characterPixels[characterPixel++] != 0) {
362
362
+
rasterizerPixels[rasterizerPixel++] = color;
363
363
+
} else {
364
364
+
rasterizerPixel++;
365
365
+
}
366
366
+
}
367
367
+
for (int widthCounter = negativeFirstTwoWidthBits; widthCounter < 0; widthCounter++) {
368
368
+
if (characterPixels[characterPixel++] != 0) {
369
369
+
rasterizerPixels[rasterizerPixel++] = color;
370
370
+
} else {
371
371
+
rasterizerPixel++;
372
372
+
}
373
373
+
}
374
374
+
rasterizerPixel += rasterizerPixelOffset;
375
375
+
characterPixel += characterPixelOffset;
376
376
+
}
377
377
+
}
378
378
+
379
379
+
private void drawAlphaCharacter(int alpha, int x, byte[] characterPixels, int width, int y, int height, int color) {
380
380
+
int rasterizerPixel = x + y * Rasterizer.width;
381
381
+
int rasterizerPixelOffset = Rasterizer.width - width;
382
382
+
int characterPixelOffset = 0;
383
383
+
int characterPixel = 0;
384
384
+
if (y < Rasterizer.topY) {
385
385
+
int yOffset = Rasterizer.topY - y;
386
386
+
height -= yOffset;
387
387
+
y = Rasterizer.topY;
388
388
+
characterPixel += yOffset * width;
389
389
+
rasterizerPixel += yOffset * Rasterizer.width;
390
390
+
}
391
391
+
if (y + height >= Rasterizer.bottomY) {
392
392
+
height -= y + height - Rasterizer.bottomY + 1;
393
393
+
}
394
394
+
if (x < Rasterizer.topX) {
395
395
+
int xOffset = Rasterizer.topX - x;
396
396
+
width -= xOffset;
397
397
+
x = Rasterizer.topX;
398
398
+
characterPixel += xOffset;
399
399
+
rasterizerPixel += xOffset;
400
400
+
characterPixelOffset += xOffset;
401
401
+
rasterizerPixelOffset += xOffset;
402
402
+
}
403
403
+
if (x + width >= Rasterizer.bottomX) {
404
404
+
int widthoffset = x + width - Rasterizer.bottomX + 1;
405
405
+
width -= widthoffset;
406
406
+
characterPixelOffset += widthoffset;
407
407
+
rasterizerPixelOffset += widthoffset;
408
408
+
}
409
409
+
if (width > 0 && height > 0) {
410
410
+
drawCharacterPixelsAlpha(characterPixels, Rasterizer.pixels, characterPixel, rasterizerPixel,
411
411
+
characterPixelOffset, rasterizerPixelOffset, width, height, color, alpha);
412
412
+
}
413
413
+
}
414
414
+
415
415
+
private void drawCharacterPixelsAlpha(byte[] characterPixels, int[] rasterizerPixels, int characterPixel,
416
416
+
int rasterizerPixel, int characterPixelOffset, int rasterizerPixelOffset, int width, int height, int color,
417
417
+
int alpha) {
418
418
+
color = ((color & 0xff00ff) * alpha & ~0xff00ff) + ((color & 0xff00) * alpha & 0xff0000) >> 8;
419
419
+
alpha = 256 - alpha;
420
420
+
for (int heightCounter = -height; heightCounter < 0; heightCounter++) {
421
421
+
for (int widthCounter = -width; widthCounter < 0; widthCounter++) {
422
422
+
if (characterPixels[characterPixel++] != 0) {
423
423
+
int rasterizerPixelColor = rasterizerPixels[rasterizerPixel];
424
424
+
rasterizerPixels[rasterizerPixel++] = (((rasterizerPixelColor & 0xff00ff) * alpha & ~0xff00ff)
425
425
+
+ ((rasterizerPixelColor & 0xff00) * alpha & 0xff0000) >> 8)
426
426
+
+ color;
427
427
+
} else {
428
428
+
rasterizerPixel++;
429
429
+
}
430
430
+
}
431
431
+
rasterizerPixel += rasterizerPixelOffset;
432
432
+
characterPixel += characterPixelOffset;
433
433
+
}
434
434
+
}
435
435
+
}
+373
src/com/jagex/runescape/cache/media/Widget.java
Reviewed
···
1
1
+
package com.jagex.runescape.cache.media;
2
2
+
3
3
+
import com.jagex.runescape.cache.Archive;
4
4
+
import com.jagex.runescape.collection.Cache;
5
5
+
import com.jagex.runescape.Game;
6
6
+
import com.jagex.runescape.cache.def.ActorDefinition;
7
7
+
import com.jagex.runescape.cache.def.ItemDefinition;
8
8
+
import com.jagex.runescape.media.Animation;
9
9
+
import com.jagex.runescape.media.renderable.Model;
10
10
+
import com.jagex.runescape.net.Buffer;
11
11
+
import com.jagex.runescape.util.TextUtils;
12
12
+
13
13
+
public class Widget {
14
14
+
15
15
+
public ImageRGB disabledImage;
16
16
+
public int animationDuration;
17
17
+
public ImageRGB[] images;
18
18
+
public static Widget[] cache;
19
19
+
public int unknownOne;
20
20
+
public int[] conditionValues;
21
21
+
public int contentType;
22
22
+
public int[] imageX;
23
23
+
public int disabledHoveredColor;
24
24
+
public int actionType;
25
25
+
public String spellName;
26
26
+
public int enabledColor;
27
27
+
public int width;
28
28
+
public String tooltip;
29
29
+
public String selectedActionName;
30
30
+
public boolean typeFaceCentered;
31
31
+
public int scrollPosition;
32
32
+
public String[] actions;
33
33
+
public int[][] opcodes;
34
34
+
public boolean filled;
35
35
+
public String enabledText;
36
36
+
public int hoveredPopup;
37
37
+
public int itemSpritePadsX;
38
38
+
public int disabledColor;
39
39
+
public int modelType;
40
40
+
public int modelId;
41
41
+
public boolean itemDeletesDraged;
42
42
+
public int parentId;
43
43
+
public int spellUsableOn;
44
44
+
private static Cache spriteCache;
45
45
+
public int enabledHoveredColor;
46
46
+
public int[] children;
47
47
+
public int[] childrenX;
48
48
+
public boolean itemUsable;
49
49
+
public TypeFace typeFaces;
50
50
+
public int itemSpritePadsY;
51
51
+
public int[] conditionTypes;
52
52
+
public int animationFrame;
53
53
+
public int[] imageY;
54
54
+
public String disabledText;
55
55
+
public boolean isInventory;
56
56
+
public int id;
57
57
+
public boolean unknownTwo;
58
58
+
public int[] itemAmounts;
59
59
+
public int[] items;
60
60
+
public byte alpha;
61
61
+
public int enabledModelType;
62
62
+
public int enabledModelId;
63
63
+
public int disabledAnimation;
64
64
+
public int enabledAnimation;
65
65
+
public boolean itemSwapable;
66
66
+
public ImageRGB enabledImage;
67
67
+
public int scrollLimit;
68
68
+
public int type;
69
69
+
public int x;
70
70
+
static Cache modelCache = new Cache(30);
71
71
+
public int y;
72
72
+
public boolean hiddenUntilHovered;
73
73
+
public int height;
74
74
+
public boolean typeFaceShadowed;
75
75
+
public int zoom;
76
76
+
public int rotationX;
77
77
+
public int rotationY;
78
78
+
public int[] childrenY;
79
79
+
80
80
+
public void swapItems(int originalSlot, int newSlot) {
81
81
+
int originalItem = items[originalSlot];
82
82
+
items[originalSlot] = items[newSlot];
83
83
+
items[newSlot] = originalItem;
84
84
+
originalItem = itemAmounts[originalSlot];
85
85
+
itemAmounts[originalSlot] = itemAmounts[newSlot];
86
86
+
itemAmounts[newSlot] = originalItem;
87
87
+
}
88
88
+
89
89
+
public static void load(Archive widgetArchive, TypeFace[] fonts, Archive mediaArchive) {
90
90
+
Widget.spriteCache = new Cache(50000);
91
91
+
Buffer buffer = new Buffer(widgetArchive.getFile("data"));
92
92
+
int parentId = -1;
93
93
+
int widgetCount = buffer.getUnsignedLEShort();
94
94
+
Widget.cache = new Widget[widgetCount];
95
95
+
while (buffer.offset < buffer.payload.length) {
96
96
+
int widgetIndex = buffer.getUnsignedLEShort();
97
97
+
if (widgetIndex == 65535) {
98
98
+
parentId = buffer.getUnsignedLEShort();
99
99
+
widgetIndex = buffer.getUnsignedLEShort();
100
100
+
}
101
101
+
Widget widget = Widget.cache[widgetIndex] = new Widget();
102
102
+
widget.id = widgetIndex;
103
103
+
widget.parentId = parentId;
104
104
+
widget.type = buffer.getUnsignedByte();
105
105
+
widget.actionType = buffer.getUnsignedByte();
106
106
+
widget.contentType = buffer.getUnsignedLEShort();
107
107
+
widget.width = buffer.getUnsignedLEShort();
108
108
+
widget.height = buffer.getUnsignedLEShort();
109
109
+
widget.alpha = (byte) buffer.getUnsignedByte();
110
110
+
widget.hoveredPopup = buffer.getUnsignedByte();
111
111
+
if (widget.hoveredPopup != 0) {
112
112
+
widget.hoveredPopup = (widget.hoveredPopup - 1 << 8) + buffer.getUnsignedByte();
113
113
+
} else {
114
114
+
widget.hoveredPopup = -1;
115
115
+
}
116
116
+
int conditionCount = buffer.getUnsignedByte();
117
117
+
if (conditionCount > 0) {
118
118
+
widget.conditionTypes = new int[conditionCount];
119
119
+
widget.conditionValues = new int[conditionCount];
120
120
+
for (int condition = 0; condition < conditionCount; condition++) {
121
121
+
widget.conditionTypes[condition] = buffer.getUnsignedByte();
122
122
+
widget.conditionValues[condition] = buffer.getUnsignedLEShort();
123
123
+
}
124
124
+
}
125
125
+
int opcodeCount = buffer.getUnsignedByte();
126
126
+
if (opcodeCount > 0) {
127
127
+
widget.opcodes = new int[opcodeCount][];
128
128
+
for (int opcode = 0; opcode < opcodeCount; opcode++) {
129
129
+
int subOpcodeCount = buffer.getUnsignedLEShort();
130
130
+
widget.opcodes[opcode] = new int[subOpcodeCount];
131
131
+
for (int subOpcode = 0; subOpcode < subOpcodeCount; subOpcode++) {
132
132
+
widget.opcodes[opcode][subOpcode] = buffer.getUnsignedLEShort();
133
133
+
}
134
134
+
}
135
135
+
}
136
136
+
if (widget.type == 0) {
137
137
+
widget.scrollLimit = buffer.getUnsignedLEShort();
138
138
+
widget.hiddenUntilHovered = buffer.getUnsignedByte() == 1;
139
139
+
int childrenCount = buffer.getUnsignedLEShort();
140
140
+
widget.children = new int[childrenCount];
141
141
+
widget.childrenX = new int[childrenCount];
142
142
+
widget.childrenY = new int[childrenCount];
143
143
+
for (int child = 0; child < childrenCount; child++) {
144
144
+
widget.children[child] = buffer.getUnsignedLEShort();
145
145
+
widget.childrenX[child] = buffer.getShort();
146
146
+
widget.childrenY[child] = buffer.getShort();
147
147
+
}
148
148
+
}
149
149
+
if (widget.type == 1) {
150
150
+
widget.unknownOne = buffer.getUnsignedLEShort();
151
151
+
widget.unknownTwo = buffer.getUnsignedByte() == 1;
152
152
+
}
153
153
+
if (widget.type == 2) {
154
154
+
widget.items = new int[widget.width * widget.height];
155
155
+
widget.itemAmounts = new int[widget.width * widget.height];
156
156
+
widget.itemSwapable = buffer.getUnsignedByte() == 1;
157
157
+
widget.isInventory = buffer.getUnsignedByte() == 1;
158
158
+
widget.itemUsable = buffer.getUnsignedByte() == 1;
159
159
+
widget.itemDeletesDraged = buffer.getUnsignedByte() == 1;
160
160
+
widget.itemSpritePadsX = buffer.getUnsignedByte();
161
161
+
widget.itemSpritePadsY = buffer.getUnsignedByte();
162
162
+
widget.imageX = new int[20];
163
163
+
widget.imageY = new int[20];
164
164
+
widget.images = new ImageRGB[20];
165
165
+
for (int sprite = 0; sprite < 20; sprite++) {
166
166
+
int hasSprite = buffer.getUnsignedByte();
167
167
+
if (hasSprite == 1) {
168
168
+
widget.imageX[sprite] = buffer.getShort();
169
169
+
widget.imageY[sprite] = buffer.getShort();
170
170
+
String spriteName = buffer.getString();
171
171
+
if (mediaArchive != null && spriteName.length() > 0) {
172
172
+
int spriteId = spriteName.lastIndexOf(",");
173
173
+
widget.images[sprite] = Widget.getImage(
174
174
+
Integer.parseInt(spriteName.substring(spriteId + 1)), mediaArchive,
175
175
+
spriteName.substring(0, spriteId));
176
176
+
}
177
177
+
}
178
178
+
}
179
179
+
widget.actions = new String[5];
180
180
+
for (int action = 0; action < 5; action++) {
181
181
+
widget.actions[action] = buffer.getString();
182
182
+
if (widget.actions[action].length() == 0) {
183
183
+
widget.actions[action] = null;
184
184
+
}
185
185
+
}
186
186
+
}
187
187
+
if (widget.type == 3) {
188
188
+
widget.filled = buffer.getUnsignedByte() == 1;
189
189
+
}
190
190
+
if (widget.type == 4 || widget.type == 1) {
191
191
+
widget.typeFaceCentered = buffer.getUnsignedByte() == 1;
192
192
+
int typeFace = buffer.getUnsignedByte();
193
193
+
if (fonts != null) {
194
194
+
widget.typeFaces = fonts[typeFace];
195
195
+
}
196
196
+
widget.typeFaceShadowed = buffer.getUnsignedByte() == 1;
197
197
+
}
198
198
+
if (widget.type == 4) {
199
199
+
widget.disabledText = buffer.getString();
200
200
+
widget.enabledText = buffer.getString();
201
201
+
}
202
202
+
if (widget.type == 1 || widget.type == 3 || widget.type == 4) {
203
203
+
widget.disabledColor = buffer.getInt();
204
204
+
}
205
205
+
if (widget.type == 3 || widget.type == 4) {
206
206
+
widget.enabledColor = buffer.getInt();
207
207
+
widget.disabledHoveredColor = buffer.getInt();
208
208
+
widget.enabledHoveredColor = buffer.getInt();
209
209
+
}
210
210
+
if (widget.type == 5) {
211
211
+
String spriteName = buffer.getString();
212
212
+
if (mediaArchive != null && spriteName.length() > 0) {
213
213
+
int spriteId = spriteName.lastIndexOf(",");
214
214
+
widget.disabledImage = Widget.getImage(Integer.parseInt(spriteName.substring(spriteId + 1)),
215
215
+
mediaArchive, spriteName.substring(0, spriteId));
216
216
+
}
217
217
+
spriteName = buffer.getString();
218
218
+
if (mediaArchive != null && spriteName.length() > 0) {
219
219
+
int spriteId = spriteName.lastIndexOf(",");
220
220
+
widget.enabledImage = Widget.getImage(Integer.parseInt(spriteName.substring(spriteId + 1)),
221
221
+
mediaArchive, spriteName.substring(0, spriteId));
222
222
+
}
223
223
+
}
224
224
+
if (widget.type == 6) {
225
225
+
widgetIndex = buffer.getUnsignedByte();
226
226
+
if (widgetIndex != 0) {
227
227
+
widget.modelType = 1;
228
228
+
widget.modelId = (widgetIndex - 1 << 8) + buffer.getUnsignedByte();
229
229
+
}
230
230
+
widgetIndex = buffer.getUnsignedByte();
231
231
+
if (widgetIndex != 0) {
232
232
+
widget.enabledModelType = 1;
233
233
+
widget.enabledModelId = (widgetIndex - 1 << 8) + buffer.getUnsignedByte();
234
234
+
}
235
235
+
widgetIndex = buffer.getUnsignedByte();
236
236
+
if (widgetIndex != 0) {
237
237
+
widget.disabledAnimation = (widgetIndex - 1 << 8) + buffer.getUnsignedByte();
238
238
+
} else {
239
239
+
widget.disabledAnimation = -1;
240
240
+
}
241
241
+
widgetIndex = buffer.getUnsignedByte();
242
242
+
if (widgetIndex != 0) {
243
243
+
widget.enabledAnimation = (widgetIndex - 1 << 8) + buffer.getUnsignedByte();
244
244
+
} else {
245
245
+
widget.enabledAnimation = -1;
246
246
+
}
247
247
+
widget.zoom = buffer.getUnsignedLEShort();
248
248
+
widget.rotationX = buffer.getUnsignedLEShort();
249
249
+
widget.rotationY = buffer.getUnsignedLEShort();
250
250
+
}
251
251
+
if (widget.type == 7) {
252
252
+
widget.items = new int[widget.width * widget.height];
253
253
+
widget.itemAmounts = new int[widget.width * widget.height];
254
254
+
widget.typeFaceCentered = buffer.getUnsignedByte() == 1;
255
255
+
int typeFaceCount = buffer.getUnsignedByte();
256
256
+
if (fonts != null) {
257
257
+
widget.typeFaces = fonts[typeFaceCount];
258
258
+
}
259
259
+
widget.typeFaceShadowed = buffer.getUnsignedByte() == 1;
260
260
+
widget.disabledColor = buffer.getInt();
261
261
+
widget.itemSpritePadsX = buffer.getShort();
262
262
+
widget.itemSpritePadsY = buffer.getShort();
263
263
+
widget.isInventory = buffer.getUnsignedByte() == 1;
264
264
+
widget.actions = new String[5];
265
265
+
for (int action = 0; action < 5; action++) {
266
266
+
widget.actions[action] = buffer.getString();
267
267
+
if (widget.actions[action].length() == 0) {
268
268
+
widget.actions[action] = null;
269
269
+
}
270
270
+
}
271
271
+
}
272
272
+
if (widget.actionType == 2 || widget.type == 2) {
273
273
+
widget.selectedActionName = buffer.getString();
274
274
+
widget.spellName = buffer.getString();
275
275
+
widget.spellUsableOn = buffer.getUnsignedLEShort();
276
276
+
}
277
277
+
if (widget.type == 8) {
278
278
+
widget.disabledText = buffer.getString();
279
279
+
}
280
280
+
if (widget.actionType == 1 || widget.actionType == 4 || widget.actionType == 5 || widget.actionType == 6) {
281
281
+
widget.tooltip = buffer.getString();
282
282
+
if (widget.tooltip.length() == 0) {
283
283
+
if (widget.actionType == 1) {
284
284
+
widget.tooltip = "Ok";
285
285
+
}
286
286
+
if (widget.actionType == 4) {
287
287
+
widget.tooltip = "Select";
288
288
+
}
289
289
+
if (widget.actionType == 5) {
290
290
+
widget.tooltip = "Select";
291
291
+
}
292
292
+
if (widget.actionType == 6) {
293
293
+
widget.tooltip = "Continue";
294
294
+
}
295
295
+
}
296
296
+
}
297
297
+
}
298
298
+
Widget.spriteCache = null;
299
299
+
}
300
300
+
301
301
+
private Model getModel(int modelType, int modelId) {
302
302
+
Model model = (Model) Widget.modelCache.get((modelType << 16) + modelId);
303
303
+
if (model != null) {
304
304
+
return model;
305
305
+
}
306
306
+
if (modelType == 1) {
307
307
+
model = Model.getModel(modelId);
308
308
+
}
309
309
+
if (modelType == 2) {
310
310
+
model = ActorDefinition.getDefinition(modelId).getHeadModel();
311
311
+
}
312
312
+
if (modelType == 3) {
313
313
+
model = Game.localPlayer.getHeadModel();
314
314
+
}
315
315
+
if (modelType == 4) {
316
316
+
model = ItemDefinition.getDefinition(modelId).getInventoryModel(50);
317
317
+
}
318
318
+
if (modelType == 5) {
319
319
+
model = null;
320
320
+
}
321
321
+
if (model != null) {
322
322
+
Widget.modelCache.put(model, (modelType << 16) + modelId);
323
323
+
}
324
324
+
return model;
325
325
+
}
326
326
+
327
327
+
private static ImageRGB getImage(int spriteId, Archive mediaArchive, String spriteName) {
328
328
+
long spriteHash = (TextUtils.spriteToHash(spriteName) << 8) + spriteId;
329
329
+
ImageRGB sprite = (ImageRGB) Widget.spriteCache.get(spriteHash);
330
330
+
if (sprite != null) {
331
331
+
return sprite;
332
332
+
}
333
333
+
try {
334
334
+
sprite = new ImageRGB(mediaArchive, spriteName, spriteId);
335
335
+
Widget.spriteCache.put(sprite, spriteHash);
336
336
+
} catch (Exception exception) {
337
337
+
return null;
338
338
+
}
339
339
+
return sprite;
340
340
+
}
341
341
+
342
342
+
public static void setModel(int modelId, int modelType, Model model) {
343
343
+
Widget.modelCache.removeAll();
344
344
+
Widget.modelCache.put(model, (modelType << 16) + modelId);
345
345
+
}
346
346
+
347
347
+
public Model getAnimatedModel(int frame1Id, int frame2Id, boolean modelEnabled) {
348
348
+
Model model;
349
349
+
if (modelEnabled) {
350
350
+
model = getModel(enabledModelType, enabledModelId);
351
351
+
} else {
352
352
+
model = getModel(modelType, modelId);
353
353
+
}
354
354
+
if (model == null) {
355
355
+
return null;
356
356
+
}
357
357
+
if (frame2Id == -1 && frame1Id == -1 && model.triangleColorValues == null) {
358
358
+
return model;
359
359
+
}
360
360
+
Model animatedModel = new Model(true, Animation.exists(frame2Id) & Animation.exists(frame1Id), false, model);
361
361
+
if (frame2Id != -1 || frame1Id != -1) {
362
362
+
animatedModel.createBones();
363
363
+
}
364
364
+
if (frame2Id != -1) {
365
365
+
animatedModel.applyTransform(frame2Id);
366
366
+
}
367
367
+
if (frame1Id != -1) {
368
368
+
animatedModel.applyTransform(frame1Id);
369
369
+
}
370
370
+
animatedModel.applyLighting(64, 768, -50, -10, -50, true);
371
371
+
return animatedModel;
372
372
+
}
373
373
+
}