Magic-number elimination.

This commit is contained in:
Eric S. Raymond 2017-07-01 22:50:08 -04:00
parent 16688c6d8f
commit 5c2b76f762
2 changed files with 13 additions and 12 deletions

View file

@ -123,7 +123,7 @@ static int attack(struct command_t *command)
} }
state_change(DRAGON, DRAGON_DEAD); state_change(DRAGON, DRAGON_DEAD);
game.prop[RUG] = RUG_FLOOR; game.prop[RUG] = RUG_FLOOR;
/* FIXME: Arithmentic on location values */ /* FIXME: Arithmetic on location values */
int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2; int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
move(DRAGON + NOBJECTS, -1); move(DRAGON + NOBJECTS, -1);
move(RUG + NOBJECTS, 0); move(RUG + NOBJECTS, 0);
@ -172,11 +172,11 @@ static int bigwords(token_t foo)
* crossing. */ * crossing. */
if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID) if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
game.prop[TROLL] = TROLL_PAIDONCE; game.prop[TROLL] = TROLL_PAIDONCE;
k = 2; k = EGGS_DONE;
if (HERE(EGGS)) if (HERE(EGGS))
k = 1; k = EGGS_VANISHED;
if (game.loc == objects[EGGS].plac) if (game.loc == objects[EGGS].plac)
k = 0; k = EGGS_HERE;
move(EGGS, objects[EGGS].plac); move(EGGS, objects[EGGS].plac);
pspeak(EGGS, look, k); pspeak(EGGS, look, k);
return GO_CLEAROBJ; return GO_CLEAROBJ;
@ -444,15 +444,15 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
move(TROLL2, objects[TROLL].plac); move(TROLL2, objects[TROLL].plac);
move(TROLL2 + NOBJECTS, objects[TROLL].fixd); move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
juggle(CHASM); juggle(CHASM);
game.prop[TROLL] = 2; game.prop[TROLL] = TROLL_GONE;
} else if (obj != VASE || game.loc == objects[PILLOW].plac) { } else if (obj != VASE || game.loc == objects[PILLOW].plac) {
rspeak(OK_MAN); rspeak(OK_MAN);
} else { } else {
game.prop[VASE] = 2; game.prop[VASE] = VASE_BROKEN;
if (AT(PILLOW)) if (AT(PILLOW))
game.prop[VASE] = 0; game.prop[VASE] = VASE_WHOLE;
pspeak(VASE, look, game.prop[VASE] + 1); pspeak(VASE, look, game.prop[VASE] + 1);
if (game.prop[VASE] != 0) if (game.prop[VASE] != VASE_WHOLE)
game.fixed[VASE] = -1; game.fixed[VASE] = -1;
} }
} }
@ -605,7 +605,7 @@ int fill(token_t verb, token_t obj)
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
rspeak(SHATTER_VASE); rspeak(SHATTER_VASE);
game.prop[VASE] = 2; game.prop[VASE] = VASE_BROKEN;
game.fixed[VASE] = -1; game.fixed[VASE] = -1;
return (discard(verb, obj, true)); return (discard(verb, obj, true));
} else if (obj == URN) { } else if (obj == URN) {

View file

@ -3330,6 +3330,7 @@ objects: !!omap
- [TROLL_GONE, ''] # chased away - [TROLL_GONE, ''] # chased away
sounds: sounds:
- 'The troll sounds quite adamant in his demand for a treasure.' - 'The troll sounds quite adamant in his demand for a treasure.'
- 'The troll sounds quite adamant in his demand for a treasure.'
- TROLL2: - TROLL2:
words: ['troll'] words: ['troll']
inventory: '*phony troll' inventory: '*phony troll'
@ -3514,9 +3515,9 @@ objects: !!omap
locations: LOC_GIANTROOM locations: LOC_GIANTROOM
treasure: true treasure: true
descriptions: descriptions:
- 'There is a large nest here, full of golden eggs!' - [EGGS_HERE, 'There is a large nest here, full of golden eggs!']
- 'The nest of golden eggs has vanished!' - [EGGS_VANISHED, 'The nest of golden eggs has vanished!']
- 'Done!' - [EGGS_DONE, 'Done!']
- TRIDENT: - TRIDENT:
words: ['tride'] words: ['tride']
inventory: 'Jeweled trident' inventory: 'Jeweled trident'