From: Eric S. Raymond Date: Wed, 5 Jul 2017 07:17:24 +0000 (-0400) Subject: Magic-number elimination. X-Git-Tag: takebird~14 X-Git-Url: https://jxself.org/git/?p=open-adventure.git;a=commitdiff_plain;h=7be7ac9406512644886fbf4a99d16e1b4f7cefc3 Magic-number elimination. --- diff --git a/actions.c b/actions.c index 686d0a6..06da688 100644 --- a/actions.c +++ b/actions.c @@ -889,8 +889,7 @@ static int listen(void) long packed_zzword = token_to_packed(game.zzword); pspeak(i, hear, mi, true, packed_zzword); rspeak(NO_MESSAGE); - /* FIXME: Magic number, sensitive to bird state logic */ - if (i == BIRD && game.prop[i] == 5) + if (i == BIRD && mi == BIRD_ENDSTATE) DESTROY(BIRD); return GO_CLEAROBJ; } diff --git a/make_dungeon.py b/make_dungeon.py index 576601d..4e3c88e 100755 --- a/make_dungeon.py +++ b/make_dungeon.py @@ -192,6 +192,8 @@ extern const char *ignore; #define NTRAVEL {} #define NKEYS {} +#define BIRD_ENDSTATE {} + enum arbitrary_messages_refs {{ {} }}; @@ -768,6 +770,10 @@ if __name__ == "__main__": ignore, ) + # 0-origin index of birds's last song. Bird should + # die after player hears this. + deathbird = len(dict(db["objects"])["BIRD"]["sounds"]) - 1 + h = h_template.format( len(db["locations"])-1, len(db["objects"])-1, @@ -780,6 +786,7 @@ if __name__ == "__main__": len(db["specials"]), len(travel), len(tkey), + deathbird, get_refs(db["arbitrary_messages"]), get_refs(db["locations"]), get_refs(db["objects"]),