struct game game;
coord thing;
-int iqhere, iqengry;
+bool iqhere, iqengry;
int iscore, iskill; // Common PLAQ
double aaitem;
double perdate;
#define NUMCOMMANDS sizeof(commands)/sizeof(commands[0])
#define ACCEPT(i) (!commands[i].option || (commands[i].option & game.options))
-static void listCommands(void) {
+static void listCommands(void)
+/* generate a list of legal commands */
+{
int i, k = 0;
proutn("LEGAL COMMANDS ARE:");
for (i = 0; i < NUMCOMMANDS; i++) {
skip(1);
}
-static void helpme(void)
+static void helpme(void)
+/* browse on-line help */
{
int i, j;
char cmdbuf[32], *cp;
fclose(fp);
}
-void enqueue(char *s)
+void enqueue(char *s)
+/* enqueue input for the command parser */
{
strcpy(line, s);
}
-static void makemoves(void)
+static void makemoves(void)
+/* command-interpretation loop */
{
int key, i, v = 0;
bool hitme;
makechart();
continue;
}
- game.ididit=0;
+ game.ididit = false;
clrscr();
setwnd(message_window);
clrscr();
dreprt();
break;
case CHART: // chart
- chart(0);
+ chart(false);
break;
case IMPULSE: // impulse
impuls();
abandn();
break;
case DESTRUCT: // Self Destruct
- dstrct();
+ selfdestruct();
break;
case SAVE: // Save Game
freeze(false);
if (game.ididit) hitme = true;
break;
case QUIT:
- game.alldone = 1; // quit the game
+ game.alldone = true; // quit the game
break;
case HELP:
helpme(); // get help
if (game.alldone) break; // Events did us in
}
if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova) { // Galaxy went Nova!
- atover(0);
+ atover(false);
continue;
}
- if (hitme && game.justin==0) {
+ if (hitme && !game.justin) {
attack(2);
if (game.alldone) break;
if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova) { // went NOVA!
- atover(0);
+ atover(false);
hitme = true;
continue;
}
setup(line[0] == '\0');
if (game.alldone) {
score();
- game.alldone = 0;
+ game.alldone = false;
}
else makemoves();
skip(1);
if (game.tourn && game.alldone) {
proutn("Do you want your score recorded?");
- if (ja()) {
+ if (ja() == true) {
chew2();
freeze(false);
}
void cramen(int i)
+/* print the name of an enemy */
{
/* return an enemy */
char *s;
}
char *cramlc(enum loctype key, coord w)
+/* name a location */
{
static char buf[32];
buf[0] = '\0';
return buf;
}
-void crmena(int i, int enemy, int key, coord w)
+void crmena(bool stars, int enemy, enum loctype key, coord w)
+/* print an enemy and his location */
{
- if (i == 1) proutn("***");
+ if (stars) proutn("***");
cramen(enemy);
proutn(" at ");
proutn(cramlc(key, w));
}
-void crmshp(void)
+void crmshp(void)
+/* print our ship name */
{
char *s;
switch (game.ship) {
proutn(s);
}
-void stars(void)
+void stars(void)
+/* print a line of stars */
{
prouts("******************************************************");
skip(1);
return rand()/(1.0 + (double)RAND_MAX);
}
-void iran(int size, int *i, int *j)
+coord iran(int size)
+/* choose a random location */
{
- *i = Rand()*(size*1.0) + 1.0;
- *j = Rand()*(size*1.0) + 1.0;
+ coord w;
+ w.x = Rand()*(size*1.0) + 1.0;
+ w.y = Rand()*(size*1.0) + 1.0;
+ return w;
}
void chew(void)
return IHALPHA;
}
-bool ja(void)
+bool ja(void)
+/* yes-or-no confirmation */
{
chew();
for(;;) {
}
}
-void huh(void)
+void huh(void)
+/* complain about unparseable input */
{
chew();
skip(1);
}
int isit(char *s)
+/* compares s to citem and returns true if it matches to the length of s */
{
- /* New function -- compares s to scanned citem and returns true if it
- matches to the length of s */
-
return strncasecmp(s, citem, max(1, strlen(citem))) == 0;
-
}
-void debugme(void)
+void debugme(void)
+/* access to the internals for debugging */
{
proutn("Reset levels? ");
- if (ja() != 0) {
+ if (ja() == true) {
if (game.energy < game.inenrg) game.energy = game.inenrg;
game.shield = game.inshld;
game.torps = game.intorps;
game.lsupres = game.inlsr;
}
proutn("Reset damage? ");
- if (ja() != 0) {
+ if (ja() == true) {
int i;
for (i=0; i < NDEVICES; i++)
if (game.damage[i] > 0.0)
game.damage[i] = 0.0;
}
proutn("Toggle debug flag? ");
- if (ja() != 0) {
+ if (ja() == true) {
idebug = !idebug;
if (idebug) prout("Debug output ON");
else prout("Debug output OFF");
}
proutn("Cause selective damage? ");
- if (ja() != 0) {
+ if (ja() == true) {
int i, key;
for (i=0; i < NDEVICES; i++) {
proutn("Kill ");
}
}
proutn("Examine/change events? ");
- if (ja() != 0) {
+ if (ja() == true) {
event *ev;
coord w;
int i;
chew();
}
proutn("Induce supernova here? ");
- if (ja()) {
+ if (ja() == true) {
game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova = true;
- atover(1);
+ atover(true);
}
}