X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=main.c;h=be3f2f15ac6eec0066cb7d212c1aa457ef0bb4b4;hb=1c4097314abd4a1fbf380fba17dcd5a499a11eca;hp=36773b35572e16ccbf69ce9a47c6ff73a29d14bb;hpb=d7ae7efd3050222304192db0155773af42f347ef;p=open-adventure.git diff --git a/main.c b/main.c index 36773b3..be3f2f1 100644 --- a/main.c +++ b/main.c @@ -840,6 +840,53 @@ static void lampcheck(void) } } +static void listobjects(void) +/* Print out descriptions of objects at this location. If + * not closing and property value is negative, tally off + * another treasure. Rug is special case; once seen, its + * game.prop is 1 (dragon on it) till dragon is killed. + * Similarly for chain; game.prop is initially 1 (locked to + * bear). These hacks are because game.prop=0 is needed to + * get full score. */ +{ + if (!DARK(game.loc)) { + long obj; + ++game.abbrev[game.loc]; + for (int i=game.atloc[game.loc]; i != 0; i=game.link[i]) { + obj=i; + if (obj > NOBJECTS)obj=obj-NOBJECTS; + if (obj == STEPS && TOTING(NUGGET)) + continue; + if (game.prop[obj] < 0) { + if (game.closed) + continue; + game.prop[obj]=0; + if (obj == RUG || obj == CHAIN) + game.prop[obj]=1; + --game.tally; + /* Note: There used to be a test here to see whether the + * player had blown it so badly that he could never ever see + * the remaining treasures, and if so the lamp was zapped to + * 35 turns. But the tests were too simple-minded; things + * like killing the bird before the snake was gone (can never + * see jewelry), and doing it "right" was hopeless. E.G., + * could cross troll bridge several times, using up all + * available treasures, breaking vase, using coins to buy + * batteries, etc., and eventually never be able to get + * across again. If bottle were left on far side, could then + * never get eggs or trident, and the effects propagate. So + * the whole thing was flushed. anyone who makes such a + * gross blunder isn't likely to find everything else anyway + * (so goes the rationalisation). */ + } + int kk=game.prop[obj]; + if (obj == STEPS && game.loc == game.fixed[STEPS]) + kk=1; + PSPEAK(obj,kk); + } + } +} + static bool do_command(FILE *cmdin) { long KQ, VERB, KK, V1, V2; @@ -897,52 +944,15 @@ L2000: } if (TOTING(BEAR))RSPEAK(141); newspeak(msg); - KMOD=1; if (FORCED(game.loc)) { - goto L8; + if (playermove(cmdin, VERB, 1)) + return true; + else + goto L2000; } if (game.loc == 33 && PCT(25) && !game.closng)RSPEAK(7); - /* Print out descriptions of objects at this location. If - * not closing and property value is negative, tally off - * another treasure. Rug is special case; once seen, its - * game.prop is 1 (dragon on it) till dragon is killed. - * Similarly for chain; game.prop is initially 1 (locked to - * bear). These hacks are because game.prop=0 is needed to - * get full score. */ - - if (DARK(game.loc)) goto L2012; - ++game.abbrev[game.loc]; - i=game.atloc[game.loc]; -L2004: - if (i == 0) - goto L2012; - obj=i; - if (obj > NOBJECTS)obj=obj-NOBJECTS; - if (obj == STEPS && TOTING(NUGGET)) goto L2008; - if (game.prop[obj] >= 0) goto L2006; - if (game.closed) goto L2008; - game.prop[obj]=0; - if (obj == RUG || obj == CHAIN)game.prop[obj]=1; - --game.tally; - /* Note: There used to be a test here to see whether the player had blown it - * so badly that he could never ever see the remaining treasures, and if so - * the lamp was zapped to 35 turns. But the tests were too simple-minded; - * things like killing the bird before the snake was gone (can never see - * jewelry), and doing it "right" was hopeless. E.G., could cross troll - * bridge several times, using up all available treasures, breaking vase, - * using coins to buy batteries, etc., and eventually never be able to get - * across again. If bottle were left on far side, could then never get eggs - * or trident, and the effects propagate. So the whole thing was flushed. - * anyone who makes such a gross blunder isn't likely to find everything - * else anyway (so goes the rationalisation). */ -L2006: - KK=game.prop[obj]; - if (obj == STEPS && game.loc == game.fixed[STEPS])KK=1; - PSPEAK(obj,KK); -L2008: - i=game.link[i]; - goto L2004; + listobjects(); L2012: VERB=0; @@ -1047,7 +1057,11 @@ L2630: KQ=i/1000+1; switch (KQ-1) { - case 0: goto L8; + case 0: + if (playermove(cmdin, VERB, KMOD)) + return true; + else + goto L2000; case 1: part=unknown; obj = KMOD; break; case 2: part=intransitive; VERB = KMOD; break; case 3: RSPEAK(KMOD); goto L2012; @@ -1056,8 +1070,11 @@ L2630: Laction: switch (action(cmdin, part, VERB, obj)) { - case 2: return true; - case 8: KMOD=NUL; goto L8; + case 2: + return true; + case 8: + playermove(cmdin, VERB, NUL); + return true; case 2000: goto L2000; case 2012: goto L2012; case 2600: goto L2600; @@ -1084,12 +1101,6 @@ Laction: default: BUG(99); } - - /* no fallthrough here */ - - /* Figure out the new location */ -L8: if (playermove(cmdin, VERB, KMOD)) - return true; - else - goto L2000; } + +/* EMD */