Get rid of obnoxious iattak global.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 20 Sep 2006 21:18:05 +0000 (21:18 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 20 Sep 2006 21:18:05 +0000 (21:18 +0000)
This was a kluge to prevent recursion through an infinit regress of
moves leading to exit attacks forcing moves, etc.

src/battle.c
src/events.c
src/moving.c
src/setup.c
src/sst.h

index 7815b72b663a82a038d6f7c752d60836391a98d2..dc3cede30542008697aaefaf8272072d781200d3 100644 (file)
@@ -544,7 +544,6 @@ void attack(bool torps_ok)
     coord jay;
     enum loctype where = neither;
 
     coord jay;
     enum loctype where = neither;
 
-    game.iattak = 1;
     if (game.alldone) return;
     if (idebug) prout("=== ATTACK!");
 
     if (game.alldone) return;
     if (idebug) prout("=== ATTACK!");
 
index 3fc27e61b67d9701c95cf80b8f98c16d14ff4650..b4d465888957c1a71c68c0db4394e7d92b19ad84 100644 (file)
@@ -784,8 +784,7 @@ void nova(coord nov)
     game.optime = 10.0*game.dist/16.0;
     skip(1);
     prout(_("Force of nova displaces starship."));
     game.optime = 10.0*game.dist/16.0;
     skip(1);
     prout(_("Force of nova displaces starship."));
-    game.iattak=2;     /* Eliminates recursion problem */
-    imove();
+    imove(true);
     game.optime = 10.0*game.dist/16.0;
     return;
 }
     game.optime = 10.0*game.dist/16.0;
     return;
 }
index 534c13f1e9277c63d2f3d3fd840b0db399ce573a..948cdb40c73402a78f68940cda09899fae906876 100644 (file)
@@ -4,8 +4,8 @@
 
 static void getcd(bool, int);
 
 
 static void getcd(bool, int);
 
-void imove(void)
-/* movement execution for warp, impule, supernova, and tractor-beam events */
+void imove(bool novapush)
+/* movement execution for warp, impulse, supernova, and tractor-beam events */
 {
     double angle, deltax, deltay, bigger, x, y,
         finald, stopegy, probf;
 {
     double angle, deltax, deltay, bigger, x, y,
         finald, stopegy, probf;
@@ -51,7 +51,7 @@ void imove(void)
            if (!VALID_SECTOR(w.x, w.y)) {
                /* Leaving quadrant -- allow final enemy attack */
                /* Don't do it if being pushed by Nova */
            if (!VALID_SECTOR(w.x, w.y)) {
                /* Leaving quadrant -- allow final enemy attack */
                /* Don't do it if being pushed by Nova */
-               if (game.nenhere != 0 && game.iattak != 2) {
+               if (game.nenhere != 0 && !novapush) {
                    newcnd();
                    for_local_enemies(m) {
                        finald = distance(w, game.ks[m]);
                    newcnd();
                    for_local_enemies(m) {
                        finald = distance(w, game.ks[m]);
@@ -197,12 +197,11 @@ no_quad_change:
            game.kdist[m] = finald;
        }
        sortkl();
            game.kdist[m] = finald;
        }
        sortkl();
-       if (!game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova && game.iattak == 0)
+       if (!game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova)
            attack(false);
        for_local_enemies(m) game.kavgd[m] = game.kdist[m];
     }
     newcnd();
            attack(false);
        for_local_enemies(m) game.kavgd[m] = game.kdist[m];
     }
     newcnd();
-    game.iattak = 0;
     drawmaps(0);
     setwnd(message_window);
     return;
     drawmaps(0);
     setwnd(message_window);
     return;
@@ -477,7 +476,7 @@ void impuls(void)
        if (ja() == false) return;
     }
     /* Activate impulse engines and pay the cost */
        if (ja() == false) return;
     }
     /* Activate impulse engines and pay the cost */
-    imove();
+    imove(false);
     game.ididit = true;
     if (game.alldone) return;
     power = 20.0 + 100.0*game.dist;
     game.ididit = true;
     if (game.alldone) return;
     power = 20.0 + 100.0*game.dist;
@@ -605,7 +604,7 @@ void warp(bool timewarp)
                                
 
     /* Activate Warp Engines and pay the cost */
                                
 
     /* Activate Warp Engines and pay the cost */
-    imove();
+    imove(false);
     if (game.alldone) return;
     game.energy -= game.dist*game.warpfac*game.warpfac*game.warpfac*(game.shldup+1);
     if (game.energy <= 0) finish(FNRG);
     if (game.alldone) return;
     game.energy -= game.dist*game.warpfac*game.warpfac*game.warpfac*(game.shldup+1);
     if (game.energy <= 0) finish(FNRG);
index e0ca59da9b9d3c5e3bf76c72cca660eb538b1980..8bbafbc31e539f43fd0b7927979a31af22f303e7 100644 (file)
@@ -560,7 +560,6 @@ void newqad(bool shutup)
     coord w;
     struct quadrant *q;
 
     coord w;
     struct quadrant *q;
 
-    game.iattak = 1;
     game.justin = true;
     game.base.x = game.base.y = 0;
     game.klhere = 0;
     game.justin = true;
     game.base.x = game.base.y = 0;
     game.klhere = 0;
index 2e6f90994d9ed41a272c73e9c2d4b4b13c447da6..f96ea03bbd1499f0e8f1c388b365911bf2af0395 100644 (file)
--- a/src/sst.h
+++ b/src/sst.h
@@ -286,7 +286,6 @@ struct game {
        nenhere,        // number of enemies in quadrant
        irhere,         // Romulans in quadrant
        isatb,          // =1 if super commander is attacking base
        nenhere,        // number of enemies in quadrant
        irhere,         // Romulans in quadrant
        isatb,          // =1 if super commander is attacking base
-       iattak,         // attack recursion elimination (was cracks[4])
        tourn,          // tournament number
        proben,         // number of moves for probe
        nprobes;        // number of probes available
        tourn,          // tournament number
        proben,         // number of moves for probe
        nprobes;        // number of probes available
@@ -400,7 +399,7 @@ coord randplace(int);
 coord dropin(feature);
 void newcnd(void);
 void sortkl(void);
 coord dropin(feature);
 void newcnd(void);
 void sortkl(void);
-void imove(void);
+void imove(bool);
 void ram(bool, feature, coord);
 void crmena(bool, feature, enum loctype, coord w);
 void deadkl(coord, feature, coord);
 void ram(bool, feature, coord);
 void crmena(bool, feature, enum loctype, coord w);
 void deadkl(coord, feature, coord);