aboutsummaryrefslogtreecommitdiff
path: root/engines/draci
diff options
context:
space:
mode:
Diffstat (limited to 'engines/draci')
-rw-r--r--engines/draci/script.cpp10
-rw-r--r--engines/draci/script.h2
2 files changed, 11 insertions, 1 deletions
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp
index 17cdefe009..9d72c4ab34 100644
--- a/engines/draci/script.cpp
+++ b/engines/draci/script.cpp
@@ -583,6 +583,9 @@ void Script::talk(Common::Queue<int> &params) {
_vm->_game->setExitLoop(false);
}
+void Script::endCurrentProgram() {
+ _endProgram = true;
+}
/**
* @brief Evaluates mathematical expressions
@@ -797,6 +800,10 @@ int Script::run(GPL2Program program, uint16 offset) {
// extract low byte, i.e. the command subnumber
byte subnum = cmdpair & 0xFF;
+ // This might get set by some GPL commands via Script::endCurrentProgram()
+ // if they need a program to stop midway
+ _endProgram = false;
+
if ((cmd = findCommand(num, subnum))) {
int tmp;
@@ -828,8 +835,9 @@ int Script::run(GPL2Program program, uint16 offset) {
(this->*(cmd->_handler))(params);
}
- } while (cmd->_name != "gplend" && cmd->_name != "exit");
+ } while (cmd->_name != "gplend" && cmd->_name != "exit" && !_endProgram);
+ _endProgram = false;
_jump = oldJump;
return 0;
diff --git a/engines/draci/script.h b/engines/draci/script.h
index 9e3345cd0b..78e813da40 100644
--- a/engines/draci/script.h
+++ b/engines/draci/script.h
@@ -89,10 +89,12 @@ public:
Script(DraciEngine *vm) : _vm(vm), _jump(0) { setupCommandList(); };
int run(GPL2Program program, uint16 offset);
+ void endCurrentProgram();
private:
int _jump;
+ bool _endProgram;
/** List of all GPL commands. Initialised in the constructor. */
const GPL2Command *_commandList;