Search in sources :

Example 21 with Archive

use of net.runelite.cache.fs.Archive 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)

Example 22 with Archive

use of net.runelite.cache.fs.Archive in project runelite by runelite.

the class WorldMapDumperTest 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.WORLDMAP);
        // there is also archive 1/2, but their data format is not this
        Archive archive = index.getArchive(0);
        byte[] archiveData = storage.loadArchive(archive);
        ArchiveFiles files = archive.getFiles(archiveData);
        for (FSFile file : files.getFiles()) {
            WorldMapLoader loader = new WorldMapLoader();
            WorldMapDefinition def = loader.load(file.getContents(), file.getFileId());
            Files.write(gson.toJson(def), new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} world map data to {}", count, outDir);
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) WorldMapDefinition(net.runelite.cache.definitions.WorldMapDefinition) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) File(java.io.File) FSFile(net.runelite.cache.fs.FSFile) FSFile(net.runelite.cache.fs.FSFile) WorldMapLoader(net.runelite.cache.definitions.loaders.WorldMapLoader) Test(org.junit.Test)

Example 23 with Archive

use of net.runelite.cache.fs.Archive in project runelite by runelite.

the class InterfaceSaverTest method testSave.

@Test
public void testSave() throws Exception {
    File base = StoreLocation.LOCATION;
    try (Store store = new Store(base)) {
        store.load();
        Storage storage = store.getStorage();
        Index index = store.getIndex(IndexType.INTERFACES);
        Archive archive = index.getArchive(149);
        byte[] archiveData = storage.loadArchive(archive);
        ArchiveFiles files = archive.getFiles(archiveData);
        FSFile file = files.findFile(0);
        byte[] contents = file.getContents();
        InterfaceDefinition def = new InterfaceLoader().load(0, contents);
        byte[] b = new InterfaceSaver().save(def);
        assertArrayEquals(contents, b);
    }
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) InterfaceLoader(net.runelite.cache.definitions.loaders.InterfaceLoader) InterfaceDefinition(net.runelite.cache.definitions.InterfaceDefinition) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) File(java.io.File) FSFile(net.runelite.cache.fs.FSFile) FSFile(net.runelite.cache.fs.FSFile) Test(org.junit.Test)

Example 24 with Archive

use of net.runelite.cache.fs.Archive in project runelite by runelite.

the class EnumDumperTest method test.

@Test
public void test() throws IOException {
    File dumpDir = folder.newFolder();
    int count = 0;
    try (Store store = new Store(StoreLocation.LOCATION)) {
        store.load();
        Storage storage = store.getStorage();
        Index index = store.getIndex(IndexType.CONFIGS);
        Archive archive = index.getArchive(ConfigType.ENUM.getId());
        byte[] archiveData = storage.loadArchive(archive);
        ArchiveFiles files = archive.getFiles(archiveData);
        EnumLoader loader = new EnumLoader();
        for (FSFile file : files.getFiles()) {
            byte[] b = file.getContents();
            EnumDefinition def = loader.load(file.getFileId(), b);
            Files.write(gson.toJson(def), new File(dumpDir, file.getFileId() + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} enums to {}", count, dumpDir);
}
Also used : 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) EnumLoader(net.runelite.cache.definitions.loaders.EnumLoader) EnumDefinition(net.runelite.cache.definitions.EnumDefinition) File(java.io.File) FSFile(net.runelite.cache.fs.FSFile) FSFile(net.runelite.cache.fs.FSFile) Test(org.junit.Test)

Example 25 with Archive

use of net.runelite.cache.fs.Archive 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

Archive (net.runelite.cache.fs.Archive)41 Index (net.runelite.cache.fs.Index)38 Storage (net.runelite.cache.fs.Storage)34 Store (net.runelite.cache.fs.Store)21 File (java.io.File)19 Test (org.junit.Test)19 ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)18 FSFile (net.runelite.cache.fs.FSFile)18 IOException (java.io.IOException)6 FileData (net.runelite.cache.index.FileData)4 Container (net.runelite.cache.fs.Container)3 BufferedImage (java.awt.image.BufferedImage)2 CacheClient (net.runelite.cache.client.CacheClient)2 FramemapDefinition (net.runelite.cache.definitions.FramemapDefinition)2 InterfaceDefinition (net.runelite.cache.definitions.InterfaceDefinition)2 InventoryDefinition (net.runelite.cache.definitions.InventoryDefinition)2 ItemDefinition (net.runelite.cache.definitions.ItemDefinition)2 LocationsDefinition (net.runelite.cache.definitions.LocationsDefinition)2 MapDefinition (net.runelite.cache.definitions.MapDefinition)2 OverlayDefinition (net.runelite.cache.definitions.OverlayDefinition)2