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 */
if (irun == 0) {
/* avoid intruding on another commander's territory */
if (ienm == IHC) {
- for (l = 1; l <= game.state.remcom; l++)
+ for_commanders(l)
if (game.state.cx[l]==iqx && game.state.cy[l]==iqy) return 0;
/* refuse to leave if currently attacking starbase */
if (batx==quadx && baty==quady) return 0;
game.state.isy=iqy;
}
else {
- for (l=1; l<=game.state.remcom; l++) {
+ for_commanders(l) {
if (game.state.cx[l]==quadx && game.state.cy[l]==quady) {
game.state.cx[l]=iqx;
game.state.cy[l]=iqy;
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;
continue;
/* if there is a commander, an no other base is appropriate,
we will take the one with the commander */
- for (j = 1; j <= game.state.remcom; j++) {
+ for_commanders (j) {
if (ibqx==game.state.cx[j] && ibqy==game.state.cy[j] && ifindit!= 2) {
ifindit = 2;
iwhichb = i;
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;