X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=src%2Fevents.c;h=55de8a5040dba6dcabff12602849fd685be7e1e4;hp=f5aed2e75f49039b022da27260cdf7de82bdde7a;hb=459d6afcbe13be588b29c8bd1fbffb39b13fdee1;hpb=c81e0f1dc6cd1fe5c56e9d521ee1d262932e3a2b diff --git a/src/events.c b/src/events.c index f5aed2e..55de8a5 100644 --- a/src/events.c +++ b/src/events.c @@ -36,10 +36,9 @@ void events(void) int ictbeam=0, ipage=0, istract=0, line, i=0, j, k, l, ixhold=0, iyhold=0; double fintim = game.state.date + game.optime, datemin, xtime, repair, yank=0; int radio_was_broken; + struct quadrant *pdest; -#ifdef DEBUG - if (game.idebug) prout("EVENTS"); -#endif + if (idebug) prout("=== EVENTS"); radio_was_broken = (game.damage[DRADIO] != 0.0); @@ -280,8 +279,8 @@ void events(void) /* Not perfect, but will have to do */ /* Handle case where base is in same quadrant as starship */ if (game.battle.x==game.quadrant.x && game.battle.y==game.quadrant.y) { - game.state.chart[game.battle.x][game.battle.y].starbase = FALSE; - game.quad[game.base.x][game.base.y]= IHDOT; + game.state.chart[game.battle.x][game.battle.y].starbase = false; + game.quad[game.base.x][game.base.y] = IHDOT; game.base.x=game.base.y=0; newcnd(); skip(1); @@ -297,12 +296,13 @@ void events(void) proutn(_(" the starbase in ")); proutn(cramlc(quadrant, game.battle)); prout(_(" has been destroyed by")); - if (game.isatb==2) prout(_("the Klingon Super-Commander")); + if (game.isatb == 2) + prout(_("the Klingon Super-Commander")); else prout(_("a Klingon Commander")); - game.state.chart[game.battle.x][game.battle.y].starbase = FALSE; + game.state.chart[game.battle.x][game.battle.y].starbase = false; } /* Remove Starbase from galaxy */ - game.state.galaxy[game.battle.x][game.battle.y].starbase = FALSE; + game.state.galaxy[game.battle.x][game.battle.y].starbase = false; for_starbases(i) if (game.state.baseq[i].x==game.battle.x && game.state.baseq[i].y==game.battle.y) { game.state.baseq[i].x=game.state.baseq[game.state.rembase].x; @@ -322,8 +322,8 @@ void events(void) case FSCMOVE: /* Supercommander moves */ schedule(FSCMOVE, 0.2777); if (game.ientesc+istract==0 && - game.isatb!=1 && - (game.iscate!=1 || game.justin==1)) scom(&ipage); + game.isatb != 1 && + (game.iscate != 1 || !game.justin)) scom(&ipage); break; case FDSPROB: /* Move deep space probe */ schedule(FDSPROB, 0.01); @@ -360,17 +360,19 @@ void events(void) prout(".\""); } } + pdest = &game.state.galaxy[game.probec.x][game.probec.y]; /* Update star chart if Radio is working or have access to radio. */ if (game.damage[DRADIO] == 0.0 || game.condit == IHDOCKED) { - game.state.chart[game.probec.x][game.probec.y].klingons = game.state.galaxy[game.probec.x][game.probec.y].klingons; - game.state.chart[game.probec.x][game.probec.y].starbase = game.state.galaxy[game.probec.x][game.probec.y].starbase; - game.state.chart[game.probec.x][game.probec.y].stars = game.state.galaxy[game.probec.x][game.probec.y].stars; - game.state.galaxy[game.probec.x][game.probec.y].charted = TRUE; + struct page *chp = &game.state.chart[game.probec.x][game.probec.y]; + + chp->klingons = pdest->klingons; + chp->starbase = pdest->starbase; + chp->stars = pdest->stars; + pdest->charted = true; } game.proben--; // One less to travel - if (game.proben == 0 && game.isarmed && - game.state.galaxy[game.probec.x][game.probec.y].stars) { + if (game.proben == 0 && game.isarmed && pdest->stars) { /* lets blow the sucker! */ snova(1,0); unschedule(FDSPROB); @@ -629,7 +631,7 @@ void nova(int ix, int iy) game.quad[scratch.x][scratch.y] = IHDOT; break; case IHB: /* Destroy base */ - game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase = FALSE; + game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase = false; for_starbases(i) if (game.state.baseq[i].x==game.quadrant.x && game.state.baseq[i].y==game.quadrant.y) break; @@ -667,7 +669,7 @@ void nova(int ix, int iy) kount++; break; case IHK: /* kill klingon */ - deadkl(scratch.x,scratch.y,iquad, scratch.x, scratch.y); + deadkl(scratch,iquad, scratch.x, scratch.y); break; case IHC: /* Damage/destroy big enemies */ case IHS: @@ -676,7 +678,7 @@ void nova(int ix, int iy) if (game.ks[ll].x==scratch.x && game.ks[ll].y==scratch.y) break; game.kpower[ll] -= 800.0; /* If firepower is lost, die */ if (game.kpower[ll] <= 0.0) { - deadkl(scratch.x, scratch.y, iquad, scratch.x, scratch.y); + deadkl(scratch, iquad, scratch.x, scratch.y); break; } newc.x = scratch.x + scratch.x - hits[mm][1]; @@ -693,7 +695,7 @@ void nova(int ix, int iy) proutn(_(", blasted into ")); crmena(0, IHBLANK, 2, newc); skip(1); - deadkl(scratch.x, scratch.y, iquad, newc.x, newc.y); + deadkl(scratch, iquad, newc.x, newc.y); break; } if (iquad1 != IHDOT) { @@ -772,15 +774,13 @@ void snova(int insx, int insy) } if (num <=0) break; } -#ifdef DEBUG - if (game.idebug) { - proutn("Super nova here?"); + if (idebug) { + proutn("=== Super nova here?"); if (ja()==1) { nq.x = game.quadrant.x; nq.y = game.quadrant.y; } } -#endif } if (nq.x != game.quadrant.y || nq.y != game.quadrant.y || game.justin != 0) { @@ -886,7 +886,7 @@ void snova(int insx, int insy) if ((game.quadrant.x == nq.x && game.quadrant.y == nq.y) || game.damage[DRADIO] == 0 || game.condit == IHDOCKED) - game.state.galaxy[nq.x][nq.y].supernova = TRUE; + game.state.galaxy[nq.x][nq.y].supernova = true; /* If supernova destroys last klingons give special message */ if (KLINGREM==0 && (nq.x != game.quadrant.x || nq.y != game.quadrant.y)) { skip(2);