More magic-number hunting -- BASEMAX this time.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 6 Feb 2005 16:45:25 +0000 (16:45 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 6 Feb 2005 16:45:25 +0000 (16:45 +0000)
ai.c
setup.c
sst.h

diff --git a/ai.c b/ai.c
index db9de871bc6b154eb3face6016ef430eba3c1a1e..1367f43747ead849898d1ed5450e4c80ff7498fe 100644 (file)
--- a/ai.c
+++ b/ai.c
@@ -364,8 +364,8 @@ static int movescom(int iqx, int iqy, int flag, int *ipage) {
 void scom(int *ipage) {
        int i, i2, j, ideltax, ideltay, ibqx, ibqy, sx, sy, ifindit, iwhichb;
        int iqx, iqy;
-       int basetbl[6];
-       double bdist[6];
+       int basetbl[BASEMAX];
+       double bdist[BASEMAX];
        int flag;
 #ifdef DEBUG
        if (idebug) prout("SCOM");
diff --git a/setup.c b/setup.c
index 0ecac03b081801da608d2d75cb8cdc2d44b225bb..572d92284d088680fb9527e5fdad451a5aa53d12 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -253,7 +253,7 @@ void setup(int needprompt) {
                        for (j = i-1; j > 0; j--) {
                                /* Improved placement algorithm to spread out bases */
                                double distq = square(ix-game.state.baseqx[j]) + square(iy-game.state.baseqy[j]);
-                               if (distq < 6.0*(6-inbase) && Rand() < 0.75) {
+                               if (distq < 6.0*(BASEMAX-inbase) && Rand() < 0.75) {
                                        contflag = TRUE;
 #ifdef DEBUG
                                        proutn("DEBUG: Abandoning base #%d at %d-%d\n", i, ix, iy);
@@ -261,7 +261,7 @@ void setup(int needprompt) {
                                        break;
                                }
 #ifdef DEBUG
-                               else if (distq < 6.0 * (6-inbase)) {
+                               else if (distq < 6.0 * (BASEMAX-inbase)) {
                                        proutn("DEBUG: saving base #%d, close to #%d\n", i, j);
                                }
 #endif
diff --git a/sst.h b/sst.h
index beeee5c6dfc1d1291b68f773c686c3c523e8baa6..0cb66ceccfae6e26d1d9efa7ea20b1399c3ba4eb 100644 (file)
--- a/sst.h
+++ b/sst.h
@@ -20,6 +20,7 @@
 #define NEVENTS (8)
 #define GALSIZE        (8)
 #define QUADSIZE (10)
+#define BASEMAX        (6)
 
 typedef struct {
     int x;     /* Quadrant location of planet */
@@ -42,8 +43,8 @@ typedef struct {
        killc,                  // commanders killed
        galaxy[GALSIZE+1][GALSIZE+1],   // The Galaxy (subscript 0 not used)
        cx[QUADSIZE+1],cy[QUADSIZE+1],  // Commander quadrant coordinates
-       baseqx[6],              // Base quadrant X
-       baseqy[6],              // Base quadrant Y
+       baseqx[BASEMAX],                // Base quadrant X
+       baseqy[BASEMAX],                // Base quadrant Y
        newstuf[GALSIZE+1][GALSIZE+1],  // Extended galaxy goodies
        isx, isy,               // Coordinate of Super Commander
        nscrem,                 // remaining super commanders