Confine uses of PROP_STASHIFY() to advent.h
authorEric S. Raymond <esr@thyrsus.com>
Mon, 23 Sep 2024 03:09:16 +0000 (23:09 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 23 Sep 2024 08:26:59 +0000 (04:26 -0400)
Now it shouyld be possible to manipulate a stashed flag by only
changing macros.

actions.c
advent.h

index 107b298758e29a03a4d3e6c55bc885ebbcbbb255..6f93eb0fee78eb35ce437b89ad141a86b447f3a8 100644 (file)
--- a/actions.c
+++ b/actions.c
@@ -406,8 +406,7 @@ static phase_codes_t vcarry(verb_t verb, obj_t obj) {
                game.objects[BIRD].prop = BIRD_CAGED;
        }
        if ((obj == BIRD || obj == CAGE) &&
-           (game.objects[BIRD].prop == BIRD_CAGED ||
-            PROP_STASHIFY(game.objects[BIRD].prop) == BIRD_CAGED)) {
+           OBJECT_STATE_EQUALS(BIRD, BIRD_CAGED)) {
                /* expression maps BIRD to CAGE and CAGE to BIRD */
                carry(BIRD + CAGE - obj, game.loc);
        }
index d1504f088f471d203603b34d29e117ec749952b7..6686dfcfbd4a5ff94f311a1675bb321168a23e3a 100644 (file)
--- a/advent.h
+++ b/advent.h
@@ -77,6 +77,7 @@
 #define OBJECT_SET_FOUND(obj) (game.objects[obj].prop = STATE_FOUND)
 #define OBJECT_SET_NOT_FOUND(obj) (game.objects[obj].prop = STATE_NOTFOUND)
 #define OBJECT_IS_NOTFOUND2(g, o) (g.objects[o].prop == STATE_NOTFOUND)
+#define OBJECT_STATE_EQUALS(obj, pval) ((game.objects[obj].prop == pval) || (game.objects[obj].prop == PROP_STASHIFY(pval))) 
 #else
 /* (ESR) Only the boldest of adventurers will explore here.  This
  * alternate set of definitions for the macros above was an attempt to