Chase more booleans and enums.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 20 Sep 2006 15:47:19 +0000 (15:47 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 20 Sep 2006 15:47:19 +0000 (15:47 +0000)
src/ai.c
src/battle.c
src/events.c
src/finish.c
src/moving.c
src/planets.c
src/setup.c
src/sst.c
src/sst.h

index 7adbfdf060ed4aac060fde3a45aa1af2f7dcd85f..b4b35b9ed93f8be79999b3d72b0d786d7232972b 100644 (file)
--- a/src/ai.c
+++ b/src/ai.c
@@ -46,7 +46,7 @@ static bool tryexit(coord look, int ienm, int loccom, bool irun)
     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);
@@ -310,7 +310,7 @@ static bool movescom(coord iq, bool flag, bool *ipage)
     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;
@@ -335,8 +335,8 @@ static bool movescom(coord iq, bool flag, bool *ipage)
            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));
@@ -363,7 +363,7 @@ void scom(bool *ipage)
     /* 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;
@@ -387,9 +387,9 @@ void scom(bool *ipage)
        }
        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];
@@ -398,7 +398,7 @@ void scom(bool *ipage)
                        bdist[i+1] = t;
                        basetbl[i] = basetbl[i+1];
                        basetbl[i+1] =ti;
-                       iswitch = 1;
+                       iswitch = true;
                    }
                }
            } while (iswitch);
@@ -417,7 +417,7 @@ void scom(bool *ipage)
            /* 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;
@@ -490,8 +490,8 @@ void scom(bool *ipage)
            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);
@@ -513,8 +513,8 @@ void scom(bool *ipage)
         (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));
index b36f86ac05f8859c1b5bde63575b8d36e0c0bbfa..f47cd94874800f9deea528219d798438acd38b44 100644 (file)
@@ -62,7 +62,7 @@ void doshield(bool raise)
            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) {
@@ -79,7 +79,7 @@ void doshield(bool raise)
            return;
        }
        game.shldup=false;
-       game.shldchg=1;
+       game.shldchg=true;
        prout(_("Shields lowered."));
        game.ididit = true;
        return;
@@ -289,7 +289,8 @@ void torpedo(double course, double r, coord in, double *hit, int i, int n)
            *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));
@@ -388,7 +389,7 @@ void torpedo(double course, double r, coord in, double *hit, int i, int n)
            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);
            }
@@ -402,7 +403,7 @@ void torpedo(double course, double r, coord in, double *hit, int i, int n)
            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);
            }
@@ -513,7 +514,7 @@ static void fry(double hit)
            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;
@@ -556,7 +557,7 @@ void attack(bool torps_ok)
     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) {
@@ -601,7 +602,7 @@ void attack(bool torps_ok)
                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;
@@ -724,7 +725,8 @@ void deadkl(coord w, feature type, coord mv)
        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;
@@ -1195,7 +1197,7 @@ void phasers(void)
                key = scan();
            }
            if (key == IHALPHA && isit("no")) {
-               no = 1;
+               no = true;
                key = scan();
                continue;
            }
index f7831a6870e10fccec2ec58e9c29ff44dcd55d71..1c5ec94dbce929ff21b98cf04da42cd3315851a8 100644 (file)
@@ -162,7 +162,7 @@ void events(void)
        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)) ||
@@ -195,7 +195,7 @@ void events(void)
            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();
@@ -208,13 +208,13 @@ void events(void)
                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."));
@@ -237,7 +237,7 @@ void events(void)
            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.)"));
            }
@@ -250,7 +250,7 @@ void events(void)
            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 */
@@ -365,7 +365,7 @@ void events(void)
        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 */
@@ -381,8 +381,8 @@ void events(void)
                    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))
@@ -395,8 +395,8 @@ void events(void)
                    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));
@@ -677,7 +677,7 @@ void nova(coord nov)
                        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;
                        }
@@ -866,7 +866,8 @@ void snova(bool induced, coord *w)
     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);
     }
index 95c7d974a22a52a6f2ab538e108ed3b4c926c6b4..d39257422299a0ba4aa61eb6bb4d4291753537df 100644 (file)
@@ -101,6 +101,8 @@ void finish(FINTYPE ifin)
                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;
@@ -167,7 +169,7 @@ void finish(FINTYPE ifin)
        else {
            prout(_("found guilty and"));
            prout(_("sentenced to death by slow torture."));
-           game.alive = 0;
+           game.alive = false;
        }
        score();
        return;
@@ -286,7 +288,7 @@ void finish(FINTYPE ifin)
     }
     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);
