diff options
author | Paul Gilbert | 2019-10-06 17:44:18 -0700 |
---|---|---|
committer | Paul Gilbert | 2019-10-07 19:01:52 -0700 |
commit | 1a78b67d08d206c58c841e7540eb04bdcd032b6e (patch) | |
tree | 466d2280fa2f9adae0cfde4e4f970190ebc045ef /engines/glk | |
parent | fecf1b3834cca049c82bdbb764dffdd50a22d031 (diff) | |
download | scummvm-rg350-1a78b67d08d206c58c841e7540eb04bdcd032b6e.tar.gz scummvm-rg350-1a78b67d08d206c58c841e7540eb04bdcd032b6e.tar.bz2 scummvm-rg350-1a78b67d08d206c58c841e7540eb04bdcd032b6e.zip |
GLK: JACL: Graceful exit when error occurs
Diffstat (limited to 'engines/glk')
-rw-r--r-- | engines/glk/jacl/interpreter.cpp | 12 | ||||
-rw-r--r-- | engines/glk/jacl/jacl.cpp | 1 | ||||
-rw-r--r-- | engines/glk/jacl/jacl_main.cpp | 8 | ||||
-rw-r--r-- | engines/glk/jacl/loader.cpp | 3 | ||||
-rw-r--r-- | engines/glk/jacl/utils.cpp | 5 |
5 files changed, 22 insertions, 7 deletions
diff --git a/engines/glk/jacl/interpreter.cpp b/engines/glk/jacl/interpreter.cpp index 94fa45f3e8..0488d0a381 100644 --- a/engines/glk/jacl/interpreter.cpp +++ b/engines/glk/jacl/interpreter.cpp @@ -363,6 +363,9 @@ int execute(const char *funcname) { int object_1, object_2; + if (g_vm->shouldQuit()) + return 0; + /* THESE VARIABLE KEEP TRACK OF if AND endif COMMANDS TO DECIDE WHETHER *THE CURRENT LINE OF CODE SHOULD BE EXECUTED OR NOT */ int currentLevel = 0; @@ -389,6 +392,8 @@ int execute(const char *funcname) { #ifdef GLK push_stack(g_vm->glk_stream_get_position(game_stream)); + if (g_vm->shouldQuit()) + return FALSE; #else push_stack(ftell(file)); #endif @@ -1163,6 +1168,7 @@ int execute(const char *funcname) { } } else if (!strcmp(word[0], "terminate")) { terminate(0); + return 0; } else if (!strcmp(word[0], "more")) { if (word[1] == NULL) { more("[MORE]"); @@ -1295,6 +1301,7 @@ int execute(const char *funcname) { clrscrn(); } else if (!strcmp(word[0], "terminate")) { terminate(0); + return; } else if (!strcmp(word[0], "more")) { if (word[1] == NULL) { more("[MORE]"); @@ -2355,6 +2362,9 @@ int execute(const char *funcname) { } #ifdef GLK + if (g_vm->shouldQuit()) + return 0; + before_command = g_vm->glk_stream_get_position(game_stream); glk_get_bin_line_stream(game_stream, text_buffer, (glui32) 1024); #else @@ -2716,6 +2726,7 @@ void push_stack(int32 file_pointer) { if (stack == STACK_SIZE) { log_error("Stack overflow.", PLUS_STDERR); terminate(45); + return; } else { backup[stack].infile = infile; infile = NULL; @@ -2851,6 +2862,7 @@ void push_proxy() { if (proxy_stack == STACK_SIZE) { log_error("Stack overflow.", PLUS_STDERR); terminate(45); + return; } else { proxy_backup[proxy_stack].start_of_this_command = start_of_this_command; proxy_backup[proxy_stack].start_of_last_command = start_of_last_command; diff --git a/engines/glk/jacl/jacl.cpp b/engines/glk/jacl/jacl.cpp index c0530339ee..86b7c72110 100644 --- a/engines/glk/jacl/jacl.cpp +++ b/engines/glk/jacl/jacl.cpp @@ -42,7 +42,6 @@ void JACL::runGame() { // Open up the game file as a stream, and play the game game_stream = _streams->openStream(&_gameFile); glk_main(); - glk_stream_close(game_stream); } bool JACL::initialize() { diff --git a/engines/glk/jacl/jacl_main.cpp b/engines/glk/jacl/jacl_main.cpp index 00fa706210..c277f8372f 100644 --- a/engines/glk/jacl/jacl_main.cpp +++ b/engines/glk/jacl/jacl_main.cpp @@ -214,6 +214,7 @@ void glk_main() { * OPEN GLK WINDOW, OUTPUT THE ERROR MESSAGE AND EXIT */ log_error(error_buffer, FALSE); terminate(200); + return; } // INTIALISE THE CSV PARSER @@ -257,6 +258,7 @@ void glk_main() { if (object[2] == NULL) { log_error(CANT_RUN, PLUS_STDERR); terminate(43); + return; } /* DUMMY RETRIEVE OF 'HERE' FOR TESTING OF GAME STATE */ @@ -265,7 +267,7 @@ void glk_main() { eachturn(); /* TOP OF COMMAND LOOP */ - do { + while (!g_vm->shouldQuit()) { int gotline; event_t ev; @@ -423,8 +425,7 @@ void glk_main() { command_encapsulate(); preparse(); } - - } while (TRUE); + } } void preparse() { @@ -477,6 +478,7 @@ void word_check() { newline(); execute("+score"); terminate(0); + return; } else { write_text(cstring_resolve("RETURN_GAME")->value); } diff --git a/engines/glk/jacl/loader.cpp b/engines/glk/jacl/loader.cpp index c969facd36..e5ad3d2522 100644 --- a/engines/glk/jacl/loader.cpp +++ b/engines/glk/jacl/loader.cpp @@ -319,6 +319,7 @@ void read_gamefile() { if (objects == MAX_OBJECTS) { log_error(MAXIMUM_EXCEEDED, PLUS_STDERR); terminate(47); + return; } else { if ((object[objects] = (struct object_type *) malloc(sizeof(struct object_type))) == NULL) @@ -614,6 +615,7 @@ void read_gamefile() { if (errors) { totalerrs(errors); terminate(48); + return; } /************************************************************************* @@ -995,6 +997,7 @@ void read_gamefile() { if (errors) { totalerrs(errors); terminate(48); + return; } } diff --git a/engines/glk/jacl/utils.cpp b/engines/glk/jacl/utils.cpp index f9513223fa..48ede2babd 100644 --- a/engines/glk/jacl/utils.cpp +++ b/engines/glk/jacl/utils.cpp @@ -74,15 +74,14 @@ int get_here() { if (player < 1 || player > objects) { badplrrun(player); terminate(44); + return 0; } else if (object[player]->PARENT < 1 || object[player]->PARENT > objects || object[player]->PARENT == player) { badparrun(); terminate(44); + return 0; } else { return (object[player]->PARENT); } - - /* SHOULDN'T GET HERE, JUST TRYING TO KEEP VisualC++ HAPPY */ - return 1; } char *strip_return(char *string) { |