diff options
author | Paul Gilbert | 2019-06-29 14:56:31 -0700 |
---|---|---|
committer | Paul Gilbert | 2019-07-06 15:27:08 -0700 |
commit | 55b93f5a20bb352b0388c8cc1802437a2fcc6ce9 (patch) | |
tree | 914f0e7c158f709260c240819b968fbe0099cf12 /engines/glk | |
parent | c833d39ccf8ec2493929afaa7066113802fb90b0 (diff) | |
download | scummvm-rg350-55b93f5a20bb352b0388c8cc1802437a2fcc6ce9.tar.gz scummvm-rg350-55b93f5a20bb352b0388c8cc1802437a2fcc6ce9.tar.bz2 scummvm-rg350-55b93f5a20bb352b0388c8cc1802437a2fcc6ce9.zip |
GLK: ALAN3: Hook up empty lines to forfeit longjmp replacement
Diffstat (limited to 'engines/glk')
-rw-r--r-- | engines/glk/alan3/main.cpp | 25 | ||||
-rw-r--r-- | engines/glk/alan3/parse.cpp | 7 | ||||
-rw-r--r-- | engines/glk/alan3/parse.h | 3 | ||||
-rw-r--r-- | engines/glk/alan3/scan.cpp | 20 | ||||
-rw-r--r-- | engines/glk/alan3/scan.h | 3 |
5 files changed, 31 insertions, 27 deletions
diff --git a/engines/glk/alan3/main.cpp b/engines/glk/alan3/main.cpp index 4fd8cf6a3e..ad690c62f1 100644 --- a/engines/glk/alan3/main.cpp +++ b/engines/glk/alan3/main.cpp @@ -656,20 +656,23 @@ static void moveActor(CONTEXT, int theActor) { StepEntry *step; Aint previousInstance = current.instance; + if (context._break) { + // forfeit setjmp replacement destination + assert(context._label == "forfeit"); + context.clear(); + current.instance = previousInstance; + return; + } + current.actor = theActor; current.instance = theActor; current.location = where(theActor, TRANSITIVE); - if (context._break || theActor == (int)HERO) { - if (context._break) { - // Forfeit jump destination - assert(context._label == "forfeit"); - context.clear(); - } else { - // Ask him! - parse(); - capitalize = TRUE; - fail = FALSE; // fail only aborts one actor - } + + if (theActor == (int)HERO) { + // Ask him! + CALL0(parse) + capitalize = TRUE; + fail = FALSE; // fail only aborts one actor } else if (admin[theActor].script != 0) { for (scr = (ScriptEntry *) pointerTo(header->scriptTableAddress); !isEndOfArray(scr); scr++) { diff --git a/engines/glk/alan3/parse.cpp b/engines/glk/alan3/parse.cpp index f04b91040c..da9d7594f9 100644 --- a/engines/glk/alan3/parse.cpp +++ b/engines/glk/alan3/parse.cpp @@ -1437,7 +1437,7 @@ static void parseInstanceCommand(Parameter parameters[], Parameter multipleParam /*======================================================================*/ -void parse(void) { +void parse(CONTEXT) { /* longjmp's ahead so these need to survive to not leak memory */ static Parameter *parameters = NULL; static Parameter *multipleParameters = NULL; @@ -1446,9 +1446,10 @@ void parse(void) { if (endOfWords(currentWordIndex)) { currentWordIndex = 0; - scan(); - } else if (anyOutput) + CALL0(scan) + } else if (anyOutput) { para(); + } capitalize = TRUE; diff --git a/engines/glk/alan3/parse.h b/engines/glk/alan3/parse.h index 7425301081..2737183eaa 100644 --- a/engines/glk/alan3/parse.h +++ b/engines/glk/alan3/parse.h @@ -27,13 +27,14 @@ #include "glk/alan3/types.h" #include "glk/alan3/params.h" +#include "glk/alan3/jumps.h" namespace Glk { namespace Alan3 { /* FUNCTIONS */ -extern void parse(void); +extern void parse(CONTEXT); extern void initParsing(void); } // End of namespace Alan3 diff --git a/engines/glk/alan3/scan.cpp b/engines/glk/alan3/scan.cpp index dcfcc6f603..284f28f13c 100644 --- a/engines/glk/alan3/scan.cpp +++ b/engines/glk/alan3/scan.cpp @@ -134,7 +134,7 @@ static char *gettoken(char *txtBuf) { /*----------------------------------------------------------------------*/ // TODO replace dependency to exe.c with injection of quitGame() and undo() -static void getLine(void) { +static void getLine(CONTEXT) { para(); do { statusline(); @@ -160,14 +160,10 @@ static void getLine(void) { g_vm->glk_put_char_stream(logFile, '\n'); } /* If the player input an empty command he forfeited his command */ -#ifdef TODO if (strlen(buf) == 0) { clearWordList(playerWords); - longjmp(forfeitLabel, 0); + LONG_JUMP_LABEL("forfeit") } -#else - syserr("TODO: empty command"); -#endif strcpy(isobuf, buf); token = gettoken(isobuf); @@ -190,7 +186,7 @@ static void getLine(void) { /*======================================================================*/ -void scan(void) { +void scan(CONTEXT) { int i; int w; @@ -198,11 +194,13 @@ void scan(void) { /* Player used '.' to separate commands. Read next */ para(); token = gettoken(NULL); /* Or did he just finish the command with a full stop? */ - if (token == NULL) - getLine(); + if (token == NULL) { + CALL0(getLine) + } continued = FALSE; - } else - getLine(); + } else { + CALL0(getLine) + } freeLiterals(); playerWords[0].code = 0; // TODO This means what? diff --git a/engines/glk/alan3/scan.h b/engines/glk/alan3/scan.h index 04d893765c..6f565c0559 100644 --- a/engines/glk/alan3/scan.h +++ b/engines/glk/alan3/scan.h @@ -26,6 +26,7 @@ /* Player input scanner for ALAN interpreter module. */ #include "glk/alan3/types.h" +#include "glk/alan3/jumps.h" namespace Glk { namespace Alan3 { @@ -37,7 +38,7 @@ extern bool continued; /* FUNCTIONS */ extern void forceNewPlayerInput(); -extern void scan(); +extern void scan(CONTEXT); } // End of namespace Alan3 } // End of namespace Glk |