aboutsummaryrefslogtreecommitdiff
path: root/engines/adl
diff options
context:
space:
mode:
authorWalter van Niftrik2016-04-01 16:47:07 +0200
committerWalter van Niftrik2016-06-06 20:35:49 +0200
commitfde2db9d4c09d4318d9dbc409044838d456693a6 (patch)
treec9ade155ae7f1b3c4692cda03d06caaeadfe0e4d /engines/adl
parent9eb7af0f671d6b172c838666f423a3be5eaeae09 (diff)
downloadscummvm-rg350-fde2db9d4c09d4318d9dbc409044838d456693a6.tar.gz
scummvm-rg350-fde2db9d4c09d4318d9dbc409044838d456693a6.tar.bz2
scummvm-rg350-fde2db9d4c09d4318d9dbc409044838d456693a6.zip
ADL: Add items and give_item debug commands
Diffstat (limited to 'engines/adl')
-rw-r--r--engines/adl/console.cpp99
-rw-r--r--engines/adl/console.h4
2 files changed, 103 insertions, 0 deletions
diff --git a/engines/adl/console.cpp b/engines/adl/console.cpp
index e1625979c5..377909cf3f 100644
--- a/engines/adl/console.cpp
+++ b/engines/adl/console.cpp
@@ -36,6 +36,8 @@ Console::Console(AdlEngine *engine) : GUI::Debugger() {
registerCmd("dump_scripts", WRAP_METHOD(Console, Cmd_DumpScripts));
registerCmd("valid_cmds", WRAP_METHOD(Console, Cmd_ValidCommands));
registerCmd("room", WRAP_METHOD(Console, Cmd_Room));
+ registerCmd("items", WRAP_METHOD(Console, Cmd_Items));
+ registerCmd("give_item", WRAP_METHOD(Console, Cmd_GiveItem));
}
Common::String Console::toAscii(const Common::String &str) {
@@ -163,6 +165,103 @@ bool Console::Cmd_Room(int argc, const char **argv) {
return true;
}
+bool Console::Cmd_Items(int argc, const char **argv) {
+ if (argc != 1) {
+ debugPrintf("Usage: %s\n", argv[0]);
+ return true;
+ }
+
+ Common::List<Item>::const_iterator item;
+
+ for (item = _engine->_state.items.begin(); item != _engine->_state.items.end(); ++item)
+ printItem(*item);
+
+ return true;
+}
+
+bool Console::Cmd_GiveItem(int argc, const char **argv) {
+ if (argc != 2) {
+ debugPrintf("Usage: %s <ID | name>\n", argv[0]);
+ return true;
+ }
+
+ Common::List<Item>::iterator item;
+
+ char *end;
+ int id = strtoul(argv[1], &end, 0);
+
+ if (*end != 0) {
+ Common::Array<Item *> matches;
+
+ Common::String searchName(argv[1]);
+ searchName.toUppercase();
+ while (searchName.size() < IDI_WORD_SIZE)
+ searchName += ' ';
+
+ for (item = _engine->_state.items.begin(); item != _engine->_state.items.end(); ++item) {
+ Common::String itemName;
+
+ if (item->noun > 0)
+ itemName = _engine->_priNouns[item->noun - 1];
+
+ if (itemName == searchName)
+ matches.push_back(&*item);
+ }
+
+ if (matches.size() == 0) {
+ debugPrintf("Item '%s' not found\n", argv[1]);
+ return true;
+ }
+
+ if (matches.size() > 1) {
+ debugPrintf("Multiple matches found, please use item ID:\n");
+ for (uint i = 0; i < matches.size(); ++i)
+ printItem(*matches[i]);
+ return true;
+ }
+
+ matches[0]->room = IDI_ANY;
+ debugPrintf("OK\n");
+ return true;
+ }
+
+ for (item = _engine->_state.items.begin(); item != _engine->_state.items.end(); ++item)
+ if (item->id == id) {
+ item->room = IDI_ANY;
+ debugPrintf("OK\n");
+ return true;
+ }
+
+ debugPrintf("Item %i not found\n", id);
+ return true;
+}
+
+void Console::printItem(const Item &item) {
+ Common::String name, desc, state;
+
+ if (item.noun > 0)
+ name = _engine->_priNouns[item.noun - 1];
+
+ if (item.description > 0) {
+ desc = toAscii(_engine->_messages[item.description - 1]);
+ desc.deleteLastChar();
+ }
+
+ switch (item.state) {
+ case IDI_ITEM_NOT_MOVED:
+ state = "PLACED";
+ break;
+ case IDI_ITEM_DROPPED:
+ state = "DROPPED";
+ break;
+ case IDI_ITEM_DOESNT_MOVE:
+ state = "FIXED";
+ break;
+ }
+
+ debugPrintf("%3d %s %-30s %-10s %-8s (%3d, %3d)\n", item.id, name.c_str(), desc.c_str(), _engine->itemRoomStr(item.room).c_str(), state.c_str(), item.position.x, item.position.y);
+}
+
void Console::printWordMap(const WordMap &wordMap) {
Common::StringArray words;
WordMap::const_iterator verb;
diff --git a/engines/adl/console.h b/engines/adl/console.h
index 8af23b9694..a1b692d6fa 100644
--- a/engines/adl/console.h
+++ b/engines/adl/console.h
@@ -34,6 +34,7 @@ class String;
namespace Adl {
class AdlEngine;
+struct Item;
class Console : public GUI::Debugger {
public:
@@ -47,7 +48,10 @@ private:
bool Cmd_DumpScripts(int argc, const char **argv);
bool Cmd_ValidCommands(int argc, const char **argv);
bool Cmd_Room(int argc, const char **argv);
+ bool Cmd_Items(int argc, const char **argv);
+ bool Cmd_GiveItem(int argc, const char **argv);
+ void printItem(const Item &item);
void printWordMap(const Common::HashMap<Common::String, uint> &wordMap);
AdlEngine *_engine;