X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;ds=sidebyside;f=battle.c;h=549039999cdbf594490e157a670a81c466325d2b;hb=0e1982742e811243ff7887fbc8e1963f31138608;hp=5356e3d14f9f11a1bdcb6a7ed057dc8d20274610;hpb=e536fe754b3a9be00dcaee8f6ec50ea2d8c7a184;p=super-star-trek.git diff --git a/battle.c b/battle.c index 5356e3d..5490399 100644 --- 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; } @@ -634,7 +633,7 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) switch (type) { case IHC: comhere = 0; - for (i=1; i<=game.state.remcom; i++) + for_commanders (i) if (game.state.cx[i]==quadx && game.state.cy[i]==quady) break; game.state.cx[i] = game.state.cx[game.state.remcom]; game.state.cy[i] = game.state.cy[game.state.remcom]; @@ -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; }