From f2f73e20553ed56a51b878f81098208fb8e5e273 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 20 Sep 2006 21:18:05 +0000 Subject: [PATCH] Get rid of obnoxious iattak global. This was a kluge to prevent recursion through an infinit regress of moves leading to exit attacks forcing moves, etc. --- src/battle.c | 1 - src/events.c | 3 +-- src/moving.c | 13 ++++++------- src/setup.c | 1 - src/sst.h | 3 +-- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/battle.c b/src/battle.c index 7815b72..dc3cede 100644 --- a/src/battle.c +++ b/src/battle.c @@ -544,7 +544,6 @@ void attack(bool torps_ok) coord jay; enum loctype where = neither; - game.iattak = 1; if (game.alldone) return; if (idebug) prout("=== ATTACK!"); diff --git a/src/events.c b/src/events.c index 3fc27e6..b4d4658 100644 --- a/src/events.c +++ b/src/events.c @@ -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.iattak=2; /* Eliminates recursion problem */ - imove(); + imove(true); game.optime = 10.0*game.dist/16.0; return; } diff --git a/src/moving.c b/src/moving.c index 534c13f..948cdb4 100644 --- a/src/moving.c +++ b/src/moving.c @@ -4,8 +4,8 @@ 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; @@ -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 (game.nenhere != 0 && game.iattak != 2) { + if (game.nenhere != 0 && !novapush) { newcnd(); for_local_enemies(m) { finald = distance(w, game.ks[m]); @@ -197,12 +197,11 @@ no_quad_change: 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(); - game.iattak = 0; drawmaps(0); setwnd(message_window); return; @@ -477,7 +476,7 @@ void impuls(void) 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; @@ -605,7 +604,7 @@ void warp(bool timewarp) /* 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); diff --git a/src/setup.c b/src/setup.c index e0ca59d..8bbafbc 100644 --- a/src/setup.c +++ b/src/setup.c @@ -560,7 +560,6 @@ void newqad(bool shutup) coord w; struct quadrant *q; - game.iattak = 1; game.justin = true; game.base.x = game.base.y = 0; game.klhere = 0; diff --git a/src/sst.h b/src/sst.h index 2e6f909..f96ea03 100644 --- 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 - iattak, // attack recursion elimination (was cracks[4]) 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); -void imove(void); +void imove(bool); void ram(bool, feature, coord); void crmena(bool, feature, enum loctype, coord w); void deadkl(coord, feature, coord); -- 2.31.1