Magic-number elimination.
This commit is contained in:
parent
369c67840e
commit
e712f4c0e0
5 changed files with 12 additions and 10 deletions
|
@ -166,10 +166,9 @@ static int attack(struct command_t *command)
|
|||
|
||||
static int bigwords(token_t foo)
|
||||
/* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
|
||||
* Look up foo in section 3 of vocab to determine which word we've got. Last
|
||||
* word zips the eggs back to the giant room (unless already there). */
|
||||
* Look up foo in special section of vocab to determine which word we've got.
|
||||
* Last word zips the eggs back to the giant room (unless already there). */
|
||||
{
|
||||
//int k = vocab(foo, 3);
|
||||
char word[6];
|
||||
packed_to_token(foo, word);
|
||||
int k = (int) get_special_vocab_id(word);
|
||||
|
@ -362,7 +361,7 @@ static int vcarry(token_t verb, token_t obj)
|
|||
if (obj == BOTTLE && LIQUID() != 0)
|
||||
game.place[LIQUID()] = CARRIED;
|
||||
if (GSTONE(obj) && game.prop[obj] != 0) {
|
||||
game.prop[obj] = 0;
|
||||
game.prop[obj] = STATE_GROUND;
|
||||
game.prop[CAVITY] = CAVITY_EMPTY;
|
||||
}
|
||||
rspeak(OK_MAN);
|
||||
|
|
5
advent.h
5
advent.h
|
@ -19,11 +19,14 @@
|
|||
#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
|
||||
|
||||
/* Special object-state values - integers > 0 are object-specific */
|
||||
#define STATE_NOTFOUND -1 // 'Not found" state of treasures */
|
||||
#define STATE_GROUND 0 // After discovered, before messed with
|
||||
|
||||
/*
|
||||
* MOD(N,M) = Arithmetic modulus
|
||||
* AT(OBJ) = true if on either side of two-placed object
|
||||
|
|
2
init.c
2
init.c
|
@ -91,7 +91,7 @@ long initialise(void)
|
|||
for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
|
||||
if (objects[treasure].is_treasure) {
|
||||
if (objects[treasure].inventory != 0)
|
||||
game.prop[treasure] = NOT_YET_FOUND;
|
||||
game.prop[treasure] = STATE_NOTFOUND;
|
||||
game.tally = game.tally - game.prop[treasure];
|
||||
}
|
||||
}
|
||||
|
|
4
main.c
4
main.c
|
@ -185,7 +185,7 @@ static void checkhints(void)
|
|||
game.hintlc[hint] = 0;
|
||||
return;
|
||||
case 4: /* dark */
|
||||
if (game.prop[EMERALD] != NOT_YET_FOUND && game.prop[PYRAMID] == NOT_YET_FOUND)
|
||||
if (game.prop[EMERALD] != STATE_NOTFOUND && game.prop[PYRAMID] == STATE_NOTFOUND)
|
||||
break;
|
||||
game.hintlc[hint] = 0;
|
||||
return;
|
||||
|
@ -1076,7 +1076,7 @@ L2607:
|
|||
packed_to_token(command.wd2, word2);
|
||||
V1 = get_vocab_id(word1);
|
||||
V2 = get_vocab_id(word2);
|
||||
if (V1 == ENTER && (V2 == STREAM || V2 == 1000 + WATER)) {
|
||||
if (V1 == ENTER && (V2 == STREAM || V2 == PROMOTE_WORD(WATER))) {
|
||||
if (LIQLOC(game.loc) == WATER) {
|
||||
rspeak(FEET_WET);
|
||||
} else {
|
||||
|
|
4
score.c
4
score.c
|
@ -45,9 +45,9 @@ long score(enum termination mode)
|
|||
k = 14;
|
||||
if (i > CHEST)
|
||||
k = 16;
|
||||
if (game.prop[i] >= 0)
|
||||
if (game.prop[i] > STATE_NOTFOUND)
|
||||
score += 2;
|
||||
if (game.place[i] == LOC_BUILDING && game.prop[i] == 0)
|
||||
if (game.place[i] == LOC_BUILDING && game.prop[i] == STATE_GROUND)
|
||||
score += k - 2;
|
||||
mxscor += k;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue