More type cleanup.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 18 Sep 2006 05:16:40 +0000 (05:16 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 18 Sep 2006 05:16:40 +0000 (05:16 +0000)
Use stdbool facility from C99 so code checkers can do type-consistency
analysis.

src/ai.c
src/battle.c
src/events.c
src/finish.c
src/io.c
src/moving.c
src/planets.c
src/reports.c
src/setup.c
src/sst.c
src/sst.h

index ead5a8b1d34064d7f22eed52e0dfefb7f67db7bf..dbf65737a7e63d0e18ce5cfcc3911603969c52d2 100644 (file)
--- a/src/ai.c
+++ b/src/ai.c
@@ -423,10 +423,8 @@ void scom(int *ipage)
 
        for_starbases(i2) {
            i = basetbl[i2];    /* bug in original had it not finding nearest*/
 
        for_starbases(i2) {
            i = basetbl[i2];    /* bug in original had it not finding nearest*/
-           ibq.x = game.state.baseq[i].x;
-           ibq.y = game.state.baseq[i].y;
-           if ((ibq.x == game.quadrant.x && ibq.y == game.quadrant.y) ||
-               (ibq.x == game.battle.x && ibq.y == game.battle.y) ||
+           ibq = game.state.baseq[i];
+           if (same(ibq, game.quadrant) || same(ibq, game.battle) ||
                game.state.galaxy[ibq.x][ibq.y].supernova ||
                game.state.galaxy[ibq.x][ibq.y].klingons > 8) 
                continue;
                game.state.galaxy[ibq.x][ibq.y].supernova ||
                game.state.galaxy[ibq.x][ibq.y].klingons > 8) 
                continue;
@@ -446,8 +444,7 @@ void scom(int *ipage)
            }
        }
        if (ifindit==0) return; /* Nothing suitable -- wait until next time*/
            }
        }
        if (ifindit==0) return; /* Nothing suitable -- wait until next time*/
-       ibq.x = game.state.baseq[iwhichb].x;
-       ibq.y = game.state.baseq[iwhichb].y;
+       ibq = game.state.baseq[iwhichb];
        /* decide how to move toward base */
        ideltax = ibq.x - game.state.kscmdr.x;
        ideltay = ibq.y - game.state.kscmdr.y;
        /* decide how to move toward base */
        ideltax = ibq.x - game.state.kscmdr.x;
        ideltay = ibq.y - game.state.kscmdr.y;
@@ -587,8 +584,7 @@ void movetho(void)
        }
     }
     game.quad[game.tholian.x][game.tholian.y] = IHT;
        }
     }
     game.quad[game.tholian.x][game.tholian.y] = IHT;
-    game.ks[game.nenhere].x=game.tholian.x;
-    game.ks[game.nenhere].y=game.tholian.y;
+    game.ks[game.nenhere] = game.tholian;
 
     /* check to see if all holes plugged */
     for_sectors(i) {
 
     /* check to see if all holes plugged */
     for_sectors(i) {
index 01365f52fc5bf1b3f92590bd2c0602c6326c00b4..aa5f04a7a85bc405a2119304d81e6c15f82a5ba7 100644 (file)
@@ -151,7 +151,7 @@ void ram(int ibumpd, int ienm, coord w)
     crmena(0, ienm, 2, w);
     if (ibumpd) proutn(_(" (original position)"));
     skip(1);
     crmena(0, ienm, 2, w);
     if (ibumpd) proutn(_(" (original position)"));
     skip(1);
-    deadkl(w.x, w.y, ienm, game.sector.x, game.sector.y);
+    deadkl(w, ienm, game.sector.x, game.sector.y);
     proutn("***");
     crmshp();
     prout(_(" heavily damaged."));
     proutn("***");
     crmshp();
     prout(_(" heavily damaged."));
@@ -265,7 +265,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
            if (kp < h1) h1 = kp;
            game.kpower[ll] -= (game.kpower[ll]<0 ? -h1 : h1);
            if (game.kpower[ll] == 0) {
            if (kp < h1) h1 = kp;
            game.kpower[ll] -= (game.kpower[ll]<0 ? -h1 : h1);
            if (game.kpower[ll] == 0) {
-               deadkl(w.x, w.y, iquad, w.x, w.y);
+               deadkl(w, iquad, w.x, w.y);
                return;
            }
            crmena(1, iquad, 2, w);
                return;
            }
            crmena(1, iquad, 2, w);
@@ -283,7 +283,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
            }
            if (game.quad[jx][jy]==IHBLANK) {
                prout(_(" buffeted into black hole."));
            }
            if (game.quad[jx][jy]==IHBLANK) {
                prout(_(" buffeted into black hole."));
-               deadkl(w.x, w.y, iquad, jx, jy);
+               deadkl(w, iquad, jx, jy);
                return;
            }
            if (game.quad[jx][jy]!=IHDOT) {
                return;
            }
            if (game.quad[jx][jy]!=IHDOT) {
@@ -346,7 +346,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
                proutn(_("Mr. Spock-"));
                prouts(_("  \"Fascinating!\""));
                skip(1);
                proutn(_("Mr. Spock-"));
                prouts(_("  \"Fascinating!\""));
                skip(1);
-               deadkl(w.x, w.y, iquad, w.x, w.y);
+               deadkl(w, iquad, w.x, w.y);
            } else {
                /*
                 * Stas Sergeev added the possibility that
            } else {
                /*
                 * Stas Sergeev added the possibility that
@@ -375,7 +375,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int i, int
                game.quad[w.x][w.y] = IHDOT;
                game.ithere = 0;
                game.tholian.x = game.tholian.y = 0;
                game.quad[w.x][w.y] = IHDOT;
                game.ithere = 0;
                game.tholian.x = game.tholian.y = 0;
-               deadkl(w.x, w.y, iquad, w.x, w.y);
+               deadkl(w, iquad, w.x, w.y);
                return;
            }
            skip(1);
                return;
            }
            skip(1);
@@ -603,7 +603,7 @@ void attack(int torps_ok)
     return;
 }
                
     return;
 }
                
-void deadkl(int ix, int iy, int type, int ixx, int iyy) 
+void deadkl(coord w, int type, int ixx, int iyy) 
 {
     /* Added ixx and iyy allow enemy to "move" before dying */
     coord mv;
 {
     /* Added ixx and iyy allow enemy to "move" before dying */
     coord mv;
@@ -658,7 +658,7 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy)
 
     /* For each kind of enemy, finish message to player */
     prout(_(" destroyed."));
 
     /* For each kind of enemy, finish message to player */
     prout(_(" destroyed."));
-    game.quad[ix][iy] = IHDOT;
+    game.quad[w.x][w.y] = IHDOT;
     if (KLINGREM==0) return;
 
     game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom);
     if (KLINGREM==0) return;
 
     game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom);
@@ -667,7 +667,7 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy)
     if (is_scheduled(FCDBAS) && game.battle.x==game.quadrant.x && game.battle.y==game.quadrant.y && type==IHC)
        unschedule(FCDBAS);
     for_local_enemies(i)
     if (is_scheduled(FCDBAS) && game.battle.x==game.quadrant.x && game.battle.y==game.quadrant.y && type==IHC)
        unschedule(FCDBAS);
     for_local_enemies(i)
-       if (game.ks[i].x==ix && game.ks[i].y==iy) break;
+       if (same(game.ks[i], w)) break;
     game.nenhere--;
     if (i <= game.nenhere)  {
        for (j=i; j<=game.nenhere; j++) {
     game.nenhere--;
     if (i <= game.nenhere)  {
        for (j=i; j<=game.nenhere; j++) {
@@ -684,13 +684,13 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy)
     return;
 }
 
     return;
 }
 
-static int targetcheck(double x, double y, double *course) 
+static bool targetcheck(double x, double y, double *course) 
 {
     double deltx, delty;
 {
     double deltx, delty;
-    /* Return TRUE if target is invalid */
+    /* Return true if target is invalid */
     if (!VALID_SECTOR(x, y)) {
        huh();
     if (!VALID_SECTOR(x, y)) {
        huh();
-       return 1;
+       return true;
     }
     deltx = 0.1*(y - game.sector.y);
     delty = 0.1*(game.sector.x - x);
     }
     deltx = 0.1*(y - game.sector.y);
     delty = 0.1*(game.sector.x - x);
@@ -700,10 +700,10 @@ static int targetcheck(double x, double y, double *course)
        prout(_("  I recommend an immediate review of"));
        prout(_("  the Captain's psychological profile.\""));
        chew();
        prout(_("  I recommend an immediate review of"));
        prout(_("  the Captain's psychological profile.\""));
        chew();
-       return 1;
+       return true;
     }
     *course = 1.90985932*atan2(deltx, delty);
     }
     *course = 1.90985932*atan2(deltx, delty);
-    return 0;
+    return false;
 }
 
 void photon(void) 
 }
 
 void photon(void) 
@@ -1210,7 +1210,7 @@ void hittem(double *hits)
        crmena(0,ienm,2,w);
        skip(1);
        if (kpow == 0) {
        crmena(0,ienm,2,w);
        skip(1);
        if (kpow == 0) {
-           deadkl(w.x, w.y, ienm, w.x, w.y);
+           deadkl(w, ienm, w.x, w.y);
            if (KLINGREM==0) finish(FWON);
            if (game.alldone) return;
            kk--; /* don't do the increment */
            if (KLINGREM==0) finish(FWON);
            if (game.alldone) return;
            kk--; /* don't do the increment */
index f5aed2e75f49039b022da27260cdf7de82bdde7a..cd921c57c914b1de8e8769e77636226decc0a91d 100644 (file)
@@ -36,6 +36,7 @@ void events(void)
     int ictbeam=0, ipage=0, istract=0, line, i=0, j, k, l, ixhold=0, iyhold=0;
     double fintim = game.state.date + game.optime, datemin, xtime, repair, yank=0;
     int radio_was_broken;
     int ictbeam=0, ipage=0, istract=0, line, i=0, j, k, l, ixhold=0, iyhold=0;
     double fintim = game.state.date + game.optime, datemin, xtime, repair, yank=0;
     int radio_was_broken;
+    struct quadrant *pdest;
 
 #ifdef DEBUG
     if (game.idebug) prout("EVENTS");
 
 #ifdef DEBUG
     if (game.idebug) prout("EVENTS");
@@ -280,8 +281,8 @@ void events(void)
            /* Not perfect, but will have to do */
            /* Handle case where base is in same quadrant as starship */
            if (game.battle.x==game.quadrant.x && game.battle.y==game.quadrant.y) {
            /* Not perfect, but will have to do */
            /* Handle case where base is in same quadrant as starship */
            if (game.battle.x==game.quadrant.x && game.battle.y==game.quadrant.y) {
-               game.state.chart[game.battle.x][game.battle.y].starbase = FALSE;
-               game.quad[game.base.x][game.base.y]= IHDOT;
+               game.state.chart[game.battle.x][game.battle.y].starbase = false;
+               game.quad[game.base.x][game.base.y] = IHDOT;
                game.base.x=game.base.y=0;
                newcnd();
                skip(1);
                game.base.x=game.base.y=0;
                newcnd();
                skip(1);
@@ -299,10 +300,10 @@ void events(void)
                prout(_(" has been destroyed by"));
                if (game.isatb==2) prout(_("the Klingon Super-Commander"));
                else prout(_("a Klingon Commander"));
                prout(_(" has been destroyed by"));
                if (game.isatb==2) prout(_("the Klingon Super-Commander"));
                else prout(_("a Klingon Commander"));
-               game.state.chart[game.battle.x][game.battle.y].starbase = FALSE;
+               game.state.chart[game.battle.x][game.battle.y].starbase = false;
            }
            /* Remove Starbase from galaxy */
            }
            /* Remove Starbase from galaxy */
-           game.state.galaxy[game.battle.x][game.battle.y].starbase = FALSE;
+           game.state.galaxy[game.battle.x][game.battle.y].starbase = false;
            for_starbases(i)
                if (game.state.baseq[i].x==game.battle.x && game.state.baseq[i].y==game.battle.y) {
                    game.state.baseq[i].x=game.state.baseq[game.state.rembase].x;
            for_starbases(i)
                if (game.state.baseq[i].x==game.battle.x && game.state.baseq[i].y==game.battle.y) {
                    game.state.baseq[i].x=game.state.baseq[game.state.rembase].x;
@@ -360,17 +361,19 @@ void events(void)
                    prout(".\"");
                }
            }
                    prout(".\"");
                }
            }
+           pdest = &game.state.galaxy[game.probec.x][game.probec.y];
            /* Update star chart if Radio is working or have access to
               radio. */
            if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED) {
            /* Update star chart if Radio is working or have access to
               radio. */
            if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED) {
-               game.state.chart[game.probec.x][game.probec.y].klingons = game.state.galaxy[game.probec.x][game.probec.y].klingons;
-               game.state.chart[game.probec.x][game.probec.y].starbase = game.state.galaxy[game.probec.x][game.probec.y].starbase;
-               game.state.chart[game.probec.x][game.probec.y].stars = game.state.galaxy[game.probec.x][game.probec.y].stars;
-               game.state.galaxy[game.probec.x][game.probec.y].charted = TRUE;
+               struct page *chp = &game.state.chart[game.probec.x][game.probec.y];
+
+               chp->klingons = pdest->klingons;
+               chp->starbase = pdest->starbase;
+               chp->stars = pdest->stars;
+               pdest->charted = true;
            }
            game.proben--; // One less to travel
            }
            game.proben--; // One less to travel
