diff options
author | Ľubomír Remák | 2018-03-24 03:10:26 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2018-08-25 23:12:01 +0200 |
commit | e93e20dbe869f2d3906ec1d0a151a21de29e9714 (patch) | |
tree | cd44e5a9755aff3f833c75fd12f10581449fce31 /engines/mutationofjb/commands | |
parent | 7a1898730155dce824451d98bbe65b430832d575 (diff) | |
download | scummvm-rg350-e93e20dbe869f2d3906ec1d0a151a21de29e9714.tar.gz scummvm-rg350-e93e20dbe869f2d3906ec1d0a151a21de29e9714.tar.bz2 scummvm-rg350-e93e20dbe869f2d3906ec1d0a151a21de29e9714.zip |
MUTATIONOFJB: Parse startup sections in scripts and fix change scene command.
Diffstat (limited to 'engines/mutationofjb/commands')
-rw-r--r-- | engines/mutationofjb/commands/changecommand.cpp | 42 | ||||
-rw-r--r-- | engines/mutationofjb/commands/changecommand.h | 2 | ||||
-rw-r--r-- | engines/mutationofjb/commands/endblockcommand.cpp | 26 | ||||
-rw-r--r-- | engines/mutationofjb/commands/endblockcommand.h | 1 |
4 files changed, 52 insertions, 19 deletions
diff --git a/engines/mutationofjb/commands/changecommand.cpp b/engines/mutationofjb/commands/changecommand.cpp index a4316bde3b..f2639b620e 100644 --- a/engines/mutationofjb/commands/changecommand.cpp +++ b/engines/mutationofjb/commands/changecommand.cpp @@ -37,16 +37,30 @@ namespace MutationOfJB { // <ii> 2B Entity ID. // <val> VL Value. -bool ChangeCommandParser::parseValueString(const Common::String &valueString, uint8 &sceneId, uint8 &entityId, ChangeCommand::ChangeRegister ®, ChangeCommand::ChangeOperation &op, ChangeCommandValue &ccv) { - if (valueString.size() < 8) { - return false; +bool ChangeCommandParser::parseValueString(const Common::String &valueString, bool changeEntity, uint8 &sceneId, uint8 &entityId, ChangeCommand::ChangeRegister ®, ChangeCommand::ChangeOperation &op, ChangeCommandValue &ccv) { + if (changeEntity) { + if (valueString.size() < 8) { + return false; + } + } else { + if (valueString.size() < 7) { + return false; + } } sceneId = atoi(valueString.c_str() + 3); - entityId = atoi(valueString.c_str() + 6); + if (changeEntity) { + entityId = atoi(valueString.c_str() + 6); + } const char *val = nullptr; - if (valueString.size() >= 9) { - val = valueString.c_str() + 9; + if (changeEntity) { + if (valueString.size() >= 9) { + val = valueString.c_str() + 9; + } + } else { + if (valueString.size() >= 6) { + val = valueString.c_str() + 6; + } } if (valueString.hasPrefix("NM")) { @@ -137,7 +151,7 @@ bool ChangeDoorCommandParser::parse(const Common::String &line, ScriptParseConte ChangeCommand::ChangeRegister reg; ChangeCommand::ChangeOperation op; ChangeCommandValue val; - if (!parseValueString(line.c_str() + 8, sceneId, objectId, reg, op, val)) { + if (!parseValueString(line.c_str() + 8, true, sceneId, objectId, reg, op, val)) { return false; } @@ -154,7 +168,7 @@ bool ChangeObjectCommandParser::parse(const Common::String &line, ScriptParseCon ChangeCommand::ChangeRegister reg; ChangeCommand::ChangeOperation op; ChangeCommandValue val; - if (!parseValueString(line.c_str() + 8, sceneId, objectId, reg, op, val)) { + if (!parseValueString(line.c_str() + 8, true, sceneId, objectId, reg, op, val)) { return false; } @@ -171,7 +185,7 @@ bool ChangeStaticCommandParser::parse(const Common::String &line, ScriptParseCon ChangeCommand::ChangeRegister reg; ChangeCommand::ChangeOperation op; ChangeCommandValue val; - if (!parseValueString(line.c_str() + 8, sceneId, objectId, reg, op, val)) { + if (!parseValueString(line.c_str() + 8, true, sceneId, objectId, reg, op, val)) { return false; } @@ -188,7 +202,7 @@ bool ChangeSceneCommandParser::parse(const Common::String &line, ScriptParseCont ChangeCommand::ChangeRegister reg; ChangeCommand::ChangeOperation op; ChangeCommandValue val; - if (!parseValueString(line.c_str() + 8, sceneId, objectId, reg, op, val)) { + if (!parseValueString(line.c_str() + 7, false, sceneId, objectId, reg, op, val)) { return false; } @@ -351,7 +365,7 @@ Command::ExecuteResult ChangeDoorCommand::execute(ScriptExecutionContext &script } Common::String ChangeDoorCommand::debugString() const { - return Common::String::format("scene%d.door%d.%s %s %s", _sceneId, _entityId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str()); + return Common::String::format("SCENE%d.DOOR%d.%s %s %s", _sceneId, _entityId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str()); } Command::ExecuteResult ChangeObjectCommand::execute(ScriptExecutionContext &scriptExecCtx) { @@ -414,7 +428,7 @@ Command::ExecuteResult ChangeObjectCommand::execute(ScriptExecutionContext &scri } Common::String ChangeObjectCommand::debugString() const { - return Common::String::format("scene%d.object%d.%s %s %s", _sceneId, _entityId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str()); + return Common::String::format("SCENE%d.OBJECT%d.%s %s %s", _sceneId, _entityId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str()); } Command::ExecuteResult ChangeStaticCommand::execute(ScriptExecutionContext &scriptExecCtx) { @@ -465,7 +479,7 @@ Command::ExecuteResult ChangeStaticCommand::execute(ScriptExecutionContext &scri } Common::String ChangeStaticCommand::debugString() const { - return Common::String::format("scene%d.static%d.%s %s %s", _sceneId, _entityId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str()); + return Common::String::format("SCENE%d.STATIC%d.%s %s %s", _sceneId, _entityId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str()); } Command::ExecuteResult ChangeSceneCommand::execute(ScriptExecutionContext &scriptExecCtx) { @@ -508,6 +522,6 @@ Command::ExecuteResult ChangeSceneCommand::execute(ScriptExecutionContext &scrip } Common::String ChangeSceneCommand::debugString() const { - return Common::String::format("scene%d.%s %s %s", _sceneId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str()); + return Common::String::format("SCENE%d.%s %s %s", _sceneId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str()); } } diff --git a/engines/mutationofjb/commands/changecommand.h b/engines/mutationofjb/commands/changecommand.h index dde5cd1487..f5d7cf5e52 100644 --- a/engines/mutationofjb/commands/changecommand.h +++ b/engines/mutationofjb/commands/changecommand.h @@ -84,7 +84,7 @@ protected: class ChangeCommandParser : public SeqCommandParser { protected: - bool parseValueString(const Common::String &valueString, uint8 &sceneId, uint8 &entityId, ChangeCommand::ChangeRegister ®, ChangeCommand::ChangeOperation &op, ChangeCommandValue &ccv); + bool parseValueString(const Common::String &valueString, bool changeEntity, uint8 &sceneId, uint8 &entityId, ChangeCommand::ChangeRegister ®, ChangeCommand::ChangeOperation &op, ChangeCommandValue &ccv); int parseInteger(const char *val, ChangeCommand::ChangeOperation &op); }; diff --git a/engines/mutationofjb/commands/endblockcommand.cpp b/engines/mutationofjb/commands/endblockcommand.cpp index 53ea74a97b..492a4244b3 100644 --- a/engines/mutationofjb/commands/endblockcommand.cpp +++ b/engines/mutationofjb/commands/endblockcommand.cpp @@ -25,6 +25,7 @@ #include "mutationofjb/commands/conditionalcommand.h" #include "common/str.h" #include "common/debug.h" +#include "common/translation.h" /* ("#L " | "-L ") <object> @@ -107,6 +108,8 @@ bool EndBlockCommandParser::parse(const Common::String &line, ScriptParseContext } } else if (line.size() >= 8 && line.hasPrefix("#MACRO")) { _foundMacro = line.c_str() + 7; + } else if (line.size() >= 10 && line.hasPrefix("#STARTUP")) { + _foundStartup = line.c_str() + 9; } if (firstChar == '#') { @@ -138,11 +141,26 @@ void EndBlockCommandParser::transition(ScriptParseContext &parseCtx, Command *, _ifTag = 0; } - if (!_foundMacro.empty() && newCommand) { - if (!parseCtx._macros.contains(_foundMacro)) { - parseCtx._macros[_foundMacro] = newCommand; + if (!_foundMacro.empty()) { + if (newCommand) { + if (!parseCtx._macros.contains(_foundMacro)) { + parseCtx._macros[_foundMacro] = newCommand; + } else { + warning(_("Macro '%s' already exists."), _foundMacro.c_str()); + } + } + _foundMacro.clear(); + } + if (!_foundStartup.empty()) { + if (newCommand) { + const uint8 startupId = atoi(_foundStartup.c_str()); + if (!parseCtx._startups.contains(startupId)) { + parseCtx._startups[startupId] = newCommand; + } else { + warning(_("Startup %u already exists."), (unsigned int) startupId); + } } - _foundMacro = ""; + _foundStartup.clear(); } if (newCommandParser != this) { diff --git a/engines/mutationofjb/commands/endblockcommand.h b/engines/mutationofjb/commands/endblockcommand.h index 4c0d23b609..eb77f435d4 100644 --- a/engines/mutationofjb/commands/endblockcommand.h +++ b/engines/mutationofjb/commands/endblockcommand.h @@ -45,6 +45,7 @@ private: Common::Array<uint> _pendingActionInfos; Common::String _foundMacro; + Common::String _foundStartup; }; class EndBlockCommand : public Command { |