Search in sources :

Example 1 with VarbitDefinition

use of net.runelite.cache.definitions.VarbitDefinition in project runelite by runelite.

the class VarbitLoader method load.

public VarbitDefinition load(int id, byte[] b) {
    VarbitDefinition def = new VarbitDefinition();
    InputStream is = new InputStream(b);
    def.setId(id);
    for (; ; ) {
        int opcode = is.readUnsignedByte();
        if (opcode == 0) {
            break;
        }
        if (opcode == 1) {
            def.setIndex(is.readUnsignedShort());
            def.setLeastSignificantBit(is.readUnsignedByte());
            def.setMostSignificantBit(is.readUnsignedByte());
        }
    }
    return def;
}
Also used : VarbitDefinition(net.runelite.cache.definitions.VarbitDefinition) InputStream(net.runelite.cache.io.InputStream)

Example 2 with VarbitDefinition

use of net.runelite.cache.definitions.VarbitDefinition in project runelite by runelite.

the class VarbitDumper method extract.

@Test
public void extract() throws IOException {
    File base = StoreLocation.LOCATION, outDir = folder.newFolder();
    int count = 0;
    try (Store store = new Store(base)) {
        store.load();
        Storage storage = store.getStorage();
        Index index = store.getIndex(IndexType.CONFIGS);
        Archive archive = index.getArchive(ConfigType.VARBIT.getId());
        byte[] archiveData = storage.loadArchive(archive);
        ArchiveFiles files = archive.getFiles(archiveData);
        for (FSFile file : files.getFiles()) {
            VarbitLoader loader = new VarbitLoader();
            VarbitDefinition varbit = loader.load(file.getFileId(), file.getContents());
            Files.write(gson.toJson(varbit), new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} varbits to {}", count, outDir);
}
Also used : VarbitDefinition(net.runelite.cache.definitions.VarbitDefinition) Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) File(java.io.File) FSFile(net.runelite.cache.fs.FSFile) VarbitLoader(net.runelite.cache.definitions.loaders.VarbitLoader) FSFile(net.runelite.cache.fs.FSFile) Test(org.junit.Test)

Aggregations

VarbitDefinition (net.runelite.cache.definitions.VarbitDefinition)2 File (java.io.File)1 VarbitLoader (net.runelite.cache.definitions.loaders.VarbitLoader)1 Archive (net.runelite.cache.fs.Archive)1 ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)1 FSFile (net.runelite.cache.fs.FSFile)1 Index (net.runelite.cache.fs.Index)1 Storage (net.runelite.cache.fs.Storage)1 Store (net.runelite.cache.fs.Store)1 InputStream (net.runelite.cache.io.InputStream)1 Test (org.junit.Test)1