-           if (game.proben == 0 && game.isarmed &&
-               game.state.galaxy[game.probec.x][game.probec.y].stars) {
+           if (game.proben == 0 && game.isarmed && pdest->stars) {
                /* lets blow the sucker! */
                snova(1,0);
                unschedule(FDSPROB);
                /* lets blow the sucker! */
                snova(1,0);
                unschedule(FDSPROB);
@@ -629,7 +632,7 @@ void nova(int ix, int iy)
                        game.quad[scratch.x][scratch.y] = IHDOT;
                        break;
                    case IHB: /* Destroy base */
                        game.quad[scratch.x][scratch.y] = IHDOT;
                        break;
                    case IHB: /* Destroy base */
-                       game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase = FALSE;
+                       game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase = false;
                        for_starbases(i)
                            if (game.state.baseq[i].x==game.quadrant.x && game.state.baseq[i].y==game.quadrant.y) 
                                break;
                        for_starbases(i)
                            if (game.state.baseq[i].x==game.quadrant.x && game.state.baseq[i].y==game.quadrant.y) 
                                break;
@@ -667,7 +670,7 @@ void nova(int ix, int iy)
                        kount++;
                        break;
                    case IHK: /* kill klingon */
                        kount++;
                        break;
                    case IHK: /* kill klingon */
-                       deadkl(scratch.x,scratch.y,iquad, scratch.x, scratch.y);
+                       deadkl(scratch,iquad, scratch.x, scratch.y);
                        break;
                    case IHC: /* Damage/destroy big enemies */
                    case IHS:
                        break;
                    case IHC: /* Damage/destroy big enemies */
                    case IHS:
@@ -676,7 +679,7 @@ void nova(int ix, int iy)
                            if (game.ks[ll].x==scratch.x && game.ks[ll].y==scratch.y) break;
                        game.kpower[ll] -= 800.0; /* If firepower is lost, die */
                        if (game.kpower[ll] <= 0.0) {
                            if (game.ks[ll].x==scratch.x && game.ks[ll].y==scratch.y) break;
                        game.kpower[ll] -= 800.0; /* If firepower is lost, die */
                        if (game.kpower[ll] <= 0.0) {
-                           deadkl(scratch.x, scratch.y, iquad, scratch.x, scratch.y);
+                           deadkl(scratch, iquad, scratch.x, scratch.y);
                            break;
                        }
                        newc.x = scratch.x + scratch.x - hits[mm][1];
                            break;
                        }
                        newc.x = scratch.x + scratch.x - hits[mm][1];
@@ -693,7 +696,7 @@ void nova(int ix, int iy)
                            proutn(_(", blasted into "));
                            crmena(0, IHBLANK, 2, newc);
                            skip(1);
                            proutn(_(", blasted into "));
                            crmena(0, IHBLANK, 2, newc);
                            skip(1);
-                           deadkl(scratch.x, scratch.y, iquad, newc.x, newc.y);
+                           deadkl(scratch, iquad, newc.x, newc.y);
                            break;
                        }
                        if (iquad1 != IHDOT) {
                            break;
                        }
                        if (iquad1 != IHDOT) {
@@ -886,7 +889,7 @@ void snova(int insx, int insy)
     if ((game.quadrant.x == nq.x && game.quadrant.y == nq.y) ||
        game.damage[DRADIO] == 0 ||
        game.condit == IHDOCKED)
     if ((game.quadrant.x == nq.x && game.quadrant.y == nq.y) ||
        game.damage[DRADIO] == 0 ||
        game.condit == IHDOCKED)
-       game.state.galaxy[nq.x][nq.y].supernova = TRUE;
+       game.state.galaxy[nq.x][nq.y].supernova = true;
     /* If supernova destroys last klingons give special message */
     if (KLINGREM==0 && (nq.x != game.quadrant.x || nq.y != game.quadrant.y)) {
        skip(2);
     /* If supernova destroys last klingons give special message */
     if (KLINGREM==0 && (nq.x != game.quadrant.x || nq.y != game.quadrant.y)) {
        skip(2);
index e5a7386cf1cbfb2912a737a525fa5378ddfc94db..e1914514bc05b1f65ca2d569b3e9cda9bbac9fdd 100644 (file)
@@ -61,7 +61,7 @@ void kaboom(void)
        int l=1;
        while (l <= game.nenhere) {
            if (game.kpower[l]*game.kdist[l] <= whammo) 
        int l=1;
        while (l <= game.nenhere) {
            if (game.kpower[l]*game.kdist[l] <= whammo) 
-               deadkl(game.ks[l].x,game.ks[l].x, game.quad[game.ks[l].x][game.ks[l].y], game.ks[l].x, game.ks[l].y);
+               deadkl(game.ks[l], game.quad[game.ks[l].x][game.ks[l].y], game.ks[l].x, game.ks[l].y);
            l++;
        }
     }
            l++;
        }
     }
index b513f26af4efe625d0cddb238ba06491de6057b7..48f2e3876266a13dce90226a111656ba74f280c3 100644 (file)
--- a/src/io.c
+++ b/src/io.c
@@ -303,7 +303,7 @@ void highvideo (void)
     }
 }
  
     }
 }
  
-void commandhook(char *cmd, int before) {
+void commandhook(char *cmd, bool before) {
 }
 
 /*
 }
 
 /*
@@ -430,7 +430,7 @@ void makechart(void)
 void setpassword(void) 
 {
     if (!(game.options & OPTION_CURSES)) {
 void setpassword(void) 
 {
     if (!(game.options & OPTION_CURSES)) {
-       while (TRUE) {
+       for (;;) {
            scan();
            strcpy(game.passwd, citem);
            chew();
            scan();
            strcpy(game.passwd, citem);
            chew();
index 48c08a210449561ff4a81ea8f5ac9daaac619205..42df8c1ea6e45002da883757e72adaaf6b7f1475 100644 (file)
@@ -2,7 +2,7 @@
 #include "sstlinux.h"
 #include "sst.h"
 
 #include "sstlinux.h"
 #include "sst.h"
 
-static void getcd(int, int);
+static void getcd(bool, int);
 
 void imove(void) 
 {
 
 void imove(void) 
 {
@@ -14,7 +14,7 @@ void imove(void)
     w.x = w.y = 0;
     if (game.inorbit) {
        prout("Helmsman Sulu- \"Leaving standard orbit.\"");
     w.x = w.y = 0;
     if (game.inorbit) {
        prout("Helmsman Sulu- \"Leaving standard orbit.\"");
-       game.inorbit = FALSE;
+       game.inorbit = false;
     }
 
     angle = ((15.0 - game.direc) * 0.5235988);
     }
 
     angle = ((15.0 - game.direc) * 0.5235988);
@@ -246,7 +246,7 @@ void dock(int l)
     }
 }
 
     }
 }
 
-static void getcd(int isprobe, int akey) {
+static void getcd(bool isprobe, int akey) {
        /* This program originally required input in terms of a (clock)
           direction and distance. Somewhere in history, it was changed to
           cartesian coordinates. So we need to convert. I think
        /* This program originally required input in terms of a (clock)
           direction and distance. Somewhere in history, it was changed to
           cartesian coordinates. So we need to convert. I think
@@ -446,7 +446,7 @@ void impuls(void)
     }
 
     if (game.energy > 30.0) {
     }
 
     if (game.energy > 30.0) {
-       getcd(FALSE, 0);
+       getcd(false, 0);
        if (game.direc == -1.0) return;
        power = 20.0 + 100.0*game.dist;
     }
        if (game.direc == -1.0) return;
        power = 20.0 + 100.0*game.dist;
     }
@@ -511,7 +511,7 @@ void warp(int i)
        }
                        
        /* Read in course and distance */
        }
                        
        /* Read in course and distance */
