From eaf59bc9a6f0a5c917df2f51be128ae29ba6a595 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 1 Nov 2004 00:00:39 +0000 Subject: [PATCH] Another step in coalescing all the globals. --- ai.c | 86 +++++++++++++++++++------------------- battle.c | 118 ++++++++++++++++++++++++++--------------------------- events.c | 116 ++++++++++++++++++++++++++-------------------------- finish.c | 8 ++-- moving.c | 80 ++++++++++++++++++------------------ planets.c | 22 +++++----- reports.c | 48 +++++++++++----------- setup.c | 120 +++++++++++++++++++++++------------------------------- sst.h | 34 +++++++--------- 9 files changed, 304 insertions(+), 328 deletions(-) diff --git a/ai.c b/ai.c index 6b173b5..4572d4f 100644 --- a/ai.c +++ b/ai.c @@ -18,11 +18,11 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) { if (batx==quadx && baty==quady) return 0; } /* don't leave if over 1000 units of energy */ - if (kpower[loccom] > 1000.) return 0; + if (frozen.kpower[loccom] > 1000.) return 0; } /* print escape message and move out of quadrant. We know this if either short or long range sensors are working */ - if (damage[DSRSENS] == 0.0 || damage[DLRSENS] == 0.0 || + if (frozen.damage[DSRSENS] == 0.0 || frozen.damage[DLRSENS] == 0.0 || condit == IHDOCKED) { proutn("***"); cramen(ienm); @@ -31,11 +31,11 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) { prout(" (and regains strength)."); } /* handle local matters related to escape */ - kx[loccom] = kx[nenhere]; - ky[loccom] = ky[nenhere]; - kavgd[loccom] = kavgd[nenhere]; - kpower[loccom] = kpower[nenhere]; - kdist[loccom] = kdist[nenhere]; + frozen.kx[loccom] = frozen.kx[nenhere]; + frozen.ky[loccom] = frozen.ky[nenhere]; + frozen.kavgd[loccom] = frozen.kavgd[nenhere]; + frozen.kpower[loccom] = frozen.kpower[nenhere]; + frozen.kdist[loccom] = frozen.kdist[nenhere]; klhere--; nenhere--; if (condit != IHDOCKED) newcnd(); @@ -47,8 +47,8 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) { iscate=0; ientesc=0; isatb=0; - future[FSCMOVE]=0.2777+state.date; - future[FSCDBAS]=1e30; + frozen.future[FSCMOVE]=0.2777+state.date; + frozen.future[FSCDBAS]=1e30; state.isx=iqx; state.isy=iqy; } @@ -78,12 +78,12 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) { (comhere + ishere); double dist1, forces; - dist1 = kdist[loccom]; + dist1 = frozen.kdist[loccom]; mdist = dist1 + 0.5; /* Nearest integer distance */ /* If SC, check with spy to see if should hi-tail it */ if (ienm==IHS && - (kpower[loccom] <= 500.0 || (condit==IHDOCKED && damage[DPHOTON]==0))) { + (frozen.kpower[loccom] <= 500.0 || (condit==IHDOCKED && frozen.damage[DPHOTON]==0))) { irun = 1; motion = -10; } @@ -127,14 +127,14 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) { * Motion is limited to skill level, except for SC hi-tailing it out. */ - forces = kpower[loccom]+100.0*nenhere+400*(nbaddys-1); + forces = frozen.kpower[loccom]+100.0*nenhere+400*(nbaddys-1); if (shldup==0) forces += 1000; /* Good for enemy if shield is down! */ - if (damage[DPHASER] == 0.0 || damage[DPHOTON] == 0.0) { - if (damage[DPHASER] != 0) /* phasers damaged */ + if (frozen.damage[DPHASER] == 0.0 || frozen.damage[DPHOTON] == 0.0) { + if (frozen.damage[DPHASER] != 0) /* phasers damaged */ forces += 300.0; else forces -= 0.2*(energy - 2500.0); - if (damage[DPHOTON] != 0) /* photon torpedoes damaged */ + if (frozen.damage[DPHOTON] != 0) /* photon torpedoes damaged */ forces += 300.0; else forces -= 50.0*torps; @@ -253,14 +253,14 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) { frozen.quad[nextx][nexty] = ienm; if (nextx != comx || nexty != comy) { /* it moved */ - kx[loccom] = nextx; - ky[loccom] = nexty; - kdist[loccom] = kavgd[loccom] = + frozen.kx[loccom] = nextx; + frozen.ky[loccom] = nexty; + frozen.kdist[loccom] = frozen.kavgd[loccom] = sqrt(square(sectx-nextx)+square(secty-nexty)); - if (damage[DSRSENS] == 0 || condit == IHDOCKED) { + if (frozen.damage[DSRSENS] == 0 || condit == IHDOCKED) { proutn("***"); cramen(ienm); - if (kdist[loccom] < dist1) proutn(" advances to"); + if (frozen.kdist[loccom] < dist1) proutn(" advances to"); else proutn(" retreats to"); cramlc(2, nextx, nexty); skip(1); @@ -278,16 +278,16 @@ void movcom(void) { /* Figure out which Klingon is the commander (or Supercommander) and do move */ if (comhere) for (i = 1; i <= nenhere; i++) { - ix = kx[i]; - iy = ky[i]; + ix = frozen.kx[i]; + iy = frozen.ky[i]; if (frozen.quad[ix][iy] == IHC) { movebaddy(ix, iy, i, IHC); break; } } if (ishere) for (i = 1; i <= nenhere; i++) { - ix = kx[i]; - iy = ky[i]; + ix = frozen.kx[i]; + iy = frozen.ky[i]; if (frozen.quad[ix][iy] == IHS) { movebaddy(ix, iy, i, IHS); break; @@ -297,8 +297,8 @@ void movcom(void) { Move these last so they can base their actions on what the commander(s) do. */ if (skill > 3) for (i = 1; i <= nenhere; i++) { - ix = kx[i]; - iy = ky[i]; + ix = frozen.kx[i]; + iy = frozen.ky[i]; if (frozen.quad[ix][iy] == IHK || frozen.quad[ix][iy] == IHR) movebaddy(ix, iy, i, frozen.quad[ix][iy]); } @@ -329,15 +329,15 @@ static int checkdest(int iqx, int iqy, int flag, int *ipage) { isatb=0; ishere=0; ientesc=0; - future[FSCDBAS]=1e30; + frozen.future[FSCDBAS]=1e30; for (i = 1; i <= nenhere; i++) - if (frozen.quad[kx[i]][ky[i]] == IHS) break; - frozen.quad[kx[i]][ky[i]] = IHDOT; - kx[i] = kx[nenhere]; - ky[i] = ky[nenhere]; - kdist[i] = kdist[nenhere]; - kavgd[i] = kavgd[nenhere]; - kpower[i] = kpower[nenhere]; + if (frozen.quad[frozen.kx[i]][frozen.ky[i]] == IHS) break; + frozen.quad[frozen.kx[i]][frozen.ky[i]] = IHDOT; + frozen.kx[i] = frozen.kx[nenhere]; + frozen.ky[i] = frozen.ky[nenhere]; + frozen.kdist[i] = frozen.kdist[nenhere]; + frozen.kavgd[i] = frozen.kavgd[nenhere]; + frozen.kpower[i] = frozen.kpower[nenhere]; klhere--; nenhere--; if (condit!=IHDOCKED) newcnd(); @@ -350,7 +350,7 @@ static int checkdest(int iqx, int iqy, int flag, int *ipage) { /* destroy the planet */ state.plnets[i] = nulplanet; state.newstuf[state.isx][state.isy] -= 1; - if (damage[DRADIO] == 0.0 || condit == IHDOCKED) { + if (frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED) { if (*ipage==0) pause(1); *ipage = 1; prout("Lt. Uhura- \"Captain, Starfleet Intelligence reports"); @@ -396,7 +396,7 @@ void scom(int *ipage) { /* compute distances to starbases */ if (state.rembase <= 0) { /* nothing left to do */ - future[FSCMOVE] = 1e30; + frozen.future[FSCMOVE] = 1e30; return; } sx = state.isx; @@ -498,7 +498,7 @@ void scom(int *ipage) { } /* check for a base */ if (state.rembase == 0) { - future[FSCMOVE] = 1e30; + frozen.future[FSCMOVE] = 1e30; } else for (i=1; i<=state.rembase; i++) { ibqx = state.baseqx[i]; @@ -508,9 +508,9 @@ void scom(int *ipage) { if (flag) return; /* no, don't attack base! */ iseenit = 0; isatb=1; - future[FSCDBAS] = state.date + 1.0 +2.0*Rand(); - if (batx != 0) future[FSCDBAS] += future[FCDBAS]-state.date; - if (damage[DRADIO] > 0 && condit != IHDOCKED) + frozen.future[FSCDBAS] = state.date + 1.0 +2.0*Rand(); + if (batx != 0) frozen.future[FSCDBAS] += frozen.future[FCDBAS]-state.date; + if (frozen.damage[DRADIO] > 0 && condit != IHDOCKED) return; /* no warning */ iseenit = 1; if (*ipage == 0) pause(1); @@ -520,7 +520,7 @@ void scom(int *ipage) { skip(1); prout(" reports that it is under attack from the Klingon Super-commander."); proutn(" It can survive until stardate "); - cramf(future[FSCDBAS], 0, 1); + cramf(frozen.future[FSCDBAS], 0, 1); prout(" .\""); if (resting==0) return; prout("Mr. Spock- \"Captain, shall we cancel the rest period?\""); @@ -536,8 +536,8 @@ void scom(int *ipage) { idebug==0 && #endif (Rand() > 0.2 || - (damage[DRADIO] > 0.0 && condit != IHDOCKED) || - starch[state.isx][state.isy] > 0)) + (frozen.damage[DRADIO] > 0.0 && condit != IHDOCKED) || + frozen.starch[state.isx][state.isy] > 0)) return; if (*ipage==0) pause(1); *ipage = 1; diff --git a/battle.c b/battle.c index 2633a32..11a1ca1 100644 --- a/battle.c +++ b/battle.c @@ -14,7 +14,7 @@ void doshield(int i) { action = NRG; else { chew(); - if (damage[DSHIELD]) { + if (frozen.damage[DSHIELD]) { prout("Shields damaged and down."); return; } @@ -30,7 +30,7 @@ void doshield(int i) { proutn("Energy to transfer to shields- "); action = NRG; } - else if (damage[DSHIELD]) { + else if (frozen.damage[DSHIELD]) { prout("Shields damaged and down."); return; } @@ -158,9 +158,9 @@ void ram(int ibumpd, int ienm, int ix, int iy) { casual += icas; for (l=1; l <= ndevice; l++) { if (l == DDRAY) continue; // Don't damage deathray - if (damage[l] < 0) continue; + if (frozen.damage[l] < 0) continue; extradm = (10.0*type*Rand()+1.0)*damfac; - damage[l] += Time + extradm; /* Damage for at least time of travel! */ + frozen.damage[l] += Time + extradm; /* Damage for at least time of travel! */ } shldup = 0; if (state.remkl) { @@ -249,15 +249,15 @@ void torpedo(double course, double r, int inx, int iny, double *hit) { case IHK: /* find the enemy */ for (ll=1; ll <= nenhere; ll++) - if (ix==kx[ll] && iy==ky[ll]) break; - kp = fabs(kpower[ll]); + if (ix==frozen.kx[ll] && iy==frozen.ky[ll]) break; + kp = fabs(frozen.kpower[ll]); h1 = 700.0 + 100.0*Rand() - 1000.0*sqrt(square(ix-inx)+square(iy-iny))* fabs(sin(bullseye-angle)); h1 = fabs(h1); if (kp < h1) h1 = kp; - kpower[ll] -= (kpower[ll]<0 ? -h1 : h1); - if (kpower[ll] == 0) { + frozen.kpower[ll] -= (frozen.kpower[ll]<0 ? -h1 : h1); + if (frozen.kpower[ll] == 0) { deadkl(ix, iy, iquad, ix, iy); return; } @@ -285,13 +285,13 @@ void torpedo(double course, double r, int inx, int iny, double *hit) { return; } prout(" damaged--"); - kx[ll] = jx; - ky[ll] = jy; + frozen.kx[ll] = jx; + frozen.ky[ll] = jy; shoved = 1; break; case IHB: /* Hit a base */ prout("***STARBASE DESTROYED.."); - if (starch[quadx][quady] < 0) starch[quadx][quady] = 0; + if (frozen.starch[quadx][quady] < 0) frozen.starch[quadx][quady] = 0; for (ll=1; ll<=state.rembase; ll++) { if (state.baseqx[ll]==quadx && state.baseqy[ll]==quady) { state.baseqx[ll]=state.baseqx[state.rembase]; @@ -391,7 +391,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit) { cramlc(2, jx, jy); skip(1); for (ll=1; ll<=nenhere; ll++) - kdist[ll] = kavgd[ll] = sqrt(square(sectx-kx[ll])+square(secty-ky[ll])); + frozen.kdist[ll] = frozen.kavgd[ll] = sqrt(square(sectx-frozen.kx[ll])+square(secty-frozen.ky[ll])); sortkl(); return; } @@ -414,11 +414,11 @@ static void fry(double hit) { do { j = ndevice*Rand()+1.0; /* Cheat to prevent shuttle damage unless on ship */ - } while (damage[j] < 0.0 || (j == DSHUTTL && iscraft != 1) || + } while (frozen.damage[j] < 0.0 || (j == DSHUTTL && iscraft != 1) || j == DDRAY); cdam[l] = j; extradm = (hit*damfac)/(ncrit*(75.0+25.0*Rand())); - damage[j] += extradm; + frozen.damage[j] += extradm; if (l > 1) { for (ll=2; ll<=l && j != cdam[ll-1]; ll++) ; if (ll<=l) continue; @@ -429,7 +429,7 @@ static void fry(double hit) { proutn(device[j]); } prout(" damaged."); - if (damage[DSHIELD] && shldup) { + if (frozen.damage[DSHIELD] && shldup) { prout("***Shields knocked down."); shldup=0; } @@ -461,14 +461,14 @@ void attack(int k) { skip(1); if (skill <= 2) i = 2; for (l=1; l <= nenhere; l++) { - if (kpower[l] < 0) continue; /* too weak to attack */ + if (frozen.kpower[l] < 0) continue; /* too weak to attack */ /* compute hit strength and diminsh shield power */ r = Rand(); /* Increase chance of photon torpedos if docked or enemy energy low */ if (condit == IHDOCKED) r *= 0.25; - if (kpower[l] < 500) r *= 0.25; - jx = kx[l]; - jy = ky[l]; + if (frozen.kpower[l] < 500) r *= 0.25; + jx = frozen.kx[l]; + jy = frozen.ky[l]; iquad = frozen.quad[jx][jy]; itflag = (iquad == IHK && r > 0.0005) || k == 0 || (iquad==IHC && r > 0.015) || @@ -479,21 +479,21 @@ void attack(int k) { if (condit == IHDOCKED) continue; /* Don't waste the effort! */ attempt = 1; /* Attempt to attack */ dustfac = 0.8+0.05*Rand(); - hit = kpower[l]*pow(dustfac,kavgd[l]); - kpower[l] *= 0.75; + hit = frozen.kpower[l]*pow(dustfac,frozen.kavgd[l]); + frozen.kpower[l] *= 0.75; } else { /* Enemy used photon torpedo */ double course = 1.90985*atan2((double)secty-jy, (double)jx-sectx); hit = 0; proutn("***TORPEDO INCOMING"); - if (damage[DSRSENS] <= 0.0) { + if (frozen.damage[DSRSENS] <= 0.0) { proutn(" From "); crmena(0, iquad, i, jx, jy); } attempt = 1; prout("--"); r = (Rand()+Rand())*0.5 -0.5; - r += 0.002*kpower[l]*r; + r += 0.002*frozen.kpower[l]*r; torpedo(course, r, jx, jy, &hit); if (state.remkl==0) finish(FWON); /* Klingons did themselves in! */ if (state.galaxy[quadx][quady] == 1000 || @@ -519,11 +519,11 @@ void attack(int k) { ihurt = 1; cramf(hit, 0, 2); proutn(" unit hit"); - if ((damage[DSRSENS] > 0 && itflag) || skill <= 2) { + if ((frozen.damage[DSRSENS] > 0 && itflag) || skill <= 2) { proutn(" on the "); crmshp(); } - if (damage[DSRSENS] <= 0.0 && itflag) { + if (frozen.damage[DSRSENS] <= 0.0 && itflag) { proutn(" from "); crmena(0, iquad, i, jx, jy); } @@ -555,7 +555,7 @@ void attack(int k) { cramf(energy, 0, 2); proutn(" shields "); if (shldup) proutn("up, "); - else if (damage[DSHIELD] == 0) proutn("down, "); + else if (frozen.damage[DSHIELD] == 0) proutn("down, "); else proutn("damaged, "); } crami(percent, 1); @@ -576,7 +576,7 @@ void attack(int k) { } /* After attack, reset average distance to enemies */ for (l = 1; l <= nenhere; l++) - kavgd[l] = kdist[l]; + frozen.kavgd[l] = frozen.kdist[l]; sortkl(); return; } @@ -614,9 +614,9 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) { state.cx[state.remcom] = 0; state.cy[state.remcom] = 0; state.remcom--; - future[FTBEAM] = 1e30; + frozen.future[FTBEAM] = 1e30; if (state.remcom != 0) - future[FTBEAM] = state.date + expran(1.0*incom/state.remcom); + frozen.future[FTBEAM] = state.date + expran(1.0*incom/state.remcom); state.killc++; break; case IHK: @@ -625,13 +625,13 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) { case IHS: state.nscrem = ishere = state.isx = state.isy = isatb = iscate = 0; state.nsckill = 1; - future[FSCMOVE] = future[FSCDBAS] = 1e30; + frozen.future[FSCMOVE] = frozen.future[FSCDBAS] = 1e30; break; } } /* For each kind of enemy, finish message to player */ - prout(" destroyestate."); + prout(" destroyed."); frozen.quad[ix][iy] = IHDOT; if (state.remkl==0) return; @@ -642,21 +642,21 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) { /* Remove enemy ship from arrays describing local conditions */ for (i=1; i<=nenhere; i++) - if (kx[i]==ix && ky[i]==iy) break; + if (frozen.kx[i]==ix && frozen.ky[i]==iy) break; nenhere--; if (i <= nenhere) { for (j=i; j<=nenhere; j++) { - kx[j] = kx[j+1]; - ky[j] = ky[j+1]; - kpower[j] = kpower[j+1]; - kavgd[j] = kdist[j] = kdist[j+1]; + frozen.kx[j] = frozen.kx[j+1]; + frozen.ky[j] = frozen.ky[j+1]; + frozen.kpower[j] = frozen.kpower[j+1]; + frozen.kavgd[j] = frozen.kdist[j] = frozen.kdist[j+1]; } } - kx[nenhere+1] = 0; - ky[nenhere+1] = 0; - kdist[nenhere+1] = 0; - kavgd[nenhere+1] = 0; - kpower[nenhere+1] = 0; + frozen.kx[nenhere+1] = 0; + frozen.ky[nenhere+1] = 0; + frozen.kdist[nenhere+1] = 0; + frozen.kavgd[nenhere+1] = 0; + frozen.kpower[nenhere+1] = 0; return; } @@ -688,7 +688,7 @@ void photon(void) { ididit = 0; - if (damage[DPHOTON]) { + if (frozen.damage[DPHOTON]) { prout("Photon tubes damaged."); chew(); return; @@ -798,7 +798,7 @@ void photon(void) { osuabor=1; if (Rand() <= 0.2) { prout("***Photon tubes damaged by misfire."); - damage[DPHOTON] = damfac*(1.0+2.0*Rand()); + frozen.damage[DPHOTON] = damfac*(1.0+2.0*Rand()); break; } } @@ -826,7 +826,7 @@ static void overheat(double rpow) { double chekbrn = (rpow-1500.)*0.00038; if (Rand() <= chekbrn) { prout("Weapons officer Sulu- \"Phasers overheated, sir.\""); - damage[DPHASER] = damfac*(1.0 + Rand()) * (1.0+chekbrn); + frozen.damage[DPHASER] = damfac*(1.0 + Rand()) * (1.0+chekbrn); } } } @@ -884,19 +884,19 @@ void phasers(void) { skip(1); /* SR sensors and Computer */ - if (damage[DSRSENS]+damage[DCOMPTR] > 0) ipoop = 0; + if (frozen.damage[DSRSENS]+frozen.damage[DCOMPTR] > 0) ipoop = 0; if (condit == IHDOCKED) { prout("Phasers can't be fired through base shields."); chew(); return; } - if (damage[DPHASER] != 0) { + if (frozen.damage[DPHASER] != 0) { prout("Phaser control damaged."); chew(); return; } if (shldup) { - if (damage[DSHCTRL]) { + if (frozen.damage[DSHCTRL]) { prout("High speed shield control damaged."); chew(); return; @@ -1017,7 +1017,7 @@ void phasers(void) { for (i = 1; i <= nenhere; i++) { hits[i] = 0.0; if (powrem <= 0) continue; - hits[i] = fabs(kpower[i])/(phasefac*pow(0.90,kdist[i])); + hits[i] = fabs(frozen.kpower[i])/(phasefac*pow(0.90,frozen.kdist[i])); over = (0.01 + 0.05*Rand())*hits[i]; temp = powrem; powrem -= hits[i] + over; @@ -1044,7 +1044,7 @@ void phasers(void) { case FORCEMAN: chew(); key = IHEOL; - if (damage[DCOMPTR]!=0) + if (frozen.damage[DCOMPTR]!=0) prout("Battle comuter damaged, manual file only."); else { skip(1); @@ -1058,7 +1058,7 @@ void phasers(void) { case MANUAL: rpow = 0.0; for (k = 1; k <= nenhere;) { - int ii = kx[k], jj = ky[k]; + int ii = frozen.kx[k], jj = frozen.ky[k]; int ienm = frozen.quad[ii][jj]; if (msgflag) { proutn("Energy available= "); @@ -1067,7 +1067,7 @@ void phasers(void) { msgflag = 0; rpow = 0.0; } - if (damage[DSRSENS] && !(abs(sectx-ii) < 2 && abs(secty-jj) < 2) && + if (frozen.damage[DSRSENS] && !(abs(sectx-ii) < 2 && abs(secty-jj) < 2) && (ienm == IHC || ienm == IHS)) { cramen(ienm); prout(" can't be located without short range scan."); @@ -1080,7 +1080,7 @@ void phasers(void) { if (key == IHEOL) { chew(); if (ipoop && k > kz) { - int irec=(fabs(kpower[k])/(phasefac*pow(0.9,kdist[k])))* + int irec=(fabs(frozen.kpower[k])/(phasefac*pow(0.9,frozen.kdist[k])))* (1.01+0.05*Rand()) + 1.0; kz = k; proutn("("); @@ -1176,14 +1176,14 @@ void hittem(double *hits) { for (; k <= nenhr2; k++, kk++) { if ((wham = hits[k])==0) continue; dustfac = 0.9 + 0.01*Rand(); - hit = wham*pow(dustfac,kdist[kk]); - kpini = kpower[kk]; + hit = wham*pow(dustfac,frozen.kdist[kk]); + kpini = frozen.kpower[kk]; kp = fabs(kpini); if (phasefac*hit < kp) kp = phasefac*hit; - kpower[kk] -= (kpower[kk] < 0 ? -kp: kp); - kpow = kpower[kk]; - ii = kx[kk]; - jj = ky[kk]; + frozen.kpower[kk] -= (frozen.kpower[kk] < 0 ? -kp: kp); + kpow = frozen.kpower[kk]; + ii = frozen.kx[kk]; + jj = frozen.ky[kk]; if (hit > 0.005) { cramf(hit, 0, 2); proutn(" unit hit on "); @@ -1206,7 +1206,7 @@ void hittem(double *hits) { cramlc(2,ii,jj); skip(1); prout(" has just lost its firepower.\""); - kpower[kk] = -kpow; + frozen.kpower[kk] = -kpow; } } return; diff --git a/events.c b/events.c index b94c05a..99591de 100644 --- a/events.c +++ b/events.c @@ -11,12 +11,12 @@ void events(void) { if (idebug) prout("EVENTS"); #endif - if (stdamtim == 1e30 && damage[DRADIO] != 0.0) { + if (stdamtim == 1e30 && frozen.damage[DRADIO] != 0.0) { /* chart will no longer be updated because radio is dead */ stdamtim = state.date; for (i=1; i <= 8 ; i++) for (j=1; j <= 8; j++) - if (starch[i][j] == 1) starch[i][j] = state.galaxy[i][j]+1000; + if (frozen.starch[i][j] == 1) frozen.starch[i][j] = state.galaxy[i][j]+1000; } for (;;) { @@ -25,9 +25,9 @@ void events(void) { if (alldone) return; datemin = fintim; for (l=1; l<=NEVENTS; l++) - if (future[l] <= datemin) { + if (frozen.future[l] <= datemin) { line = l; - datemin = future[l]; + datemin = frozen.future[l]; } xtime = datemin-state.date; state.date = datemin; @@ -39,30 +39,30 @@ void events(void) { return; } /* Is life support adequate? */ - if (damage[DLIFSUP] && condit != IHDOCKED) { - if (lsupres < xtime && damage[DLIFSUP] > lsupres) { + if (frozen.damage[DLIFSUP] && condit != IHDOCKED) { + if (lsupres < xtime && frozen.damage[DLIFSUP] > lsupres) { finish(FLIFESUP); return; } lsupres -= xtime; - if (damage[DLIFSUP] <= xtime) lsupres = inlsr; + if (frozen.damage[DLIFSUP] <= xtime) lsupres = inlsr; } /* Fix devices */ repair = xtime; if (condit == IHDOCKED) repair /= docfac; /* Don't fix Deathray here */ for (l=1; l<=ndevice; l++) - if (damage[l] > 0.0 && l != DDRAY) - damage[l] -= (damage[l]-repair > 0.0 ? repair : damage[l]); + if (frozen.damage[l] > 0.0 && l != DDRAY) + frozen.damage[l] -= (frozen.damage[l]-repair > 0.0 ? repair : frozen.damage[l]); /* If radio repaired, update star chart and attack reports */ - if (stdamtim != 1e30 && damage[DRADIO] == 0.0) { + if (stdamtim != 1e30 && frozen.damage[DRADIO] == 0.0) { stdamtim = 1e30; prout("Lt. Uhura- \"Captain, the sub-space radio is working and"); prout(" surveillance reports are coming in."); skip(1); for (i=1; i <= 8 ; i++) for (j=1; j <= 8; j++) - if (starch[i][j] > 999) starch[i][j] = 1; + if (frozen.starch[i][j] > 999) frozen.starch[i][j] = 1; if (iseenit==0) { attakreport(); iseenit = 1; @@ -78,7 +78,7 @@ void events(void) { if (ipage==0) pause(1); ipage=1; snova(0,0); - future[FSNOVA] = state.date + expran(0.5*intime); + frozen.future[FSNOVA] = state.date + expran(0.5*intime); if (state.galaxy[quadx][quady] == 1000) return; break; case FSPY: /* Check with spy to see if S.C. should tractor beam */ @@ -87,10 +87,10 @@ void events(void) { condit==IHDOCKED || isatb==1 || iscate==1) return; if (ientesc || (energy < 2000 && torps < 4 && shield < 1250) || - (damage[DPHASER]>0 && (damage[DPHOTON]>0 || torps < 4)) || - (damage[DSHIELD] > 0 && - (energy < 2500 || damage[DPHASER] > 0) && - (torps < 5 || damage[DPHOTON] > 0))) { + (frozen.damage[DPHASER]>0 && (frozen.damage[DPHOTON]>0 || torps < 4)) || + (frozen.damage[DSHIELD] > 0 && + (energy < 2500 || frozen.damage[DPHASER] > 0) && + (torps < 5 || frozen.damage[DPHOTON] > 0))) { /* Tractor-beam her! */ istract=1; yank = square(state.isx-quadx) + square(state.isy-quady); @@ -100,14 +100,14 @@ void events(void) { case FTBEAM: /* Tractor beam */ if (line==FTBEAM) { if (state.remcom == 0) { - future[FTBEAM] = 1e30; + frozen.future[FTBEAM] = 1e30; break; } i = Rand()*state.remcom+1.0; yank = square(state.cx[i]-quadx) + square(state.cy[i]-quady); if (istract || condit == IHDOCKED || yank == 0) { /* Drats! Have to reschedule */ - future[FTBEAM] = state.date + Time + + frozen.future[FTBEAM] = state.date + Time + expran(1.5*intime/state.remcom); break; } @@ -135,7 +135,7 @@ void events(void) { if (Rand() >0.5) { prout("Galileo, left on the planet surface, is captured"); prout("by aliens and made into a flying McDonald's."); - damage[DSHUTTL] = -10; + frozen.damage[DSHUTTL] = -10; iscraft = -1; } else { @@ -162,7 +162,7 @@ void events(void) { resting = 0; } if (shldup==0) { - if (damage[DSHIELD]==0 && shield > 0) { + if (frozen.damage[DSHIELD]==0 && shield > 0) { doshield(2); /* Shldsup */ shldchg=0; } @@ -171,18 +171,18 @@ void events(void) { newqad(0); /* Adjust finish time to time of tractor beaming */ fintim = state.date+Time; - if (state.remcom <= 0) future[FTBEAM] = 1e30; - else future[FTBEAM] = state.date+Time+expran(1.5*intime/state.remcom); + if (state.remcom <= 0) frozen.future[FTBEAM] = 1e30; + else frozen.future[FTBEAM] = state.date+Time+expran(1.5*intime/state.remcom); break; case FSNAP: /* Snapshot of the universe (for time warp) */ snapsht = state; state.snap = 1; - future[FSNAP] = state.date + expran(0.5 * intime); + frozen.future[FSNAP] = state.date + expran(0.5 * intime); break; case FBATTAK: /* Commander attacks starbase */ if (state.remcom==0 || state.rembase==0) { /* no can do */ - future[FBATTAK] = future[FCDBAS] = 1e30; + frozen.future[FBATTAK] = frozen.future[FCDBAS] = 1e30; break; } i = 0; @@ -198,19 +198,19 @@ void events(void) { } if (j>state.rembase) { /* no match found -- try later */ - future[FBATTAK] = state.date + expran(0.3*intime); - future[FCDBAS] = 1e30; + frozen.future[FBATTAK] = state.date + expran(0.3*intime); + frozen.future[FCDBAS] = 1e30; break; } /* commander + starbase combination found -- launch attack */ batx = state.baseqx[j]; baty = state.baseqy[j]; - future[FCDBAS] = state.date+1.0+3.0*Rand(); + frozen.future[FCDBAS] = state.date+1.0+3.0*Rand(); if (isatb) /* extra time if SC already attacking */ - future[FCDBAS] += future[FSCDBAS]-state.date; - future[FBATTAK] = future[FCDBAS] +expran(0.3*intime); + frozen.future[FCDBAS] += frozen.future[FSCDBAS]-state.date; + frozen.future[FBATTAK] = frozen.future[FCDBAS] +expran(0.3*intime); iseenit = 0; - if (damage[DRADIO] != 0.0 && + if (frozen.damage[DRADIO] != 0.0 && condit != IHDOCKED) break; /* No warning :-( */ iseenit = 1; if (ipage==0) pause(1); @@ -221,7 +221,7 @@ void events(void) { skip(1); prout(" reports that it is under atttack and that it can"); proutn(" hold out only until stardate "); - cramf(future[FCDBAS],1,1); + cramf(frozen.future[FCDBAS],1,1); prout(".\""); if (resting) { skip(1); @@ -234,7 +234,7 @@ void events(void) { } break; case FSCDBAS: /* Supercommander destroys base */ - future[FSCDBAS] = 1e30; + frozen.future[FSCDBAS] = 1e30; isatb = 2; if (state.galaxy[state.isx][state.isy]%100 < 10) break; /* WAS RETURN! */ ixhold = batx; @@ -243,7 +243,7 @@ void events(void) { baty = state.isy; case FCDBAS: /* Commander succeeds in destroying base */ if (line==FCDBAS) { - future[FCDBAS] = 1e30; + frozen.future[FCDBAS] = 1e30; /* find the lucky pair */ for (i = 1; i <= state.remcom; i++) if (state.cx[i]==batx && state.cy[i]==baty) break; @@ -256,10 +256,10 @@ void events(void) { } /* Code merges here for any commander destroying base */ /* Not perfect, but will have to do */ - if (starch[batx][baty] == -1) starch[batx][baty] = 0; + if (frozen.starch[batx][baty] == -1) frozen.starch[batx][baty] = 0; /* Handle case where base is in same quadrant as starship */ if (batx==quadx && baty==quady) { - if (starch[batx][baty] > 999) starch[batx][baty] -= 10; + if (frozen.starch[batx][baty] > 999) frozen.starch[batx][baty] -= 10; frozen.quad[basex][basey]= IHDOT; basex=basey=0; newcnd(); @@ -267,7 +267,7 @@ void events(void) { prout("Spock- \"Captain, I believe the starbase has been destroyestate.\""); } else if (state.rembase != 1 && - (damage[DRADIO] <= 0.0 || condit == IHDOCKED)) { + (frozen.damage[DRADIO] <= 0.0 || condit == IHDOCKED)) { /* Get word via subspace radio */ if (ipage==0) pause(1); ipage = 1; @@ -298,13 +298,13 @@ void events(void) { } break; case FSCMOVE: /* Supercommander moves */ - future[FSCMOVE] = state.date+0.2777; + frozen.future[FSCMOVE] = state.date+0.2777; if (ientesc+istract==0 && isatb!=1 && (iscate!=1 || justin==1)) scom(&ipage); break; case FDSPROB: /* Move deep space probe */ - future[FDSPROB] = state.date + 0.01; + frozen.future[FDSPROB] = state.date + 0.01; probex += probeinx; probey += probeiny; i = (int)(probex/10 +0.05); @@ -315,7 +315,7 @@ void events(void) { if (i < 1 || i > 8 || j < 1 || j > 8 || state.galaxy[probecx][probecy] == 1000) { // Left galaxy or ran into supernova - if (damage[DRADIO]==0.0 || condit == IHDOCKED) { + if (frozen.damage[DRADIO]==0.0 || condit == IHDOCKED) { if (ipage==0) pause(1); ipage = 1; skip(1); @@ -326,10 +326,10 @@ void events(void) { proutn("is no longer transmitting"); prout(".\""); } - future[FDSPROB] = 1e30; + frozen.future[FDSPROB] = 1e30; break; } - if (damage[DRADIO]==0.0 || condit == IHDOCKED) { + if (frozen.damage[DRADIO]==0.0 || condit == IHDOCKED) { if (ipage==0) pause(1); ipage = 1; skip(1); @@ -340,15 +340,15 @@ void events(void) { } /* Update star chart if Radio is working or have access to radio. */ - if (damage[DRADIO] == 0.0 || condit == IHDOCKED) - starch[probecx][probecy] = damage[DRADIO] > 0.0 ? + if (frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED) + frozen.starch[probecx][probecy] = frozen.damage[DRADIO] > 0.0 ? state.galaxy[probecx][probecy]+1000 : 1; proben--; // One less to travel if (proben == 0 && isarmed && state.galaxy[probecx][probecy] % 10 > 0) { /* lets blow the sucker! */ snova(1,0); - future[FDSPROB] = 1e30; + frozen.future[FDSPROB] = 1e30; if (state.galaxy[quadx][quady] == 1000) return; } break; @@ -405,7 +405,7 @@ void wait(void) { delay -= temp; /* Repair Deathray if long rest at starbase */ if (origTime-delay >= 9.99 && condit == IHDOCKED) - damage[DDRAY] = 0.0; + frozen.damage[DDRAY] = 0.0; } while (state.galaxy[quadx][quady] != 1000); // leave if quadrant supernovas resting = 0; @@ -506,7 +506,7 @@ void nova(int ix, int iy) { shield = 0.0; shldup = 0; prout("***Shields knocked out."); - damage[DSHIELD] += 0.005*damfac*Rand()*diff; + frozen.damage[DSHIELD] += 0.005*damfac*Rand()*diff; } } else energy -= 2000.0; @@ -526,9 +526,9 @@ void nova(int ix, int iy) { case IHS: case IHR: for (ll = 1; ll <= nenhere; ll++) - if (kx[ll]==ii && ky[ll]==jj) break; - kpower[ll] -= 800.0; /* If firepower is lost, die */ - if (kpower[ll] <= 0.0) { + if (frozen.kx[ll]==ii && frozen.ky[ll]==jj) break; + frozen.kpower[ll] -= 800.0; /* If firepower is lost, die */ + if (frozen.kpower[ll] <= 0.0) { deadkl(ii, jj, iquad, ii, jj); break; } @@ -558,10 +558,10 @@ void nova(int ix, int iy) { cramlc(2, newcx, newcy); frozen.quad[ii][jj] = IHDOT; frozen.quad[newcx][newcy] = iquad; - kx[ll] = newcx; - ky[ll] = newcy; - kavgd[ll] = sqrt(square(sectx-newcx)+square(secty-newcy)); - kdist[ll] = kavgd[ll]; + frozen.kx[ll] = newcx; + frozen.ky[ll] = newcy; + frozen.kavgd[ll] = sqrt(square(sectx-newcx)+square(secty-newcy)); + frozen.kdist[ll] = frozen.kavgd[ll]; skip(1); break; } @@ -635,7 +635,7 @@ void snova(int insx, int insy) { if (nqx != quady || nqy != quady || justin != 0) { /* it isn't here, or we just entered (treat as inroute) */ - if (damage[DRADIO] == 0.0 || condit == IHDOCKED) { + if (frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED) { skip(1); proutn("Message from Starfleet Command Stardate "); cramf(state.date, 0, 1); @@ -689,7 +689,7 @@ void snova(int insx, int insy) { /* did in the Supercommander! */ state.nscrem = state.isx = state.isy = isatb = iscate = 0; iscdead = 1; - future[FSCMOVE] = future[FSCDBAS] = 1e30; + frozen.future[FSCMOVE] = frozen.future[FSCDBAS] = 1e30; } state.remkl -= kldead; if (state.remcom) { @@ -702,7 +702,7 @@ void snova(int insx, int insy) { state.remcom--; kldead--; comdead++; - if (state.remcom==0) future[FTBEAM] = 1e30; + if (state.remcom==0) frozen.future[FTBEAM] = 1e30; break; } } @@ -745,9 +745,9 @@ void snova(int insx, int insy) { } /* mark supernova in galaxy and in star chart */ if ((quadx == nqx && quady == nqy) || - damage[DRADIO] == 0 || + frozen.damage[DRADIO] == 0 || condit == IHDOCKED) - starch[nqx][nqy] = 1; + frozen.starch[nqx][nqy] = 1; state.galaxy[nqx][nqy] = 1000; /* If supernova destroys last klingons give special message */ if (state.remkl==0 && (nqx != quadx || nqy != quady)) { diff --git a/finish.c b/finish.c index e396759..f355b5a 100644 --- a/finish.c +++ b/finish.c @@ -5,7 +5,7 @@ void dstrct() { /* Finish with a BANG! */ chew(); - if (damage[DCOMPTR] != 0.0) { + if (frozen.damage[DCOMPTR] != 0.0) { prout("Computer damaged; cannot execute destruct sequence."); return; } @@ -22,7 +22,7 @@ void dstrct() { prout("SELF-DESTRUCT-SEQUENCE-WILL-BE-ABORTED"); scan(); chew(); - if (strcmp(passwd, citem) != 0) { + if (strcmp(frozen.passwd, citem) != 0) { prouts("PASSWORD-REJECTED;"); skip(1); prout("CONTINUITY-EFFECTED"); skip(1); @@ -55,8 +55,8 @@ void kaboom(void) { double whammo = 25.0 * energy; int l=1; while (l <= nenhere) { - if (kpower[l]*kdist[l] <= whammo) - deadkl(kx[l],ky[l], frozen.quad[kx[l]][ky[l]], kx[l], ky[l]); + if (frozen.kpower[l]*frozen.kdist[l] <= whammo) + deadkl(frozen.kx[l],frozen.ky[l], frozen.quad[frozen.kx[l]][frozen.ky[l]], frozen.kx[l], frozen.ky[l]); l++; } } diff --git a/moving.c b/moving.c index 24c9643..0f53518 100644 --- a/moving.c +++ b/moving.c @@ -24,11 +24,11 @@ void move(void) { deltax /= bigger; /* If tractor beam is to occur, don't move full distance */ - if (state.date+Time >= future[FTBEAM]) { + if (state.date+Time >= frozen.future[FTBEAM]) { trbeam = 1; condit = IHRED; - dist = dist*(future[FTBEAM]-state.date)/Time + 0.1; - Time = future[FTBEAM] - state.date + 1e-5; + dist = dist*(frozen.future[FTBEAM]-state.date)/Time + 0.1; + Time = frozen.future[FTBEAM] - state.date + 1e-5; } /* Move within the quadrant */ frozen.quad[sectx][secty] = IHDOT; @@ -46,9 +46,9 @@ void move(void) { if (nenhere != 0 && iattak != 2) { newcnd(); for (l = 1; l <= nenhere; l++) { - finald = sqrt((ix-kx[l])*(double)(ix-kx[l]) + - (iy-ky[l])*(double)(iy-ky[l])); - kavgd[l] = 0.5 * (finald+kdist[l]); + finald = sqrt((ix-frozen.kx[l])*(double)(ix-frozen.kx[l]) + + (iy-frozen.ky[l])*(double)(iy-frozen.ky[l])); + frozen.kavgd[l] = 0.5 * (finald+frozen.kdist[l]); } if (state.galaxy[quadx][quady] != 1000) attack(0); if (alldone) return; @@ -173,15 +173,15 @@ label100: frozen.quad[sectx][secty] = ship; if (nenhere) { for (l = 1; l <= nenhere; l++) { - finald = sqrt((ix-kx[l])*(double)(ix-kx[l]) + - (iy-ky[l])*(double)(iy-ky[l])); - kavgd[l] = 0.5 * (finald+kdist[l]); - kdist[l] = finald; + finald = sqrt((ix-frozen.kx[l])*(double)(ix-frozen.kx[l]) + + (iy-frozen.ky[l])*(double)(iy-frozen.ky[l])); + frozen.kavgd[l] = 0.5 * (finald+frozen.kdist[l]); + frozen.kdist[l] = finald; } sortkl(); if (state.galaxy[quadx][quady] != 1000 && iattak == 0) attack(0); - for (l = 1 ; l <= nenhere; l++) kavgd[l] = kdist[l]; + for (l = 1 ; l <= nenhere; l++) frozen.kavgd[l] = frozen.kdist[l]; } newcnd(); iattak = 0; @@ -210,7 +210,7 @@ void dock(void) { torps = intorps; lsupres = inlsr; if (stdamtim != 1e30 && - (future[FCDBAS] < 1e30 || isatb == 1) && iseenit == 0) { + (frozen.future[FCDBAS] < 1e30 || isatb == 1) && iseenit == 0) { /* get attack report from base */ prout("Lt. Uhura- \"Captain, an important message from the starbase:\""); attakreport(); @@ -247,7 +247,7 @@ static void getcd(int isprobe, int akey) { return; } while (automatic == -1) { - if (damage[DCOMPTR]) { + if (frozen.damage[DCOMPTR]) { if (isprobe) prout("Computer damaged; manual navigation only"); else @@ -410,7 +410,7 @@ void impuls(void) { double power; ididit = 0; - if (damage[DIMPULS]) { + if (frozen.damage[DIMPULS]) { chew(); skip(1); prout("Engineer Scott- \"The impulse engines are damaged, Sir.\""); @@ -467,13 +467,13 @@ void warp(int i) { if (i!=2) { /* Not WARPX entry */ ididit = 0; - if (damage[DWARPEN] > 10.0) { + if (frozen.damage[DWARPEN] > 10.0) { chew(); skip(1); prout("Engineer Scott- \"The impulse engines are damaged, Sir.\""); return; } - if (damage[DWARPEN] > 0.0 && warpfac > 4.0) { + if (frozen.damage[DWARPEN] > 0.0 && warpfac > 4.0) { chew(); skip(1); prout("Engineer Scott- \"Sorry, Captain. Until this damage"); @@ -584,7 +584,7 @@ void warp(int i) { Time = 10.0*dist/wfacsq; if (twarp) timwrp(); if (blooey) { - damage[DWARPEN] = damfac*(3.0*Rand()+1.0); + frozen.damage[DWARPEN] = damfac*(3.0*Rand()+1.0); skip(1); prout("Engineering to bridge--"); prout(" Scott here. The warp engines are damaged."); @@ -609,11 +609,11 @@ void setwrp(void) { huh(); return; } - if (damage[DWARPEN] > 10.0) { + if (frozen.damage[DWARPEN] > 10.0) { prout("Warp engines inoperative."); return; } - if (damage[DWARPEN] > 0.0 && aaitem > 4.0) { + if (frozen.damage[DWARPEN] > 0.0 && aaitem > 4.0) { prout("Engineer Scott- \"I'm doing my best, Captain,\n" " but right now we can only go warp 4.\""); return; @@ -653,7 +653,7 @@ void atover(int igrab) { chew(); /* is captain on planet? */ if (landed==1) { - if (damage[DTRANSP]) { + if (frozen.damage[DTRANSP]) { finish(FPNOVA); return; } @@ -703,10 +703,10 @@ void atover(int igrab) { crmshp(); skip(1); prout("safely out of quadrant."); - starch[quadx][quady] = damage[DRADIO] > 0.0 ? state.galaxy[quadx][quady]+1000:1; + frozen.starch[quadx][quady] = frozen.damage[DRADIO] > 0.0 ? state.galaxy[quadx][quady]+1000:1; /* Try to use warp engines */ - if (damage[DWARPEN]) { + if (frozen.damage[DWARPEN]) { skip(1); prout("Warp engines damaged."); finish(FSNOVAED); @@ -750,15 +750,15 @@ void timwrp() { state = snapsht; state.snap = 0; if (state.remcom) { - future[FTBEAM] = state.date + expran(intime/state.remcom); - future[FBATTAK] = state.date + expran(0.3*intime); + frozen.future[FTBEAM] = state.date + expran(intime/state.remcom); + frozen.future[FBATTAK] = state.date + expran(0.3*intime); } - future[FSNOVA] = state.date + expran(0.5*intime); - future[FSNAP] = state.date +expran(0.25*state.remtime); /* next snapshot will + frozen.future[FSNOVA] = state.date + expran(0.5*intime); + frozen.future[FSNAP] = state.date +expran(0.25*state.remtime); /* next snapshot will be sooner */ - if (state.nscrem) future[FSCMOVE] = 0.2777; + if (state.nscrem) frozen.future[FSCMOVE] = 0.2777; isatb = 0; - future[FCDBAS] = future[FSCDBAS] = 1e30; + frozen.future[FCDBAS] = frozen.future[FSCDBAS] = 1e30; batx = baty = 0; /* Make sure Galileo is consistant -- Snapshot may have been taken @@ -775,19 +775,19 @@ void timwrp() { } /* Likewise, if in the original time the Galileo was abandoned, but was on ship earlier, it would have vanished -- lets restore it */ - if (iscraft==0 && gotit==0 && damage[DSHUTTL] >= 0.0) { + if (iscraft==0 && gotit==0 && frozen.damage[DSHUTTL] >= 0.0) { prout("Checkov- \"Security reports the Galileo has reappeared in the dock!\""); iscraft = 1; } /* Revert star chart to earlier era, if it was known then*/ - if (damage[DRADIO]==0.0 || stdamtim > state.date) { + if (frozen.damage[DRADIO]==0.0 || stdamtim > state.date) { for (l = 1; l <= 8; l++) for (ll = 1; ll <= 8; ll++) - if (starch[l][ll] > 1) - starch[l][ll]=damage[DRADIO]>0.0 ? state.galaxy[l][ll]+1000 :1; + if (frozen.starch[l][ll] > 1) + frozen.starch[l][ll]=frozen.damage[DRADIO]>0.0 ? state.galaxy[l][ll]+1000 :1; prout("Spock has reconstructed a correct star chart from memory"); - if (damage[DRADIO] > 0.0) stdamtim = state.date; + if (frozen.damage[DRADIO] > 0.0) stdamtim = state.date; } } else { @@ -797,8 +797,8 @@ void timwrp() { cramf(Time, 1, 2); prout(" stardates."); /* cheat to make sure no tractor beams occur during time warp */ - future[FTBEAM] += Time; - damage[DRADIO] += Time; + frozen.future[FTBEAM] += Time; + frozen.damage[DRADIO] += Time; } newqad(0); } @@ -816,16 +816,16 @@ void probe(void) { prout("Ye Faerie Queene has no deep space probes."); return; } - if (damage[DDSP] != 0.0) { + if (frozen.damage[DDSP] != 0.0) { chew(); skip(1); prout("Engineer Scott- \"The probe launcher is damaged, Sir.\""); return; } - if (future[FDSPROB] != 1e30) { + if (frozen.future[FDSPROB] != 1e30) { chew(); skip(1); - if (damage[DRADIO] != 0 && condit != IHDOCKED) { + if (frozen.damage[DRADIO] != 0 && condit != IHDOCKED) { prout("Spock- \"Records show the previous probe has not yet"); prout(" reached its destination.\""); } @@ -870,7 +870,7 @@ void probe(void) { probey = quady*10 + secty - 1; probecx = quadx; probecy = quady; - future[FDSPROB] = state.date + 0.01; // Time to move one sector + frozen.future[FDSPROB] = state.date + 0.01; // Time to move one sector prout("Ensign Chekov- \"The deep space probe is launched, Captain.\""); return; } @@ -886,7 +886,7 @@ void help(void) { prout("Lt. Uhura- \"But Captain, we're already docked.\""); return; } - if (damage[DRADIO] != 0) { + if (frozen.damage[DRADIO] != 0) { prout("Subspace radio damaged."); return; } diff --git a/planets.c b/planets.c index 133b0da..ea9aa12 100644 --- a/planets.c +++ b/planets.c @@ -64,7 +64,7 @@ void orbit(void) { prout("Already in standard orbit."); return; } - if (damage[DWARPEN] != 0 && damage[DIMPULS] != 0) { + if (frozen.damage[DWARPEN] != 0 && frozen.damage[DIMPULS] != 0) { prout("Both warp and impulse engines damaged."); return; } @@ -87,7 +87,7 @@ void orbit(void) { void sensor(void) { skip(1); chew(); - if (damage[DSRSENS] != 0.0) { + if (frozen.damage[DSRSENS] != 0.0) { prout("Short range sensors damaged."); return; } @@ -116,9 +116,9 @@ void sensor(void) { void beam(void) { chew(); skip(1); - if (damage[DTRANSP] != 0) { + if (frozen.damage[DTRANSP] != 0) { prout("Transporter damaged."); - if (damage[DSHUTTL]==0 && (state.plnets[iplnet].known==2 || iscraft == 1)) { + if (frozen.damage[DSHUTTL]==0 && (state.plnets[iplnet].known==2 || iscraft == 1)) { skip(1); prout("Spock- \"May I suggest the shuttle craft, Sir?\" "); if (ja() != 0) shuttle(); @@ -285,14 +285,14 @@ void shuttle(void) { chew(); skip(1); ididit = 0; - if(damage[DSHUTTL] != 0.0) { - if (damage[DSHUTTL] == -1.0) { + if(frozen.damage[DSHUTTL] != 0.0) { + if (frozen.damage[DSHUTTL] == -1.0) { if (inorbit && state.plnets[iplnet].known == 2) prout("Ye Faerie Queene has no shuttle craft bay to dock it at."); else prout("Ye Faerie Queene had no shuttle craft."); } - else if (damage[DSHUTTL] > 0) + else if (frozen.damage[DSHUTTL] > 0) prout("The Galileo is damaged."); else prout("Shuttle craft is now serving Big Macs."); return; @@ -337,7 +337,7 @@ void shuttle(void) { /* Kirk on planet */ if (iscraft==1) { /* Galileo on ship! */ - if (damage[DTRANSP]==0) { + if (frozen.damage[DTRANSP]==0) { proutn("Spock- \"Would you rather use the transporter?\" "); if (ja() != 0) { beam(); @@ -411,7 +411,7 @@ void deathray(void) { prout("Sulu- \"But Sir, there are no enemies in this quadrant.\""); return; } - if (damage[DDRAY] > 0.0) { + if (frozen.damage[DDRAY] > 0.0) { prout("Death Ray is damaged."); return; } @@ -437,7 +437,7 @@ void deathray(void) { prouts("Sulu- \"Captain! It's working!\""); skip(2); while (nenhere > 0) - deadkl(kx[1],ky[1],frozen.quad[kx[1]][ky[1]],kx[1],ky[1]); + deadkl(frozen.kx[1],frozen.ky[1],frozen.quad[frozen.kx[1]][frozen.ky[1]],frozen.kx[1],frozen.ky[1]); prout("Ensign Chekov- \"Congratulations, Captain!\""); if (state.remkl == 0) finish(FWON); prout("Spock- \"Captain, I believe the `Experimental Death Ray'"); @@ -446,7 +446,7 @@ void deathray(void) { } else { prout(" has been rendered disfunctional.\""); - damage[DDRAY] = 39.95; + frozen.damage[DDRAY] = 39.95; } return; } diff --git a/reports.c b/reports.c index 6ce31c4..5841aec 100644 --- a/reports.c +++ b/reports.c @@ -4,12 +4,12 @@ #include void attakreport(void) { - if (future[FCDBAS] < 1e30) { + if (frozen.future[FCDBAS] < 1e30) { proutn("Starbase in "); cramlc(1, batx, baty); prout(" is currently under attack."); proutn("It can hold out until Stardate "); - cramf(future[FCDBAS], 0,1); + cramf(frozen.future[FCDBAS], 0,1); prout("."); } if (isatb == 1) { @@ -17,7 +17,7 @@ void attakreport(void) { cramlc(1, state.isx, state.isy); prout(" is under Super-commander attack."); proutn("It can hold out until Stardate "); - cramf(future[FSCDBAS], 0, 1); + cramf(frozen.future[FSCDBAS], 0, 1); prout("."); } } @@ -46,7 +46,7 @@ void report(int f) { alldone? "were": "are now", s1, s2, s3); if (skill>3 && thawed && !alldone) prout("No plaque is allowed."); if (tourn) printf("This is tournament game %d.\n", tourn); - if (f) printf("Your secret password is \"%s\"\n",passwd); + if (f) printf("Your secret password is \"%s\"\n",frozen.passwd); printf("%d of %d Klingons have been killed", state.killk+state.killc+state.nsckill, inkling); if (state.killc) printf(", including %d Commander%s.\n", state.killc, state.killc==1?"":"s"); @@ -67,7 +67,7 @@ void report(int f) { prout(" remaining."); } else printf("There are %d bases.\n", inbase); - if (damage[DRADIO] == 0.0 || condit == IHDOCKED || iseenit) { + if (frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED || iseenit) { /* Don't report this if not seen and either the radio is dead or not at base! */ attakreport(); @@ -85,8 +85,8 @@ void report(int f) { if (nprobes!=1) proutn("s"); prout("."); } - if ((damage[DRADIO] == 0.0 || condit == IHDOCKED)&& - future[FDSPROB] != 1e30) { + if ((frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED)&& + frozen.future[FDSPROB] != 1e30) { if (isarmed) proutn("An armed deep space probe is in"); else @@ -114,7 +114,7 @@ void report(int f) { void lrscan(void) { int x, y; chew(); - if (damage[DLRSENS] != 0.0) { + if (frozen.damage[DLRSENS] != 0.0) { /* Now allow base's sensors if docked */ if (condit != IHDOCKED) { prout("LONG-RANGE SENSORS DAMAGED."); @@ -135,7 +135,7 @@ void lrscan(void) { printf(" -1"); else { printf("%5d", state.galaxy[x][y]); - starch[x][y] = damage[DRADIO] > 0 ? state.galaxy[x][y]+1000 :1; + frozen.starch[x][y] = frozen.damage[DRADIO] > 0 ? state.galaxy[x][y]+1000 :1; } } putchar('\n'); @@ -148,7 +148,7 @@ void dreprt(void) { chew(); for (i = 1; i <= ndevice; i++) { - if (damage[i] > 0.0) { + if (frozen.damage[i] > 0.0) { if (!jdam) { skip(1); prout("DEVICE -REPAIR TIMES-"); @@ -156,9 +156,9 @@ void dreprt(void) { jdam = TRUE; } printf(" %16s ", device[i]); - cramf(damage[i]+0.05, 8, 2); + cramf(frozen.damage[i]+0.05, 8, 2); proutn(" "); - cramf(docfac*damage[i]+0.005, 8, 2); + cramf(docfac*frozen.damage[i]+0.005, 8, 2); skip(1); } } @@ -182,7 +182,7 @@ void chart(int nn) { stdamtim = state.date; for (i=1; i <= 8 ; i++) for (j=1; j <= 8; j++) - if (starch[i][j] == 1) starch[i][j] = state.galaxy[i][j]+1000; + if (frozen.starch[i][j] == 1) frozen.starch[i][j] = state.galaxy[i][j]+1000; } else { proutn("(Last surveillance update "); @@ -198,12 +198,12 @@ void chart(int nn) { for (i = 1; i <= 8; i++) { printf("%d -", i); for (j = 1; j <= 8; j++) { - if (starch[i][j] < 0) + if (frozen.starch[i][j] < 0) printf(" .1."); - else if (starch[i][j] == 0) + else if (frozen.starch[i][j] == 0) printf(" ..."); - else if (starch[i][j] > 999) - printf("%5d", starch[i][j]-1000); + else if (frozen.starch[i][j] > 999) + printf("%5d", frozen.starch[i][j]-1000); else printf("%5d", state.galaxy[i][j]); } @@ -227,7 +227,7 @@ void srscan(int l) { int goodScan=TRUE; switch (l) { case 1: // SRSCAN - if (damage[DSRSENS] != 0) { + if (frozen.damage[DSRSENS] != 0) { /* Allow base's sensors if docked */ if (condit != IHDOCKED) { prout("SHORT-RANGE SENSORS DAMAGED"); @@ -237,7 +237,7 @@ void srscan(int l) { prout("[Using starbase's sensors]"); } if (goodScan) - starch[quadx][quady] = damage[DRADIO]>0.0 ? + frozen.starch[quadx][quady] = frozen.damage[DRADIO]>0.0 ? state.galaxy[quadx][quady]+1000:1; scan(); if (isit("chart")) nn = TRUE; @@ -298,7 +298,7 @@ void srscan(int l) { break; case 4: printf(" Life Support "); - if (damage[DLIFSUP] != 0.0) { + if (frozen.damage[DLIFSUP] != 0.0) { if (condit == IHDOCKED) printf("DAMAGED, supported by starbase"); else @@ -318,7 +318,7 @@ void srscan(int l) { break; case 8: printf(" Shields "); - if (damage[DSHIELD] != 0) + if (frozen.damage[DSHIELD] != 0) printf("DAMAGED,"); else if (shldup) printf("UP,"); @@ -347,7 +347,7 @@ void eta(void) { int key, ix1, ix2, iy1, iy2, prompt=FALSE; int wfl; double ttime, twarp, tpower; - if (damage[DCOMPTR] != 0.0) { + if (frozen.damage[DCOMPTR] != 0.0) { prout("COMPUTER DAMAGED, USE A POCKET CALCULATOR."); skip(1); return; @@ -473,8 +473,8 @@ void eta(void) { if (twarp > 6.0) prout("You'll be taking risks at that speed, Captain"); if ((isatb==1 && state.isy == ix1 && state.isx == iy1 && - future[FSCDBAS]< ttime+state.date)|| - (future[FCDBAS]0) { + if (frozen.damage[DSHUTTL]>0) { prout("Shuttle craft damaged."); return; } @@ -183,8 +165,8 @@ void abandn(void) { iscraft=0; /* Gallileo disappears */ /* Resupply ship */ condit=IHDOCKED; - for (l = 1; l <= ndevice; l++) damage[l] = 0.0; - damage[DSHUTTL] = -1; + for (l = 1; l <= ndevice; l++) frozen.damage[l] = 0.0; + frozen.damage[DSHUTTL] = -1; energy = inenrg = 3000.0; shield = inshld = 1250.0; torps = intorps = 6; @@ -217,7 +199,7 @@ void setup(void) { nprobes = (int)(3.0*Rand() + 2.0); /* Give them 2-4 of these wonders */ warpfac = 5.0; wfacsq = warpfac * warpfac; - for (i=0; i <= ndevice; i++) damage[i] = 0.0; + for (i=0; i <= ndevice; i++) frozen.damage[i] = 0.0; // Set up assorted game parameters batx = baty = 0; state.date = indate = 100.0*(int)(31.0*Rand()+20.0); @@ -228,16 +210,16 @@ void setup(void) { alive = 1; docfac = 0.25; for (i = 1; i <= 8; i++) - for (j = 1; j <= 8; j++) state.newstuf[i][j] = starch[i][j] = 0; + for (j = 1; j <= 8; j++) state.newstuf[i][j] = frozen.starch[i][j] = 0; // Initialize times for extraneous events - future[FSNOVA] = state.date + expran(0.5 * intime); - future[FTBEAM] = state.date + expran(1.5 * (intime / state.remcom)); - future[FSNAP] = state.date + 1.0 + Rand(); // Force an early snapshot - future[FBATTAK] = state.date + expran(0.3*intime); - future[FCDBAS] = 1e30; - future[FSCMOVE] = state.nscrem ? state.date+0.2777 : 1e30; - future[FSCDBAS] = 1e30; - future[FDSPROB] = 1e30; + frozen.future[FSNOVA] = state.date + expran(0.5 * intime); + frozen.future[FTBEAM] = state.date + expran(1.5 * (intime / state.remcom)); + frozen.future[FSNAP] = state.date + 1.0 + Rand(); // Force an early snapshot + frozen.future[FBATTAK] = state.date + expran(0.3*intime); + frozen.future[FCDBAS] = 1e30; + frozen.future[FSCMOVE] = state.nscrem ? state.date+0.2777 : 1e30; + frozen.future[FSCDBAS] = 1e30; + frozen.future[FDSPROB] = 1e30; // Starchart is functional stdamtim = 1e30; // Put stars in the galaxy @@ -275,7 +257,7 @@ void setup(void) { state.baseqx[i] = ix; state.baseqy[i] = iy; - starch[ix][iy] = -1; + frozen.starch[ix][iy] = -1; state.galaxy[ix][iy] += 10; } // Position ordinary Klingon Battle Cruisers @@ -421,7 +403,7 @@ int choose(void) { if (isit("frozen")) { thaw(); chew(); - if (*passwd==0) continue; + if (*frozen.passwd==0) continue; randomize(); Rand(); Rand(); Rand(); Rand(); if (!alldone) thawed = 1; // No plaque if not finished @@ -463,13 +445,13 @@ int choose(void) { } while (TRUE) { scan(); - strcpy(passwd, citem); + strcpy(frozen.passwd, citem); chew(); - if (*passwd != 0) break; + if (*frozen.passwd != 0) break; proutn("Please type in a secret password-"); } #ifdef DEBUG - if (strcmp(passwd, "debug")==0) idebug = 1; + if (strcmp(frozen.passwd, "debug")==0) idebug = 1; #endif // Use parameters to generate initial values of things @@ -554,7 +536,7 @@ void newqad(int shutup) { (skill == 3 && Rand() <= 0.05) || (skill > 3 && Rand() <= 0.08) #ifdef DEBUG - || strcmp(passwd, "tholianx")==0 + || strcmp(frozen.passwd, "tholianx")==0 #endif ) { do { @@ -575,10 +557,10 @@ void newqad(int shutup) { quadnum -= 100*klhere; for (i = 1; i <= klhere; i++) { dropin(IHK, &ix, &iy); - kx[i] = ix; - ky[i] = iy; - kdist[i] = kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy)); - kpower[i] = Rand()*150.0 +300.0 +25.0*skill; + frozen.kx[i] = ix; + frozen.ky[i] = iy; + frozen.kdist[i] = frozen.kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy)); + frozen.kpower[i] = Rand()*150.0 +300.0 +25.0*skill; } // If we need a commander, promote a Klingon for (i = 1; i <= state.remcom ; i++) @@ -586,14 +568,14 @@ void newqad(int shutup) { if (i <= state.remcom) { frozen.quad[ix][iy] = IHC; - kpower[klhere] = 950.0+400.0*Rand()+50.0*skill; + frozen.kpower[klhere] = 950.0+400.0*Rand()+50.0*skill; comhere = 1; } // If we need a super-commander, promote a Klingon if (quadx == state.isx && quady == state.isy) { - frozen.quad[kx[1]][ky[1]] = IHS; - kpower[1] = 1175.0 + 400.0*Rand() + 125.0*skill; + frozen.quad[frozen.kx[1]][frozen.ky[1]] = IHS; + frozen.kpower[1] = 1175.0 + 400.0*Rand() + 125.0*skill; iscate = 1; ishere = 1; } @@ -601,10 +583,10 @@ void newqad(int shutup) { // Put in Romulans if needed for (i = klhere+1; i <= nenhere; i++) { dropin(IHR, &ix, &iy); - kx[i] = ix; - ky[i] = iy; - kdist[i] = kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy)); - kpower[i] = Rand()*400.0 + 450.0 + 50.0*skill; + frozen.kx[i] = ix; + frozen.ky[i] = iy; + frozen.kdist[i] = frozen.kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy)); + frozen.kpower[i] = Rand()*400.0 + 450.0 + 50.0*skill; } sortkl(); // If quadrant needs a starbase, put it in @@ -630,7 +612,7 @@ void newqad(int shutup) { // Check for RNZ if (irhere > 0 && klhere == 0 && basex == 0) { neutz = 1; - if (damage[DRADIO] <= 0.0) { + if (frozen.damage[DRADIO] <= 0.0) { skip(1); prout("LT. Uhura- \"Captain, an urgent message."); prout(" I'll put it on audio.\" CLICK"); @@ -645,7 +627,7 @@ void newqad(int shutup) { if (thingx == quadx && thingy == quady) { dropin(IHQUEST, &ix, &iy); thingx = thingy = 0; // Transient - if (damage[DSRSENS] == 0.0) { + if (frozen.damage[DSRSENS] == 0.0) { skip(1); prout("MR. SPOCK- \"Captain, this is most unusual."); prout(" Please examine your short-range scan.\""); @@ -677,23 +659,23 @@ void sortkl(void) { do { sw = FALSE; for (j = 1; j < nenhere; j++) - if (kdist[j] > kdist[j+1]) { + if (frozen.kdist[j] > frozen.kdist[j+1]) { sw = TRUE; - t = kdist[j]; - kdist[j] = kdist[j+1]; - kdist[j+1] = t; - t = kavgd[j]; - kavgd[j] = kavgd[j+1]; - kavgd[j+1] = t; - k = kx[j]; - kx[j] = kx[j+1]; - kx[j+1] = k; - k = ky[j]; - ky[j] = ky[j+1]; - ky[j+1] = k; - t = kpower[j]; - kpower[j] = kpower[j+1]; - kpower[j+1] = t; + t = frozen.kdist[j]; + frozen.kdist[j] = frozen.kdist[j+1]; + frozen.kdist[j+1] = t; + t = frozen.kavgd[j]; + frozen.kavgd[j] = frozen.kavgd[j+1]; + frozen.kavgd[j+1] = t; + k = frozen.kx[j]; + frozen.kx[j] = frozen.kx[j+1]; + frozen.kx[j+1] = k; + k = frozen.ky[j]; + frozen.ky[j] = frozen.ky[j+1]; + frozen.ky[j+1] = k; + t = frozen.kpower[j]; + frozen.kpower[j] = frozen.kpower[j+1]; + frozen.kpower[j+1] = t; } } while (sw); } diff --git a/sst.h b/sst.h index c6a1c87..e0f9bd5 100644 --- a/sst.h +++ b/sst.h @@ -55,8 +55,18 @@ EXTERN struct foo { // but I just didn't think of it back when I started. EXTERN struct foo2 { - char quad[11][11]; // contents of our quadrant - int inkling, + char quad[11][11]; // contents of our quadrant + double kpower[21]; // enemy energy levels + double kdist[21]; // enemy distances + double kavgd[21]; // average distances + double damage[ndevice+1]; // damage encountered + double future[NEVENTS+1]; // future events + char passwd[10]; // Self Destruct password + int kx[21]; // enemy sector locations + int ky[21]; + int starch[9][9]; // star chart + /* members with macro definitions start here */ + int inkling, inbase, incom, instar, @@ -233,26 +243,10 @@ EXTERN struct foo2 { #define isarmed frozen.isarmed // Probe is armed #define nprobes frozen.nprobes // number of probes available -EXTERN int - kx[21], // enemy sector locations - ky[21], - starch[9][9]; // star chart - +/* the following global state doesn't need to be saved */ EXTERN int fromcommandline; // Game start from command line options - - -EXTERN char passwd[10], // Self Destruct password - *device[ndevice+1]; - +EXTERN char *device[ndevice+1]; EXTERN PLANETS nulplanet; // zeroed planet structure - -EXTERN double - kpower[21], // enemy energy levels - kdist[21], // enemy distances - kavgd[21], // average distances - damage[ndevice+1], // damage encountered - future[NEVENTS+1]; // future events - EXTERN int iscore, iskill; // Common PLAQ EXTERN double perdate; -- 2.31.1