aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2019-06-22 21:04:39 -0700
committerPaul Gilbert2019-06-22 22:03:06 -0700
commit3683e74d65273126afd3d7a101c656b7b52b8580 (patch)
tree2aad93fdfc6365a63b620c1e20527ac4b75a6354 /engines
parent9aadb2726732e1fcd517088bdcaff60a8a49710d (diff)
downloadscummvm-rg350-3683e74d65273126afd3d7a101c656b7b52b8580.tar.gz
scummvm-rg350-3683e74d65273126afd3d7a101c656b7b52b8580.tar.bz2
scummvm-rg350-3683e74d65273126afd3d7a101c656b7b52b8580.zip
GLK: ALAN2: Set up main game loop for restarting game
Diffstat (limited to 'engines')
-rw-r--r--engines/glk/alan2/alan2.cpp2
-rw-r--r--engines/glk/alan2/alan2.h12
-rw-r--r--engines/glk/alan2/main.cpp42
3 files changed, 35 insertions, 21 deletions
diff --git a/engines/glk/alan2/alan2.cpp b/engines/glk/alan2/alan2.cpp
index 1ae5ddad35..7d5040ca67 100644
--- a/engines/glk/alan2/alan2.cpp
+++ b/engines/glk/alan2/alan2.cpp
@@ -39,7 +39,7 @@ namespace Alan2 {
Alan2 *g_vm = nullptr;
Alan2::Alan2(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc),
- vm_exited_cleanly(false) {
+ vm_exited_cleanly(false), _restartFlag(false) {
g_vm = this;
}
diff --git a/engines/glk/alan2/alan2.h b/engines/glk/alan2/alan2.h
index ac67364910..9d007d0bde 100644
--- a/engines/glk/alan2/alan2.h
+++ b/engines/glk/alan2/alan2.h
@@ -35,6 +35,8 @@ namespace Alan2 {
* Alan2 game interpreter
*/
class Alan2 : public GlkAPI {
+private:
+ bool _restartFlag;
public:
bool vm_exited_cleanly;
Common::String _advName;
@@ -65,6 +67,16 @@ public:
void runGame();
/**
+ * Flag for the game to restart
+ */
+ void setRestart(bool flag) { _restartFlag = flag; }
+
+ /**
+ * Returns whether the game should restart
+ */
+ bool shouldRestart() const { return _restartFlag; }
+
+ /**
* Returns the running interpreter type
*/
virtual InterpreterType getInterpreterType() const override {
diff --git a/engines/glk/alan2/main.cpp b/engines/glk/alan2/main.cpp
index 2dea4519f7..6e6133db87 100644
--- a/engines/glk/alan2/main.cpp
+++ b/engines/glk/alan2/main.cpp
@@ -1415,29 +1415,31 @@ void run() {
// Set default line and column
col = lin = 1;
- //setjmp(restart_label); /* Return here if he wanted to restart */
-
- init(); /* Load, initialise and start the adventure */
-
- Context ctx;
- for (;;) {
- if (!ctx._break) {
- if (dbgflg)
- debug();
-
- eventchk();
- cur.tick++;
- }
+ while (!g_vm->shouldQuit()) {
+ // Load, initialise and start the adventure
+ g_vm->setRestart(false);
+ init();
+
+ Context ctx;
+ while (!g_vm->shouldQuit()) {
+ if (!ctx._break) {
+ if (dbgflg)
+ debug();
+
+ eventchk();
+ cur.tick++;
+ }
- // Execution ends up here after calls to the error method
+ // Execution ends up here after calls to the error method
- // Move all characters
- ctx._break = false;
- for (cur.act = ACTMIN; cur.act <= (int)ACTMAX && !ctx._break; cur.act++) {
- movactor(ctx);
+ // Move all characters
+ ctx._break = false;
+ for (cur.act = ACTMIN; cur.act <= (int)ACTMAX && !ctx._break; cur.act++) {
+ movactor(ctx);
- if (g_vm->shouldQuit())
- return;
+ if (g_vm->shouldQuit())
+ return;
+ }
}
}
}