X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=main.c;h=f83c4e0dccb36ddc8e6d9a5e3b80ad08c33dcdb2;hb=5f7ce870405316959d22ea4750e87c26f53fb416;hp=94f2b45b9fe30d5c2251e9d9b431cee7af9c028e;hpb=f911e4245357c9049ae3bd171922bdb33e4e8f84;p=open-adventure.git diff --git a/main.c b/main.c index 94f2b45..f83c4e0 100644 --- a/main.c +++ b/main.c @@ -55,8 +55,13 @@ char *myreadline(const char *prompt) * logfiles for testing purposes. */ /* Normal case - no script arguments */ - if (settings.argc == 0) - return readline(prompt); + if (settings.argc == 0) { + char *ln = readline(prompt); + if (ln == NULL) { + fputs(prompt, stdout); + } + return ln; + } char *buf = malloc(LINESIZE + 1); for (;;) { @@ -82,9 +87,9 @@ char *myreadline(const char *prompt) } else { char *ln = fgets(buf, LINESIZE, settings.scriptfp); if (ln != NULL) { - fputs(PROMPT, stdout); + fputs(prompt, stdout); fputs(ln, stdout); - return ln; + return ln; } } } @@ -1074,7 +1079,7 @@ static bool do_move(void) return true; } -static bool do_command() +static bool do_command(void) /* Get and execute a command */ { static command_t command; @@ -1125,6 +1130,12 @@ static bool do_command() if (!get_command_input(&command)) return false; + /* Every input, check "foobar" flag. If zero, nothing's going + * on. If pos, make neg. If neg, he skipped a word, so make it + * zero. + */ + game.foobar = (game.foobar > WORD_EMPTY) ? -game.foobar : WORD_EMPTY; + ++game.turns; preprocess_command(&command); }