Simplified the logic for refeshing starcharts.
[super-star-trek.git] / moving.c
index fbbe76f004d1a05503fdf3e894ea032d5e0a49a6..7dee9e5f8089b3f521b8ec54c6751f9b5c679678 100644 (file)
--- a/moving.c
+++ b/moving.c
@@ -48,7 +48,7 @@ void imove(void)
                /* Don't do it if being pushed by Nova */
                if (nenhere != 0 && iattak != 2) {
                    newcnd();
-                   for (l = 1; l <= nenhere; l++) {
+                   for_local_enemies(l) {
                        finald = sqrt((ix-game.kx[l])*(double)(ix-game.kx[l]) +
                                      (iy-game.ky[l])*(double)(iy-game.ky[l]));
                        game.kavgd[l] = 0.5 * (finald+game.kdist[l]);
@@ -193,7 +193,7 @@ no_quad_change:
     /* No quadrant change -- compute new avg enemy distances */
     game.quad[sectx][secty] = ship;
     if (nenhere) {
-       for (l = 1; l <= nenhere; l++) {
+       for_local_enemies(l) {
            finald = sqrt((ix-game.kx[l])*(double)(ix-game.kx[l]) +
                          (iy-game.ky[l])*(double)(iy-game.ky[l]));
            game.kavgd[l] = 0.5 * (finald+game.kdist[l]);
@@ -202,7 +202,7 @@ no_quad_change:
        sortkl();
        if (!game.state.galaxy[quadx][quady].supernova && iattak == 0)
            attack(0);
-       for (l = 1 ; l <= nenhere; l++) game.kavgd[l] = game.kdist[l];
+       for_local_enemies(l) game.kavgd[l] = game.kdist[l];
     }
     newcnd();
     iattak = 0;
@@ -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 (game.damage[DRADIO] == 0.0 &&
+       (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,8 +928,8 @@ void help(void)
        ddist = sqrt(square(basex-sectx)+square(basey-secty));
     }
     else {
-       ddist = 1e30;
-       for (l = 1; l <= game.state.rembase; l++) {
+       ddist = FOREVER;
+       for_starbases(l) {
            xdist=10.0*sqrt(square(game.state.baseqx[l]-quadx)+square(game.state.baseqy[l]-quady));
            if (xdist < ddist) {
                ddist = xdist;