Made feeding a switch instead of elsif chain
authorNHOrus <jy6x2b32pie9@yahoo.com>
Wed, 5 Jul 2017 16:55:52 +0000 (19:55 +0300)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 5 Jul 2017 19:41:36 +0000 (15:41 -0400)
actions.c
adventure.yaml
misc.c

index 971bbb349cee39fb9c5398b1dcf18e7d26417dd1..c5494d0881b74a08004eee902ef6608a53400d68 100644 (file)
--- a/actions.c
+++ b/actions.c
@@ -624,46 +624,56 @@ static int feed(token_t verb, token_t obj)
 /*  Feed.  If bird, no seed.  Snake, dragon, troll: quip.  If dwarf, make him
  *  mad.  Bear, special. */
 {
-    int spk = actions[verb].message;
-    if (obj == BIRD) {
+    switch (obj) {
+    case BIRD:
         rspeak(BIRD_PINING);
-        return GO_CLEAROBJ;
-    } else if (obj == SNAKE ||
-               obj == DRAGON ||
-               obj == TROLL) {
-        spk = NOTHING_EDIBLE;
-        if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS)
-            spk = RIDICULOUS_ATTEMPT;
-        if (obj == TROLL)
-            spk = TROLL_VICES;
-        if (obj == SNAKE && !game.closed && HERE(BIRD)) {
+        break;
+
+    case DRAGON:
+        if (game.prop[DRAGON] != DRAGON_BARS)
+            rspeak(RIDICULOUS_ATTEMPT);
+        else
+            rspeak(NOTHING_EDIBLE);
+        break;
+    case SNAKE:
+        if (!game.closed && HERE(BIRD)) {
             DESTROY(BIRD);
-            spk = BIRD_DEVOURED;
-        }
-    } else if (obj == DWARF) {
+            rspeak(BIRD_DEVOURED);
+        } else
+            rspeak(NOTHING_EDIBLE);
+        break;
+    case TROLL:
+        rspeak(TROLL_VICES);
+        break;
+    case DWARF:
         if (HERE(FOOD)) {
             game.dflag += 2;
-            spk = REALLY_MAD;
+            rspeak(REALLY_MAD);
         }
-    } else if (obj == BEAR) {
-        if (game.prop[BEAR] == UNTAMED_BEAR)
-            spk = NOTHING_EDIBLE;
-        if (game.prop[BEAR] == BEAR_DEAD)
-            spk = RIDICULOUS_ATTEMPT;
-        if (HERE(FOOD)) {
-            DESTROY(FOOD);
-            game.prop[BEAR] = SITTING_BEAR;
-            game.fixed[AXE] = IS_FREE;
-            game.prop[AXE] = AXE_HERE;
-            spk = BEAR_TAMED;
+        break;
+    case BEAR:
+        if (game.prop[BEAR] == BEAR_DEAD) {
+            rspeak(RIDICULOUS_ATTEMPT);
+            break;
+        }
+        if (game.prop[BEAR] == UNTAMED_BEAR) {
+            if (HERE(FOOD)) {
+                DESTROY(FOOD);
+                game.fixed[AXE] = IS_FREE;
+                game.prop[AXE] = AXE_HERE;
+                state_change(BEAR, SITTING_BEAR);
+            } else
+                rspeak(NOTHING_EDIBLE);
         }
-    } else if (obj == OGRE) {
+        break;
+    case OGRE:
         if (HERE(FOOD))
-            spk = OGRE_FULL;
-    } else {
-        spk = AM_GAME;
+            rspeak(OGRE_FULL);
+        else rspeak(actions[verb].message);
+        break;
+    default:
+        rspeak(AM_GAME);
     }
-    rspeak(spk);
     return GO_CLEAROBJ;
 }
 
index c816099f83c36590d7c0e823510bc9dc3af3f937..fe44ce879d62d82a7d55362cd0c0777597a9be8a 100644 (file)
@@ -2966,9 +2966,6 @@ arbitrary_messages:  !!omap
 - BEAR_HANDS: 'With what?  Your bare hands?  Against *HIS* bear hands??'
 - BEAR_CONFUSED: 'The bear is confused; he only wants to be your friend.'
 - ALREADY_DEAD: 'For crying out loud, the poor thing is already dead!'
-- BEAR_TAMED: |-
-    The bear eagerly wolfs down your food, after which he seems to calm
-    down considerably and even becomes rather friendly.
 - BEAR_CHAINED: 'The bear is still chained to the wall.'
 - STILL_LOCKED: 'The chain is still locked.'
 - CHAIN_UNLOCKED: 'The chain is now unlocked.'
@@ -3537,6 +3534,11 @@ objects: !!omap
     - 'There is a gentle cave bear sitting placidly in one corner.'
     - 'There is a contented-looking bear wandering about nearby.'
     - ''
+    changes:
+    - ''
+    - 'The bear eagerly wolfs down your food, after which he seems to calm\ndown considerably and even becomes rather friendly.'
+    - ''
+    - ''
 - MESSAG:
     words: ['messa']
     inventory: '*message in second maze'
diff --git a/misc.c b/misc.c
index b4869d8568d4f2ac5b46b4b25caac491eccde1af..c219cfb059ec4b1f38570e208f1c7e498fd7fe45 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -402,7 +402,7 @@ bool yes(const char* question, const char* yes_response, const char* no_response
     for (;;) {
         speak(question);
 
-        char*        reply = get_input();
+        char* reply = get_input();
         if (reply == NULL) {
             // LCOV_EXCL_START
             // Should be unreachable. Reply should never be NULL