aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/adl/adl.cpp22
-rw-r--r--engines/adl/adl.h2
-rw-r--r--engines/adl/console.cpp24
-rw-r--r--engines/adl/console.h1
4 files changed, 49 insertions, 0 deletions
diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp
index 0c27f8b76f..1b6bf6a344 100644
--- a/engines/adl/adl.cpp
+++ b/engines/adl/adl.cpp
@@ -292,6 +292,28 @@ void AdlEngine::checkInput(byte verb, byte noun) {
printMessage(_messageIds.dontUnderstand);
}
+bool AdlEngine::isInputValid(byte verb, byte noun, bool &is_any) {
+ if (isInputValid(_roomData.commands, verb, noun, is_any))
+ return true;
+ return isInputValid(_roomCommands, verb, noun, is_any);
+}
+
+bool AdlEngine::isInputValid(const Commands &commands, byte verb, byte noun, bool &is_any) {
+ Commands::const_iterator cmd;
+
+ is_any = false;
+ for (cmd = commands.begin(); cmd != commands.end(); ++cmd) {
+ ScriptEnv env(*cmd, _state.room, verb, noun);
+ if (matchCommand(env)) {
+ if (cmd->verb == IDI_ANY || cmd->noun == IDI_ANY)
+ is_any = true;
+ return true;
+ }
+ }
+
+ return false;
+}
+
typedef Common::Functor1Mem<ScriptEnv &, int, AdlEngine> OpcodeV1;
#define SetOpcodeTable(x) table = &x;
#define Opcode(x) table->push_back(new OpcodeV1(this, &AdlEngine::x))
diff --git a/engines/adl/adl.h b/engines/adl/adl.h
index ac5e22c974..18b57ed32a 100644
--- a/engines/adl/adl.h
+++ b/engines/adl/adl.h
@@ -234,6 +234,8 @@ protected:
void loadWords(Common::ReadStream &stream, WordMap &map, Common::StringArray &pri) const;
void readCommands(Common::ReadStream &stream, Commands &commands);
void checkInput(byte verb, byte noun);
+ virtual bool isInputValid(byte verb, byte noun, bool &is_any);
+ virtual bool isInputValid(const Commands &commands, byte verb, byte noun, bool &is_any);
virtual void setupOpcodeTables();
virtual bool matchesCurrentPic(byte pic) const;
diff --git a/engines/adl/console.cpp b/engines/adl/console.cpp
index 185fb425d6..003f6893fe 100644
--- a/engines/adl/console.cpp
+++ b/engines/adl/console.cpp
@@ -33,6 +33,7 @@ Console::Console(AdlEngine *engine) : GUI::Debugger() {
registerCmd("nouns", WRAP_METHOD(Console, Cmd_Nouns));
registerCmd("verbs", WRAP_METHOD(Console, Cmd_Verbs));
registerCmd("dump_scripts", WRAP_METHOD(Console, Cmd_DumpScripts));
+ registerCmd("valid_cmds", WRAP_METHOD(Console, Cmd_ValidCommands));
}
Common::String Console::toAscii(const Common::String &str) {
@@ -66,6 +67,29 @@ bool Console::Cmd_Nouns(int argc, const char **argv) {
return true;
}
+bool Console::Cmd_ValidCommands(int argc, const char **argv) {
+ if (argc != 1) {
+ debugPrintf("Usage: %s\n", argv[0]);
+ return true;
+ }
+
+ WordMap::const_iterator verb, noun;
+ bool is_any;
+
+ for (verb = _engine->_verbs.begin(); verb != _engine->_verbs.end(); ++verb) {
+ for (noun = _engine->_nouns.begin(); noun != _engine->_nouns.end(); ++noun) {
+ if (_engine->isInputValid(verb->_value, noun->_value, is_any) && !is_any)
+ debugPrintf("%s %s\n", toAscii(verb->_key).c_str(), toAscii(noun->_key).c_str());
+ }
+ if (_engine->isInputValid(verb->_value, IDI_ANY, is_any))
+ debugPrintf("%s *\n", toAscii(verb->_key).c_str());
+ }
+ if (_engine->isInputValid(IDI_ANY, IDI_ANY, is_any))
+ debugPrintf("* *\n");
+
+ return true;
+}
+
bool Console::Cmd_DumpScripts(int argc, const char **argv) {
if (argc != 1) {
debugPrintf("Usage: %s\n", argv[0]);
diff --git a/engines/adl/console.h b/engines/adl/console.h
index e007e09976..bfe09a1303 100644
--- a/engines/adl/console.h
+++ b/engines/adl/console.h
@@ -45,6 +45,7 @@ private:
bool Cmd_Nouns(int argc, const char **argv);
bool Cmd_Verbs(int argc, const char **argv);
bool Cmd_DumpScripts(int argc, const char **argv);
+ bool Cmd_ValidCommands(int argc, const char **argv);
void printWordMap(const Common::HashMap<Common::String, uint> &wordMap);