Static analysis warnings squished
[open-adventure.git] / actions.c
index 59ec428f506127b5b2612f282ca34e5da5b31c44..2ac545c726e699bcd60065f11948ac95c613b73a 100644 (file)
--- a/actions.c
+++ b/actions.c
@@ -261,7 +261,7 @@ static int vbreak(token_t verb, token_t obj)
         if (TOTING(VASE))
             drop(VASE, game.loc);
         state_change(VASE, VASE_BROKEN);
-        game.fixed[VASE] = -1;
+        game.fixed[VASE] = IS_FIXED;
         return GO_CLEAROBJ;
     }
     rspeak(actions[verb].message);
@@ -302,8 +302,9 @@ static int vcarry(token_t verb, token_t obj)
         return GO_CLEAROBJ;
     }
 
-    if (game.fixed[obj] != 0) {
-        if (obj == PLANT && game.prop[PLANT] <= 0) {
+    if (game.fixed[obj] != IS_FREE) {
+        /* Next guard tests whether plant is tiny or stashed */
+        if (obj == PLANT && game.prop[PLANT] <= PLANT_THIRSTY) {
             rspeak(DEEP_ROOTS);
             return GO_CLEAROBJ;
         }
@@ -381,7 +382,7 @@ static int vcarry(token_t verb, token_t obj)
     if ((obj == BIRD ||
          obj == CAGE) &&
         (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
-       /* expression maps BIRD to CAGE and CAGE to BIRD */
+        /* expression maps BIRD to CAGE and CAGE to BIRD */
         carry(BIRD + CAGE - obj, game.loc);
     carry(obj, game.loc);
     if (obj == BOTTLE && LIQUID() != NO_OBJECT)
@@ -407,16 +408,16 @@ static int chain(token_t verb)
             return GO_CLEAROBJ;
         }
         game.prop[CHAIN] = CHAIN_HEAP;
-        game.fixed[CHAIN] = CHAIN_HEAP;
+        game.fixed[CHAIN] = IS_FREE;
         if (game.prop[BEAR] != BEAR_DEAD)
             game.prop[BEAR] = CONTENTED_BEAR;
 
         switch (game.prop[BEAR]) {
         case BEAR_DEAD:
-            game.fixed[BEAR] = -1;
+            game.fixed[BEAR] = IS_FIXED;
             break;
         default:
-            game.fixed[BEAR] = 0;
+            game.fixed[BEAR] = IS_FREE;
         }
         rspeak(CHAIN_UNLOCKED);
         return GO_CLEAROBJ;
@@ -435,7 +436,7 @@ static int chain(token_t verb)
 
     if (TOTING(CHAIN))
         drop(CHAIN, game.loc);
-    game.fixed[CHAIN] = -1;
+    game.fixed[CHAIN] = IS_FIXED;
 
     rspeak(CHAIN_LOCKED);
     return GO_CLEAROBJ;
@@ -502,11 +503,11 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
                    game.loc == objects[PILLOW].plac) {
             rspeak(OK_MAN);
         } else {
-           state_change(VASE, AT(PILLOW)
-                        ? VASE_WHOLE
-                        : VASE_DROPPED);
+            state_change(VASE, AT(PILLOW)
+                         ? VASE_WHOLE
+                         : VASE_DROPPED);
             if (game.prop[VASE] != VASE_WHOLE)
-                game.fixed[VASE] = -1;
+                game.fixed[VASE] = IS_FIXED;
         }
     }
     int k = LIQUID();
@@ -546,9 +547,8 @@ static int drink(token_t verb, token_t obj)
         return GO_CLEAROBJ;
     }
     if (LIQUID() == WATER && HERE(BOTTLE)) {
-        game.prop[BOTTLE] = EMPTY_BOTTLE;
         game.place[WATER] = LOC_NOWHERE;
-        rspeak(BOTTLE_EMPTY);
+        state_change(BOTTLE, EMPTY_BOTTLE);
         return GO_CLEAROBJ;
     }
 
@@ -660,7 +660,7 @@ static int feed(token_t verb, token_t obj)
         if (HERE(FOOD)) {
             DESTROY(FOOD);
             game.prop[BEAR] = SITTING_BEAR;
-            game.fixed[AXE] = 0;
+            game.fixed[AXE] = IS_FREE;
             game.prop[AXE] = AXE_HERE;
             spk = BEAR_TAMED;
         }
@@ -689,7 +689,7 @@ int fill(token_t verb, token_t obj)
         }
         rspeak(SHATTER_VASE);
         game.prop[VASE] = VASE_BROKEN;
-        game.fixed[VASE] = -1;
+        game.fixed[VASE] = IS_FIXED;
         return (discard(verb, VASE, true));
     }
 
@@ -741,13 +741,11 @@ int fill(token_t verb, token_t obj)
         return GO_CLEAROBJ;
     }
 
-    game.prop[BOTTLE] = (LIQLOC(game.loc) == OIL) ? OIL_BOTTLE : WATER_BOTTLE;
+    state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
+                 ? OIL_BOTTLE
+                 : WATER_BOTTLE);
     if (TOTING(BOTTLE))
         game.place[LIQUID()] = CARRIED;
-    if (LIQUID() == OIL)
-        rspeak(BOTTLED_OIL);
-    else
-        rspeak(BOTTLED_WATER);
     return GO_CLEAROBJ;
 }
 
@@ -805,10 +803,10 @@ static int fly(token_t verb, token_t obj)
     /* FIXME: Arithmetic on location values */
     game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
 
-    if (game.prop[SAPPH] >= 0) {
-        rspeak(RUG_RETURNS);
-    } else {
+    if (game.prop[SAPPH] == STATE_NOTFOUND) {
         rspeak(RUG_GOES);
+    } else {
+        rspeak(RUG_RETURNS);
     }
     return GO_TERMINATE;
 }
@@ -871,7 +869,7 @@ static int light(token_t verb, token_t obj)
 }
 
 static int listen(void)
-/*  Listen.  Intransitive only.  Print stuff based on objsnd/locsnd. */
+/*  Listen.  Intransitive only.  Print stuff based on object sound proprties. */
 {
     long sound = locations[game.loc].sound;
     if (sound != SILENT) {
@@ -891,8 +889,7 @@ static int listen(void)
         long packed_zzword = token_to_packed(game.zzword);
         pspeak(i, hear, mi, true, packed_zzword);
         rspeak(NO_MESSAGE);
-        /* FIXME: Magic number, sensitive to bird state logic */
-        if (i == BIRD && game.prop[i] == 5)
+        if (i == BIRD && mi == BIRD_ENDSTATE)
             DESTROY(BIRD);
         return GO_CLEAROBJ;
     }
@@ -1168,7 +1165,7 @@ static int throw (struct command_t *command)
             else if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
                 /* This'll teach him to throw the axe at the bear! */
                 drop(AXE, game.loc);
-                game.fixed[AXE] = -1;
+                game.fixed[AXE] = IS_FIXED;
                 juggle(BEAR);
                 state_change(AXE, AXE_LOST);
                 return GO_CLEAROBJ;