[Scummvm-cvs-logs] SF.net SVN: scummvm:[47366] tools/trunk/engines/mohawk/extract_mohawk.cpp
tdhs at users.sourceforge.net
tdhs at users.sourceforge.net
Tue Jan 19 01:41:37 CET 2010
Revision: 47366
http://scummvm.svn.sourceforge.net/scummvm/?rev=47366&view=rev
Author: tdhs
Date: 2010-01-19 00:41:37 +0000 (Tue, 19 Jan 2010)
Log Message:
-----------
Minor updates to extract_mohawk :
Moved old / new Archive format selection to command line option, rather than executable name suffix.
Removed leftover debug statement.
Corrections for coding standard variable form.
Modified Paths:
--------------
tools/trunk/engines/mohawk/extract_mohawk.cpp
Modified: tools/trunk/engines/mohawk/extract_mohawk.cpp
===================================================================
--- tools/trunk/engines/mohawk/extract_mohawk.cpp 2010-01-18 23:46:28 UTC (rev 47365)
+++ tools/trunk/engines/mohawk/extract_mohawk.cpp 2010-01-19 00:41:37 UTC (rev 47366)
@@ -105,7 +105,7 @@
fclose(outputFile);
}
-void outputMohawkStream(MohawkOutputStream output, bool do_conversion) {
+void outputMohawkStream(MohawkOutputStream output, bool doConversion) {
// File output naming format preserves all archive information...
char *strBuf = (char *)malloc(256);
sprintf(strBuf, "%04d_%s_%d", output.index, tag2str(output.tag), output.id);
@@ -113,7 +113,7 @@
sprintf(strBuf+strlen(strBuf), "_%s", output.name.c_str());
output.name = strBuf;
- if(do_conversion) {
+ if(doConversion) {
// Intercept the sound tags
if (output.tag == ID_TWAV || output.tag == ID_MSND || output.tag == ID_SND) {
convertSoundResource(output);
@@ -143,40 +143,45 @@
printf("Usage: %s [options] <mohawk archive> [tag id]\n", appName);
printf("Options : --raw : Dump Resources as raw binary dump (default)");
printf(" --convert : Dump Resources as converted files");
+ printf(" --new : Load Mohawk Archive assuming new file format (default)");
+ printf(" --old : Load Mohawk Archive assuming old file format");
}
int main(int argc, char *argv[]) {
- bool do_conversion = false;
- int archive_arg;
+ bool doConversion = false;
+ bool oldMohawkFormat = false;
+ int archiveArg;
// Parse parameters
- for (archive_arg = 1; archive_arg < argc; archive_arg++) {
- Common::String current = Common::String(argv[archive_arg]);
+ for (archiveArg = 1; archiveArg < argc; archiveArg++) {
+ Common::String current = Common::String(argv[archiveArg]);
if(!current.hasPrefix("--"))
break;
// Decode options
if(current.equals("--raw"))
- do_conversion = false;
+ doConversion = false;
else if(current.equals("--convert"))
- do_conversion = true;
+ doConversion = true;
+ else if(current.equals("--new"))
+ oldMohawkFormat = false;
+ else if(current.equals("--old"))
+ oldMohawkFormat = true;
else {
- printf("Unknown argument : \"%s\"\n", argv[archive_arg]);
+ printf("Unknown argument : \"%s\"\n", argv[archiveArg]);
printUsage(argv[0]);
return 1;
}
}
- printf("Debug : argc : %d archive_arg : %d\n", argc, archive_arg);
-
- if(! (archive_arg == argc - 1) || // No tag and id
- (archive_arg == argc - 2 - 1)) { // tag and id
+ if(! (archiveArg == argc - 1) || // No tag and id
+ (archiveArg == argc - 2 - 1)) { // tag and id
printUsage(argv[0]);
return 1;
}
- FILE *file = fopen(argv[archive_arg], "rb");
+ FILE *file = fopen(argv[archiveArg], "rb");
if (!file) {
printf ("Could not open \'%s\'\n", argv[1]);
return 1;
@@ -184,7 +189,7 @@
// Open the file as a Mohawk archive
MohawkFile *mohawkFile;
- if(Common::String(argv[0]).hasSuffix("old"))
+ if(oldMohawkFormat)
mohawkFile = new OldMohawkFile();
else
mohawkFile = new MohawkFile();
@@ -193,14 +198,14 @@
// Allocate a buffer for the output
outputBuffer = (byte *)malloc(MAX_BUF_SIZE);
- if (argc == archive_arg - 2 - 1) {
- uint32 tag = READ_BE_UINT32(argv[archive_arg+1]);
- uint16 id = (uint16)atoi(argv[archive_arg+2]);
+ if (argc == archiveArg - 2 - 1) {
+ uint32 tag = READ_BE_UINT32(argv[archiveArg+1]);
+ uint16 id = (uint16)atoi(argv[archiveArg+2]);
MohawkOutputStream output = mohawkFile->getRawData(tag, id);
if (output.stream) {
- outputMohawkStream(output, do_conversion);
+ outputMohawkStream(output, doConversion);
delete output.stream;
} else {
printf ("Could not find specified data!\n");
@@ -208,7 +213,7 @@
} else {
MohawkOutputStream output = mohawkFile->getNextFile();
while (output.stream) {
- outputMohawkStream(output, do_conversion);
+ outputMohawkStream(output, doConversion);
delete output.stream;
output = mohawkFile->getNextFile();
}
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