diff options
author | Ľubomír Remák | 2018-03-22 16:08:14 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2018-08-25 23:12:01 +0200 |
commit | 63c0dac9613caef3778a4cb9765bb8b628e5a1c2 (patch) | |
tree | de47fa3b7282dc163d06b51a47cbd1d3f0a868be /engines/mutationofjb/commands | |
parent | 3928c52c0ee2a930431a807d0b4262440ab75725 (diff) | |
download | scummvm-rg350-63c0dac9613caef3778a4cb9765bb8b628e5a1c2.tar.gz scummvm-rg350-63c0dac9613caef3778a4cb9765bb8b628e5a1c2.tar.bz2 scummvm-rg350-63c0dac9613caef3778a4cb9765bb8b628e5a1c2.zip |
MUTATIONOFJB: Add support for macro definitions.
Diffstat (limited to 'engines/mutationofjb/commands')
-rw-r--r-- | engines/mutationofjb/commands/command.h | 2 | ||||
-rw-r--r-- | engines/mutationofjb/commands/endblockcommand.cpp | 30 | ||||
-rw-r--r-- | engines/mutationofjb/commands/endblockcommand.h | 1 |
3 files changed, 32 insertions, 1 deletions
diff --git a/engines/mutationofjb/commands/command.h b/engines/mutationofjb/commands/command.h index c6fce1e892..1303242fb5 100644 --- a/engines/mutationofjb/commands/command.h +++ b/engines/mutationofjb/commands/command.h @@ -24,7 +24,7 @@ #define MUTATIONOFJB_COMMAND_H namespace Common { - class String; +class String; } namespace MutationOfJB { diff --git a/engines/mutationofjb/commands/endblockcommand.cpp b/engines/mutationofjb/commands/endblockcommand.cpp index c8adaaa998..4a6e608ae7 100644 --- a/engines/mutationofjb/commands/endblockcommand.cpp +++ b/engines/mutationofjb/commands/endblockcommand.cpp @@ -26,6 +26,26 @@ #include "common/str.h" #include "common/debug.h" +/* + ("#L " | "-L ") <object> + ("#W " | "-W ") <object> + ("#T " | "-T ") <object> + ("#U " | "-U ") <object1> [<object2>] + ("#ELSE" | "-ELSE") [<tag>] + "#MACRO " <name> + + If a line starts with '#', '=', '-', it is treated as the end of a section. + However, at the same time it can also start a new section depending on what follows. + + #L (look), #W (walk), #T (talk), #U (use) sections are executed + when the user starts corresponding action on the object or in case of "use" up to two objects. + The difference between '#' and '-' version is whether the player walks towards the object ('#') or not ('-'). + + #ELSE is used by conditional commands (see comments for IfCommand and others). + + #MACRO starts a new macro. Global script can call macros from local script and vice versa. +*/ + namespace MutationOfJB { bool EndBlockCommandParser::parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) { @@ -85,6 +105,8 @@ bool EndBlockCommandParser::parse(const Common::String &line, ScriptParseContext if (line.size() >= 6) { _ifTag = line[5]; } + } else if (line.size() >= 8 && line.hasPrefix("#MACRO")) { + _foundMacro = line.c_str() + 7; } if (firstChar == '#') { @@ -116,6 +138,13 @@ void EndBlockCommandParser::transition(ScriptParseContext &parseCtx, Command *, _ifTag = 0; } + if (!_foundMacro.empty() && newCommand) { + if (!parseCtx._macros.contains(_foundMacro)) { + parseCtx._macros[_foundMacro] = newCommand; + } + _foundMacro = ""; + } + if (newCommandParser != this) { if (!_pendingActionInfos.empty()) { for (Common::Array<uint>::iterator it = _pendingActionInfos.begin(); it != _pendingActionInfos.end(); ++it) { @@ -135,6 +164,7 @@ void EndBlockCommandParser::finish(ScriptParseContext &) { debug("Problem: Pending action infos from end block parser is not empty!"); } _pendingActionInfos.clear(); + _foundMacro = ""; } Command::ExecuteResult EndBlockCommand::execute(GameData &) { diff --git a/engines/mutationofjb/commands/endblockcommand.h b/engines/mutationofjb/commands/endblockcommand.h index 140fb21917..1b22d75931 100644 --- a/engines/mutationofjb/commands/endblockcommand.h +++ b/engines/mutationofjb/commands/endblockcommand.h @@ -44,6 +44,7 @@ private: char _ifTag; Common::Array<uint> _pendingActionInfos; + Common::String _foundMacro; }; class EndBlockCommand : public Command { |