From: Eric S. Raymond Date: Tue, 19 Sep 2006 21:30:15 +0000 (+0000) Subject: More type cleanup and explanatory comments. X-Git-Tag: 2.0~226 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=0e9bdbb882f74cad6af644e3e1b530f9ffbf5e8d;p=super-star-trek.git More type cleanup and explanatory comments. --- diff --git a/src/finish.c b/src/finish.c index 75425fb..570be4e 100644 --- a/src/finish.c +++ b/src/finish.c @@ -2,7 +2,8 @@ #include #include -void dstrct() +void selfdestruct(void) +/* self-destruct maneuver */ { /* 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; @@ -313,6 +315,7 @@ void finish(FINTYPE ifin) } void score(void) +/* compute player's score */ { double timused = game.state.date - game.indate; int ithperd, iwon, klship; @@ -392,7 +395,9 @@ void score(void) prout(_("TOTAL SCORE %5d"), iscore); } -void plaque(void) { +void plaque(void) +/* emit winner's commemmorative plaque */ +{ FILE *fp=NULL; time_t t; char *timestring; diff --git a/src/moving.c b/src/moving.c index 91c74c4..222f86f 100644 --- a/src/moving.c +++ b/src/moving.c @@ -711,7 +711,7 @@ void atover(bool igrab) } prout(_("SUCCEEDS!")); if (game.imine) { - game.imine = 0; + game.imine = false; proutn(_("The crystals mined were ")); if (Rand() <= 0.25) { prout(_("lost.")); diff --git a/src/planets.c b/src/planets.c index c7fb440..2eed37c 100644 --- a/src/planets.c +++ b/src/planets.c @@ -2,30 +2,18 @@ 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) +/* report on (uninhabited) planets in the galaxy */ { bool iknow = false; int i; @@ -51,10 +39,11 @@ void preport(void) 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(); @@ -82,7 +71,8 @@ void orbit(void) game.ididit = true; } -void sensor(void) +void sensor(void) +/* examine planets in this quadrant */ { skip(1); chew(); @@ -110,6 +100,7 @@ void sensor(void) } void beam(void) +/* use the transporter */ { chew(); skip(1); @@ -171,7 +162,7 @@ void beam(void) skip(1); prout(_("Kirk- \"Energize.\"")); } - game.ididit=1; + game.ididit = true; 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.imine==1) { + if (game.landed!=1 && game.imine) { game.icrystl = 1; game.cryprob = 0.05; } - game.imine = 0; + game.imine = false; return; } void mine(void) +/* strip-mine a world for dilithium */ { skip(1); chew(); @@ -213,7 +205,7 @@ void mine(void) 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; } @@ -228,13 +220,13 @@ void mine(void) 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) { @@ -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; - game.ididit=1; + game.ididit = true; } void shuttle(void) +/* use shuttlecraft for planetary jaunt */ { chew(); skip(1); @@ -370,11 +363,11 @@ void shuttle(void) if (consumeTime()) return; game.iscraft = 1; game.icraft = 0; - if (game.imine!=0) { + if (game.imine) { game.icrystl = 1; game.cryprob = 0.05; } - game.imine = 0; + game.imine = false; 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(); - game.ididit = 0; + game.ididit = false; skip(1); chew(); if (game.ship != IHE) { @@ -423,7 +417,7 @@ void deathray(void) 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.")); @@ -511,6 +505,7 @@ void deathray(void) } 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 diff --git a/src/reports.c b/src/reports.c index b36f56c..d8f31c6 100644 --- a/src/reports.c +++ b/src/reports.c @@ -3,7 +3,8 @@ #include #include -void attakreport(bool curt) +void attakreport(bool curt) +/* report status of bases under attack */ { 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; @@ -114,6 +116,7 @@ void report(void) } void lrscan(void) +/* long-range sensor scan */ { int x, y; chew(); @@ -150,6 +153,7 @@ void lrscan(void) } void dreprt(void) +/* damage report */ { 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(); @@ -232,6 +237,7 @@ void chart(bool title) } 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)){ @@ -252,7 +258,8 @@ static void sectscan(int goodScan, int i, int j) proutn("- "); } -static void status(int req) +static void status(int req) +/* print status report lines */ { 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] = @@ -406,6 +414,7 @@ int srscan(int l) void eta(void) +/* use computer to get estimated time of arrival for a warp jump */ { int ix1, ix2, iy1, iy2; bool wfl, prompt = false; diff --git a/src/setup.c b/src/setup.c index 3eba6fe..600afc4 100644 --- a/src/setup.c +++ b/src/setup.c @@ -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."); - game.imine=0; + game.imine = false; 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.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; diff --git a/src/sst.c b/src/sst.c index 9d5a20c..850a940 100644 --- a/src/sst.c +++ b/src/sst.c @@ -531,7 +531,7 @@ static void makemoves(void) abandn(); break; case DESTRUCT: // Self Destruct - dstrct(); + selfdestruct(); break; case SAVE: // Save Game freeze(false); diff --git a/src/sst.h b/src/sst.h index 8616c41..7f66a3e 100644 --- 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 + imine, // mining 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 - imine, // mining 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 dstrct(void); +void selfdestruct(void); void kaboom(void); void freeze(bool); int thaw(void);