X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=main.c;h=5288e43b24f2aab08821096da64baff39afe2ff8;hb=c366ddb7334cf85dba1f0dc75a68a8a094960aa3;hp=920bea0f4d9daae78ab29eca420e247468e2e5d9;hpb=a02b3879998e78555852f4a81a19e80694e38cdc;p=open-adventure.git diff --git a/main.c b/main.c index 920bea0..5288e43 100644 --- a/main.c +++ b/main.c @@ -5,12 +5,13 @@ * is a result of running the original Fortran IV source through a * home-brew Fortran-to-C converter.) * - * Now that the code has been restructured into idiomatic C, the following - * is more appropriate: + * Now that the code has been restructured into something much closer + * to idiomatic C, the following is more appropriate: * - * ESR apologizes for the remaing gotos (now confined to two functions in this - * file - they used to be *everywhere*), and the offensive globals. Applying - * the Structured Program Theorem can be hard. + * ESR apologizes for the remaing gotos (now confined to two functions + * in this file - there used to be hundreds of them, *everywhere*), + * and the offensive globals. Applying the Structured Program Theorem + * can be hard. */ #include #include @@ -43,6 +44,8 @@ long WD1, WD1X, WD2, WD2X; FILE *logfp; bool oldstyle = false; +bool editline = true; +bool prompt = true; lcg_state lcgstate; extern void initialise(); @@ -77,9 +80,9 @@ int main(int argc, char *argv[]) /* Options. */ - while ((ch = getopt(argc, argv, "l:o")) != EOF) { + while ((ch = getopt(argc, argv, "l:os")) != EOF) { switch (ch) { -case 'l': + case 'l': logfp = fopen(optarg, "w"); if (logfp == NULL) fprintf(stderr, @@ -89,6 +92,10 @@ case 'l': break; case 'o': oldstyle = true; + editline = prompt = false; + break; + case 's': + editline = false; break; } } @@ -599,6 +606,7 @@ static bool playermove(FILE *cmdin, token_t verb, int motion) } LL=LL/1000; + L12: for (;;) { game.newloc=LL/1000; motion=MOD(game.newloc,100); @@ -613,7 +621,6 @@ static bool playermove(FILE *cmdin, token_t verb, int motion) } else if (game.prop[motion] != game.newloc/100-3) break; - L12: do { if (TRAVEL[KK] < 0)BUG(25); ++KK; @@ -647,6 +654,12 @@ static bool playermove(FILE *cmdin, token_t verb, int motion) * plover-passage to get it out. Having dropped it, go back and * pretend he wasn't carrying it after all. */ DROP(EMRALD,game.loc); + do { + if (TRAVEL[KK] < 0)BUG(25); + ++KK; + game.newloc=labs(TRAVEL[KK])/1000; + } while + (game.newloc == LL); goto L12; case 3: /* Travel 303. Troll bridge. Must be done only as special