From: Eric S. Raymond Date: Sun, 2 Jul 2017 17:22:50 +0000 (-0400) Subject: Magic-number elimination. X-Git-Tag: takebird~102 X-Git-Url: https://jxself.org/git/?p=open-adventure.git;a=commitdiff_plain;h=346bcf9458c408b5bd2a6fb5679a2e86bd3952fb Magic-number elimination. --- diff --git a/actions.c b/actions.c index ad09b4a..076a2b2 100644 --- a/actions.c +++ b/actions.c @@ -825,7 +825,7 @@ static int lock(token_t verb, token_t obj) return bivalve(verb, obj); if (obj == DOOR) spk = RUSTY_DOOR; - if (obj == DOOR && game.prop[DOOR] == 1) + if (obj == DOOR && game.prop[DOOR] == DOOR_UNRUSTED) spk = OK_MAN; if (obj == CAGE) spk = NO_LOCK; @@ -869,7 +869,7 @@ static int pour(token_t verb, token_t obj) rspeak(spk); return GO_CLEAROBJ; } - if (HERE(URN) && game.prop[URN] == 0) + if (HERE(URN) && game.prop[URN] == URN_EMPTY) return fill(verb, URN); game.prop[BOTTLE] = EMPTY_BOTTLE; game.place[obj] = LOC_NOWHERE; @@ -952,7 +952,7 @@ static int rub(token_t verb, token_t obj) int spk = actions[verb].message; if (obj != LAMP) spk = PECULIAR_NOTHING; - if (obj == URN && game.prop[URN] == 2) { + if (obj == URN && game.prop[URN] == URN_LIT) { DESTROY(URN); drop(AMBER, game.loc); game.prop[AMBER] = 1; diff --git a/advent.h b/advent.h index a7f5ac4..b9b2e0c 100644 --- a/advent.h +++ b/advent.h @@ -19,6 +19,7 @@ #define PANICTIME 15 // time left after closing #define BATTERYLIFE 2500 // turn limit increment from batteries #define WORD_NOT_FOUND -1 // "Word not found" flag value for the vocab hash functions. +#define NOT_YET_FOUND -1 // 'Not found" state of treasures */ #define CARRIED -1 // Player is toting it #define READ_MODE "rb" // b is not needed for POSIX but harmless #define WRITE_MODE "wb" // b is not needed for POSIX but harmless diff --git a/init.c b/init.c index 5372714..87a5161 100644 --- a/init.c +++ b/init.c @@ -92,7 +92,7 @@ long initialise(void) for (int treasure = 1; treasure <= NOBJECTS; treasure++) { if (objects[treasure].is_treasure) { if (objects[treasure].inventory != 0) - game.prop[treasure] = -1; + game.prop[treasure] = NOT_YET_FOUND; game.tally = game.tally - game.prop[treasure]; } } diff --git a/main.c b/main.c index 1269efa..7eb21da 100644 --- a/main.c +++ b/main.c @@ -185,7 +185,7 @@ static void checkhints(void) game.hintlc[hint] = 0; return; case 4: /* dark */ - if (game.prop[EMERALD] != -1 && game.prop[PYRAMID] == -1) + if (game.prop[EMERALD] != NOT_YET_FOUND && game.prop[PYRAMID] == NOT_YET_FOUND) break; game.hintlc[hint] = 0; return;