Hide some differences between 0-origin and 1-origin addressing.
[super-star-trek.git] / ai.c
diff --git a/ai.c b/ai.c
index c6a862ea25c2c4ff01ae63af5db386c21b163533..f1eca73a58c3614408429158dd4e3d99f45ba539 100644 (file)
--- a/ai.c
+++ b/ai.c
@@ -6,7 +6,7 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun)
 
     iqx = quadx+(lookx+(QUADSIZE-1))/QUADSIZE - 1;
     iqy = quady+(looky+(QUADSIZE-1))/QUADSIZE - 1;
-    if (iqx < 1 || iqx > GALSIZE || iqy < 1 || iqy > GALSIZE ||
+    if (!VALID_QUADRANT(iqx,iqy) ||
        game.state.galaxy[iqx][iqy].supernova ||
        game.state.galaxy[iqx][iqy].klingons > 8)
        return 0; /* no can do -- neg energy, supernovae, or >8 Klingons */
@@ -307,7 +307,7 @@ static int movescom(int iqx, int iqy, int flag, int *ipage)
     int i;
 
     if ((iqx==quadx && iqy==quady) ||
-       iqx < 1 || iqx > GALSIZE || iqy < 1 || iqy > GALSIZE ||
+       !VALID_QUADRANT(iqx, iqy) ||
        game.state.galaxy[iqx][iqy].supernova ||
        game.state.galaxy[iqx][iqy].klingons > 8) 
        return 1;
@@ -595,7 +595,7 @@ void movetho(void)
     game.ky[nenhere]=ithy;
 
     /* check to see if all holes plugged */
-    for (i = 1; i < QUADSIZE+1; i++) {
+    for_sectors(i) {
        if (game.quad[1][i]!=IHWEB && game.quad[1][i]!=IHT) return;
        if (game.quad[QUADSIZE][i]!=IHWEB && game.quad[QUADSIZE][i]!=IHT) return;
        if (game.quad[i][1]!=IHWEB && game.quad[i][1]!=IHT) return;