Search in sources :

Example 1 with FrameDefinition

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

the class FrameLoader method load.

public FrameDefinition load(FramemapDefinition framemap, byte[] b) {
    FrameDefinition def = new FrameDefinition();
    InputStream in = new InputStream(b);
    InputStream data = new InputStream(b);
    def.framemap = framemap;
    int framemapArchiveIndex = in.readUnsignedShort();
    int length = in.readUnsignedByte();
    // framemapArchiveIndex + length + data
    data.skip(3 + length);
    int[] indexFrameIds = new int[500];
    int[] scratchTranslatorX = new int[500];
    int[] scratchTranslatorY = new int[500];
    int[] scratchTranslatorZ = new int[500];
    int lastI = -1;
    int index = 0;
    for (int i = 0; i < length; ++i) {
        int var9 = in.readUnsignedByte();
        if (var9 <= 0) {
            continue;
        }
        if (def.framemap.field1456[i] != 0) {
            for (int var10 = i - 1; var10 > lastI; --var10) {
                if (def.framemap.field1456[var10] == 0) {
                    indexFrameIds[index] = var10;
                    scratchTranslatorX[index] = 0;
                    scratchTranslatorY[index] = 0;
                    scratchTranslatorZ[index] = 0;
                    ++index;
                    break;
                }
            }
        }
        indexFrameIds[index] = i;
        short var11 = 0;
        if (def.framemap.field1456[i] == 3) {
            var11 = 128;
        }
        if ((var9 & 1) != 0) {
            scratchTranslatorX[index] = data.readShortSmart();
        } else {
            scratchTranslatorX[index] = var11;
        }
        if ((var9 & 2) != 0) {
            scratchTranslatorY[index] = data.readShortSmart();
        } else {
            scratchTranslatorY[index] = var11;
        }
        if ((var9 & 4) != 0) {
            scratchTranslatorZ[index] = data.readShortSmart();
        } else {
            scratchTranslatorZ[index] = var11;
        }
        lastI = i;
        ++index;
        if (def.framemap.field1456[i] == 5) {
            def.field1315 = true;
        }
    }
    if (data.getOffset() != b.length) {
        throw new RuntimeException();
    }
    def.field1310 = index;
    def.indexFrameIds = new int[index];
    def.translator_x = new int[index];
    def.translator_y = new int[index];
    def.translator_z = new int[index];
    for (int i = 0; i < index; ++i) {
        def.indexFrameIds[i] = indexFrameIds[i];
        def.translator_x[i] = scratchTranslatorX[i];
        def.translator_y[i] = scratchTranslatorY[i];
        def.translator_z[i] = scratchTranslatorZ[i];
    }
    return def;
}
Also used : FrameDefinition(net.runelite.cache.definitions.FrameDefinition) InputStream(net.runelite.cache.io.InputStream)

Example 2 with FrameDefinition

use of net.runelite.cache.definitions.FrameDefinition 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)

Aggregations

FrameDefinition (net.runelite.cache.definitions.FrameDefinition)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 FramemapDefinition (net.runelite.cache.definitions.FramemapDefinition)1 FrameLoader (net.runelite.cache.definitions.loaders.FrameLoader)1 FramemapLoader (net.runelite.cache.definitions.loaders.FramemapLoader)1 Archive (net.runelite.cache.fs.Archive)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