Search in sources :

Example 11 with Storage

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

the class ModelDumperTest method test.

@Test
public void test() throws IOException {
    File modelDir = folder.newFolder("models");
    int count = 0;
    try (Store store = new Store(StoreLocation.LOCATION)) {
        store.load();
        Storage storage = store.getStorage();
        Index index = store.getIndex(IndexType.MODELS);
        for (Archive archive : index.getArchives()) {
            byte[] contents = archive.decompress(storage.loadArchive(archive));
            ModelLoader loader = new ModelLoader();
            loader.load(archive.getArchiveId(), contents);
            Files.write(contents, new File(modelDir, archive.getArchiveId() + ".model"));
            ++count;
        }
    }
    logger.info("Dumped {} models to {}", count, modelDir);
}
Also used : ModelLoader(net.runelite.cache.definitions.loaders.ModelLoader) 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) Test(org.junit.Test)

Example 12 with Storage

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

the class TrackDumperTest method test.

@Test
public void test() throws IOException {
    File dumpDir1 = folder.newFolder(), dumpDir2 = folder.newFolder();
    int idx1 = 0, idx2 = 0;
    djb2.load();
    try (Store store = new Store(StoreLocation.LOCATION)) {
        store.load();
        Storage storage = store.getStorage();
        Index index = store.getIndex(IndexType.TRACK1);
        Index index2 = store.getIndex(IndexType.TRACK2);
        for (Archive archive : index.getArchives()) {
            dumpTrackArchive(dumpDir1, storage, archive);
            ++idx1;
        }
        for (Archive archive : index2.getArchives()) {
            dumpTrackArchive(dumpDir2, storage, archive);
            ++idx2;
        }
    }
    logger.info("Dumped {} sound tracks ({} idx1, {} idx2) to {} and {}", idx1 + idx2, idx1, idx2, dumpDir1, dumpDir2);
}
Also used : 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) Test(org.junit.Test)

Example 13 with Storage

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

the class RegionLoader method loadRegionFromArchive.

public Region loadRegionFromArchive(int i) throws IOException {
    int x = i >> 8;
    int y = i & 0xFF;
    Storage storage = store.getStorage();
    Archive map = index.findArchiveByName("m" + x + "_" + y);
    Archive land = index.findArchiveByName("l" + x + "_" + y);
    assert (map == null) == (land == null);
    if (map == null || land == null) {
        return null;
    }
    byte[] data = map.decompress(storage.loadArchive(map));
    MapDefinition mapDef = new MapLoader().load(x, y, data);
    Region region = new Region(i);
    region.loadTerrain(mapDef);
    int[] keys = keyManager.getKeys(i);
    if (keys != null) {
        try {
            data = land.decompress(storage.loadArchive(land), keys);
            LocationsDefinition locDef = new LocationsLoader().load(x, y, data);
            region.loadLocations(locDef);
        } catch (IOException ex) {
            logger.debug("Can't decrypt region " + i, ex);
        }
    }
    return region;
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) MapLoader(net.runelite.cache.definitions.loaders.MapLoader) IOException(java.io.IOException) LocationsLoader(net.runelite.cache.definitions.loaders.LocationsLoader) LocationsDefinition(net.runelite.cache.definitions.LocationsDefinition) MapDefinition(net.runelite.cache.definitions.MapDefinition)

Example 14 with Storage

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

the class TitleDumper method extract.

@Test
public void extract() throws IOException {
    File base = StoreLocation.LOCATION, outFile = folder.newFolder();
    try (Store store = new Store(base)) {
        store.load();
        Storage storage = store.getStorage();
        Index index = store.getIndex(IndexType.BINARY);
        Archive archive = index.findArchiveByName("title.jpg");
        byte[] contents = archive.decompress(storage.loadArchive(archive));
        Files.write(outFile.toPath(), contents);
    }
    logger.info("Dumped to {}", outFile);
}
Also used : 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) Test(org.junit.Test)

Example 15 with Storage

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

the class UnderlayDumper 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.UNDERLAY.getId());
        byte[] archiveData = storage.loadArchive(archive);
        ArchiveFiles files = archive.getFiles(archiveData);
        for (FSFile file : files.getFiles()) {
            UnderlayLoader loader = new UnderlayLoader();
            UnderlayDefinition underlay = loader.load(file.getFileId(), file.getContents());
            Files.write(gson.toJson(underlay), new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} underlays to {}", count, outDir);
}
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) UnderlayDefinition(net.runelite.cache.definitions.UnderlayDefinition) Index(net.runelite.cache.fs.Index) File(java.io.File) FSFile(net.runelite.cache.fs.FSFile) UnderlayLoader(net.runelite.cache.definitions.loaders.UnderlayLoader) FSFile(net.runelite.cache.fs.FSFile) Test(org.junit.Test)

Aggregations

Archive (net.runelite.cache.fs.Archive)34 Storage (net.runelite.cache.fs.Storage)34 Index (net.runelite.cache.fs.Index)33 ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)18 FSFile (net.runelite.cache.fs.FSFile)18 Store (net.runelite.cache.fs.Store)18 File (java.io.File)17 Test (org.junit.Test)17 IOException (java.io.IOException)4 FramemapDefinition (net.runelite.cache.definitions.FramemapDefinition)2 InterfaceDefinition (net.runelite.cache.definitions.InterfaceDefinition)2 InventoryDefinition (net.runelite.cache.definitions.InventoryDefinition)2 LocationsDefinition (net.runelite.cache.definitions.LocationsDefinition)2 MapDefinition (net.runelite.cache.definitions.MapDefinition)2 OverlayDefinition (net.runelite.cache.definitions.OverlayDefinition)2 SpriteDefinition (net.runelite.cache.definitions.SpriteDefinition)2 UnderlayDefinition (net.runelite.cache.definitions.UnderlayDefinition)2 FramemapLoader (net.runelite.cache.definitions.loaders.FramemapLoader)2 InterfaceLoader (net.runelite.cache.definitions.loaders.InterfaceLoader)2 InventoryLoader (net.runelite.cache.definitions.loaders.InventoryLoader)2