More type cleanup and explanatory comments.
authorEric S. Raymond <esr@thyrsus.com>
Tue, 19 Sep 2006 21:30:15 +0000 (21:30 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 19 Sep 2006 21:30:15 +0000 (21:30 +0000)
src/finish.c
src/moving.c
src/planets.c
src/reports.c
src/setup.c
src/sst.c
src/sst.h

index 75425fbf8bbb6f902cb029ef3bb786bc9eb10760..570be4e9a94b2023f2e41881b651e170f4e65a29 100644 (file)
@@ -2,7 +2,8 @@
 #include <string.h>
 #include <time.h>
 
 #include <string.h>
 #include <time.h>
 
-void dstrct() 
+void selfdestruct(void)
+/* self-destruct maneuver */
 {
     /* Finish with a BANG! */
     chew();
 {
     /* Finish with a BANG! */
     chew();
@@ -69,7 +70,8 @@ void kaboom(void)
 }
                                
 
 }
                                
 
-void finish(FINTYPE ifin) 
+void finish(FINTYPE ifin)
+/* end the game, with appropriate notfications */
 {
     bool igotit = false;
     game.alldone = true;
 {
     bool igotit = false;
     game.alldone = true;
@@ -313,6 +315,7 @@ void finish(FINTYPE ifin)
 }
 
 void score(void) 
 }
 
 void score(void) 
+/* compute player's score */
 {
     double timused = game.state.date - game.indate;
     int ithperd, iwon, klship;
 {
     double timused = game.state.date - game.indate;
     int ithperd, iwon, klship;
@@ -392,7 +395,9 @@ void score(void)
     prout(_("TOTAL SCORE                               %5d"), iscore);
 }
 
     prout(_("TOTAL SCORE                               %5d"), iscore);
 }
 
-void plaque(void) {
+void plaque(void)
+/* emit winner's commemmorative plaque */
+{
        FILE *fp=NULL;
        time_t t;
        char *timestring;
        FILE *fp=NULL;
        time_t t;
        char *timestring;
index 91c74c4a69eabf7f1d7181caa0658bd2c3a246a7..222f86fea524ea19c05318b98685fbbe54583d67 100644 (file)
@@ -711,7 +711,7 @@ void atover(bool igrab)
        }
        prout(_("SUCCEEDS!"));
        if (game.imine) {
        }
        prout(_("SUCCEEDS!"));
        if (game.imine) {
-           game.imine = 0;
+           game.imine = false;
            proutn(_("The crystals mined were "));
            if (Rand() <= 0.25) {
                prout(_("lost."));
            proutn(_("The crystals mined were "));
            if (Rand() <= 0.25) {
                prout(_("lost."));
index c7fb44008db7a586d625498d87fc16ca4cba2f93..2eed37c0846c5282d98a794d93ec554c0960821d 100644 (file)
@@ -2,30 +2,18 @@
 
 static char *classes[] = {"M","N","O"};
 
 
 static char *classes[] = {"M","N","O"};
 
-static int consumeTime(void) 
+static bool consumeTime(void)
+/* abort a lengthy operation if an event interrupts it */
 {
 {
-/* I think most of this avoidance was caused by overlay scheme.
-   Let's see what happens if all events can occur here */
-
-//  double asave;
-    game.ididit = 1;
-#if 0
-    /* Don't worry about this */
-    if (scheduled(FTBEAM) <= game.state.date+game.optime && game.state.remcom != 0 && game.condit != IHDOCKED) {
-       /* We are about to be tractor beamed -- operation fails */
-       return 1;
-    }
-#endif
-//     asave = scheduled(FSNOVA);
-//     unschedule(FSNOVA); /* defer supernovas */
-    events();  /* Used to avoid if FSCMOVE is scheduled within time */
-//     schedule(FSNOVA, asave-game.state.time);
-    /*fails if game over, quadrant super-novas or we've moved to new quadrant*/
-    if (game.alldone || game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova || game.justin != 0) return 1;
-    return 0;
+    game.ididit = true;
+    events();
+    if (game.alldone || game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova || game.justin) 
+       return true;
+    return false;
 }
 
 void preport(void) 
 }
 
 void preport(void) 
+/* report on (uninhabited) planets in the galaxy */
 {
     bool iknow = false;
     int i;
 {
     bool iknow = false;
     int i;
@@ -51,10 +39,11 @@ void preport(void)
                prout(_("    Shuttle Craft Galileo on surface."));
        }
     }
                prout(_("    Shuttle Craft Galileo on surface."));
        }
     }
-    if (iknow==0) prout(_("No information available."));
+    if (!iknow) prout(_("No information available."));
 }
 
 }
 
-void orbit(void) 
+void orbit(void)
+/* enter standard orbit */
 {
     skip(1);
     chew();
 {
     skip(1);
     chew();
@@ -82,7 +71,8 @@ void orbit(void)
     game.ididit = true;
 }
 
     game.ididit = true;
 }
 
-void sensor(void) 
+void sensor(void)
+/* examine planets in this quadrant */
 {
     skip(1);
     chew();
 {
     skip(1);
     chew();
@@ -110,6 +100,7 @@ void sensor(void)
 }
 
 void beam(void) 
 }
 
 void beam(void) 
+/* use the transporter */
 {
     chew();
     skip(1);
 {
     chew();
     skip(1);
@@ -171,7 +162,7 @@ void beam(void)
        skip(1);
        prout(_("Kirk-  \"Energize.\""));
     }
        skip(1);
        prout(_("Kirk-  \"Energize.\""));
     }
-    game.ididit=1;
+    game.ididit = true;
     skip(1);
     prouts("WWHOOOIIIIIRRRRREEEE.E.E.  .  .  .  .   .    .");
     skip(2);
     skip(1);
     prouts("WWHOOOIIIIIRRRRREEEE.E.E.  .  .  .  .   .    .");
     skip(2);
@@ -189,15 +180,16 @@ void beam(void)
     if (game.landed==1 && game.state.plnets[game.iplnet].known==shuttle_down) {
        prout(_("The shuttle craft Galileo is here!"));
     }
     if (game.landed==1 && game.state.plnets[game.iplnet].known==shuttle_down) {
        prout(_("The shuttle craft Galileo is here!"));
     }
-    if (game.landed!=1 && game.imine==1) {
+    if (game.landed!=1 && game.imine) {
        game.icrystl = 1;
        game.cryprob = 0.05;
     }
        game.icrystl = 1;
        game.cryprob = 0.05;
     }
-    game.imine = 0;
+    game.imine = false;
     return;
 }
 
 void mine(void) 
     return;
 }
 
 void mine(void) 
