Abstract out some state arithmetic.
[open-adventure.git] / actions.c
index 2ad4623dce25e693b44a01157d212629b2566731..ec17c07b2145254be33b052c1700b9912df1f8a6 100644 (file)
--- a/actions.c
+++ b/actions.c
@@ -361,7 +361,7 @@ static int vcarry(token_t verb, token_t obj)
 
     }
 
-    if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
+    if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
         if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
             DESTROY(BIRD);
             rspeak(BIRD_CRAP);
@@ -380,8 +380,7 @@ static int vcarry(token_t verb, token_t obj)
     /* FIXME: Arithmetic on state numbers */
     if ((obj == BIRD ||
          obj == CAGE) &&
-        (game.prop[BIRD] == BIRD_CAGED ||
-         -1 - game.prop[BIRD] == 1))
+        (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
         carry(BIRD + CAGE - obj, game.loc);
     carry(obj, game.loc);
     if (obj == BOTTLE && LIQUID() != NO_OBJECT)
@@ -447,12 +446,11 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
  *  bird (might attack snake or dragon) and cage (might contain bird) and vase.
  *  Drop coins at vending machine for extra batteries. */
 {
-    int spk = actions[verb].message;
     if (!just_do_it) {
         if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
             obj = ROD2;
         if (!TOTING(obj)) {
-            rspeak(spk);
+            rspeak(actions[verb].message);
             return GO_CLEAROBJ;
         }
         if (obj == BIRD && HERE(SNAKE)) {
@@ -469,7 +467,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
             game.prop[CAVITY] = CAVITY_FULL;
             if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
                               (obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
-                spk = RUG_RISES;
+                int spk = RUG_RISES;
                 if (TOTING(RUG))
                     spk = RUG_WIGGLES;
                 if (obj == RUBY)
@@ -515,7 +513,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
     int k = LIQUID();
     if (k == obj)
         obj = BOTTLE;
-    if (obj == BOTTLE && k != 0)
+    if (obj == BOTTLE && k != NO_OBJECT)
         game.place[k] = LOC_NOWHERE;
     if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
         drop(BIRD, game.loc);
@@ -693,7 +691,7 @@ int fill(token_t verb, token_t obj)
         rspeak(SHATTER_VASE);
         game.prop[VASE] = VASE_BROKEN;
         game.fixed[VASE] = -1;
-        return (discard(verb, obj, true));
+        return (discard(verb, VASE, true));
     }
 
     if (obj == URN) {