-       getcd(FALSE, 0);
+       getcd(false, 0);
        if (game.direc == -1.0) return;
 
        /* Make sure starship has enough energy for the trip */
        if (game.direc == -1.0) return;
 
        /* Make sure starship has enough energy for the trip */
@@ -734,7 +734,7 @@ void atover(int igrab)
        skip(1);
        prout("safely out of quadrant.");
        if (game.damage[DRADIO] == 0.0)
        skip(1);
        prout("safely out of quadrant.");
        if (game.damage[DRADIO] == 0.0)
-           game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = TRUE;
+           game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = true;
        /* Try to use warp engines */
        if (game.damage[DWARPEN]) {
            skip(1);
        /* Try to use warp engines */
        if (game.damage[DWARPEN]) {
            skip(1);
@@ -869,16 +869,16 @@ void probe(void)
        if (ja()==0) return;
     }
 
        if (ja()==0) return;
     }
 
-    game.isarmed = FALSE;
+    game.isarmed = false;
     if (key == IHALPHA && strcmp(citem,"armed") == 0) {
     if (key == IHALPHA && strcmp(citem,"armed") == 0) {
-       game.isarmed = TRUE;
+       game.isarmed = true;
        key = scan();
     }
     else if (key == IHEOL) {
        proutn("Arm NOVAMAX warhead? ");
        game.isarmed = ja();
     }
        key = scan();
     }
     else if (key == IHEOL) {
        proutn("Arm NOVAMAX warhead? ");
        game.isarmed = ja();
     }
-    getcd(TRUE, key);
+    getcd(true, key);
     if (game.direc == -1.0) return;
     game.nprobes--;
     angle = ((15.0 - game.direc) * 0.5235988);
     if (game.direc == -1.0) return;
     game.nprobes--;
     angle = ((15.0 - game.direc) * 0.5235988);
@@ -943,8 +943,7 @@ void mayday(void)
            }
        }
        /* Since starbase not in quadrant, set up new quadrant */
            }
        }
        /* Since starbase not in quadrant, set up new quadrant */
-       game.quadrant.x = game.state.baseq[line].x;
-       game.quadrant.y = game.state.baseq[line].y;
+       game.quadrant = game.state.baseq[line];
        newqad(1);
     }
     /* dematerialize starship */
        newqad(1);
     }
     /* dematerialize starship */
index 723e5e9a7ab92e24d6a8360076fa6010a1142bcc..c1ead062244db3436a38cc3f00dd6f45b234be17 100644 (file)
@@ -443,7 +443,7 @@ void deathray(void)
        prouts("Sulu- \"Captain!  It's working!\"");
        skip(2);
        while (game.nenhere > 0)
        prouts("Sulu- \"Captain!  It's working!\"");
        skip(2);
        while (game.nenhere > 0)
