From 1e2622cf770b7183b813e0dc0095f085dda4419f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 12 Feb 2005 04:13:42 +0000 Subject: [PATCH] Get rid of another magic number. --- events.c | 22 +++++++++++----------- moving.c | 10 +++++----- reports.c | 10 +++++----- setup.c | 12 ++++++------ sst.c | 7 ++++--- sst.h | 2 ++ 6 files changed, 33 insertions(+), 30 deletions(-) diff --git a/events.c b/events.c index a9da410..2935404 100644 --- a/events.c +++ b/events.c @@ -50,7 +50,7 @@ void events(void) game.damage[l] -= (game.damage[l]-repair > 0.0 ? repair : game.damage[l]); /* If radio repaired, update star chart and attack reports */ if (radio_was_broken && game.damage[DRADIO] == 0.0) { - stdamtim = 1e30; + stdamtim = FOREVER; prout("Lt. Uhura- \"Captain, the sub-space radio is working and"); prout(" surveillance reports are coming in."); skip(1); @@ -91,7 +91,7 @@ void events(void) case FTBEAM: /* Tractor beam */ if (line==FTBEAM) { if (game.state.remcom == 0) { - game.future[FTBEAM] = 1e30; + game.future[FTBEAM] = FOREVER; break; } i = Rand()*game.state.remcom+1.0; @@ -162,7 +162,7 @@ void events(void) /* Adjust finish time to time of tractor beaming */ fintim = game.state.date+Time; attack(0); - if (game.state.remcom <= 0) game.future[FTBEAM] = 1e30; + if (game.state.remcom <= 0) game.future[FTBEAM] = FOREVER; else game.future[FTBEAM] = game.state.date+Time+expran(1.5*intime/game.state.remcom); break; case FSNAP: /* Snapshot of the universe (for time warp) */ @@ -173,7 +173,7 @@ void events(void) case FBATTAK: /* Commander attacks starbase */ if (game.state.remcom==0 || game.state.rembase==0) { /* no can do */ - game.future[FBATTAK] = game.future[FCDBAS] = 1e30; + game.future[FBATTAK] = game.future[FCDBAS] = FOREVER; break; } i = 0; @@ -190,7 +190,7 @@ void events(void) if (j>game.state.rembase) { /* no match found -- try later */ game.future[FBATTAK] = game.state.date + expran(0.3*intime); - game.future[FCDBAS] = 1e30; + game.future[FCDBAS] = FOREVER; break; } /* commander + starbase combination found -- launch attack */ @@ -224,7 +224,7 @@ void events(void) } break; case FSCDBAS: /* Supercommander destroys base */ - game.future[FSCDBAS] = 1e30; + game.future[FSCDBAS] = FOREVER; isatb = 2; if (!game.state.galaxy[game.state.isx][game.state.isy].starbase) break; /* WAS RETURN! */ @@ -234,7 +234,7 @@ void events(void) baty = game.state.isy; case FCDBAS: /* Commander succeeds in destroying base */ if (line==FCDBAS) { - game.future[FCDBAS] = 1e30; + game.future[FCDBAS] = FOREVER; /* find the lucky pair */ for_commanders(i) if (game.state.cx[i]==batx && game.state.cy[i]==baty) @@ -318,7 +318,7 @@ void events(void) proutn("is no longer transmitting"); prout(".\""); } - game.future[FDSPROB] = 1e30; + game.future[FDSPROB] = FOREVER; break; } if (game.damage[DRADIO]==0.0 || condit == IHDOCKED) { @@ -343,7 +343,7 @@ void events(void) game.state.galaxy[probecx][probecy].stars) { /* lets blow the sucker! */ snova(1,0); - game.future[FDSPROB] = 1e30; + game.future[FDSPROB] = FOREVER; if (game.state.galaxy[quadx][quady].supernova) return; } @@ -686,7 +686,7 @@ void snova(int insx, int insy) /* did in the Supercommander! */ game.state.nscrem = game.state.isx = game.state.isy = isatb = iscate = 0; iscdead = 1; - game.future[FSCMOVE] = game.future[FSCDBAS] = 1e30; + game.future[FSCMOVE] = game.future[FSCDBAS] = FOREVER; } game.state.remkl -= kldead; if (game.state.remcom) { @@ -699,7 +699,7 @@ void snova(int insx, int insy) game.state.remcom--; kldead--; comdead++; - if (game.state.remcom==0) game.future[FTBEAM] = 1e30; + if (game.state.remcom==0) game.future[FTBEAM] = FOREVER; break; } } diff --git a/moving.c b/moving.c index f44aff4..31374c2 100644 --- a/moving.c +++ b/moving.c @@ -233,8 +233,8 @@ void dock(int l) shield = inshld; torps = intorps; lsupres = inlsr; - if (stdamtim != 1e30 && - (game.future[FCDBAS] < 1e30 || isatb == 1) && iseenit == 0) { + if (stdamtim != FOREVER && + (game.future[FCDBAS] < FOREVER || isatb == 1) && iseenit == 0) { /* get attack report from base */ prout("Lt. Uhura- \"Captain, an important message from the starbase:\""); attakreport(0); @@ -783,7 +783,7 @@ void timwrp() be sooner */ if (game.state.nscrem) game.future[FSCMOVE] = 0.2777; isatb = 0; - game.future[FCDBAS] = game.future[FSCDBAS] = 1e30; + game.future[FCDBAS] = game.future[FSCDBAS] = FOREVER; batx = baty = 0; /* Make sure Galileo is consistant -- Snapshot may have been taken @@ -842,7 +842,7 @@ void probe(void) prout("Engineer Scott- \"The probe launcher is damaged, Sir.\""); return; } - if (game.future[FDSPROB] != 1e30) { + if (game.future[FDSPROB] != FOREVER) { chew(); skip(1); if (game.damage[DRADIO] != 0 && condit != IHDOCKED) { @@ -928,7 +928,7 @@ void help(void) ddist = sqrt(square(basex-sectx)+square(basey-secty)); } else { - ddist = 1e30; + ddist = FOREVER; for_starbases(l) { xdist=10.0*sqrt(square(game.state.baseqx[l]-quadx)+square(game.state.baseqy[l]-quady)); if (xdist < ddist) { diff --git a/reports.c b/reports.c index f670a1e..29bcba5 100644 --- a/reports.c +++ b/reports.c @@ -6,7 +6,7 @@ void attakreport(int curt) { if (!curt) { - if (game.future[FCDBAS] < 1e30) { + if (game.future[FCDBAS] < FOREVER) { prout("Starbase in %s is currently under Commander attack.", cramlc(quadrant, batx, baty)); prout("It can hold out until Stardate %d.", @@ -19,7 +19,7 @@ void attakreport(int curt) (int)game.future[FSCDBAS]); } } else { - if (game.future[FCDBAS] < 1e30) + if (game.future[FCDBAS] < FOREVER) proutn("Base in %i - %i attacked by C. Alive until %.1f", batx, baty, game.future[FCDBAS]); if (isatb == 1) proutn("Base in %i - %i attacked by S. Alive until %.1f", game.state.isx, game.state.isy, game.future[FSCDBAS]); @@ -89,7 +89,7 @@ void report(void) prout("."); } if ((game.damage[DRADIO] == 0.0 || condit == IHDOCKED)&& - game.future[FDSPROB] != 1e30) { + game.future[FDSPROB] != FOREVER) { if (isarmed) proutn("An armed deep space probe is in"); else @@ -190,11 +190,11 @@ void chart(int nn) int i,j; char *cp; chew(); - if (stdamtim != 1e30 && stdamtim != game.state.date && condit == IHDOCKED) { + if (stdamtim != FOREVER && stdamtim != game.state.date && condit == IHDOCKED) { proutn("Spock- \"I revised the Star Chart from the starbase's records.\"\n\r"); } if (nn == 0) proutn(" STAR CHART FOR THE KNOWN GALAXY\n\r"); - if (stdamtim != 1e30) { + if (stdamtim != FOREVER) { if (condit == IHDOCKED) { /* We are docked, so restore chart from base information */ rechart(); diff --git a/setup.c b/setup.c index fb03bde..4963413 100644 --- a/setup.c +++ b/setup.c @@ -237,12 +237,12 @@ void setup(int needprompt) game.future[FTBEAM] = game.state.date + expran(1.5 * (intime / game.state.remcom)); game.future[FSNAP] = game.state.date + 1.0 + Rand(); // Force an early snapshot game.future[FBATTAK] = game.state.date + expran(0.3*intime); - game.future[FCDBAS] = 1e30; - game.future[FSCMOVE] = game.state.nscrem ? game.state.date+0.2777 : 1e30; - game.future[FSCDBAS] = 1e30; - game.future[FDSPROB] = 1e30; - // Starchart is functional - stdamtim = 1e30; + game.future[FCDBAS] = FOREVER; + game.future[FSCMOVE] = game.state.nscrem ? game.state.date+0.2777 : FOREVER; + game.future[FSCDBAS] = FOREVER; + game.future[FDSPROB] = FOREVER; + // Starchart is functional but we've never seen it + stdamtim = FOREVER; // Put stars in the galaxy instar = 0; for_quadrants(i) diff --git a/sst.c b/sst.c index 3d394c6..87595a6 100644 --- a/sst.c +++ b/sst.c @@ -751,7 +751,7 @@ void debugme(void) for (i=0; i < NDEVICES; i++) if (game.damage[i] > 0.0) game.damage[i] = 0.0; - stdamtim = 1e30; + stdamtim = FOREVER; } proutn("Toggle idebug? "); if (ja() != 0) { @@ -770,7 +770,8 @@ void debugme(void) key = scan(); if (key == IHALPHA && isit("y")) { game.damage[i] = 10.0; - if (i == DRADIO) stdamtim = game.state.date; + if (i == DRADIO) + stdamtim = game.state.date; } } } @@ -779,7 +780,7 @@ void debugme(void) int i; for (i = 1; i < NEVENTS; i++) { int key; - if (game.future[i] == 1e30) continue; + if (game.future[i] == FOREVER) continue; switch (i) { case FSNOVA: proutn("Supernova "); break; case FTBEAM: proutn("T Beam "); break; diff --git a/sst.h b/sst.h index 83db771..f514d5c 100644 --- a/sst.h +++ b/sst.h @@ -115,6 +115,8 @@ typedef struct { #define DDSP 14 // Added deep space probe #define NDEVICES (15) // Number of devices +#define FOREVER 1e30 + /* Define future events */ #define FSPY 0 // Spy event happens always (no future[] entry) // can cause SC to tractor beam Enterprise -- 2.31.1