Dataset Viewer
Auto-converted to Parquet Duplicate
text
stringlengths
67
71k
package com.rs.cache; import com.rs.cache.utils.CacheUtil; import com.rs.cache.utils.CompressionUtils; import com.rs.cache.utils.Constants; import com.rs.cache.utils.Whirlpool; import com.rs.lib.io.InputStream; import com.rs.lib.io.OutputStream; public class Archive { private int id; private int revision; private int compression; private byte[] data; private int[] keys; protected Archive(int id, byte[] archive, int[] keys) { this.id = id; this.keys = keys; decompress(archive); } public Archive(int id, int compression, int revision, byte[] data) { this.id = id; this.compression = compression; this.revision = revision; this.data = data; } public byte[] compress() { OutputStream stream = new OutputStream(); stream.writeByte(compression); byte[] compressedData; switch (compression) { case Constants.GZIP_COMPRESSION: compressedData = CompressionUtils.gzip(data); stream.writeInt(compressedData.length); stream.writeInt(data.length); break; case Constants.BZIP2_COMPRESSION: compressedData = CompressionUtils.bzip2(data); stream.writeInt(compressedData.length); stream.writeInt(data.length); break; default: compressedData = data; stream.writeInt(data.length); break; } stream.writeBytes(compressedData); if (keys != null && keys.length == 4) stream.encodeXTEA(keys, 5, stream.getOffset()); if (revision != -1) stream.writeShort(revision); return stream.toByteArray(); } private void decompress(byte[] archive) { try { InputStream stream = new InputStream(archive); compression = stream.readUnsignedByte(); int length = stream.readInt(); if (keys != null && keys.length == 4) stream.decodeXTEA(keys, 5, length + (compression == Constants.NO_COMPRESSION ? 5 : 9)); if (length < 0 || length > Constants.MAX_VALID_ARCHIVE_LENGTH) throw new RuntimeException("INVALID ARCHIVE HEADER"); switch (compression) { case Constants.NO_COMPRESSION: data = new byte[length]; stream.readBytes(data, 0, length); revision = -1; if (stream.getRemaining() >= 2) { revision = stream.readShort(); } break; case Constants.BZIP2_COMPRESSION: case Constants.GZIP_COMPRESSION: int uncompressedLength = stream.readInt(); if (uncompressedLength <= 0 || uncompressedLength > 1000000000) { data = null; break; } byte[] compressed = new byte[length]; stream.readBytes(compressed, 0, length); data = (compression == Constants.BZIP2_COMPRESSION ? CompressionUtils.bunzip2(compressed) : CompressionUtils.gunzip(compressed)); if (data.length != uncompressedLength) { throw new Exception("Length mismatch. [ " + data.length + ", " + uncompressedLength + " ]"); } revision = -1; if (stream.getRemaining() >= 2) { revision = stream.readShort(); } break; } } catch (Exception e) { System.out.println("Exception loading archive: " + id); } } public Object[] editNoRevision(byte[] data, MainFile mainFile) { this.data = data; byte[] compressed = compress(); if (!mainFile.putArchiveData(id, compressed)) return null; return new Object[] { CacheUtil.getCrcChecksum(compressed, compressed.length), Whirlpool.getWhirlpool(compressed, 0, compressed.length) }; } public int getId() { return id; } public byte[] getData() { return data; } public int getDecompressedLength() { return data.length; } public int getRevision() { return revision; } public void setRevision(int revision) { this.revision = revision; } public int getCompression() { return compression; } public int[] getKeys() { return keys; } public void setKeys(int[] keys) { this.keys = keys; } }
package com.rs.cache; import java.util.Arrays; public class ArchiveReference { private int nameHash; private byte[] whirpool; private int crc; private int revision; private FileReference[] files; private int[] validFileIds; private boolean needsFilesSort; private boolean updatedRevision; public void updateRevision() { if (updatedRevision) return; revision++; updatedRevision = true; } public int getNameHash() { return nameHash; } public void setNameHash(int nameHash) { this.nameHash = nameHash; } public byte[] getWhirpool() { return whirpool; } public void setWhirpool(byte[] whirpool) { this.whirpool = whirpool; } public int getCRC() { return crc; } public void setCrc(int crc) { this.crc = crc; } public int getRevision() { return revision; } public FileReference[] getFiles() { return files; } public void setFiles(FileReference[] files) { this.files = files; } public void setRevision(int revision) { this.revision = revision; } public int[] getValidFileIds() { return validFileIds; } public void setValidFileIds(int[] validFileIds) { this.validFileIds = validFileIds; } public boolean isNeedsFilesSort() { return needsFilesSort; } public void setNeedsFilesSort(boolean needsFilesSort) { this.needsFilesSort = needsFilesSort; } public void removeFileReference(int fileId) { int[] newValidFileIds = new int[validFileIds.length - 1]; int count = 0; for (int id : validFileIds) { if (id == fileId) continue; newValidFileIds[count++] = id; } validFileIds = newValidFileIds; files[fileId] = null; } public void addEmptyFileReference(int fileId) { needsFilesSort = true; int[] newValidFileIds = Arrays.copyOf(validFileIds, validFileIds.length + 1); newValidFileIds[newValidFileIds.length - 1] = fileId; validFileIds = newValidFileIds; if (files.length <= fileId) { FileReference[] newFiles = Arrays.copyOf(files, fileId + 1); newFiles[fileId] = new FileReference(); files = newFiles; } else files[fileId] = new FileReference(); } public void sortFiles() { Arrays.sort(validFileIds); needsFilesSort = false; } public void reset() { whirpool = null; updatedRevision = true; revision = 0; nameHash = 0; crc = 0; files = new FileReference[0]; validFileIds = new int[0]; needsFilesSort = false; } public void copyHeader(ArchiveReference fromReference) { setCrc(fromReference.getCRC()); setNameHash(fromReference.getNameHash()); setWhirpool(fromReference.getWhirpool()); int[] validFiles = fromReference.getValidFileIds(); setValidFileIds(Arrays.copyOf(validFiles, validFiles.length)); FileReference[] files = fromReference.getFiles(); setFiles(Arrays.copyOf(files, files.length)); } }
package com.rs.cache; public enum ArchiveType { UNDERLAYS(1), SCT_2(2), IDENTIKIT(3), OVERLAYS(4), INVENTORIES(5), OBJECTS(6, 8), SCT_7(7), ENUMS(8, 8), NPCS(9, 7), ITEMS(10, 8), PARAMS(11), ANIMATIONS(12, 7), SPOT_ANIMS(13, 8), VARBITS(14, 10), VARC_STRING(15), VARS(16), SCT_17(17), SCT_18(18), VARC(19), SCT_20(20), SCT_21(21), SCT_22(22), SCT_23(23), SCT_24(24), //varn SCT_25(25), //varnBit STRUCTS(26), SCT_27(27), SCT_28(28), SKYBOX(29), SUN(30), LIGHT_INTENSITIES(31), BAS(32), CURSORS(33), MAP_SPRITES(34), QUESTS(35), MAP_AREAS(36), SCT_37(37), SCT_38(38), SCT_39(39), SCT_40(40), SCT_41(41), SCT_42(42), SCT_43(43), SCT_44(44), SCT_45(45), HITSPLATS(46), CLAN_VAR(47), SCT_48(48), SCT_49(49), SCT_50(50), SCT_51(51), SCT_53(53), CLAN_VAR_SETTINGS(54), SCT_70(70), HITBARS(72), SCT_73(73), SCT_74(74); private int id, fileIdBitShift; private ArchiveType(int id) { this(id, 0); } ArchiveType(int id, int fileIdBitShift) { this.id = id; this.fileIdBitShift = fileIdBitShift; } public int getId() { return id; } public int filesPerContainer() { return 1 << this.fileIdBitShift; } public int archiveId(int id) { return id >>> this.fileIdBitShift; } public int fileId(int id) { return id & (1 << this.fileIdBitShift) - 1; } }
package com.rs.cache; import java.io.IOException; import com.rs.lib.util.Logger; public final class Cache { public static Store STORE; private Cache() { } public static void init(String path) throws IOException { Logger.info(Cache.class, "init", "Loading cache at "+path+"..."); STORE = new Store(path, false); } }
package com.rs.cache; public class FileReference { private int nameHash; public int getNameHash() { return nameHash; } public void setNameHash(int nameHash) { this.nameHash = nameHash; } }
package com.rs.cache; import com.rs.lib.io.InputStream; import com.rs.lib.io.OutputStream; import com.rs.lib.util.Utils; public final class Huffman { private int[] huffmanAlgorithm1; private byte[] huffmanAlgorithm2; private int[] huffmanAlgorithm3; public Huffman(Store store) { loadAlgorithmValues(store); } public int sendEncryptMessage(OutputStream stream, String message) { try { int startOffset = stream.getOffset(); byte[] messageData = Utils.getFormatedMessage(message); stream.writeSmart(messageData.length); stream.checkCapacityPosition(stream.getOffset() + message.length() * 2); stream.skip(encryptMessage(stream.getOffset(), messageData.length, stream.getBuffer(), 0, messageData)); return stream.getOffset() - startOffset; } catch (Throwable e) { return -1; } } public final String readEncryptedMessage(InputStream stream) { return readEncryptedMessage(32767, stream); } public final String readEncryptedMessage(int maxLength, InputStream stream) { try { int messageDataLength = stream.readUnsignedSmart(); if (messageDataLength > maxLength) messageDataLength = maxLength; byte[] messageData = new byte[messageDataLength]; stream.skip(decryptMessage(messageData, messageDataLength, stream.getBuffer(), stream.getOffset(), 0)); String message = Utils.getUnformatedMessage(messageDataLength, 0, messageData); return message; } catch (Throwable e) { return ""; } } public final void loadAlgorithmValues(Store store) { byte[] huffmanFile = store.getIndex(IndexType.HUFFMAN).getFile(store.getIndex(IndexType.HUFFMAN).getArchiveId("huffman")); int fileLength = huffmanFile.length; huffmanAlgorithm2 = huffmanFile; huffmanAlgorithm1 = new int[fileLength]; huffmanAlgorithm3 = new int[8]; int[] is = new int[33]; int i_4_ = 0; for (int i_5_ = 0; (fileLength ^ 0xffffffff) < (i_5_ ^ 0xffffffff); i_5_++) { int i_6_ = huffmanFile[i_5_]; if (i_6_ != 0) { int i_7_ = 1 << 32 - i_6_; int i_8_ = is[i_6_]; huffmanAlgorithm1[i_5_] = i_8_; int i_9_; if ((i_8_ & i_7_) == 0) { for (int i_10_ = -1 + i_6_; i_10_ >= 1; i_10_--) { int i_11_ = is[i_10_]; if (i_8_ != i_11_) break; int i_12_ = 1 << 32 + -i_10_; if ((i_12_ & i_11_ ^ 0xffffffff) != -1) { is[i_10_] = is[-1 + i_10_]; break; } is[i_10_] = (i_11_ | i_12_); } i_9_ = i_7_ | i_8_; } else i_9_ = is[i_6_ + -1]; is[i_6_] = i_9_; for (int i_13_ = 1 + i_6_; i_13_ <= 32; i_13_++) { if (i_8_ == is[i_13_]) is[i_13_] = i_9_; } int i_14_ = 0; for (int i_15_ = 0; (i_6_ ^ 0xffffffff) < (i_15_ ^ 0xffffffff); i_15_++) { int i_16_ = -2147483648 >>> i_15_; if ((i_8_ & i_16_ ^ 0xffffffff) == -1) i_14_++; else { if (huffmanAlgorithm3[i_14_] == 0) huffmanAlgorithm3[i_14_] = i_4_; i_14_ = huffmanAlgorithm3[i_14_]; } if ((huffmanAlgorithm3.length ^ 0xffffffff) >= (i_14_ ^ 0xffffffff)) { int[] is_17_ = new int[huffmanAlgorithm3.length * 2]; for (int i_18_ = 0; i_18_ < huffmanAlgorithm3.length; i_18_++) is_17_[i_18_] = huffmanAlgorithm3[i_18_]; huffmanAlgorithm3 = is_17_; } i_16_ >>>= 1; } huffmanAlgorithm3[i_14_] = i_5_ ^ 0xffffffff; if ((i_4_ ^ 0xffffffff) >= (i_14_ ^ 0xffffffff)) i_4_ = 1 + i_14_; } } } public final int decryptMessage(byte[] messageData, int messagedDataLength, byte[] streamBuffer, int streamOffset, int messageDataOffset) { if ((messagedDataLength ^ 0xffffffff) == -1) return 0; int i = 0; messagedDataLength += messageDataOffset; int i_1_ = streamOffset; for (;;) { byte i_2_ = streamBuffer[i_1_]; if ((i_2_ ^ 0xffffffff) <= -1) i++; else i = huffmanAlgorithm3[i]; int i_3_; if ((i_3_ = huffmanAlgorithm3[i]) < 0) { messageData[messageDataOffset++] = (byte) (i_3_ ^ 0xffffffff); if (messagedDataLength <= messageDataOffset) break; i = 0; } if ((i_2_ & 0x40 ^ 0xffffffff) == -1) i++; else i = huffmanAlgorithm3[i]; if (((i_3_ = huffmanAlgorithm3[i]) ^ 0xffffffff) > -1) { messageData[messageDataOffset++] = (byte) (i_3_ ^ 0xffffffff); if (messagedDataLength <= messageDataOffset) break; i = 0; } if ((0x20 & i_2_ ^ 0xffffffff) != -1) i = huffmanAlgorithm3[i]; else i++; if ((i_3_ = huffmanAlgorithm3[i]) < 0) { messageData[messageDataOffset++] = (byte) (i_3_ ^ 0xffffffff); if (messagedDataLength <= messageDataOffset) break; i = 0; } if ((0x10 & i_2_ ^ 0xffffffff) != -1) i = huffmanAlgorithm3[i]; else i++; if ((i_3_ = huffmanAlgorithm3[i]) < 0) { messageData[messageDataOffset++] = (byte) (i_3_ ^ 0xffffffff); if ((messageDataOffset ^ 0xffffffff) <= (messagedDataLength ^ 0xffffffff)) break; i = 0; } if ((i_2_ & 0x8) == 0) i++; else i = huffmanAlgorithm3[i]; if ((i_3_ = huffmanAlgorithm3[i]) < 0) { messageData[messageDataOffset++] = (byte) (i_3_ ^ 0xffffffff); if (messageDataOffset >= messagedDataLength) break; i = 0; } if ((0x4 & i_2_ ^ 0xffffffff) != -1) i = huffmanAlgorithm3[i]; else i++; if (((i_3_ = huffmanAlgorithm3[i]) ^ 0xffffffff) > -1) { messageData[messageDataOffset++] = (byte) (i_3_ ^ 0xffffffff); if (messageDataOffset >= messagedDataLength) break; i = 0; } if ((0x2 & i_2_) != 0) i = huffmanAlgorithm3[i]; else i++; if (((i_3_ = huffmanAlgorithm3[i]) ^ 0xffffffff) > -1) { messageData[messageDataOffset++] = (byte) (i_3_ ^ 0xffffffff); if (messagedDataLength <= messageDataOffset) break; i = 0; } if ((0x1 & i_2_ ^ 0xffffffff) != -1) i = huffmanAlgorithm3[i]; else i++; if ((i_3_ = huffmanAlgorithm3[i]) < 0) { messageData[messageDataOffset++] = (byte) (i_3_ ^ 0xffffffff); if ((messageDataOffset ^ 0xffffffff) <= (messagedDataLength ^ 0xffffffff)) break; i = 0; } i_1_++; } return -streamOffset + i_1_ - -1; } public final int encryptMessage(int streamOffset, int messageDataLength, byte[] streamBuffer, int messageDataOffset, byte[] messageData) { int i = 0; messageDataLength += messageDataOffset; int i_19_ = streamOffset << 309760323; for (/**/; messageDataOffset < messageDataLength; messageDataOffset++) { int i_20_ = 0xff & messageData[messageDataOffset]; int i_21_ = huffmanAlgorithm1[i_20_]; int i_22_ = huffmanAlgorithm2[i_20_]; if (i_22_ == 0) throw new RuntimeException("No codeword for data value " + i_20_); int i_23_ = i_19_ >> -976077821; int i_24_ = 0x7 & i_19_; i &= -i_24_ >> -1041773793; int i_25_ = (-1 + i_24_ - -i_22_ >> -2003626461) + i_23_; i_19_ += i_22_; i_24_ += 24; streamBuffer[i_23_] = (byte) (i = (i | (i_21_ >>> i_24_))); if (i_25_ > i_23_) { i_24_ -= 8; i_23_++; streamBuffer[i_23_] = (byte) (i = i_21_ >>> i_24_); if ((i_23_ ^ 0xffffffff) > (i_25_ ^ 0xffffffff)) { i_24_ -= 8; i_23_++; streamBuffer[i_23_] = (byte) (i = i_21_ >>> i_24_); if ((i_23_ ^ 0xffffffff) > (i_25_ ^ 0xffffffff)) { i_24_ -= 8; i_23_++; streamBuffer[i_23_] = (byte) (i = i_21_ >>> i_24_); if ((i_25_ ^ 0xffffffff) < (i_23_ ^ 0xffffffff)) { i_23_++; i_24_ -= 8; streamBuffer[i_23_] = (byte) (i = i_21_ << -i_24_); } } } } } return -streamOffset + (7 + i_19_ >> 1737794179); } }
package com.rs.cache; import java.util.zip.CRC32; import com.rs.cache.utils.CacheUtil; import com.rs.cache.utils.Constants; import com.rs.cache.utils.Whirlpool; import com.rs.lib.io.InputStream; import com.rs.lib.io.OutputStream; public final class Index { private MainFile mainFile; private MainFile index255; private ReferenceTable table; private byte[][][] cachedFiles; private int crc; private byte[] whirlpool; protected Index(MainFile index255, MainFile mainFile) { this.mainFile = mainFile; this.index255 = index255; byte[] archiveData = index255.getArchiveData(getId()); if (archiveData == null) return; crc = CacheUtil.getCrcChecksum(archiveData, archiveData.length); whirlpool = Whirlpool.getWhirlpool(archiveData, 0, archiveData.length); Archive archive = new Archive(getId(), archiveData, null); table = new ReferenceTable(archive); resetCachedFiles(); } public void resetCachedFiles() { cachedFiles = new byte[getLastArchiveId() + 1][][]; } public int getLastFileId(int archiveId) { if (!archiveExists(archiveId)) return -1; return table.getArchives()[archiveId].getFiles().length - 1; } public int getLastArchiveId() { return table.getArchives().length - 1; } public int getValidArchivesCount() { return table.getValidArchiveIds().length; } public int getValidFilesCount(int archiveId) { if (!archiveExists(archiveId)) return -1; return table.getArchives()[archiveId].getValidFileIds().length; } public boolean archiveExists(int archiveId) { if (archiveId < 0) return false; ArchiveReference[] archives = table.getArchives(); return archives.length > archiveId && archives[archiveId] != null; } public boolean fileExists(int archiveId, int fileId) { if (!archiveExists(archiveId)) return false; FileReference[] files = table.getArchives()[archiveId].getFiles(); return files.length > fileId && files[fileId] != null; } public int getArchiveId(String name) { int nameHash = CacheUtil.getNameHash(name); ArchiveReference[] archives = table.getArchives(); int[] validArchiveIds = table.getValidArchiveIds(); for (int archiveId : validArchiveIds) { if (archives[archiveId].getNameHash() == nameHash) return archiveId; } return -1; } public int getFileId(int archiveId, String name) { if (!archiveExists(archiveId)) return -1; int nameHash = CacheUtil.getNameHash(name); FileReference[] files = table.getArchives()[archiveId].getFiles(); int[] validFileIds = table.getArchives()[archiveId].getValidFileIds(); for (int index = 0; index < validFileIds.length; index++) { int fileId = validFileIds[index]; if (files[fileId].getNameHash() == nameHash) return fileId; } return -1; } public byte[] getFile(int archiveId) { if (!archiveExists(archiveId)) return null; return getFile(archiveId, table.getArchives()[archiveId].getValidFileIds()[0]); } public byte[] getFile(int archiveId, int fileId) { return getFile(archiveId, fileId, null); } public byte[] getFile(int archiveId, int fileId, int[] keys) { try { if (!fileExists(archiveId, fileId)) { return null; } if (cachedFiles[archiveId] == null || cachedFiles[archiveId][fileId] == null) cacheArchiveFiles(archiveId, keys); byte[] file = cachedFiles[archiveId][fileId]; cachedFiles[archiveId][fileId] = null; return file; } catch (Throwable e) { e.printStackTrace(); return null; } } public boolean packIndex(Store originalStore) { return packIndex(originalStore, false); } public boolean packIndex(Store originalStore, boolean checkCRC) { try { return packIndex(getRef(), originalStore, checkCRC); } catch (Exception e) { } return packIndex(getRef(), originalStore, checkCRC); } public boolean packIndex(IndexType index, Store originalStore, boolean checkCRC) { try { Index originalIndex = originalStore.getIndex(index); for (int archiveId : originalIndex.table.getValidArchiveIds()) { if (checkCRC && archiveExists(archiveId) && originalIndex.table.getArchives()[archiveId].getCRC() == table.getArchives()[archiveId].getCRC()) continue; if (!putArchive(index, archiveId, originalStore, false, false)) return false; } if (!rewriteTable()) return false; resetCachedFiles(); return true; } catch (Exception e) { } return true; } public boolean putArchive(int archiveId, Store originalStore) { return putArchive(getRef(), archiveId, originalStore, true, true); } public boolean putArchive(int archiveId, Store originalStore, boolean rewriteTable, boolean resetCache) { return putArchive(getRef(), archiveId, originalStore, rewriteTable, resetCache); } public boolean putArchive(IndexType index, int archiveId, Store originalStore, boolean rewriteTable, boolean resetCache) { try { Index originalIndex = originalStore.getIndex(index); byte[] data = originalIndex.getMainFile().getArchiveData(archiveId); if (data == null) return false; if (!archiveExists(archiveId)) table.addEmptyArchiveReference(archiveId); ArchiveReference reference = table.getArchives()[archiveId]; reference.updateRevision(); ArchiveReference originalReference = originalIndex.table.getArchives()[archiveId]; reference.copyHeader(originalReference); int revision = reference.getRevision(); data[data.length - 2] = (byte) (revision >> 8); data[data.length - 1] = (byte) revision; if (!mainFile.putArchiveData(archiveId, data)) return false; if (rewriteTable && !rewriteTable()) return false; if (resetCache) resetCachedFiles(); return true; } catch (Exception e) { e.printStackTrace(); } return true; } public boolean putArchive(int archiveId, byte[] data) { return putFile(archiveId, 0, data); } public boolean putFile(int archiveId, int fileId, byte[] data) { return putFile(archiveId, fileId, Constants.GZIP_COMPRESSION, data, null, true, true, -1, -1); } public boolean removeFile(int archiveId, int fileId) { return removeFile(archiveId, fileId, Constants.GZIP_COMPRESSION, null); } public boolean removeFile(int archiveId, int fileId, int compression, int[] keys) { if (!fileExists(archiveId, fileId)) return false; cacheArchiveFiles(archiveId, keys); ArchiveReference reference = table.getArchives()[archiveId]; reference.removeFileReference(fileId); int filesCount = getValidFilesCount(archiveId); byte[] archiveData; if (filesCount == 1) archiveData = getFile(archiveId, reference.getValidFileIds()[0], keys); else { int[] filesSize = new int[filesCount]; OutputStream stream = new OutputStream(); for (int index = 0; index < filesCount; index++) { int id = reference.getValidFileIds()[index]; byte[] fileData = getFile(archiveId, id, keys); filesSize[index] = fileData.length; stream.writeBytes(fileData); } for (int index = 0; index < filesSize.length; index++) { int offset = filesSize[index]; if (index != 0) offset -= filesSize[index - 1]; stream.writeInt(offset); } stream.writeByte(1); // 1loop archiveData = new byte[stream.getOffset()]; stream.setOffset(0); stream.getBytes(archiveData, 0, archiveData.length); } reference.updateRevision(); Archive archive = new Archive(archiveId, compression, reference.getRevision(), archiveData); byte[] closedArchive = archive.compress(); CRC32 crc = new CRC32(); crc.update(closedArchive, 0, closedArchive.length - 2); reference.setCrc((int) crc.getValue()); reference.setWhirpool(Whirlpool.getWhirlpool(closedArchive, 0, closedArchive.length - 2)); if (!mainFile.putArchiveData(archiveId, closedArchive)) return false; if (!rewriteTable()) return false; resetCachedFiles(); return true; } public boolean putFile(int archiveId, int fileId, int compression, byte[] data, int[] keys, boolean rewriteTable, boolean resetCache, int archiveName, int fileName) { if (!archiveExists(archiveId)) { table.addEmptyArchiveReference(archiveId); resetCachedFiles(); cachedFiles[archiveId] = new byte[1][]; } else cacheArchiveFiles(archiveId, keys); ArchiveReference reference = table.getArchives()[archiveId]; if (!fileExists(archiveId, fileId)) reference.addEmptyFileReference(fileId); reference.sortFiles(); int filesCount = getValidFilesCount(archiveId); byte[] archiveData; if (filesCount == 1) archiveData = data; else { int[] filesSize = new int[filesCount]; OutputStream stream = new OutputStream(); for (int index = 0; index < filesCount; index++) { int id = reference.getValidFileIds()[index]; byte[] fileData; if (id == fileId) fileData = data; else fileData = getFile(archiveId, id, keys); filesSize[index] = fileData.length; stream.writeBytes(fileData); } for (int index = 0; index < filesCount; index++) { int offset = filesSize[index]; if (index != 0) offset -= filesSize[index - 1]; stream.writeInt(offset); } stream.writeByte(1); // 1loop archiveData = new byte[stream.getOffset()]; stream.setOffset(0); stream.getBytes(archiveData, 0, archiveData.length); } reference.updateRevision(); Archive archive = new Archive(archiveId, compression, reference.getRevision(), archiveData); byte[] closedArchive = archive.compress(); reference.setCrc(CacheUtil.getCrcChecksum(closedArchive, closedArchive.length - 2)); reference.setWhirpool(Whirlpool.getWhirlpool(closedArchive, 0, closedArchive.length - 2)); if (archiveName != -1) reference.setNameHash(archiveName); if (fileName != -1) reference.getFiles()[fileId].setNameHash(fileName); if (!mainFile.putArchiveData(archiveId, closedArchive)) return false; if (rewriteTable && !rewriteTable()) return false; if (resetCache) resetCachedFiles(); return true; } public boolean encryptArchive(int archiveId, int[] keys) { return encryptArchive(archiveId, null, keys, true, true); } public boolean encryptArchive(int archiveId, int[] oldKeys, int[] keys, boolean rewriteTable, boolean resetCache) { if (!archiveExists(archiveId)) return false; Archive archive = mainFile.getArchive(archiveId, oldKeys); if (archive == null) return false; ArchiveReference reference = table.getArchives()[archiveId]; if (reference.getRevision() != archive.getRevision()) throw new RuntimeException("ERROR REVISION"); reference.updateRevision(); archive.setRevision(reference.getRevision()); archive.setKeys(keys); byte[] closedArchive = archive.compress(); reference.setCrc(CacheUtil.getCrcChecksum(closedArchive, closedArchive.length - 2)); reference.setWhirpool(Whirlpool.getWhirlpool(closedArchive, 0, closedArchive.length - 2)); if (!mainFile.putArchiveData(archiveId, closedArchive)) return false; if (rewriteTable && !rewriteTable()) return false; if (resetCache) resetCachedFiles(); return true; } public boolean rewriteTable() { table.updateRevision(); table.sortTable(); Object[] hashes = table.encodeHeader(index255); if (hashes == null) return false; crc = (int) hashes[0]; whirlpool = (byte[]) hashes[1]; return true; } public void setKeys(int[] keys) { table.setKeys(keys); } public int[] getKeys() { return table.getKeys(); } private void cacheArchiveFiles(int archiveId, int[] keys) { Archive archive = getArchive(archiveId, keys); int lastFileId = getLastFileId(archiveId); cachedFiles[archiveId] = new byte[lastFileId + 1][]; if (archive == null) return; byte[] data = archive.getData(); if (data == null) return; int filesCount = getValidFilesCount(archiveId); if (filesCount == 1) cachedFiles[archiveId][lastFileId] = data; else { int readPosition = data.length; int amtOfLoops = data[--readPosition] & 0xff; readPosition -= amtOfLoops * (filesCount * 4); InputStream stream = new InputStream(data); stream.setOffset(readPosition); int filesSize[] = new int[filesCount]; for (int loop = 0; loop < amtOfLoops; loop++) { int offset = 0; for (int i = 0; i < filesCount; i++) filesSize[i] += offset += stream.readInt(); } byte[][] filesData = new byte[filesCount][]; for (int i = 0; i < filesCount; i++) { filesData[i] = new byte[filesSize[i]]; filesSize[i] = 0; } stream.setOffset(readPosition); int sourceOffset = 0; for (int loop = 0; loop < amtOfLoops; loop++) { int dataRead = 0; for (int i = 0; i < filesCount; i++) { dataRead += stream.readInt(); System.arraycopy(data, sourceOffset, filesData[i], filesSize[i], dataRead); sourceOffset += dataRead; filesSize[i] += dataRead; } } int count = 0; for (int fileId : table.getArchives()[archiveId].getValidFileIds()) cachedFiles[archiveId][fileId] = filesData[count++]; } } public IndexType getRef() { return IndexType.values()[mainFile.getId()]; } public int getId() { return mainFile.getId(); } public ReferenceTable getTable() { return table; } public MainFile getMainFile() { return mainFile; } public Archive getArchive(int id) { return mainFile.getArchive(id, null); } public Archive getArchive(int id, int[] keys) { return mainFile.getArchive(id, keys); } public int getCRC() { return crc; } public byte[] getWhirlpool() { return whirlpool; } }
package com.rs.cache; public enum IndexType { ANIMATION_FRAME_SETS(0), ANIMATION_FRAME_BASES(1), CONFIG(2), INTERFACES(3), SOUND_EFFECTS(4), MAPS(5), MUSIC(6), MODELS(7), SPRITES(8), MATERIALS(9), HUFFMAN(10), MUSIC2(11), CS2_SCRIPTS(12), FONT_METRICS(13), MIDI_INSTRUMENTS(14), SOUND_EFFECTS_MIDI(15), OBJECTS(16), ENUMS(17), NPCS(18), ITEMS(19), ANIMATIONS(20), SPOT_ANIMS(21), VARBITS(22), MAP_AREAS(23), QC_MESSAGES(24), QC_MENUS(25), TEXTURES(26), PARTICLES(27), DEFAULTS(28), BILLBOARDS(29), NATIVE_LIBRARIES(30), SHADERS(31), NORMAL_FONTS(32), GAME_TIPS(33), JAGEX_FONTS(34), CUTSCENES(35), VORBIS(36); private int id; private IndexType(int id) { this.id = id; } public int getId() { return id; } }
package com.rs.cache; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; /* * Created by Alex(Dragonkk) * 23/10/11 */ public final class MainFile { private static final int IDX_BLOCK_LEN = 6; private static final int HEADER_LEN = 8; private static final int EXPANDED_HEADER_LEN = 10; private static final int BLOCK_LEN = 512; private static final int EXPANDED_BLOCK_LEN = 510; private static final int TOTAL_BLOCK_LEN = HEADER_LEN + BLOCK_LEN; private static final ByteBuffer tempBuffer = ByteBuffer.allocateDirect(TOTAL_BLOCK_LEN); private int id; private FileChannel index; private FileChannel data; protected MainFile(int id, RandomAccessFile data, RandomAccessFile index) throws IOException { this.id = id; this.data = data.getChannel(); this.index = index.getChannel(); } public Archive getArchive(int id) { return getArchive(id, null); } public Archive getArchive(int id, int[] keys) { byte[] data = getArchiveData(id); if (data == null) return null; return new Archive(id, data, keys); } public byte[] getArchiveData(int archiveId) { synchronized (data) { try { tempBuffer.position(0).limit(IDX_BLOCK_LEN); index.read(tempBuffer, archiveId * IDX_BLOCK_LEN); tempBuffer.flip(); int size = getMediumInt(tempBuffer); int block = getMediumInt(tempBuffer); if (size < 0) return null; if (block <= 0 || block > data.size() / TOTAL_BLOCK_LEN) { return null; } ByteBuffer fileBuffer = ByteBuffer.allocate(size); int remaining = size; int chunk = 0; int blockLen = archiveId <= 0xffff ? BLOCK_LEN : EXPANDED_BLOCK_LEN; int headerLen = archiveId <= 0xffff ? HEADER_LEN : EXPANDED_HEADER_LEN; while (remaining > 0) { if (block == 0) { System.out.println(archiveId + ", "); return null; } int blockSize = remaining > blockLen ? blockLen : remaining; tempBuffer.position(0).limit(blockSize + headerLen); data.read(tempBuffer, block * TOTAL_BLOCK_LEN); tempBuffer.flip(); int currentFile, currentChunk, nextBlock, currentIndex; if (archiveId <= 65535) { currentFile = tempBuffer.getShort() & 0xffff; currentChunk = tempBuffer.getShort() & 0xffff; nextBlock = getMediumInt(tempBuffer); currentIndex = tempBuffer.get() & 0xff; } else { currentFile = tempBuffer.getInt(); currentChunk = tempBuffer.getShort() & 0xffff; nextBlock = getMediumInt(tempBuffer); currentIndex = tempBuffer.get() & 0xff; } if ((archiveId != currentFile && archiveId <= 65535) || chunk != currentChunk || id != currentIndex) { return null; } if (nextBlock < 0 || nextBlock > data.size() / TOTAL_BLOCK_LEN) { return null; } fileBuffer.put(tempBuffer); remaining -= blockSize; block = nextBlock; chunk++; } return (byte[]) fileBuffer.flip().array(); } catch (Exception ex) { return null; } } } private static int getMediumInt(ByteBuffer buffer) { return ((buffer.get() & 0xff) << 16) | ((buffer.get() & 0xff) << 8) | (buffer.get() & 0xff); } private static void putMediumInt(ByteBuffer buffer, int val) { buffer.put((byte) (val >> 16)); buffer.put((byte) (val >> 8)); buffer.put((byte) val); } public boolean putArchive(Archive archive) { return putArchiveData(archive.getId(), archive.getData()); } public boolean putArchiveData(int id, byte[] archive) { ByteBuffer buffer = ByteBuffer.wrap(archive); boolean done = putArchiveData(id, buffer, archive.length, false); if (!done) done = putArchiveData(id, buffer, archive.length, true); return done; } public boolean putArchiveData(int archiveId, ByteBuffer archive, int size, boolean exists) { synchronized (data) { try { int block; if (exists) { if (archiveId * IDX_BLOCK_LEN + IDX_BLOCK_LEN > index.size()) { return false; } tempBuffer.position(0).limit(IDX_BLOCK_LEN); index.read(tempBuffer, archiveId * IDX_BLOCK_LEN); tempBuffer.flip().position(3); block = getMediumInt(tempBuffer); if (block <= 0 || block > data.size() / TOTAL_BLOCK_LEN) { return false; } } else { block = (int) (data.size() + TOTAL_BLOCK_LEN - 1) / TOTAL_BLOCK_LEN; if (block == 0) { block = 1; } } tempBuffer.position(0); putMediumInt(tempBuffer, size); putMediumInt(tempBuffer, block); tempBuffer.flip(); index.write(tempBuffer, archiveId * IDX_BLOCK_LEN); int remaining = size; int chunk = 0; int blockLen = archiveId <= 0xffff ? BLOCK_LEN : EXPANDED_BLOCK_LEN; int headerLen = archiveId <= 0xffff ? HEADER_LEN : EXPANDED_HEADER_LEN; while (remaining > 0) { int nextBlock = 0; if (exists) { tempBuffer.position(0).limit(headerLen); data.read(tempBuffer, block * TOTAL_BLOCK_LEN); tempBuffer.flip(); int currentFile, currentChunk, currentIndex; if (archiveId <= 0xffff) { currentFile = tempBuffer.getShort() & 0xffff; currentChunk = tempBuffer.getShort() & 0xffff; nextBlock = getMediumInt(tempBuffer); currentIndex = tempBuffer.get() & 0xff; } else { currentFile = tempBuffer.getInt(); currentChunk = tempBuffer.getShort() & 0xffff; nextBlock = getMediumInt(tempBuffer); currentIndex = tempBuffer.get() & 0xff; } if ((archiveId != currentFile && archiveId <= 65535) || chunk != currentChunk || id != currentIndex) { return false; } if (nextBlock < 0 || nextBlock > data.size() / TOTAL_BLOCK_LEN) { return false; } } if (nextBlock == 0) { exists = false; nextBlock = (int) ((data.size() + TOTAL_BLOCK_LEN - 1) / TOTAL_BLOCK_LEN); if (nextBlock == 0) { nextBlock = 1; } if (nextBlock == block) { nextBlock++; } } if (remaining <= blockLen) { nextBlock = 0; } tempBuffer.position(0).limit(TOTAL_BLOCK_LEN); if (archiveId <= 0xffff) { tempBuffer.putShort((short) archiveId); tempBuffer.putShort((short) chunk); putMediumInt(tempBuffer, nextBlock); tempBuffer.put((byte) id); } else { tempBuffer.putInt(archiveId); tempBuffer.putShort((short) chunk); putMediumInt(tempBuffer, nextBlock); tempBuffer.put((byte) id); } int blockSize = remaining > blockLen ? blockLen : remaining; archive.limit(archive.position() + blockSize); tempBuffer.put(archive); tempBuffer.flip(); data.write(tempBuffer, block * TOTAL_BLOCK_LEN); remaining -= blockSize; block = nextBlock; chunk++; } return true; } catch (Exception ex) { return false; } } } public int getId() { return id; } public int getArchivesCount() throws IOException { synchronized (index) { return (int) (index.size() / 6); } } }
package com.rs.cache; import java.util.Arrays; import com.rs.lib.io.InputStream; import com.rs.lib.io.OutputStream; public final class ReferenceTable { private Archive archive; private int revision; private boolean named; private boolean usesWhirpool; private ArchiveReference[] archives; private int[] validArchiveIds; // editing private boolean updatedRevision; private boolean needsArchivesSort; protected ReferenceTable(Archive archive) { this.archive = archive; decodeHeader(); } public void setKeys(int[] keys) { archive.setKeys(keys); } public int[] getKeys() { return archive.getKeys(); } public void sortArchives() { Arrays.sort(validArchiveIds); needsArchivesSort = false; } public void addEmptyArchiveReference(int archiveId) { needsArchivesSort = true; int[] newValidArchiveIds = Arrays.copyOf(validArchiveIds, validArchiveIds.length + 1); newValidArchiveIds[newValidArchiveIds.length - 1] = archiveId; validArchiveIds = newValidArchiveIds; ArchiveReference reference; if (archives.length <= archiveId) { ArchiveReference[] newArchives = Arrays.copyOf(archives, archiveId + 1); reference = newArchives[archiveId] = new ArchiveReference(); archives = newArchives; } else reference = archives[archiveId] = new ArchiveReference(); reference.reset(); } public void sortTable() { if (needsArchivesSort) sortArchives(); for (int index = 0; index < validArchiveIds.length; index++) { ArchiveReference archive = archives[validArchiveIds[index]]; if (archive.isNeedsFilesSort()) archive.sortFiles(); } } public Object[] encodeHeader(MainFile mainFile) { OutputStream stream = new OutputStream(); int protocol = getProtocol(); stream.writeByte(protocol); if (protocol >= 6) stream.writeInt(revision); stream.writeByte((named ? 0x1 : 0) | (usesWhirpool ? 0x2 : 0)); if (protocol >= 7) stream.writeBigSmart(validArchiveIds.length); else stream.writeShort(validArchiveIds.length); for (int index = 0; index < validArchiveIds.length; index++) { int offset = validArchiveIds[index]; if (index != 0) offset -= validArchiveIds[index - 1]; if (protocol >= 7) stream.writeBigSmart(offset); else stream.writeShort(offset); } if (named) for (int index = 0; index < validArchiveIds.length; index++) stream.writeInt(archives[validArchiveIds[index]].getNameHash()); for (int index = 0; index < validArchiveIds.length; index++) stream.writeInt(archives[validArchiveIds[index]].getCRC()); if (usesWhirpool) for (int index = 0; index < validArchiveIds.length; index++) stream.writeBytes(archives[validArchiveIds[index]].getWhirpool()); for (int index = 0; index < validArchiveIds.length; index++) stream.writeInt(archives[validArchiveIds[index]].getRevision()); for (int index = 0; index < validArchiveIds.length; index++) { int value = archives[validArchiveIds[index]].getValidFileIds().length; if (protocol >= 7) stream.writeBigSmart(value); else stream.writeShort(value); } for (int index = 0; index < validArchiveIds.length; index++) { ArchiveReference archive = archives[validArchiveIds[index]]; for (int index2 = 0; index2 < archive.getValidFileIds().length; index2++) { int offset = archive.getValidFileIds()[index2]; if (index2 != 0) offset -= archive.getValidFileIds()[index2 - 1]; if (protocol >= 7) stream.writeBigSmart(offset); else stream.writeShort(offset); } } if (named) { for (int index = 0; index < validArchiveIds.length; index++) { ArchiveReference archive = archives[validArchiveIds[index]]; for (int index2 = 0; index2 < archive.getValidFileIds().length; index2++) stream.writeInt(archive.getFiles()[archive.getValidFileIds()[index2]].getNameHash()); } } byte[] data = new byte[stream.getOffset()]; stream.setOffset(0); stream.getBytes(data, 0, data.length); return archive.editNoRevision(data, mainFile); } public int getProtocol() { if (archives.length > 65535) return 7; for (int index = 0; index < validArchiveIds.length; index++) { if (index > 0) if (validArchiveIds[index] - validArchiveIds[index - 1] > 65535) return 7; if (archives[validArchiveIds[index]].getValidFileIds().length > 65535) return 7; } return revision == 0 ? 5 : 6; } public void setRevision(int revision) { updatedRevision = true; this.revision = revision; } public void updateRevision() { if (updatedRevision) return; revision++; updatedRevision = true; } private void decodeHeader() { InputStream stream = new InputStream(archive.getData()); int protocol = stream.readUnsignedByte(); if (protocol < 5 || protocol > 7) throw new RuntimeException("INVALID PROTOCOL"); if (protocol >= 6) revision = stream.readInt(); int hash = stream.readUnsignedByte(); named = (0x1 & hash) != 0; usesWhirpool = (0x2 & hash) != 0; int validArchivesCount = protocol >= 7 ? stream.readBigSmart() : stream.readUnsignedShort(); validArchiveIds = new int[validArchivesCount]; int lastArchiveId = 0; int biggestArchiveId = 0; for (int index = 0; index < validArchivesCount; index++) { int archiveId = lastArchiveId += protocol >= 7 ? stream.readBigSmart() : stream.readUnsignedShort(); if (archiveId > biggestArchiveId) biggestArchiveId = archiveId; validArchiveIds[index] = archiveId; } archives = new ArchiveReference[biggestArchiveId + 1]; for (int index = 0; index < validArchivesCount; index++) archives[validArchiveIds[index]] = new ArchiveReference(); if (named) for (int index = 0; index < validArchivesCount; index++) archives[validArchiveIds[index]].setNameHash(stream.readInt()); for (int index = 0; index < validArchivesCount; index++) archives[validArchiveIds[index]].setCrc(stream.readInt()); if (usesWhirpool) { for (int index = 0; index < validArchivesCount; index++) { byte[] whirpool = new byte[64]; stream.getBytes(whirpool, 0, 64); archives[validArchiveIds[index]].setWhirpool(whirpool); } } for (int index = 0; index < validArchivesCount; index++) archives[validArchiveIds[index]].setRevision(stream.readInt()); for (int index = 0; index < validArchivesCount; index++) archives[validArchiveIds[index]].setValidFileIds(new int[protocol >= 7 ? stream.readBigSmart() : stream.readUnsignedShort()]); for (int index = 0; index < validArchivesCount; index++) { int lastFileId = 0; int biggestFileId = 0; ArchiveReference archive = archives[validArchiveIds[index]]; for (int index2 = 0; index2 < archive.getValidFileIds().length; index2++) { int fileId = lastFileId += protocol >= 7 ? stream.readBigSmart() : stream.readUnsignedShort(); if (fileId > biggestFileId) biggestFileId = fileId; archive.getValidFileIds()[index2] = fileId; } archive.setFiles(new FileReference[biggestFileId + 1]); for (int index2 = 0; index2 < archive.getValidFileIds().length; index2++) archive.getFiles()[archive.getValidFileIds()[index2]] = new FileReference(); } if (named) { for (int index = 0; index < validArchivesCount; index++) { ArchiveReference archive = archives[validArchiveIds[index]]; for (int index2 = 0; index2 < archive.getValidFileIds().length; index2++) archive.getFiles()[archive.getValidFileIds()[index2]].setNameHash(stream.readInt()); } } } public int getRevision() { return revision; } public ArchiveReference[] getArchives() { return archives; } public int[] getValidArchiveIds() { return validArchiveIds; } public boolean isNamed() { return named; } public boolean usesWhirpool() { return usesWhirpool; } public int getCompression() { return archive.getCompression(); } }
package com.rs.cache; import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.math.BigInteger; import java.util.Arrays; import com.rs.cache.utils.CacheUtil; import com.rs.cache.utils.Whirlpool; import com.rs.lib.io.OutputStream; public final class Store { private Index[] indexes; private MainFile index255; private String path; private RandomAccessFile data; private Huffman huffman; public Store(String path, boolean newProtocol) throws IOException { this.path = path; data = new RandomAccessFile(path + "main_file_cache.dat2", "rw"); index255 = new MainFile(255, data, new RandomAccessFile(path + "main_file_cache.idx255", "rw")); int idxsCount = index255.getArchivesCount(); indexes = new Index[idxsCount]; for (int id = 0; id < idxsCount; id++) { if (id == 47) continue; Index index = new Index(index255, new MainFile(id, data, new RandomAccessFile(path + "main_file_cache.idx" + id, "rw"))); if (index.getTable() == null) continue; indexes[id] = index; } huffman = new Huffman(this); } public Store(String path) throws IOException { this(path, false); } public final byte[] getChecksumContainer(BigInteger rsaExp, BigInteger rsaMod) { byte[] checksumTable = getChecksumTable(rsaExp, rsaMod); OutputStream out = new OutputStream(); out.writeByte(255); out.writeInt(255); out.writeByte(0); out.writeInt(checksumTable.length); int offset = 10; for (int index = 0; index < checksumTable.length; index++) { if (offset == 512) { out.writeByte(255); offset = 1; } out.writeByte(checksumTable[index]); offset++; } return out.toByteArray(); } public final byte[] getChecksumTable(BigInteger rsaExp, BigInteger rsaMod) { OutputStream os = new OutputStream(); os.writeByte(indexes.length); for (int i = 0;i < indexes.length;i++) { os.writeInt(indexes[i].getCRC()); os.writeInt(indexes[i].getTable().getRevision()); os.writeBytes(indexes[i].getWhirlpool()); } byte[] archive = os.toByteArray(); OutputStream temp = new OutputStream(65); temp.writeByte(0); temp.writeBytes(Whirlpool.getWhirlpool(archive, 0, archive.length)); os.writeBytes(CacheUtil.cryptRSA(temp.toByteArray(), rsaExp, rsaMod)); return os.toByteArray(); } public Index getIndex(IndexType index) { return indexes[index.ordinal()]; } public Index[] getIndices() { return indexes; } public MainFile getIndex255() { return index255; } /* * returns index */ public int addIndex(boolean named, boolean usesWhirpool, int tableCompression) throws IOException { int id = indexes.length; Index[] newIndexes = Arrays.copyOf(indexes, indexes.length + 1); resetIndex(id, newIndexes, named, usesWhirpool, tableCompression); indexes = newIndexes; return id; } public void resetIndex(int id, boolean named, boolean usesWhirpool, int tableCompression) throws FileNotFoundException, IOException { resetIndex(id, indexes, named, usesWhirpool, tableCompression); } public void resetIndex(int id, Index[] indexes, boolean named, boolean usesWhirpool, int tableCompression) throws FileNotFoundException, IOException { OutputStream stream = new OutputStream(4); stream.writeByte(5); stream.writeByte((named ? 0x1 : 0) | (usesWhirpool ? 0x2 : 0)); stream.writeShort(0); byte[] archiveData = new byte[stream.getOffset()]; stream.setOffset(0); stream.getBytes(archiveData, 0, archiveData.length); Archive archive = new Archive(id, tableCompression, -1, archiveData); index255.putArchiveData(id, archive.compress()); indexes[id] = new Index(index255, new MainFile(id, data, new RandomAccessFile(path + "main_file_cache.idx" + id, "rw"))); } public Huffman getHuffman() { return huffman; } }
package com.rs.cache.loaders; import java.util.concurrent.ConcurrentHashMap; import com.rs.cache.ArchiveType; import com.rs.cache.Cache; import com.rs.cache.IndexType; import com.rs.lib.io.InputStream; public final class MapSpriteDefinitions { private static final ConcurrentHashMap<Integer, MapSpriteDefinitions> defs = new ConcurrentHashMap<Integer, MapSpriteDefinitions>(); public boolean aBool7726 = false; public int anInt7727; public int spriteId; int[] anIntArray7730; public int id; public static final MapSpriteDefinitions getMapSpriteDefinitions(int id) { MapSpriteDefinitions script = defs.get(id); if (script != null)// open new txt document return script; byte[] data = Cache.STORE.getIndex(IndexType.CONFIG).getFile(ArchiveType.MAP_SPRITES.getId(), id); script = new MapSpriteDefinitions(); script.id = id; if (data != null) script.readValueLoop(new InputStream(data)); defs.put(id, script); return script; } private MapSpriteDefinitions() { } private void readValueLoop(InputStream stream) { for (;;) { int opcode = stream.readUnsignedByte(); if (opcode == 0) break; readValues(stream, opcode); } } private void readValues(InputStream stream, int i) { if (i == 1) spriteId = stream.readBigSmart(); else if (2 == i) anInt7727 = stream.read24BitInt(); else if (i == 3) aBool7726 = true; else if (4 == i) spriteId = -1; } }
package com.rs.cache.loaders; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; import com.rs.cache.ArchiveType; import com.rs.cache.Cache; import com.rs.cache.IndexType; import com.rs.lib.io.InputStream; import com.rs.lib.util.Utils; public final class AreaDefinitions { private static final ConcurrentHashMap<Integer, AreaDefinitions> defs = new ConcurrentHashMap<Integer, AreaDefinitions>(); public int anInt2715; public int[] anIntArray2717; public int anInt2718; public int spriteId = -1; public int anInt2720; public int anInt2721; public int anInt2722; public int anInt2726; public int anInt2727; public boolean aBool2728; public boolean aBool2729; public boolean aBool2730; public int anInt2731; public String aString2732; int anInt2733; int anInt2734; int anInt2735; int anInt2736; public int[] anIntArray2738; int anInt2739; public String[] options; int anInt2741; public boolean aBool2742; int anInt2743; public int anInt2744; int anInt2745; public int anInt2746; public int anInt2747; public int anInt2748; public int anInt2749; public int anInt2750; public String areaName; public int anInt2752; public int anInt2753; public byte[] aByteArray2754; int anInt2755; public int anInt2756; public int anInt2757 = -1; public HashMap<Integer, Object> clientScriptMap = new HashMap<Integer, Object>(); public int id; public static final AreaDefinitions getDefinitions(int id) { AreaDefinitions area = defs.get(id); if (area != null) return area; byte[] data = Cache.STORE.getIndex(IndexType.CONFIG).getFile(ArchiveType.MAP_AREAS.getId(), id); area = new AreaDefinitions(); area.id = id; if (data != null) area.readValueLoop(new InputStream(data)); defs.put(id, area); return area; } public static void dump() throws IOException { File file = new File("worldMap.txt"); if (file.exists()) file.delete(); else file.createNewFile(); BufferedWriter writer = new BufferedWriter(new FileWriter(file));; writer.append("//Version = 727\n"); writer.flush(); for (int i = 0;i < Cache.STORE.getIndex(IndexType.CONFIG).getLastFileId(ArchiveType.MAP_AREAS.getId())+1;i++) { AreaDefinitions defs = getDefinitions(i); writer.append(i+" - "+defs); writer.newLine(); writer.flush(); } writer.close(); } AreaDefinitions() { options = new String[5]; anInt2722 = 0; aBool2728 = true; aBool2729 = false; aBool2730 = true; aBool2742 = true; } private void readValueLoop(InputStream stream) { for (;;) { int opcode = stream.readUnsignedByte(); if (opcode == 0) break; readValues(stream, opcode); } } private void readValues(InputStream stream, int i) { if (1 == i) spriteId = stream.readBigSmart(); else if (2 == i) anInt2757 = stream.readBigSmart(); else if (i == 3) areaName = stream.readString(); else if (4 == i) anInt2720 = stream.read24BitInt(); else if (5 == i) anInt2721 = stream.read24BitInt(); else if (i == 6) anInt2722 = stream.readUnsignedByte(); else if (i == 7) { int i_3_ = stream.readUnsignedByte(); if ((i_3_ & 0x1) == 0) aBool2728 = false; if (2 == (i_3_ & 0x2)) aBool2729 = true; } else if (i == 8) aBool2730 = stream.readUnsignedByte() == 1; else if (i == 9) { anInt2736 = stream.readUnsignedShort(); if (anInt2736 == 65535) anInt2736 = -1; anInt2745 = stream.readUnsignedShort(); if (anInt2745 == 65535) anInt2745 = 1; anInt2734 = stream.readInt(); anInt2735 = stream.readInt(); } else if (i >= 10 && i <= 14) options[i - 10] = stream.readString(); else if (15 == i) { int i_4_ = stream.readUnsignedByte(); anIntArray2717 = new int[2 * i_4_]; for (int i_5_ = 0; i_5_ < i_4_ * 2; i_5_++) anIntArray2717[i_5_] = stream.readShort(); anInt2715 = stream.readInt(); int i_6_ = stream.readUnsignedByte(); anIntArray2738 = new int[i_6_]; for (int i_7_ = 0; i_7_ < anIntArray2738.length; i_7_++) anIntArray2738[i_7_] = stream.readInt(); aByteArray2754 = new byte[i_4_]; for (int i_8_ = 0; i_8_ < i_4_; i_8_++) aByteArray2754[i_8_] = (byte) stream.readByte(); } else if (i == 16) aBool2742 = false; else if (17 == i) aString2732 = stream.readString(); else if (i == 18) anInt2733 = stream.readBigSmart(); else if (19 == i) anInt2718 = stream.readUnsignedShort(); else if (20 == i) { anInt2755 = stream.readUnsignedShort(); if (65535 == anInt2755) anInt2755 = 1; anInt2741 = stream.readUnsignedShort(); if (anInt2741 == 65535) anInt2741 = 1; anInt2743 = stream.readInt(); anInt2739 = stream.readInt(); } else if (i == 21) anInt2727 = stream.readInt(); else if (22 == i) anInt2726 = stream.readInt(); else if (23 == i) { anInt2748 = stream.readUnsignedByte(); anInt2749 = stream.readUnsignedByte(); anInt2756 = stream.readUnsignedByte(); } else if (24 == i) { anInt2750 = stream.readShort(); anInt2752 = stream.readShort(); } else if (i == 249) { int i_19_ = stream.readUnsignedByte(); for (int i_21_ = 0; i_21_ < i_19_; i_21_++) { boolean bool = stream.readUnsignedByte() == 1; int i_22_ = stream.read24BitInt(); if (bool) clientScriptMap.put(i_22_, stream.readString()); else clientScriptMap.put(i_22_, stream.readInt()); } } } @Override public String toString() { StringBuilder result = new StringBuilder(); String newLine = System.getProperty("line.separator"); result.append(this.getClass().getName()); result.append(" {"); result.append(newLine); // determine fields declared in this class only (no fields of // superclass) Field[] fields = this.getClass().getDeclaredFields(); // print field names paired with their values for (Field field : fields) { if (Modifier.isStatic(field.getModifiers())) continue; result.append(" "); try { result.append(field.getType().getCanonicalName() + " " + field.getName() + ": "); result.append(Utils.getFieldValue(this, field)); } catch (Throwable ex) { System.out.println(ex); } result.append(newLine); } result.append("}"); return result.toString(); } }
package com.rs.cache.loaders; import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.concurrent.ConcurrentHashMap; import com.rs.cache.ArchiveType; import com.rs.cache.Cache; import com.rs.cache.IndexType; import com.rs.lib.io.InputStream; import com.rs.lib.util.Utils; public class BASDefinitions { public int numStandAnimations; public int[] standAnimations; public int standAnimation = -1; public int standTurn1; public int standTurn2; public int walkAnimation; public int walkDir1; public int walkDir2; public int walkDir3; public int walkTurn1; public int walkTurn2; public int runningAnimation; public int runDir1; public int runDir2; public int runDir3; public int runTurn1; public int runTurn2; public int teleportingAnimation; public int teleDir1; public int teleDir2; public int teleDir3; public int teleTurn1; public int teleTurn2; public int anInt2790; public int[][] anIntArrayArray2791; public int anInt2798; public int[][] anIntArrayArray2802; public int anInt2804; public int[] anIntArray2811; public int anInt2813; public int[] anIntArray2814; public int anInt2815; public int anInt2816; public int[] anIntArray2818; public int anInt2820; public int anInt2823; public int anInt2824; public int anInt2825; public int anInt2826; public int anInt2827; public int anInt2829; public int anInt2786; public boolean aBool2787; private static final ConcurrentHashMap<Integer, BASDefinitions> RENDER_ANIM_CACHE = new ConcurrentHashMap<Integer, BASDefinitions>(); public static void main(String[] args) throws IOException { Cache.init("../darkan-cache/"); int search = 772; for (int i = 0;i < Utils.getBASAnimDefSize();i++) { BASDefinitions def = BASDefinitions.getDefs(i); if (def.walkAnimation == search || def.runningAnimation == search || def.walkDir1 == search || def.walkDir2 == search || def.walkDir3 == search || def.standAnimation == search) System.out.println(i); } } public static final BASDefinitions getDefs(int emoteId) { BASDefinitions defs = RENDER_ANIM_CACHE.get(emoteId); if (defs != null) return defs; if (emoteId == -1) return null; byte[] data = Cache.STORE.getIndex(IndexType.CONFIG).getFile(ArchiveType.BAS.getId(), emoteId); defs = new BASDefinitions(); if (data != null) defs.readValueLoop(new InputStream(data)); RENDER_ANIM_CACHE.put(emoteId, defs); return defs; } @Override public String toString() { StringBuilder result = new StringBuilder(); String newLine = System.getProperty("line.separator"); result.append(this.getClass().getName()); result.append(" {"); result.append(newLine); // determine fields declared in this class only (no fields of // superclass) Field[] fields = this.getClass().getDeclaredFields(); // print field names paired with their values for (Field field : fields) { if (Modifier.isStatic(field.getModifiers())) continue; result.append(" "); try { result.append(field.getType().getCanonicalName() + " " + field.getName() + ": "); result.append(Utils.getFieldValue(this, field)); } catch (Throwable ex) { System.out.println(ex); } result.append(newLine); } result.append("}"); return result.toString(); } private void readValueLoop(InputStream stream) { for (;;) { int opcode = stream.readUnsignedByte(); if (opcode == 0) break; readValues(stream, opcode); } } private void readValues(InputStream stream, int opcode) { if (1 == opcode) { standAnimation = stream.readBigSmart(); walkAnimation = stream.readBigSmart(); } else if (2 == opcode) teleportingAnimation = stream.readBigSmart(); else if (opcode == 3) teleDir3 = stream.readBigSmart(); else if (opcode == 4) teleDir2 = stream.readBigSmart(); else if (5 == opcode) teleDir1 = stream.readBigSmart(); else if (opcode == 6) runningAnimation = stream.readBigSmart(); else if (opcode == 7) runDir3 = stream.readBigSmart(); else if (8 == opcode) runDir2 = stream.readBigSmart(); else if (opcode == 9) runDir1 = stream.readBigSmart(); else if (26 == opcode) { anInt2786 = ((short) (stream.readUnsignedByte() * 4)); anInt2829 = ((short) (stream.readUnsignedByte() * 4)); } else if (opcode == 27) { if (anIntArrayArray2802 == null) anIntArrayArray2802 = new int[15][]; int i_1_ = stream.readUnsignedByte(); anIntArrayArray2802[i_1_] = new int[6]; for (int i_2_ = 0; i_2_ < 6; i_2_++) anIntArrayArray2802[i_1_][i_2_] = stream.readShort(); } else if (opcode == 28) { int i_3_ = stream.readUnsignedByte(); anIntArray2811 = new int[i_3_]; for (int i_4_ = 0; i_4_ < i_3_; i_4_++) { anIntArray2811[i_4_] = stream.readUnsignedByte(); if (255 == anIntArray2811[i_4_]) anIntArray2811[i_4_] = -1; } } else if (29 == opcode) anInt2820 = stream.readUnsignedByte(); else if (30 == opcode) anInt2804 = stream.readUnsignedShort(); else if (opcode == 31) anInt2825 = stream.readUnsignedByte(); else if (32 == opcode) anInt2823 = stream.readUnsignedShort(); else if (33 == opcode) anInt2824 = stream.readShort(); else if (opcode == 34) anInt2816 = stream.readUnsignedByte(); else if (opcode == 35) anInt2815 = stream.readUnsignedShort(); else if (36 == opcode) anInt2827 = stream.readShort(); else if (37 == opcode) anInt2826 = stream.readUnsignedByte(); else if (38 == opcode) standTurn1 = stream.readBigSmart(); else if (opcode == 39) standTurn2 = stream.readBigSmart(); else if (opcode == 40) walkDir3 = stream.readBigSmart(); else if (41 == opcode) walkDir2 = stream.readBigSmart(); else if (42 == opcode) walkDir1 = stream.readBigSmart(); else if (opcode == 43) stream.readUnsignedShort(); else if (opcode == 44) stream.readUnsignedShort(); else if (45 == opcode) anInt2798 = stream.readUnsignedShort(); else if (46 == opcode) teleTurn1 = stream.readBigSmart(); else if (opcode == 47) teleTurn2 = stream.readBigSmart(); else if (opcode == 48) runTurn1 = stream.readBigSmart(); else if (49 == opcode) runTurn2 = stream.readBigSmart(); else if (opcode == 50) walkTurn1 = stream.readBigSmart(); else if (opcode == 51) walkTurn2 = stream.readBigSmart(); else if (52 == opcode) { int i_5_ = stream.readUnsignedByte(); anIntArray2814 = new int[i_5_]; standAnimations = new int[i_5_]; for (int i_6_ = 0; i_6_ < i_5_; i_6_++) { anIntArray2814[i_6_] = stream.readBigSmart(); int i_7_ = stream.readUnsignedByte(); standAnimations[i_6_] = i_7_; numStandAnimations += i_7_; } } else if (53 == opcode) aBool2787 = false; else if (opcode == 54) { anInt2813 = (stream.readUnsignedByte() << 6); anInt2790 = (stream.readUnsignedByte() << 6); } else if (opcode == 55) { if (anIntArray2818 == null) anIntArray2818 = new int[15]; int i_8_ = stream.readUnsignedByte(); anIntArray2818[i_8_] = stream.readUnsignedShort(); } else if (opcode == 56) { if (null == anIntArrayArray2791) anIntArrayArray2791 = new int[15][]; int i_9_ = stream.readUnsignedByte(); anIntArrayArray2791[i_9_] = new int[3]; for (int i_10_ = 0; i_10_ < 3; i_10_++) anIntArrayArray2791[i_9_][i_10_] = stream.readShort(); } } public BASDefinitions() { anIntArray2814 = null; standAnimations = null; numStandAnimations = 0; standTurn1 = -1; standTurn2 = -1; walkAnimation = -1; walkDir3 = -1; walkDir2 = -1; walkDir1 = -1; runningAnimation = -1; runDir3 = -1; runDir2 = -1; runDir1 = -1; teleportingAnimation = -1; teleDir3 = -1; teleDir2 = -1; teleDir1 = -1; teleTurn1 = -1; teleTurn2 = -1; runTurn1 = -1; runTurn2 = -1; walkTurn1 = -1; walkTurn2 = -1; anInt2786 = 0; anInt2829 = 0; anInt2813 = 0; anInt2790 = 0; anInt2820 = 0; anInt2804 = 0; anInt2825 = 0; anInt2823 = 0; anInt2824 = 0; anInt2816 = 0; anInt2815 = 0; anInt2827 = 0; anInt2826 = -1; anInt2798 = -1; aBool2787 = true; } }
package com.rs.cache.loaders; public enum Bonus { STAB_ATT, //0 SLASH_ATT, //1 CRUSH_ATT, //2 MAGIC_ATT, //3 RANGE_ATT, //4 STAB_DEF, //5 SLASH_DEF, //6 CRUSH_DEF, //7 MAGIC_DEF, //8 RANGE_DEF, //9 SUMM_DEF, //10 ABSORB_MELEE, //11 ABSORB_MAGIC, //12 ABSORB_RANGE, //13 MELEE_STR, //14 RANGE_STR, //15 PRAYER, //16 MAGIC_STR //17 }
package com.rs.cache.loaders; import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.HashSet; import java.util.Set; import com.rs.cache.ArchiveType; import com.rs.cache.Cache; import com.rs.cache.IndexType; import com.rs.cache.loaders.cs2.CS2Type; import com.rs.lib.io.InputStream; import com.rs.lib.util.Utils; public class ClanVarDefinitions { private static final HashMap<Integer, ClanVarDefinitions> CACHE = new HashMap<>(); public int id; public char aChar4832; public CS2Type type; public int baseVar = -1; public int startBit; public int endBit; public static void main(String[] args) throws IOException { Cache.init("../cache/"); Set<Integer> varbits = new HashSet<>(); for (int i = 0;i < Cache.STORE.getIndex(IndexType.CONFIG).getLastFileId(ArchiveType.CLAN_VAR.getId()) + 1;i++) { ClanVarDefinitions defs = getDefs(i); if (defs.baseVar != -1) varbits.add(defs.baseVar); } for (int i = 0;i < Cache.STORE.getIndex(IndexType.CONFIG).getLastFileId(ArchiveType.CLAN_VAR.getId()) + 1;i++) { ClanVarDefinitions defs = getDefs(i); if (varbits.contains(i)) continue; System.out.println("/*"+i + "\t" + defs.type + "\t" + defs.getMaxSize() +"\t\t*/"); } } public static final ClanVarDefinitions getDefs(int id) { ClanVarDefinitions defs = CACHE.get(id); if (defs != null) return defs; byte[] data = Cache.STORE.getIndex(IndexType.CONFIG).getFile(ArchiveType.CLAN_VAR.getId(), id); defs = new ClanVarDefinitions(); defs.id = id; if (data != null) defs.readValueLoop(new InputStream(data)); CACHE.put(id, defs); return defs; } private void readValueLoop(InputStream stream) { for (;;) { int opcode = stream.readUnsignedByte(); if (opcode == 0) break; readValues(stream, opcode); } } private void readValues(InputStream stream, int opcode) { if (opcode == 1) { this.aChar4832 = Utils.cp1252ToChar((byte) stream.readByte()); this.type = CS2Type.forJagexDesc(this.aChar4832); } else if (opcode == 3) { this.baseVar = stream.readUnsignedShort(); this.startBit = stream.readUnsignedByte(); this.endBit = stream.readUnsignedByte(); } } @Override public String toString() { StringBuilder result = new StringBuilder(); String newLine = System.getProperty("line.separator"); result.append(this.getClass().getName()); result.append(" {"); result.append(newLine); // determine fields declared in this class only (no fields of // superclass) Field[] fields = this.getClass().getDeclaredFields(); // print field names paired with their values for (Field field : fields) { if (Modifier.isStatic(field.getModifiers())) continue; result.append(" "); try { result.append(field.getType().getCanonicalName() + " " + field.getName() + ": "); result.append(Utils.getFieldValue(this, field)); } catch (Throwable ex) { System.out.println(ex); } result.append(newLine); } result.append("}"); return result.toString(); } public long getMaxSize() { if (baseVar == -1) { if (type == CS2Type.INT) return Integer.MAX_VALUE; else if (type == CS2Type.LONG) return Long.MAX_VALUE; else return -1; } else { return 1 << (endBit - startBit); } } }
package com.rs.cache.loaders; import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.HashSet; import java.util.Set; import com.rs.cache.ArchiveType; import com.rs.cache.Cache; import com.rs.cache.IndexType; import com.rs.cache.loaders.cs2.CS2Type; import com.rs.lib.io.InputStream; import com.rs.lib.util.Utils; public class ClanVarSettingsDefinitions { private static final HashMap<Integer, ClanVarSettingsDefinitions> CACHE = new HashMap<>(); public int id; public char aChar4832; public CS2Type type; public int baseVar = -1; public int startBit; public int endBit; public static void main(String[] args) throws IOException { Cache.init("../cache/"); Set<Integer> varbits = new HashSet<>(); for (int i = 0;i < Cache.STORE.getIndex(IndexType.CONFIG).getLastFileId(ArchiveType.CLAN_VAR_SETTINGS.getId()) + 1;i++) { ClanVarSettingsDefinitions defs = getDefs(i); if (defs.baseVar != -1) varbits.add(defs.baseVar); } for (int i = 0;i < Cache.STORE.getIndex(IndexType.CONFIG).getLastFileId(ArchiveType.CLAN_VAR_SETTINGS.getId()) + 1;i++) { ClanVarSettingsDefinitions defs = getDefs(i); if (varbits.contains(i)) continue; System.out.println("/*"+i + "\t" + defs.type + "\t" + defs.getMaxSize() +"\t\t*/"); } } public static final ClanVarSettingsDefinitions getDefs(int id) { ClanVarSettingsDefinitions defs = CACHE.get(id); if (defs != null) return defs; byte[] data = Cache.STORE.getIndex(IndexType.CONFIG).getFile(ArchiveType.CLAN_VAR_SETTINGS.getId(), id); defs = new ClanVarSettingsDefinitions(); defs.id = id; if (data != null) defs.readValueLoop(new InputStream(data)); CACHE.put(id, defs); return defs; } private void readValueLoop(InputStream stream) { for (;;) { int opcode = stream.readUnsignedByte(); if (opcode == 0) break; readValues(stream, opcode); } } private void readValues(InputStream stream, int opcode) { if (opcode == 1) { this.aChar4832 = Utils.cp1252ToChar((byte) stream.readByte()); this.type = CS2Type.forJagexDesc(this.aChar4832); } else if (opcode == 2) { this.baseVar = stream.readUnsignedShort(); this.startBit = stream.readUnsignedByte(); this.endBit = stream.readUnsignedByte(); } } public long getMaxSize() { if (baseVar == -1) { if (type == CS2Type.INT) return Integer.MAX_VALUE; else if (type == CS2Type.LONG) return Long.MAX_VALUE; else return -1; } else { return 1 << (endBit - startBit); } } @Override public String toString() { StringBuilder result = new StringBuilder(); String newLine = System.getProperty("line.separator"); result.append(this.getClass().getName()); result.append(" {"); result.append(newLine); // determine fields declared in this class only (no fields of // superclass) Field[] fields = this.getClass().getDeclaredFields(); // print field names paired with their values for (Field field : fields) { if (Modifier.isStatic(field.getModifiers())) continue; result.append(" "); try { result.append(field.getType().getCanonicalName() + " " + field.getName() + ": "); result.append(Utils.getFieldValue(this, field)); } catch (Throwable ex) { System.out.println(ex); } result.append(newLine); } result.append("}"); return result.toString(); } }
package com.rs.cache.loaders; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.HashMap; import com.rs.cache.ArchiveType; import com.rs.cache.Cache; import com.rs.cache.IndexType; import com.rs.lib.io.InputStream; import com.rs.lib.util.Utils; public class CursorDefinitions { private static final HashMap<Integer, CursorDefinitions> CACHE = new HashMap<>(); public int id; int spriteId; public int anInt5002; public int anInt5000; public static final CursorDefinitions getDefs(int id) { CursorDefinitions defs = CACHE.get(id); if (defs != null) return defs; byte[] data = Cache.STORE.getIndex(IndexType.CONFIG).getFile(ArchiveType.CURSORS.getId(), id); defs = new CursorDefinitions(); defs.id = id; if (data != null) defs.readValueLoop(new InputStream(data)); CACHE.put(id, defs); return defs; } private void readValueLoop(InputStream stream) { for (;;) { int opcode = stream.readUnsignedByte(); if (opcode == 0) break; readValues(stream, opcode); } } private void readValues(InputStream stream, int opcode) { if (opcode == 1) { this.spriteId = stream.readBigSmart(); } else if (opcode == 2) { this.anInt5002 = stream.readUnsignedByte(); this.anInt5000 = stream.readUnsignedByte(); } } public SpriteDefinitions getSprite() { return SpriteDefinitions.getSprite(spriteId, 0); } @Override public String toString() { StringBuilder result = new StringBuilder(); String newLine = System.getProperty("line.separator"); result.append(this.getClass().getName()); result.append(" {"); result.append(newLine); // determine fields declared in this class only (no fields of // superclass) Field[] fields = this.getClass().getDeclaredFields(); // print field names paired with their values for (Field field : fields) { if (Modifier.isStatic(field.getModifiers())) continue; result.append(" "); try { result.append(field.getType().getCanonicalName() + " " + field.getName() + ": "); result.append(Utils.getFieldValue(this, field)); } catch (Throwable ex) { System.out.println(ex); } result.append(newLine); } result.append("}"); return result.toString(); } }
package com.rs.cache.loaders; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.HashMap; import com.rs.lib.io.InputStream; import com.rs.lib.util.Utils; public class DefinitionsTemplate { private static final HashMap<Integer, DefinitionsTemplate> CACHE = new HashMap<>(); public int id; public static final DefinitionsTemplate getDefs(int id) { DefinitionsTemplate defs = CACHE.get(id); if (defs != null) return defs; //byte[] data = Cache.STORE.getIndex(IndexType.).getFile(FileType., id); byte[] data = new byte[5]; defs = new DefinitionsTemplate(); defs.id = id; if (data != null) defs.readValueLoop(new InputStream(data)); CACHE.put(id, defs); return defs; } private void readValueLoop(InputStream stream) { for (;;) { int opcode = stream.readUnsignedByte(); if (opcode == 0) break; readValues(stream, opcode); } } private void readValues(InputStream stream, int opcode) { } @Override public String toString() { StringBuilder result = new StringBuilder(); String newLine = System.getProperty("line.separator"); result.append(this.getClass().getName()); result.append(" {"); result.append(newLine); // determine fields declared in this class only (no fields of // superclass) Field[] fields = this.getClass().getDeclaredFields(); // print field names paired with their values for (Field field : fields) { if (Modifier.isStatic(field.getModifiers())) continue; result.append(" "); try { result.append(field.getType().getCanonicalName() + " " + field.getName() + ": "); result.append(Utils.getFieldValue(this, field)); } catch (Throwable ex) { System.out.println(ex); } result.append(newLine); } result.append("}"); return result.toString(); } }
package com.rs.cache.loaders; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; import com.rs.cache.ArchiveType; import com.rs.cache.Cache; import com.rs.cache.IndexType; import com.rs.cache.loaders.cs2.CS2Type; import com.rs.lib.Constants; import com.rs.lib.game.WorldTile; import com.rs.lib.io.InputStream; import com.rs.lib.util.Utils; public final class EnumDefinitions { public CS2Type keyType; public char keyTypeChar; public CS2Type valueType; public char valueTypeChar; private String defaultStringValue; private int defaultIntValue; private HashMap<Long, Object> values; private static final ConcurrentHashMap<Integer, EnumDefinitions> ENUMS_CACHE = new ConcurrentHashMap<Integer, EnumDefinitions>(); public static void main(String[] args) throws IOException { File file = new File("enums.txt"); if (file.exists()) file.delete(); else file.createNewFile(); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writer.append("//Version = 727\n"); writer.flush(); for (int i = 0; i < 100000; i++) { EnumDefinitions map = getEnum(i); if (map == null || map.getValues() == null) continue; writer.append(i + ": " + map.toString()); writer.newLine(); writer.flush(); System.out.println(i + " - " + map.getValues().toString()); } writer.close(); } public static final EnumDefinitions getEnum(int enumId) { EnumDefinitions script = ENUMS_CACHE.get(enumId); if (script != null) return script; byte[] data = Cache.STORE.getIndex(IndexType.ENUMS).getFile(ArchiveType.ENUMS.archiveId(enumId), ArchiveType.ENUMS.fileId(enumId)); script = new EnumDefinitions(); if (data != null) script.readValueLoop(new InputStream(data)); ENUMS_CACHE.put(enumId, script); return script; } public int getDefaultIntValue() { return defaultIntValue; } public String getDefaultStringValue() { return defaultStringValue; } public HashMap<Long, Object> getValues() { return values; } public Object getValue(long key) { if (values == null) return null; return values.get(key); } public long getKeyForValue(Object value) { for (Long key : values.keySet()) { if (values.get(key).equals(value)) return key; } return -1; } public int getSize() { if (values == null) return 0; return values.size(); } public int getIntValue(long key) { if (values == null) return defaultIntValue; Object value = values.get(key); if (value == null || !(value instanceof Integer)) return defaultIntValue; return (Integer) value; } public int getKeyIndex(long key) { if (values == null) return -1; int i = 0; for (long k : values.keySet()) { if (k == key) return i; i++; } return -1; } public int getIntValueAtIndex(int i) { if (values == null) return -1; return (int) values.values().toArray()[i]; } public String getStringValue(long key) { if (values == null) return defaultStringValue; Object value = values.get(key); if (value == null || !(value instanceof String)) return defaultStringValue; return (String) value; } private void readValueLoop(InputStream stream) { for (;;) { int opcode = stream.readUnsignedByte(); if (opcode == 0) break; readValues(stream, opcode); } } private void readValues(InputStream stream, int opcode) { if (opcode == 1) { keyTypeChar = Utils.cp1252ToChar((byte) stream.readByte()); keyType = CS2Type.forJagexDesc(keyTypeChar); } else if (opcode == 2) { valueTypeChar = Utils.cp1252ToChar((byte) stream.readByte()); valueType = CS2Type.forJagexDesc(valueTypeChar); } else if (opcode == 3) defaultStringValue = stream.readString(); else if (opcode == 4) defaultIntValue = stream.readInt(); else if (opcode == 5 || opcode == 6 || opcode == 7 || opcode == 8) { int count = stream.readUnsignedShort(); int loop = opcode == 7 || opcode == 8 ? stream.readUnsignedShort() : count; if (values == null) values = new HashMap<Long, Object>(Utils.getHashMapSize(count)); for (int i = 0; i < loop; i++) { int key = opcode == 7 || opcode == 8 ? stream.readUnsignedShort() : stream.readInt(); Object value = opcode == 5 || opcode == 7 ? stream.readString() : stream.readInt(); values.put((long) key, value); } } } private EnumDefinitions() { defaultStringValue = "null"; } public Object keyToType(long l) { if (keyType == CS2Type.ICOMPONENT) { long interfaceId = l >> 16; long componentId = l - (interfaceId << 16); return "IComponent("+interfaceId+", "+componentId+")"; } else if (keyType == CS2Type.LOCATION) { return WorldTile.of((int) l); } else if (keyType == CS2Type.SKILL) { int idx = (int) l; if (idx >= Constants.SKILL_NAME.length) return l; return idx+"("+Constants.SKILL_NAME[((int) l)]+")"; } else if (keyType == CS2Type.ITEM) { return l+"("+ItemDefinitions.getDefs((int) l).getName()+")"; } else if (keyType == CS2Type.NPCDEF) { return l+"("+NPCDefinitions.getDefs((int) l).getName()+")"; } else if (keyType == CS2Type.STRUCT) { return l + ": " + StructDefinitions.getStruct((int) l); } return l; } public Object valToType(Object o) { if (valueType == CS2Type.ICOMPONENT) { if (o instanceof String) return o; long interfaceId = ((int) o) >> 16; long componentId = ((int) o) - (interfaceId << 16); return "IComponent("+interfaceId+", "+componentId+")"; } else if (valueType == CS2Type.LOCATION) { if (o instanceof String) return o; return WorldTile.of(((int) o)); } else if (valueType == CS2Type.SKILL) { if (o instanceof String) return o; int idx = (int) o; if (idx >= Constants.SKILL_NAME.length) return o; return idx+"("+Constants.SKILL_NAME[((int) o)]+")"; } else if (valueType == CS2Type.ITEM) { if (o instanceof String) return o; return ((int) o)+" ("+ItemDefinitions.getDefs(((int) o)).getName()+")"; } else if (valueType == CS2Type.NPCDEF) { if (o instanceof String) return o; return ((int) o)+" ("+NPCDefinitions.getDefs(((int) o)).getName()+")"; } else if (valueType == CS2Type.STRUCT) { return o + ": " + StructDefinitions.getStruct((int) o); } else if (valueType == CS2Type.ENUM) { return o + ": " + getEnum((int) o); } return o; } @Override public String toString() { StringBuilder s = new StringBuilder(); if (getValues() == null) return "null"; s.append("<"+keyType+", "+valueType+"> - " + getDefaultStringValue() + " - " + getDefaultIntValue() + " { "); s.append("\r\n"); for (Long l : getValues().keySet()) { s.append(keyToType(l)); s.append(" = "); s.append(valToType(getValues().get(l))); s.append("\r\n"); } s.append("} \r\n"); return s.toString(); } }
package com.rs.cache.loaders; import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.HashMap; import com.rs.cache.Cache; import com.rs.cache.IndexType; import com.rs.lib.io.InputStream; import com.rs.lib.util.Utils; public class FontMetrics { private static final HashMap<Integer, FontMetrics> CACHE = new HashMap<>(); private static int p11Full, p12Full, b12Full; public int id; byte[] characters; public int anInt4975; public int anInt4978; public int anInt4979; byte[][] kerning; public static void main(String[] args) throws IOException { //Cache.init(); p11Full = Cache.STORE.getIndex(IndexType.NORMAL_FONTS).getArchiveId("p11_full"); p12Full = Cache.STORE.getIndex(IndexType.NORMAL_FONTS).getArchiveId("p12_full"); b12Full = Cache.STORE.getIndex(IndexType.NORMAL_FONTS).getArchiveId("b12_full"); System.out.println(p11Full); System.out.println(p12Full); System.out.println(b12Full); System.out.println(get(p11Full)); System.out.println(get(p12Full)); System.out.println(get(b12Full)); // for (int i = 0;i < Cache.STORE.getIndex(IndexType.FONT_METRICS).getLastArchiveId()+1;i++) { // FontMetrics defs = get(i); // System.out.println(defs); // } } public static final FontMetrics get(int id) { FontMetrics defs = CACHE.get(id); if (defs != null) return defs; byte[] data = Cache.STORE.getIndex(IndexType.FONT_METRICS).getFile(id); defs = new FontMetrics(); defs.id = id; if (data != null) defs.decode(new InputStream(data)); CACHE.put(id, defs); return defs; } private void decode(InputStream stream) { int i_3 = stream.readUnsignedByte(); if (i_3 != 0) { throw new RuntimeException(""); } else { boolean bool_4 = stream.readUnsignedByte() == 1; this.characters = new byte[256]; stream.readBytes(this.characters, 0, 256); if (bool_4) { int[] ints_5 = new int[256]; int[] ints_6 = new int[256]; int i_7; for (i_7 = 0; i_7 < 256; i_7++) { ints_5[i_7] = stream.readUnsignedByte(); } for (i_7 = 0; i_7 < 256; i_7++) { ints_6[i_7] = stream.readUnsignedByte(); } byte[][] bytes_12 = new byte[256][]; int i_10; for (int i_8 = 0; i_8 < 256; i_8++) { bytes_12[i_8] = new byte[ints_5[i_8]]; byte b_9 = 0; for (i_10 = 0; i_10 < bytes_12[i_8].length; i_10++) { b_9 += stream.readByte(); bytes_12[i_8][i_10] = b_9; } } byte[][] bytes_13 = new byte[256][]; int i_14; for (i_14 = 0; i_14 < 256; i_14++) { bytes_13[i_14] = new byte[ints_5[i_14]]; byte b_15 = 0; for (int i_11 = 0; i_11 < bytes_13[i_14].length; i_11++) { b_15 += stream.readByte(); bytes_13[i_14][i_11] = b_15; } } this.kerning = new byte[256][256]; for (i_14 = 0; i_14 < 256; i_14++) { if (i_14 != 32 && i_14 != 160) { for (i_10 = 0; i_10 < 256; i_10++) { if (i_10 != 32 && i_10 != 160) { this.kerning[i_14][i_10] = (byte) Utils.calculateKerning(bytes_12, bytes_13, ints_6, this.characters, ints_5, i_14, i_10); } } } } this.anInt4975 = ints_6[32] + ints_5[32]; } else { this.anInt4975 = stream.readUnsignedByte(); } stream.readUnsignedByte(); stream.readUnsignedByte(); this.anInt4978 = stream.readUnsignedByte(); this.anInt4979 = stream.readUnsignedByte(); } } @Override public String toString() { StringBuilder result = new StringBuilder(); String newLine = System.getProperty("line.separator"); result.append(this.getClass().getName()); result.append(" {"); result.append(newLine); // determine fields declared in this class only (no fields of // superclass) Field[] fields = this.getClass().getDeclaredFields(); // print field names paired with their values for (Field field : fields) { if (Modifier.isStatic(field.getModifiers())) continue; result.append(" "); try { result.append(field.getType().getCanonicalName() + " " + field.getName() + ": "); result.append(Utils.getFieldValue(this, field)); } catch (Throwable ex) { System.out.println(ex); } result.append(newLine); } result.append("}"); return result.toString(); } }
package com.rs.cache.loaders; import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.HashMap; import com.rs.cache.ArchiveType; import com.rs.cache.Cache; import com.rs.cache.IndexType; import com.rs.lib.io.InputStream; import com.rs.lib.util.Utils; public class HitbarDefinitions { private static final HashMap<Integer, HitbarDefinitions> CACHE = new HashMap<>(); public int id; public int anInt2446 = 255; public int anInt2440 = 255; public int anInt2439 = -1; public int anInt2443 = 70; int anInt2444 = -1; int anInt2445 = -1; int anInt2441 = -1; int anInt2447 = -1; public int anInt2442 = 1; public static void main(String[] args) throws IOException { //Cache.init(); for (int i = 0;i < Cache.STORE.getIndex(IndexType.CONFIG).getLastFileId(ArchiveType.HITBARS.getId())+1;i++) { HitbarDefinitions defs = getDefs(i); System.out.println(defs); } } public static final HitbarDefinitions getDefs(int id) { HitbarDefinitions defs = CACHE.get(id); if (defs != null) return defs; byte[] data = Cache.STORE.getIndex(IndexType.CONFIG).getFile(ArchiveType.HITBARS.getId(), id); defs = new HitbarDefinitions(); defs.id = id; if (data != null) defs.readValueLoop(new InputStream(data)); CACHE.put(id, defs); return defs; } private void readValueLoop(InputStream stream) { for (;;) { int opcode = stream.readUnsignedByte(); if (opcode == 0) break; readValues(stream, opcode); } } private void readValues(InputStream stream, int opcode) { if (opcode == 1) { stream.readUnsignedShort(); } else if (opcode == 2) { this.anInt2446 = stream.readUnsignedByte(); } else if (opcode == 3) { this.anInt2440 = stream.readUnsignedByte(); } else if (opcode == 4) { this.anInt2439 = 0; } else if (opcode == 5) { this.anInt2443 = stream.readUnsignedShort(); } else if (opcode == 6) { stream.readUnsignedByte(); } else if (opcode == 7) { this.anInt2444 = stream.readBigSmart(); } else if (opcode == 8) { this.anInt2445 = stream.readBigSmart(); } else if (opcode == 9) { this.anInt2441 = stream.readBigSmart(); } else if (opcode == 10) { this.anInt2447 = stream.readBigSmart(); } else if (opcode == 11) { this.anInt2439 = stream.readUnsignedShort(); } } @Override public String toString() { StringBuilder result = new StringBuilder(); String newLine = System.getProperty("line.separator"); result.append(this.getClass().getName()); result.append(" {"); result.append(newLine); // determine fields declared in this class only (no fields of // superclass) Field[] fields = this.getClass().getDeclaredFields(); // print field names paired with their values for (Field field : fields) { if (Modifier.isStatic(field.getModifiers())) continue; result.append(" "); try { result.append(field.getType().getCanonicalName() + " " + field.getName() + ": "); result.append(Utils.getFieldValue(this, field)); } catch (Throwable ex) { System.out.println(ex); } result.append(newLine); } result.append("}"); return result.toString(); } }
package com.rs.cache.loaders; import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.HashMap; import com.rs.cache.ArchiveType; import com.rs.cache.Cache; import com.rs.cache.IndexType; import com.rs.lib.io.InputStream; import com.rs.lib.util.Utils; public class HitsplatDefinitions { private static final HashMap<Integer, HitsplatDefinitions> CACHE = new HashMap<>(); public int id; public int anInt2849 = -1; public int anInt2844 = 16777215; public boolean aBool2838 = false; int anInt2842 = -1; int anInt2851 = -1; int anInt2843 = -1; int anInt2845 = -1; public int anInt2846 = 0; String aString2840 = ""; public int anInt2841 = 70; public int anInt2833 = 0; public int anInt2847 = -1; public int anInt2839 = -1; public int anInt2832 = 0; public static void main(String[] args) throws IOException { //Cache.init(); for (int i = 0;i < Cache.STORE.getIndex(IndexType.CONFIG).getLastFileId(ArchiveType.HITSPLATS.getId())+1;i++) { HitsplatDefinitions defs = getDefs(i); System.out.println(defs); } } public static final HitsplatDefinitions getDefs(int id) { HitsplatDefinitions defs = CACHE.get(id); if (defs != null) return defs; byte[] data = Cache.STORE.getIndex(IndexType.CONFIG).getFile(ArchiveType.HITSPLATS.getId(), id); defs = new HitsplatDefinitions(); defs.id = id; if (data != null) defs.readValueLoop(new InputStream(data)); CACHE.put(id, defs); return defs; } private void readValueLoop(InputStream stream) { for (;;) { int opcode = stream.readUnsignedByte(); if (opcode == 0) break; readValues(stream, opcode); } } private void readValues(InputStream stream, int opcode) { if (opcode == 1) { this.anInt2849 = stream.readBigSmart(); } else if (opcode == 2) { this.anInt2844 = stream.read24BitUnsignedInteger(); this.aBool2838 = true; } else if (opcode == 3) { this.anInt2842 = stream.readBigSmart(); } else if (opcode == 4) { this.anInt2851 = stream.readBigSmart(); } else if (opcode == 5) { this.anInt2843 = stream.readBigSmart(); } else if (opcode == 6) { this.anInt2845 = stream.readBigSmart(); } else if (opcode == 7) { this.anInt2846 = stream.readShort(); } else if (opcode == 8) { //TODO check readGJString compare to readJagString this.aString2840 = stream.readGJString(); } else if (opcode == 9) { this.anInt2841 = stream.readUnsignedShort(); } else if (opcode == 10) { this.anInt2833 = stream.readShort(); } else if (opcode == 11) { this.anInt2847 = 0; } else if (opcode == 12) { this.anInt2839 = stream.readUnsignedByte(); } else if (opcode == 13) { this.anInt2832 = stream.readShort(); } else if (opcode == 14) { this.anInt2847 = stream.readUnsignedShort(); } } @Override public String toString() { StringBuilder result = new StringBuilder(); String newLine = System.getProperty("line.separator"); result.append(this.getClass().getName()); result.append(" {"); result.append(newLine); // determine fields declared in this class only (no fields of // superclass) Field[] fields = this.getClass().getDeclaredFields(); // print field names paired with their values for (Field field : fields) { if (Modifier.isStatic(field.getModifiers())) continue; result.append(" "); try { result.append(field.getType().getCanonicalName() + " " + field.getName() + ": "); result.append(Utils.getFieldValue(this, field)); } catch (Throwable ex) { System.out.println(ex); } result.append(newLine); } result.append("}"); return result.toString(); } }
package com.rs.cache.loaders; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.HashMap; import com.rs.cache.ArchiveType; import com.rs.cache.Cache; import com.rs.cache.IndexType; import com.rs.lib.io.InputStream; import com.rs.lib.util.Utils; public class IdentiKitDefinitions { private static final HashMap<Integer, IdentiKitDefinitions> CACHE = new HashMap<>(); public int id; int[] modelIds; short[] originalColours; short[] replacementColours; short[] originalTextures; short[] replacementTextures; int[] headModels = new int[] { -1, -1, -1, -1, -1 }; public static final IdentiKitDefinitions getDefs(int id) { IdentiKitDefinitions defs = CACHE.get(id); if (defs != null) return defs; byte[] data = Cache.STORE.getIndex(IndexType.CONFIG).getFile(ArchiveType.IDENTIKIT.getId(), id); defs = new IdentiKitDefinitions(); defs.id = id; if (data != null) defs.readValueLoop(new InputStream(data)); CACHE.put(id, defs); return defs; } private void readValueLoop(InputStream stream) { for (;;) { int opcode = stream.readUnsignedByte(); if (opcode == 0) break; readValues(stream, opcode); } } private void readValues(InputStream buffer, int opcode) { if (opcode == 1) { buffer.readUnsignedByte(); } else if (opcode == 2) { int count = buffer.readUnsignedByte(); this.modelIds = new int[count]; for (int i_5 = 0; i_5 < count; i_5++) { this.modelIds[i_5] = buffer.readBigSmart(); } } else if (opcode == 40) { int count = buffer.readUnsignedByte(); this.originalColours = new short[count]; this.replacementColours = new short[count]; for (int i_5 = 0; i_5 < count; i_5++) { this.originalColours[i_5] = (short) buffer.readUnsignedShort(); this.replacementColours[i_5] = (short) buffer.readUnsignedShort(); } } else if (opcode == 41) { int count = buffer.readUnsignedByte(); this.originalTextures = new short[count]; this.replacementTextures = new short[count]; for (int i_5 = 0; i_5 < count; i_5++) { this.originalTextures[i_5] = (short) buffer.readUnsignedShort(); this.replacementTextures[i_5] = (short) buffer.readUnsignedShort(); } } else if (opcode >= 60 && opcode < 70) { this.headModels[opcode - 60] = buffer.readBigSmart(); } } @Override public String toString() { StringBuilder result = new StringBuilder(); String newLine = System.getProperty("line.separator"); result.append(this.getClass().getName()); result.append(" {"); result.append(newLine); // determine fields declared in this class only (no fields of // superclass) Field[] fields = this.getClass().getDeclaredFields(); // print field names paired with their values for (Field field : fields) { if (Modifier.isStatic(field.getModifiers())) continue; result.append(" "); try { result.append(field.getType().getCanonicalName() + " " + field.getName() + ": "); result.append(Utils.getFieldValue(this, field)); } catch (Throwable ex) { System.out.println(ex); } result.append(newLine); } result.append("}"); return result.toString(); } }
package com.rs.cache.loaders; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.concurrent.ConcurrentHashMap; import com.rs.cache.ArchiveType; import com.rs.cache.Cache; import com.rs.cache.IndexType; import com.rs.cache.Store; import com.rs.lib.io.InputStream; import com.rs.lib.io.OutputStream; import com.rs.lib.util.Utils; public final class InventoryDefinitions { public int id; public int maxSize = 0; public int contentSize = 0; public int[] ids; public int[] amounts; private static final ConcurrentHashMap<Integer, InventoryDefinitions> maps = new ConcurrentHashMap<Integer, InventoryDefinitions>(); public static void main(String... args) { //Cache.init(); for (int i = 0;i < Cache.STORE.getIndex(IndexType.CONFIG).getValidFilesCount(ArchiveType.INVENTORIES.getId());i++) { InventoryDefinitions defs = InventoryDefinitions.getContainer(i); String shop = (i+1000)+" -1 false - Inventory "+i+" - "; if (defs.ids == null) continue; for (int j = 0;j < defs.ids.length;j++) { shop += "" + defs.ids[j] + " " + defs.amounts[j] + " "; } System.out.println(shop); } } public InventoryDefinitions(int id) { this.id = id; byte[] data = Cache.STORE.getIndex(IndexType.CONFIG).getFile(ArchiveType.INVENTORIES.getId(), id); if (data != null) decode(new InputStream(data)); } public static boolean contains(int[] arr, int id) { for (int i = 0;i < arr.length;i++) { if (arr[i] == id) return true; } return false; } public static final InventoryDefinitions getContainer(int id) { InventoryDefinitions def = maps.get(id); if (def != null) return def; def = new InventoryDefinitions(id); maps.put(id, def); return def; } public void write(Store store) { store.getIndex(IndexType.CONFIG).putFile(ArchiveType.INVENTORIES.getId(), id, encode()); } private byte[] encode() { OutputStream stream = new OutputStream(); if (maxSize != 0) { stream.writeByte(2); stream.writeShort(maxSize); } if (contentSize != 0) { stream.writeByte(4); stream.writeByte(contentSize); for (int i = 0;i < contentSize;i++) { stream.writeShort(ids[i]); stream.writeShort(amounts[i]); } } stream.writeByte(0); return stream.toByteArray(); } private void decode(InputStream stream) { while(true) { int opcode = stream.readUnsignedByte(); if (opcode == 0) break; readValues(opcode, stream); } } private void readValues(int opcode, InputStream stream) { if (opcode == 2) { maxSize = stream.readUnsignedShort(); } else if (opcode == 4) { contentSize = stream.readUnsignedByte(); ids = new int[contentSize]; amounts = new int[contentSize]; for (int i = 0; i < contentSize; i++) { ids[i] = stream.readUnsignedShort(); amounts[i] = stream.readUnsignedShort(); } } } @Override public String toString() { StringBuilder result = new StringBuilder(); String newLine = System.getProperty("line.separator"); result.append(this.getClass().getName()); result.append(" {"); result.append(newLine); // determine fields declared in this class only (no fields of // superclass) Field[] fields = this.getClass().getDeclaredFields(); // print field names paired with their values for (Field field : fields) { if (Modifier.isStatic(field.getModifiers())) continue; result.append(" "); try { result.append(field.getType().getCanonicalName() + " " + field.getName() + ": "); result.append(Utils.getFieldValue(this, field)); } catch (Throwable ex) { System.out.println(ex); } result.append(newLine); } result.append("}"); return result.toString(); } }
package com.rs.cache.loaders; import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.Arrays; import java.util.HashMap; import java.lang.SuppressWarnings; import com.rs.cache.ArchiveType; import com.rs.cache.Cache; import com.rs.cache.IndexType; import com.rs.cache.Store; import com.rs.lib.Constants; import com.rs.lib.io.InputStream; import com.rs.lib.io.OutputStream; import com.rs.lib.util.RSColor; import com.rs.lib.util.Utils; public final class ItemDefinitions { private static final HashMap<Integer, ItemDefinitions> ITEM_DEFINITIONS = new HashMap<>(); private static final HashMap<Integer, Integer> EQUIP_IDS = new HashMap<Integer, Integer>(); public int id; public boolean loaded; public int value = 1; public int modelId; public int modelZoom = 2000; public int modelRotationX = 0; public int modelRotationY = 0; public int modelRotationZ = 0; public int modelOffsetX = 0; public int modelOffsetY = 0; public int[] originalModelColors; public int[] modifiedModelColors; public byte[] spriteRecolorIndices; public int[] originalTextureIds; public int[] modifiedTextureIds; public String name = "null"; public boolean membersOnly = false; public int wearPos = -1; public int wearPos2 = -1; public int wearPos3 = -1; public int maleEquip1 = -1; public int maleEquip2 = -1; public int maleEquip3 = -1; public int femaleEquip1 = -1; public int femaleEquip2 = -1; public int femaleEquip3 = -1; public int maleWearXOffset = 0; public int femaleWearXOffset = 0; public int maleWearYOffset = 0; public int femaleWearYOffset = 0; public int maleWearZOffset = 0; public int femaleWearZOffset = 0; public int maleHead1 = -1; public int maleHead2 = -1; public int femaleHead1 = -1; public int femaleHead2 = -1; public int teamId = 0; public String[] groundOptions; public int stackable = 0; public String[] inventoryOptions; public int multiStackSize = -1; public int tooltipColor; public boolean hasTooltipColor = false; private boolean grandExchange = false; public int unknownInt6 = 0; public int certId = -1; public int certTemplateId = -1; public int resizeX = 128; public int[] stackIds; public int[] stackAmounts; public int resizeY = 128; public int resizeZ = 128; public int ambient = 0; public int contrast = 0; public int lendId = -1; public int lendTemplateId = -1; public int unknownInt18 = -1; public int unknownInt19 = -1; public int unknownInt20 = -1; public int unknownInt21 = -1; public int customCursorOp1 = -1; public int customCursorId1 = -1; public int customCursorOp2 = -1; public int customCursorId2 = -1; public int[] quests; public int[] bonuses = new int[18]; public int pickSizeShift = 0; public int bindId = -1; public int bindTemplateId = -1; // extra added public boolean noted; public boolean lended; private HashMap<Integer, Object> params; private HashMap<Integer, Integer> wieldRequirements; public static void main(String[] args) throws IOException { Cache.init("../cache/"); for (int i = 0;i < Utils.getItemDefinitionsSize();i++) { ItemDefinitions def = ItemDefinitions.getDefs(i); if (!def.name.toLowerCase().contains("key")) continue; if (def.originalModelColors != null && def.originalModelColors.length > 0) System.out.println(i + " - " + def.name + " - " + Arrays.toString(def.originalModelColors) + " - " + Arrays.toString(def.modifiedModelColors)); } System.out.println(RSColor.RGB_to_HSL(255, 255, 255)); //6792 8867 } /** * 1 = thrown weapons? and cannonballs 2 = arrows 3 = bolts 4 = construction * materials 5 = flatpacks 6 = cooking items 7 = cosmetic items 8 = crafting * items 9 = summoning pouches 10 = junky farming produce 11 = fletching items * 12 = eatable items 13 = herblore secondaries and unf pots 14 = hunter * clothing/traps/bait 15 = hunter produce 16 = jewelry 17 = magic armour 18 = * staves 19 = low tier melee armour 20 = mid tier melee armour 21 = high tier * melee armour 22 = low level melee weapons 23 = mid tier melee weapons 24 = * high tier melee weapons 25 = smithables 26 = finished potions 27 = prayer * enhancing items 28 = prayer training items bones/ashes 29 = ranged armour 30 * = ranged weapons 31 = runecrafting training items 32 = teleport items 33 = * seeds 34 = summoning scrolls 35 = crafting misc items/tools 36 = woodcutting * produce */ public int getItemCategory() { if (params == null) return -1; Object protectedOnDeath = params.get(2195); if (protectedOnDeath != null && protectedOnDeath instanceof Integer) return (Integer) protectedOnDeath; return -1; } public int getIdk() { if (params == null) return -1; Object protectedOnDeath = params.get(1397); if (protectedOnDeath != null && protectedOnDeath instanceof Integer) return (Integer) protectedOnDeath; return -1; } public static void mapEquipIds() { int equipId = 0; for (int itemId = 0; itemId < Utils.getItemDefinitionsSize(); itemId++) { ItemDefinitions def = ItemDefinitions.getDefs(itemId); if (def.getMaleWornModelId1() >= 0 || def.getFemaleWornModelId1() >= 0) { EQUIP_IDS.put(itemId, equipId++); } } } public int getEquipId() { if (EQUIP_IDS.isEmpty()) mapEquipIds(); Integer equipId = EQUIP_IDS.get(id); return equipId == null ? -1 : equipId; } public static final ItemDefinitions getItemDefinitions(Store store, int itemId, boolean loadTemplates) { return new ItemDefinitions(store, itemId, loadTemplates); } public static final ItemDefinitions getItemDefinitions(Store store, int itemId) { return new ItemDefinitions(store, itemId, true); } public static final ItemDefinitions getDefs(int itemId) { return getItemDefinitions(itemId, true); } public static final ItemDefinitions getItemDefinitions(int itemId, boolean loadTemplates) { ItemDefinitions def = ITEM_DEFINITIONS.get(itemId); if (def == null) { def = new ItemDefinitions(itemId, loadTemplates); ITEM_DEFINITIONS.put(itemId, def); } return def; } public static final void clearItemsDefinitions() { ITEM_DEFINITIONS.clear(); } public ItemDefinitions(int id) { this(Cache.STORE, id, true); } public ItemDefinitions(int id, boolean loadTemplates) { this(Cache.STORE, id, loadTemplates); } public ItemDefinitions(Store store, int id, boolean loadTemplates) { this.id = id; setDefaultOptions(); loadItemDefinitions(store, loadTemplates); switch (id) { case 25629: this.name = "Iron"; break; case 25630: this.name = "Coal"; break; case 25631: this.name = "Mithril"; break; case 25632: this.name = "Adamantite"; break; case 25633: this.name = "Runite"; break; default: break; } } @Override public String toString() { StringBuilder result = new StringBuilder(); String newLine = System.getProperty("line.separator"); result.append(this.getClass().getName()); result.append(" {"); result.append(newLine); // determine fields declared in this class only (no fields of // superclass) Field[] fields = this.getClass().getDeclaredFields(); // print field names paired with their values for (Field field : fields) { if (Modifier.isStatic(field.getModifiers())) continue; result.append(" "); try { result.append(field.getType().getCanonicalName() + " " + field.getName() + ": "); result.append(Utils.getFieldValue(this, field)); } catch (Throwable ex) { System.out.println(ex); } result.append(newLine); } result.append("}"); return result.toString(); } public boolean isLoaded() { return loaded; } private final void loadItemDefinitions(Store store, boolean loadTemplates) { byte[] data = store.getIndex(IndexType.ITEMS).getFile(ArchiveType.ITEMS.archiveId(id), ArchiveType.ITEMS.fileId(id)); if (data == null) { return; } readOpcodeValues(new InputStream(data)); if (loadTemplates) { if (certTemplateId != -1) toNote(); if (lendTemplateId != -1) toLend(); if (bindTemplateId != -1) toBind(); } parseBonuses(); loaded = true; } public static final int STAB_ATTACK = 0, SLASH_ATTACK = 1, CRUSH_ATTACK = 2, RANGE_ATTACK = 4, MAGIC_ATTACK = 3; public static final int STAB_DEF = 5, SLASH_DEF = 6, CRUSH_DEF = 7, RANGE_DEF = 9, MAGIC_DEF = 8, SUMMONING_DEF = 10; public static final int STRENGTH_BONUS = 14, RANGED_STR_BONUS = 15, MAGIC_DAMAGE = 17, PRAYER_BONUS = 16; public static final int ABSORVE_MELEE_BONUS = 11, ABSORVE_RANGE_BONUS = 13, ABSORVE_MAGE_BONUS = 12; public boolean faceMask() { if (id == 4168) return true; return getParamVal(625) == 1; } private void parseBonuses() { bonuses = new int[18]; bonuses[STAB_ATTACK] = getParamVal(0); bonuses[SLASH_ATTACK] = getParamVal(1); bonuses[CRUSH_ATTACK] = getParamVal(2); bonuses[MAGIC_ATTACK] = getParamVal(3); bonuses[RANGE_ATTACK] = getParamVal(4); bonuses[STAB_DEF] = getParamVal(5); bonuses[SLASH_DEF] = getParamVal(6); bonuses[CRUSH_DEF] = getParamVal(7); bonuses[MAGIC_DEF] = getParamVal(8); bonuses[RANGE_DEF] = getParamVal(9); bonuses[SUMMONING_DEF] = getParamVal(417); bonuses[PRAYER_BONUS] = getParamVal(11); bonuses[ABSORVE_MELEE_BONUS] = getParamVal(967); bonuses[ABSORVE_RANGE_BONUS] = getParamVal(968); bonuses[ABSORVE_MAGE_BONUS] = getParamVal(969); bonuses[STRENGTH_BONUS] = getParamVal(641) / 10; bonuses[RANGED_STR_BONUS] = getParamVal(643) / 10; bonuses[MAGIC_DAMAGE] = getParamVal(685); if (id == 25349) { for (int i = 0;i < bonuses.length;i++) { bonuses[i] = 10000; } } } public void setBonuses(int[] bonuses2) { if (bonuses2[STAB_ATTACK] != 0 || bonuses[STAB_ATTACK] != bonuses2[STAB_ATTACK]) params.put(0, bonuses2[STAB_ATTACK]); if (bonuses2[SLASH_ATTACK] != 0 || bonuses[SLASH_ATTACK] != bonuses2[SLASH_ATTACK]) params.put(1, bonuses2[SLASH_ATTACK]); if (bonuses2[CRUSH_ATTACK] != 0 || bonuses[CRUSH_ATTACK] != bonuses2[CRUSH_ATTACK]) params.put(2, bonuses2[CRUSH_ATTACK]); if (bonuses2[MAGIC_ATTACK] != 0 || bonuses[MAGIC_ATTACK] != bonuses2[MAGIC_ATTACK]) params.put(3, bonuses2[MAGIC_ATTACK]); if (bonuses2[RANGE_ATTACK] != 0 || bonuses[RANGE_ATTACK] != bonuses2[RANGE_ATTACK]) params.put(4, bonuses2[RANGE_ATTACK]); if (bonuses2[STAB_DEF] != 0 || bonuses[STAB_DEF] != bonuses2[STAB_DEF]) params.put(5, bonuses2[STAB_DEF]); if (bonuses2[SLASH_DEF] != 0 || bonuses[SLASH_DEF] != bonuses2[SLASH_DEF]) params.put(6, bonuses2[SLASH_DEF]); if (bonuses2[CRUSH_DEF] != 0 || bonuses[CRUSH_DEF] != bonuses2[CRUSH_DEF]) params.put(7, bonuses2[CRUSH_DEF]); if (bonuses2[MAGIC_DEF] != 0 || bonuses[MAGIC_DEF] != bonuses2[MAGIC_DEF]) params.put(8, bonuses2[MAGIC_DEF]); if (bonuses2[RANGE_DEF] != 0 || bonuses[RANGE_DEF] != bonuses2[RANGE_DEF]) params.put(9, bonuses2[RANGE_DEF]); if (bonuses2[SUMMONING_DEF] != 0 || bonuses[SUMMONING_DEF] != bonuses2[SUMMONING_DEF]) params.put(417, bonuses2[SUMMONING_DEF]); if (bonuses2[PRAYER_BONUS] != 0 || bonuses[PRAYER_BONUS] != bonuses2[PRAYER_BONUS]) params.put(11, bonuses2[PRAYER_BONUS]); if (bonuses2[ABSORVE_MELEE_BONUS] != 0 || bonuses[ABSORVE_MELEE_BONUS] != bonuses2[ABSORVE_MELEE_BONUS]) params.put(967, bonuses2[ABSORVE_MELEE_BONUS]); if (bonuses2[ABSORVE_RANGE_BONUS] != 0 || bonuses[ABSORVE_RANGE_BONUS] != bonuses2[ABSORVE_RANGE_BONUS]) params.put(968, bonuses2[ABSORVE_RANGE_BONUS]); if (bonuses2[ABSORVE_MAGE_BONUS] != 0 || bonuses[ABSORVE_MAGE_BONUS] != bonuses2[ABSORVE_MAGE_BONUS]) params.put(969, bonuses2[ABSORVE_MAGE_BONUS]); if (bonuses2[STRENGTH_BONUS] != 0 || bonuses[STRENGTH_BONUS] != bonuses2[STRENGTH_BONUS]) params.put(641, bonuses2[STRENGTH_BONUS] * 10); if (bonuses2[RANGED_STR_BONUS] != 0 || bonuses[RANGED_STR_BONUS] != bonuses2[RANGED_STR_BONUS]) params.put(643, bonuses2[RANGED_STR_BONUS] * 10); if (bonuses2[MAGIC_DAMAGE] != 0 || bonuses[MAGIC_DAMAGE] != bonuses2[MAGIC_DAMAGE]) params.put(685, bonuses2[MAGIC_DAMAGE]); } private void toNote() { // ItemDefinitions noteItem; //certTemplateId ItemDefinitions realItem = getDefs(certId); membersOnly = realItem.membersOnly; value = realItem.value; name = realItem.name; stackable = 1; noted = true; } private void toBind() { // ItemDefinitions lendItem; //lendTemplateId ItemDefinitions realItem = getDefs(bindId); originalModelColors = realItem.originalModelColors; maleEquip3 = realItem.maleEquip3; femaleEquip3 = realItem.femaleEquip3; teamId = realItem.teamId; value = 0; membersOnly = realItem.membersOnly; name = realItem.name; inventoryOptions = new String[5]; groundOptions = realItem.groundOptions; if (realItem.inventoryOptions != null) for (int optionIndex = 0; optionIndex < 4; optionIndex++) inventoryOptions[optionIndex] = realItem.inventoryOptions[optionIndex]; inventoryOptions[4] = "Discard"; maleEquip1 = realItem.maleEquip1; maleEquip2 = realItem.maleEquip2; femaleEquip1 = realItem.femaleEquip1; femaleEquip2 = realItem.femaleEquip2; params = realItem.params; wearPos = realItem.wearPos; wearPos2 = realItem.wearPos2; } private void toLend() { // ItemDefinitions lendItem; //lendTemplateId ItemDefinitions realItem = getDefs(lendId); originalModelColors = realItem.originalModelColors; maleEquip3 = realItem.maleEquip3; femaleEquip3 = realItem.femaleEquip3; teamId = realItem.teamId; value = 0; membersOnly = realItem.membersOnly; name = realItem.name; inventoryOptions = new String[5]; groundOptions = realItem.groundOptions; if (realItem.inventoryOptions != null) for (int optionIndex = 0; optionIndex < 4; optionIndex++) inventoryOptions[optionIndex] = realItem.inventoryOptions[optionIndex]; inventoryOptions[4] = "Discard"; maleEquip1 = realItem.maleEquip1; maleEquip2 = realItem.maleEquip2; femaleEquip1 = realItem.femaleEquip1; femaleEquip2 = realItem.femaleEquip2; params = realItem.params; wearPos = realItem.wearPos; wearPos2 = realItem.wearPos2; lended = true; } public boolean isDestroyItem() { if (inventoryOptions == null) return false; for (String option : inventoryOptions) { if (option == null) continue; if (option.equalsIgnoreCase("destroy")) return true; } return false; } public boolean canExchange() { if (isNoted() && certId != -1) return getDefs(certId).grandExchange; return grandExchange; } public int getStageOnDeath() { if (params == null) return 0; Object protectedOnDeath = params.get(1397); if (protectedOnDeath != null && protectedOnDeath instanceof Integer) return (Integer) protectedOnDeath; return 0; } public boolean containsOption(int i, String option) { if (inventoryOptions == null || inventoryOptions[i] == null || inventoryOptions.length <= i) return false; return inventoryOptions[i].equals(option); } public boolean containsOption(String option) { if (inventoryOptions == null) return false; for (String o : inventoryOptions) { if (o == null || !o.equals(option)) continue; return true; } return false; } public boolean isWearItem() { return wearPos != -1; } public boolean isWearItem(boolean male) { if (id == 4285) return true; if (wearPos < 12 && (male ? getMaleWornModelId1() == -1 : getFemaleWornModelId1() == -1)) return false; return wearPos != -1; } public boolean hasSpecialBar() { if (params == null) return false; Object specialBar = params.get(686); if (specialBar != null && specialBar instanceof Integer) return (Integer) specialBar == 1; return false; } public int getRenderAnimId() { if (params == null) return 1426; Object animId = params.get(644); if (animId != null && animId instanceof Integer) return (Integer) animId; return 1426; } public double getDungShopValueMultiplier() { if (params == null) return 1; Object value = params.get(1046); if (value != null && value instanceof Integer) return ((Integer) value).doubleValue() / 100; return 1; } public int getModelZoom() { return modelZoom; } public int getModelOffset1() { return modelOffsetX; } public int getModelOffset2() { return modelOffsetY; } public int getQuestId() { if (params == null) return -1; Object questId = params.get(861); if (questId != null && questId instanceof Integer) return (Integer) questId; return -1; } public int getWieldQuestReq() { switch(id) { case 19784: return 174; case 10887: return 120; default: return getParam(-1, 743); } } public int getParamVal(int id) { return getParam(0, id); } public int getParam(int defaultVal, int id) { if (params == null || params.get(id) == null) return defaultVal; return (int) params.get(id); } public HashMap<Integer, Object> getClientScriptData() { return params; } public HashMap<Integer, Integer> getWearingSkillRequiriments() { if (params == null) return null; if (wieldRequirements == null) { HashMap<Integer, Integer> skills = new HashMap<Integer, Integer>(); for (int i = 0; i < 10; i++) { Integer skill = (Integer) params.get(749 + (i * 2)); if (skill != null) { Integer level = (Integer) params.get(750 + (i * 2)); if (level != null) skills.put(skill, level); } } Integer maxedSkill = (Integer) params.get(277); if (maxedSkill != null) skills.put(maxedSkill, getId() == 19709 ? 120 : 99); wieldRequirements = skills; switch(getId()) { case 8846: wieldRequirements.put(Constants.ATTACK, 5); wieldRequirements.put(Constants.DEFENSE, 5); break; case 8847: wieldRequirements.put(Constants.ATTACK, 10); wieldRequirements.put(Constants.DEFENSE, 10); break; case 8848: wieldRequirements.put(Constants.ATTACK, 20); wieldRequirements.put(Constants.DEFENSE, 20); break; case 8849: wieldRequirements.put(Constants.ATTACK, 30); wieldRequirements.put(Constants.DEFENSE, 30); break; case 8850: wieldRequirements.put(Constants.ATTACK, 40); wieldRequirements.put(Constants.DEFENSE, 40); break; case 20072: wieldRequirements.put(Constants.ATTACK, 60); wieldRequirements.put(Constants.DEFENSE, 60); break; case 10498: wieldRequirements.put(Constants.RANGE, 30); break; case 10499: wieldRequirements.put(Constants.RANGE, 50); break; case 20068: wieldRequirements.put(Constants.RANGE, 50); break; case 22358: case 22359: case 22360: case 22361: wieldRequirements.put(Constants.ATTACK, 80); break; case 22362: case 22363: case 22364: case 22365: wieldRequirements.put(Constants.RANGE, 80); break; case 22366: case 22367: case 22368: case 22369: wieldRequirements.put(Constants.MAGIC, 80); break; case 21371: case 21372: case 21373: case 21374: case 21375: wieldRequirements.put(Constants.ATTACK, 85); wieldRequirements.put(Constants.SLAYER, 80); break; case 10887: wieldRequirements.put(Constants.ATTACK, 60); wieldRequirements.put(Constants.STRENGTH, 40); break; case 7459: wieldRequirements.put(Constants.DEFENSE, 13); break; case 7460: wieldRequirements.put(Constants.DEFENSE, 34); break; case 7461: wieldRequirements.put(Constants.DEFENSE, 41); break; case 7462: wieldRequirements.put(Constants.DEFENSE, 41); wieldRequirements.put(Constants.COOKING, 64); wieldRequirements.put(Constants.AGILITY, 48); wieldRequirements.put(Constants.MINING, 44); wieldRequirements.put(Constants.FISHING, 47); wieldRequirements.put(Constants.THIEVING, 53); wieldRequirements.put(Constants.HERBLORE, 19); wieldRequirements.put(Constants.MAGIC, 50); wieldRequirements.put(Constants.SMITHING, 34); wieldRequirements.put(Constants.FIREMAKING, 50); wieldRequirements.put(Constants.RANGE, 40); break; } } return wieldRequirements; } private void setDefaultOptions() { groundOptions = new String[] { null, null, "take", null, null }; inventoryOptions = new String[] { null, null, null, null, "drop" }; } public boolean write(Store store) { return store.getIndex(IndexType.ITEMS).putFile(ArchiveType.ITEMS.archiveId(id), ArchiveType.ITEMS.fileId(id), encode()); } private final byte[] encode() { OutputStream stream = new OutputStream(); stream.writeByte(1); stream.writeBigSmart(modelId); if (!name.equals("null")) { stream.writeByte(2); stream.writeString(name); } if (modelZoom != 2000) { stream.writeByte(4); stream.writeShort(modelZoom); } if (modelRotationX != 0) { stream.writeByte(5); stream.writeShort(modelRotationX); } if (modelRotationY != 0) { stream.writeByte(6); stream.writeShort(modelRotationY); } if (modelOffsetX != 0) { stream.writeByte(7); int value = modelOffsetX >>= 0; if (value < 0) value += 65536; stream.writeShort(value); } if (modelOffsetY != 0) { stream.writeByte(8); int value = modelOffsetY >>= 0; if (value < 0) value += 65536; stream.writeShort(value); } if (stackable == 1) { stream.writeByte(11); } if (value != 1) { stream.writeByte(12); stream.writeInt(value); } if (wearPos != -1) { stream.writeByte(13); stream.writeByte(wearPos); } if (wearPos2 != -1) { stream.writeByte(14); stream.writeByte(wearPos2); } if (membersOnly) { stream.writeByte(16); } if (multiStackSize != -1) { stream.writeByte(18); stream.writeShort(multiStackSize); } if (maleEquip1 != -1) { stream.writeByte(23); stream.writeBigSmart(maleEquip1); } if (maleEquip2 != -1) { stream.writeByte(24); stream.writeBigSmart(maleEquip2); } if (femaleEquip1 != -1) { stream.writeByte(25); stream.writeBigSmart(femaleEquip1); } if (femaleEquip2 != -1) { stream.writeByte(26); stream.writeBigSmart(femaleEquip2); } if (wearPos3 != -1) { stream.writeByte(27); stream.writeByte(wearPos3); } String[] DEFAULTGROUND = new String[] { null, null, "take", null, null }; for (int i = 0;i < groundOptions.length;i++) { if (groundOptions[i] != null && !groundOptions[i].equals(DEFAULTGROUND[i])) { stream.writeByte(30+i); stream.writeString(groundOptions[i]); } } String[] DEFAULTINV = new String[] { null, null, null, null, "drop" }; for (int i = 0;i < inventoryOptions.length;i++) { if (inventoryOptions[i] != null && !inventoryOptions[i].equals(DEFAULTINV[i])) { stream.writeByte(35+i); stream.writeString(inventoryOptions[i]); } } if (originalModelColors != null && modifiedModelColors != null) { stream.writeByte(40); stream.writeByte(originalModelColors.length); for (int i = 0; i < originalModelColors.length; i++) { stream.writeShort(originalModelColors[i]); stream.writeShort(modifiedModelColors[i]); } } if (originalTextureIds != null && modifiedTextureIds != null) { stream.writeByte(41); stream.writeByte(originalTextureIds.length); for (int i = 0; i < originalTextureIds.length; i++) { stream.writeShort(originalTextureIds[i]); stream.writeShort(modifiedTextureIds[i]); } } if (spriteRecolorIndices != null) { stream.writeByte(42); stream.writeByte(spriteRecolorIndices.length); for (int i = 0; i < spriteRecolorIndices.length; i++) stream.writeByte(spriteRecolorIndices[i]); } if (tooltipColor != 0 && hasTooltipColor) { stream.writeByte(43); stream.writeInt(tooltipColor); } if (grandExchange) { stream.writeByte(65); } if (maleEquip3 != -1) { stream.writeByte(78); stream.writeBigSmart(maleEquip3); } if (femaleEquip3 != -1) { stream.writeByte(79); stream.writeBigSmart(femaleEquip3); } if (maleHead1 != -1) { stream.writeByte(90); stream.writeBigSmart(maleHead1); } if (femaleHead1 != -1) { stream.writeByte(91); stream.writeBigSmart(femaleHead1); } if (maleHead2 != -1) { stream.writeByte(92); stream.writeBigSmart(maleHead2); } if (femaleHead2 != -1) { stream.writeByte(93); stream.writeBigSmart(femaleHead2); } if (modelRotationZ != 0) { stream.writeByte(95); stream.writeShort(modelRotationZ); } if (unknownInt6 != 0) { stream.writeByte(96); stream.writeByte(unknownInt6); } if (certId != -1) { stream.writeByte(97); stream.writeShort(certId); } if (certTemplateId != -1) { stream.writeByte(98); stream.writeShort(certTemplateId); } if (stackIds != null && stackAmounts != null) { for (int i = 0; i < stackIds.length; i++) { if (stackIds[i] == 0 && stackAmounts[i] == 0) continue; stream.writeByte(100 + i); stream.writeShort(stackIds[i]); stream.writeShort(stackAmounts[i]); } } if (resizeX != 128) { stream.writeByte(110); stream.writeShort(resizeX); } if (resizeY != 128) { stream.writeByte(111); stream.writeShort(resizeY); } if (resizeZ != 128) { stream.writeByte(112); stream.writeShort(resizeZ); } if (ambient != 0) { stream.writeByte(113); stream.writeByte(ambient); } if (contrast != 0) { stream.writeByte(114); stream.writeByte(contrast / 5); } if (teamId != 0) { stream.writeByte(115); stream.writeByte(teamId); } if (lendId != -1) { stream.writeByte(121); stream.writeShort(lendId); } if (lendTemplateId != -1) { stream.writeByte(122); stream.writeShort(lendTemplateId); } if (maleWearXOffset != 0 || maleWearYOffset != 0 || maleWearZOffset != 0) { stream.writeByte(125); stream.writeByte(maleWearXOffset >> 2); stream.writeByte(maleWearYOffset >> 2); stream.writeByte(maleWearZOffset >> 2); } if (femaleWearXOffset != 0 || femaleWearYOffset != 0 || femaleWearZOffset != 0) { stream.writeByte(126); stream.writeByte(femaleWearXOffset >> 2); stream.writeByte(femaleWearYOffset >> 2); stream.writeByte(femaleWearZOffset >> 2); } if (unknownInt18 != -1 || unknownInt19 != -1) { stream.writeByte(127); stream.writeByte(unknownInt18); stream.writeShort(unknownInt19); } if (unknownInt20 != -1 || unknownInt21 != -1) { stream.writeByte(128); stream.writeByte(unknownInt20); stream.writeShort(unknownInt21); } if (customCursorOp1 != -1 || customCursorId1 != -1) { stream.writeByte(129); stream.writeByte(customCursorOp1); stream.writeShort(customCursorId1); } if (customCursorOp2 != -1 || customCursorId2 != -1) { stream.writeByte(130); stream.writeByte(customCursorOp2); stream.writeShort(customCursorId2); } if (quests != null) { stream.writeByte(132); stream.writeByte(quests.length); for (int index = 0; index < quests.length; index++) stream.writeShort(quests[index]); } if (pickSizeShift != 0) { stream.writeByte(134); stream.writeByte(pickSizeShift); } if (bindId != -1) { stream.writeByte(139); stream.writeShort(bindId); } if (bindTemplateId != -1) { stream.writeByte(140); stream.writeShort(bindTemplateId); } if (params != null) { stream.writeByte(249); stream.writeByte(params.size()); for (int key : params.keySet()) { Object value = params.get(key); stream.writeByte(value instanceof String ? 1 : 0); stream.write24BitInt(key); if (value instanceof String) { stream.writeString((String) value); } else { stream.writeInt((Integer) value); } } } stream.writeByte(0); byte[] data = new byte[stream.getOffset()]; stream.setOffset(0); stream.getBytes(data, 0, data.length); return data; } @SuppressWarnings("unused") private final void readValues(InputStream stream, int opcode) { if (opcode == 1) modelId = stream.readBigSmart(); else if (opcode == 2) name = stream.readString(); else if (opcode == 4) modelZoom = stream.readUnsignedShort(); else if (opcode == 5) modelRotationX = stream.readUnsignedShort(); else if (opcode == 6) modelRotationY = stream.readUnsignedShort(); else if (opcode == 7) { modelOffsetX = stream.readUnsignedShort(); if (modelOffsetX > 32767) modelOffsetX -= 65536; modelOffsetX <<= 0; } else if (opcode == 8) { modelOffsetY = stream.readUnsignedShort(); if (modelOffsetY > 32767) modelOffsetY -= 65536; modelOffsetY <<= 0; } else if (opcode == 11) stackable = 1; else if (opcode == 12) { value = stream.readInt(); } else if (opcode == 13) { wearPos = stream.readUnsignedByte(); } else if (opcode == 14) { wearPos2 = stream.readUnsignedByte(); } else if (opcode == 16) membersOnly = true; else if (opcode == 18) { multiStackSize = stream.readUnsignedShort(); } else if (opcode == 23) maleEquip1 = stream.readBigSmart(); else if (opcode == 24) maleEquip2 = stream.readBigSmart(); else if (opcode == 25) femaleEquip1 = stream.readBigSmart(); else if (opcode == 26) femaleEquip2 = stream.readBigSmart(); else if (opcode == 27) wearPos3 = stream.readUnsignedByte(); else if (opcode >= 30 && opcode < 35) groundOptions[opcode - 30] = stream.readString(); else if (opcode >= 35 && opcode < 40) inventoryOptions[opcode - 35] = stream.readString(); else if (opcode == 40) { int length = stream.readUnsignedByte(); originalModelColors = new int[length]; modifiedModelColors = new int[length]; for (int index = 0; index < length; index++) { originalModelColors[index] = stream.readUnsignedShort(); modifiedModelColors[index] = stream.readUnsignedShort(); } } else if (opcode == 41) { int length = stream.readUnsignedByte(); originalTextureIds = new int[length]; modifiedTextureIds = new int[length]; for (int index = 0; index < length; index++) { originalTextureIds[index] = (short) stream.readUnsignedShort(); modifiedTextureIds[index] = (short) stream.readUnsignedShort(); } } else if (opcode == 42) { int length = stream.readUnsignedByte(); spriteRecolorIndices = new byte[length]; for (int index = 0; index < length; index++) spriteRecolorIndices[index] = (byte) stream.readByte(); } else if (opcode == 43) { this.tooltipColor = stream.readInt(); this.hasTooltipColor = true; } else if (opcode == 44) { /*int i_7_ = */stream.readUnsignedShort(); // int i_8_ = 0; // for (int i_9_ = i_7_; i_9_ > 0; i_9_ >>= 1) // i_8_++; // aByteArray6974 = new byte[i_8_]; // byte i_10_ = 0; // for (int i_11_ = 0; i_11_ < i_8_; i_11_++) { // if ((i_7_ & 1 << i_11_) > 0) { // aByteArray6974[i_11_] = i_10_; // i_10_++; // } else // aByteArray6974[i_11_] = (byte) -1; // } } else if (45 == opcode) { /*int i_12_ = */stream.readUnsignedShort(); // int i_13_ = 0; // for (int i_14_ = i_12_; i_14_ > 0; i_14_ >>= 1) // i_13_++; // aByteArray6975 = new byte[i_13_]; // byte i_15_ = 0; // for (int i_16_ = 0; i_16_ < i_13_; i_16_++) { // if ((i_12_ & 1 << i_16_) > 0) { // aByteArray6975[i_16_] = i_15_; // i_15_++; // } else // aByteArray6975[i_16_] = (byte) -1; // } } else if (opcode == 65) grandExchange = true; else if (opcode == 78) maleEquip3 = stream.readBigSmart(); else if (opcode == 79) femaleEquip3 = stream.readBigSmart(); else if (opcode == 90) maleHead1 = stream.readBigSmart(); else if (opcode == 91) femaleHead1 = stream.readBigSmart(); else if (opcode == 92) maleHead2 = stream.readBigSmart(); else if (opcode == 93) femaleHead2 = stream.readBigSmart(); else if (opcode == 94) // new stream.readUnsignedShort(); else if (opcode == 95) modelRotationZ = stream.readUnsignedShort(); else if (opcode == 96) unknownInt6 = stream.readUnsignedByte(); else if (opcode == 97) certId = stream.readUnsignedShort(); else if (opcode == 98) certTemplateId = stream.readUnsignedShort(); else if (opcode >= 100 && opcode < 110) { if (stackIds == null) { stackIds = new int[10]; stackAmounts = new int[10]; } stackIds[opcode - 100] = stream.readUnsignedShort(); stackAmounts[opcode - 100] = stream.readUnsignedShort(); } else if (opcode == 110) resizeX = stream.readUnsignedShort(); else if (opcode == 111) resizeY = stream.readUnsignedShort(); else if (opcode == 112) resizeZ = stream.readUnsignedShort(); else if (opcode == 113) ambient = stream.readByte(); else if (opcode == 114) contrast = stream.readByte() * 5; else if (opcode == 115) teamId = stream.readUnsignedByte(); else if (opcode == 121) lendId = stream.readUnsignedShort(); else if (opcode == 122) lendTemplateId = stream.readUnsignedShort(); else if (opcode == 125) { this.maleWearXOffset = stream.readByte() << 2; this.maleWearYOffset = stream.readByte() << 2; this.maleWearZOffset = stream.readByte() << 2; } else if (opcode == 126) { this.femaleWearXOffset = stream.readByte() << 2; this.femaleWearYOffset = stream.readByte() << 2; this.femaleWearZOffset = stream.readByte() << 2; } else if (opcode == 127) { unknownInt18 = stream.readUnsignedByte(); unknownInt19 = stream.readUnsignedShort(); } else if (opcode == 128) { unknownInt20 = stream.readUnsignedByte(); unknownInt21 = stream.readUnsignedShort(); } else if (opcode == 129) { customCursorOp1 = stream.readUnsignedByte(); customCursorId1 = stream.readUnsignedShort(); } else if (opcode == 130) { customCursorOp2 = stream.readUnsignedByte(); customCursorId2 = stream.readUnsignedShort(); } else if (opcode == 132) { int length = stream.readUnsignedByte(); quests = new int[length]; for (int index = 0; index < length; index++) quests[index] = stream.readUnsignedShort(); } else if (opcode == 134) { this.pickSizeShift = stream.readUnsignedByte(); } else if (opcode == 139) { bindId = stream.readUnsignedShort(); } else if (opcode == 140) { bindTemplateId = stream.readUnsignedShort(); } else if (opcode >= 142 && opcode < 147) { // if (null == ((Class518) this).anIntArray6988) { // ((Class518) this).anIntArray6988 = new int[6]; // Arrays.fill(((Class518) this).anIntArray6988, -1); // } /*anIntArray6988[opcode - 142] = */stream.readUnsignedShort(); } else if (opcode >= 150 && opcode < 155) { // if (null == ((Class518) this).anIntArray6986) { // ((Class518) this).anIntArray6986 = new int[5]; // Arrays.fill(((Class518) this).anIntArray6986, -1); // } /*anIntArray6986[opcode - 150] = */stream.readUnsignedShort(); } else if (opcode == 157) { } else if (161 == opcode) {// new int anInt7904 = stream.readUnsignedShort(); } else if (162 == opcode) {// new int anInt7923 = stream.readUnsignedShort(); } else if (163 == opcode) {// new int anInt7939 = stream.readUnsignedShort(); } else if (164 == opcode) {// new coinshare shard String aString7902 = stream.readString(); } else if (165 == opcode) {// new stackable = 2; } else if (opcode == 249) { int length = stream.readUnsignedByte(); if (params == null) params = new HashMap<Integer, Object>(length); for (int index = 0; index < length; index++) { boolean stringInstance = stream.readUnsignedByte() == 1; int key = stream.read24BitInt(); Object value = stringInstance ? stream.readString() : stream.readInt(); params.put(key, value); } } else { System.err.println("MISSING OPCODE " + opcode + " FOR ITEM " + getId()); throw new RuntimeException("MISSING OPCODE " + opcode + " FOR ITEM " + getId()); } } private final void readOpcodeValues(InputStream stream) { while (true) { int opcode = stream.readUnsignedByte(); if (opcode == 0) break; readValues(stream, opcode); } } public boolean containsEquipmentOption(int optionId, String option) { if (params == null) return false; Object wearingOption = params.get(528 + optionId); if (wearingOption != null && wearingOption instanceof String) return wearingOption.equals(option); return false; } public String getEquipmentOption(int optionId) { if (params == null) return "null"; Object wearingOption = params.get(optionId == 4 ? 1211 : (528 + optionId)); if (wearingOption != null && wearingOption instanceof String) return (String) wearingOption; return "null"; } public String getInventoryOption(int optionId) { switch(id) { case 6099: case 6100: case 6101: case 6102: if (optionId == 2) return "Temple"; break; case 19760: case 13561: case 13562: if (optionId == 0) return inventoryOptions[1]; else if (optionId == 1) return inventoryOptions[0]; break; } if (inventoryOptions == null) return "null"; if (optionId >= inventoryOptions.length) return "null"; if (inventoryOptions[optionId] == null) return "null"; return inventoryOptions[optionId]; } public String getName() { return name; } public int getFemaleWornModelId1() { return femaleEquip1; } public int getFemaleWornModelId2() { return femaleEquip2; } public int getMaleWornModelId1() { return maleEquip1; } public int getMaleWornModelId2() { return maleEquip2; } public boolean isOverSized() { return modelZoom > 5000; } public boolean isLended() { return lended; } public boolean isMembersOnly() { return membersOnly; } public boolean isStackable() { return stackable == 1; } public boolean isNoted() { return noted; } public int getLendId() { return lendId; } public int getCertId() { return certId; } public int getValue() { if (id == 18744 || id == 18745 || id == 18746 || id == 18747) return 5; if (id == 10551 || id == 10548 || id == 2952 || id == 2890 || id == 10499) return 1; return value; } public int getSellPrice() { return (int) (value / (10.0 / 3.0)); } public int getHighAlchPrice() { return (int) (value / (10.0 / 6.0)); } public int getId() { return id; } public int getEquipSlot() { return wearPos; } public boolean isEquipType(int type) { return wearPos3 == type || wearPos2 == type; } public boolean isBinded() { return (id >= 15775 && id <= 16272) || (id >= 19865 && id <= 19866); } public boolean isBindItem() { if (inventoryOptions == null) return false; for (String option : inventoryOptions) { if (option == null) continue; if (option.equalsIgnoreCase("bind")) return true; } return false; } public boolean containsInventoryOption(int i, String string) { if (inventoryOptions == null || i >= inventoryOptions.length || inventoryOptions[i] == null) return false; return inventoryOptions[i].equalsIgnoreCase(string); } public int[] getBonuses() { return bonuses; } }
package com.rs.cache.loaders; import java.io.IOException; import java.util.Arrays; import java.util.HashMap; import java.lang.SuppressWarnings; import com.rs.lib.game.Item; public class LoyaltyRewardDefinitions { private static int NAME = 1930; private static int ITEM_ID = 1935; private static int ENUM = 1995; public enum Type { AURA, EFFECT, EMOTE, COSTUME, TITLE, RECOLOR } public enum Tab { AURAS(5182, 2229, 66, 1, Reward.ODDBALL, Reward.POISON_PURGE, Reward.FRIEND_IN_NEED, Reward.KNOCK_OUT, Reward.SHARPSHOOTER, Reward.RUNIC_ACCURACY, Reward.SUREFOOTED, Reward.REVERENCE, Reward.CALL_OF_THE_SEA, Reward.JACK_OF_TRADES, Reward.GREATER_POISON_PURGE, Reward.GREATER_RUNIC_ACCURACY, Reward.GREATER_SHARPSHOOTER, Reward.GREATER_CALL_OF_THE_SEA, Reward.GREATER_REVERENCE, Reward.GREATER_SUREFOOTED, Reward.LUMBERJACK, Reward.GREATER_LUMBERJACK, Reward.QUARRYMASTER, Reward.GREATER_QUARRYMASTER, Reward.FIVE_FINGER_DISCOUNT, Reward.GREATER_FIVE_FINGER_DISCOUNT, Reward.RESOURCEFUL, Reward.EQUILIBRIUM, Reward.INSPIRATION, Reward.VAMPYRISM, Reward.PENANCE, Reward.WISDOM, Reward.AEGIS, Reward.REGENERATION, Reward.DARK_MAGIC, Reward.BERSERKER, Reward.ANCESTOR_SPIRITS, Reward.GREENFINGERS, Reward.GREATER_GREENFINGERS, Reward.MASTER_GREENFINGERS, Reward.TRACKER, Reward.GREATER_TRACKER, Reward.MASTER_TRACKER, Reward.SALVATION, Reward.GREATER_SALVATION, Reward.MASTER_SALVATION, Reward.CORRUPTION, Reward.GREATER_CORRUPTION, Reward.MASTER_CORRUPTION, Reward.MASTER_FIVE_FINGER_DISCOUNT, Reward.MASTER_QUARRYMASTER, Reward.MASTER_LUMBERJACK, Reward.MASTER_POISON_PURGE, Reward.MASTER_RUNIC_ACCURACY, Reward.MASTER_SHARPSHOOTER, Reward.MASTER_CALL_OF_THE_SEA, Reward.MASTER_REVERENCE, Reward.MASTER_KNOCK_OUT, Reward.SUPREME_SALVATION, Reward.SUPREME_CORRUPTION, Reward.HARMONY, Reward.GREATER_HARMONY, Reward.MASTER_HARMONY, Reward.SUPREME_HARMONY, Reward.INVIGORATE, Reward.GREATER_INVIGORATE, Reward.MASTER_INVIGORATE, Reward.SUPREME_INVIGORATE, Reward.SUPREME_FIVE_FINGER_DISCOUNT, Reward.SUPREME_QUARRYMASTER, Reward.SUPREME_LUMBERJACK, Reward.SUPREME_POISON_PURGE, Reward.SUPREME_RUNIC_ACCURACY, Reward.SUPREME_SHARPSHOOTER, Reward.SUPREME_CALL_OF_THE_SEA, Reward.SUPREME_REVERENCE, Reward.SUPREME_TRACKER, Reward.SUPREME_GREENFINGERS), EFFECTS(5724, 2540, 67, 9, Reward.INFERNAL_GAZE, Reward.SERENE_GAZE, Reward.VERNAL_GAZE, Reward.NOCTURNAL_GAZE, Reward.MYSTICAL_GAZE, Reward.BLAZING_GAZE, Reward.ABYSSAL_GAZE, Reward.DIVINE_GAZE), EMOTES(3875, 2230, 68, 2, Reward.CAT_FIGHT, Reward.TALK_TO_THE_HAND, Reward.SHAKE_HANDS, Reward.HIGH_FIVE, Reward.FACE_PALM, Reward.SURRENDER, Reward.LEVITATE, Reward.MUSCLE_MAN_POSE, Reward.ROFL, Reward.BREATHE_FIRE, Reward.STORM, Reward.SNOW, Reward.HEAD_IN_THE_SAND, Reward.HULA_HOOP, Reward.DISAPPEAR, Reward.GHOST, Reward.BRING_IT, Reward.PALM_FIST, Reward.EVIL_LAUGH, Reward.GOLF_CLAP, Reward.LOLCANO, Reward.INFERNAL_POWER, Reward.DIVINE_POWER, Reward.YOURE_DEAD, Reward.SCREAM, Reward.TORNADO, Reward.ROFLCOPTER, Reward.NATURES_MIGHT, Reward.INNER_POWER, Reward.WEREWOLF_TRANSFORMATION), COSTUMES(5189, 2231, 69, 3, Reward.DERVISH_OUTFIT, Reward.EASTERN_OUTFIT, Reward.SAXON_OUTFIT, Reward.SAMBA_OUTFIT, Reward.THEATRICAL_OUTFIT, Reward.PHARAOH_OUTFIT, Reward.CHANGSHAN_OUTFIT, Reward.SILKEN_OUTFIT, Reward.COLONISTS_OUTFIT, Reward.AZTEC_OUTFIT, Reward.HIGHLANDER_OUTFIT, Reward.MUSKETEER_OUTFIT, Reward.ELVEN_OUTFIT, Reward.WEREWOLF_COSTUME), TITLES(5184, 2232, 70, 4, Reward.SIR, Reward.LORD, Reward.DUDERINO, Reward.LIONHEART, Reward.HELLRAISER, Reward.CRUSADER, Reward.DESPERADO, Reward.BARON, Reward.COUNT, Reward.OVERLORD, Reward.BANDITO, Reward.DUKE, Reward.KING, Reward.BIG_CHEESE, Reward.BIGWIG, Reward.WUNDERKIND, Reward.EMPEROR, Reward.PRINCE, Reward.WITCH_KING, Reward.ARCHON, Reward.JUSTICIAR, Reward.THE_AWESOME, Reward.THE_MAGNIFICENT, Reward.THE_UNDEFEATED, Reward.THE_STRANGE, Reward.THE_DIVINE, Reward.THE_FALLEN, Reward.THE_WARRIOR, Reward.ATHLETE), RECOLOR(5183, 2232, 71, 5, Reward.PET_ROCK, Reward.ROBIN_HOOD_HAT, Reward.STAFF_OF_LIGHT, Reward.GNOME_SCARF, Reward.LUNAR_EQUIPMENT, Reward.FULL_SLAYER_HELMET, Reward.RANGER_BOOTS, Reward.RING_OF_STONE, Reward.ANCIENT_STAFF, Reward.MAGES_BOOK, Reward.TOP_HAT); private int csMapId; public int unlockConfig; private int favoriteComponent; private int buyComponent; public int configId; private Reward[] rewards; private static HashMap<Integer, Tab> map = new HashMap<>(); static { for (Tab t : Tab.values()) { map.put(t.buyComponent, t); map.put(t.favoriteComponent, t); } } public static Tab forId(int componentId) { return map.get(componentId); } private Tab(int reqScript, int unlockConfig, int buyComponent, int configId, Reward... rewards) { this.csMapId = reqScript; this.unlockConfig = unlockConfig; this.buyComponent = buyComponent; this.favoriteComponent = buyComponent-6; this.configId = configId; this.rewards = rewards; } public int getBuyComponent() { return buyComponent; } public int getFavoriteComponent() { return favoriteComponent; } public boolean isBuyComponent(int component) { return buyComponent == component; } public boolean isFavoriteComponent(int component) { return favoriteComponent == component; } public Reward getReward(int slot) { if (slot >= rewards.length) return null; return rewards[slot]; } public int getCSMapId(boolean male) { if (this == Tab.COSTUMES) { return male ? 5189 : 5188; } return csMapId; } public Reward[] getRewards() { return rewards; } } public enum Reward { /* * AURAS */ ODDBALL(Type.AURA, 0x0, -1, 20957, 2000), POISON_PURGE(Type.AURA, 0x1, -1, 20958, 2750), FRIEND_IN_NEED(Type.AURA, 0x2, -1, 20963, 3500), KNOCK_OUT(Type.AURA, 0x3, -1, 20961, 3500), SHARPSHOOTER(Type.AURA, 0x4, -1, 20967, 4250), RUNIC_ACCURACY(Type.AURA, 0x5, -1, 20962, 4250), SUREFOOTED(Type.AURA, 0x6, -1, 20964, 5000), REVERENCE(Type.AURA, 0x7, -1, 20965, 5000), CALL_OF_THE_SEA(Type.AURA, 0x8, -1, 20966, 5000), JACK_OF_TRADES(Type.AURA, 0x9, -1, 20959, 15000), GREATER_POISON_PURGE(Type.AURA, 0xA, 20958, 22268, 12250), GREATER_RUNIC_ACCURACY(Type.AURA, 0xB, 20962, 22270, 16750), GREATER_SHARPSHOOTER(Type.AURA, 0xC, 20967, 22272, 16750), GREATER_CALL_OF_THE_SEA(Type.AURA, 0xD, 20966, 22274, 14000), GREATER_REVERENCE(Type.AURA, 0xE, 20965, 22276, 16000), GREATER_SUREFOOTED(Type.AURA, 0xF, 20964, 22278, 12000), LUMBERJACK(Type.AURA, 0x10, -1, 22280, 5000), GREATER_LUMBERJACK(Type.AURA, 0x11, 22280, 22282, 14000), QUARRYMASTER(Type.AURA, 0x12, -1, 22284, 5000), GREATER_QUARRYMASTER(Type.AURA, 0x13, 22284, 22286, 14000), FIVE_FINGER_DISCOUNT(Type.AURA, 0x14, -1, 22288, 5000), GREATER_FIVE_FINGER_DISCOUNT(Type.AURA, 0x15, 22288, 22290, 14000), RESOURCEFUL(Type.AURA, 0x16, -1, 22292, 23000), EQUILIBRIUM(Type.AURA, 0x17, -1, 22294, 23000), INSPIRATION(Type.AURA, 0x18, -1, 22296, 23000), VAMPYRISM(Type.AURA, 0x19, -1, 22298, 23000), PENANCE(Type.AURA, 0x1A, -1, 22300, 23000), WISDOM(Type.AURA, 0x1B, -1, 22302, 40000), AEGIS(Type.AURA, 0x1C, -1, 22889, 84000), REGENERATION(Type.AURA, 0x1D, -1, 22893, 45000), DARK_MAGIC(Type.AURA, 0x1E, -1, 22891, 42500), BERSERKER(Type.AURA, 0x1F, -1, 22897, 50000), ANCESTOR_SPIRITS(Type.AURA, 0x20, -1, 22895, 50000), GREENFINGERS(Type.AURA, 0x21, -1, 22883, 5000), GREATER_GREENFINGERS(Type.AURA, 0x22, 22883, 22885, 16000), MASTER_GREENFINGERS(Type.AURA, 0x23, 22885, 22887, 29000), TRACKER(Type.AURA, 0x24, -1, 22927, 5000), GREATER_TRACKER(Type.AURA, 0x25, 22927, 22929, 16000), MASTER_TRACKER(Type.AURA, 0x26, 22929, 22931, 29000), SALVATION(Type.AURA, 0x27, -1, 22899, 5000), GREATER_SALVATION(Type.AURA, 0x28, 22899, 22901, 12000), MASTER_SALVATION(Type.AURA, 0x29, 22901, 22903, 30500), CORRUPTION(Type.AURA, 0x2A, -1, 22905, 5000), GREATER_CORRUPTION(Type.AURA, 0x2B, 22905, 22907, 12000), MASTER_CORRUPTION(Type.AURA, 0x2C, 22907, 22909, 30500), MASTER_FIVE_FINGER_DISCOUNT(Type.AURA, 0x2D, 22290, 22911, 33500), MASTER_QUARRYMASTER(Type.AURA, 0x2E, 22286, 22913, 33500), MASTER_LUMBERJACK(Type.AURA, 0x2F, 22282, 22915, 33500), MASTER_POISON_PURGE(Type.AURA, 0x30, 22268, 22917, 32500), MASTER_RUNIC_ACCURACY(Type.AURA, 0x31, 22270, 22919, 29000), MASTER_SHARPSHOOTER(Type.AURA, 0x32, 22272, 22921, 29000), MASTER_CALL_OF_THE_SEA(Type.AURA, 0x33, 22274, 22923, 33500), MASTER_REVERENCE(Type.AURA, 0x34, 22276, 22925, 36500), MASTER_KNOCK_OUT(Type.AURA, 0x35, 20961, 22933, 50000), SUPREME_SALVATION(Type.AURA, 0x36, 22903, 23876, 63500), SUPREME_CORRUPTION(Type.AURA, 0x37, 22909, 23874, 63500), HARMONY(Type.AURA, 0x38, -1, 23848, 5000), GREATER_HARMONY(Type.AURA, 0x39, 23848, 23850, 12000), MASTER_HARMONY(Type.AURA, 0x3A, 23850, 23852, 30500), SUPREME_HARMONY(Type.AURA, 0x3B, 23852, 23854, 63500), INVIGORATE(Type.AURA, 0x3C, -1, 23840, 5000), GREATER_INVIGORATE(Type.AURA, 0x3D, 23840, 23842, 16000), MASTER_INVIGORATE(Type.AURA, 0x3E, 23842, 23844, 36500), SUPREME_INVIGORATE(Type.AURA, 0x3F, 23844, 23846, 57500), SUPREME_FIVE_FINGER_DISCOUNT(Type.AURA, 0x40, 22911, 23856, 58500), SUPREME_QUARRYMASTER(Type.AURA, 0x41, 22913, 23858, 58500), SUPREME_LUMBERJACK(Type.AURA, 0x42, 22915, 23860, 58500), SUPREME_POISON_PURGE(Type.AURA, 0x43, 22917, 23862, 51500), SUPREME_RUNIC_ACCURACY(Type.AURA, 0x44, 22919, 23864, 57000), SUPREME_SHARPSHOOTER(Type.AURA, 0x45, 22921, 23866, 57000), SUPREME_CALL_OF_THE_SEA(Type.AURA, 0x46, 22923, 23868, 58500), SUPREME_REVERENCE(Type.AURA, 0x47, 22925, 23870, 57500), SUPREME_TRACKER(Type.AURA, 0x48, 22931, 23872, 61000), SUPREME_GREENFINGERS(Type.AURA, 0x49, 22887, 23878, 61000), /* * Gazes */ INFERNAL_GAZE(Type.EFFECT, 0x0, -1, 23880, 18000), SERENE_GAZE(Type.EFFECT, 0x1, -1, 23882, 18000), VERNAL_GAZE(Type.EFFECT, 0x2, -1, 23884, 18000), NOCTURNAL_GAZE(Type.EFFECT, 0x3, -1, 23886, 18000), MYSTICAL_GAZE(Type.EFFECT, 0x4, -1, 23888, 18000), BLAZING_GAZE(Type.EFFECT, 0x5, -1, 23890, 18000), ABYSSAL_GAZE(Type.EFFECT, 0x6, -1, 23892, 18000), DIVINE_GAZE(Type.EFFECT, 0x7, -1, 23894, 18000), /* * EMOTES */ CAT_FIGHT(Type.EMOTE, 0x0, -1, 21314, 500), TALK_TO_THE_HAND(Type.EMOTE, 0x1, -1, 21306, 750), SHAKE_HANDS(Type.EMOTE, 0x2, -1, 21300, 750), HIGH_FIVE(Type.EMOTE, 0x3, -1, 21302, 750), FACE_PALM(Type.EMOTE, 0x4, -1, 21312, 750), SURRENDER(Type.EMOTE, 0x5, -1, 21320, 750), LEVITATE(Type.EMOTE, 0x6, -1, 21304, 1000), MUSCLE_MAN_POSE(Type.EMOTE, 0x7, -1, 21298, 1000), ROFL(Type.EMOTE, 0x8, -1, 21316, 1000), BREATHE_FIRE(Type.EMOTE, 0x9, -1, 21318, 1000), STORM(Type.EMOTE, 0xA, -1, 21308, 4000), SNOW(Type.EMOTE, 0xB, -1, 21310, 4000), HEAD_IN_THE_SAND(Type.EMOTE, 0xC, -1, 21874, 6000), HULA_HOOP(Type.EMOTE, 0xD, -1, 21876, 4000), DISAPPEAR(Type.EMOTE, 0xE, -1, 21878, 12000), GHOST(Type.EMOTE, 0xF, -1, 21880, 12000), BRING_IT(Type.EMOTE, 0x10, -1, 21882, 1000), PALM_FIST(Type.EMOTE, 0x11, -1, 21884, 750), EVIL_LAUGH(Type.EMOTE, 0x12, -1, 22512, 1000), GOLF_CLAP(Type.EMOTE, 0x13, -1, 22514, 750), LOLCANO(Type.EMOTE, 0x14, -1, 22516, 6000), INFERNAL_POWER(Type.EMOTE, 0x15, -1, 22518, 12000), DIVINE_POWER(Type.EMOTE, 0x16, -1, 22520, 12000), YOURE_DEAD(Type.EMOTE, 0x17, -1, 22522, 1000), SCREAM(Type.EMOTE, 0x18, -1, 22524, 6000), TORNADO(Type.EMOTE, 0x19, -1, 22526, 12000), ROFLCOPTER(Type.EMOTE, 0x1A, -1, 23832, 6000), NATURES_MIGHT(Type.EMOTE, 0x1B, -1, 23834, 12000), INNER_POWER(Type.EMOTE, 0x1C, -1, 23836, 6000), WEREWOLF_TRANSFORMATION(Type.EMOTE, 0x1D, -1, 23838, 12000), /* * COSTUMES */ DERVISH_OUTFIT(Type.COSTUME, 0x0, -1, new Item[][] { //male new Item[] { new Item(20970, 2), new Item(20980, 2), new Item(20990, 2), new Item(21000, 2) }, //female new Item[] { new Item(21010, 2), new Item(21020, 2), new Item(21030, 2), new Item(21040, 2) }, }, 1000), EASTERN_OUTFIT(Type.COSTUME, 0x1, -1, new Item[][] { //male new Item[] { new Item(21050), new Item(21052, 2), new Item(21062, 2), new Item(21072) }, //female new Item[] { new Item(21074), new Item(21076, 2), new Item(21086, 2), new Item(21096, 2) }, }, 1000), SAXON_OUTFIT(Type.COSTUME, 0x2, -1, new Item[][] { //male new Item[] { new Item(21106, 2), new Item(21116, 2), new Item(21126, 2), new Item(21136, 2) }, //female new Item[] { new Item(21146, 2), new Item(21156, 2), new Item(21166, 2), new Item(21176) }, }, 1000), SAMBA_OUTFIT(Type.COSTUME, 0x3, -1, new Item[][] { //male new Item[] { new Item(21178, 2), new Item(21188, 2), new Item(21198, 2), new Item(21208, 2) }, //female new Item[] { new Item(21218, 2), new Item(21228, 2), new Item(21238, 2), new Item(21248) }, }, 1000), THEATRICAL_OUTFIT(Type.COSTUME, 0x4, -1, new Item[][] { //male new Item[] { new Item(21887, 2), new Item(21897, 2), new Item(21907, 2), new Item(21917, 2) }, //female new Item[] { new Item(21927, 2), new Item(21937, 2), new Item(21947, 2), new Item(21957, 2) }, }, 2000), PHARAOH_OUTFIT(Type.COSTUME, 0x5, -1, new Item[][] { //male new Item[] { new Item(21967, 2), new Item(21977, 2), new Item(21987, 2), new Item(21997, 2) }, //female new Item[] { new Item(22007, 2), new Item(22017, 2), new Item(22027, 2), new Item(22037, 2) }, }, 2000), CHANGSHAN_OUTFIT(Type.COSTUME, 0x6, -1, new Item[][] { //male new Item[] { new Item(22047, 2), new Item(22057, 2), new Item(22067, 2), new Item(22077, 2) }, //female new Item[] { new Item(22087, 2), new Item(22097, 2), new Item(22107, 2), new Item(22117, 2) }, }, 2000), SILKEN_OUTFIT(Type.COSTUME, 0x7, -1, new Item[][] { //male new Item[] { new Item(22127, 2), new Item(22137, 2), new Item(22147, 2), new Item(22157, 2) }, //female new Item[] { new Item(22167, 2), new Item(22177, 2), new Item(22187, 2), new Item(22197, 2) }, }, 2000), COLONISTS_OUTFIT(Type.COSTUME, 0x8, -1, new Item[][] { //male new Item[] { new Item(22568, 2), new Item(22578, 2), new Item(22588, 2), new Item(22598, 2) }, //female new Item[] { new Item(22608, 2), new Item(22618, 2), new Item(22628, 2), new Item(22638) }, //TODO cancer shoes.. }, 4000), AZTEC_OUTFIT(Type.COSTUME, 0x9, -1, new Item[][] { //male new Item[] { new Item(22723, 2), new Item(22733, 2), new Item(22743, 2), new Item(22753, 2) }, //female new Item[] { new Item(22763, 2), new Item(22773, 2), new Item(22783, 2), new Item(22793, 2) }, }, 4000), HIGHLANDER_OUTFIT(Type.COSTUME, 0xA, -1, new Item[][] { //male new Item[] { new Item(22643, 2), new Item(22653, 2), new Item(22663, 2), new Item(22673, 2) }, //female new Item[] { new Item(22683, 2), new Item(22693, 2), new Item(22703, 2), new Item(22713, 2) }, }, 4000), MUSKETEER_OUTFIT(Type.COSTUME, 0xB, -1, new Item[][] { //male new Item[] { new Item(22803, 2), new Item(22813, 2), new Item(22823, 2), new Item(22833, 2) }, //female new Item[] { new Item(22843, 2), new Item(22853, 2), new Item(22863, 2), new Item(22873, 2) }, }, 4000), ELVEN_OUTFIT(Type.COSTUME, 0xC, -1, new Item[][] { //male new Item[] { new Item(23912, 2), new Item(23922, 2), new Item(23932, 2), new Item(23942, 2) }, //female new Item[] { new Item(23952, 2), new Item(23962, 2), new Item(23972, 2), new Item(23982, 2) }, }, 8000), WEREWOLF_COSTUME(Type.COSTUME, 0xD, -1, new Item[][] { //male new Item[] { new Item(23992, 2), new Item(24002, 2), new Item(24012, 2), new Item(24022, 2), new Item(24032, 2) }, //female new Item[] { new Item(24042, 2), new Item(24052, 2), new Item(24062, 2), new Item(24072, 2), new Item(24082, 2) }, }, 8000), /* * TITLES */ SIR(Type.TITLE, 0x0, -1, 5, 1000), LORD(Type.TITLE, 0x1, -1, 6, 1000), DUDERINO(Type.TITLE, 0x2, -1, 7, 4000), LIONHEART(Type.TITLE, 0x3, -1, 8, 4000), HELLRAISER(Type.TITLE, 0x4, -1, 9, 8000), CRUSADER(Type.TITLE, 0x5, -1, 10, 8000), DESPERADO(Type.TITLE, 0x6, -1, 11, 10000), BARON(Type.TITLE, 0x7, -1, 12, 10000), COUNT(Type.TITLE, 0x8, -1, 13, 15000), OVERLORD(Type.TITLE, 0x9, -1, 14, 15000), BANDITO(Type.TITLE, 0xA, -1, 15, 20000), DUKE(Type.TITLE, 0xB, -1, 16, 20000), KING(Type.TITLE, 0xC, -1, 17, 25000), BIG_CHEESE(Type.TITLE, 0xD, -1, 18, 25000), BIGWIG(Type.TITLE, 0xE, -1, 19, 25000), WUNDERKIND(Type.TITLE, 0xF, -1, 20, 50000), EMPEROR(Type.TITLE, 0x10, -1, 26, 30000), PRINCE(Type.TITLE, 0x11, -1, 27, 15000), WITCH_KING(Type.TITLE, 0x12, -1, 28, 50000), ARCHON(Type.TITLE, 0x13, -1, 29, 25000), JUSTICIAR(Type.TITLE, 0x14, -1, 30, 20000), THE_AWESOME(Type.TITLE, 0x15, -1, 31, 50000), THE_MAGNIFICENT(Type.TITLE, 0x16, -1, 32, 50000), THE_UNDEFEATED(Type.TITLE, 0x17, -1, 33, 50000), THE_STRANGE(Type.TITLE, 0x18, -1, 34, 50000), THE_DIVINE(Type.TITLE, 0x19, -1, 35, 50000), THE_FALLEN(Type.TITLE, 0x1A, -1, 36, 50000), THE_WARRIOR(Type.TITLE, 0x1B, -1, 37, 50000), ATHLETE(Type.TITLE, 0x1C, -1, 71, 5000), /* * RECOLORS */ PET_ROCK(Type.RECOLOR, 0x10, -1, 3695, 1000), ROBIN_HOOD_HAT(Type.RECOLOR, 0x11, -1, 2581, 1000), STAFF_OF_LIGHT(Type.RECOLOR, 0x12, -1, 15486, 2000), GNOME_SCARF(Type.RECOLOR, 0x13, -1, 9470, 2000), LUNAR_EQUIPMENT(Type.RECOLOR, 0x14, -1, 9096, 2000), FULL_SLAYER_HELMET(Type.RECOLOR, 0x15, -1, 15492, 4000), RANGER_BOOTS(Type.RECOLOR, 0x16, -1, 2577, 4000), RING_OF_STONE(Type.RECOLOR, 0x17, -1, 6583, 4000), ANCIENT_STAFF(Type.RECOLOR, 0x18, -1, 4675, 6000), MAGES_BOOK(Type.RECOLOR, 0x19, -1, 6889, 6000), TOP_HAT(Type.RECOLOR, 0x1A, -1, 13101, 6000); private Type type; private int bit; private int preReq; private Item[][] items; private int price; private static HashMap<Integer, Reward> ITEMID_MAP = new HashMap<Integer, Reward>(); private static HashMap<Integer, Reward> PREREQ_MAP = new HashMap<Integer, Reward>(); static { for (Reward r : Reward.values()) { ITEMID_MAP.put(r.items[0][0].getId(), r); PREREQ_MAP.put(r.preReq, r); } } public static Reward forId(int itemId) { return ITEMID_MAP.get(itemId); } public static Reward forPreReq(int itemId) { return PREREQ_MAP.get(itemId); } private Reward(Type type, int bit, int preReq, Item[][] items, int price) { this.type = type; this.bit = bit; this.preReq = preReq; this.items = items; this.price = price; } private Reward(Type type, int bit, int preReq, int itemId, int price) { this(type, bit, preReq, new Item[][] { { new Item(itemId) } }, price); } public Reward getLowestTier() { Reward reward = this; while(reward.getPreReq() != -1) reward = Reward.forId(reward.preReq); return reward; } public Type getType() { return type; } public int getBit() { return bit; } public int getPreReq() { return preReq; } public Item getItem() { return items[0][0]; } public Item[] getItems() { return items[0]; } public Item[] getItems(int type) { return items[type]; } public int getPrice() { return price; } } public static void main(String[] args) throws IOException { //Cache.init(); dump(); } @SuppressWarnings("unused") private static void dump() { for (Tab t : Tab.values()) { if (t != Tab.COSTUMES) continue; int bit = 0; int index = 0; String nameArr = ""; EnumDefinitions tab = EnumDefinitions.getEnum(t.csMapId); //System.out.println("Tab parsed: " + t.name()); for (int i = 0;i < tab.getSize();i++) { StructDefinitions reward = StructDefinitions.getStruct(tab.getIntValue(i)); if (reward != null) { int bitVal = (bit + (t == Tab.RECOLOR ? 16 : 0)); String name = reward.getStringValue(NAME).trim().toUpperCase().replaceAll(" ", "_"); int itemId = reward.getIntValue(ITEM_ID); if (reward.getStringValue(ENUM).contains("_female")) name += "_F"; if (reward.getStringValue(ENUM).contains("_male")) name += "_M"; int num = 1; if (reward.getIntValue(1950) != 0) { num = 5; } else if (reward.getIntValue(1949) != 0) { num = 4; } else if (reward.getIntValue(1948) != 0) { num = 3; } else if (reward.getIntValue(1947) != 0) { num = 2; } else if (reward.getIntValue(1946) != 0) { num = 1; } int preReq = -1; if (reward.getIntValue(1989) != 0 && reward.getIntValue(1989) < itemId && preReq < itemId) { preReq = reward.getIntValue(1989); } if (reward.getIntValue(1990) != 0 && reward.getIntValue(1990) < itemId && preReq < itemId) { preReq = reward.getIntValue(1990); } if (reward.getIntValue(1991) != 0 && reward.getIntValue(1991) < itemId && preReq < itemId) { preReq = reward.getIntValue(1991); } String[] colors = new String[num]; for (int j = 0;j < num;j++) { if (reward.getIntValue(1946+j) != 0) { colors[j] = StructDefinitions.getStruct(reward.getIntValue(1946+j)).getStringValue(1994); } } nameArr += "Reward."+name + (i == tab.getSize()-1 ? "" : ", "); //System.out.println(name+"(0x"+Integer.toHexString(bitVal).toUpperCase()+", "+preReq+", "+itemId+", "+num+", "+reward.getIntValue(PRICE)+"),"); System.out.println(reward.getValues()); System.out.println(Arrays.toString(colors)); // if (i == tab.getSize()-1) { // System.out.println(nameArr); // } index++; bit++; } } } } }
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
4