+/* strip-mine a world for dilithium */
 {
     skip(1);
     chew();
 {
     skip(1);
     chew();
@@ -213,7 +205,7 @@ void mine(void)
        prout(_("No dilithium crystals on this planet."));
        return;
     }
        prout(_("No dilithium crystals on this planet."));
        return;
     }
-    if (game.imine == 1) {
+    if (game.imine) {
        prout(_("You've already mined enough crystals for this trip."));
        return;
     }
        prout(_("You've already mined enough crystals for this trip."));
        return;
     }
@@ -228,13 +220,13 @@ void mine(void)
     if (consumeTime()) return;
     prout(_("Mining operation complete."));
     game.state.plnets[game.iplnet].crystals = MINED;
     if (consumeTime()) return;
     prout(_("Mining operation complete."));
     game.state.plnets[game.iplnet].crystals = MINED;
-    game.imine = 1;
-    game.ididit=1;
+    game.imine = game.ididit = true;
 }
 
 }
 
-void usecrystals(void) 
+void usecrystals(void)
+/* use dilithium crystals */
 {
 {
-    game.ididit=0;
+    game.ididit = false;
     skip(1);
     chew();
     if (game.icrystl!=1) {
     skip(1);
     chew();
     if (game.icrystl!=1) {
@@ -280,10 +272,11 @@ void usecrystals(void)
     prout(_("   are going crazy, but I think it's"));
     prout(_("   going to work!!  Congratulations, Sir!\""));
     game.cryprob *= 2.0;
     prout(_("   are going crazy, but I think it's"));
     prout(_("   going to work!!  Congratulations, Sir!\""));
     game.cryprob *= 2.0;
-    game.ididit=1;
+    game.ididit = true;
 }
 
 void shuttle(void) 
 }
 
 void shuttle(void) 
+/* use shuttlecraft for planetary jaunt */
 {
     chew();
     skip(1);
 {
     chew();
     skip(1);
@@ -370,11 +363,11 @@ void shuttle(void)
            if (consumeTime()) return;
            game.iscraft = 1;
            game.icraft = 0;
            if (consumeTime()) return;
            game.iscraft = 1;
            game.icraft = 0;
-           if (game.imine!=0) {
+           if (game.imine) {
                game.icrystl = 1;
                game.cryprob = 0.05;
            }
                game.icrystl = 1;
                game.cryprob = 0.05;
            }
-           game.imine = 0;
+           game.imine = false;
            prout(_("Trip complete."));
            return;
        }
            prout(_("Trip complete."));
            return;
        }
@@ -398,11 +391,12 @@ void shuttle(void)
     }
 }
 
     }
 }
 
