Improved behavior when magic words are said before they're seen.
[open-adventure.git] / actions.c
index c09331a8a7a3f812e8585381993189392a8f6a25..658d95d1789fe6df51ab990128d0cf807d790c63 100644 (file)
--- a/actions.c
+++ b/actions.c
@@ -1,9 +1,9 @@
 /*
  * Actions for the dungeon-running code.
  *
- * Copyright (c) 1977, 2005 by Will Crowther and Don Woods
- * Copyright (c) 2017 by Eric S. Raymond
- * SPDX-License-Identifier: BSD-2-clause
+ * SPDX-FileCopyrightText: 1977, 2005 by Will Crowther and Don Woods
+ * SPDX-FileCopyrightText 2017 by Eric S. Raymond
+ * SPDX-License-Identifier: BSD-2-Clause
  */
 
 #include <stdlib.h>
@@ -192,13 +192,20 @@ static phase_codes_t bigwords(vocab_t id)
  * word we've got. Last word zips the eggs back to the giant room (unless
  * already there). */
 {
-    if ((game.foobar == WORD_EMPTY && id == FEE) ||
-        (game.foobar == FEE && id == FIE) ||
-        (game.foobar == FIE && id == FOE) ||
-        (game.foobar == FOE && id == FOO) ||
-        (game.foobar == FOE && id == FUM)) {
+    int foobar = abs(game.foobar);
+
+    /* Only FEE can start a magic-word sequence. */
+    if ((foobar == WORD_EMPTY) && (id == FIE || id == FOE || id == FOO || id == FUM)) {
+       rspeak(NOTHING_HAPPENS);
+       return GO_CLEAROBJ;
+    }
+    
+    if ((foobar == WORD_EMPTY && id == FEE) ||
+        (foobar == FEE && id == FIE) ||
+        (foobar == FIE && id == FOE) ||
+        (foobar == FOE && id == FOO)) {
         game.foobar = id;
-        if ((id != FOO) && (id != FUM)) {
+        if (id != FOO) {
             rspeak(OK_MAN);
             return GO_CLEAROBJ;
         }
@@ -207,8 +214,6 @@ static phase_codes_t bigwords(vocab_t id)
             (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
             rspeak(NOTHING_HAPPENS);
             return GO_CLEAROBJ;
-        } else if (id == FUM) {
-            goto fum;
         } else {
             /*  Bring back troll if we steal the eggs back from him before
              *  crossing. */
@@ -225,14 +230,11 @@ static phase_codes_t bigwords(vocab_t id)
             return GO_CLEAROBJ;
         }
     } else {
-fum:
-        if (game.loc == LOC_GIANTROOM) {
-            rspeak(START_OVER);
-        } else {
-            /* This is new behavior in Open Adventure - sounds better when
-             * player isn't in the Giant Room. */
-            rspeak(NOTHING_HAPPENS);
-        }
+       /* Magic-word sequebce was started but is incorrect */
+       if (settings.oldstyle || game.seenbigwords)
+           rspeak(START_OVER);
+       else
+           rspeak(WELL_POINTLESS);
         game.foobar = WORD_EMPTY;
         return GO_CLEAROBJ;
     }