[Scummvm-cvs-logs] SF.net SVN: scummvm:[47623] scummvm/trunk/engines/sci
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Thu Jan 28 02:45:21 CET 2010
Revision: 47623
http://scummvm.svn.sourceforge.net/scummvm/?rev=47623&view=rev
Author: thebluegr
Date: 2010-01-28 01:45:20 +0000 (Thu, 28 Jan 2010)
Log Message:
-----------
Introduced a new console command, diskdump, which is able to dump files from resource files to disk
Modified Paths:
--------------
scummvm/trunk/engines/sci/console.cpp
scummvm/trunk/engines/sci/console.h
Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp 2010-01-28 00:28:08 UTC (rev 47622)
+++ scummvm/trunk/engines/sci/console.cpp 2010-01-28 01:45:20 UTC (rev 47623)
@@ -91,6 +91,7 @@
DCmd_Register("parse", WRAP_METHOD(Console, cmdParse));
DCmd_Register("set_parse_nodes", WRAP_METHOD(Console, cmdSetParseNodes));
// Resources
+ DCmd_Register("diskdump", WRAP_METHOD(Console, cmdDiskDump));
DCmd_Register("hexdump", WRAP_METHOD(Console, cmdHexDump));
DCmd_Register("resource_id", WRAP_METHOD(Console, cmdResourceId));
DCmd_Register("resource_size", WRAP_METHOD(Console, cmdResourceSize));
@@ -298,6 +299,7 @@
DebugPrintf(" set_parse_nodes - Sets the contents of all parse nodes\n");
DebugPrintf("\n");
DebugPrintf("Resources:\n");
+ DebugPrintf(" diskdump - Dumps the specified resource to disk as a patch file\n");
DebugPrintf(" hexdump - Dumps the specified resource to standard output\n");
DebugPrintf(" resource_id - Identifies a resource number by splitting it up in resource type and resource number\n");
DebugPrintf(" resource_size - Shows the size of a resource\n");
@@ -563,6 +565,41 @@
return true;
}
+bool Console::cmdDiskDump(int argc, const char **argv) {
+ if (argc != 3) {
+ DebugPrintf("Dumps the specified resource to disk as a patch file\n");
+ DebugPrintf("Usage: %s <resource type> <resource number>\n", argv[0]);
+ cmdResourceTypes(argc, argv);
+ return true;
+ }
+
+ int resNum = atoi(argv[2]);
+ ResourceType res = parseResourceType(argv[1]);
+
+ if (res == kResourceTypeInvalid)
+ DebugPrintf("Resource type '%s' is not valid\n", argv[1]);
+ else {
+ Resource *resource = _vm->getResourceManager()->findResource(ResourceId(res, resNum), 0);
+ if (resource) {
+ char outFileName[50];
+ sprintf(outFileName, "%s.%03d", getResourceTypeName(res), resNum);
+ Common::DumpFile *outFile = new Common::DumpFile();
+ outFile->open(outFileName);
+ outFile->writeByte(res);
+ outFile->writeByte(0);
+ outFile->write(resource->data, resource->size);
+ outFile->finalize();
+ outFile->close();
+ delete outFile;
+ DebugPrintf("Resource %s.%03d has been dumped to disk\n", argv[1], resNum);
+ } else {
+ DebugPrintf("Resource %s.%03d not found\n", argv[1], resNum);
+ }
+ }
+
+ return true;
+}
+
bool Console::cmdHexDump(int argc, const char **argv) {
if (argc != 3) {
DebugPrintf("Dumps the specified resource to standard output\n");
@@ -808,6 +845,12 @@
// TODO: enable custom descriptions? force filename into a specific format?
if (gamestate_save(_vm->_gamestate, out, "debugging", version)) {
DebugPrintf("Saving the game state to '%s' failed\n", argv[1]);
+ } else {
+ out->finalize();
+ if (out->err()) {
+ warning("Writing the savegame failed.");
+ }
+ delete out;
}
return true;
Modified: scummvm/trunk/engines/sci/console.h
===================================================================
--- scummvm/trunk/engines/sci/console.h 2010-01-28 00:28:08 UTC (rev 47622)
+++ scummvm/trunk/engines/sci/console.h 2010-01-28 01:45:20 UTC (rev 47623)
@@ -66,6 +66,7 @@
bool cmdParse(int argc, const char **argv);
bool cmdSetParseNodes(int argc, const char **argv);
// Resources
+ bool cmdDiskDump(int argc, const char **argv);
bool cmdHexDump(int argc, const char **argv);
bool cmdResourceId(int argc, const char **argv);
bool cmdResourceSize(int argc, const char **argv);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list