game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons--;
game.state.galaxy[iq.x][iq.y].klingons++;
if (ienm==IHS) {
- game.ishere=0;
- game.iscate=0;
- game.ientesc=0;
- game.isatb=0;
+ game.ishere = false;
+ game.iscate = 0;
+ game.ientesc = false;
+ game.isatb = 0;
schedule(FSCMOVE, 0.2777);
unschedule(FSCDBAS);
- game.state.kscmdr.x=iq.x;
- game.state.kscmdr.y=iq.y;
+ game.state.kscmdr=iq;
}
else {
for_commanders(n) {
/* SC has scooted, Remove him from current quadrant */
game.iscate=0;
game.isatb=0;
- game.ishere=0;
- game.ientesc=0;
+ game.ishere = false;
+ game.ientesc = false;
unschedule(FSCDBAS);
for_local_enemies(i)
if (game.quad[game.ks[i].x][game.ks[i].y] == IHS) break;
int idx, idy, im, i;
coord dummy;
/* Move the Tholian */
- if (game.ithere==0 || game.justin == 1) return;
+ if (!game.ithere || game.justin) return;
if (game.tholian.x == 1 && game.tholian.y == 1) {
idx = 1; idy = QUADSIZE;
}
else {
/* something is wrong! */
- game.ithere = 0;
+ game.ithere = false;
return;
}
dropin(IHBLANK, &dummy);
crmena(true, IHT, sector, game.tholian);
prout(_(" completes web."));
- game.ithere = game.tholian.x = game.tholian.y = 0;
+ game.ithere = false;
+ game.tholian.x = game.tholian.y = 0;
game.nenhere--;
return;
}
void torpedo(double course, double r, int inx, int iny, double *hit, int i, int n)
/* let a photon torpedo fly */
{
- int l, iquad=0, jx=0, jy=0, shoved=0, ll;
-
+ int l, iquad=0, jx=0, jy=0, ll;
+ bool shoved = false;
double ac=course + 0.25*r;
double angle = (15.0-ac)*0.5235988;
double bullseye = (15.0 - course)*0.5235988;
double deltax=-sin(angle), deltay=cos(angle), x=inx, y=iny, bigger;
double ang, temp, xx, yy, kp, h1;
+ struct quadrant *q = &game.state.galaxy[game.quadrant.x][game.quadrant.y];
coord w;
w.x = w.y = 0;
game.sector.x = jx;
game.sector.y = jy;
crmshp();
- shoved = 1;
+ shoved = true;
break;
case IHC: /* Hit a commander */
proutn(_(" damaged--"));
game.ks[ll].x = jx;
game.ks[ll].y = jy;
- shoved = 1;
+ shoved = true;
break;
case IHB: /* Hit a base */
skip(1);
prout(_("***STARBASE DESTROYED.."));
for_starbases(ll) {
- if (game.state.baseq[ll].x==game.quadrant.x && game.state.baseq[ll].y==game.quadrant.y) {
- game.state.baseq[ll].x=game.state.baseq[game.state.rembase].x;
- game.state.baseq[ll].y=game.state.baseq[game.state.rembase].y;
+ 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.state.rembase--;
game.base.x=game.base.y=0;
- game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase--;
+ q->starbase--;
game.state.chart[game.quadrant.x][game.quadrant.y].starbase--;
game.state.basekl++;
newcnd();
crmena(true, iquad, sector, w);
prout(_(" destroyed."));
game.state.nplankl++;
- game.state.galaxy[game.quadrant.x][game.quadrant.y].planet = NOPLANET;
+ q->planet = NOPLANET;
DESTROY(&game.state.plnets[game.iplnet]);
game.iplnet = 0;
game.plnet.x = game.plnet.y = 0;
crmena(true, iquad, sector, w);
prout(_(" destroyed."));
game.state.nworldkl++;
- game.state.galaxy[game.quadrant.x][game.quadrant.y].planet = NOPLANET;
+ q->planet = NOPLANET;
DESTROY(&game.state.plnets[game.iplnet]);
game.iplnet = 0;
game.plnet.x = game.plnet.y = 0;
* you can shove the Thingy and piss it off.
* It then becomes an enemy and may fire at you.
*/
- iqengry=1;
- shoved=1;
+ iqengry = true;
+ shoved = true;
}
return;
case IHBLANK: /* Black hole */
h1 = fabs(h1);
if (h1 >= 600) {
game.quad[w.x][w.y] = IHDOT;
- game.ithere = 0;
+ game.ithere = false;
game.tholian.x = game.tholian.y = 0;
deadkl(w, iquad, w.x, w.y);
return;
}
prout(_(" disappears."));
game.quad[w.x][w.y] = IHWEB;
- game.ithere = game.tholian.x = game.tholian.y = 0;
+ game.ithere = false;
+ game.tholian.x = game.tholian.y = 0;
game.nenhere--;
{
coord dummy;
return;
}
if ((((game.comhere || game.ishere) && !game.justin) || game.skill == SKILL_EMERITUS) && torps_ok) movcom();
- if (game.nenhere==0 || (game.nenhere==1 && iqhere && iqengry==0)) return;
+ if (game.nenhere==0 || (game.nenhere==1 && iqhere && !iqengry)) return;
pfac = 1.0/game.inshld;
if (game.shldchg == 1) chgfac = 0.25+0.5*Rand();
skip(1);
/* Increase chance of photon torpedos if docked or enemy energy low */
if (game.condit == IHDOCKED) r *= 0.25;
if (game.kpower[loop] < 500) r *= 0.25;
- jay.x = game.ks[loop].x;
- jay.y = game.ks[loop].y;
+ jay = game.ks[loop];
iquad = game.quad[jay.x][jay.y];
if (iquad==IHT || (iquad==IHQUEST && !iqengry)) continue;
itflag = (iquad == IHK && r > 0.0005) || !torps_ok ||
}
else if (type == IHT) {
/* Killed a Tholian */
- game.ithere = 0;
+ game.ithere = false;
}
else if (type == IHQUEST) {
/* Killed a Thingy */
- iqhere=iqengry=thing.x=thing.y=0;
+ iqhere = iqengry = false;
+ thing.x =thing.y = 0;
}
else {
/* Some type of a Klingon */
break;
case IHS:
game.state.nscrem--;
- game.ishere = game.state.kscmdr.x = game.state.kscmdr.y = game.isatb = game.iscate = 0;
+ game.ishere = false;
+ game.state.kscmdr.x = game.state.kscmdr.y = game.isatb = game.iscate = 0;
unschedule(FSCMOVE);
unschedule(FSCDBAS);
break;
{
double targ[4][3], course[4];
double r, dummy;
- int key, n, i, osuabor;
+ int key, n, i;
+ bool osuabor;
game.ididit = false;
}
game.ididit = true;
/* Loop for moving <n> torpedoes */
- osuabor = 0;
+ osuabor = false;
for (i = 1; i <= n && !osuabor; i++) {
if (game.condit != IHDOCKED) game.torps--;
r = (Rand()+Rand())*0.5 -0.5;
skip(1);
if (i < n)
prout(_(" Remainder of burst aborted."));
- osuabor=1;
+ osuabor = true;
if (Rand() <= 0.2) {
prout(_("***Photon tubes damaged by misfire."));
game.damage[DPHOTON] = game.damfac*(1.0+2.0*Rand());
}
}
-static int checkshctrl(double rpow)
+static bool checkshctrl(double rpow)
/* check shield control */
{
double hit;
skip(1);
if (Rand() < .998) {
prout(_("Shields lowered."));
- return 0;
+ return false;
}
/* Something bad has happened */
prouts(_("***RED ALERT! RED ALERT!"));
skip(1);
stars();
finish(FPHASER);
- return 1;
+ return true;
}
prouts(_("Sulu- \"Captain! Shield malfunction! Phaser fire contained!\""));
skip(2);
prout(_("Phaser energy dispersed by shields."));
prout(_("Enemy unaffected."));
overheat(rpow);
- return 1;
+ return true;
}
{
double hits[21], rpow=0, extra, powrem, over, temp;
int kz = 0, k=1, i, irec=0; /* Cheating inhibitor */
- int ifast=0, no=0, ipoop=1, msgflag = 1;
+ bool ifast = false, no = false, ipoop = true, msgflag = true;
enum {NOTSET, MANUAL, FORCEMAN, AUTOMATIC} automode = NOTSET;
int key=0;
skip(1);
/* SR sensors and Computer */
- if (damaged(DSRSENS) || damaged(DCOMPTR)) ipoop = 0;
+ if (damaged(DSRSENS) || damaged(DCOMPTR)) ipoop = false;
if (game.condit == IHDOCKED) {
prout(_("Phasers can't be fired through base shields."));
chew();
return;
}
prout(_("Weapons Officer Sulu- \"High-speed shield control enabled, sir.\""));
- ifast = 1;
+ ifast = true;
}
/* Original code so convoluted, I re-did it all */
}
}
else if (isit("no")) {
- no = 1;
+ no = true;
}
else {
huh();
switch (automode) {
case AUTOMATIC:
if (key == IHALPHA && isit("no")) {
- no = 1;
+ no = true;
key = scan();
}
if (key != IHREAL && game.nenhere != 0) {
return;
}
if ((key=scan()) == IHALPHA && isit("no")) {
- no = 1;
+ no = true;
}
if (ifast) {
game.energy -= 200; /* Go and do it! */
hittem(hits);
game.ididit = true;
}
- if (extra > 0 && game.alldone == 0) {
+ if (extra > 0 && !game.alldone) {
if (game.ithere) {
proutn(_("*** Tholian web absorbs "));
if (game.nenhere>0) proutn(_("excess "));
proutn(_("Energy available= %.2f"),
game.energy-.006-(ifast?200:0));
skip(1);
- msgflag = 0;
+ msgflag = false;
rpow = 0.0;
}
if (damaged(DSRSENS) && !(abs(game.sector.x-aim.x) < 2 && abs(game.sector.y-aim.y) < 2) &&
}
if (key == IHEOL) {
if (k==1) { /* Let me say I'm baffled by this */
- msgflag = 1;
+ msgflag = true;
}
continue;
}
return;
}
if (key == IHALPHA && isit("no")) {
- no = 1;
+ no = true;
}
game.energy -= rpow;
chew();
else
proutn(_("Very small hit on "));
ienm = game.quad[w.x][w.y];
- if (ienm==IHQUEST) iqengry=1;
+ if (ienm==IHQUEST) iqengry = true;
crmena(false,ienm,sector,w);
skip(1);
if (kpow == 0) {
void events(void)
/* run through the event queue looking for things to do */
{
- int istract=0, evcode, i=0, j, k, l;
+ int evcode, i=0, j, k, l;
double fintim = game.state.date + game.optime, datemin, xtime, repair, yank=0;
- bool radio_was_broken, ictbeam = false, ipage = false;
+ bool radio_was_broken, ictbeam = false, ipage = false, istract = false;
struct quadrant *pdest, *q;
coord w, hold;
event *ev, *ev2;
break;
case FSPY: /* Check with spy to see if S.C. should tractor beam */
if (game.state.nscrem == 0 ||
- ictbeam+istract > 0 ||
+ ictbeam || istract ||
game.condit==IHDOCKED || game.isatb==1 || game.iscate==1) return;
if (game.ientesc ||
(game.energy < 2000 && game.torps < 4 && game.shield < 1250) ||
(game.energy < 2500 || damaged(DPHASER)) &&
(game.torps < 5 || damaged(DPHOTON)))) {
/* Tractor-beam her! */
- istract=1;
+ istract = true;
yank = square(game.state.kscmdr.x-game.quadrant.x) + square(game.state.kscmdr.y-game.quadrant.y);
/********* fall through to FTBEAM code ***********/
}
/* If Kirk & Co. screwing around on planet, handle */
atover(true); /* atover(true) is Grab */
if (game.alldone) return;
- if (game.icraft == 1) { /* Caught in Galileo? */
+ if (game.icraft) { /* Caught in Galileo? */
finish(FSTRACTOR);
return;
}
break;
case FSCMOVE: /* Supercommander moves */
schedule(FSCMOVE, 0.2777);
- if (game.ientesc+istract==0 &&
- game.isatb != 1 &&
- (game.iscate != 1 || !game.justin)) scom(&ipage);
+ if (!game.ientesc && !istract && game.isatb != 1 &&
+ (game.iscate != 1 || !game.justin))
+ scom(&ipage);
break;
case FDSPROB: /* Move deep space probe */
schedule(FDSPROB, 0.01);
skip(1);
prout(_("The short hop begins . . ."));
game.state.plnets[game.iplnet].known=known;
- game.icraft = 1;
+ game.icraft = true;
skip(1);
game.landed = -1;
if (consumeTime()) return;
game.iscraft = 1;
- game.icraft = 0;
+ game.icraft = false;
if (game.imine) {
game.icrystl = 1;
game.cryprob = 0.05;
skip(1);
prouts(_("The hangar doors open; the trip begins."));
skip(1);
- game.icraft = 1;
+ game.icraft = true;
game.iscraft = 0;
if (consumeTime()) return;
game.state.plnets[game.iplnet].known = shuttle_down;
game.landed = 1;
- game.icraft = 0;
+ game.icraft = false;
prout(_("Trip complete"));
return;
}
break;
case 10:
if (game.options & OPTION_WORLDS) {
- int here = game.state.galaxy[game.quadrant.x][game.quadrant.y].planet;
- if (here != NOPLANET && game.state.plnets[here].inhabited != UNINHABITED)
- proutn(_("Major system %s"), systemname(here));
+ int plnet = game.state.galaxy[game.quadrant.x][game.quadrant.y].planet;
+ if (plnet != NOPLANET && game.state.plnets[plnet].inhabited != UNINHABITED)
+ proutn(_("Major system %s"), systemname(plnet));
else
proutn(_("Sector is uninhabited"));
}
game.battle.x = game.battle.y = 0;
game.state.date = game.indate = 100.0*(int)(31.0*Rand()+20.0);
game.nkinks = game.nhelp = game.casual = game.abandoned = 0;
- game.resting = game.imine = false;
- game.isatb = game.iscate = game.icrystl = game.icraft = game.state.nplankl = 0;
+ game.resting = game.imine = game.icraft = false;
+ game.isatb = game.iscate = game.icrystl = game.state.nplankl = 0;
game.state.starkl = game.state.basekl = 0;
game.iscraft = 1;
game.landed = -1;
{
int i, j;
coord w;
- struct quadrant *here;
+ struct quadrant *q;
game.iattak = 1;
game.justin = true;
game.klhere = 0;
game.comhere = 0;
game.plnet.x = game.plnet.y = 0;
- game.ishere = 0;
+ game.ishere = false;
game.irhere = 0;
game.iplnet = 0;
game.nenhere = 0;
game.neutz = false;
game.inorbit = false;
game.landed = -1;
- game.ientesc = 0;
- game.ithere = 0;
- iqhere=0;
- iqengry=0;
+ game.ientesc = false;
+ game.ithere = false;
+ iqhere = false;
+ iqengry = false;
game.iseenit = 0;
if (game.iscate) {
// Attempt to escape Super-commander, so tbeam back!
game.iscate = 0;
- game.ientesc = 1;
+ game.ientesc = true;
}
// Clear quadrant
for_sectors(i)
for_sectors(j)
game.quad[i][j] = IHDOT;
- here = &game.state.galaxy[game.quadrant.x][game.quadrant.y];
+ q = &game.state.galaxy[game.quadrant.x][game.quadrant.y];
// cope with supernova
- if (here->supernova)
+ if (q->supernova)
return;
- game.klhere = here->klingons;
- game.irhere = here->romulans;
+ game.klhere = q->klingons;
+ game.irhere = q->romulans;
game.nenhere = game.klhere + game.irhere;
// Position Starship
game.quad[game.sector.x][game.sector.y] = game.ship;
- if (here->klingons) {
+ if (q->klingons) {
// Position ordinary Klingons
for (i = 1; i <= game.klhere; i++)
newkling(i, &w);
game.quad[game.ks[1].x][game.ks[1].y] = IHS;
game.kpower[1] = 1175.0 + 400.0*Rand() + 125.0*game.skill;
game.iscate = game.state.remkl>1;
- game.ishere = 1;
+ game.ishere = true;
}
}
// Put in Romulans if needed
game.kpower[i] = Rand()*400.0 + 450.0 + 50.0*game.skill;
}
// If quadrant needs a starbase, put it in
- if (here->starbase)
+ if (q->starbase)
dropin(IHB, &game.base);
// If quadrant needs a planet, put it in
- if (here->planet != NOPLANET) {
- game.iplnet = here->planet;
- if (game.state.plnets[here->planet].inhabited == UNINHABITED)
+ if (q->planet != NOPLANET) {
+ game.iplnet = q->planet;
+ if (game.state.plnets[q->planet].inhabited == UNINHABITED)
dropin(IHP, &game.plnet);
else
dropin(IHW, &game.plnet);
// Check for game.condition
newcnd();
// And finally the stars
- for (i = 1; i <= here->stars; i++)
+ for (i = 1; i <= q->stars; i++)
dropin(IHSTAR, &w);
// Check for RNZ
- if (game.irhere > 0 && game.klhere == 0 && (here->planet == NOPLANET || game.state.plnets[here->planet].inhabited == UNINHABITED)) {
+ if (game.irhere > 0 && game.klhere == 0 && (q->planet == NOPLANET || game.state.plnets[q->planet].inhabited == UNINHABITED)) {
game.neutz = 1;
if (!damaged(DRADIO)) {
skip(1);
game.tholian.y = Rand() > 0.5 ? QUADSIZE : 1;
} while (game.quad[game.tholian.x][game.tholian.y] != IHDOT);
game.quad[game.tholian.x][game.tholian.y] = IHT;
- game.ithere = 1;
+ game.ithere = true;
game.nenhere++;
game.ks[game.nenhere].x = game.tholian.x;
game.ks[game.nenhere].y = game.tholian.y;
struct game game;
coord thing;
-int iqhere, iqengry;
+bool iqhere, iqengry;
int iscore, iskill; // Common PLAQ
double aaitem;
double perdate;
alive, // we are alive (not killed)
justin, // just entered quadrant
shldup, // shields are up
+ ishere, // super-commander in quadrant
+ ientesc, // attempted escape from supercommander
+ ithere, // Tholian is here
resting, // rest time
+ icraft, // Kirk in Galileo
alldone, // game is now finished
neutz, // Romulan Neutral Zone
isarmed, // probe is armed
iplnet, // planet # in quadrant
inplan, // initial planets
nenhere, // number of enemies in quadrant
- ishere, // super-commander in quandrant
irhere, // Romulans in quadrant
- icraft, // Kirk in Galileo
- ientesc, // attempted escape from supercommander
iscraft, // =1 if craft on ship, -1 if removed from game
isatb, // =1 if super commander is attacking base
iscate, // super commander is here
iattak, // attack recursion elimination (was cracks[4])
icrystl, // dilithium crystals aboard
tourn, // tournament number
- ithere, // Tholian is here
iseenit, // seen base attack report
proben, // number of moves for probe
nprobes; // number of probes available
/* the Space Thingy's global state should *not* be saved! */
extern coord thing;
-extern int iqhere, iqengry;
+extern bool iqhere, iqengry;
typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,