Search in sources :

Example 1 with EnumDefinition

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

the class EnumLoader method load.

public EnumDefinition load(int id, byte[] b) {
    EnumDefinition def = new EnumDefinition();
    InputStream is = new InputStream(b);
    def.setId(id);
    for (; ; ) {
        int opcode = is.readUnsignedByte();
        if (opcode == 0) {
            break;
        }
        processOp(opcode, def, is);
    }
    return def;
}
Also used : InputStream(net.runelite.cache.io.InputStream) EnumDefinition(net.runelite.cache.definitions.EnumDefinition)

Example 2 with EnumDefinition

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

the class EnumDumperTest 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.CONFIGS);
        Archive archive = index.getArchive(ConfigType.ENUM.getId());
        byte[] archiveData = storage.loadArchive(archive);
        ArchiveFiles files = archive.getFiles(archiveData);
        EnumLoader loader = new EnumLoader();
        for (FSFile file : files.getFiles()) {
            byte[] b = file.getContents();
            EnumDefinition def = loader.load(file.getFileId(), b);
            Files.write(gson.toJson(def), new File(dumpDir, file.getFileId() + ".json"), Charset.defaultCharset());
            ++count;
        }
    }
    logger.info("Dumped {} enums to {}", count, dumpDir);
}
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) Index(net.runelite.cache.fs.Index) EnumLoader(net.runelite.cache.definitions.loaders.EnumLoader) EnumDefinition(net.runelite.cache.definitions.EnumDefinition) File(java.io.File) FSFile(net.runelite.cache.fs.FSFile) FSFile(net.runelite.cache.fs.FSFile) Test(org.junit.Test)

Aggregations

EnumDefinition (net.runelite.cache.definitions.EnumDefinition)2 File (java.io.File)1 EnumLoader (net.runelite.cache.definitions.loaders.EnumLoader)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 Test (org.junit.Test)1