aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2013-09-14 12:34:03 +0300
committerFilippos Karapetis2013-09-14 12:39:58 +0300
commitcdeb55777d4279cfb332a3a68ac91cafdff7f48b (patch)
tree93becb559dcea285984bede491a33e8375c1edd8
parent7625ae671859ae53c90a343a21e20307d0c87c89 (diff)
downloadscummvm-rg350-cdeb55777d4279cfb332a3a68ac91cafdff7f48b.tar.gz
scummvm-rg350-cdeb55777d4279cfb332a3a68ac91cafdff7f48b.tar.bz2
scummvm-rg350-cdeb55777d4279cfb332a3a68ac91cafdff7f48b.zip
NEVERHOOD: Add console commands to handle resources
-rw-r--r--engines/neverhood/console.cpp49
-rw-r--r--engines/neverhood/console.h3
2 files changed, 52 insertions, 0 deletions
diff --git a/engines/neverhood/console.cpp b/engines/neverhood/console.cpp
index 733d7dd8a4..fc85f88332 100644
--- a/engines/neverhood/console.cpp
+++ b/engines/neverhood/console.cpp
@@ -32,6 +32,8 @@ namespace Neverhood {
Console::Console(NeverhoodEngine *vm) : GUI::Debugger(), _vm(vm) {
DCmd_Register("cheat", WRAP_METHOD(Console, Cmd_Cheat));
+ DCmd_Register("checkresource", WRAP_METHOD(Console, Cmd_CheckResource));
+ DCmd_Register("dumpresource", WRAP_METHOD(Console, Cmd_DumpResource));
DCmd_Register("dumpvars", WRAP_METHOD(Console, Cmd_Dumpvars));
DCmd_Register("room", WRAP_METHOD(Console, Cmd_Room));
DCmd_Register("surfaces", WRAP_METHOD(Console, Cmd_Surfaces));
@@ -188,4 +190,51 @@ bool Console::Cmd_PlaySound(int argc, const char **argv) {
return true;
}
+bool Console::Cmd_CheckResource(int argc, const char **argv) {
+ const char *resourceNames[] = { "unknown", "unknown", "bitmap", "palette", "animation", "data", "text", "sound", "music", "unknown", "video" };
+
+ if (argc < 2) {
+ DebugPrintf("Gets information about a resource\n");
+ DebugPrintf("Usage: %s <resource hash>\n", argv[0]);
+ } else {
+ uint32 resourceHash = strtol(argv[1], NULL, 0);
+ ResourceHandle handle;
+
+ _vm->_res->queryResource(resourceHash, handle);
+ if (!handle.isValid()) {
+ DebugPrintf("Invalid resource hash\n");
+ } else {
+ DebugPrintf("Resource type: %d (%s). Size: %d bytes\n", handle.type(), resourceNames[handle.type()], handle.size());
+ }
+ }
+
+ return true;
+}
+
+bool Console::Cmd_DumpResource(int argc, const char **argv) {
+ if (argc < 3) {
+ DebugPrintf("Dumps a resource to disk\n");
+ DebugPrintf("Usage: %s <resource hash> <output file>\n", argv[0]);
+ } else {
+ uint32 resourceHash = strtol(argv[1], NULL, 0);
+ const char *outFileName = argv[2];
+ ResourceHandle handle;
+
+ _vm->_res->queryResource(resourceHash, handle);
+ if (!handle.isValid()) {
+ DebugPrintf("Invalid resource hash\n");
+ } else {
+ _vm->_res->loadResource(handle);
+ Common::DumpFile outFile;
+ outFile.open(outFileName);
+ outFile.write(handle.data(), handle.size());
+ outFile.finalize();
+ outFile.close();
+ _vm->_res->unloadResource(handle);
+ }
+ }
+
+ return true;
+}
+
} // End of namespace Neverhood
diff --git a/engines/neverhood/console.h b/engines/neverhood/console.h
index 62d65bd693..77dde231dc 100644
--- a/engines/neverhood/console.h
+++ b/engines/neverhood/console.h
@@ -42,6 +42,9 @@ private:
bool Cmd_Cheat(int argc, const char **argv);
bool Cmd_Dumpvars(int argc, const char **argv);
bool Cmd_PlaySound(int argc, const char **argv);
+ bool Cmd_CheckResource(int argc, const char **argv);
+ bool Cmd_DumpResource(int argc, const char **argv);
+
};
} // End of namespace Neverhood