Magic-number elimination.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 7 Jun 2017 01:06:16 +0000 (21:06 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 7 Jun 2017 01:06:16 +0000 (21:06 -0400)
actions2.c
advent.h
init.c

index 295f1880a1fd07dbb59213ad85170649a0b05bb9..08a62837e73449a499072458dc90ffbd97183ad4 100644 (file)
@@ -198,7 +198,7 @@ L9128:      RSPEAK(SPK);
        RSPEAK(6);
        DSTROY(OGRE);
        K=0;
-       for (I=1; I<=5; I++) {
+       for (I=1; I < PIRATE; I++) {
                if(DLOC[I] == LOC) {
                        K=K+1;
                        DLOC[I]=61;
index 13ad1e772d776ee0287c5eb6700a6947b1210d53..af9695a6d4151b982f4e9787cf0985dff9040c25 100644 (file)
--- a/advent.h
+++ b/advent.h
@@ -3,6 +3,7 @@
 
 #define LINESIZE       100
 #define NDWARVES       6
+#define PIRATE         NDWARVES        /* must be NDWARVES-1 when zero-origin */
 
 typedef struct lcg_state
 {
diff --git a/init.c b/init.c
index 53552f70226e58509fd844bab70dd7b242559037..1220d88d93e0a7683bf0693fe7b20e3ac1e1202c 100644 (file)
--- a/init.c
+++ b/init.c
@@ -330,8 +330,8 @@ L1106:      /*etc*/ ;
 
        CHLOC=114;
        CHLOC2=140;
-       for (I=1; I<=6; I++) {
-       DSEEN[I]=false;
+       for (I=1; I<=NDWARVES; I++) {
+               DSEEN[I]=false;
        } /* end loop */
        DFLAG=0;
        DLOC[1]=19;