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);
}
}
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);
}
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"));
}
}
}
}
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;
}
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);
}
Aggregations