Hide some differences between 0-origin and 1-origin addressing.
[super-star-trek.git] / battle.c
index 5356e3d14f9f11a1bdcb6a7ed057dc8d20274610..ef45ca275b001e9158f1f5a745920e09535c3f3e 100644 (file)
--- a/battle.c
+++ b/battle.c
@@ -198,10 +198,9 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int wait, i
     for (l=1; l <= 15; l++) {
        x += deltax;
        ix = x + 0.5;
-       if (ix < 1 || ix > QUADSIZE) break;
        y += deltay;
        iy = y + 0.5;
-       if (iy < 1 || iy > QUADSIZE) break;
+       if (!VALID_SECTOR(ix, iy)) break;
        iquad=game.quad[ix][iy];
        tracktorpedo(x, y, ix, iy, wait, l, i, n, iquad);
        wait = 1;
@@ -230,7 +229,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int wait, i
            yy = cos(ang)/temp;
            jx=ix+xx+0.5;
            jy=iy+yy+0.5;
-           if (jx<1 || jx>QUADSIZE || jy<1 ||jy > QUADSIZE) return;
+           if (!VALID_SECTOR(jx, jy)) return;
            if (game.quad[jx][jy]==IHBLANK) {
                finish(FHOLE);
                return;
@@ -278,7 +277,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int wait, i
            yy = cos(ang)/temp;
            jx=ix+xx+0.5;
            jy=iy+yy+0.5;
-           if (jx<1 || jx>QUADSIZE || jy<1 ||jy > QUADSIZE) {
+           if (!VALID_SECTOR(jx, jy)) {
                prout(" damaged but not destroyed.");
                return;
            }
@@ -690,7 +689,7 @@ static int targetcheck(double x, double y, double *course)
 {
     double deltx, delty;
     /* Return TRUE if target is invalid */
-    if (x < 1.0 || x > QUADSIZE || y < 1.0 || y > QUADSIZE) {
+    if (!VALID_SECTOR(x, y)) {
        huh();
        return 1;
     }