Magic number elimination, repair some careless replace damage.

This commit is contained in:
Eric S. Raymond 2017-06-19 08:37:19 -04:00
parent df86aa283b
commit 98b02eeeb1
3 changed files with 5 additions and 5 deletions

View file

@ -578,7 +578,7 @@ static int find(token_t verb, token_t obj)
obj == LIQLOC(game.loc) || obj == LIQLOC(game.loc) ||
(obj == DWARF && ATDWRF(game.loc) > 0)) (obj == DWARF && ATDWRF(game.loc) > 0))
spk = YOU_HAVEIT; spk = YOU_HAVEIT;
if (game.closed)spk = NEEDED_NEreplace; if (game.closed)spk = NEEDED_NEARBY;
if (TOTING(obj))spk = ALREADY_CARRYING; if (TOTING(obj))spk = ALREADY_CARRYING;
RSPEAK(spk); RSPEAK(spk);
return GO_CLEAROBJ; return GO_CLEAROBJ;

View file

@ -804,7 +804,7 @@ arbitrary_messages: !!omap
- FUTILE_CRAWL: 'You have crawled around in some little holes and wound up back in the\nmain passage.' - FUTILE_CRAWL: 'You have crawled around in some little holes and wound up back in the\nmain passage.'
- FOLLOW_STREAM: 'I don''t know where the cave is, but hereabouts no stream can run on\nthe surface for long. I would try the stream.' - FOLLOW_STREAM: 'I don''t know where the cave is, but hereabouts no stream can run on\nthe surface for long. I would try the stream.'
- NEED_DETAIL: 'I need more detailed instructions to do that.' - NEED_DETAIL: 'I need more detailed instructions to do that.'
- NEreplace: 'I can only tell you what you see as you move about and manipulate\nthings. I cannot tell you where remote things are.' - NEARBY: 'I can only tell you what you see as you move about and manipulate\nthings. I cannot tell you where remote things are.'
- OGRE_SNARL: 'The ogre snarls and shoves you back.' - OGRE_SNARL: 'The ogre snarls and shoves you back.'
- HUH_MAN: 'Huh?' - HUH_MAN: 'Huh?'
- ENTRY_QUERY: 'Are you trying to get into the cave?' - ENTRY_QUERY: 'Are you trying to get into the cave?'
@ -883,7 +883,7 @@ arbitrary_messages: !!omap
- SPLATTER_MESSAGE: 'There is a loud explosion, and you are suddenly splashed across the\nwalls of the room.' - SPLATTER_MESSAGE: 'There is a loud explosion, and you are suddenly splashed across the\nwalls of the room.'
- DWARVES_AWAKEN: 'The resulting ruckus has awakened the dwarves. There are now several\nthreatening little dwarves in the room with you! Most of them throw\nknives at you! All of them get you!' - DWARVES_AWAKEN: 'The resulting ruckus has awakened the dwarves. There are now several\nthreatening little dwarves in the room with you! Most of them throw\nknives at you! All of them get you!'
- UNHAPPY_BIRD: 'Oh, leave the poor unhappy bird alone.' - UNHAPPY_BIRD: 'Oh, leave the poor unhappy bird alone.'
- NEEDED_NEreplace: 'I daresay whatever you want is around here somewhere.' - NEEDED_NEARBY: 'I daresay whatever you want is around here somewhere.'
- STOP_UNKNOWN: 'I don''t know the word "stop". Use "quit" if you want to give up.' - STOP_UNKNOWN: 'I don''t know the word "stop". Use "quit" if you want to give up.'
- NOT_CONNECTED: 'You can''t get there from here.' - NOT_CONNECTED: 'You can''t get there from here.'
- TAME_BEAR: 'You are being followed by a very large, tame bear.' - TAME_BEAR: 'You are being followed by a very large, tame bear.'

4
main.c
View file

@ -451,7 +451,7 @@ static bool dwarfmove(void)
if (game.dtotal == 0) if (game.dtotal == 0)
return true; return true;
SETPRM(1, game.dtotal, 0); SETPRM(1, game.dtotal, 0);
RSPEAK(DWARF_PACK + 1 / game.dtotal); /* FIXME: Arithmetic on message number */ RSPEAK(game.dtotal == 1 ? DWARF_SINGLE : DWARF_PACK);
if (attack == 0) if (attack == 0)
return true; return true;
if (game.dflag == 2)game.dflag = 3; if (game.dflag == 2)game.dflag = 3;
@ -606,7 +606,7 @@ static bool playermove(token_t verb, int motion)
if (motion == 29 || motion == 30)spk = BAD_DIRECTION; if (motion == 29 || motion == 30)spk = BAD_DIRECTION;
if (motion == 7 || motion == 36 || motion == 37)spk = UNSURE_FACING; if (motion == 7 || motion == 36 || motion == 37)spk = UNSURE_FACING;
if (motion == 11 || motion == 19)spk = NO_INOUT_HERE; if (motion == 11 || motion == 19)spk = NO_INOUT_HERE;
if (verb == FIND || verb == INVENT)spk = NEreplace; if (verb == FIND || verb == INVENT)spk = NEARBY;
if (motion == 62 || motion == 65)spk = NOTHING_HAPPENS; if (motion == 62 || motion == 65)spk = NOTHING_HAPPENS;
if (motion == 17)spk = WHICH_WAY; if (motion == 17)spk = WHICH_WAY;
RSPEAK(spk); RSPEAK(spk);