aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2009-05-29 08:59:13 +0000
committerFilippos Karapetis2009-05-29 08:59:13 +0000
commitc95e5fceeeefb1e52c6456224626680930ecbd84 (patch)
tree09e1a9ef01ef7285f2afafdd19884c53ee9d9f03
parent0ad3b7bb7d47492d85206095ec5ea27b2905628a (diff)
downloadscummvm-rg350-c95e5fceeeefb1e52c6456224626680930ecbd84.tar.gz
scummvm-rg350-c95e5fceeeefb1e52c6456224626680930ecbd84.tar.bz2
scummvm-rg350-c95e5fceeeefb1e52c6456224626680930ecbd84.zip
Moved the "size" console debugger command to console.cpp and silenced a warning
svn-id: r40978
-rw-r--r--engines/sci/console.cpp30
-rw-r--r--engines/sci/console.h1
-rw-r--r--engines/sci/engine/game.cpp2
-rw-r--r--engines/sci/engine/sciconsole.cpp17
4 files changed, 32 insertions, 18 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index 7a86236531..b1fd831187 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -89,6 +89,7 @@ Console::Console(SciEngine *vm) : GUI::Debugger() {
DCmd_Register("hexdump", WRAP_METHOD(Console, cmdHexDump));
DCmd_Register("dissect_script", WRAP_METHOD(Console, cmdDissectScript));
DCmd_Register("room", WRAP_METHOD(Console, cmdRoomNumber));
+ DCmd_Register("size", WRAP_METHOD(Console, cmdResourceSize));
}
Console::~Console() {
@@ -330,4 +331,33 @@ bool Console::cmdRoomNumber(int argc, const char **argv) {
return true;
}
+bool Console::cmdResourceSize(int argc, const char **argv) {
+ if (argc != 2) {
+ DebugPrintf("Shows the size of a resource\n");
+ DebugPrintf("Usage: %s <resource number>\n", argv[0]);
+ return true;
+ }
+
+ int resNum = atoi(argv[2]);
+ if (resNum == 0) {
+ DebugPrintf("The resource number specified is not a number");
+ return true;
+ }
+
+ ResourceType res = parseResourceType(argv[1]);
+
+ if (res == kResourceTypeInvalid)
+ DebugPrintf("Resource type '%s' is not valid\n", argv[1]);
+ else {
+ Resource *resource = _vm->getResMgr()->findResource(res, resNum, 0);
+ if (resource) {
+ DebugPrintf("Resource size: %d\n", resource->size);
+ } else {
+ DebugPrintf("Resource %s.%03d not found\n", argv[1], resNum);
+ }
+ }
+
+ return true;
+}
+
} // End of namespace Sci
diff --git a/engines/sci/console.h b/engines/sci/console.h
index c54147d942..2b706df536 100644
--- a/engines/sci/console.h
+++ b/engines/sci/console.h
@@ -54,6 +54,7 @@ private:
bool cmdHexDump(int argc, const char **argv);
bool cmdDissectScript(int argc, const char **argv);
bool cmdRoomNumber(int argc, const char **argv);
+ bool cmdResourceSize(int argc, const char **argv);
private:
SciEngine *_vm;
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp
index 41e262a480..b8af8bdc34 100644
--- a/engines/sci/engine/game.cpp
+++ b/engines/sci/engine/game.cpp
@@ -323,7 +323,7 @@ static int create_class_table_sci0(EngineState *s) {
// Map the class ID to the script the corresponding class is contained in
// The script number is found in vocab.996, if it exists
- if (!vocab996 || classnr >= vocab996->size >> 2)
+ if (!vocab996 || (uint32)classnr >= vocab996->size >> 2)
sugg_script = -1;
else
sugg_script = (int16)READ_LE_UINT16(vocab996->data + 2 + (classnr << 2));
diff --git a/engines/sci/engine/sciconsole.cpp b/engines/sci/engine/sciconsole.cpp
index 7332a22193..9177a4b11f 100644
--- a/engines/sci/engine/sciconsole.cpp
+++ b/engines/sci/engine/sciconsole.cpp
@@ -40,7 +40,6 @@ static int c_list(EngineState *s, const Common::Array<cmd_param_t> &cmdParams);
static int c_man(EngineState *s, const Common::Array<cmd_param_t> &cmdParams); // 'manual page'
static int c_set(EngineState *s, const Common::Array<cmd_param_t> &cmdParams); // sets an int variable
static int c_print(EngineState *s, const Common::Array<cmd_param_t> &cmdParams); // prints a variable
-static int c_size(EngineState *s, const Common::Array<cmd_param_t> &cmdParams); // displays the size of a resource
//static int c_objinfo(EngineState *s, const Common::Array<cmd_param_t> &cmdParams); // shows some info about one class
//static int c_objmethods(EngineState *s, const Common::Array<cmd_param_t> &cmdParams); // Disassembles all methods of a class
static int c_hexgrep(EngineState *s, const Common::Array<cmd_param_t> &cmdParams); // Searches a string in one resource or resource class
@@ -166,7 +165,6 @@ void con_init() {
con_hook_command(&c_man, "man", "s", "Gives a short description of something");
con_hook_command(&c_print, "print", "s", "Prints an int variable");
con_hook_command(&c_set, "set", "si", "Sets an int variable");
- con_hook_command(&c_size, "size", "si", "Displays the size of a resource");
con_hook_command(&c_hexgrep, "hexgrep", "shh*", "Searches some resources for a\n"
" particular sequence of bytes, re-\n presented as hexadecimal numbers.\n\n"
"EXAMPLES:\n hexgrep script e8 03 c8 00\n hexgrep pic.042 fe");
@@ -829,21 +827,6 @@ static int c_print(EngineState *s, const Common::Array<cmd_param_t> &cmdParams)
return 0;
}
-static int c_size(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
- ResourceType res = parseResourceType(cmdParams[0].str);
- if (res == kResourceTypeInvalid)
- sciprintf("Resource type '%s' is not valid\n", cmdParams[0].str);
- else {
- Resource *resource = s->resmgr->findResource(res, cmdParams[1].val, 0);
- if (resource) {
- sciprintf("Size: %d\n", resource->size);
- } else
- sciprintf("Resource %s.%03d not found\n", cmdParams[0].str, cmdParams[1].val);
- }
-
- return 0;
-}
-
static int c_hexgrep(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
int i, seeklen, resnr, resmax;
unsigned char *seekstr = NULL;