Search in sources :

Example 1 with WorldMapDefinition

use of net.runelite.cache.definitions.WorldMapDefinition in project runelite by runelite.

the class WorldMapLoader method load.

public WorldMapDefinition load(byte[] b, int fileId) {
    WorldMapDefinition def = new WorldMapDefinition();
    InputStream in = new InputStream(b);
    def.fileId = fileId;
    def.safeName = in.readString();
    def.name = in.readString();
    int packedPos = in.readInt();
    if (packedPos == -1) {
        def.position = new Position(-1, -1, -1);
    } else {
        int y = packedPos >> 28 & 3;
        int x = packedPos >> 14 & 16383;
        int z = packedPos & 16383;
        def.position = new Position(x, y, z);
    }
    def.field450 = in.readInt();
    in.readUnsignedByte();
    def.field457 = in.readUnsignedByte() == 1;
    def.field451 = in.readUnsignedByte();
    int var3 = in.readUnsignedByte();
    def.field458 = new LinkedList();
    for (int var4 = 0; var4 < var3; ++var4) {
        def.field458.add(this.loadType(in));
    }
    return def;
}
Also used : Position(net.runelite.cache.region.Position) InputStream(net.runelite.cache.io.InputStream) WorldMapDefinition(net.runelite.cache.definitions.WorldMapDefinition) LinkedList(java.util.LinkedList)

Example 2 with WorldMapDefinition

use of net.runelite.cache.definitions.WorldMapDefinition 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)

Aggregations

WorldMapDefinition (net.runelite.cache.definitions.WorldMapDefinition)2 File (java.io.File)1 LinkedList (java.util.LinkedList)1 WorldMapLoader (net.runelite.cache.definitions.loaders.WorldMapLoader)1 Archive (net.runelite.cache.fs.Archive)1 ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)1 FSFile (net.runelite.cache.fs.FSFile)1 Index (net.runelite.cache.fs.Index)1 Storage (net.runelite.cache.fs.Storage)1 Store (net.runelite.cache.fs.Store)1 InputStream (net.runelite.cache.io.InputStream)1 Position (net.runelite.cache.region.Position)1 Test (org.junit.Test)1