They interfere with mechanical translation.
if (!irun) {
/* avoid intruding on another commander's territory */
if (ienm == IHC) {
- for_commanders(n)
+ for (n = 1; n <= game.state.remcom; n++)
if (same(game.state.kcmdr[n],iq))
return false;
/* refuse to leave if currently attacking starbase */
game.state.kscmdr=iq;
}
else {
- for_commanders(n) {
+ for (n = 1; n <= game.state.remcom; n++) {
if (same(game.state.kcmdr[n], game.quadrant)) {
game.state.kcmdr[n]=iq;
break;
// Figure out which Klingon is the commander (or Supercommander)
// and do move
if (game.comhere)
- for_local_enemies(i) {
+ for (i = 1; i <= game.nenhere; i++) {
w = game.ks[i];
if (game.quad[w.x][w.y] == IHC) {
movebaddy(w, i, IHC);
}
}
if (game.ishere)
- for_local_enemies(i) {
+ for (i = 1; i <= game.nenhere; i++) {
w = game.ks[i];
if (game.quad[w.x][w.y] == IHS) {
movebaddy(w, i, IHS);
// Move these last so they can base their actions on what the
// commander(s) do.
if (game.skill >= SKILL_EXPERT && (game.options & OPTION_MVBADDY))
- for_local_enemies(i) {
+ for (i = 1; i <= game.nenhere; i++) {
w = game.ks[i];
if (game.quad[w.x][w.y] == IHK || game.quad[w.x][w.y] == IHR)
movebaddy(w, i, game.quad[w.x][w.y]);
return 1;
if (avoid) {
/* Avoid quadrants with bases if we want to avoid Enterprise */
- for_starbases(i)
+ for (i = 1; i <= game.state.rembase; i++)
if (same(game.state.baseq[i], iq))
return true;
}
game.ishere = false;
game.ientesc = false;
unschedule(FSCDBAS);
- for_local_enemies(i)
+ for (i = 1; i <= game.nenhere; i++)
if (game.quad[game.ks[i].x][game.ks[i].y] == IHS)
break;
game.quad[game.ks[i].x][game.ks[i].y] = IHDOT;
return;
}
sc = game.state.kscmdr;
- for_starbases(i) {
+ for (i = 1; i <= game.state.rembase; i++) {
basetbl[i] = i;
bdist[i] = distance(game.state.baseq[i], sc);
}
without too many Klingons, and not already under attack. */
ifindit = iwhichb = 0;
- for_starbases(i2) {
+ for (i2 = 1; i2 <= game.state.rembase; i2++) {
i = basetbl[i2]; /* bug in original had it not finding nearest*/
ibq = game.state.baseq[i];
if (same(ibq, game.quadrant) || same(ibq, game.battle) ||
game.state.galaxy[ibq.x][ibq.y].supernova ||
game.state.galaxy[ibq.x][ibq.y].klingons > MAXKLQUAD-1)
continue;
- /* if there is a commander, and no other base is appropriate,
- we will take the one with the commander */
- for_commanders (j) {
+ // if there is a commander, and no other base is appropriate,
+ // we will take the one with the commander
+ for (j = 1; j <= game.state.remcom; j++) {
if (same(ibq, game.state.kcmdr[j]) && ifindit!= 2) {
ifindit = 2;
iwhichb = i;
if (game.state.rembase == 0) {
unschedule(FSCMOVE);
}
- else for_starbases(i) {
- ibq = game.state.baseq[i];
- if (same(ibq, game.state.kscmdr) && same(game.state.kscmdr, game.battle)) {
- /* attack the base */
- if (avoid)
- return; /* no, don't attack base! */
- game.iseenit = false;
- game.isatb = 1;
- schedule(FSCDBAS, 1.0 +2.0*Rand());
- if (is_scheduled(FCDBAS))
- postpone(FSCDBAS, scheduled(FCDBAS)-game.state.date);
- if (damaged(DRADIO) && game.condition != docked)
- return; /* no warning */
- game.iseenit = true;
- pause_game(true);
- proutn(_("Lt. Uhura- \"Captain, the starbase in "));
- proutn(cramlc(quadrant, game.state.kscmdr));
- skip(1);
- prout(_(" reports that it is under attack from the Klingon Super-commander."));
- proutn(_(" It can survive until stardate %d.\""),
- (int)scheduled(FSCDBAS));
- if (!game.resting)
- return;
- prout(_("Mr. Spock- \"Captain, shall we cancel the rest period?\""));
- if (ja() == false)
+ else {
+ for (i = 1; i <= game.state.rembase; i++) {
+ ibq = game.state.baseq[i];
+ if (same(ibq, game.state.kscmdr) && same(game.state.kscmdr, game.battle)) {
+ /* attack the base */
+ if (avoid)
+ return; /* no, don't attack base! */
+ game.iseenit = false;
+ game.isatb = 1;
+ schedule(FSCDBAS, 1.0 +2.0*Rand());
+ if (is_scheduled(FCDBAS))
+ postpone(FSCDBAS, scheduled(FCDBAS)-game.state.date);
+ if (damaged(DRADIO) && game.condition != docked)
+ return; /* no warning */
+ game.iseenit = true;
+ pause_game(true);
+ proutn(_("Lt. Uhura- \"Captain, the starbase in "));
+ proutn(cramlc(quadrant, game.state.kscmdr));
+ skip(1);
+ prout(_(" reports that it is under attack from the Klingon Super-commander."));
+ proutn(_(" It can survive until stardate %d.\""),
+ (int)scheduled(FSCDBAS));
+ if (!game.resting)
+ return;
+ prout(_("Mr. Spock- \"Captain, shall we cancel the rest period?\""));
+ if (ja() == false)
+ return;
+ game.resting = false;
+ game.optime = 0.0; /* actually finished */
return;
- game.resting = false;
- game.optime = 0.0; /* actually finished */
- return;
+ }
}
}
/* Check for intelligence report */
game.ks[game.nenhere] = game.tholian;
/* check to see if all holes plugged */
- for_sectors(i) {
+ for (i = 1; i <= QUADSIZE; i++) {
if (game.quad[1][i]!=IHWEB && game.quad[1][i]!=IHT)
return;
if (game.quad[QUADSIZE][i]!=IHWEB && game.quad[QUADSIZE][i]!=IHT)
case IHR: /* Hit a regular enemy */
case IHK:
/* find the enemy */
- for_local_enemies(ll)
+ for (ll = 1; ll <= game.nenhere; ll++)
if (same(w, game.ks[ll]))
break;
kp = fabs(game.kpower[ll]);
case IHB: /* Hit a base */
skip(1);
prout(_("***STARBASE DESTROYED.."));
- for_starbases(ll) {
+ for (ll = 1; ll <= game.state.rembase; ll++) {
if (same(game.state.baseq[ll], game.quadrant)) {
game.state.baseq[ll]=game.state.baseq[game.state.rembase];
break;
game.quad[w.x][w.y]=IHDOT;
game.quad[jw.x][jw.y]=iquad;
prout(_(" displaced by blast to %s "), cramlc(sector, jw));
- for_local_enemies(ll)
+ for (ll = 1; ll <= game.nenhere; ll++)
game.kdist[ll] = game.kavgd[ll] = distance(game.sector,game.ks[ll]);
sortklings();
return;
if (game.skill <= SKILL_FAIR)
where = sector;
- for_local_enemies(loop) {
+ for (loop = 1; loop <= game.nenhere; loop++) {
if (game.kpower[loop] < 0)
continue; /* too weak to attack */
/* compute hit strength and diminish shield power */
}
}
/* After attack, reset average distance to enemies */
- for_local_enemies(loop)
+ for (loop = 1; loop <= game.nenhere; loop++)
game.kavgd[loop] = game.kdist[loop];
sortklings();
return;
switch (type) {
case IHC:
game.comhere = false;
- for_commanders (i)
+ for (i = 1; i <= game.state.remcom; i++)
if (same(game.state.kcmdr[i], game.quadrant))
break;
game.state.kcmdr[i] = game.state.kcmdr[game.state.remcom];
/* Remove enemy ship from arrays describing local conditions */
if (is_scheduled(FCDBAS) && same(game.battle, game.quadrant) && type==IHC)
unschedule(FCDBAS);
- for_local_enemies(i)
+ for (i = 1; i <= game.nenhere; i++)
if (same(game.ks[i], w))
break;
game.nenhere--;
irec=0;
do {
chew();
- if (!kz) for_local_enemies(i)
- irec+=fabs(game.kpower[i])/(PHASEFAC*pow(0.90,game.kdist[i]))*
- (1.01+0.05*Rand()) + 1.0;
+ if (!kz)
+ for (i = 1; i <= game.nenhere; i++)
+ irec += fabs(game.kpower[i])/(PHASEFAC*pow(0.90,game.kdist[i]))*
+ (1.01+0.05*Rand()) + 1.0;
kz=1;
proutn(_("%d units required. "), irec);
chew();
if (game.nenhere) {
extra = 0.0;
powrem = rpow;
- for_local_enemies(i) {
+ for (i = 1; i <= game.nenhere; i++) {
hits[i] = 0.0;
if (powrem <= 0)
continue;
break;
}
i = 0;
- for_starbases(j) {
- for_commanders(k)
+ for (j = 1; j <= game.state.rembase; j++) {
+ for (k = 1; k <= game.state.remcom; k++)
if (same(game.state.baseq[j], game.state.kcmdr[k]) &&
!same(game.state.baseq[j], game.quadrant) &&
!same(game.state.baseq[j], game.state.kscmdr)) {
if (evcode==FCDBAS) {
unschedule(FCDBAS);
/* find the lucky pair */
- for_commanders(i)
+ for (i = 1; i <= game.state.remcom; i++)
if (same(game.state.kcmdr[i], game.battle))
break;
if (i > game.state.remcom || game.state.rembase == 0 ||
}
/* Remove Starbase from galaxy */
game.state.galaxy[game.battle.x][game.battle.y].starbase = false;
- for_starbases(i)
+ for (i = 1; i <= game.state.rembase; i++)
if (same(game.state.baseq[i], game.battle))
game.state.baseq[i] = game.state.baseq[game.state.rembase];
game.state.rembase--;
break;
case IHB: /* Destroy base */
game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase = false;
- for_starbases(i)
+ for (i = 1; i <= game.state.rembase; i++)
if (same(game.state.baseq[i], game.quadrant))
break;
game.state.baseq[i] = game.state.baseq[game.state.rembase];
case IHC: /* Damage/destroy big enemies */
case IHS:
case IHR:
- for_local_enemies(ll)
+ for (ll = 1; ll <= game.nenhere; ll++)
if (same(game.ks[ll], scratch))
break;
game.kpower[ll] -= 800.0; /* If firepower is lost, die */
/* Scheduled supernova -- select star */
/* logic changed here so that we won't favor quadrants in top
left of universe */
- for_quadrants(nq.x) {
- for_quadrants(nq.y) {
+ for (nq.x = 1; nq.x <= GALSIZE; nq.x++)
+ for (nq.y = 1; nq.y <= GALSIZE; nq.y++)
stars += game.state.galaxy[nq.x][nq.y].stars;
- }
- }
if (stars == 0)
return; /* nothing to supernova exists */
num = Rand()*stars + 1;
- for_quadrants(nq.x) {
- for_quadrants(nq.y) {
+ for (nq.x = 1; nq.x <= GALSIZE; nq.x++) {
+ for (nq.y = 1; nq.y <= GALSIZE; nq.y++) {
num -= game.state.galaxy[nq.x][nq.y].stars;
if (num <= 0)
break;
coord ns;
/* we are in the quadrant! */
num = Rand()* game.state.galaxy[nq.x][nq.y].stars + 1;
- for_sectors(ns.x) {
- for_sectors(ns.y) {
+ for (ns.x = 1; ns.x <= QUADSIZE; ns.x++) {
+ for (ns.y = 1; ns.y <= QUADSIZE; ns.y++) {
if (game.quad[ns.x][ns.y]==IHSTAR) {
num--;
if (num==0)
/* Don't do it if being pushed by Nova */
if (game.nenhere != 0 && !novapush) {
newcnd();
- for_local_enemies(m) {
+ for (m = 1; m <= game.nenhere; m++) {
finald = distance(w, game.ks[m]);
game.kavgd[m] = 0.5 * (finald + game.kdist[m]);
}
/* No quadrant change -- compute new avg enemy distances */
game.quad[game.sector.x][game.sector.y] = game.ship;
if (game.nenhere) {
- for_local_enemies(m) {
+ for (m = 1; m <= game.nenhere; m++) {
finald = distance(w, game.ks[m]);
game.kavgd[m] = 0.5 * (finald+game.kdist[m]);
game.kdist[m] = finald;
sortklings();
if (!game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova)
attack(false);
- for_local_enemies(m) game.kavgd[m] = game.kdist[m];
+ for (m = 1; m <= game.nenhere; m++)
+ game.kavgd[m] = game.kdist[m];
}
newcnd();
drawmaps(0);
}
else {
ddist = FOREVER;
- for_starbases(m) {
+ for (m = 1; m <= game.state.rembase; m++) {
xdist = QUADSIZE * distance(game.state.baseq[m], game.quadrant);
if (xdist < ddist) {
ddist = xdist;
for (;;) {
/* position next to base by trial and error */
game.quad[game.sector.x][game.sector.y] = IHDOT;
- for_sectors(l) {
+ for (l = 1; l <= QUADSIZE; l++) {
game.sector.x = 3.0*Rand() - 1.0 + game.base.x;
game.sector.y = 3.0*Rand() - 1.0 + game.base.y;
if (VALID_SECTOR(game.sector.x, game.sector.y) &&
proutn(_("Spock- \"I believe the word is"));
prouts(_(" *ASTONISHING*"));
prout(_(" Mr. Sulu."));
- for_sectors(i)
- for_sectors(j)
+ for (i = 1; i <= QUADSIZE; i++)
+ for (j = 1; j <= QUADSIZE; j++)
if (game.quad[i][j] == IHDOT)
game.quad[i][j] = IHQUEST;
prout(_(" Captain, our quadrant is now infested with"));
{
int i, j;
game.lastchart = game.state.date;
- for_quadrants(i)
- for_quadrants(j)
+ for (i = 1; i <= GALSIZE; i++)
+ for (j = 1; j <= GALSIZE; j++)
if (game.state.galaxy[i][j].charted) {
game.state.chart[i][j].klingons = game.state.galaxy[i][j].klingons;
game.state.chart[i][j].starbase = game.state.galaxy[i][j].starbase;
prout(_("(Last surveillance update %d stardates ago)."),
(int)(game.state.date-game.lastchart));
prout(" 1 2 3 4 5 6 7 8");
- for_quadrants(i) {
+ for (i = 1; i <= GALSIZE; i++) {
proutn("%d |", i);
- for_quadrants(j) {
+ for (j = 1; j <= GALSIZE; j++) {
char buf[4];
if ((game.options & OPTION_SHOWME) && i == game.quadrant.x && j == game.quadrant.y)
proutn("<");
newcnd();
for (i = 1; i <= QUADSIZE; i++) {
proutn("%2d ", i);
- for_sectors(j) {
+ for (j = 1; j <= QUADSIZE; j++) {
sectscan(goodScan, i, j);
}
skip(1);
game.landed = false;
game.alive = true;
game.docfac = 0.25;
- for_quadrants(i)
- for_quadrants(j) {
- struct quadrant *quad = &game.state.galaxy[i][j];
+ for (i = 1; i <= GALSIZE; i++)
+ for (j = 1; j <= GALSIZE; j++) {
+ struct quadrant *quad = &game.state.galaxy[i][j];
quad->charted = 0;
quad->planet = NOPLANET;
quad->romulans = 0;
game.lastchart = FOREVER;
// Put stars in the galaxy
game.instar = 0;
- for_quadrants(i)
- for_quadrants(j) {
+ for (i = 1; i <= GALSIZE; i++)
+ for (j = 1; j <= GALSIZE; j++) {
int k = Rand()*9.0 + 1.0;
game.instar += k;
game.state.galaxy[i][j].stars = k;
game.ientesc = true;
}
// Clear quadrant
- for_sectors(i)
- for_sectors(j)
+ for (i = 1; i <= QUADSIZE; i++)
+ for (j = 1; j <= QUADSIZE; j++)
game.quad[i][j] = IHDOT;
q = &game.state.galaxy[game.quadrant.x][game.quadrant.y];
// cope with supernova
for (i = 1; i <= game.klhere; i++)
w = newkling(i);
// If we need a commander, promote a Klingon
- for_commanders(i)
+ for (i = 1; i <= game.state.remcom; i++)
if (same(game.state.kcmdr[i], game.quadrant))
break;
*/
#define VALID_QUADRANT(x, y) ((x)>=1 && (x)<=GALSIZE && (y)>=1 && (y)<=GALSIZE)
#define VALID_SECTOR(x, y) ((x)>=1 && (x)<=QUADSIZE && (y)>=1 && (y)<=QUADSIZE)
-#define for_quadrants(i) for (i = 1; i <= GALSIZE; i++)
-#define for_sectors(i) for (i = 1; i <= QUADSIZE; i++)
-#define for_commanders(i) for (i = 1; i <= game.state.remcom; i++)
-#define for_local_enemies(i) for (i = 1; i <= game.nenhere; i++)
-#define for_starbases(i) for (i = 1; i <= game.state.rembase; i++)
typedef struct {int x; int y;} coord;