Address GitLab issue #28: Advent hangs on some inputs
[open-adventure.git] / main.c
diff --git a/main.c b/main.c
index 17f2643c901f66a8313cf29bdfb7d162cc519d25..ee2291298fa388fe5265efac343ac7f23b1239aa 100644 (file)
--- a/main.c
+++ b/main.c
@@ -989,8 +989,6 @@ static void listobjects(void)
 static bool get_command_input(struct command_t *command)
 {
     char inputbuf[LINESIZE];
-    char word1[TOKLEN + 1];
-    char word2[TOKLEN + 1];
     char* input;
 
     for (;;) {
@@ -1128,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;