Search in sources :

Example 1 with FramemapDefinition

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

the class FrameDumper 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 frameIndex = store.getIndex(IndexType.FRAMES);
        Index framemapIndex = store.getIndex(IndexType.FRAMEMAPS);
        for (Archive archive : frameIndex.getArchives()) {
            List<FrameDefinition> frames = new ArrayList<>();
            byte[] archiveData = storage.loadArchive(archive);
            byte[] contents = archive.decompress(archiveData);
            int framemapArchiveId = (contents[0] & 0xff) << 8 | contents[1] & 0xff;
            Archive framemapArchive = framemapIndex.getArchives().get(framemapArchiveId);
            archiveData = storage.loadArchive(framemapArchive);
            byte[] framemapContents = framemapArchive.decompress(archiveData);
            FramemapLoader fmloader = new FramemapLoader();
            FramemapDefinition framemap = fmloader.load(0, framemapContents);
            FrameLoader frameLoader = new FrameLoader();
            FrameDefinition frame = frameLoader.load(framemap, contents);
            frames.add(frame);
            Files.write(gson.toJson(frames), new File(outDir, archive.getArchiveId() + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} frames to {}", count, outDir);
}
Also used : FrameDefinition(net.runelite.cache.definitions.FrameDefinition) Archive(net.runelite.cache.fs.Archive) ArrayList(java.util.ArrayList) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) FramemapLoader(net.runelite.cache.definitions.loaders.FramemapLoader) Storage(net.runelite.cache.fs.Storage) FrameLoader(net.runelite.cache.definitions.loaders.FrameLoader) File(java.io.File) FramemapDefinition(net.runelite.cache.definitions.FramemapDefinition)

Example 2 with FramemapDefinition

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

the class FramemapDumper 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.FRAMEMAPS);
        for (Archive archive : index.getArchives()) {
            byte[] archiveData = storage.loadArchive(archive);
            byte[] contents = archive.decompress(archiveData);
            FramemapLoader loader = new FramemapLoader();
            FramemapDefinition framemap = loader.load(0, contents);
            Files.write(gson.toJson(framemap), new File(outDir, archive.getArchiveId() + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} framemaps to {}", count, outDir);
}
Also used : FramemapLoader(net.runelite.cache.definitions.loaders.FramemapLoader) Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) File(java.io.File) FramemapDefinition(net.runelite.cache.definitions.FramemapDefinition) Test(org.junit.Test)

Example 3 with FramemapDefinition

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

the class FramemapLoader method load.

public FramemapDefinition load(int id, byte[] b) {
    FramemapDefinition def = new FramemapDefinition();
    InputStream in = new InputStream(b);
    def.id = id;
    def.length = in.readUnsignedByte();
    def.field1456 = new int[def.length];
    def.field1457 = new int[def.length][];
    for (int i = 0; i < def.length; ++i) {
        def.field1456[i] = in.readUnsignedByte();
    }
    for (int i = 0; i < def.length; ++i) {
        def.field1457[i] = new int[in.readUnsignedByte()];
    }
    for (int i = 0; i < def.length; ++i) {
        for (int j = 0; j < def.field1457[i].length; ++j) {
            def.field1457[i][j] = in.readUnsignedByte();
        }
    }
    return def;
}
Also used : InputStream(net.runelite.cache.io.InputStream) FramemapDefinition(net.runelite.cache.definitions.FramemapDefinition)

Aggregations

FramemapDefinition (net.runelite.cache.definitions.FramemapDefinition)3 File (java.io.File)2 FramemapLoader (net.runelite.cache.definitions.loaders.FramemapLoader)2 Archive (net.runelite.cache.fs.Archive)2 Index (net.runelite.cache.fs.Index)2 Storage (net.runelite.cache.fs.Storage)2 Store (net.runelite.cache.fs.Store)2 ArrayList (java.util.ArrayList)1 FrameDefinition (net.runelite.cache.definitions.FrameDefinition)1 FrameLoader (net.runelite.cache.definitions.loaders.FrameLoader)1 InputStream (net.runelite.cache.io.InputStream)1 Test (org.junit.Test)1