-void deathray(void) 
+void deathray(void)
+/* use the big zapper */
 {
     double dprob, r = Rand();
        
 {
     double dprob, r = Rand();
        
-    game.ididit = 0;
+    game.ididit = false;
     skip(1);
     chew();
     if (game.ship != IHE) {
     skip(1);
     chew();
     if (game.ship != IHE) {
@@ -423,7 +417,7 @@ void deathray(void)
     if (ja() == false) return;
     prout(_("Spock-  \"Acknowledged.\""));
     skip(1);
     if (ja() == false) return;
     prout(_("Spock-  \"Acknowledged.\""));
     skip(1);
-    game.ididit=1;
+    game.ididit = true;
     prouts(_("WHOOEE ... WHOOEE ... WHOOEE ... WHOOEE"));
     skip(1);
     prout(_("Crew scrambles in emergency preparation."));
     prouts(_("WHOOEE ... WHOOEE ... WHOOEE ... WHOOEE"));
     skip(1);
     prout(_("Crew scrambles in emergency preparation."));
@@ -511,6 +505,7 @@ void deathray(void)
 }
 
 char *systemname(int pindx)
 }
 
 char *systemname(int pindx)
+/* return the name of a given solar system */
 {
     static char copy[BUFSIZ];
     /* the below array should not be static, or it won't gettextize
 {
     static char copy[BUFSIZ];
     /* the below array should not be static, or it won't gettextize
index b36f56c30667e9c253ccc18e596234c92ddfa5d6..d8f31c618c76c52a18250b9550e6aca5e41eda6d 100644 (file)
@@ -3,7 +3,8 @@
 #include <stdlib.h>
 #include <string.h>
 
 #include <stdlib.h>
 #include <string.h>
 
-void attakreport(bool curt) 
+void attakreport(bool curt)
+/* report status of bases under attack */
 {
     if (!curt) {
        if (is_scheduled(FCDBAS)) {
 {
     if (!curt) {
        if (is_scheduled(FCDBAS)) {
@@ -28,7 +29,8 @@ void attakreport(bool curt)
 }
        
 
 }
        
 
-void report(void) 
+void report(void)
+/* report on general game status */
 {
     char *s1,*s2,*s3;
 
 {
     char *s1,*s2,*s3;
 
@@ -114,6 +116,7 @@ void report(void)
 }
        
 void lrscan(void) 
 }
        
 void lrscan(void) 
+/* long-range sensor scan */
 {
     int x, y;
     chew();
 {
     int x, y;
     chew();
@@ -150,6 +153,7 @@ void lrscan(void)
 }
 
 void dreprt(void) 
 }
 
 void dreprt(void) 
+/* damage report */
 {
     bool jdam = false;
     int i;
 {
     bool jdam = false;
     int i;
@@ -185,7 +189,8 @@ void rechart(void)
            }
 }
 
            }
 }
 
-void chart(bool title) 
+void chart(bool title)
+/* display the star chart */ 
 {
     int i,j;
     chew();
 {
     int i,j;
     chew();
@@ -232,6 +237,7 @@ void chart(bool title)
 }
 
 static void sectscan(int goodScan, int i, int j) 
 }
 
 static void sectscan(int goodScan, int i, int j) 
+/* light up an individual dot in a sector */
 {
     if (goodScan || (abs(i-game.sector.x)<= 1 && abs(j-game.sector.y) <= 1)){
        if ((game.quad[i][j]==IHMATER0)||(game.quad[i][j]==IHMATER1)||(game.quad[i][j]==IHMATER2)||(game.quad[i][j]==IHE)||(game.quad[i][j]==IHF)){
 {
     if (goodScan || (abs(i-game.sector.x)<= 1 && abs(j-game.sector.y) <= 1)){
        if ((game.quad[i][j]==IHMATER0)||(game.quad[i][j]==IHMATER1)||(game.quad[i][j]==IHMATER2)||(game.quad[i][j]==IHE)||(game.quad[i][j]==IHF)){
@@ -252,7 +258,8 @@ static void sectscan(int goodScan, int i, int j)
        proutn("- ");
 }
 
        proutn("- ");
 }
 
-static void status(int req) 
+static void status(int req)
+/* print status report lines */
 {
     char *cp = NULL;
     int t, dam = 0;
 {
     char *cp = NULL;
     int t, dam = 0;
@@ -330,7 +337,8 @@ static void status(int req)
     }
 }
                
     }
 }
                
-int srscan(int l) 
+int srscan(int l)
+/* short-range scan */
 {
     /* the "sy" request is undocumented */
     static char requests[][3] =
 {
     /* the "sy" request is undocumented */
     static char requests[][3] =
@@ -406,6 +414,7 @@ int srscan(int l)
                        
                        
 void eta(void)
                        
                        
 void eta(void)
+/* use computer to get estimated time of arrival for a warp jump */
 {
     int ix1, ix2, iy1, iy2;
     bool wfl, prompt = false;
 {
     int ix1, ix2, iy1, iy2;
     bool wfl, prompt = false;
index 3eba6fe3dd8e3691edbd8d78f24a8af095a8a9da..600afc43dbfb102494c113bb35469bc16249bf55 100644 (file)
@@ -208,7 +208,7 @@ void abandn(void)
     prout("the Faerie Queene, which is antiquated but,");
     prout("still useable.");
     if (game.icrystl!=0) prout("The dilithium crystals have been moved.");
     prout("the Faerie Queene, which is antiquated but,");
     prout("still useable.");
     if (game.icrystl!=0) prout("The dilithium crystals have been moved.");
-    game.imine=0;
+    game.imine = false;
     game.iscraft=0; /* Galileo disappears */
     /* Resupply ship */
     game.condit=IHDOCKED;
     game.iscraft=0; /* Galileo disappears */
     /* Resupply ship */
     game.condit=IHDOCKED;
@@ -253,8 +253,8 @@ 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.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 = false;
-    game.isatb = game.iscate = game.imine = game.icrystl = game.icraft = game.state.nplankl = 0;
+    game.resting = game.imine = false;
+    game.isatb = game.iscate = 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;
index 9d5a20c1d6cf6a7a3f56718022a38611c6777cf6..850a940096efc21980d0cf5a4ba4e3e988f9543d 100644 (file)
--- a/src/sst.c
+++ b/src/sst.c
@@ -531,7 +531,7 @@ static void makemoves(void)
            abandn();
            break;
        case DESTRUCT:                  // Self Destruct
            abandn();
            break;
        case DESTRUCT:                  // Self Destruct
-           dstrct();
+           selfdestruct();
            break;
        case SAVE:                      // Save Game
            freeze(false);
            break;
        case SAVE:                      // Save Game
            freeze(false);
index 8616c416f1ad2777e1e28a788970bddd05e93912..7f66a3e831dcdf44dfa3e0172eabdf287087bf95 100644 (file)
--- a/src/sst.h
+++ b/src/sst.h
@@ -215,6 +215,7 @@ struct game {
        neutz,          // Romulan Neutral Zone
        isarmed,        // probe is armed
        inorbit,        // orbiting a planet
        neutz,          // Romulan Neutral Zone
        isarmed,        // probe is armed
        inorbit,        // orbiting a planet
+       imine,          // mining
        thawed;         // thawed game
     int inkling,       // initial number of klingons
        inbase,         // initial number of bases
        thawed;         // thawed game
     int inkling,       // initial number of klingons
        inbase,         // initial number of bases
@@ -237,7 +238,6 @@ struct game {
        shldchg,        // shield is changing (affects efficiency)
        landed,         // party on planet (1), on ship (-1)
        iplnet,         // planet # in quadrant
        shldchg,        // shield is changing (affects efficiency)
        landed,         // party on planet (1), on ship (-1)
        iplnet,         // planet # in quadrant
-       imine,          // mining
        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
@@ -352,7 +352,7 @@ void eta(void);
 void mayday(void);
 void abandn(void);
 void finish(FINTYPE);
 void mayday(void);
 void abandn(void);
 void finish(FINTYPE);
-void dstrct(void);
+void selfdestruct(void);
 void kaboom(void);
 void freeze(bool);
 int thaw(void);
 void kaboom(void);
 void freeze(bool);
 int thaw(void);