From 1f45966decac274509ba6b179555585344354863 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 30 Jun 2017 11:58:17 -0400 Subject: [PATCH] Magic-number ellimination, contiguity warnings, cleanup. --- actions.c | 8 ++++---- adventure.yaml | 6 ++++-- tests/resumefail2.log | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/actions.c b/actions.c index 5e2f5a3..fbd7f55 100644 --- a/actions.c +++ b/actions.c @@ -92,10 +92,10 @@ static int attack(struct command_t *command) } } spk = (dwarves > 1) ? OGRE_PANIC1 : OGRE_PANIC2; - } else if (obj == BEAR) + } else if (obj == BEAR) { /* FIXME: Arithmetic on message numbers */ spk = BEAR_HANDS + (game.prop[BEAR] + 1) / 2; - else if (obj == DRAGON && game.prop[DRAGON] == 0) { + } else if (obj == DRAGON && game.prop[DRAGON] == 0) { /* Fun stuff for dragon. If he insists on attacking it, win! * Set game.prop to dead, move dragon to central loc (still * fixed), move rug there (not fixed), and move him there, @@ -966,8 +966,8 @@ static int say(struct command_t *command) char word1[6]; packed_to_token(command->wd1, word1); int wd = (int) get_vocab_id(word1); - /* FIXME: Magic numbers */ - if (wd == 62 || wd == 65 || wd == 71 || wd == 2025 || wd == 2034) { + /* FIXME: issue in lexical analyzer, last two magic numbers can't change */ + if (wd == XYZZY || wd == PLUGH || wd == PLOVER || wd == 2025 || wd == 2034) { /* FIXME: scribbles on the interpreter's command block */ wordclear(&command->wd2); return GO_LOOKUP; diff --git a/adventure.yaml b/adventure.yaml index 83296a7..e7ff38b 100644 --- a/adventure.yaml +++ b/adventure.yaml @@ -266,9 +266,9 @@ motions: !!omap words: !!null - MOT_69: words: ['cross'] -- FORWARD0: +- BEDQUILT: words: ['bedqu'] -- FORWARD1: +- PLOVER: words: ['plove'] - FORWARD2: words: ['orien'] @@ -2676,6 +2676,7 @@ arbitrary_messages: !!omap - TROLL_SCAMPERS: 'The bear lumbers toward the troll, who lets out a startled shriek and\nscurries away. The bear soon gives up the pursuit and wanders back.' - AXE_LOST: 'The axe misses and lands near the bear where you can''t get at it.' - BEAR_HANDS: 'With what? Your bare hands? Against *HIS* bear hands??' +# The following three messages must be contiguous - BEAR_CONFUSED: 'The bear is confused; he only wants to be your friend.' - ALREADY_DEAD: 'For crying out loud, the poor thing is already dead!' - BEAR_TAMED: 'The bear eagerly wolfs down your food, after which he seems to calm\ndown considerably and even becomes rather friendly.' @@ -2709,6 +2710,7 @@ arbitrary_messages: !!omap - OGRE_DODGE: 'The ogre, who despite his bulk is quite agile, easily dodges your\nattack. He seems almost amused by your puny effort.' - OGRE_PANIC1: 'The ogre, distracted by your rush, is struck by the knife. With a\nblood-curdling yell he turns and bounds after the dwarves, who flee\nin panic. You are left alone in the room.' - OGRE_PANIC2: 'The ogre, distracted by your rush, is struck by the knife. With a\nblood-curdling yell he turns and bounds after the dwarf, who flees\nin panic. You are left alone in the room.' +# Following three messages must be contiguous - FREE_FLY: 'The bird flies about agitatedly for a moment.' - CAGE_FLY: 'The bird flies agitatedly about the cage.' - NECKLACE_FLY: 'The bird flies about agitatedly for a moment, then disappears through\nthe crack. It reappears shortly, carrying in its beak a jade\nnecklace, which it drops at your feet.' diff --git a/tests/resumefail2.log b/tests/resumefail2.log index 1cde52e..0682156 100644 --- a/tests/resumefail2.log +++ b/tests/resumefail2.log @@ -1,5 +1,5 @@ -## Resume input from cheat-generated save inducing a version mismatch error +## Resume from cheat-generated save inducing version mismatch error n resume y -resume_badversion.adv \ No newline at end of file +resume_badversion.adv -- 2.31.1