aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorĽubomír Remák2018-03-20 22:15:23 +0100
committerEugene Sandulenko2018-08-25 23:12:01 +0200
commit7a081f0605f2282fdce907bedfc9cae55dc67ab7 (patch)
tree520e4fff4e6d582ab911f18d997d3f7048b22bee /engines
parent1d84041508b3acaf7a47fde81e7e334c004507b8 (diff)
downloadscummvm-rg350-7a081f0605f2282fdce907bedfc9cae55dc67ab7.tar.gz
scummvm-rg350-7a081f0605f2282fdce907bedfc9cae55dc67ab7.tar.bz2
scummvm-rg350-7a081f0605f2282fdce907bedfc9cae55dc67ab7.zip
MUTATIONOFJB: Load local (room) scripts.
Diffstat (limited to 'engines')
-rw-r--r--engines/mutationofjb/commands/command.cpp1
-rw-r--r--engines/mutationofjb/commands/command.h3
-rw-r--r--engines/mutationofjb/commands/conditionalcommand.cpp4
-rw-r--r--engines/mutationofjb/commands/conditionalcommand.h2
-rw-r--r--engines/mutationofjb/commands/endblockcommand.cpp10
-rw-r--r--engines/mutationofjb/commands/endblockcommand.h6
-rw-r--r--engines/mutationofjb/commands/gotocommand.cpp4
-rw-r--r--engines/mutationofjb/game.cpp22
-rw-r--r--engines/mutationofjb/script.cpp4
-rw-r--r--engines/mutationofjb/util.cpp2
10 files changed, 52 insertions, 6 deletions
diff --git a/engines/mutationofjb/commands/command.cpp b/engines/mutationofjb/commands/command.cpp
index 943986e89d..6c4dc47cbb 100644
--- a/engines/mutationofjb/commands/command.cpp
+++ b/engines/mutationofjb/commands/command.cpp
@@ -26,6 +26,7 @@
namespace MutationOfJB {
void CommandParser::transition(ScriptParseContext &, Command *, Command *, CommandParser *) {}
+void CommandParser::finish(ScriptParseContext &parseCtx) {}
CommandParser::~CommandParser() {}
Command::~Command() {}
diff --git a/engines/mutationofjb/commands/command.h b/engines/mutationofjb/commands/command.h
index ccfdea25f0..c6fce1e892 100644
--- a/engines/mutationofjb/commands/command.h
+++ b/engines/mutationofjb/commands/command.h
@@ -43,6 +43,9 @@ public:
/* Old command - created by this parser. */
virtual void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand, CommandParser *newCommandParser);
+
+ /* Called after parsing. */
+ virtual void finish(ScriptParseContext &parseCtx);
};
class Command {
diff --git a/engines/mutationofjb/commands/conditionalcommand.cpp b/engines/mutationofjb/commands/conditionalcommand.cpp
index 1e0b7555c2..aa42d1c4db 100644
--- a/engines/mutationofjb/commands/conditionalcommand.cpp
+++ b/engines/mutationofjb/commands/conditionalcommand.cpp
@@ -38,6 +38,10 @@ void ConditionalCommandParser::transition(ScriptParseContext &parseContext, Comm
condCommand->setTrueCommand(newCommand);
}
+void ConditionalCommandParser::finish(ScriptParseContext &) {
+ _lastTag = 0;
+}
+
ConditionalCommand::ConditionalCommand() :
_trueCommand(nullptr),
diff --git a/engines/mutationofjb/commands/conditionalcommand.h b/engines/mutationofjb/commands/conditionalcommand.h
index 4a4e7e1064..d64efbf180 100644
--- a/engines/mutationofjb/commands/conditionalcommand.h
+++ b/engines/mutationofjb/commands/conditionalcommand.h
@@ -30,7 +30,9 @@ namespace MutationOfJB {
class ConditionalCommandParser : public CommandParser {
public:
+ ConditionalCommandParser() : _lastTag(0) {}
virtual void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand, CommandParser *newCommandParser);
+ virtual void finish(ScriptParseContext &parseCtx) override;
protected:
char _lastTag;
};
diff --git a/engines/mutationofjb/commands/endblockcommand.cpp b/engines/mutationofjb/commands/endblockcommand.cpp
index 019c3b5432..2d2ebe3478 100644
--- a/engines/mutationofjb/commands/endblockcommand.cpp
+++ b/engines/mutationofjb/commands/endblockcommand.cpp
@@ -121,6 +121,16 @@ void EndBlockCommandParser::transition(ScriptParseContext &parseCtx, Command *,
}
}
+void EndBlockCommandParser::finish(ScriptParseContext &) {
+ _elseFound = false;
+ _ifTag = 0;
+
+ if (!_pendingActionInfos.empty()) {
+ debug("Problem: Pending action infos from end block parser is not empty!");
+ }
+ _pendingActionInfos.clear();
+}
+
Command::ExecuteResult EndBlockCommand::execute(GameData &) {
return Finished;
}
diff --git a/engines/mutationofjb/commands/endblockcommand.h b/engines/mutationofjb/commands/endblockcommand.h
index 24c4e5c432..3af86a3d82 100644
--- a/engines/mutationofjb/commands/endblockcommand.h
+++ b/engines/mutationofjb/commands/endblockcommand.h
@@ -35,9 +35,9 @@ class EndBlockCommandParser : public CommandParser {
public:
EndBlockCommandParser() : _elseFound(false), _ifTag(0) {}
- virtual bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command);
- virtual void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand, CommandParser *newCommandParser);
-
+ virtual bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
+ virtual void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand, CommandParser *newCommandParser) override;
+ virtual void finish(ScriptParseContext &parseCtx) override;
private:
bool _elseFound;
char _ifTag;
diff --git a/engines/mutationofjb/commands/gotocommand.cpp b/engines/mutationofjb/commands/gotocommand.cpp
index 40560f3bfb..a1d1a9d819 100644
--- a/engines/mutationofjb/commands/gotocommand.cpp
+++ b/engines/mutationofjb/commands/gotocommand.cpp
@@ -26,7 +26,7 @@
#include "mutationofjb/script.h"
/*
- GOTO <label>
+ "GOTO " <label>
Jumps to a label.
*/
@@ -38,7 +38,7 @@ bool GotoCommandParser::parse(const Common::String &line, ScriptParseContext &pa
return false;
}
- Common::String label = line.c_str() + 6;
+ Common::String label = line.c_str() + 5;
GotoCommand *gotoCmd = new GotoCommand();
if (parseCtx._labels.contains(label)) {
diff --git a/engines/mutationofjb/game.cpp b/engines/mutationofjb/game.cpp
index 6fe6b958d7..cc7dab753f 100644
--- a/engines/mutationofjb/game.cpp
+++ b/engines/mutationofjb/game.cpp
@@ -79,6 +79,28 @@ bool Game::loadGameData(bool partB) {
void Game::changeScene(uint8 sceneId, bool partB) {
_gameData->_currentScene = sceneId;
_room->load(_gameData->_currentScene, partB);
+
+ if (_localScript) {
+ delete _localScript;
+ _localScript = nullptr;
+ }
+
+ EncryptedFile scriptFile;
+ Common::String fileName = Common::String::format("scrn%d%s.atn", sceneId, partB ? "b" : "");
+ scriptFile.open(fileName);
+ if (!scriptFile.isOpen()) {
+ reportFileMissingError(fileName.c_str());
+ return;
+ }
+
+ // TODO Actually parse this.
+ Common::String dummy;
+ dummy = scriptFile.readLine(); // Skip first line.
+ scriptFile.seek(126, SEEK_CUR); // Skip 126 bytes.
+
+ _localScript = new Script;
+ _localScript->loadFromStream(scriptFile);
+ scriptFile.close();
}
}
diff --git a/engines/mutationofjb/script.cpp b/engines/mutationofjb/script.cpp
index 95c2bdc7ca..3c34660402 100644
--- a/engines/mutationofjb/script.cpp
+++ b/engines/mutationofjb/script.cpp
@@ -130,6 +130,10 @@ bool Script::loadFromStream(Common::SeekableReadStream &stream) {
lastParser = currentParser;
}
+ for (CommandParser **parser = parsers; *parser; ++parser) {
+ (*parser)->finish(parseCtx);
+ }
+
for (ActionInfos::iterator it = parseCtx._actionInfos.begin(); it != parseCtx._actionInfos.end(); ++it) {
if (it->_action == ActionInfo::Look) {
_lookActionInfos.push_back(*it);
diff --git a/engines/mutationofjb/util.cpp b/engines/mutationofjb/util.cpp
index 0878748d42..1a56a62af6 100644
--- a/engines/mutationofjb/util.cpp
+++ b/engines/mutationofjb/util.cpp
@@ -28,7 +28,7 @@
namespace MutationOfJB {
void reportFileMissingError(const char *fileName) {
- Common::String errorMessage = Common::String::format(_("Unable to locate the '%s' engine data file."), fileName);
+ Common::String errorMessage = Common::String::format(_("Unable to locate the '%s' engine data file"), fileName);
GUIErrorMessage(errorMessage);
warning("%s", errorMessage.c_str());
}