bool Console::Cmd_ListLocations(int argc, const char **argv) { ArchiveLoader *archiveLoader = new ArchiveLoader(); // Temporarily replace the global archive loader with our instance ArchiveLoader *gameArchiveLoader = StarkArchiveLoader; StarkArchiveLoader = archiveLoader; archiveLoader->load("x.xarc"); Resources::Root *root = archiveLoader->useRoot<Resources::Root>("x.xarc"); // Find all the levels Common::Array<Resources::Level *> levels = root->listChildren<Resources::Level>(); // Loop over the levels for (uint i = 0; i < levels.size(); i++) { Resources::Level *level = levels[i]; Common::String levelArchive = archiveLoader->buildArchiveName(level); debugPrintf("%s - %s\n", levelArchive.c_str(), level->getName().c_str()); // Load the detailed level archive archiveLoader->load(levelArchive); level = archiveLoader->useRoot<Resources::Level>(levelArchive); Common::Array<Resources::Location *> locations = level->listChildren<Resources::Location>(); // Loop over the locations for (uint j = 0; j < locations.size(); j++) { Resources::Location *location = locations[j]; Common::String roomArchive = archiveLoader->buildArchiveName(level, location); debugPrintf("%s - %s\n", roomArchive.c_str(), location->getName().c_str()); } archiveLoader->returnRoot(levelArchive); archiveLoader->unloadUnused(); } // Restore the global archive loader StarkArchiveLoader = gameArchiveLoader; delete archiveLoader; return true; }
bool Console::Cmd_TestDecompiler(int argc, const char **argv) { _testDecompilerTotalScripts = 0; _testDecompilerOKScripts = 0; ArchiveLoader *archiveLoader = new ArchiveLoader(); // Temporarily replace the global archive loader with our instance ArchiveLoader *gameArchiveLoader = StarkArchiveLoader; StarkArchiveLoader = archiveLoader; archiveLoader->load("x.xarc"); Resources::Root *root = archiveLoader->useRoot<Resources::Root>("x.xarc"); // Find all the levels Common::Array<Resources::Level *> levels = root->listChildren<Resources::Level>(); // Loop over the levels for (uint i = 0; i < levels.size(); i++) { Resources::Level *level = levels[i]; Common::String levelArchive = archiveLoader->buildArchiveName(level); debug("%s - %s", levelArchive.c_str(), level->getName().c_str()); // Load the detailed level archive archiveLoader->load(levelArchive); level = archiveLoader->useRoot<Resources::Level>(levelArchive); // Decompile all the scripts in the level archive decompileScriptChildren(level); Common::Array<Resources::Location *> locations = level->listChildren<Resources::Location>(); // Loop over the locations for (uint j = 0; j < locations.size(); j++) { Resources::Location *location = locations[j]; Common::String locationArchive = archiveLoader->buildArchiveName(level, location); debug("%s - %s", locationArchive.c_str(), location->getName().c_str()); // Load the detailed location archive archiveLoader->load(locationArchive); location = archiveLoader->useRoot<Resources::Location>(locationArchive); // Decompile all the scripts in the location archive decompileScriptChildren(location); archiveLoader->returnRoot(locationArchive); archiveLoader->unloadUnused(); } archiveLoader->returnRoot(levelArchive); archiveLoader->unloadUnused(); } // Restore the global archive loader StarkArchiveLoader = gameArchiveLoader; delete archiveLoader; debugPrintf("Successfully decompiled %d scripts out of %d\n", _testDecompilerOKScripts, _testDecompilerTotalScripts); return true; }