From 1af01ff91fd0fee206d096449a564996ea85abed Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 8 Apr 2023 22:53:06 -0400 Subject: [PATCH] Confine use of STATE_NOTFOUND to macros. --- advent.h | 1 + main.c | 6 +++--- saveresume.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/advent.h b/advent.h index 738d546..b24eed7 100644 --- a/advent.h +++ b/advent.h @@ -61,6 +61,7 @@ #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 PROMPT "> " diff --git a/main.c b/main.c index 196a4ed..b90056c 100644 --- a/main.c +++ b/main.c @@ -859,8 +859,8 @@ static bool closecheck(void) * objects come from known locations and/or states (e.g. the * snake is known to have been destroyed and needn't be * carried away from its old "place"), making the various - * objects be handled differently. We also drop all other - * objects he might be carrying (lest he have some which + * objects be handled differently. We also drop all other + * objects he might be acrrying (lest he have some which * could cause trouble, such as the keys). We describe the * flash of light and trundle back. */ put(BOTTLE, LOC_NE, EMPTY_BOTTLE); @@ -868,7 +868,7 @@ static bool closecheck(void) put(OYSTER, LOC_NE, STATE_FOUND); put(LAMP, LOC_NE, LAMP_DARK); put(ROD, LOC_NE, STATE_FOUND); - put(DWARF, LOC_NE, 0); + put(DWARF, LOC_NE, STATE_FOUND); game.loc = LOC_NE; game.oldloc = LOC_NE; game.newloc = LOC_NE; diff --git a/saveresume.c b/saveresume.c index ceda43c..9c788d1 100644 --- a/saveresume.c +++ b/saveresume.c @@ -218,7 +218,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 (valgame.objects[treasure].prop == STATE_NOTFOUND) { + if (PROP_IS_NOTFOUND2(valgame, treasure)) { ++temp_tally; } } -- 2.31.1