#include "sst.h"
-static bool tryexit(int lookx, int looky, int ienm, int loccom, int irun)
+static bool tryexit(coord look, int ienm, int loccom, bool irun)
/* a bad guy attempts to bug out */
{
int n;
coord iq;
- iq.x = game.quadrant.x+(lookx+(QUADSIZE-1))/QUADSIZE - 1;
- iq.y = game.quadrant.y+(looky+(QUADSIZE-1))/QUADSIZE - 1;
+ iq.x = game.quadrant.x+(look.x+(QUADSIZE-1))/QUADSIZE - 1;
+ iq.y = game.quadrant.y+(look.y+(QUADSIZE-1))/QUADSIZE - 1;
if (!VALID_QUADRANT(iq.x,iq.y) ||
game.state.galaxy[iq.x][iq.y].supernova ||
game.state.galaxy[iq.x][iq.y].klingons > 8)
return false; /* no can do -- neg energy, supernovae, or >8 Klingons */
if (ienm == IHR) return false; /* Romulans cannot escape! */
- if (irun == 0) {
+ if (!irun) {
/* avoid intruding on another commander's territory */
if (ienm == IHC) {
for_commanders(n)
break;
}
}
- game.comhere = 0;
+ game.comhere = false;
}
return true; /* success */
}
static void movebaddy(coord com, int loccom, int ienm)
/* tactical movement for the bad guys */
{
- int motion, mdist, nsteps, mx, my, lookx, looky, ll;
- coord next;
- int irun = 0;
+ int motion, mdist, nsteps, mx, my, ll;
+ coord next, look;
int krawlx, krawly;
- bool success;
+ bool success, irun = false;
int attempts;
/* This should probably be just game.comhere + game.ishere */
int nbaddys = game.skill >= SKILL_EXPERT ?
/* If SC, check with spy to see if should hi-tail it */
if (ienm==IHS &&
(game.kpower[loccom] <= 500.0 || (game.condit==IHDOCKED && !damaged(DPHOTON)))) {
- irun = 1;
+ irun = true;
motion = -QUADSIZE;
}
else {
if (idebug)
proutn(" %d", ll+1);
/* Check if preferred position available */
- lookx = next.x + mx;
- looky = next.y + my;
+ look.x = next.x + mx;
+ look.y = next.y + my;
krawlx = mx < 0 ? 1 : -1;
krawly = my < 0 ? 1 : -1;
success = false;
attempts = 0; /* Settle mysterious hang problem */
while (attempts++ < 20 && !success) {
- if (lookx < 1 || lookx > QUADSIZE) {
- if (motion < 0 && tryexit(lookx, looky, ienm, loccom, irun))
+ if (look.x < 1 || look.x > QUADSIZE) {
+ if (motion < 0 && tryexit(look, ienm, loccom, irun))
return;
if (krawlx == mx || my == 0) break;
- lookx = next.x + krawlx;
+ look.x = next.x + krawlx;
krawlx = -krawlx;
}
- else if (looky < 1 || looky > QUADSIZE) {
- if (motion < 0 && tryexit(lookx, looky, ienm, loccom, irun))
+ else if (look.y < 1 || look.y > QUADSIZE) {
+ if (motion < 0 && tryexit(look, ienm, loccom, irun))
return;
if (krawly == my || mx == 0) break;
- looky = next.y + krawly;
+ look.y = next.y + krawly;
krawly = -krawly;
}
- else if ((game.options & OPTION_RAMMING) && game.quad[lookx][looky] != IHDOT) {
+ else if ((game.options & OPTION_RAMMING) && game.quad[look.x][look.y] != IHDOT) {
/* See if we should ram ship */
- if (game.quad[lookx][looky] == game.ship &&
+ if (game.quad[look.x][look.y] == game.ship &&
(ienm == IHC || ienm == IHS)) {
ram(true, ienm, com);
return;
}
if (krawlx != mx && my != 0) {
- lookx = next.x + krawlx;
+ look.x = next.x + krawlx;
krawlx = -krawlx;
}
else if (krawly != my && mx != 0) {
- looky = next.y + krawly;
+ look.y = next.y + krawly;
krawly = -krawly;
}
else break; /* we have failed */
else success = true;
}
if (success) {
- next.x = lookx;
- next.y = looky;
+ next = look;
if (idebug)
proutn(cramlc(neither, next));
}
/* Put commander in place within same quadrant */
game.quad[com.x][com.y] = IHDOT;
game.quad[next.x][next.y] = ienm;
- if (next.x != com.x || next.y != com.y) {
+ if (!same(next, com)) {
/* it moved */
- game.ks[loccom].x = next.x;
- game.ks[loccom].y = next.y;
+ game.ks[loccom] = next;
game.kdist[loccom] = game.kavgd[loccom] = distance(game.sector, next);
if (!damaged(DSRSENS) || game.condit == IHDOCKED) {
proutn("***");
if (same(ibq, game.state.kscmdr) && same(game.state.kscmdr, game.battle)) {
/* attack the base */
if (flag) return; /* no, don't attack base! */
- game.iseenit = 0;
+ 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.condit != IHDOCKED)
return; /* no warning */
- game.iseenit = 1;
+ game.iseenit = true;
if (*ipage == 0) pause_game(1);
*ipage=1;
proutn(_("Lt. Uhura- \"Captain, the starbase in "));
crmena(true, IHT, sector, game.tholian);
prout(_(" completes web."));
game.ithere = false;
- game.tholian.x = game.tholian.y = 0;
game.nenhere--;
return;
}
if (h1 >= 600) {
game.quad[w.x][w.y] = IHDOT;
game.ithere = false;
- game.tholian.x = game.tholian.y = 0;
deadkl(w, iquad, w);
return;
}
prout(_(" disappears."));
game.quad[w.x][w.y] = IHWEB;
game.ithere = false;
- game.tholian.x = game.tholian.y = 0;
game.nenhere--;
dropin(IHBLANK);
return;
if (game.ithere) movetho();
if (game.neutz) { /* The one chance not to be attacked */
- game.neutz = 0;
+ game.neutz = false;
return;
}
if ((((game.comhere || game.ishere) && !game.justin) || game.skill == SKILL_EMERITUS) && torps_ok) movcom();
game.klhere--;
switch (type) {
case IHC:
- game.comhere = 0;
+ game.comhere = false;
for_commanders (i)
if (game.state.kcmdr[i].x==game.quadrant.x && game.state.kcmdr[i].y==game.quadrant.y) break;
game.state.kcmdr[i] = game.state.kcmdr[game.state.remcom];
prout(_("Lt. Uhura- \"Captain, the sub-space radio is working and"));
prout(_(" surveillance reports are coming in."));
skip(1);
- if (game.iseenit==0) {
+ if (!game.iseenit) {
attakreport(false);
- game.iseenit = 1;
+ game.iseenit = true;
}
rechart();
prout(_(" The star chart is now up to date.\""));
if (game.isatb) /* extra time if SC already attacking */
postpone(FCDBAS, scheduled(FSCDBAS)-game.state.date);
game.future[FBATTAK].date = game.future[FCDBAS].date + expran(0.3*game.intime);
- game.iseenit = 0;
+ game.iseenit = false;
if (!damaged(DRADIO) && game.condit != IHDOCKED)
break; /* No warning :-( */
- game.iseenit = 1;
+ game.iseenit = true;
if (!ipage) pause_game(1);
ipage = true;
skip(1);
proutn(_("Do you want your Commodore Emeritus Citation printed? "));
chew();
if (ja() == true) {
- igotit = 1;
+ igotit = true;
}
}
}
prout(_("LIVE LONG AND PROSPER."));
}
score();
- if (igotit != 0) plaque();
+ if (igotit) plaque();
return;
case FDEPLETE: // Federation Resources Depleted
prout(_("Your time has run out and the Federation has been"));
game.lsupres = game.inlsr;
game.state.crew = FULLCREW;
if (!damaged(DRADIO) &&
- (is_scheduled(FCDBAS) || game.isatb == 1) && game.iseenit == 0) {
+ (is_scheduled(FCDBAS) || game.isatb == 1) && !game.iseenit) {
/* get attack report from base */
prout(_("Lt. Uhura- \"Captain, an important message from the starbase:\""));
attakreport(false);
- game.iseenit = 1;
+ game.iseenit = true;
}
}
void timwrp()
/* let's do the time warp again */
{
- int l, gotit;
+ int l;
+ bool gotit;
prout(_("***TIME WARP ENTERED."));
if (game.state.snap && Rand() < 0.5) {
/* Go back in time */
/* Make sure Galileo is consistant -- Snapshot may have been taken
when on planet, which would give us two Galileos! */
- gotit = 0;
+ gotit = false;
for (l = 0; l < game.inplan; l++) {
if (game.state.plnets[l].known == shuttle_down) {
- gotit = 1;
+ gotit = true;
if (game.iscraft==1 && game.ship==IHE) {
prout(_("Checkov- \"Security reports the Galileo has disappeared, Sir!"));
game.iscraft = 0;
}
/* Likewise, if in the original time the Galileo was abandoned, but
was on ship earlier, it would have vanished -- lets restore it */
- if (game.iscraft==0 && gotit==0 && game.damage[DSHUTTL] >= 0.0) {
+ if (game.iscraft==0 && !gotit && game.damage[DSHUTTL] >= 0.0) {
prout(_("Checkov- \"Security reports the Galileo has reappeared in the dock!\""));
game.iscraft = 1;
}
/* Don't report this if not seen and
either the radio is dead or not at base! */
attakreport(false);
- game.iseenit = 1;
+ game.iseenit = true;
}
if (game.casual) prout(_("%d casualt%s suffered so far."),
game.casual, game.casual==1? "y" : "ies");
game.justin = true;
game.base.x = game.base.y = 0;
game.klhere = 0;
- game.comhere = 0;
+ game.comhere = false;
game.plnet.x = game.plnet.y = 0;
game.ishere = false;
game.irhere = 0;
game.ithere = false;
iqhere = false;
iqengry = false;
- game.iseenit = 0;
+ game.iseenit = false;
if (game.iscate) {
// Attempt to escape Super-commander, so tbeam back!
game.iscate = 0;
if (i <= game.state.remcom) {
game.quad[w.x][w.y] = IHC;
game.kpower[game.klhere] = 950.0+400.0*Rand()+50.0*game.skill;
- game.comhere = 1;
+ game.comhere = true;
}
// If we need a super-commander, promote a Klingon
// Check for RNZ
if (game.irhere > 0 && game.klhere == 0 && (q->planet == NOPLANET || game.state.plnets[q->planet].inhabited == UNINHABITED)) {
- game.neutz = 1;
+ game.neutz = true;
if (!damaged(DRADIO)) {
skip(1);
prout("LT. Uhura- \"Captain, an urgent message.");
game.quad[game.tholian.x][game.tholian.y] = IHT;
game.ithere = true;
game.nenhere++;
- game.ks[game.nenhere].x = game.tholian.x;
- game.ks[game.nenhere].y = game.tholian.y;
+ game.ks[game.nenhere] = game.tholian;
game.kdist[game.nenhere] = game.kavgd[game.nenhere] =
distance(game.sector, game.tholian);
game.kpower[game.nenhere] = Rand()*400.0 +100.0 +25.0*game.skill;
drawmaps(1);
for(;;) { /* get a command */
hitme = false;
- game.justin = 0;
+ game.justin = false;
game.optime = 0.0;
i = -1;
chew();
alive, // we are alive (not killed)
justin, // just entered quadrant
shldup, // shields are up
+ comhere, // commander here
ishere, // super-commander in quadrant
ientesc, // attempted escape from supercommander
ithere, // Tholian is here
inorbit, // orbiting a planet
imine, // mining
icrystl, // dilithium crystals aboard
+ iseenit, // seen base attack report
thawed; // thawed game
int inkling, // initial number of klingons
inbase, // initial number of bases
length, // length of game
skill, // skill level
klhere, // klingons here
- comhere, // commanders here
casual, // causalties
nhelp, // calls for help
nkinks, // count of energy-barrier crossings
iscate, // super commander is here
iattak, // attack recursion elimination (was cracks[4])
tourn, // tournament number
- iseenit, // seen base attack report
proben, // number of moves for probe
nprobes; // number of probes available
double inresor, // initial resources