diff options
author | Walter van Niftrik | 2016-04-01 18:13:10 +0200 |
---|---|---|
committer | Walter van Niftrik | 2016-06-06 20:35:49 +0200 |
commit | 1d314b20841d78ebbce2652ec874fb131cf9cf36 (patch) | |
tree | 379430d83ae8d0a93ac7281c6342f39ef3e14530 | |
parent | 23d4e61260f96cf3aa5104649a3a4f7b72c7df78 (diff) | |
download | scummvm-rg350-1d314b20841d78ebbce2652ec874fb131cf9cf36.tar.gz scummvm-rg350-1d314b20841d78ebbce2652ec874fb131cf9cf36.tar.bz2 scummvm-rg350-1d314b20841d78ebbce2652ec874fb131cf9cf36.zip |
ADL: Allow synonyms in give_item debug command
-rw-r--r-- | engines/adl/console.cpp | 33 | ||||
-rw-r--r-- | engines/adl/console.h | 1 |
2 files changed, 25 insertions, 9 deletions
diff --git a/engines/adl/console.cpp b/engines/adl/console.cpp index 1a670b7a6a..af16330ed0 100644 --- a/engines/adl/console.cpp +++ b/engines/adl/console.cpp @@ -49,6 +49,22 @@ Common::String Console::toAscii(const Common::String &str) { return ascii; } +Common::String Console::toAppleWord(const Common::String &str) { + Common::String apple(str); + + if (apple.size() > IDI_WORD_SIZE) + apple.erase(IDI_WORD_SIZE); + apple.toUppercase(); + + for (uint i = 0; i < apple.size(); ++i) + apple.setChar(APPLECHAR(apple[i]), i); + + while (apple.size() < IDI_WORD_SIZE) + apple += APPLECHAR(' '); + + return apple; +} + bool Console::Cmd_Verbs(int argc, const char **argv) { if (argc != 1) { debugPrintf("Usage: %s\n", argv[0]); @@ -193,18 +209,17 @@ bool Console::Cmd_GiveItem(int argc, const char **argv) { if (*end != 0) { Common::Array<Item *> matches; - Common::String searchName(argv[1]); - searchName.toUppercase(); - while (searchName.size() < IDI_WORD_SIZE) - searchName += ' '; + Common::String name = toAppleWord(argv[1]); - for (item = _engine->_state.items.begin(); item != _engine->_state.items.end(); ++item) { - Common::String itemName; + if (!_engine->_nouns.contains(name)) { + debugPrintf("Item '%s' not found\n", argv[1]); + return true; + } - if (item->noun > 0) - itemName = _engine->_priNouns[item->noun - 1]; + byte noun = _engine->_nouns[name]; - if (itemName == searchName) + for (item = _engine->_state.items.begin(); item != _engine->_state.items.end(); ++item) { + if (item->noun == noun) matches.push_back(&*item); } diff --git a/engines/adl/console.h b/engines/adl/console.h index a1b692d6fa..ece9cd0822 100644 --- a/engines/adl/console.h +++ b/engines/adl/console.h @@ -41,6 +41,7 @@ public: Console(AdlEngine *engine); static Common::String toAscii(const Common::String &str); + static Common::String toAppleWord(const Common::String &str); private: bool Cmd_Nouns(int argc, const char **argv); |