GLK: ALAN3: Hook up empty lines to forfeit longjmp replacement

This commit is contained in:
Paul Gilbert 2019-06-29 14:56:31 -07:00
parent c833d39ccf
commit 55b93f5a20
5 changed files with 31 additions and 27 deletions

View File

@ -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++) {

View File

@ -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;

View File

@ -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

View File

@ -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?

View File

@ -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