From 87c6d3fb1e583e4d2fa6fd9532287b34b3948d77 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 3 Aug 2017 15:02:41 -0400 Subject: [PATCH] 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. --- actions.c | 2 -- main.c | 11 +++++++++++ tests/water_plant2.chk | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/actions.c b/actions.c index 3d03d83..b63f795 100644 --- a/actions.c +++ b/actions.c @@ -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; } diff --git a/main.c b/main.c index a20d9dc..0eab6e8 100644 --- a/main.c +++ b/main.c @@ -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: diff --git a/tests/water_plant2.chk b/tests/water_plant2.chk index 4ccbe2b..8cb32a4 100644 --- a/tests/water_plant2.chk +++ b/tests/water_plant2.chk @@ -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. -- 2.31.1