A RuneTek3 client (377) that is deobfuscated, converted to Kotlin, and includes QoL improvements.
0

Configure Feed

Select the types of activity you want to include in your feed.

Readded com.jagex.runescape.cache

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