-           deadkl(game.ks[1].x,game.ks[1].y,game.quad[game.ks[1].x][game.ks[1].y],game.ks[1].x,game.ks[1].y);
+           deadkl(game.ks[1]game.quad[game.ks[1].x][game.ks[1].y],game.ks[1].x,game.ks[1].y);
        prout("Ensign Chekov-  \"Congratulations, Captain!\"");
        if (KLINGREM == 0) finish(FWON);
        if ((game.options & OPTION_PLAIN) == 0) {
        prout("Ensign Chekov-  \"Congratulations, Captain!\"");
        if (KLINGREM == 0) finish(FWON);
        if ((game.options & OPTION_PLAIN) == 0) {
index ac4f417b047b579ad3d211e3192988287046da1e..8e4f070e02ab5c21a2e7431c482dfb8cc6fbef32 100644 (file)
@@ -135,7 +135,7 @@ void lrscan(void)
                proutn("  -1");
            else {
                if (!game.damage[DRADIO])
                proutn("  -1");
            else {
                if (!game.damage[DRADIO])
-                   game.state.galaxy[x][y].charted = TRUE;
+                   game.state.galaxy[x][y].charted = true;
                game.state.chart[x][y].klingons = game.state.galaxy[x][y].klingons;
                game.state.chart[x][y].starbase = game.state.galaxy[x][y].starbase;
                game.state.chart[x][y].stars = game.state.galaxy[x][y].stars;
                game.state.chart[x][y].klingons = game.state.galaxy[x][y].klingons;
                game.state.chart[x][y].starbase = game.state.galaxy[x][y].starbase;
                game.state.chart[x][y].stars = game.state.galaxy[x][y].stars;
@@ -151,7 +151,8 @@ void lrscan(void)
 
 void dreprt(void) 
 {
 
 void dreprt(void) 
 {
-    int jdam = FALSE, i;
+    bool jdam = false;
+    int i;
     chew();
 
     for (i = 0; i < NDEVICES; i++) {
     chew();
 
     for (i = 0; i < NDEVICES; i++) {
@@ -159,7 +160,7 @@ void dreprt(void)
            if (!jdam) {
                prout("DEVICE            -REPAIR TIMES-");
                prout("                IN FLIGHT   DOCKED");
            if (!jdam) {
                prout("DEVICE            -REPAIR TIMES-");
                prout("                IN FLIGHT   DOCKED");
-               jdam = TRUE;
+               jdam = true;
            }
            prout("  %16s %8.2f  %8.2f", 
                  device[i],
            }
            prout("  %16s %8.2f  %8.2f", 
                  device[i],
@@ -334,15 +335,16 @@ int srscan(int l)
     /* the "sy" request is undocumented */
     static char requests[][3] =
        {"","da","co","po","ls","wa","en","to","sh","kl","sy", "ti"};
     /* the "sy" request is undocumented */
     static char requests[][3] =
        {"","da","co","po","ls","wa","en","to","sh","kl","sy", "ti"};
-    int leftside=TRUE, rightside=TRUE, i, j, jj, req=0, nn=FALSE;
-    int goodScan=TRUE;
+    
+    int i, j, jj, req=0;
+    int goodScan=true, leftside=true, rightside=true, nn=false; 
     switch (l) {
     case SCAN_FULL: // SRSCAN
        if (game.damage[DSRSENS] != 0) {
            /* Allow base's sensors if docked */
            if (game.condit != IHDOCKED) {
                prout("   S.R. SENSORS DAMAGED!");
     switch (l) {
     case SCAN_FULL: // SRSCAN
        if (game.damage[DSRSENS] != 0) {
            /* Allow base's sensors if docked */
            if (game.condit != IHDOCKED) {
                prout("   S.R. SENSORS DAMAGED!");
-               goodScan=FALSE;
+               goodScan=false;
            }
            else
                prout("  [Using Base's sensors]");
            }
            else
                prout("  [Using Base's sensors]");
@@ -352,11 +354,11 @@ int srscan(int l)
            game.state.chart[game.quadrant.x][game.quadrant.y].klingons = game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons;
            game.state.chart[game.quadrant.x][game.quadrant.y].starbase = game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase;
            game.state.chart[game.quadrant.x][game.quadrant.y].stars = game.state.galaxy[game.quadrant.x][game.quadrant.y].stars;
            game.state.chart[game.quadrant.x][game.quadrant.y].klingons = game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons;
            game.state.chart[game.quadrant.x][game.quadrant.y].starbase = game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase;
            game.state.chart[game.quadrant.x][game.quadrant.y].stars = game.state.galaxy[game.quadrant.x][game.quadrant.y].stars;
-           game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = TRUE;
+           game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = true;
        }
        scan();
        }
        scan();
-       if (isit("chart")) nn = TRUE;
-       if (isit("no")) rightside = FALSE;
+       if (isit("chart")) nn = true;
+       if (isit("no")) rightside = false;
        chew();
        prout("    1 2 3 4 5 6 7 8 9 10");
        break;
        chew();
        prout("    1 2 3 4 5 6 7 8 9 10");
        break;
@@ -371,16 +373,16 @@ int srscan(int l)
            prout("UNRECOGNIZED REQUEST. Legal requests are:");
            prout("  date, condition, position, lsupport, warpfactor,");
            prout("  energy, torpedoes, shields, klingons, time, system, bases.");
            prout("UNRECOGNIZED REQUEST. Legal requests are:");
            prout("  date, condition, position, lsupport, warpfactor,");
            prout("  energy, torpedoes, shields, klingons, time, system, bases.");
-           return FALSE;
+           return false;
        }
        // no break
     case SCAN_STATUS: // STATUS
        chew();
        }
        // no break
     case SCAN_STATUS: // STATUS
        chew();
-       leftside = FALSE;
+       leftside = false;
        skip(1);
        // no break
     case SCAN_NO_LEFTSIDE: // REQUEST
        skip(1);
        // no break
     case SCAN_NO_LEFTSIDE: // REQUEST
-       leftside=FALSE;
+       leftside=false;
        break;
     }
     if (game.condit != IHDOCKED) newcnd();
        break;
     }
     if (game.condit != IHDOCKED) newcnd();
@@ -405,8 +407,8 @@ int srscan(int l)
                        
 void eta(void)
 {
                        
 void eta(void)
 {
-    int ix1, ix2, iy1, iy2, prompt=FALSE;
-    int wfl;
+    int ix1, ix2, iy1, iy2;
+    bool wfl, prompt = false;
     double ttime, twarp, tpower;
     if (game.damage[DCOMPTR] != 0.0) {
        prout("COMPUTER DAMAGED, USE A POCKET CALCULATOR.");
     double ttime, twarp, tpower;
     if (game.damage[DCOMPTR] != 0.0) {
        prout("COMPUTER DAMAGED, USE A POCKET CALCULATOR.");
@@ -414,7 +416,7 @@ void eta(void)
        return;
     }
     if (scan() != IHREAL) {
        return;
     }
     if (scan() != IHREAL) {
-       prompt = TRUE;
+       prompt = true;
        chew();
        proutn("Destination quadrant and/or sector? ");
        if (scan()!=IHREAL) {
        chew();
        proutn("Destination quadrant and/or sector? ");
        if (scan()!=IHREAL) {
@@ -449,10 +451,10 @@ void eta(void)
     }
     game.dist = sqrt(square(iy1-game.quadrant.x+0.1*(iy2-game.sector.x))+
                square(ix1-game.quadrant.y+0.1*(ix2-game.sector.y)));
     }
     game.dist = sqrt(square(iy1-game.quadrant.x+0.1*(iy2-game.sector.x))+
                square(ix1-game.quadrant.y+0.1*(ix2-game.sector.y)));
-    wfl = FALSE;
+    wfl = false;
 
     if (prompt) prout("Answer \"no\" if you don't know the value:");
 
     if (prompt) prout("Answer \"no\" if you don't know the value:");
-    while (TRUE) {
+    for (;;) {
        chew();
        proutn("Time or arrival date? ");
        if (scan()==IHREAL) {
        chew();
        proutn("Time or arrival date? ");
        if (scan()==IHREAL) {
@@ -470,7 +472,7 @@ void eta(void)
        chew();
        proutn("Warp factor? ");
        if (scan()== IHREAL) {
        chew();
        proutn("Warp factor? ");
        if (scan()== IHREAL) {
-           wfl = TRUE;
+           wfl = true;
            twarp = aaitem;
            if (twarp<1.0 || twarp > 10.0) {
                huh();
            twarp = aaitem;
            if (twarp<1.0 || twarp > 10.0) {
                huh();
@@ -480,7 +482,7 @@ void eta(void)
        }
        prout("Captain, certainly you can give me one of these.");
     }
        }
        prout("Captain, certainly you can give me one of these.");
     }
-    while (TRUE) {
+    for (;;) {
        chew();
        ttime = (10.0*game.dist)/square(twarp);
        tpower = game.dist*twarp*twarp*twarp*(game.shldup+1);
        chew();
        ttime = (10.0*game.dist)/square(twarp);
        tpower = game.dist*twarp*twarp*twarp*(game.shldup+1);
@@ -490,7 +492,7 @@ void eta(void)
                if (!wfl) return;
                proutn("New warp factor to try? ");
                if (scan() == IHREAL) {
                if (!wfl) return;
                proutn("New warp factor to try? ");
                if (scan() == IHREAL) {
-                   wfl = TRUE;
+                   wfl = true;
                    twarp = aaitem;
                    if (twarp<1.0 || twarp > 10.0) {
                        huh();
                    twarp = aaitem;
                    if (twarp<1.0 || twarp > 10.0) {
                        huh();
@@ -532,7 +534,7 @@ void eta(void)
            prout("The starbase there will be destroyed by then.");
        proutn("New warp factor to try? ");
        if (scan() == IHREAL) {
            prout("The starbase there will be destroyed by then.");
        proutn("New warp factor to try? ");
        if (scan() == IHREAL) {
-           wfl = TRUE;
+           wfl = true;
            twarp = aaitem;
            if (twarp<1.0 || twarp > 10.0) {
                huh();
            twarp = aaitem;
            if (twarp<1.0 || twarp > 10.0) {
                huh();
index 3e6718f4620b1bc0339e0fa205f40c504e2e6a8d..bbfbb67a42181da97b641dbbd75f900f423adf6c 100644 (file)
@@ -19,7 +19,7 @@ void prelim(void)
 #endif /* __HISTORICAL__ */
 }
 
 #endif /* __HISTORICAL__ */
 }
 
-void freeze(int boss) 
+void freeze(bool boss) 
 {
     FILE *fp;
     int key;
 {
     FILE *fp;
     int key;
@@ -220,7 +220,8 @@ void setup(int needprompt)
     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.resting = game.casual = 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.resting = game.casual = 0;
-    game.isatb = game.iscate = game.imine = game.icrystl = game.icraft = game.state.nplankl = 0;
+    game.isatb = game.iscate = true;
+    game.imine = game.icrystl = game.icraft = game.state.nplankl = 0;
     game.state.starkl = game.state.basekl = 0;
     game.iscraft = 1;
     game.landed = -1;
     game.state.starkl = game.state.basekl = 0;
     game.iscraft = 1;
     game.landed = -1;
@@ -269,16 +270,16 @@ void setup(int needprompt)
        }
     // Locate star bases in galaxy
     for (i = 1; i <= game.inbase; i++) {
        }
     // Locate star bases in galaxy
     for (i = 1; i <= game.inbase; i++) {
-       int contflag;
+       bool contflag;
        do {
            do iran(GALSIZE, &ix, &iy);
            while (game.state.galaxy[ix][iy].starbase);
        do {
            do iran(GALSIZE, &ix, &iy);
            while (game.state.galaxy[ix][iy].starbase);
-           contflag = FALSE;
+           contflag = false;
            for (j = i-1; j > 0; j--) {
                /* Improved placement algorithm to spread out bases */
                double distq = square(ix-game.state.baseq[j].x) + square(iy-game.state.baseq[j].y);
                if (distq < 6.0*(BASEMAX+1-game.inbase) && Rand() < 0.75) {
            for (j = i-1; j > 0; j--) {
                /* Improved placement algorithm to spread out bases */
                double distq = square(ix-game.state.baseq[j].x) + square(iy-game.state.baseq[j].y);
                if (distq < 6.0*(BASEMAX+1-game.inbase) && Rand() < 0.75) {
-                   contflag = TRUE;
+                   contflag = true;
 #ifdef DEBUG
                    prout("DEBUG: Abandoning base #%d at %d-%d", i, ix, iy);
 #endif
 #ifdef DEBUG
                    prout("DEBUG: Abandoning base #%d at %d-%d", i, ix, iy);
 #endif
@@ -423,9 +424,9 @@ void setup(int needprompt)
     if (game.neutz) attack(0); // bad luck to start in a Romulan Neutral Zone
 }
 
     if (game.neutz) attack(0); // bad luck to start in a Romulan Neutral Zone
 }
 
-int choose(int needprompt) 
+bool choose(bool needprompt) 
 {
 {
-    while (TRUE) {
+    for(;;) {
        game.tourn = 0;
        game.thawed = 0;
        game.skill = SKILL_NONE;
        game.tourn = 0;
        game.thawed = 0;
        game.skill = SKILL_NONE;
@@ -454,7 +455,7 @@ int choose(int needprompt)
            if (!game.alldone) game.thawed = 1; // No plaque if not finished
            report();
            waitfor();
            if (!game.alldone) game.thawed = 1; // No plaque if not finished
            report();
            waitfor();
-           return TRUE;
+           return true;
        }
        if (isit("regular")) break;
        proutn("What is \"");
        }
        if (isit("regular")) break;
        proutn("What is \"");
@@ -531,7 +532,7 @@ int choose(int needprompt)
     if (game.inkling > 50) {
        game.inbase = (game.state.rembase += 1);
     }
     if (game.inkling > 50) {
        game.inbase = (game.state.rembase += 1);
     }
-    return FALSE;
+    return false;
 }
 
 void dropin(int iquad, coord *w) 
 }
 
 void dropin(int iquad, coord *w) 
@@ -730,17 +731,18 @@ void newqad(int shutup)
 void sortkl(void) 
 {
     double t;
 void sortkl(void) 
 {
     double t;
-    int sw, j, k;
+    int j, k;
+    bool sw;
 
     // The author liked bubble sort. So we will use it. :-(
 
     if (game.nenhere-iqhere-game.ithere < 2) return;
 
     do {
 
     // The author liked bubble sort. So we will use it. :-(
 
     if (game.nenhere-iqhere-game.ithere < 2) return;
 
     do {
-       sw = FALSE;
+       sw = false;
        for (j = 1; j < game.nenhere; j++)
            if (game.kdist[j] > game.kdist[j+1]) {
        for (j = 1; j < game.nenhere; j++)
            if (game.kdist[j] > game.kdist[j+1]) {
-               sw = TRUE;
+               sw = true;
                t = game.kdist[j];
                game.kdist[j] = game.kdist[j+1];
                game.kdist[j+1] = t;
                t = game.kdist[j];
                game.kdist[j] = game.kdist[j+1];
                game.kdist[j+1] = t;
index b68613d21f8fe26540b763805755d387594ad55a..080a9a01b0224f42870138fce382f97e15eca17f 100644 (file)
--- a/src/sst.c
+++ b/src/sst.c
@@ -298,7 +298,7 @@ static void helpme(void)
     /* Give help on commands */
     int key;
     key = scan();
     /* Give help on commands */
     int key;
     key = scan();
-    while (TRUE) {
+    for(;;) {
        if (key == IHEOL) {
            setwnd(prompt_window);
            proutn("Help on what command? ");
        if (key == IHEOL) {
            setwnd(prompt_window);
            proutn("Help on what command? ");
@@ -375,13 +375,14 @@ void enqueue(char *s)
 
 static void makemoves(void) 
 {
 
 static void makemoves(void) 
 {
-    int i, v = 0, hitme;
+    int i, v = 0;
+    bool hitme;
     clrscr();
     setwnd(message_window);
     clrscr();
     setwnd(message_window);
-    while (TRUE) { /* command loop */
+    for(;;) { /* command loop */
        drawmaps(1);
        drawmaps(1);
-       while (TRUE)  { /* get a command */
-           hitme = FALSE;
+       for(;;)  { /* get a command */
+           hitme = false;
            game.justin = 0;
            game.optime = 0.0;
            i = -1;
            game.justin = 0;
            game.optime = 0.0;
            i = -1;
@@ -413,7 +414,7 @@ static void makemoves(void)
                break;
            listCommands();
        }
                break;
            listCommands();
        }
-       commandhook(commands[i].name, TRUE);
+       commandhook(commands[i].name, true);
        switch (v) { /* command switch */
        case SRSCAN:                 // srscan
            srscan(SCAN_FULL);
        switch (v) { /* command switch */
        case SRSCAN:                 // srscan
            srscan(SCAN_FULL);
@@ -429,11 +430,11 @@ static void makemoves(void)
            break;
        case PHASERS:                   // phasers
            phasers();
            break;
        case PHASERS:                   // phasers
            phasers();
-           if (game.ididit) hitme = TRUE;
+           if (game.ididit) hitme = true;
            break;
        case TORPEDO:                   // photons
            photon();
            break;
        case TORPEDO:                   // photons
            photon();
-           if (game.ididit) hitme = TRUE;
+           if (game.ididit) hitme = true;
            break;
        case MOVE:                      // move
            warp(1);
            break;
        case MOVE:                      // move
            warp(1);
@@ -441,7 +442,7 @@ static void makemoves(void)
        case SHIELDS:                   // shields
            doshield(1);
            if (game.ididit) {
        case SHIELDS:                   // shields
            doshield(1);
            if (game.ididit) {
-               hitme=TRUE;
+               hitme=true;
                game.shldchg = 0;
            }
            break;
                game.shldchg = 0;
            }
            break;
@@ -460,7 +461,7 @@ static void makemoves(void)
            break;
        case REST:                      // rest
            wait();
            break;
        case REST:                      // rest
            wait();
-           if (game.ididit) hitme = TRUE;
+           if (game.ididit) hitme = true;
            break;
        case WARP:                      // warp
            setwrp();
            break;
        case WARP:                      // warp
            setwrp();
@@ -473,22 +474,22 @@ static void makemoves(void)
            break;
        case ORBIT:                     // orbit
            orbit();
            break;
        case ORBIT:                     // orbit
            orbit();
-           if (game.ididit) hitme = TRUE;
+           if (game.ididit) hitme = true;
            break;
        case TRANSPORT:                 // transport "beam"
            beam();
            break;
        case MINE:                      // mine
            mine();
            break;
        case TRANSPORT:                 // transport "beam"
            beam();
            break;
        case MINE:                      // mine
            mine();
-           if (game.ididit) hitme = TRUE;
+           if (game.ididit) hitme = true;
            break;
        case CRYSTALS:                  // crystals
            usecrystals();
            break;
        case CRYSTALS:                  // crystals
            usecrystals();
-           if (game.ididit) hitme = TRUE;
+           if (game.ididit) hitme = true;
            break;
        case SHUTTLE:                   // shuttle
            shuttle();
            break;
        case SHUTTLE:                   // shuttle
            shuttle();
-           if (game.ididit) hitme = TRUE;
+           if (game.ididit) hitme = true;
            break;
        case PLANETS:                   // Planet list
            preport();
            break;
        case PLANETS:                   // Planet list
            preport();
@@ -504,12 +505,12 @@ static void makemoves(void)
            break;
        case EMEXIT:                    // Emergency exit
            clrscr();                   // Hide screen
            break;
        case EMEXIT:                    // Emergency exit
            clrscr();                   // Hide screen
-           freeze(TRUE);               // forced save
+           freeze(true);               // forced save
            exit(1);                    // And quick exit
            break;
        case PROBE:
            probe();                    // Launch probe
            exit(1);                    // And quick exit
            break;
        case PROBE:
            probe();                    // Launch probe
-           if (game.ididit) hitme = TRUE;
+           if (game.ididit) hitme = true;
            break;
        case ABANDON:                   // Abandon Ship
            abandn();
            break;
        case ABANDON:                   // Abandon Ship
            abandn();
@@ -518,14 +519,14 @@ static void makemoves(void)
            dstrct();
            break;
        case SAVE:                      // Save Game
            dstrct();
            break;
        case SAVE:                      // Save Game
-           freeze(FALSE);
+           freeze(false);
            clrscr();
            if (game.skill > SKILL_GOOD)
                prout("WARNING--Saved games produce no plaques!");
            break;
        case DEATHRAY:                  // Try a desparation measure
            deathray();
            clrscr();
            if (game.skill > SKILL_GOOD)
                prout("WARNING--Saved games produce no plaques!");
            break;
        case DEATHRAY:                  // Try a desparation measure
            deathray();
-           if (game.ididit) hitme = TRUE;
+           if (game.ididit) hitme = true;
            break;
        case DEBUGCMD:                  // What do we want for debug???
 #ifdef DEBUG
            break;
        case DEBUGCMD:                  // What do we want for debug???
 #ifdef DEBUG
@@ -534,7 +535,7 @@ static void makemoves(void)
            break;
        case MAYDAY:                    // Call for help
            mayday();
            break;
        case MAYDAY:                    // Call for help
            mayday();
-           if (game.ididit) hitme = TRUE;
+           if (game.ididit) hitme = true;
            break;
        case QUIT:
            game.alldone = 1;           // quit the game
            break;
        case QUIT:
            game.alldone = 1;           // quit the game
@@ -546,7 +547,7 @@ static void makemoves(void)
            helpme();   // get help
            break;
        }
            helpme();   // get help
            break;
        }
-       commandhook(commands[i].name, FALSE);
+       commandhook(commands[i].name, false);
        for (;;) {
            if (game.alldone) break;            // Game has ended
 #ifdef DEBUG
        for (;;) {
            if (game.alldone) break;            // Game has ended
 #ifdef DEBUG
@@ -565,7 +566,7 @@ static void makemoves(void)
                if (game.alldone) break;
                if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova) {    // went NOVA! 
                    atover(0);
                if (game.alldone) break;
                if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova) {    // went NOVA! 
                    atover(0);
-                   hitme = TRUE;
+                   hitme = true;
                    continue;
                }
            }
                    continue;
                }
            }
@@ -606,7 +607,7 @@ int main(int argc, char **argv)
        strcat(line, argv[i]);
        strcat(line, " ");
     }
        strcat(line, argv[i]);
        strcat(line, " ");
     }
-    while (TRUE) { /* Play a game */
+    for(;;) { /* Play a game */
        setwnd(fullscreen_window);
 #ifdef DEBUG
        prout("INITIAL OPTIONS: %0lx", game.options);
        setwnd(fullscreen_window);
 #ifdef DEBUG
        prout("INITIAL OPTIONS: %0lx", game.options);
@@ -627,7 +628,7 @@ int main(int argc, char **argv)
            proutn("Do you want your score recorded?");
            if (ja()) {
                chew2();
            proutn("Do you want your score recorded?");
            if (ja()) {
                chew2();
-               freeze(FALSE);
+               freeze(false);
            }
        }
        proutn("Do you want to play again? ");
            }
        }
        proutn("Do you want to play again? ");
@@ -779,14 +780,14 @@ int scan(void)
     return IHALPHA;
 }
 
     return IHALPHA;
 }
 
-int ja(void) 
+bool ja(void) 
 {
     chew();
 {
     chew();
-    while (TRUE) {
+    for(;;) {
        scan();
        chew();
        scan();
        chew();
-       if (*citem == 'y') return TRUE;
-       if (*citem == 'n') return FALSE;
+       if (*citem == 'y') return true;
+       if (*citem == 'n') return false;
        proutn("Please answer with \"Y\" or \"N\": ");
     }
 }
        proutn("Please answer with \"Y\" or \"N\": ");
     }
 }
@@ -871,7 +872,7 @@ void debugme(void)
     }
     proutn("Induce supernova here? ");
     if (ja() != 0) {
     }
     proutn("Induce supernova here? ");
     if (ja() != 0) {
-       game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova = TRUE;
+       game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova = true;
        atover(1);
     }
 }
        atover(1);
     }
 }
index 182634d6c2da8b741ebaf6a22fc87bd529aecd7b..c4a7a99e32b8eef6de34bd8538fc3e464628fc28 100644 (file)
--- a/src/sst.h
+++ b/src/sst.h
@@ -7,6 +7,7 @@
 #include <locale.h>
 #include <libintl.h>
 #include <curses.h>
 #include <locale.h>
 #include <libintl.h>
 #include <curses.h>
+#include <stdbool.h>
 
 #ifdef DATA_DIR
 #define SSTDOC DATA_DIR"/"DOC_NAME
 
 #ifdef DATA_DIR
 #define SSTDOC DATA_DIR"/"DOC_NAME
@@ -77,16 +78,16 @@ typedef struct {
     struct quadrant {
        int stars;
        planet *planet;
     struct quadrant {
        int stars;
        planet *planet;
-       int starbase;
+       bool starbase;
        int klingons;
        int romulans;
        int klingons;
        int romulans;
-       int supernova;
-       int charted;
+       bool supernova;
+       bool charted;
 #ifdef EXPERIMENTAL
        enum {secure, distressed, enslaved} status;
 #endif /* EXPERIMENTAL */
     } galaxy[GALSIZE+1][GALSIZE+1];    // The Galaxy (subscript 0 not used)
 #ifdef EXPERIMENTAL
        enum {secure, distressed, enslaved} status;
 #endif /* EXPERIMENTAL */
     } galaxy[GALSIZE+1][GALSIZE+1];    // The Galaxy (subscript 0 not used)
-    struct {
+    struct page {
        int stars;
        int starbase;
        int klingons;
        int stars;
        int starbase;
        int klingons;
@@ -201,6 +202,16 @@ struct game {
     coord battle;              // base coordinates being attacked
     coord plnet;               // location of planet in quadrant
     coord probec;      // current probe quadrant
     coord battle;              // base coordinates being attacked
     coord plnet;               // location of planet in quadrant
     coord probec;      // current probe quadrant
+    bool gamewon,      // Finished!
+       ididit,         // Action taken -- allows enemy to attack
+       alive,          // We are alive (not killed)
+       justin,         // just entered quadrant
+       alldone,        // game is now finished
+       neutz,          // Romulan Neutral Zone
+       isatb,          // =1 if super commander is attacking base
+       isarmed,        // probe is armed
+       thawed,         // thawed game
+       iscate;         // super commander is here
     int inkling,       // Initial number of klingons
        inbase,         // Initial number of bases
        incom,          // Initial number of commanders
     int inkling,       // Initial number of klingons
        inbase,         // Initial number of bases
        incom,          // Initial number of commanders
@@ -218,11 +229,6 @@ struct game {
        casual,         // causalties
        nhelp,          // calls for help
        nkinks,         // count of energy-barrier crossings
        casual,         // causalties
        nhelp,          // calls for help
        nkinks,         // count of energy-barrier crossings
-       ididit,         // Action taken -- allows enemy to attack
-       gamewon,        // Finished!
-       alive,          // We are alive (not killed)
-       justin,         // just entered quadrant
-       alldone,        // game is now finished
        shldchg,        // shield is changing (affects efficiency)
        inorbit,        // orbiting
        landed,         // party on planet (1), on ship (-1)
        shldchg,        // shield is changing (affects efficiency)
        inorbit,        // orbiting
        landed,         // party on planet (1), on ship (-1)
@@ -231,27 +237,22 @@ struct game {
        inplan,         // initial planets
        nenhere,        // number of enemies in quadrant
        ishere,         // super-commander in quandrant
        inplan,         // initial planets
        nenhere,        // number of enemies in quadrant
        ishere,         // super-commander in quandrant
-       neutz,          // Romulan Neutral Zone
        irhere,         // Romulans in quadrant
        icraft,         // Kirk in Galileo
        ientesc,        // attempted escape from supercommander
        iscraft,        // =1 if craft on ship, -1 if removed from game
        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
 #ifdef DEBUG
        idebug,         // debug mode
 #endif
        iattak,         // attack recursion elimination (was cracks[4])
        icrystl,        // dilithium crystals aboard
        tourn,          // tournament number
 #ifdef DEBUG
        idebug,         // debug mode
 #endif
        iattak,         // attack recursion elimination (was cracks[4])
        icrystl,        // dilithium crystals aboard
        tourn,          // tournament number
-       thawed,         // thawed game
        ithere,         // Tholian is here 
        iseenit,        // seen base attack report
 #ifdef EXPERIMENTAL
        ndistr,         //* count of distress calls */ 
 #endif /* EXPERIMENTAL */
        proben,         // number of moves for probe
        ithere,         // Tholian is here 
        iseenit,        // seen base attack report
 #ifdef EXPERIMENTAL
        ndistr,         //* count of distress calls */ 
 #endif /* EXPERIMENTAL */
        proben,         // number of moves for probe
-       isarmed,        // probe is armed
        nprobes;        // number of probes available
     double inresor,    // initial resources
        intime,         // initial time
        nprobes;        // number of probes available
     double inresor,    // initial resources
        intime,         // initial time
@@ -299,11 +300,6 @@ typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
                          FHOLE} FINTYPE ;
 enum loctype {neither, quadrant, sector};
 
                          FHOLE} FINTYPE ;
 enum loctype {neither, quadrant, sector};
 
-#ifndef TRUE
-#define TRUE (1)
-#define FALSE (0)
-#endif
-
 #define IHR 'R'
 #define IHK 'K'
 #define IHC 'C'
 #define IHR 'R'
 #define IHK 'K'
 #define IHC 'C'
@@ -332,7 +328,7 @@ enum loctype {neither, quadrant, sector};
 /* Function prototypes */
 void prelim(void);
 void attack(int);
 /* Function prototypes */
 void prelim(void);
 void attack(int);
-int choose(int);
+bool choose(bool);
 void setup(int);
 void score(void);
 void atover(int);
 void setup(int);
 void score(void);
 void atover(int);
@@ -357,7 +353,7 @@ void abandn(void);
 void finish(FINTYPE);
 void dstrct(void);
 void kaboom(void);
 void finish(FINTYPE);
 void dstrct(void);
 void kaboom(void);
-void freeze(int);
+void freeze(bool);
 int thaw(void);
 void plaque(void);
 int scan(void);
 int thaw(void);
 void plaque(void);
 int scan(void);
@@ -371,7 +367,7 @@ void prout(char *, ...);
 void proutn(char *, ...);
 void stars(void);
 void newqad(int);
 void proutn(char *, ...);
 void stars(void);
 void newqad(int);
-int ja(void);
+bool ja(void);
 void cramen(int);
 void crmshp(void);
 char *cramlc(enum loctype, coord w);
 void cramen(int);
 void crmshp(void);
 char *cramlc(enum loctype, coord w);
@@ -385,7 +381,7 @@ void sortkl(void);
 void imove(void);
 void ram(int, int, coord);
 void crmena(int, int, int, coord w);
 void imove(void);
 void ram(int, int, coord);
 void crmena(int, int, int, coord w);
-void deadkl(int, int, int, int, int);
+void deadkl(coord, int, int, int);
 void timwrp(void);
 void movcom(void);
 void torpedo(double, double, int, int, double *, int, int);
 void timwrp(void);
 void movcom(void);
 void torpedo(double, double, int, int, double *, int, int);
@@ -418,7 +414,7 @@ void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad);
 void cgetline(char *, int);
 void waitfor(void);
 void setpassword(void);
 void cgetline(char *, int);
 void waitfor(void);
 void setpassword(void);
-void commandhook(char *, int);
+void commandhook(char *, bool);
 void makechart(void);
 void enqueue(char *);
 char *systemname(planet *);
 void makechart(void);
 void enqueue(char *);
 char *systemname(planet *);