Do not compare state to magic numbers

This commit is contained in:
NHOrus 2017-07-01 18:12:25 +03:00
parent b8d86b840d
commit ab79fc7814
3 changed files with 18 additions and 16 deletions

View file

@ -170,8 +170,8 @@ static int bigwords(token_t foo)
} else { } else {
/* Bring back troll if we steal the eggs back from him before /* Bring back troll if we steal the eggs back from him before
* crossing. */ * crossing. */
if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == 0) if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
game.prop[TROLL] = 1; game.prop[TROLL] = TROLL_PAIDONCE;
k = 2; k = 2;
if (HERE(EGGS)) if (HERE(EGGS))
k = 1; k = 1;
@ -354,21 +354,21 @@ static int chain(token_t verb)
spk = CHAIN_UNLOCKED; spk = CHAIN_UNLOCKED;
if (game.prop[BEAR] == UNTAMED_BEAR) if (game.prop[BEAR] == UNTAMED_BEAR)
spk = BEAR_BLOCKS; spk = BEAR_BLOCKS;
if (game.prop[CHAIN] == 0) if (game.prop[CHAIN] == CHAIN_HEAP)
spk = ALREADY_UNLOCKED; spk = ALREADY_UNLOCKED;
if (spk != CHAIN_UNLOCKED) { if (spk != CHAIN_UNLOCKED) {
rspeak(spk); rspeak(spk);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
game.prop[CHAIN] = 0; game.prop[CHAIN] = CHAIN_HEAP;
game.fixed[CHAIN] = 0; game.fixed[CHAIN] = CHAIN_HEAP;
if (game.prop[BEAR] != BEAR_DEAD) if (game.prop[BEAR] != BEAR_DEAD)
game.prop[BEAR] = CONTENTED_BEAR; game.prop[BEAR] = CONTENTED_BEAR;
/* FIXME: Arithmetic on state numbers */ /* FIXME: Arithmetic on state numbers */
game.fixed[BEAR] = 2 - game.prop[BEAR]; game.fixed[BEAR] = 2 - game.prop[BEAR];
} else { } else {
spk = CHAIN_LOCKED; spk = CHAIN_LOCKED;
if (game.prop[CHAIN] != 0) if (game.prop[CHAIN] != CHAIN_HEAP)
spk = ALREADY_LOCKED; spk = ALREADY_LOCKED;
if (game.loc != objects[CHAIN].plac) if (game.loc != objects[CHAIN].plac)
spk = NO_LOCKSITE; spk = NO_LOCKSITE;
@ -376,7 +376,7 @@ static int chain(token_t verb)
rspeak(spk); rspeak(spk);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
game.prop[CHAIN] = 2; game.prop[CHAIN] = CHAIN_FIXED;
if (TOTING(CHAIN)) if (TOTING(CHAIN))
drop(CHAIN, game.loc); drop(CHAIN, game.loc);
game.fixed[CHAIN] = -1; game.fixed[CHAIN] = -1;

View file

@ -3724,9 +3724,9 @@ objects: !!omap
immovable: true immovable: true
treasure: true treasure: true
descriptions: descriptions:
- 'There is a golden chain lying in a heap on the floor!' - [CHAIN_HEAP, 'There is a golden chain lying in a heap on the floor!']
- 'The bear is locked to the wall with a golden chain!' - [CHAINING_BEAR, 'The bear is locked to the wall with a golden chain!']
- 'There is a golden chain locked to the wall!' - [CHAIN_FIXED, 'There is a golden chain locked to the wall!']
- RUBY: - RUBY:
words: ['ruby'] words: ['ruby']
inventory: 'Giant ruby' inventory: 'Giant ruby'

14
main.c
View file

@ -770,8 +770,8 @@ static bool closecheck(void)
juggle(CHASM); juggle(CHASM);
if (game.prop[BEAR] != BEAR_DEAD) if (game.prop[BEAR] != BEAR_DEAD)
DESTROY(BEAR); DESTROY(BEAR);
game.prop[CHAIN] = 0; game.prop[CHAIN] = CHAIN_HEAP;
game.fixed[CHAIN] = 0; game.fixed[CHAIN] = CHAIN_HEAP;
game.prop[AXE] = 0; game.prop[AXE] = 0;
game.fixed[AXE] = 0; game.fixed[AXE] = 0;
rspeak(CAVE_CLOSING); rspeak(CAVE_CLOSING);
@ -873,8 +873,8 @@ static void listobjects(void)
/* Print out descriptions of objects at this location. If /* Print out descriptions of objects at this location. If
* not closing and property value is negative, tally off * not closing and property value is negative, tally off
* another treasure. Rug is special case; once seen, its * another treasure. Rug is special case; once seen, its
* game.prop is 1 (dragon on it) till dragon is killed. * game.prop is RUG_DRAGON (dragon on it) till dragon is killed.
* Similarly for chain; game.prop is initially 1 (locked to * Similarly for chain; game.prop is initially CHAINING_BEAR (locked to
* bear). These hacks are because game.prop=0 is needed to * bear). These hacks are because game.prop=0 is needed to
* get full score. */ * get full score. */
{ {
@ -890,8 +890,10 @@ static void listobjects(void)
if (game.closed) if (game.closed)
continue; continue;
game.prop[obj] = 0; game.prop[obj] = 0;
if (obj == RUG || obj == CHAIN) if (obj == RUG)
game.prop[obj] = 1; game.prop[RUG] = RUG_DRAGON;
if (obj == CHAIN)
game.prop[CHAIN] = CHAINING_BEAR;
--game.tally; --game.tally;
/* Note: There used to be a test here to see whether the /* Note: There used to be a test here to see whether the
* player had blown it so badly that he could never ever see * player had blown it so badly that he could never ever see