We know this if either short or long range sensors are working */
if (!damaged(DSRSENS) || !damaged(DLRSENS) ||
game.condition == docked) {
- crmena(1, ienm, sector, game.ks[loccom]);
+ crmena(true, ienm, sector, game.ks[loccom]);
prout(_(" escapes to %s (and regains strength)."),
cramlc(quadrant, iq));
}
}
-static void movebaddy(coord com, int loccom, int ienm)
+static void movebaddy(coord com, int loccom, feature ienm)
/* tactical movement for the bad guys */
{
int motion, mdist, nsteps, mx, my, ll;
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(1);
+ if (*ipage==0) pause_game(true);
*ipage = 1;
prout(_("Lt. Uhura- \"Captain, Starfleet Intelligence reports"));
proutn(_(" a planet in "));
if (damaged(DRADIO) && game.condition != docked)
return; /* no warning */
game.iseenit = true;
- if (*ipage == 0) pause_game(1);
+ if (*ipage == 0) pause_game(true);
*ipage=1;
proutn(_("Lt. Uhura- \"Captain, the starbase in "));
proutn(cramlc(quadrant, game.state.kscmdr));
(damaged(DRADIO) && game.condition != docked) ||
!game.state.galaxy[game.state.kscmdr.x][game.state.kscmdr.y].charted))
return;
- if (*ipage==0) pause_game(1);
+ if (*ipage==0) pause_game(true);
*ipage = 1;
prout(_("Lt. Uhura- \"Captain, Starfleet Intelligence reports"));
proutn(_(" the Super-commander is in "));
#include "sst.h"
-void doshield(int i)
+void doshield(bool raise)
/* change shield status */
{
int key;
game.ididit = false;
- if (i == 2) action = SHUP;
+ if (raise)
+ action = SHUP;
else {
key = scan();
if (key == IHALPHA) {
}
}
-void ram(bool ibumpd, int ienm, coord w)
+void ram(bool ibumpd, feature ienm, coord w)
/* make our ship ram something */
{
- double type = 1.0, extradm;
+ double hardness, extradm;
int icas, m;
prouts(_("***RED ALERT! RED ALERT!"));
proutn("***");
crmshp();
switch (ienm) {
- case IHR: type = 1.5; break;
- case IHC: type = 2.0; break;
- case IHS: type = 2.5; break;
- case IHT: type = 0.5; break;
- case IHQUEST: type = 4.0; break;
+ case IHR: hardness = 1.5; break;
+ case IHC: hardness = 2.0; break;
+ case IHS: hardness = 2.5; break;
+ case IHT: hardness = 0.5; break;
+ case IHQUEST: hardness = 4.0; break;
+ default: hardness = 1.0; break;
}
proutn(ibumpd ? _(" rammed by ") : _(" rams "));
crmena(false, ienm, sector, w);
continue; // Don't damage deathray
if (game.damage[m] < 0)
continue;
- extradm = (10.0*type*Rand()+1.0)*game.damfac;
+ extradm = (10.0*hardness*Rand()+1.0)*game.damfac;
game.damage[m] += game.optime + extradm; /* Damage for at least time of travel! */
}
game.shldup = false;
if (KLINGREM) {
- pause_game(2);
+ pause_game(true);
dreprt();
}
else finish(FWON);
return;
}
-void deadkl(coord w, int type, coord mv)
+void deadkl(coord w, feature type, coord mv)
/* kill a Klingon, Tholian, Romulan, or Thingy */
{
/* Added mv to allow enemy to "move" before dying */
unschedule(FSCMOVE);
unschedule(FSCDBAS);
break;
+ default: /* avoids a gcc warning */
+ prout("*** Internal error, deadkl() called on %c\n", type);
+ break;
}
}
game.optime -= xtime;
switch (evcode) {
case FSNOVA: /* Supernova */
- if (!ipage) pause_game(1);
+ if (!ipage) pause_game(true);
ipage=true;
snova(false, NULL);
schedule(FSNOVA, expran(0.5*game.intime));
}
/* tractor beaming cases merge here */
yank = sqrt(yank);
- if (!ipage) pause_game(1);
+ 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;
game.quadrant = game.state.kscmdr;
else
game.quadrant = game.state.kcmdr[i];
- game.sector = iran(QUADSIZE);
+ game.sector = randplace(QUADSIZE);
crmshp();
proutn(_(" is pulled to "));
proutn(cramlc(quadrant, game.quadrant));
}
if (!game.shldup) {
if (!damaged(DSHIELD) && game.shield > 0) {
- doshield(2); /* Shldsup */
+ doshield(true); /* raise shields */
game.shldchg=0;
}
else prout(_("(Shields not currently useable.)"));
if (!damaged(DRADIO) && game.condition != docked)
break; /* No warning :-( */
game.iseenit = true;
- if (!ipage) pause_game(1);
+ if (!ipage) pause_game(true);
ipage = true;
skip(1);
proutn(_("Lt. Uhura- \"Captain, the starbase in "));
else if (game.state.rembase != 1 &&
(!damaged(DRADIO) || game.condition == docked)) {
/* Get word via subspace radio */
- if (!ipage) pause_game(1);
+ if (!ipage) pause_game(true);
ipage = true;
skip(1);
prout(_("Lt. Uhura- \"Captain, Starfleet Command reports that"));
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(1);
+ if (ipage==0) pause_game(true);
ipage = 1;
skip(1);
proutn(_("Lt. Uhura- \"The deep space probe "));
break;
}
if (!damaged(DRADIO) || game.condition == docked) {
- if (ipage==0) pause_game(1);
+ if (ipage==0) pause_game(true);
ipage = 1;
skip(1);
proutn(_("Lt. Uhura- \"The deep space probe is now in "));
which has some stars which are inhabited and
not already under attack, which is not
supernova'ed, and which has some Klingons in it */
- w = iran(GALSIZE);
+ w = randplace(GALSIZE);
q = &game.state.galaxy[w.x][w.y];
} while (--i &&
(same(game.quadrant, w) || q->planet == NOPLANET ||
getch();
}
-void pause_game(int i)
+void pause_game(bool announcement)
{
char *prompt;
char buf[BUFSIZ];
- if (i==1) {
+ if (announcement) {
if (game.skill > SKILL_FAIR)
prompt = _("[ANOUNCEMENT ARRIVING...]");
else
putchar('\n');
proutn(prompt);
fgets(buf, sizeof(buf), stdin);
- if (i != 0) {
+ if (announcement) {
int j;
for (j = 0; j < rows; j++)
putchar('\n');
while (i-- > 0) {
if (game.options & OPTION_CURSES) {
if (curwnd == message_window && linecount >= getmaxy(curwnd) - 3) {
- pause_game(0);
+ pause_game(false);
clrscr();
} else {
proutn("\n");
} else {
linecount++;
if (linecount >= rows)
- pause_game(0);
+ pause_game(false);
else
putchar('\n');
}
{
double angle, deltax, deltay, bigger, x, y,
finald, stopegy, probf;
- int n, m, kink, kinks, iquad;
+ int n, m, kink, kinks;
+ feature iquad;
coord w, final;
bool trbeam = false;
}
}
-int srscan(int l)
+void srscan(scantype type)
/* short-range scan */
{
/* the "sy" request is undocumented */
int i, j, jj, req=0;
int goodScan=true, leftside=true, rightside=true, title=false;
- switch (l) {
+ switch (type) {
case SCAN_FULL: // SRSCAN
if (damaged(DSRSENS)) {
/* Allow base's sensors if docked */
prout(_("UNRECOGNIZED REQUEST. Legal requests are:"));
prout(_(" date, condition, position, lsupport, warpfactor,"));
prout(_(" energy, torpedoes, shields, klingons, time, system, bases."));
- return false;
+ return;
}
// no break
case SCAN_STATUS: // STATUS
if (rightside)
status(jj);
if (i<sizeof(requests)/sizeof(requests[0])) skip(1);
- if (req!=0) return(goodScan);
+ if (req!=0) return;
}
prout("");
if (title) chart(true);
- return(goodScan);
}
game.shldup = false;
game.inlsr = 4.0;
game.lsupres = 4.0;
- game.quadrant = iran(GALSIZE);
- game.sector = iran(QUADSIZE);
+ game.quadrant = randplace(GALSIZE);
+ game.sector = randplace(QUADSIZE);
game.torps = game.intorps = 10;
game.nprobes = (int)(3.0*Rand() + 2.0); /* Give them 2-4 of these wonders */
game.warpfac = 5.0;
for (i = 1; i <= game.inbase; i++) {
bool contflag;
do {
- do w = iran(GALSIZE);
+ do w = randplace(GALSIZE);
while (game.state.galaxy[w.x][w.y].starbase);
contflag = false;
for (j = i-1; j > 0; j--) {
int klump = (1.0 - r*r)*klumper;
if (klump > krem) klump = krem;
krem -= klump;
- do w = iran(GALSIZE);
+ do w = randplace(GALSIZE);
while (game.state.galaxy[w.x][w.y].supernova ||
game.state.galaxy[w.x][w.y].klingons + klump > 9);
game.state.galaxy[w.x][w.y].klingons += klump;
}
else
#endif /* ODEBUG */
- w = iran(GALSIZE);
+ w = randplace(GALSIZE);
}
while ((!game.state.galaxy[w.x][w.y].klingons && Rand() < 0.75)||
game.state.galaxy[w.x][w.y].supernova||
}
// Locate planets in galaxy
for (i = 0; i < game.inplan; i++) {
- do w = iran(GALSIZE);
+ do w = randplace(GALSIZE);
while (game.state.galaxy[w.x][w.y].planet != NOPLANET);
game.state.plnets[i].w = w;
if (i < NINHAB) {
}
// Locate Romulans
for (i = 1; i <= game.state.nromrem; i++) {
- w = iran(GALSIZE);
+ w = randplace(GALSIZE);
game.state.galaxy[w.x][w.y].romulans = 1;
}
// Locate the Super Commander
if (game.state.nscrem > 0) {
- do w = iran(GALSIZE);
+ do w = randplace(GALSIZE);
while (game.state.galaxy[w.x][w.y].supernova || game.state.galaxy[w.x][w.y].klingons > 8);
game.state.kscmdr = w;
game.state.galaxy[w.x][w.y].klingons++;
}
// Place thing (in tournament game, thingx == -1, don't want one!)
if (thing.x != -1) {
- thing = iran(GALSIZE);
+ thing = randplace(GALSIZE);
}
else {
thing.x = thing.y = 0;
return false;
}
-coord dropin(int iquad)
+coord dropin(feature iquad)
/* drop a feature on a random dot in the current quadrant */
{
coord w;
- do w = iran(QUADSIZE);
+ do w = randplace(QUADSIZE);
while (game.quad[w.x][w.y] != IHDOT);
game.quad[w.x][w.y] = iquad;
return w;
// Put in THING if needed
if (same(thing, game.quadrant)) {
w = dropin(IHQUEST);
- thing = iran(GALSIZE);
+ thing = randplace(GALSIZE);
game.nenhere++;
iqhere=1;
game.ks[game.nenhere] = w;
warp(false);
break;
case SHIELDS: // shields
- doshield(1);
+ doshield(false);
if (game.ididit) {
hitme=true;
game.shldchg = 0;
}
-void cramen(int i)
+void cramen(feature i)
/* print the name of an enemy */
{
/* return an enemy */
return buf;
}
-void crmena(bool stars, int enemy, enum loctype key, coord w)
+void crmena(bool stars, feature enemy, enum loctype key, coord w)
/* print an enemy and his location */
{
if (stars) proutn("***");
return rand()/(1.0 + (double)RAND_MAX);
}
-coord iran(int size)
+coord randplace(int size)
/* choose a random location */
{
coord w;
prout("Beg your pardon, Captain?");
}
-int isit(char *s)
+bool isit(char *s)
/* compares s to citem and returns true if it matches to the length of s */
{
return strncasecmp(s, citem, max(1, strlen(citem))) == 0;
#define DESTROY(pl) memset(pl, '\0', sizeof(planet))
+typedef enum {
+ IHR = 'R',
+ IHK = 'K',
+ IHC = 'C',
+ IHS = 'S',
+ IHSTAR = '*',
+ IHP = 'P',
+ IHW = '@',
+ IHB = 'B',
+ IHBLANK = ' ',
+ IHDOT = '.',
+ IHQUEST = '?',
+ IHE = 'E',
+ IHF = 'F',
+ IHT = 'T',
+ IHWEB = '#',
+ IHMATER0 = '-',
+ IHMATER1 = 'o',
+ IHMATER2 = '0',
+} feature;
+
typedef struct {
int snap, // snapshot taken
crew, // crew complement
unsigned long options;
snapshot state;
snapshot snapsht;
- char quad[QUADSIZE+1][QUADSIZE+1]; // contents of our quadrant
+ feature quad[QUADSIZE+1][QUADSIZE+1]; // contents of our quadrant
double kpower[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy energy levels
double kdist[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy distances
double kavgd[(QUADSIZE+1)*(QUADSIZE+1)]; // average distances
iseenit, // seen base attack report
thawed; // thawed game
enum {
- green = 'G',
- yellow = 'Y',
- red = 'R',
- docked = 'D',
- dead = 'Z',
+ green,
+ yellow,
+ red,
+ docked,
+ dead,
} condition; // condition (red/yellow/green/docked)
int inkling, // initial number of klingons
inbase, // initial number of bases
extern coord thing;
extern bool iqhere, iqengry;
-typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
- FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
- FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
- FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
- FHOLE, FCREW} FINTYPE ;
+typedef enum {
+ FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
+ FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
+ FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
+ FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
+ FHOLE, FCREW
+} FINTYPE ;
+
enum loctype {neither, quadrant, sector};
-#define IHR 'R'
-#define IHK 'K'
-#define IHC 'C'
-#define IHS 'S'
-#define IHSTAR '*'
-#define IHP 'P'
-#define IHW '@'
-#define IHB 'B'
-#define IHBLANK ' '
-#define IHDOT '.'
-#define IHQUEST '?'
-#define IHE 'E'
-#define IHF 'F'
-#define IHT 'T'
-#define IHWEB '#'
-#define IHMATER0 '-'
-#define IHMATER1 'o'
-#define IHMATER2 '0'
+typedef enum {
+ SCAN_FULL,
+ SCAN_REQUEST,
+ SCAN_STATUS,
+ SCAN_NO_LEFTSIDE,
+} scantype;
/* Function prototypes */
void prelim(void);
void setup(bool);
void score(void);
void atover(bool);
-int srscan(int);
+void srscan(scantype);
void lrscan(void);
void phasers(void);
void photon(void);
void warp(bool);
-void doshield(int);
+void doshield(bool);
void dock(bool);
void dreprt(void);
void chart(bool);
void stars(void);
void newqad(bool);
bool ja(void);
-void cramen(int);
+void cramen(feature);
void crmshp(void);
char *cramlc(enum loctype, coord w);
double expran(double);
double Rand(void);
-coord iran(int);
-coord dropin(int);
+coord randplace(int);
+coord dropin(feature);
void newcnd(void);
void sortkl(void);
void imove(void);
-void ram(bool, int, coord);
-void crmena(bool, int, enum loctype, coord w);
-void deadkl(coord, int, coord);
+void ram(bool, feature, coord);
+void crmena(bool, feature, enum loctype, coord w);
+void deadkl(coord, feature, coord);
void timwrp(void);
void movcom(void);
void torpedo(double, double, coord, double *, int, int);
void huh(void);
-void pause_game(int);
+void pause_game(bool);
void nova(coord);
void snova(bool, coord *);
void scom(bool *);
void hittem(double *);
void prouts(char *, ...);
-int isit(char *);
+bool isit(char *);
void preport(void);
void orbit(void);
void sensor(void);
char *systemname(int);
coord newkling(int);
-/* mode arguments for srscan() */
-#define SCAN_FULL 1
-#define SCAN_REQUEST 2
-#define SCAN_STATUS 3
-#define SCAN_NO_LEFTSIDE 4
-
extern WINDOW *curwnd;
extern WINDOW *fullscreen_window;
extern WINDOW *srscan_window;
extern void clreol(void);
extern void clrscr(void);
-extern void textcolor(int color);
+extern void textcolor(int);
extern void highvideo(void);
enum COLORS {