Magic-number elimination.

This commit is contained in:
Eric S. Raymond 2017-06-30 11:03:57 -04:00
parent 0bbfe6baf7
commit 46185a6e88
2 changed files with 29 additions and 29 deletions

View file

@ -139,7 +139,7 @@ motions: !!omap
words: ['downs'] words: ['downs']
- MOT_6: - MOT_6:
words: ['fores'] words: ['fores']
- MOT_7: - FORWARD:
words: ['forwa', 'conti', 'onwar'] words: ['forwa', 'conti', 'onwar']
- BACK: - BACK:
words: ['back', 'retur', 'retre'] words: ['back', 'retur', 'retre']
@ -147,7 +147,7 @@ motions: !!omap
words: ['valle'] words: ['valle']
- MOT_10: - MOT_10:
words: ['stair'] words: ['stair']
- MOT_11: - OUTSIDE:
words: ['out', 'outsi', 'exit', 'leave'] words: ['out', 'outsi', 'exit', 'leave']
- MOT_12: - MOT_12:
words: ['build', 'house'] words: ['build', 'house']
@ -159,11 +159,11 @@ motions: !!omap
words: ['fork'] words: ['fork']
- MOT_16: - MOT_16:
words: ['bed'] words: ['bed']
- MOT_17: - CRAWL:
words: ['crawl'] words: ['crawl']
- MOT_18: - MOT_18:
words: ['cobbl'] words: ['cobbl']
- MOT_19: - INSIDE:
words: ['inwar', 'insid', 'in'] words: ['inwar', 'insid', 'in']
- MOT_20: - MOT_20:
words: ['surfa'] words: ['surfa']
@ -183,9 +183,9 @@ motions: !!omap
words: ['giant'] words: ['giant']
- MOT_28: - MOT_28:
words: ['view'] words: ['view']
- MOT_29: - UP:
words: ['upwar', 'up', 'u', 'above', 'ascen'] words: ['upwar', 'up', 'u', 'above', 'ascen']
- MOT_30: - DOWN:
words: ['d', 'downw', 'down', 'desce'] words: ['d', 'downw', 'down', 'desce']
- MOT_31: - MOT_31:
words: ['pit'] words: ['pit']
@ -197,9 +197,9 @@ motions: !!omap
words: ['steps'] words: ['steps']
- MOT_35: - MOT_35:
words: ['dome'] words: ['dome']
- MOT_36: - LEFT:
words: ['left'] words: ['left']
- MOT_37: - RIGHT:
words: ['right'] words: ['right']
- MOT_38: - MOT_38:
words: ['hall'] words: ['hall']
@ -211,21 +211,21 @@ motions: !!omap
words: ['over'] words: ['over']
- MOT_42: - MOT_42:
words: ['acros'] words: ['acros']
- MOT_43: - EAST:
words: ['east', 'e'] words: ['east', 'e']
- MOT_44: - WEST:
words: ['west', 'w'] words: ['west', 'w']
- MOT_45: - MOT_45:
words: ['north', 'n'] words: ['north', 'n']
- MOT_46: - MOT_46:
words: ['south', 's'] words: ['south', 's']
- MOT_47: - NE:
words: ['ne'] words: ['ne']
- MOT_48: - SE:
words: ['se'] words: ['se']
- MOT_49: - SW:
words: ['sw'] words: ['sw']
- MOT_50: - NW:
words: ['nw'] words: ['nw']
- MOT_51: - MOT_51:
words: ['debri'] words: ['debri']
@ -249,13 +249,13 @@ motions: !!omap
words: ['slit'] words: ['slit']
- MOT_61: - MOT_61:
words: ['slab', 'slabr'] words: ['slab', 'slabr']
- MOT_62: - XYZZY:
words: ['xyzzy'] words: ['xyzzy']
- DPRSSN: - DPRSSN:
words: ['depre'] words: ['depre']
- ENTRNC: - ENTRNC:
words: ['entra'] words: ['entra']
- MOT_65: - PLUGH:
words: ['plugh'] words: ['plugh']
- MOT_66: - MOT_66:
words: ['secre'] words: ['secre']
@ -265,19 +265,19 @@ motions: !!omap
words: !!null words: !!null
- MOT_69: - MOT_69:
words: ['cross'] words: ['cross']
- MOT_70: - FORWARD0:
words: ['bedqu'] words: ['bedqu']
- MOT_71: - FORWARD1:
words: ['plove'] words: ['plove']
- MOT_72: - FORWARD2:
words: ['orien'] words: ['orien']
- MOT_73: - FORWARD3:
words: ['caver'] words: ['caver']
- MOT_74: - FORWARD4:
words: ['shell'] words: ['shell']
- MOT_75: - FORWARD5:
words: ['reser'] words: ['reser']
- MOT_76: - FORWARD6:
words: ['main', 'offic'] words: ['main', 'offic']
actions: !!omap actions: !!omap

12
main.c
View file

@ -602,19 +602,19 @@ static bool playermove(token_t verb, int motion)
/* Couldn't find an entry matching the motion word passed /* Couldn't find an entry matching the motion word passed
* in. Various messages depending on word given. */ * in. Various messages depending on word given. */
int spk = CANT_APPLY; int spk = CANT_APPLY;
if (motion >= MOT_43 && motion <= MOT_50) if (motion >= EAST && motion <= NW)
spk = BAD_DIRECTION; spk = BAD_DIRECTION;
if (motion == MOT_29 || motion == MOT_30) if (motion == UP || motion == DOWN)
spk = BAD_DIRECTION; spk = BAD_DIRECTION;
if (motion == MOT_7 || motion == MOT_36 || motion == MOT_37) if (motion == FORWARD || motion == LEFT || motion == RIGHT)
spk = UNSURE_FACING; spk = UNSURE_FACING;
if (motion == MOT_11 || motion == MOT_19) if (motion == OUTSIDE || motion == INSIDE)
spk = NO_INOUT_HERE; spk = NO_INOUT_HERE;
if (verb == FIND || verb == INVENTORY) if (verb == FIND || verb == INVENTORY)
spk = NEARBY; spk = NEARBY;
if (motion == MOT_62 || motion == MOT_65) if (motion == XYZZY || motion == PLUGH)
spk = NOTHING_HAPPENS; spk = NOTHING_HAPPENS;
if (motion == MOT_17) if (motion == CRAWL)
spk = WHICH_WAY; spk = WHICH_WAY;
rspeak(spk); rspeak(spk);
return true; return true;