Address GitLab issue #28: Advent hangs on some inputs

This commit is contained in:
Eric S. Raymond 2017-07-20 12:24:02 -04:00
parent b7af7b9e87
commit 342994376a
4 changed files with 21 additions and 19 deletions

View file

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

17
main.c
View file

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

View file

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

View file

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