Search in sources :

Example 11 with Archive

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

the class TextureManager method load.

public void load() throws IOException {
    Storage storage = store.getStorage();
    Index index = store.getIndex(IndexType.TEXTURES);
    Archive archive = index.getArchive(0);
    byte[] archiveData = storage.loadArchive(archive);
    ArchiveFiles files = archive.getFiles(archiveData);
    TextureLoader loader = new TextureLoader();
    for (FSFile file : files.getFiles()) {
        TextureDefinition texture = loader.load(file.getFileId(), file.getContents());
        textures.add(texture);
    }
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) TextureLoader(net.runelite.cache.definitions.loaders.TextureLoader) Index(net.runelite.cache.fs.Index) TextureDefinition(net.runelite.cache.definitions.TextureDefinition) FSFile(net.runelite.cache.fs.FSFile)

Example 12 with Archive

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

the class SoundEffectsDumperTest 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.SOUNDEFFECTS);
        for (Archive archive : index.getArchives()) {
            byte[] contents = archive.decompress(storage.loadArchive(archive));
            SoundEffectLoader soundEffectLoader = new SoundEffectLoader();
            SoundEffectDefinition soundEffect = soundEffectLoader.load(contents);
            Files.write(gson.toJson(soundEffect), new File(dumpDir, archive.getArchiveId() + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} sound effects to {}", count, dumpDir);
}
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) SoundEffectLoader(net.runelite.cache.definitions.loaders.sound.SoundEffectLoader) SoundEffectDefinition(net.runelite.cache.definitions.sound.SoundEffectDefinition) File(java.io.File) Test(org.junit.Test)

Example 13 with Archive

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

the class MapDumperTest method dumpRaw.

@Test
@Ignore
public void dumpRaw() throws IOException {
    File base = StoreLocation.LOCATION, outDir = folder.newFolder();
    XteaKeyManager keyManager = new XteaKeyManager();
    keyManager.loadKeys();
    try (Store store = new Store(base)) {
        store.load();
        Storage storage = store.getStorage();
        Index index = store.getIndex(IndexType.MAPS);
        for (int i = 0; i < MAX_REGIONS; i++) {
            int[] keys = keyManager.getKeys(i);
            int x = i >> 8;
            int y = i & 0xFF;
            Archive map = index.findArchiveByName("m" + x + "_" + y);
            Archive land = index.findArchiveByName("l" + x + "_" + y);
            assert (map == null) == (land == null);
            if (map == null || land == null) {
                continue;
            }
            byte[] data = map.decompress(storage.loadArchive(map));
            Files.write(data, new File(outDir, "m" + x + "_" + y + ".dat"));
            if (keys != null) {
                try {
                    data = land.decompress(storage.loadArchive(land), keys);
                } catch (IOException ex) {
                    logger.info("Unable to decompress and load land " + x + "," + y + " (bad keys?)", ex);
                    continue;
                }
                logger.info("Decrypted region {} coords {},{}", i, x, y);
                Files.write(data, new File(outDir, "l" + x + "_" + y + ".dat"));
            }
        }
    }
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) XteaKeyManager(net.runelite.cache.util.XteaKeyManager) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) IOException(java.io.IOException) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 14 with Archive

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

the class MapDumperTest method loadRegions.

private Map<MapDefinition, LocationsDefinition> loadRegions(Store store) throws IOException {
    Map<MapDefinition, LocationsDefinition> mapMap = new HashMap<>();
    Storage storage = store.getStorage();
    Index index = store.getIndex(IndexType.MAPS);
    XteaKeyManager keyManager = new XteaKeyManager();
    keyManager.loadKeys();
    for (int i = 0; i < MAX_REGIONS; ++i) {
        int x = i >> 8;
        int y = i & 0xFF;
        Archive map = index.findArchiveByName("m" + x + "_" + y);
        Archive land = index.findArchiveByName("l" + x + "_" + y);
        assert (map == null) == (land == null);
        if (map == null || land == null) {
            continue;
        }
        byte[] data = map.decompress(storage.loadArchive(map));
        MapDefinition mapDef = new MapLoader().load(x, y, data);
        LocationsDefinition locDef = null;
        int[] keys = keyManager.getKeys(i);
        if (keys != null) {
            try {
                data = land.decompress(storage.loadArchive(land), keys);
            } catch (IOException ex) {
                continue;
            }
            locDef = new LocationsLoader().load(x, y, data);
        }
        mapMap.put(mapDef, locDef);
    }
    return mapMap;
}
Also used : Archive(net.runelite.cache.fs.Archive) HashMap(java.util.HashMap) XteaKeyManager(net.runelite.cache.util.XteaKeyManager) Index(net.runelite.cache.fs.Index) IOException(java.io.IOException) LocationsLoader(net.runelite.cache.definitions.loaders.LocationsLoader) MapDefinition(net.runelite.cache.definitions.MapDefinition) Storage(net.runelite.cache.fs.Storage) MapLoader(net.runelite.cache.definitions.loaders.MapLoader) LocationsDefinition(net.runelite.cache.definitions.LocationsDefinition)

Example 15 with Archive

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

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