game.state.galaxy[iq.x][iq.y].klingons++;
if (ienm==IHS) {
game.ishere = false;
- game.iscate = 0;
+ game.iscate = false;
game.ientesc = false;
game.isatb = 0;
schedule(FSCMOVE, 0.2777);
game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].klingons++;
if (game.ishere) {
/* SC has scooted, Remove him from current quadrant */
- game.iscate=0;
+ game.iscate=false;
game.isatb=0;
game.ishere = false;
game.ientesc = false;
DESTROY(&game.state.plnets[i]);
game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].planet = NOPLANET;
if (!damaged(DRADIO) || game.condition == docked) {
- if (*ipage==0) pause_game(true);
- *ipage = 1;
+ if (!*ipage) pause_game(true);
+ *ipage = true;
prout(_("Lt. Uhura- \"Captain, Starfleet Intelligence reports"));
proutn(_(" a planet in "));
proutn(cramlc(quadrant, game.state.kscmdr));
/* Decide on being active or passive */
flag = ((NKILLC+NKILLK)/(game.state.date+0.01-game.indate) < 0.1*game.skill*(game.skill+1.0) ||
(game.state.date-game.indate) < 3.0);
- if (game.iscate==0 && flag) {
+ if (!game.iscate && flag) {
/* compute move away from Enterprise */
ideltax = game.state.kscmdr.x-game.quadrant.x;
ideltay = game.state.kscmdr.y-game.quadrant.y;
}
if (game.state.rembase > 1) {
/* sort into nearest first order */
- int iswitch;
+ bool iswitch;
do {
- iswitch = 0;
+ iswitch = false;
for (i=1; i < game.state.rembase-1; i++) {
if (bdist[i] > bdist[i+1]) {
int ti = basetbl[i];
bdist[i+1] = t;
basetbl[i] = basetbl[i+1];
basetbl[i+1] =ti;
- iswitch = 1;
+ iswitch = true;
}
}
} while (iswitch);
/* if there is a commander, an no other base is appropriate,
we will take the one with the commander */
for_commanders (j) {
- if (ibq.x==game.state.kcmdr[j].x && ibq.y==game.state.kcmdr[j].y && ifindit!= 2) {
+ if (same(ibq, game.state.kcmdr[j]) && ifindit!= 2) {
ifindit = 2;
iwhichb = i;
break;
if (damaged(DRADIO) && game.condition != docked)
return; /* no warning */
game.iseenit = true;
- if (*ipage == 0) pause_game(true);
- *ipage=1;
+ if (!*ipage) pause_game(true);
+ *ipage = true;
proutn(_("Lt. Uhura- \"Captain, the starbase in "));
proutn(cramlc(quadrant, game.state.kscmdr));
skip(1);
(damaged(DRADIO) && game.condition != docked) ||
!game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].charted))
return;
- if (*ipage==0) pause_game(true);
- *ipage = 1;
+ if (!*ipage) pause_game(true);
+ *ipage = true;
prout(_("Lt. Uhura- \"Captain, Starfleet Intelligence reports"));
proutn(_(" the Super-commander is in "));
proutn(cramlc(quadrant, game.state.kscmdr));
return;
}
game.shldup = true;
- game.shldchg = 1;
+ game.shldchg = true;
if (game.condition != docked) game.energy -= 50.0;
prout(_("Shields raised."));
if (game.energy <= 0) {
return;
}
game.shldup=false;
- game.shldchg=1;
+ game.shldchg=true;
prout(_("Shields lowered."));
game.ididit = true;
return;
*hit = fabs(*hit);
newcnd(); /* we're blown out of dock */
/* We may be displaced. */
- if (game.landed==1 || game.condition==docked) return; /* Cheat if on a planet */
+ if (game.landed || game.condition==docked)
+ return; /* Cheat if on a planet */
ang = angle + 2.5*(Rand()-0.5);
temp = fabs(sin(ang));
if (fabs(cos(ang)) > temp) temp = fabs(cos(ang));
game.iplnet = 0;
game.plnet.x = game.plnet.y = 0;
game.quad[w.x][w.y] = IHDOT;
- if (game.landed==1) {
+ if (game.landed) {
/* captain perishes on planet */
finish(FDPLANET);
}
game.iplnet = 0;
game.plnet.x = game.plnet.y = 0;
game.quad[w.x][w.y] = IHDOT;
- if (game.landed==1) {
+ if (game.landed) {
/* captain perishes on planet */
finish(FDPLANET);
}
j = randdevice();
/* Cheat to prevent shuttle damage unless on ship */
} while
- (game.damage[j]<0.0 || (j==DSHUTTL && game.iscraft!=1));
+ (game.damage[j]<0.0 || (j==DSHUTTL && game.iscraft != onship));
cdam[loop1] = j;
extradm = (hit*game.damfac)/(ncrit*(75.0+25.0*Rand()));
game.damage[j] += extradm;
if ((((game.comhere || game.ishere) && !game.justin) || game.skill == SKILL_EMERITUS) && torps_ok) movcom();
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();
+ if (game.shldchg) chgfac = 0.25+0.5*Rand();
skip(1);
if (game.skill <= SKILL_FAIR) where = sector;
for_local_enemies(loop) {
return; /* Supernova or finished */
if (hit == 0) continue;
}
- if (game.shldup || game.shldchg != 0 || game.condition==docked) {
+ if (game.shldup || game.shldchg || game.condition==docked) {
/* shields will take hits */
double absorb, hitsh, propor = pfac*game.shield*(game.condition==docked ? 2.1 : 1.0);
if(propor < 0.1) propor = 0.1;
case IHS:
game.state.nscrem--;
game.ishere = false;
- game.state.kscmdr.x = game.state.kscmdr.y = game.isatb = game.iscate = 0;
+ game.state.kscmdr.x = game.state.kscmdr.y = game.isatb = 0;
+ game.iscate = false;
unschedule(FSCMOVE);
unschedule(FSCDBAS);
break;
key = scan();
}
if (key == IHALPHA && isit("no")) {
- no = 1;
+ no = true;
key = scan();
continue;
}
case FSPY: /* Check with spy to see if S.C. should tractor beam */
if (game.state.nscrem == 0 ||
ictbeam || istract ||
- game.condition==docked || game.isatb==1 || game.iscate==1) return;
+ game.condition==docked || game.isatb==1 || game.iscate) return;
if (game.ientesc ||
(game.energy < 2000 && game.torps < 4 && game.shield < 1250) ||
(damaged(DPHASER) && (damaged(DPHOTON) || game.torps < 4)) ||
if (!ipage) pause_game(true);
ipage=true;
game.optime = (10.0/(7.5*7.5))*yank; /* 7.5 is yank rate (warp 7.5) */
- ictbeam = 1;
+ ictbeam = true;
skip(1);
proutn("***");
crmshp();
return;
}
/* Check to see if shuttle is aboard */
- if (game.iscraft==0) {
+ if (game.iscraft == offship) {
skip(1);
if (Rand() > 0.5) {
prout(_("Galileo, left on the planet surface, is captured"));
prout(_("by aliens and made into a flying McDonald's."));
game.damage[DSHUTTL] = -10;
- game.iscraft = -1;
+ game.iscraft = removed;
}
else {
prout(_("Galileo, left on the planet surface, is well hidden."));
if (!game.shldup) {
if (!damaged(DSHIELD) && game.shield > 0) {
doshield(true); /* raise shields */
- game.shldchg=0;
+ game.shldchg=false;
}
else prout(_("(Shields not currently useable.)"));
}
break;
case FSNAP: /* Snapshot of the universe (for time warp) */
game.snapsht = game.state;
- game.state.snap = 1;
+ game.state.snap = true;
schedule(FSNAP, expran(0.5 * game.intime));
break;
case FBATTAK: /* Commander attacks starbase */
case FSCMOVE: /* Supercommander moves */
schedule(FSCMOVE, 0.2777);
if (!game.ientesc && !istract && game.isatb != 1 &&
- (game.iscate != 1 || !game.justin))
+ (!game.iscate || !game.justin))
scom(&ipage);
break;
case FDSPROB: /* Move deep space probe */
game.state.galaxy[game.probec.x][game.probec.y].supernova) {
// Left galaxy or ran into supernova
if (!damaged(DRADIO) || game.condition == docked) {
- if (ipage==0) pause_game(true);
- ipage = 1;
+ if (!ipage) pause_game(true);
+ ipage = true;
skip(1);
proutn(_("Lt. Uhura- \"The deep space probe "));
if (!VALID_QUADRANT(j, i))
break;
}
if (!damaged(DRADIO) || game.condition == docked) {
- if (ipage==0) pause_game(true);
- ipage = 1;
+ if (!ipage) pause_game(true);
+ ipage = true;
skip(1);
proutn(_("Lt. Uhura- \"The deep space probe is now in "));
proutn(cramlc(quadrant, game.probec));
prout(_(" destroyed."));
DESTROY(&game.state.plnets[game.iplnet]);
game.iplnet = game.plnet.x = game.plnet.y = 0;
- if (game.landed == 1) {
+ if (game.landed) {
finish(FPNOVA);
return;
}
game.state.galaxy[nq.x][nq.y].klingons = 0;
if (same(nq, game.state.kscmdr)) {
/* did in the Supercommander! */
- game.state.nscrem = game.state.kscmdr.x = game.state.kscmdr.y = game.isatb = game.iscate = 0;
+ game.state.nscrem = game.state.kscmdr.x = game.state.kscmdr.y = game.isatb = 0;
+ game.iscate = false;
unschedule(FSCMOVE);
unschedule(FSCDBAS);
}
skip(1);
prout(_("In fact, you have done so well that Starfleet Command"));
switch (game.skill) {
+ case SKILL_NONE:
+ break; /* quiet gcc warning */
case SKILL_NOVICE:
prout(_("promotes you one step in rank from \"Novice\" to \"Fair\"."));
break;
else {
prout(_("found guilty and"));
prout(_("sentenced to death by slow torture."));
- game.alive = 0;
+ game.alive = false;
}
score();
return;
}
if (game.ship==IHF) game.ship= 0;
else if (game.ship == IHE) game.ship = IHF;
- game.alive = 0;
+ game.alive = false;
if (KLINGREM != 0) {
double goodies = game.state.remres/game.inresor;
double baddies = (game.state.remkl + 2.0*game.state.remcom)/(game.inkling+2.0*game.incom);
prout(_("martyr and a hero. Someday maybe they'll erect a"));
prout(_("statue in your memory. Rest in peace, and try not"));
prout(_("to think about pigeons."));
- game.gamewon = 1;
+ game.gamewon = true;
}
score();
}
if (game.ship == IHE) klship = 0;
else if (game.ship == IHF) klship = 1;
else klship = 2;
- if (game.gamewon == 0) game.state.nromrem = 0; // None captured if no win
+ if (!game.gamewon) game.state.nromrem = 0; // None captured if no win
iscore = 10*NKILLK + 50*NKILLC + ithperd + iwon
- 100*game.state.basekl - 100*klship - 45*game.nhelp -5*game.state.starkl - game.casual
+ 20*NKILLROM + 200*NKILLSC - 10*game.state.nplankl - 300*game.state.nworldkl + game.state.nromrem;
- if (game.alive == 0) iscore -= 200;
+ if (!game.alive) iscore -= 200;
skip(2);
prout(_("Your score --"));
if (NKILLROM)
if (klship)
prout(_("%6d ship(s) lost or destroyed %5d"),
klship, -100*klship);
- if (game.alive==0)
+ if (!game.alive)
prout(_("Penalty for getting yourself killed -200"));
if (game.gamewon) {
proutn(_("Bonus for winning "));
switch (game.skill) {
+ case SKILL_NONE: break; /* quiet gcc warning */
case SKILL_NOVICE: proutn(_("Novice game ")); break;
case SKILL_FAIR: proutn(_("Fair game ")); break;
case SKILL_GOOD: proutn(_("Good game ")); break;
game.direc = -1.0;
- if (game.landed == 1 && !isprobe) {
+ if (game.landed && !isprobe) {
prout(_("Dummy! You can't leave standard orbit until you"));
proutn(_("are back aboard the "));
crmshp();
chew();
/* is captain on planet? */
- if (game.landed==1) {
+ if (game.landed) {
if (damaged(DTRANSP)) {
finish(FPNOVA);
return;
prout(_("You are traveling backwards in time %d stardates."),
(int)(game.state.date-game.snapsht.date));
game.state = game.snapsht;
- game.state.snap = 0;
+ game.state.snap = false;
if (game.state.remcom) {
schedule(FTBEAM, expran(game.intime/game.state.remcom));
schedule(FBATTAK, expran(0.3*game.intime));
for (l = 0; l < game.inplan; l++) {
if (game.state.plnets[l].known == shuttle_down) {
gotit = true;
- if (game.iscraft==1 && game.ship==IHE) {
+ if (game.iscraft == onship && game.ship==IHE) {
prout(_("Checkov- \"Security reports the Galileo has disappeared, Sir!"));
- game.iscraft = 0;
+ game.iscraft = offship;
}
}
}
/* 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 && game.damage[DSHUTTL] >= 0.0) {
+ if (game.iscraft == offship && !gotit && game.damage[DSHUTTL] >= 0.0) {
prout(_("Checkov- \"Security reports the Galileo has reappeared in the dock!\""));
- game.iscraft = 1;
+ game.iscraft = onship;
}
/*
* There used to be code to do the actual reconstrction here,
prout(_("Lt. Uhura- \"Captain, I'm not getting any response from Starbase.\""));
return;
}
- if (game.landed == 1) {
+ if (game.landed) {
proutn(_("You must be aboard the "));
crmshp();
prout(".");
}
if (m > 3) {
game.quad[ix][iy]=IHQUEST;
- game.alive = 0;
+ game.alive = false;
drawmaps(1);
setwnd(message_window);
finish(FMATERIALIZE);
skip(1);
if (damaged(DTRANSP)) {
prout(_("Transporter damaged."));
- if (!damaged(DSHUTTL) && (game.state.plnets[game.iplnet].known==shuttle_down || game.iscraft == 1)) {
+ if (!damaged(DSHUTTL) && (game.state.plnets[game.iplnet].known==shuttle_down || game.iscraft == onship)) {
skip(1);
proutn(_("Spock- \"May I suggest the shuttle craft, Sir?\" "));
if (ja() == true) shuttle();
prout(_(" you may not go down.\""));
return;
}
- if (game.landed==1) {
+ if (game.landed) {
/* Coming from planet */
if (game.state.plnets[game.iplnet].known==shuttle_down) {
proutn(_("Spock- \"Wouldn't you rather take the Galileo?\" "));
prouts(". . . . . . .E.E.EEEERRRRRIIIIIOOOHWW");
skip(2);
prout(_("Transport complete."));
- game.landed = -game.landed;
- if (game.landed==1 && game.state.plnets[game.iplnet].known==shuttle_down) {
+ game.landed = !game.landed;
+ if (game.landed && game.state.plnets[game.iplnet].known==shuttle_down) {
prout(_("The shuttle craft Galileo is here!"));
}
- if (game.landed!=1 && game.imine) {
+ if (!game.landed && game.imine) {
game.icrystl = true;
game.cryprob = 0.05;
}
{
skip(1);
chew();
- if (game.landed!= 1) {
+ if (!game.landed) {
prout(_("Mining party not on planet."));
return;
}
prout(_(" not in standard orbit."));
return;
}
- if ((game.state.plnets[game.iplnet].known != shuttle_down) && game.iscraft != 1) {
+ if ((game.state.plnets[game.iplnet].known != shuttle_down) && game.iscraft != onship) {
prout(_("Shuttle craft not currently available."));
return;
}
- if (game.landed==-1 && game.state.plnets[game.iplnet].known==shuttle_down) {
+ if (!game.landed && game.state.plnets[game.iplnet].known==shuttle_down) {
prout(_("You will have to beam down to retrieve the shuttle craft."));
return;
}
return;
}
}
- if (game.landed == 1) {
+ if (game.landed) {
/* Kirk on planet */
- if (game.iscraft==1) {
+ if (game.iscraft == onship) {
/* Galileo on ship! */
if (!damaged(DTRANSP)) {
proutn(_("Spock- \"Would you rather use the transporter?\" "));
else
proutn(_("Rescue party"));
prout(_(" boards Galileo and swoops toward planet surface."));
- game.iscraft = 0;
+ game.iscraft = offship;
skip(1);
if (consumeTime()) return;
game.state.plnets[game.iplnet].known=shuttle_down;
game.state.plnets[game.iplnet].known=known;
game.icraft = true;
skip(1);
- game.landed = -1;
+ game.landed = false;
if (consumeTime()) return;
- game.iscraft = 1;
+ game.iscraft = onship;
game.icraft = false;
if (game.imine) {
game.icrystl = true;
prouts(_("The hangar doors open; the trip begins."));
skip(1);
game.icraft = true;
- game.iscraft = 0;
+ game.iscraft = offship;
if (consumeTime()) return;
game.state.plnets[game.iplnet].known = shuttle_down;
- game.landed = 1;
+ game.landed = true;
game.icraft = false;
prout(_("Trip complete"));
return;
prout("Shuttle craft damaged.");
return;
}
- if (game.landed==1) {
+ if (game.landed) {
prout("You must be aboard the Enterprise.");
return;
}
- if (game.iscraft!=1) {
+ if (game.iscraft != onship) {
prout("Shuttle craft not currently available.");
return;
}
prout("still useable.");
if (game.icrystl) prout("The dilithium crystals have been moved.");
game.imine = false;
- game.iscraft=0; /* Galileo disappears */
+ game.iscraft = offship; /* Galileo disappears */
/* Resupply ship */
game.condition=docked;
for (l = 0; l < NDEVICES; l++)
game.state.crew = FULLCREW;
game.energy = game.inenrg = 5000.0;
game.shield = game.inshld = 2500.0;
- game.shldchg = 0;
+ game.shldchg = false;
game.shldup = false;
game.inlsr = 4.0;
game.lsupres = 4.0;
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 = game.icrystl = game.icraft = false;
- game.isatb = game.iscate = game.state.nplankl = 0;
+ game.iscate = game.resting = game.imine = game.icrystl = game.icraft = false;
+ game.isatb = game.state.nplankl = 0;
game.state.starkl = game.state.basekl = 0;
- game.iscraft = 1;
- game.landed = -1;
- game.alive = 1;
+ game.iscraft = onship;
+ game.landed = false;
+ game.alive = true;
game.docfac = 0.25;
for_quadrants(i)
for_quadrants(j) {
quad->planet = NOPLANET;
quad->romulans = 0;
quad->klingons = 0;
- quad->starbase = 0;
- quad->supernova = 0;
+ quad->starbase = false;
+ quad->supernova = false;
quad->status = secure;
}
// Initialize times for extraneous events
} while (contflag);
game.state.baseq[i] = w;
- game.state.galaxy[w.x][w.y].starbase = 1;
- game.state.chart[w.x][w.y].starbase = 1;
+ game.state.galaxy[w.x][w.y].starbase = true;
+ game.state.chart[w.x][w.y].starbase = true;
}
// Position ordinary Klingon Battle Cruisers
krem = game.inkling;
if (thing.x != -1) {
thing = randplace(GALSIZE);
}
- else {
+ else
thing.x = thing.y = 0;
- }
-// idate = date;
skip(2);
- game.state.snap = 0;
+ game.state.snap = false;
if (game.skill == SKILL_NOVICE) {
prout("It is stardate %d. The Federation is being attacked by",
game.nenhere = 0;
game.neutz = false;
game.inorbit = false;
- game.landed = -1;
+ game.landed = false;
game.ientesc = false;
game.ithere = false;
iqhere = false;
game.iseenit = false;
if (game.iscate) {
// Attempt to escape Super-commander, so tbeam back!
- game.iscate = 0;
+ game.iscate = false;
game.ientesc = true;
}
// Clear quadrant
if (same(game.quadrant, game.state.kscmdr)) {
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.iscate = (game.state.remkl > 1);
game.ishere = true;
}
}
w = dropin(IHQUEST);
thing = randplace(GALSIZE);
game.nenhere++;
- iqhere=1;
+ iqhere = true;
game.ks[game.nenhere] = w;
game.kdist[game.nenhere] = game.kavgd[game.nenhere] =
distance(game.sector, w);
case SHIELDS: // shields
doshield(false);
if (game.ididit) {
- hitme=true;
- game.shldchg = 0;
+ hitme = true;
+ game.shldchg = false;
}
break;
case DOCK: // dock
} feature;
typedef struct {
- int snap, // snapshot taken
- crew, // crew complement
+ bool snap; // snapshot taken
+ int crew, // crew complement
#define FULLCREW 428 /* BSD Trek was 387, that's wrong */
remkl, // remaining klingons
remcom, // remaining commanders
} galaxy[GALSIZE+1][GALSIZE+1]; // The Galaxy (subscript 0 not used)
struct page {
int stars;
- int starbase;
+ bool starbase;
int klingons;
} chart[GALSIZE+1][GALSIZE+1]; // the starchart (subscript 0 not used)
} snapshot; // Data that is snapshot
#define INKLINGTOT (game.inkling + game.incom + game.inscom)
#define KLINGKILLED (INKLINGTOT - KLINGREM)
-#define SKILL_NONE 0
-#define SKILL_NOVICE 1
-#define SKILL_FAIR 2
-#define SKILL_GOOD 3
-#define SKILL_EXPERT 4
-#define SKILL_EMERITUS 5
-
/* game options */
#define OPTION_ALL 0xffffffff
#define OPTION_TTY 0x00000001 /* old interface */
alive, // we are alive (not killed)
justin, // just entered quadrant
shldup, // shields are up
+ shldchg, // shield is changing (affects efficiency)
comhere, // commander here
ishere, // super-commander in quadrant
+ iscate, // super commander is here
ientesc, // attempted escape from supercommander
ithere, // Tholian is here
resting, // rest time
icraft, // Kirk in Galileo
+ landed, // party on planet (true), on ship (false)
alldone, // game is now finished
neutz, // Romulan Neutral Zone
isarmed, // probe is armed
docked,
dead,
} condition; // condition (red/yellow/green/docked)
+ enum {
+ onship,
+ offship,
+ removed,
+ } iscraft; // 'onship' if craft on ship, 'removed' if out of game
+ enum {
+ SKILL_NONE,
+ SKILL_NOVICE,
+ SKILL_FAIR,
+ SKILL_GOOD,
+ SKILL_EXPERT,
+ SKILL_EMERITUS,
+ } skill; // skill level
int inkling, // initial number of klingons
inbase, // initial number of bases
incom, // initial number of commanders
inscom, // initial number of commanders
inrom, // initial number of commanders
instar, // initial stars
- intorps, // initial/Max torpedoes
+ intorps, // initial/max torpedoes
torps, // number of torpedoes
ship, // ship type -- 'E' is Enterprise
abandoned, // count of crew abandoned in space
length, // length of game
- skill, // skill level
klhere, // klingons here
casual, // causalties
nhelp, // calls for help
nkinks, // count of energy-barrier crossings
- shldchg, // shield is changing (affects efficiency)
- landed, // party on planet (1), on ship (-1)
iplnet, // planet # in quadrant
inplan, // initial planets
nenhere, // number of enemies in quadrant
irhere, // Romulans in quadrant
- 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])
tourn, // tournament number
proben, // number of moves for probe