From: Eric S. Raymond Date: Thu, 20 Jul 2017 16:24:02 +0000 (-0400) Subject: Address GitLab issue #28: Advent hangs on some inputs X-Git-Tag: 1.3~32 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=342994376a6cc0fc9623cece2b9b85a7557ca47f;p=open-adventure.git Address GitLab issue #28: Advent hangs on some inputs --- diff --git a/actions.c b/actions.c index bc442de..ca243b6 100644 --- a/actions.c +++ b/actions.c @@ -1305,20 +1305,7 @@ int action(struct command_t *command) * location. */ if (HERE(command->obj)) /* FALL THROUGH */; - else if (command->obj == GRATE) { - if (game.loc == LOC_START || - game.loc == LOC_VALLEY || - game.loc == LOC_SLIT) { - command->obj = DEPRESSION; - } - if (game.loc == LOC_COBBLE || - game.loc == LOC_DEBRIS || - game.loc == LOC_AWKWARD || - game.loc == LOC_BIRD || - game.loc == LOC_PITTOP) { - command->obj = ENTRANCE; - } - } else if (command->obj == DWARF && atdwrf(game.loc) > 0) + else if (command->obj == DWARF && atdwrf(game.loc) > 0) /* FALL THROUGH */; else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc)) diff --git a/main.c b/main.c index 2a2f99e..ee22912 100644 --- a/main.c +++ b/main.c @@ -1126,7 +1126,22 @@ Lclearobj: } if (command.type1 == OBJECT) { - if (!((command.id1 != WATER && command.id1 != OIL) || (command.id2 != PLANT && command.id2 != DOOR))) { + if (command.id1 == GRATE) { + command.type1 = MOTION; + if (game.loc == LOC_START || + game.loc == LOC_VALLEY || + game.loc == LOC_SLIT) { + command.id1 = DEPRESSION; + } + if (game.loc == LOC_COBBLE || + game.loc == LOC_DEBRIS || + game.loc == LOC_AWKWARD || + game.loc == LOC_BIRD || + game.loc == LOC_PITTOP) { + command.id1 = ENTRANCE; + } + } + if (!((command.id1 != WATER && command.id1 != OIL) || (command.id2 != PLANT && command.id2 != DOOR))) { if (AT(command.id2)) { command.id2 = POUR; command.type2 = ACTION; diff --git a/tests/carrybird.chk b/tests/carrybird.chk index 64ffe64..654577a 100644 --- a/tests/carrybird.chk +++ b/tests/carrybird.chk @@ -52,7 +52,7 @@ A three foot black rod with a rusty star on an end lies nearby. > eat grate -Don't be ridiculous! +I see no grate here. > w diff --git a/tests/illformed.chk b/tests/illformed.chk index f777412..6f74957 100644 --- a/tests/illformed.chk +++ b/tests/illformed.chk @@ -116,7 +116,7 @@ You're in front of building. > eat grate -Don't be ridiculous! +I see no grate here. > eat building @@ -513,11 +513,11 @@ Sorry, I don't know the word "frob". > read grate -I'm afraid I don't understand. +I see no grate here. > grate -What do you want to do with the grate? +I see no grate here. > pour bottle