Rename some macos for clarity.

This commit is contained in:
Eric S. Raymond 2024-06-30 14:42:06 -04:00
parent 124e7768b4
commit cb293f4aa4
8 changed files with 50 additions and 50 deletions

View file

@ -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

View file

@ -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;

View file

@ -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
@ -69,14 +69,14 @@
* 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
@ -84,27 +84,27 @@
* 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 "> "

4
init.c
View file

@ -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);

24
main.c
View file

@ -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);
}
}
}

6
misc.c
View file

@ -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
}

View 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;
}
}

View file

@ -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;