Magic-number elimination.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 5 Jul 2017 07:17:24 +0000 (03:17 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 5 Jul 2017 07:17:24 +0000 (03:17 -0400)
actions.c
make_dungeon.py

index 686d0a676387d649c4c3654690f4cdf0d4b95de1..06da68805481e1526c7a24687b09c9224188b6b1 100644 (file)
--- 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;
     }
index 576601d675f3ee4142ef37962082e306e1d40c11..4e3c88e219284af62a62de64397d3c7bbfab4f3e 100755 (executable)
@@ -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"]),