Magic-number elimination.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 25 Jun 2017 22:37:14 +0000 (18:37 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 25 Jun 2017 23:22:46 +0000 (19:22 -0400)
main.c

diff --git a/main.c b/main.c
index 733027f70eca8160e3813c60aaa4203c6c85d522..ad2fdb1c16ae600391696c3e6601df623101d2f9 100644 (file)
--- a/main.c
+++ b/main.c
@@ -25,6 +25,8 @@
 #include "linenoise/linenoise.h"
 #include "newdb.h"
 
+#define DIM(a) (sizeof(a)/sizeof(a[0]))
+
 struct game_t game;
 
 long LNLENG, LNPOSN;
@@ -414,7 +416,7 @@ static bool dwarfmove(void)
                                 !INDEEP(game.newloc) ||
                                 game.newloc == game.odloc[i] ||
                                 (j > 1 && game.newloc == tk[j - 1]) ||
-                                j >= 20 ||
+                                j >= DIM(tk) - 1 ||
                                 game.newloc == game.dloc[i] ||
                                 FORCED(game.newloc) ||
                                 (i == PIRATE && CNDBIT(game.newloc, COND_NOARRR)) ||