aboutsummaryrefslogtreecommitdiff
path: root/engines/glk
diff options
context:
space:
mode:
Diffstat (limited to 'engines/glk')
-rw-r--r--engines/glk/alan2/exe.cpp2
-rw-r--r--engines/glk/alan2/main.cpp39
-rw-r--r--engines/glk/alan2/parse.cpp9
-rw-r--r--engines/glk/alan2/readline.cpp4
4 files changed, 36 insertions, 18 deletions
diff --git a/engines/glk/alan2/exe.cpp b/engines/glk/alan2/exe.cpp
index 1cccf3d32d..9b06943257 100644
--- a/engines/glk/alan2/exe.cpp
+++ b/engines/glk/alan2/exe.cpp
@@ -236,7 +236,7 @@ void quit()
char choices[10];
para();
- while (TRUE) {
+ while (!g_vm->shouldQuit()) {
col = 1;
statusline();
prmsg(M_QUITACTION);
diff --git a/engines/glk/alan2/main.cpp b/engines/glk/alan2/main.cpp
index a508041f7d..63ab5456f9 100644
--- a/engines/glk/alan2/main.cpp
+++ b/engines/glk/alan2/main.cpp
@@ -1763,7 +1763,9 @@ static void movactor()
cur.loc = where(cur.act);
if (cur.act == HERO) {
parse();
- fail = FALSE; /* fail only aborts one actor */
+ if (g_vm->shouldQuit())
+ return;
+ fail = FALSE; /* fail only aborts one actor */
rules();
} else if (act->script != 0) {
for (scr = (ScrElem *) addrTo(act->scradr); !endOfTable(scr); scr++)
@@ -1902,30 +1904,33 @@ static void openFiles()
*/
void run() {
- openFiles();
+ openFiles();
- // Set default line and column
- col = lin = 1;
+ // Set default line and column
+ col = lin = 1;
- //setjmp(restart_label); /* Return here if he wanted to restart */
+ //setjmp(restart_label); /* Return here if he wanted to restart */
- init(); /* Load, initialise and start the adventure */
+ init(); /* Load, initialise and start the adventure */
- while (TRUE) {
+ while (TRUE) {
#ifdef MALLOC
- if (malloc_verify() == 0) syserr("Error in heap.");
+ if (malloc_verify() == 0) syserr("Error in heap.");
#endif
- if (dbgflg)
- debug();
+ if (dbgflg)
+ debug();
- eventchk();
- cur.tick++;
-// (void) setjmp(jmpbuf);
+ eventchk();
+ cur.tick++;
+ // (void) setjmp(jmpbuf);
- /* Move all characters */
- for (cur.act = ACTMIN; cur.act <= ACTMAX; cur.act++)
- movactor();
- }
+ // Move all characters
+ for (cur.act = ACTMIN; cur.act <= ACTMAX; cur.act++) {
+ movactor();
+ if (g_vm->shouldQuit())
+ return;
+ }
+ }
}
} // End of namespace Alan2
diff --git a/engines/glk/alan2/parse.cpp b/engines/glk/alan2/parse.cpp
index 4e54c5cd6d..41a442438c 100644
--- a/engines/glk/alan2/parse.cpp
+++ b/engines/glk/alan2/parse.cpp
@@ -21,6 +21,7 @@
*/
#include <string>
+#include "glk/alan2/alan2.h"
#include "glk/alan2/types.h"
#ifdef USE_READLINE
@@ -212,6 +213,9 @@ static void agetline()
fprintf(logfil, "> ");
#ifdef USE_READLINE
if (!readline(buf)) {
+ if (g_vm->shouldQuit())
+ return;
+
newline();
quit();
}
@@ -257,6 +261,9 @@ static void scan()
char *str;
agetline();
+ if (g_vm->shouldQuit())
+ return;
+
wrds[0] = 0;
for (i = 0; i < litCount; i++)
if (litValues[i].type == TYPSTR && litValues[i].value != 0)
@@ -820,6 +827,8 @@ void parse()
if (wrds[wrdidx] == EOF) {
wrdidx = 0;
scan();
+ if (g_vm->shouldQuit())
+ return;
} else if (anyOutput)
para();
diff --git a/engines/glk/alan2/readline.cpp b/engines/glk/alan2/readline.cpp
index c96b26c13d..5f1192df5a 100644
--- a/engines/glk/alan2/readline.cpp
+++ b/engines/glk/alan2/readline.cpp
@@ -53,7 +53,11 @@ Boolean readline(char usrbuf[])
g_vm->glk_select(&event);
if (evtype_Arrange == event.type)
statusline();
+ if (g_vm->shouldQuit())
+ return false;
+
} while (event.type != evtype_LineInput);
+
usrbuf[event.val1] = 0;
return TRUE;
}