Search in sources :

Example 6 with Storage

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

the class ObjectManager method load.

public void load() throws IOException {
    ObjectLoader loader = new ObjectLoader();
    Storage storage = store.getStorage();
    Index index = store.getIndex(IndexType.CONFIGS);
    Archive archive = index.getArchive(ConfigType.OBJECT.getId());
    byte[] archiveData = storage.loadArchive(archive);
    ArchiveFiles files = archive.getFiles(archiveData);
    for (FSFile f : files.getFiles()) {
        ObjectDefinition def = loader.load(f.getFileId(), f.getContents());
        objects.put(f.getFileId(), def);
    }
}
Also used : Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) ObjectLoader(net.runelite.cache.definitions.loaders.ObjectLoader) Index(net.runelite.cache.fs.Index) ObjectDefinition(net.runelite.cache.definitions.ObjectDefinition) FSFile(net.runelite.cache.fs.FSFile)

Example 7 with Storage

use of net.runelite.cache.fs.Storage 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 8 with Storage

use of net.runelite.cache.fs.Storage 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 9 with Storage

use of net.runelite.cache.fs.Storage 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 10 with Storage

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

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