line = FSPY;
if (alldone) return;
datemin = fintim;
- for (l=1; l<=NEVENTS; l++)
+ for (l = 1; l <= NEVENTS; l++)
if (game.future[l] < datemin) {
line = l;
datemin = game.future[l];
break;
}
i = 0;
- for (j=1; j<=game.state.rembase; j++) {
- for (k=1; k<=game.state.remcom; k++)
+ for_commanders (j) {
+ for_commanders(k)
if (game.state.baseqx[j]==game.state.cx[k] && game.state.baseqy[j]==game.state.cy[k] &&
(game.state.baseqx[j]!=quadx || game.state.baseqy[j]!=quady) &&
(game.state.baseqx[j]!=game.state.isx || game.state.baseqy[j]!=game.state.isy)) {
if (line==FCDBAS) {
game.future[FCDBAS] = 1e30;
/* find the lucky pair */
- for (i = 1; i <= game.state.remcom; i++)
+ for_commanders(i)
if (game.state.cx[i]==batx && game.state.cy[i]==baty)
break;
if (i > game.state.remcom || game.state.rembase == 0 ||
}
/* Remove Starbase from galaxy */
game.state.galaxy[batx][baty].starbase = FALSE;
- for (i=1; i <= game.state.rembase; i++)
+ for_starbases(i)
if (game.state.baseqx[i]==batx && game.state.baseqy[i]==baty) {
game.state.baseqx[i]=game.state.baseqx[game.state.rembase];
game.state.baseqy[i]=game.state.baseqy[game.state.rembase];
if (probecx != i || probecy != j) {
probecx = i;
probecy = j;
- if (i < 1 || i > GALSIZE || j < 1 || j > GALSIZE ||
+ if (!VALID_QUADRANT(i, j) ||
game.state.galaxy[probecx][probecy].supernova) {
// Left galaxy or ran into supernova
if (game.damage[DRADIO]==0.0 || condit == IHDOCKED) {
ipage = 1;
skip(1);
proutn("Lt. Uhura- \"The deep space probe ");
- if (i < 1 ||i > GALSIZE || j < 1 || j > GALSIZE)
+ if (!VALID_QUADRANT(j, i))
proutn("has left the galaxy");
else
proutn("is no longer transmitting");
if (j==2 && nn== 2) continue;
ii = hits[mm][1]+nn-2;
jj = hits[mm][2]+j-2;
- if (ii < 1 || ii > QUADSIZE || jj < 1 || jj > QUADSIZE) continue;
+ if (!VALID_SECTOR(jj, ii)) continue;
iquad = game.quad[ii][jj];
switch (iquad) {
// case IHDOT: /* Empty space ends reaction
break;
case IHB: /* Destroy base */
game.state.galaxy[quadx][quady].starbase = FALSE;
- for (i = 1; i <= game.state.rembase; i++)
+ for_starbases(i)
if (game.state.baseqx[i]==quadx && game.state.baseqy[i]==quady)
break;
game.state.baseqx[i] = game.state.baseqx[game.state.rembase];
case IHC: /* Damage/destroy big enemies */
case IHS:
case IHR:
- for (ll = 1; ll <= nenhere; ll++)
+ for_local_enemies(ll)
if (game.kx[ll]==ii && game.ky[ll]==jj) break;
game.kpower[ll] -= 800.0; /* If firepower is lost, die */
if (game.kpower[ll] <= 0.0) {
newcy = jj + jj - hits[mm][2];
crmena(1, iquad, 2, ii, jj);
proutn(" damaged");
- if (newcx<1 || newcx>QUADSIZE || newcy<1 || newcy>QUADSIZE) {
+ if (!VALID_SECTOR(newcx, newcy)) {
/* can't leave quadrant */
skip(1);
break;
/* Scheduled supernova -- select star */
/* logic changed here so that we won't favor quadrants in top
left of universe */
- for (nqx = 1; nqx<=GALSIZE; nqx++) {
- for (nqy = 1; nqy<=GALSIZE; nqy++) {
+ for_quadrants(nqx) {
+ for_quadrants(nqy) {
stars += game.state.galaxy[nqx][nqy].stars;
}
}
if (stars == 0) return; /* nothing to supernova exists */
num = Rand()*stars + 1;
- for (nqx = 1; nqx<=GALSIZE; nqx++) {
- for (nqy = 1; nqy<=GALSIZE; nqy++) {
+ for_quadrants(nqx) {
+ for_quadrants(nqy) {
num -= game.state.galaxy[nqx][nqy].stars;
if (num <= 0) break;
}
/* we are in the quadrant! */
incipient = 1;
num = Rand()* game.state.galaxy[nqx][nqy].stars + 1;
- for (nsx=1; nsx < QUADSIZE; nsx++) {
- for (nsy=1; nsy < QUADSIZE; nsy++) {
+ for_sectors(nsx) {
+ for_sectors(nsy) {
if (game.quad[nsx][nsy]==IHSTAR) {
num--;
if (num==0) break;