@@ -309,7 +311,7 @@ void finish(FINTYPE ifin)
        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();
 }
@@ -329,11 +331,11 @@ void score(void)
     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)
@@ -378,11 +380,12 @@ void score(void)
     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;
index cb6e197b51e5c5625693382f65f9fd830767e42f..60ff4c3070c1e79a8ce4750c5625bf1c3271a9b7 100644 (file)
@@ -268,7 +268,7 @@ static void getcd(bool isprobe, int akey)
 
     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();
@@ -685,7 +685,7 @@ void atover(bool igrab)
 
     chew();
     /* is captain on planet? */
-    if (game.landed==1) {
+    if (game.landed) {
        if (damaged(DTRANSP)) {
            finish(FPNOVA);
            return;
@@ -783,7 +783,7 @@ void timwrp()
        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));
@@ -804,17 +804,17 @@ void timwrp()
        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,
@@ -948,7 +948,7 @@ void mayday(void)
        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(".");
@@ -1022,7 +1022,7 @@ void mayday(void)
     }
     if (m > 3) {
        game.quad[ix][iy]=IHQUEST;
-       game.alive = 0;
+       game.alive = false;
        drawmaps(1);
        setwnd(message_window);
        finish(FMATERIALIZE);
index 1589a86720997cdc37473358cc3619aaa6278665..ca8c890c6256a92e43df6d428ddb10271bf0d085 100644 (file)
@@ -106,7 +106,7 @@ void beam(void)
     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();
@@ -128,7 +128,7 @@ void beam(void)
        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?\" "));
@@ -176,11 +176,11 @@ void beam(void)
     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;
     }
@@ -193,7 +193,7 @@ void mine(void)
 {
     skip(1);
     chew();
-    if (game.landed!= 1) {
+    if (!game.landed) {
        prout(_("Mining party not on planet."));
        return;
     }
@@ -298,11 +298,11 @@ void shuttle(void)
        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;
     }
@@ -328,9 +328,9 @@ void shuttle(void)
            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?\" "));
@@ -343,7 +343,7 @@ void shuttle(void)
            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;
@@ -359,9 +359,9 @@ void shuttle(void)
            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;
@@ -381,10 +381,10 @@ void shuttle(void)
        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;
index 0f96a5c1a7e3caf650d87f82b70d80a4aca479d2..49ddf1af9b76ad9257d37e3f320c1dfc3ec74601 100644 (file)
@@ -141,11 +141,11 @@ void abandn(void)
            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;
        }
@@ -211,7 +211,7 @@ void abandn(void)
     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++) 
@@ -240,7 +240,7 @@ void setup(bool needprompt)
     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;
@@ -256,12 +256,12 @@ void setup(bool 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.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) {
@@ -270,8 +270,8 @@ void setup(bool needprompt)
            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
@@ -326,8 +326,8 @@ void setup(bool needprompt)
        } 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;
@@ -405,13 +405,11 @@ void setup(bool needprompt)
     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",
@@ -615,7 +613,7 @@ void newqad(bool shutup)
     game.nenhere = 0;
     game.neutz = false;
     game.inorbit = false;
-    game.landed = -1;
+    game.landed = false;
     game.ientesc = false;
     game.ithere = false;
     iqhere = false;
@@ -623,7 +621,7 @@ void newqad(bool shutup)
     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
@@ -661,7 +659,7 @@ void newqad(bool shutup)
        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;
        }
     }
@@ -709,7 +707,7 @@ void newqad(bool shutup)
            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);
index 62ffe2547293718d4abf7dfdd80c7aa0d822c98e..d19698491d71a64611cf7b7a0fd6a99591a9d6cd 100644 (file)
--- a/src/sst.c
+++ b/src/sst.c
@@ -468,8 +468,8 @@ static void makemoves(void)
        case SHIELDS:                   // shields
            doshield(false);
            if (game.ididit) {
-               hitme=true;
-               game.shldchg = 0;
+               hitme = true;
+               game.shldchg = false;
            }
            break;
        case DOCK:                      // dock
index 4063c4e86765474e2a0c2109028ce0be92891c7a..344ddcb6bfe8560faf03f8e3c0216ef8c621960f 100644 (file)
--- a/src/sst.h
+++ b/src/sst.h
@@ -80,8 +80,8 @@ typedef enum {
 } 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
@@ -112,7 +112,7 @@ typedef struct {
     } 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
@@ -128,13 +128,6 @@ typedef struct {
 #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 */
@@ -234,12 +227,15 @@ struct game {
        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
@@ -255,31 +251,39 @@ struct game {
        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