diff options
author | Paul Gilbert | 2009-11-04 08:38:32 +0000 |
---|---|---|
committer | Paul Gilbert | 2009-11-04 08:38:32 +0000 |
commit | a6f1280fcc5f0811f799824dab9b29e46dbb989f (patch) | |
tree | 44d3781643a4d81d829c4a5d6cc34fb6c0ab70b6 /engines/m4/console.cpp | |
parent | f45a1a5a0b3cc3e343448659c60973a6a2e95a7f (diff) | |
download | scummvm-rg350-a6f1280fcc5f0811f799824dab9b29e46dbb989f.tar.gz scummvm-rg350-a6f1280fcc5f0811f799824dab9b29e46dbb989f.tar.bz2 scummvm-rg350-a6f1280fcc5f0811f799824dab9b29e46dbb989f.zip |
Added support for loading the game's object list
svn-id: r45651
Diffstat (limited to 'engines/m4/console.cpp')
-rw-r--r-- | engines/m4/console.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/engines/m4/console.cpp b/engines/m4/console.cpp index 1950371edd..1a59d72bb4 100644 --- a/engines/m4/console.cpp +++ b/engines/m4/console.cpp @@ -47,11 +47,26 @@ Console::Console(M4Engine *vm) : GUI::Debugger() { DCmd_Register("textview", WRAP_METHOD(Console, cmdShowTextview)); DCmd_Register("animview", WRAP_METHOD(Console, cmdShowAnimview)); DCmd_Register("anim", WRAP_METHOD(Console, cmdPlayAnimation)); + DCmd_Register("object", WRAP_METHOD(Console, cmdObject)); } Console::~Console() { } +static int strToInt(const char *s) { + if (!*s) + // No string at all + return 0; + else if (toupper(s[strlen(s) - 1]) != 'H') + // Standard decimal string + return atoi(s); + + // Hexadecimal string + uint tmp; + sscanf(s, "%xh", &tmp); + return (int)tmp; +} + bool Console::cmdLoadScene(int argc, const char **argv) { if (argc != 2) { DebugPrintf("Usage: %s <scene number>\n", argv[0]); @@ -284,4 +299,49 @@ bool Console::cmdPlayAnimation(int argc, const char **argv) { return true; } +bool Console::cmdObject(int argc, const char **argv) { + if (_vm->isM4()) { + DebugPrintf("Command not implemented for M4 games\n"); + } else if (argc == 1) { + DebugPrintf("Usage: object ['list' | '#objnum']\n"); + } else if (!strcmp(argv[1], "list")) { + // List of objects + for (uint objStart = 0; objStart < _vm->_globals->getObjectsSize(); objStart += 5) { + DebugPrintf("%2d - ", objStart); + for (uint objId = objStart; objId < MIN(_vm->_globals->getObjectsSize(), objStart + 5); ++objId) { + if (objId != objStart) DebugPrintf(", "); + uint16 descId = _vm->_globals->getObject(objId)->descId - 1; + DebugPrintf("%s", _vm->_globals->getVocab(descId)); + } + + DebugPrintf("\n"); + } + + DebugPrintf("\n"); + } else { + // Print the details of a specific object + int id = strToInt(argv[1]); + + if ((id < 0) || (id >= (int)_vm->_globals->getObjectsSize())) + DebugPrintf("Invalid object specified\n"); + else { + const MadsObject *obj = _vm->_globals->getObject(id); + + DebugPrintf("Object #%d (%s) room=%d vocabs=%d", id, _vm->_globals->getVocab(obj->descId - 1), + obj->roomNumber, obj->vocabCount); + if (obj->vocabCount > 0) { + DebugPrintf(" - "); + for (int i = 0; i < obj->vocabCount; ++i) { + if (i != 0) DebugPrintf(", "); + DebugPrintf("%s (%d)/%d", _vm->_globals->getVocab(obj->vocabList[i].vocabId - 1), + obj->vocabList[i].vocabId, obj->vocabList[i].unk); + } + } + DebugPrintf("\n"); + } + } + + return true; +} + } // End of namespace M4 |