use of net.runelite.cache.definitions.loaders.ScriptLoader in project runelite by runelite.
the class DisassemblerTest method test.
@Test
public void test() throws IOException {
File outDir = folder.newFolder();
int count = 0;
try (Store store = new Store(StoreLocation.LOCATION)) {
store.load();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CLIENTSCRIPT);
ScriptLoader loader = new ScriptLoader();
for (Archive archive : index.getArchives()) {
byte[] contents = archive.decompress(storage.loadArchive(archive));
if (contents == null) {
continue;
}
ScriptDefinition script = loader.load(0, contents);
File outFile = new File(outDir, archive.getArchiveId() + ".rs2asm");
Disassembler disassembler = new Disassembler();
String out = disassembler.disassemble(script);
Files.write(out.getBytes(), outFile);
++count;
}
}
logger.info("Dumped {} scripts to {}", count, outDir);
}
use of net.runelite.cache.definitions.loaders.ScriptLoader in project runelite by runelite.
the class ScriptSaverTest method testSave.
@Test
public void testSave() throws IOException {
Instructions instructions = new Instructions();
instructions.init();
ScriptDefinition script = new Assembler(instructions).assemble(getClass().getResourceAsStream(SCRIPT_RESOURCE));
byte[] saved = new ScriptSaver().save(script);
ScriptDefinition loadedScripot = new ScriptLoader().load(42, saved);
assertEquals(script, loadedScripot);
}
Aggregations