Permalink
Browse files

MUTATIONOFJB: Add changescene debug command and fix macro debug comma…

…nds.
  • Loading branch information...
LubomirR authored and sev- committed Mar 22, 2018
1 parent 63c0dac commit e1d173ed7541f9da79f60a65d974da3ebbb29e7a
Showing with 108 additions and 60 deletions.
  1. +3 −2 engines/mutationofjb/commands/additemcommand.cpp
  2. +1 −1 engines/mutationofjb/commands/additemcommand.h
  3. +3 −2 engines/mutationofjb/commands/camefromcommand.cpp
  4. +1 −1 engines/mutationofjb/commands/camefromcommand.h
  5. +10 −8 engines/mutationofjb/commands/changecommand.cpp
  6. +4 −4 engines/mutationofjb/commands/changecommand.h
  7. +0 −4 engines/mutationofjb/commands/command.cpp
  8. +3 −7 engines/mutationofjb/commands/command.h
  9. +3 −2 engines/mutationofjb/commands/endblockcommand.cpp
  10. +4 −1 engines/mutationofjb/commands/endblockcommand.h
  11. +1 −1 engines/mutationofjb/commands/gotocommand.cpp
  12. +1 −1 engines/mutationofjb/commands/gotocommand.h
  13. +3 −3 engines/mutationofjb/commands/ifcommand.cpp
  14. +1 −1 engines/mutationofjb/commands/ifcommand.h
  15. +2 −2 engines/mutationofjb/commands/ifitemcommand.cpp
  16. +1 −1 engines/mutationofjb/commands/ifitemcommand.h
  17. +2 −2 engines/mutationofjb/commands/ifpiggycommand.cpp
  18. +1 −1 engines/mutationofjb/commands/ifpiggycommand.h
  19. +1 −1 engines/mutationofjb/commands/labelcommand.cpp
  20. +1 −1 engines/mutationofjb/commands/labelcommand.h
  21. +3 −2 engines/mutationofjb/commands/removeallitemscommand.cpp
  22. +1 −1 engines/mutationofjb/commands/removeallitemscommand.h
  23. +3 −2 engines/mutationofjb/commands/removeitemcommand.cpp
  24. +1 −1 engines/mutationofjb/commands/removeitemcommand.h
  25. +1 −1 engines/mutationofjb/commands/saycommand.cpp
  26. +1 −1 engines/mutationofjb/commands/saycommand.h
  27. +0 −4 engines/mutationofjb/commands/seqcommand.cpp
  28. +0 −1 engines/mutationofjb/commands/seqcommand.h
  29. +16 −0 engines/mutationofjb/debug.cpp
  30. +1 −0 engines/mutationofjb/debug.h
  31. +20 −1 engines/mutationofjb/script.cpp
  32. +15 −0 engines/mutationofjb/script.h
@@ -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;
}

@@ -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;
@@ -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;
}
@@ -37,7 +37,7 @@ class CameFromCommandParser : public ConditionalCommandParser {
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;
@@ -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;
}
@@ -113,7 +113,7 @@ class ChangeDoorCommand : public ChangeCommand {
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 @@ class ChangeObjectCommand : public ChangeCommand {
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 @@ class ChangeStaticCommand : public ChangeCommand {
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 @@ class ChangeSceneCommand : public ChangeCommand {
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;
};

@@ -31,8 +31,4 @@ CommandParser::~CommandParser() {}

Command::~Command() {}

SeqCommand *Command::asSeqCommand() {
return nullptr;
}

}
@@ -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 @@ class Command {

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;
};
}
@@ -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 {
@@ -49,11 +49,14 @@ class EndBlockCommandParser : public CommandParser {

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;
};

}
@@ -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;
@@ -43,7 +43,7 @@ class GotoCommand : public Command {

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:
@@ -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;
}
@@ -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:
@@ -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;
}
@@ -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:
@@ -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;
}
@@ -38,7 +38,7 @@ class IfPiggyCommandParser : public ConditionalCommandParser {

class IfPiggyCommand : public ConditionalCommand {
public:
virtual ExecuteResult execute(GameData &gameData) override;
virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
virtual Common::String debugString() const;

private:
@@ -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;
@@ -40,7 +40,7 @@ class LabelCommand : public SeqCommand {
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;
@@ -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;
}

@@ -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:
};
@@ -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;
}

@@ -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;
@@ -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;
@@ -42,7 +42,7 @@ class SayCommand : public SeqCommand {
_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;
Oops, something went wrong.

0 comments on commit e1d173e

Please sign in to comment.