Canonicalize OV commands to VO form.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 3 Aug 2017 19:02:41 +0000 (15:02 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 3 Aug 2017 19:02:41 +0000 (15:02 -0400)
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
main.c
tests/water_plant2.chk

index 3d03d830e5f0da9b71e04c80395fbc47492ab8bf..b63f795ddb0dc8bcd7f67f8c1545733b5c5f0965 100644 (file)
--- 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 a20d9dc2e5114210594fc126f7ba0c0323dd1ebb..0eab6e8d19bacb4b49d0e89a655fed530f4633e9 100644 (file)
--- 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:
index 4ccbe2b3493202d4981eed9fb917f8b45601fd97..8cb32a4f8a9187684acd510124e5f36b7c875750 100644 (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.