private static Store loadStore(String cache) throws IOException { Store store = new Store(new File(cache)); store.load(); return store; }
@Test public void testLoad() throws IOException { try (Store store = new Store(StoreLocation.LOCATION)) { store.load(); } }
@Test public void test() throws IOException { File dumpDir = folder.newFolder(); int count = 0; try (Store store = new Store(StoreLocation.LOCATION)) { store.load(); StructManager loader = new StructManager(store); loader.load(); for (Map.Entry<Integer, StructDefinition> struct : loader.getStructs().entrySet()) { StructDefinition def = struct.getValue(); Files.write(gson.toJson(def), new File(dumpDir, struct.getKey() + ".json"), Charset.defaultCharset()); ++count; } } logger.info("Dumped {} structs to {}", count, dumpDir); } }
@Test @Ignore public void testExport() throws Exception { try (Store store = new Store(StoreLocation.LOCATION)) { store.load(); TextureManager tm = new TextureManager(store); tm.load(); ModelLoader loader = new ModelLoader(); ModelDefinition model = loader.load(9638, Files.readAllBytes(new File("D:\\rs\\07\\cache\\models\\9638.model").toPath())); ObjExporter exporter = new ObjExporter(tm, model); try (PrintWriter objWriter = new PrintWriter(new FileWriter(new File("D:\\rs\\07\\temp\\9638.obj"))); PrintWriter mtlWriter = new PrintWriter(new FileWriter(new File("D:\\rs\\07\\temp\\9638.mtl")))) { exporter.export(objWriter, mtlWriter); } } } }
public void extract() throws IOException { File base = StoreLocation.LOCATION, outDir = folder.newFolder(); try (Store store = new Store(base)) { store.load(); HeightMapDumper dumper = new HeightMapDumper(store); dumper.load(); BufferedImage image = dumper.drawHeightMap(0); File imageFile = new File(outDir, "heightmap-0.png"); ImageIO.write(image, "png", imageFile); logger.info("Wrote image {}", imageFile); } } }
@Test public void extract() throws IOException { File base = StoreLocation.LOCATION, outDir = folder.newFolder(); int count = 0; try (Store store = new Store(base)) { store.load(); AreaManager areaManager = new AreaManager(store); areaManager.load(); for (AreaDefinition area : areaManager.getAreas()) { Files.write(gson.toJson(area), new File(outDir, area.id + ".json"), Charset.defaultCharset()); ++count; } } logger.info("Dumped {} areas to {}", count, outDir); } }
@Test public void extract() throws IOException { File base = StoreLocation.LOCATION, outDir = folder.newFolder(); int count = 0; try (Store store = new Store(base)) { store.load(); TextureManager tm = new TextureManager(store); tm.load(); for (TextureDefinition texture : tm.getTextures()) { Files.write(gson.toJson(texture), new File(outDir, texture.getId() + ".json"), Charset.defaultCharset()); ++count; } } logger.info("Dumped {} textures to {}", count, outDir); } }
@Test @Ignore public void dumpMap() throws IOException { File base = StoreLocation.LOCATION, outDir = folder.newFolder(); try (Store store = new Store(base)) { store.load(); MapImageDumper dumper = new MapImageDumper(store); dumper.load(); for (int i = 0; i < Region.Z; ++i) { BufferedImage image = dumper.drawMap(i); File imageFile = new File(outDir, "img-" + i + ".png"); ImageIO.write(image, "png", imageFile); logger.info("Wrote image {}", imageFile); } } }
@Test public void extract() throws IOException { File base = StoreLocation.LOCATION, outFile = folder.newFolder(); try (Store store = new Store(base)) { store.load(); Storage storage = store.getStorage(); Index index = store.getIndex(IndexType.BINARY); Archive archive = index.findArchiveByName("title.jpg"); byte[] contents = archive.decompress(storage.loadArchive(archive)); Files.write(outFile.toPath(), contents); } logger.info("Dumped to {}", outFile); } }
@Test public void test() throws IOException { File dumpDir = folder.newFolder(); try (Store store = new Store(StoreLocation.LOCATION)) { store.load(); SpriteManager dumper = new SpriteManager( store ); dumper.load(); dumper.export(dumpDir); } logger.info("Dumped to {}", dumpDir); } }
@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); } }
@Test public void test() throws IOException { File dumpDir = folder.newFolder(), javaDir = folder.newFolder(); Store store = new Store(StoreLocation.LOCATION); store.load(); ItemManager dumper = new ItemManager( store ); dumper.load(); dumper.export(dumpDir); dumper.java(javaDir); logger.info("Dumped to {}, java {}", dumpDir, javaDir); }
@Test public void test() throws IOException { File dumpDir = folder.newFolder(), javaDir = folder.newFolder(); Store store = new Store(StoreLocation.LOCATION); store.load(); InterfaceManager dumper = new InterfaceManager( store ); dumper.load(); dumper.export(dumpDir); dumper.java(javaDir); logger.info("Dumped to {}, java {}", dumpDir, javaDir); }
@Test public void test() throws IOException { File dumpDir = folder.newFolder(), javaDir = folder.newFolder(); try (Store store = new Store(StoreLocation.LOCATION)) { store.load(); ObjectManager dumper = new ObjectManager( store ); dumper.load(); dumper.dump(dumpDir); dumper.java(javaDir); } logger.info("Dumped to {}, java {}", dumpDir, javaDir); }
@Test public void test() throws IOException { File dumpDir = folder.newFolder(), javaDir = folder.newFolder(); try (Store store = new Store(StoreLocation.LOCATION)) { store.load(); NpcManager dumper = new NpcManager( store ); dumper.load(); dumper.dump(dumpDir); dumper.java(javaDir); } logger.info("Dumped to {}, java {}", dumpDir, javaDir); }
store.load();
store.load();
@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); } }
@Test public void testOneFile() throws IOException { try (Store store = new Store(folder.getRoot())) { Index index = store.addIndex(0); Archive archive = index.addArchive(0); archive.setFileData(new FileData[1]); FileData fileData = archive.getFileData()[0] = new FileData(); fileData.setId(42); fileData.setNameHash(7); store.save(); try (Store store2 = new Store(folder.getRoot())) { store2.load(); Assert.assertEquals(store, store2); } } }
@Test public void testSave() throws Exception { File base = StoreLocation.LOCATION; try (Store store = new Store(base)) { store.load(); Storage storage = store.getStorage(); Index index = store.getIndex(IndexType.INTERFACES); Archive archive = index.getArchive(31); byte[] archiveData = storage.loadArchive(archive); ArchiveFiles files = archive.getFiles(archiveData); FSFile file = files.findFile(76); byte[] contents = file.getContents(); InterfaceDefinition def = new InterfaceLoader().load(0, contents); byte[] b = new InterfaceSaver().save(def); assertArrayEquals(contents, b); } }