aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorĽubomír Remák2018-03-22 19:48:57 +0100
committerEugene Sandulenko2018-08-25 23:12:01 +0200
commite1d173ed7541f9da79f60a65d974da3ebbb29e7a (patch)
tree505833c76c52396d154a49474c5509729020e4f5 /engines
parent63c0dac9613caef3778a4cb9765bb8b628e5a1c2 (diff)
downloadscummvm-rg350-e1d173ed7541f9da79f60a65d974da3ebbb29e7a.tar.gz
scummvm-rg350-e1d173ed7541f9da79f60a65d974da3ebbb29e7a.tar.bz2
scummvm-rg350-e1d173ed7541f9da79f60a65d974da3ebbb29e7a.zip
MUTATIONOFJB: Add changescene debug command and fix macro debug commands.
Diffstat (limited to 'engines')
-rw-r--r--engines/mutationofjb/commands/additemcommand.cpp5
-rw-r--r--engines/mutationofjb/commands/additemcommand.h2
-rw-r--r--engines/mutationofjb/commands/camefromcommand.cpp5
-rw-r--r--engines/mutationofjb/commands/camefromcommand.h2
-rw-r--r--engines/mutationofjb/commands/changecommand.cpp18
-rw-r--r--engines/mutationofjb/commands/changecommand.h8
-rw-r--r--engines/mutationofjb/commands/command.cpp4
-rw-r--r--engines/mutationofjb/commands/command.h10
-rw-r--r--engines/mutationofjb/commands/endblockcommand.cpp5
-rw-r--r--engines/mutationofjb/commands/endblockcommand.h5
-rw-r--r--engines/mutationofjb/commands/gotocommand.cpp2
-rw-r--r--engines/mutationofjb/commands/gotocommand.h2
-rw-r--r--engines/mutationofjb/commands/ifcommand.cpp6
-rw-r--r--engines/mutationofjb/commands/ifcommand.h2
-rw-r--r--engines/mutationofjb/commands/ifitemcommand.cpp4
-rw-r--r--engines/mutationofjb/commands/ifitemcommand.h2
-rw-r--r--engines/mutationofjb/commands/ifpiggycommand.cpp4
-rw-r--r--engines/mutationofjb/commands/ifpiggycommand.h2
-rw-r--r--engines/mutationofjb/commands/labelcommand.cpp2
-rw-r--r--engines/mutationofjb/commands/labelcommand.h2
-rw-r--r--engines/mutationofjb/commands/removeallitemscommand.cpp5
-rw-r--r--engines/mutationofjb/commands/removeallitemscommand.h2
-rw-r--r--engines/mutationofjb/commands/removeitemcommand.cpp5
-rw-r--r--engines/mutationofjb/commands/removeitemcommand.h2
-rw-r--r--engines/mutationofjb/commands/saycommand.cpp2
-rw-r--r--engines/mutationofjb/commands/saycommand.h2
-rw-r--r--engines/mutationofjb/commands/seqcommand.cpp4
-rw-r--r--engines/mutationofjb/commands/seqcommand.h1
-rw-r--r--engines/mutationofjb/debug.cpp16
-rw-r--r--engines/mutationofjb/debug.h1
-rw-r--r--engines/mutationofjb/script.cpp21
-rw-r--r--engines/mutationofjb/script.h15
32 files changed, 108 insertions, 60 deletions
diff --git a/engines/mutationofjb/commands/additemcommand.cpp b/engines/mutationofjb/commands/additemcommand.cpp
index 58ec5675fb..1a670f7d27 100644
--- a/engines/mutationofjb/commands/additemcommand.cpp
+++ b/engines/mutationofjb/commands/additemcommand.cpp
@@ -22,6 +22,7 @@
#include "mutationofjb/commands/additemcommand.h"
#include "mutationofjb/gamedata.h"
+#include "mutationofjb/script.h"
/*
"ADDITEM" " " <item>
@@ -40,8 +41,8 @@ bool AddItemCommandParser::parse(const Common::String &line, ScriptParseContext
return true;
}
-Command::ExecuteResult AddItemCommand::execute(GameData &gameData) {
- gameData._inventory.addItem(_item);
+Command::ExecuteResult AddItemCommand::execute(ScriptExecutionContext &scriptExecCtx) {
+ scriptExecCtx.getGameData()._inventory.addItem(_item);
return Finished;
}
diff --git a/engines/mutationofjb/commands/additemcommand.h b/engines/mutationofjb/commands/additemcommand.h
index cb4c131d0f..4e2ea2b692 100644
--- a/engines/mutationofjb/commands/additemcommand.h
+++ b/engines/mutationofjb/commands/additemcommand.h
@@ -39,7 +39,7 @@ class AddItemCommand : public SeqCommand {
public:
AddItemCommand(const Common::String &item) : _item(item) {}
- virtual ExecuteResult execute(GameData &gameData) override;
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
virtual Common::String debugString() const override;
private:
Common::String _item;
diff --git a/engines/mutationofjb/commands/camefromcommand.cpp b/engines/mutationofjb/commands/camefromcommand.cpp
index 2c232c1ce5..0583187884 100644
--- a/engines/mutationofjb/commands/camefromcommand.cpp
+++ b/engines/mutationofjb/commands/camefromcommand.cpp
@@ -22,6 +22,7 @@
#include "mutationofjb/commands/camefromcommand.h"
#include "mutationofjb/gamedata.h"
+#include "mutationofjb/script.h"
#include "common/str.h"
/*
@@ -44,8 +45,8 @@ bool CameFromCommandParser::parse(const Common::String &line, ScriptParseContext
return true;
}
-Command::ExecuteResult CameFromCommand::execute(GameData &gameData) {
- _cachedResult = (gameData._lastScene == _sceneId);
+Command::ExecuteResult CameFromCommand::execute(ScriptExecutionContext &scriptExecCtx) {
+ _cachedResult = (scriptExecCtx.getGameData()._lastScene == _sceneId);
return Finished;
}
diff --git a/engines/mutationofjb/commands/camefromcommand.h b/engines/mutationofjb/commands/camefromcommand.h
index c097ca1fa6..c4048cb044 100644
--- a/engines/mutationofjb/commands/camefromcommand.h
+++ b/engines/mutationofjb/commands/camefromcommand.h
@@ -37,7 +37,7 @@ public:
class CameFromCommand : public ConditionalCommand {
public:
CameFromCommand(uint8 sceneId) : _sceneId(sceneId) {}
- virtual ExecuteResult execute(GameData &gameData) override;
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
virtual Common::String debugString() const;
private:
uint8 _sceneId;
diff --git a/engines/mutationofjb/commands/changecommand.cpp b/engines/mutationofjb/commands/changecommand.cpp
index e4699ebb74..a4316bde3b 100644
--- a/engines/mutationofjb/commands/changecommand.cpp
+++ b/engines/mutationofjb/commands/changecommand.cpp
@@ -21,6 +21,8 @@
*/
#include "mutationofjb/commands/changecommand.h"
+#include "mutationofjb/script.h"
+#include "mutationofjb/gamedata.h"
#include "common/translation.h"
namespace MutationOfJB {
@@ -295,8 +297,8 @@ const char *ChangeCommand::getOperationAsString() const {
}
}
-Command::ExecuteResult ChangeDoorCommand::execute(GameData &gameData) {
- Scene *const scene = gameData.getScene(_sceneId);
+Command::ExecuteResult ChangeDoorCommand::execute(ScriptExecutionContext &scriptExecCtx) {
+ Scene *const scene = scriptExecCtx.getGameData().getScene(_sceneId);
if (!scene) {
return Finished;
}
@@ -352,8 +354,8 @@ Common::String ChangeDoorCommand::debugString() const {
return Common::String::format("scene%d.door%d.%s %s %s", _sceneId, _entityId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str());
}
-Command::ExecuteResult ChangeObjectCommand::execute(GameData &gameData) {
- Scene *const scene = gameData.getScene(_sceneId);
+Command::ExecuteResult ChangeObjectCommand::execute(ScriptExecutionContext &scriptExecCtx) {
+ Scene *const scene = scriptExecCtx.getGameData().getScene(_sceneId);
if (!scene) {
return Finished;
}
@@ -415,8 +417,8 @@ Common::String ChangeObjectCommand::debugString() const {
return Common::String::format("scene%d.object%d.%s %s %s", _sceneId, _entityId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str());
}
-Command::ExecuteResult ChangeStaticCommand::execute(GameData &gameData) {
- Scene *const scene = gameData.getScene(_sceneId);
+Command::ExecuteResult ChangeStaticCommand::execute(ScriptExecutionContext &scriptExecCtx) {
+ Scene *const scene = scriptExecCtx.getGameData().getScene(_sceneId);
if (!scene) {
return Finished;
}
@@ -466,8 +468,8 @@ Common::String ChangeStaticCommand::debugString() const {
return Common::String::format("scene%d.static%d.%s %s %s", _sceneId, _entityId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str());
}
-Command::ExecuteResult ChangeSceneCommand::execute(GameData &gameData) {
- Scene *const scene = gameData.getScene(_sceneId);
+Command::ExecuteResult ChangeSceneCommand::execute(ScriptExecutionContext &scriptExecCtx) {
+ Scene *const scene = scriptExecCtx.getGameData().getScene(_sceneId);
if (!scene) {
return Finished;
}
diff --git a/engines/mutationofjb/commands/changecommand.h b/engines/mutationofjb/commands/changecommand.h
index 5ba386bf02..dde5cd1487 100644
--- a/engines/mutationofjb/commands/changecommand.h
+++ b/engines/mutationofjb/commands/changecommand.h
@@ -113,7 +113,7 @@ public:
ChangeDoorCommand(uint8 sceneId, uint8 doorId, ChangeRegister reg, ChangeOperation op, const ChangeCommandValue &val)
: ChangeCommand(sceneId, doorId, reg, op, val)
{}
- virtual ExecuteResult execute(GameData &gameData) override;
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
virtual Common::String debugString() const;
};
@@ -122,7 +122,7 @@ public:
ChangeObjectCommand(uint8 sceneId, uint8 objectId, ChangeRegister reg, ChangeOperation op, const ChangeCommandValue &val)
: ChangeCommand(sceneId, objectId, reg, op, val)
{}
- virtual ExecuteResult execute(GameData &gameData) override;
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
virtual Common::String debugString() const;
};
@@ -131,7 +131,7 @@ public:
ChangeStaticCommand(uint8 sceneId, uint8 staticId, ChangeRegister reg, ChangeOperation op, const ChangeCommandValue &val)
: ChangeCommand(sceneId, staticId, reg, op, val)
{}
- virtual ExecuteResult execute(GameData &gameData) override;
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
virtual Common::String debugString() const;
};
@@ -140,7 +140,7 @@ public:
ChangeSceneCommand(uint8 sceneId, uint8 staticId, ChangeRegister reg, ChangeOperation op, const ChangeCommandValue &val)
: ChangeCommand(sceneId, staticId, reg, op, val)
{}
- virtual ExecuteResult execute(GameData &gameData) override;
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
virtual Common::String debugString() const;
};
diff --git a/engines/mutationofjb/commands/command.cpp b/engines/mutationofjb/commands/command.cpp
index d1e92f8f74..1e546ff49d 100644
--- a/engines/mutationofjb/commands/command.cpp
+++ b/engines/mutationofjb/commands/command.cpp
@@ -31,8 +31,4 @@ CommandParser::~CommandParser() {}
Command::~Command() {}
-SeqCommand *Command::asSeqCommand() {
- return nullptr;
-}
-
}
diff --git a/engines/mutationofjb/commands/command.h b/engines/mutationofjb/commands/command.h
index 1303242fb5..0133d52dd0 100644
--- a/engines/mutationofjb/commands/command.h
+++ b/engines/mutationofjb/commands/command.h
@@ -29,12 +29,9 @@ class String;
namespace MutationOfJB {
-class GameData;
-class SeqCommand;
-class IfCommand;
-class CallMacroCommand;
-class ScriptParseContext;
class Command;
+class ScriptExecutionContext;
+class ScriptParseContext;
class CommandParser {
public:
@@ -58,10 +55,9 @@ public:
virtual ~Command();
- virtual ExecuteResult execute(GameData &gameData) = 0;
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) = 0;
virtual Command *next() const = 0;
- virtual SeqCommand *asSeqCommand();
virtual Common::String debugString() const = 0;
};
}
diff --git a/engines/mutationofjb/commands/endblockcommand.cpp b/engines/mutationofjb/commands/endblockcommand.cpp
index 4a6e608ae7..53ea74a97b 100644
--- a/engines/mutationofjb/commands/endblockcommand.cpp
+++ b/engines/mutationofjb/commands/endblockcommand.cpp
@@ -167,12 +167,13 @@ void EndBlockCommandParser::finish(ScriptParseContext &) {
_foundMacro = "";
}
-Command::ExecuteResult EndBlockCommand::execute(GameData &) {
+Command::ExecuteResult EndBlockCommand::execute(ScriptExecutionContext &scriptExecCtx) {
+ _nextCmd = scriptExecCtx.popReturnCommand();
return Finished;
}
Command *EndBlockCommand::next() const {
- return nullptr;
+ return _nextCmd;
}
Common::String EndBlockCommand::debugString() const {
diff --git a/engines/mutationofjb/commands/endblockcommand.h b/engines/mutationofjb/commands/endblockcommand.h
index 1b22d75931..4c0d23b609 100644
--- a/engines/mutationofjb/commands/endblockcommand.h
+++ b/engines/mutationofjb/commands/endblockcommand.h
@@ -49,11 +49,14 @@ private:
class EndBlockCommand : public Command {
public:
+ EndBlockCommand() : _nextCmd(nullptr) {}
static bool ParseFunc(const Common::String &line, ScriptParseContext &parseContext, Command *&command);
- virtual ExecuteResult execute(GameData &gameData) override;
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
virtual Command *next() const override;
virtual Common::String debugString() const;
+private:
+ Command *_nextCmd;
};
}
diff --git a/engines/mutationofjb/commands/gotocommand.cpp b/engines/mutationofjb/commands/gotocommand.cpp
index a1d1a9d819..bc24e2c552 100644
--- a/engines/mutationofjb/commands/gotocommand.cpp
+++ b/engines/mutationofjb/commands/gotocommand.cpp
@@ -59,7 +59,7 @@ void GotoCommand::setLabelCommand(LabelCommand *labelCmd) {
_labelCommand = labelCmd;
}
-Command::ExecuteResult GotoCommand::execute(GameData &) {
+Command::ExecuteResult GotoCommand::execute(ScriptExecutionContext &) {
// Intentionally empty.
return Finished;
diff --git a/engines/mutationofjb/commands/gotocommand.h b/engines/mutationofjb/commands/gotocommand.h
index 436dd44fb3..09d426fd85 100644
--- a/engines/mutationofjb/commands/gotocommand.h
+++ b/engines/mutationofjb/commands/gotocommand.h
@@ -43,7 +43,7 @@ public:
void setLabelCommand(LabelCommand *labelCmd);
- virtual ExecuteResult execute(GameData &gameData) override;
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
virtual Command *next() const override;
virtual Common::String debugString() const override;
private:
diff --git a/engines/mutationofjb/commands/ifcommand.cpp b/engines/mutationofjb/commands/ifcommand.cpp
index f78335ad60..b5f03fc9e4 100644
--- a/engines/mutationofjb/commands/ifcommand.cpp
+++ b/engines/mutationofjb/commands/ifcommand.cpp
@@ -47,7 +47,7 @@
namespace MutationOfJB {
-bool IfCommandParser::parse(const Common::String &line, ScriptParseContext &parseContext, Command *&command) {
+bool IfCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
// IFtss oo val!
// <t> 1B Tag.
// <ss> 2B Scene.
@@ -84,8 +84,8 @@ IfCommand::IfCommand(uint8 sceneId, uint8 objectId, uint16 value, bool negative)
_negative(negative)
{}
-Command::ExecuteResult IfCommand::execute(GameData &gameData) {
- Scene *const scene = gameData.getScene(_sceneId);
+Command::ExecuteResult IfCommand::execute(ScriptExecutionContext &scriptExecCtx) {
+ Scene *const scene = scriptExecCtx.getGameData().getScene(_sceneId);
if (!scene) {
return Finished;
}
diff --git a/engines/mutationofjb/commands/ifcommand.h b/engines/mutationofjb/commands/ifcommand.h
index 51350cecd5..b04d8a363d 100644
--- a/engines/mutationofjb/commands/ifcommand.h
+++ b/engines/mutationofjb/commands/ifcommand.h
@@ -40,7 +40,7 @@ class IfCommand : public ConditionalCommand {
public:
IfCommand(uint8 sceneId, uint8 objectId, uint16 value, bool negative);
- virtual ExecuteResult execute(GameData &gameData) override;
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
virtual Common::String debugString() const;
private:
diff --git a/engines/mutationofjb/commands/ifitemcommand.cpp b/engines/mutationofjb/commands/ifitemcommand.cpp
index 7512ba5955..7a58cee22d 100644
--- a/engines/mutationofjb/commands/ifitemcommand.cpp
+++ b/engines/mutationofjb/commands/ifitemcommand.cpp
@@ -73,8 +73,8 @@ IfItemCommand::IfItemCommand(const Common::String &item, bool negative) :
_negative(negative)
{}
-Command::ExecuteResult IfItemCommand::execute(GameData &gameData) {
- _cachedResult = gameData._inventory.hasItem(_item);
+Command::ExecuteResult IfItemCommand::execute(ScriptExecutionContext &scriptExecCtx) {
+ _cachedResult = scriptExecCtx.getGameData()._inventory.hasItem(_item);
if (_negative) {
_cachedResult = !_cachedResult;
}
diff --git a/engines/mutationofjb/commands/ifitemcommand.h b/engines/mutationofjb/commands/ifitemcommand.h
index 0451786789..f11ba7cbfb 100644
--- a/engines/mutationofjb/commands/ifitemcommand.h
+++ b/engines/mutationofjb/commands/ifitemcommand.h
@@ -40,7 +40,7 @@ class IfItemCommand : public ConditionalCommand {
public:
IfItemCommand(const Common::String &item, bool negative);
- virtual ExecuteResult execute(GameData &gameData) override;
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
virtual Common::String debugString() const;
private:
diff --git a/engines/mutationofjb/commands/ifpiggycommand.cpp b/engines/mutationofjb/commands/ifpiggycommand.cpp
index cad0a14eb1..e30213ac68 100644
--- a/engines/mutationofjb/commands/ifpiggycommand.cpp
+++ b/engines/mutationofjb/commands/ifpiggycommand.cpp
@@ -57,8 +57,8 @@ bool IfPiggyCommandParser::parse(const Common::String &line, ScriptParseContext
}
-Command::ExecuteResult IfPiggyCommand::execute(GameData &gameData) {
- _cachedResult = gameData._currentAPK == "piggy.apk";
+Command::ExecuteResult IfPiggyCommand::execute(ScriptExecutionContext &scriptExecCtx) {
+ _cachedResult = scriptExecCtx.getGameData()._currentAPK == "piggy.apk";
return Finished;
}
diff --git a/engines/mutationofjb/commands/ifpiggycommand.h b/engines/mutationofjb/commands/ifpiggycommand.h
index 3fb68267c4..d10788c414 100644
--- a/engines/mutationofjb/commands/ifpiggycommand.h
+++ b/engines/mutationofjb/commands/ifpiggycommand.h
@@ -38,7 +38,7 @@ public:
class IfPiggyCommand : public ConditionalCommand {
public:
- virtual ExecuteResult execute(GameData &gameData) override;
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
virtual Common::String debugString() const;
private:
diff --git a/engines/mutationofjb/commands/labelcommand.cpp b/engines/mutationofjb/commands/labelcommand.cpp
index 87c78f953d..de6de020ab 100644
--- a/engines/mutationofjb/commands/labelcommand.cpp
+++ b/engines/mutationofjb/commands/labelcommand.cpp
@@ -64,7 +64,7 @@ const Common::String &LabelCommand::getName() const
return _name;
}
-Command::ExecuteResult LabelCommand::execute(GameData &) {
+Command::ExecuteResult LabelCommand::execute(ScriptExecutionContext &) {
// Intentionally empty.
return Finished;
diff --git a/engines/mutationofjb/commands/labelcommand.h b/engines/mutationofjb/commands/labelcommand.h
index 389c759946..f4acad63e0 100644
--- a/engines/mutationofjb/commands/labelcommand.h
+++ b/engines/mutationofjb/commands/labelcommand.h
@@ -40,7 +40,7 @@ public:
LabelCommand(const Common::String &name) : _name(name) {}
const Common::String &getName() const;
- virtual ExecuteResult execute(GameData &gameData) override;
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
virtual Common::String debugString() const override;
private:
Common::String _name;
diff --git a/engines/mutationofjb/commands/removeallitemscommand.cpp b/engines/mutationofjb/commands/removeallitemscommand.cpp
index 8043864715..d9ebe4534a 100644
--- a/engines/mutationofjb/commands/removeallitemscommand.cpp
+++ b/engines/mutationofjb/commands/removeallitemscommand.cpp
@@ -21,6 +21,7 @@
*/
#include "mutationofjb/commands/removeallitemscommand.h"
+#include "mutationofjb/script.h"
#include "mutationofjb/gamedata.h"
/*
@@ -40,8 +41,8 @@ bool RemoveAllItemsCommandParser::parse(const Common::String &line, ScriptParseC
return true;
}
-Command::ExecuteResult RemoveAllItemsCommand::execute(GameData &gameData) {
- gameData._inventory.removeAllItems();
+Command::ExecuteResult RemoveAllItemsCommand::execute(ScriptExecutionContext &scriptExecCtx) {
+ scriptExecCtx.getGameData()._inventory.removeAllItems();
return Finished;
}
diff --git a/engines/mutationofjb/commands/removeallitemscommand.h b/engines/mutationofjb/commands/removeallitemscommand.h
index 166aed8b3b..92fe93f4cf 100644
--- a/engines/mutationofjb/commands/removeallitemscommand.h
+++ b/engines/mutationofjb/commands/removeallitemscommand.h
@@ -38,7 +38,7 @@ class RemoveAllItemsCommand : public SeqCommand {
public:
RemoveAllItemsCommand() {}
- virtual ExecuteResult execute(GameData &gameData) override;
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
virtual Common::String debugString() const override;
private:
};
diff --git a/engines/mutationofjb/commands/removeitemcommand.cpp b/engines/mutationofjb/commands/removeitemcommand.cpp
index e4d9601824..48dbda9801 100644
--- a/engines/mutationofjb/commands/removeitemcommand.cpp
+++ b/engines/mutationofjb/commands/removeitemcommand.cpp
@@ -21,6 +21,7 @@
*/
#include "mutationofjb/commands/removeitemcommand.h"
+#include "mutationofjb/script.h"
#include "mutationofjb/gamedata.h"
/*
@@ -40,8 +41,8 @@ bool RemoveItemCommandParser::parse(const Common::String &line, ScriptParseConte
return true;
}
-Command::ExecuteResult RemoveItemCommand::execute(GameData &gameData) {
- gameData._inventory.removeItem(_item);
+Command::ExecuteResult RemoveItemCommand::execute(ScriptExecutionContext &scriptExecCtx) {
+ scriptExecCtx.getGameData()._inventory.removeItem(_item);
return Finished;
}
diff --git a/engines/mutationofjb/commands/removeitemcommand.h b/engines/mutationofjb/commands/removeitemcommand.h
index 452a3b2ff5..0aa13f5c84 100644
--- a/engines/mutationofjb/commands/removeitemcommand.h
+++ b/engines/mutationofjb/commands/removeitemcommand.h
@@ -39,7 +39,7 @@ class RemoveItemCommand : public SeqCommand {
public:
RemoveItemCommand(const Common::String &item) : _item(item) {}
- virtual ExecuteResult execute(GameData &gameData) override;
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
virtual Common::String debugString() const override;
private:
Common::String _item;
diff --git a/engines/mutationofjb/commands/saycommand.cpp b/engines/mutationofjb/commands/saycommand.cpp
index a0c9c79bd6..854c957b1b 100644
--- a/engines/mutationofjb/commands/saycommand.cpp
+++ b/engines/mutationofjb/commands/saycommand.cpp
@@ -140,7 +140,7 @@ bool SayCommandParser::parse(const Common::String &line, ScriptParseContext &par
}
-Command::ExecuteResult SayCommand::execute(GameData &) {
+Command::ExecuteResult SayCommand::execute(ScriptExecutionContext &) {
// TODO: Actual implementation.
debug("%s [%s]", _lineToSay.c_str(), _voiceFile.c_str());
return Finished;
diff --git a/engines/mutationofjb/commands/saycommand.h b/engines/mutationofjb/commands/saycommand.h
index e2a1207afc..e41d10fb17 100644
--- a/engines/mutationofjb/commands/saycommand.h
+++ b/engines/mutationofjb/commands/saycommand.h
@@ -42,7 +42,7 @@ public:
_voiceFile(voiceFile),
_waitForPrevious(waitForPrevious),
_talkingAnimation(talkingAnimation) {}
- virtual ExecuteResult execute(GameData &gameData) override;
+ virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
virtual Common::String debugString() const override;
private:
Common::String _lineToSay;
diff --git a/engines/mutationofjb/commands/seqcommand.cpp b/engines/mutationofjb/commands/seqcommand.cpp
index 03d9538145..02164dcff7 100644
--- a/engines/mutationofjb/commands/seqcommand.cpp
+++ b/engines/mutationofjb/commands/seqcommand.cpp
@@ -43,8 +43,4 @@ Command *SeqCommand::next() const {
return _nextCommand;
}
-SeqCommand *SeqCommand::asSeqCommand() {
- return this;
-}
-
}
diff --git a/engines/mutationofjb/commands/seqcommand.h b/engines/mutationofjb/commands/seqcommand.h
index c3455cec89..241932a360 100644
--- a/engines/mutationofjb/commands/seqcommand.h
+++ b/engines/mutationofjb/commands/seqcommand.h
@@ -37,7 +37,6 @@ class SeqCommand : public Command {
public:
void setNextCommand(Command *nextCommand);
virtual Command *next() const override;
- virtual SeqCommand *asSeqCommand();
private:
Command *_nextCommand;
diff --git a/engines/mutationofjb/debug.cpp b/engines/mutationofjb/debug.cpp
index 99c4c7b70f..867a0210a6 100644
--- a/engines/mutationofjb/debug.cpp
+++ b/engines/mutationofjb/debug.cpp
@@ -56,6 +56,9 @@ static Common::String convertToASCII(const Common::String &str) {
Console::Console(MutationOfJBEngine *vm) : _vm(vm) {
registerCmd("listsections", WRAP_METHOD(Console, cmd_listsections));
registerCmd("showsection", WRAP_METHOD(Console, cmd_showsection));
+ registerCmd("listmacros", WRAP_METHOD(Console, cmd_listmacros));
+ registerCmd("showmacro", WRAP_METHOD(Console, cmd_showmacro));
+ registerCmd("changescene", WRAP_METHOD(Console, cmd_changescene));
}
bool Console::cmd_listsections(int argc, const char **argv) {
@@ -255,4 +258,17 @@ bool Console::cmd_showmacro(int argc, const char **argv) {
return true;
}
+bool Console::cmd_changescene(int argc, const char **argv) {
+ if (argc == 2) {
+ const uint8 sceneId = atoi(argv[1]);
+ const bool partB = argv[1][strlen(argv[1]) - 1] == 'B';
+
+ _vm->getGame().changeScene(sceneId, partB);
+ } else {
+ debugPrintf(_("changescene <scenename>\n"));
+ }
+
+ return true;
+}
+
}
diff --git a/engines/mutationofjb/debug.h b/engines/mutationofjb/debug.h
index 1dcc0fb264..2f35a9c1dc 100644
--- a/engines/mutationofjb/debug.h
+++ b/engines/mutationofjb/debug.h
@@ -39,6 +39,7 @@ private:
bool cmd_showsection(int argc, const char **argv);
bool cmd_listmacros(int argc, const char **argv);
bool cmd_showmacro(int argc, const char **argv);
+ bool cmd_changescene(int argc, const char **argv);
void showIndent(int indentLevel);
void showCommands(Command *command, int indentLevel = 0);
diff --git a/engines/mutationofjb/script.cpp b/engines/mutationofjb/script.cpp
index 7a39127728..699daeb6c3 100644
--- a/engines/mutationofjb/script.cpp
+++ b/engines/mutationofjb/script.cpp
@@ -20,7 +20,7 @@
*
*/
-#include "script.h"
+#include "mutationofjb/script.h"
#include "common/hashmap.h"
#include "common/hash-str.h"
@@ -39,6 +39,7 @@
#include "mutationofjb/commands/labelcommand.h"
#include "mutationofjb/commands/gotocommand.h"
#include "mutationofjb/commands/camefromcommand.h"
+#include "mutationofjb/game.h"
namespace MutationOfJB {
@@ -95,6 +96,24 @@ void ScriptParseContext::addConditionalCommand(ConditionalCommand *command, char
_pendingCondCommands.push_back(cmi);
}
+
+void ScriptExecutionContext::pushReturnCommand(Command *cmd) {
+ _stack.push(cmd);
+}
+
+Command *ScriptExecutionContext::popReturnCommand() {
+ if (_stack.empty()) {
+ return nullptr;
+ }
+
+ return _stack.pop();
+}
+
+GameData &ScriptExecutionContext::getGameData() {
+ return _game.getGameData();
+}
+
+
bool Script::loadFromStream(Common::SeekableReadStream &stream) {
destroy();
diff --git a/engines/mutationofjb/script.h b/engines/mutationofjb/script.h
index 64adda831e..477181b445 100644
--- a/engines/mutationofjb/script.h
+++ b/engines/mutationofjb/script.h
@@ -26,6 +26,7 @@
#include "common/array.h"
#include "common/hashmap.h"
#include "common/hash-str.h"
+#include "common/stack.h"
namespace Common {
class SeekableReadStream;
@@ -36,6 +37,8 @@ namespace MutationOfJB {
class Command;
class LabelCommand;
+class Game;
+class GameData;
class GotoCommand;
class ConditionalCommand;
typedef Common::Array<Command *> Commands;
@@ -91,6 +94,18 @@ public:
private:
};
+class ScriptExecutionContext {
+public:
+ ScriptExecutionContext(Game &game) : _game(game) {}
+ void pushReturnCommand(Command *);
+ Command *popReturnCommand();
+ GameData &getGameData();
+
+private:
+ Game &_game;
+ Common::Stack<Command *> _stack;
+};
+
class Script {
public:
bool loadFromStream(Common::SeekableReadStream &stream);