Get rid of another magic number.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 12 Feb 2005 04:13:42 +0000 (04:13 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 12 Feb 2005 04:13:42 +0000 (04:13 +0000)
events.c
moving.c
reports.c
setup.c
sst.c
sst.h

index a9da410909b97badf86f593851c40f6b83049509..2935404971853361eb375ce2f3c12a16b31673d2 100644 (file)
--- 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;
            }
        }
index f44aff4c2bd98f98ac10409bfd9b1a9f8e2d9464..31374c2ebd4bdd82c85e6ebfc9617b2e7736d07e 100644 (file)
--- 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) {
index f670a1ec38825eb0ece66f5c5717c9509f1acdb3..29bcba5d061c865e26a101e210a4bb473b3b3eea 100644 (file)
--- 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 fb03bde96be24a742fe96852a8b7d53b536c8560..496341375e552e9f09dd6a8351d8bcbfa1e3184f 100644 (file)
--- 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 3d394c67b4da2097edf5f027d119589227e3c5e3..87595a694e8c7670e7e6a82203cec54e10f66abe 100644 (file)
--- 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 83db771a6eabdf55833569b55e7e5ef8010141ce..f514d5cb0541d2ad4a2920b7027713123863d7dc 100644 (file)
--- 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