Canonicalize OV commands to VO form.

Allows us to get rid of some obscure logic that causes an unnecessary
word shift. One error message changes in a benign way.
This commit is contained in:
Eric S. Raymond 2017-08-03 15:02:41 -04:00
parent cfa37c83a7
commit 87c6d3fb1e
3 changed files with 12 additions and 3 deletions

View file

@ -1360,8 +1360,6 @@ int action(command_t command)
return GO_CLEAROBJ;
}
if (command.word[1].id != WORD_EMPTY && command.word[1].id != WORD_NOT_FOUND)
return GO_WORD2;
if (command.verb != 0)
command.part = transitive;
}

11
main.c
View file

@ -1134,6 +1134,17 @@ Lclearobj:
command.word[0].id = CARRY;
command.word[0].type = ACTION;
}
/* From OV to VO form */
if (command.word[0].type==OBJECT && command.word[1].type==ACTION) {
command_word_t stage;
memcpy(&stage, &command.word[0],
sizeof(command_word_t));
memcpy(&command.word[0], &command.word[1],
sizeof(command_word_t));
memcpy(&command.word[1], &stage,
sizeof(command_word_t));
}
}
Lookup:

View file

@ -600,7 +600,7 @@ The top of a 12-foot-tall beanstalk is poking out of the west pit.
> water plant
What do you want to do with the plant?
What do you want to do with the water?
You scored 65 out of a possible 430, using 85 turns.