Rename some macos for clarity.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 30 Jun 2024 18:42:06 +0000 (14:42 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 30 Jun 2024 18:48:44 +0000 (14:48 -0400)
Makefile
actions.c
advent.h
init.c
main.c
misc.c
saveresume.c
score.c

index a7acbd8538b19ea49c03f7ad9269f8236b383327..88c59e6e60c46d3ec5855b94f93f6f7647ef5067 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -67,7 +67,7 @@ cheat: $(CHEAT_OBJS) dungeon.o
 
 CSUPPRESSIONS = --suppress=missingIncludeSystem --suppress=invalidscanf
 cppcheck:
-       @-cppcheck -I. --quiet --template gcc -UPROP_SET_SEEN --enable=all $(CSUPPRESSIONS) *.[ch]
+       @-cppcheck -I. --quiet --template gcc -UOBJECT_SET_SEEN --enable=all $(CSUPPRESSIONS) *.[ch]
 
 pylint:
        @-pylint --score=n *.py */*.py
index 31a09c82f5bed6ee2f50dc68a00686b7e683c4ab..27b790456b4572a5e63471aa0eee560354a00eb4 100644 (file)
--- a/actions.c
+++ b/actions.c
@@ -246,7 +246,7 @@ static phase_codes_t bigwords(vocab_t id) {
 static void blast(void) {
        /*  Blast.  No effect unless you've got dynamite, which is a neat trick!
         */
-       if (PROP_IS_NOTFOUND(ROD2) || !game.closed) {
+       if (OBJECT_IS_NOTFOUND(ROD2) || !game.closed) {
                rspeak(REQUIRES_DYNAMITE);
        } else {
                if (HERE(ROD2)) {
@@ -389,7 +389,7 @@ static phase_codes_t vcarry(verb_t verb, obj_t obj) {
        }
 
        if (obj == BIRD && game.objects[BIRD].prop != BIRD_CAGED &&
-           !PROP_IS_STASHED(BIRD)) {
+           !OBJECT_IS_STASHED(BIRD)) {
                if (game.objects[BIRD].prop == BIRD_FOREST_UNCAGED) {
                        DESTROY(BIRD);
                        rspeak(BIRD_CRAP);
@@ -407,7 +407,7 @@ static phase_codes_t vcarry(verb_t verb, obj_t obj) {
        }
        if ((obj == BIRD || obj == CAGE) &&
            (game.objects[BIRD].prop == BIRD_CAGED ||
-            PROP_STASHED(BIRD) == BIRD_CAGED)) {
+            OBJECT_STASHED(BIRD) == BIRD_CAGED)) {
                /* expression maps BIRD to CAGE and CAGE to BIRD */
                carry(BIRD + CAGE - obj, game.loc);
        }
@@ -418,8 +418,8 @@ static phase_codes_t vcarry(verb_t verb, obj_t obj) {
                game.objects[LIQUID()].place = CARRIED;
        }
 
-       if (GSTONE(obj) && !PROP_IS_FOUND(obj)) {
-               PROP_SET_FOUND(obj);
+       if (GSTONE(obj) && !OBJECT_IS_FOUND(obj)) {
+               OBJECT_SET_FOUND(obj);
                game.objects[CAVITY].prop = CAVITY_EMPTY;
        }
        rspeak(OK_MAN);
@@ -971,7 +971,7 @@ static phase_codes_t listen(void) {
        }
        for (obj_t i = 1; i <= NOBJECTS; i++) {
                if (!HERE(i) || objects[i].sounds[0] == NULL ||
-                   PROP_IS_STASHED_OR_UNSEEN(i)) {
+                   OBJECT_IS_STASHED_OR_UNSEEN(i)) {
                        continue;
                }
                int mi = game.objects[i].prop;
@@ -1151,7 +1151,7 @@ static phase_codes_t read(command_t command)
                command.obj = NO_OBJECT;
                for (int i = 1; i <= NOBJECTS; i++) {
                        if (HERE(i) && objects[i].texts[0] != NULL &&
-                           !PROP_IS_STASHED(i)) {
+                           !OBJECT_IS_STASHED(i)) {
                                command.obj = command.obj * NOBJECTS + i;
                        }
                }
@@ -1175,7 +1175,7 @@ static phase_codes_t read(command_t command)
                               1); // Not really a sound, but oh well.
                }
        } else if (objects[command.obj].texts[0] == NULL ||
-                  PROP_IS_NOTFOUND(command.obj)) {
+                  OBJECT_IS_NOTFOUND(command.obj)) {
                speak(actions[command.verb].message);
        } else {
                pspeak(command.obj, study, true,
@@ -1351,9 +1351,9 @@ static phase_codes_t wave(verb_t verb, obj_t obj) {
        }
 
        if (game.objects[BIRD].prop == BIRD_UNCAGED &&
-           game.loc == game.objects[STEPS].place && PROP_IS_NOTFOUND(JADE)) {
+           game.loc == game.objects[STEPS].place && OBJECT_IS_NOTFOUND(JADE)) {
                drop(JADE, game.loc);
-               PROP_SET_FOUND(JADE);
+               OBJECT_SET_FOUND(JADE);
                --game.tally;
                rspeak(NECKLACE_FLY);
                return GO_CLEAROBJ;
index 21a521f8d6fc71c7ede4226a8705813a23bd4597..f561e8962fe43fb8e37a59c128d67b5b9c50fc3e 100644 (file)
--- a/advent.h
+++ b/advent.h
@@ -61,7 +61,7 @@
  * STATE_NOTFOUND is only set on treasures. Non-treasures start the
  * game in STATE_FOUND.
  *
- * PROP_STASHED is supposed to map a state property value to a
+ * OBJECT_STASHED is supposed to map a state property value to a
  * negative range, where the object cannot be picked up but the value
  * can be recovered later.  Various objects get this property when
  * the cave starts to close. Only seems to be significant for the bird
  * those tests is difficult to read.
  */
 #define PROP_STASHIFY(n) (-1 - (n))
-#define PROP_IS_STASHED(obj) (game.objects[obj].prop < STATE_NOTFOUND)
-#define PROP_IS_NOTFOUND(obj) (game.objects[obj].prop == STATE_NOTFOUND)
-#define PROP_IS_FOUND(obj) (game.objects[obj].prop == STATE_FOUND)
-#define PROP_IS_STASHED_OR_UNSEEN(obj) (game.objects[obj].prop < 0)
-#define PROP_SET_FOUND(obj) (game.objects[obj].prop = STATE_FOUND)
-#define PROP_SET_NOT_FOUND(obj) (game.objects[obj].prop = STATE_NOTFOUND)
-#define PROP_IS_NOTFOUND2(g, o) (g.objects[o].prop == STATE_NOTFOUND)
 #define PROP_IS_INVALID(val) (val < -MAX_STATE - 1 || val > MAX_STATE)
+#define OBJECT_IS_STASHED(obj) (game.objects[obj].prop < STATE_NOTFOUND)
+#define OBJECT_IS_NOTFOUND(obj) (game.objects[obj].prop == STATE_NOTFOUND)
+#define OBJECT_IS_FOUND(obj) (game.objects[obj].prop == STATE_FOUND)
+#define OBJECT_IS_STASHED_OR_UNSEEN(obj) (game.objects[obj].prop < 0)
+#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)
 #else
 /* (ESR) Only the boldest of adventurers will explore here.  This
  * alternate set of definitions for the macros above was an attempt to
  * telling whether or not the player has seen the object.
  *
  * What's broken when you try to use thus is
- * PROP_IS_STASHED_OR_UNSEEN. The symptom is game.tally getting
+ * OBJECT_IS_STASHED_OR_UNSEEN. The symptom is game.tally getting
  * decremented on non-treasures.
  */
 #define PROP_STASHIFY(n) (-(n))
-#define PROP_IS_STASHED(obj) (game.objects[obj].prop < 0)
-#define PROP_IS_NOTFOUND(obj) (!game.objects[obj].found)
-#define PROP_IS_FOUND(obj)                                                     \
+#define PROP_IS_INVALID(val) (val < -MAX_STATE || val > MAX_STATE)
+#define OBJECT_IS_STASHED(obj) (game.objects[obj].prop < 0)
+#define OBJECT_IS_NOTFOUND(obj) (!game.objects[obj].found)
+#define OBJECT_IS_FOUND(obj)                                                     \
        (game.objects[obj].found && game.objects[obj].prop == 0)
-#define PROP_IS_STASHED_OR_UNSEEN(obj)                                         \
+#define OBJECT_IS_STASHED_OR_UNSEEN(obj)                                         \
        (!game.objects[obj].found || game.objects[obj].prop < 0)
-#define PROP_SET_FOUND(obj)                                                    \
+#define OBJECT_SET_FOUND(obj)                                                    \
        do {                                                                   \
                game.objects[obj].found = true;                                \
                game.objects[obj].prop = STATE_FOUND;                          \
        } while (0)
-#define PROP_SET_NOT_FOUND(obj) game.objects[obj].found = false
-#define PROP_IS_NOTFOUND2(g, o) (!g.objects[o].found)
-#define PROP_IS_INVALID(val) (val < -MAX_STATE || val > MAX_STATE)
-#define PROP_SET_SEEN(obj) game.objects[object].found = true
+#define OBJECT_SET_NOT_FOUND(obj) game.objects[obj].found = false
+#define OBJECT_IS_NOTFOUND2(g, o) (!g.objects[o].found)
+#define OBJECT_SET_SEEN(obj) game.objects[object].found = true
 #endif
-#define PROP_STASHED(obj) PROP_STASHIFY(game.objects[obj].prop)
+#define OBJECT_STASHED(obj) PROP_STASHIFY(game.objects[obj].prop)
 
 #define PROMPT "> "
 
diff --git a/init.c b/init.c
index 2fffc144d195aa8d4b1aa90685b96601506097f5..58bb0e88bdd7662176a49d8e9016e809a894cf9e 100644 (file)
--- a/init.c
+++ b/init.c
@@ -84,10 +84,10 @@ int initialise(void) {
                if (objects[object].is_treasure) {
                        ++game.tally;
                        if (objects[object].inventory != NULL) {
-                               PROP_SET_NOT_FOUND(object);
+                               OBJECT_SET_NOT_FOUND(object);
                        }
                } else {
-                       PROP_SET_FOUND(object);
+                       OBJECT_SET_FOUND(object);
                }
        }
        game.conds = setbit(COND_HBASE);
diff --git a/main.c b/main.c
index 6d904f297734fe78e1f27d334d596769d8cdbb51..2dfa8802cb2d6301b176f451e89da8d714076d61 100644 (file)
--- a/main.c
+++ b/main.c
@@ -152,8 +152,8 @@ static void checkhints(void) {
                                        game.hints[hint].lc = 0;
                                        return;
                                case 4: /* dark */
-                                       if (!PROP_IS_NOTFOUND(EMERALD) &&
-                                           PROP_IS_NOTFOUND(PYRAMID)) {
+                                       if (!OBJECT_IS_NOTFOUND(EMERALD) &&
+                                           OBJECT_IS_NOTFOUND(PYRAMID)) {
                                                break;
                                        }
                                        game.hints[hint].lc = 0;
@@ -188,7 +188,7 @@ static void checkhints(void) {
                                        return;
                                case 9: /* jade */
                                        if (game.tally == 1 &&
-                                           PROP_IS_STASHED_OR_UNSEEN(JADE)) {
+                                           OBJECT_IS_STASHED_OR_UNSEEN(JADE)) {
                                                break;
                                        }
                                        game.hints[hint].lc = 0;
@@ -231,8 +231,8 @@ static bool spotted_by_pirate(int i) {
         *  tally=1 for an unseen chest, let the pirate be spotted.  Note
         *  that game.objexts,place[CHEST] = LOC_NOWHERE might mean that he's
         * thrown it to the troll, but in that case he's seen the chest
-        *  PROP_IS_FOUND(CHEST) == true. */
-       if (game.loc == game.chloc || !PROP_IS_NOTFOUND(CHEST)) {
+        *  OBJECT_IS_FOUND(CHEST) == true. */
+       if (game.loc == game.chloc || !OBJECT_IS_NOTFOUND(CHEST)) {
                return true;
        }
        int snarfed = 0;
@@ -1061,11 +1061,11 @@ static void listobjects(void) {
                         * running this code only on objects with the treasure
                         * property set. Nope.  There is mystery here.
                         */
-                       if (PROP_IS_STASHED_OR_UNSEEN(obj)) {
+                       if (OBJECT_IS_STASHED_OR_UNSEEN(obj)) {
                                if (game.closed) {
                                        continue;
                                }
-                               PROP_SET_FOUND(obj);
+                               OBJECT_SET_FOUND(obj);
                                if (obj == RUG) {
                                        game.objects[RUG].prop = RUG_DRAGON;
                                }
@@ -1266,16 +1266,16 @@ static bool do_command(void) {
                                 * way objects won't be described until they've
                                 * been picked up and put down separate from
                                 * their respective piles. */
-                               if ((PROP_IS_NOTFOUND(OYSTER) ||
-                                    PROP_IS_STASHED(OYSTER)) &&
+                               if ((OBJECT_IS_NOTFOUND(OYSTER) ||
+                                    OBJECT_IS_STASHED(OYSTER)) &&
                                    TOTING(OYSTER)) {
                                        pspeak(OYSTER, look, true, 1);
                                }
                                for (size_t i = 1; i <= NOBJECTS; i++) {
-                                       if (TOTING(i) && (PROP_IS_NOTFOUND(i) ||
-                                                         PROP_IS_STASHED(i))) {
+                                       if (TOTING(i) && (OBJECT_IS_NOTFOUND(i) ||
+                                                         OBJECT_IS_STASHED(i))) {
                                                game.objects[i].prop =
-                                                   PROP_STASHED(i);
+                                                   OBJECT_STASHED(i);
                                        }
                                }
                        }
diff --git a/misc.c b/misc.c
index 9e90d05613f14281879c12a4989226f98c53ca55..14d0622541ac2805f5540110375d52cde89d1dc0 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -620,11 +620,11 @@ void put(obj_t object, loc_t where, int pval) {
        /*  put() is the same as move(), except it returns a value used to set
         * up the negated game.prop values for the repository objects. */
        move(object, where);
-       /* (ESR) Read this in combination with the macro defintions in advebt.h.
+       /* (ESR) Read this in combination with the macro defintions in advent.h.
         */
        game.objects[object].prop = PROP_STASHIFY(pval);
-#ifdef PROP_SET_SEEN
-       PROP_SET_SEEN(object);
+#ifdef OBJECT_SET_SEEN
+       OBJECT_SET_SEEN(object);
 #endif
 }
 
index 100c925d400ab77c0dc2c5a354a5bfb24bac2f48..1c778ef5abc9d389c5152ae08a15eb5075d34a71 100644 (file)
@@ -230,7 +230,7 @@ bool is_valid(struct game_t valgame) {
        int temp_tally = 0;
        for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
                if (objects[treasure].is_treasure) {
-                       if (PROP_IS_NOTFOUND2(valgame, treasure)) {
+                       if (OBJECT_IS_NOTFOUND2(valgame, treasure)) {
                                ++temp_tally;
                        }
                }
diff --git a/score.c b/score.c
index 1d84c79a74fb5705f1f7ecea1e94f88ac3100ef5..ad1c00ae84490d06508e9f372478fc4dec659656 100644 (file)
--- a/score.c
+++ b/score.c
@@ -49,11 +49,11 @@ int score(enum termination mode) {
                        if (i > CHEST) {
                                k = 16;
                        }
-                       if (!PROP_IS_STASHED(i) && !PROP_IS_NOTFOUND(i)) {
+                       if (!OBJECT_IS_STASHED(i) && !OBJECT_IS_NOTFOUND(i)) {
                                score += 2;
                        }
                        if (game.objects[i].place == LOC_BUILDING &&
-                           PROP_IS_FOUND(i)) {
+                           OBJECT_IS_FOUND(i)) {
                                score += k - 2;
                        }
                        mxscor += k;