From: Eric S. Raymond Date: Mon, 1 Nov 2004 00:23:05 +0000 (+0000) Subject: Another step in consolidating the saved-state globals. X-Git-Tag: 2.0~453 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=48763357ef69f0b711fc332b13e2170ab914d881;p=super-star-trek.git Another step in consolidating the saved-state globals. They all live in one structure now. --- diff --git a/ai.c b/ai.c index 4572d4f..9dcb1a0 100644 --- a/ai.c +++ b/ai.c @@ -6,23 +6,23 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) { iqx = quadx+(lookx+9)/10 - 1; iqy = quady+(looky+9)/10 - 1; if (iqx < 1 || iqx > 8 || iqy < 1 || iqy > 8 || - state.galaxy[iqx][iqy] > 899) + game.state.galaxy[iqx][iqy] > 899) return 0; /* no can do -- neg energy, supernovae, or >8 Klingons */ if (ienm == IHR) return 0; /* Romulans cannot escape! */ if (irun == 0) { /* avoid intruding on another commander's territory */ if (ienm == IHC) { - for (l = 1; l <= state.remcom; l++) - if (state.cx[l]==iqx && state.cy[l]==iqy) return 0; + for (l = 1; l <= game.state.remcom; l++) + if (game.state.cx[l]==iqx && game.state.cy[l]==iqy) return 0; /* refuse to leave if currently attacking starbase */ if (batx==quadx && baty==quady) return 0; } /* don't leave if over 1000 units of energy */ - if (frozen.kpower[loccom] > 1000.) return 0; + if (game.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 (frozen.damage[DSRSENS] == 0.0 || frozen.damage[DLRSENS] == 0.0 || + if (game.damage[DSRSENS] == 0.0 || game.damage[DLRSENS] == 0.0 || condit == IHDOCKED) { proutn("***"); cramen(ienm); @@ -31,32 +31,32 @@ static int tryexit(int lookx, int looky, int ienm, int loccom, int irun) { prout(" (and regains strength)."); } /* handle local matters related to escape */ - 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]; + game.kx[loccom] = game.kx[nenhere]; + game.ky[loccom] = game.ky[nenhere]; + game.kavgd[loccom] = game.kavgd[nenhere]; + game.kpower[loccom] = game.kpower[nenhere]; + game.kdist[loccom] = game.kdist[nenhere]; klhere--; nenhere--; if (condit != IHDOCKED) newcnd(); /* Handle global matters related to escape */ - state.galaxy[quadx][quady] -= 100; - state.galaxy[iqx][iqy] += 100; + game.state.galaxy[quadx][quady] -= 100; + game.state.galaxy[iqx][iqy] += 100; if (ienm==IHS) { ishere=0; iscate=0; ientesc=0; isatb=0; - frozen.future[FSCMOVE]=0.2777+state.date; - frozen.future[FSCDBAS]=1e30; - state.isx=iqx; - state.isy=iqy; + game.future[FSCMOVE]=0.2777+game.state.date; + game.future[FSCDBAS]=1e30; + game.state.isx=iqx; + game.state.isy=iqy; } else { - for (l=1; l<=state.remcom; l++) { - if (state.cx[l]==quadx && state.cy[l]==quady) { - state.cx[l]=iqx; - state.cy[l]=iqy; + for (l=1; l<=game.state.remcom; l++) { + if (game.state.cx[l]==quadx && game.state.cy[l]==quady) { + game.state.cx[l]=iqx; + game.state.cy[l]=iqy; break; } } @@ -78,12 +78,12 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) { (comhere + ishere); double dist1, forces; - dist1 = frozen.kdist[loccom]; + dist1 = game.kdist[loccom]; mdist = dist1 + 0.5; /* Nearest integer distance */ /* If SC, check with spy to see if should hi-tail it */ if (ienm==IHS && - (frozen.kpower[loccom] <= 500.0 || (condit==IHDOCKED && frozen.damage[DPHOTON]==0))) { + (game.kpower[loccom] <= 500.0 || (condit==IHDOCKED && game.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 = frozen.kpower[loccom]+100.0*nenhere+400*(nbaddys-1); + forces = game.kpower[loccom]+100.0*nenhere+400*(nbaddys-1); if (shldup==0) forces += 1000; /* Good for enemy if shield is down! */ - if (frozen.damage[DPHASER] == 0.0 || frozen.damage[DPHOTON] == 0.0) { - if (frozen.damage[DPHASER] != 0) /* phasers damaged */ + if (game.damage[DPHASER] == 0.0 || game.damage[DPHOTON] == 0.0) { + if (game.damage[DPHASER] != 0) /* phasers damaged */ forces += 300.0; else forces -= 0.2*(energy - 2500.0); - if (frozen.damage[DPHOTON] != 0) /* photon torpedoes damaged */ + if (game.damage[DPHOTON] != 0) /* photon torpedoes damaged */ forces += 300.0; else forces -= 50.0*torps; @@ -187,7 +187,7 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) { if (my != 0) my = my*motion < 0 ? -1 : 1; nextx = comx; nexty = comy; - frozen.quad[comx][comy] = IHDOT; + game.quad[comx][comy] = IHDOT; /* main move loop */ for (ll = 1; ll <= nsteps; ll++) { #ifdef DEBUG @@ -218,9 +218,9 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) { looky = nexty + krawly; krawly = -krawly; } - else if (frozen.quad[lookx][looky] != IHDOT) { + else if (game.quad[lookx][looky] != IHDOT) { /* See if we should ram ship */ - if (frozen.quad[lookx][looky] == ship && + if (game.quad[lookx][looky] == ship && (ienm == IHC || ienm == IHS)) { ram(1, ienm, comx, comy); return; @@ -250,17 +250,17 @@ static void movebaddy(int comx, int comy, int loccom, int ienm) { else break; /* done early */ } /* Put commander in place within same quadrant */ - frozen.quad[nextx][nexty] = ienm; + game.quad[nextx][nexty] = ienm; if (nextx != comx || nexty != comy) { /* it moved */ - frozen.kx[loccom] = nextx; - frozen.ky[loccom] = nexty; - frozen.kdist[loccom] = frozen.kavgd[loccom] = + game.kx[loccom] = nextx; + game.ky[loccom] = nexty; + game.kdist[loccom] = game.kavgd[loccom] = sqrt(square(sectx-nextx)+square(secty-nexty)); - if (frozen.damage[DSRSENS] == 0 || condit == IHDOCKED) { + if (game.damage[DSRSENS] == 0 || condit == IHDOCKED) { proutn("***"); cramen(ienm); - if (frozen.kdist[loccom] < dist1) proutn(" advances to"); + if (game.kdist[loccom] < dist1) proutn(" advances to"); else proutn(" retreats to"); cramlc(2, nextx, nexty); skip(1); @@ -278,17 +278,17 @@ void movcom(void) { /* Figure out which Klingon is the commander (or Supercommander) and do move */ if (comhere) for (i = 1; i <= nenhere; i++) { - ix = frozen.kx[i]; - iy = frozen.ky[i]; - if (frozen.quad[ix][iy] == IHC) { + ix = game.kx[i]; + iy = game.ky[i]; + if (game.quad[ix][iy] == IHC) { movebaddy(ix, iy, i, IHC); break; } } if (ishere) for (i = 1; i <= nenhere; i++) { - ix = frozen.kx[i]; - iy = frozen.ky[i]; - if (frozen.quad[ix][iy] == IHS) { + ix = game.kx[i]; + iy = game.ky[i]; + if (game.quad[ix][iy] == IHS) { movebaddy(ix, iy, i, IHS); break; } @@ -297,10 +297,10 @@ 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 = 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]); + ix = game.kx[i]; + iy = game.ky[i]; + if (game.quad[ix][iy] == IHK || game.quad[ix][iy] == IHR) + movebaddy(ix, iy, i, game.quad[ix][iy]); } sortkl(); @@ -311,33 +311,33 @@ static int checkdest(int iqx, int iqy, int flag, int *ipage) { if ((iqx==quadx && iqy==quady) || iqx < 1 || iqx > 8 || iqy < 1 || iqy > 8 || - state.galaxy[iqx][iqy] > 899) return 1; + game.state.galaxy[iqx][iqy] > 899) return 1; if (flag) { /* Avoid quadrants with bases if we want to avoid Enterprise */ - for (i = 1; i <= state.rembase; i++) - if (state.baseqx[i]==iqx && state.baseqy[i]==iqy) return 1; + for (i = 1; i <= game.state.rembase; i++) + if (game.state.baseqx[i]==iqx && game.state.baseqy[i]==iqy) return 1; } /* do the move */ - state.galaxy[state.isx][state.isy] -= 100; - state.isx = iqx; - state.isy = iqy; - state.galaxy[state.isx][state.isy] += 100; + game.state.galaxy[game.state.isx][game.state.isy] -= 100; + game.state.isx = iqx; + game.state.isy = iqy; + game.state.galaxy[game.state.isx][game.state.isy] += 100; if (iscate) { /* SC has scooted, Remove him from current quadrant */ iscate=0; isatb=0; ishere=0; ientesc=0; - frozen.future[FSCDBAS]=1e30; + game.future[FSCDBAS]=1e30; for (i = 1; i <= nenhere; i++) - 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]; + if (game.quad[game.kx[i]][game.ky[i]] == IHS) break; + game.quad[game.kx[i]][game.ky[i]] = IHDOT; + game.kx[i] = game.kx[nenhere]; + game.ky[i] = game.ky[nenhere]; + game.kdist[i] = game.kdist[nenhere]; + game.kavgd[i] = game.kavgd[nenhere]; + game.kpower[i] = game.kpower[nenhere]; klhere--; nenhere--; if (condit!=IHDOCKED) newcnd(); @@ -345,17 +345,17 @@ static int checkdest(int iqx, int iqy, int flag, int *ipage) { } /* check for a helpful planet */ for (i = 1; i <= inplan; i++) { - if (state.plnets[i].x==state.isx && state.plnets[i].y==state.isy && - state.plnets[i].crystals == 1) { + if (game.state.plnets[i].x==game.state.isx && game.state.plnets[i].y==game.state.isy && + game.state.plnets[i].crystals == 1) { /* destroy the planet */ - state.plnets[i] = nulplanet; - state.newstuf[state.isx][state.isy] -= 1; - if (frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED) { + game.state.plnets[i] = nulplanet; + game.state.newstuf[game.state.isx][game.state.isy] -= 1; + if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED) { if (*ipage==0) pause(1); *ipage = 1; prout("Lt. Uhura- \"Captain, Starfleet Intelligence reports"); proutn(" a planet in"); - cramlc(1, state.isx, state.isy); + cramlc(1, game.state.isx, game.state.isy); prout(" has been destroyed"); prout(" by the Super-commander.\""); } @@ -380,39 +380,39 @@ void scom(int *ipage) { #endif /* Decide on being active or passive */ - flag = ((state.killc+state.killk)/(state.date+0.01-indate) < 0.1*skill*(skill+1.0) || - (state.date-indate) < 3.0); + flag = ((game.state.killc+game.state.killk)/(game.state.date+0.01-indate) < 0.1*skill*(skill+1.0) || + (game.state.date-indate) < 3.0); if (iscate==0 && flag) { /* compute move away from Enterprise */ - ideltax = state.isx-quadx; - ideltay = state.isy-quady; + ideltax = game.state.isx-quadx; + ideltay = game.state.isy-quady; if (sqrt(ideltax*(double)ideltax+ideltay*(double)ideltay) > 2.0) { /* circulate in space */ - ideltax = state.isy-quady; - ideltay = quadx-state.isx; + ideltax = game.state.isy-quady; + ideltay = quadx-game.state.isx; } } else { /* compute distances to starbases */ - if (state.rembase <= 0) { + if (game.state.rembase <= 0) { /* nothing left to do */ - frozen.future[FSCMOVE] = 1e30; + game.future[FSCMOVE] = 1e30; return; } - sx = state.isx; - sy = state.isy; - for (i = 1; i <= state.rembase; i++) { + sx = game.state.isx; + sy = game.state.isy; + for (i = 1; i <= game.state.rembase; i++) { basetbl[i] = i; - ibqx = state.baseqx[i]; - ibqy = state.baseqy[i]; + ibqx = game.state.baseqx[i]; + ibqy = game.state.baseqy[i]; bdist[i] = sqrt(square(ibqx-sx) + square(ibqy-sy)); } - if (state.rembase > 1) { + if (game.state.rembase > 1) { /* sort into nearest first order */ int iswitch; do { iswitch = 0; - for (i=1; i < state.rembase-1; i++) { + for (i=1; i < game.state.rembase-1; i++) { if (bdist[i] > bdist[i+1]) { int ti = basetbl[i]; double t = bdist[i]; @@ -429,34 +429,34 @@ void scom(int *ipage) { without too many Klingons, and not already under attack. */ ifindit = iwhichb = 0; - for (i2 = 1; i2 <= state.rembase; i2++) { + for (i2 = 1; i2 <= game.state.rembase; i2++) { i = basetbl[i2]; /* bug in original had it not finding nearest*/ - ibqx = state.baseqx[i]; - ibqy = state.baseqy[i]; + ibqx = game.state.baseqx[i]; + ibqy = game.state.baseqy[i]; if ((ibqx == quadx && ibqy == quady) || (ibqx == batx && ibqy == baty) || - state.galaxy[ibqx][ibqy] > 899) continue; + game.state.galaxy[ibqx][ibqy] > 899) continue; /* if there is a commander, an no other base is appropriate, we will take the one with the commander */ - for (j = 1; j <= state.remcom; j++) { - if (ibqx==state.cx[j] && ibqy==state.cy[j] && ifindit!= 2) { + for (j = 1; j <= game.state.remcom; j++) { + if (ibqx==game.state.cx[j] && ibqy==game.state.cy[j] && ifindit!= 2) { ifindit = 2; iwhichb = i; break; } } - if (j > state.remcom) { /* no commander -- use this one */ + if (j > game.state.remcom) { /* no commander -- use this one */ ifindit = 1; iwhichb = i; break; } } if (ifindit==0) return; /* Nothing suitable -- wait until next time*/ - ibqx = state.baseqx[iwhichb]; - ibqy = state.baseqy[iwhichb]; + ibqx = game.state.baseqx[iwhichb]; + ibqy = game.state.baseqy[iwhichb]; /* decide how to move toward base */ - ideltax = ibqx - state.isx; - ideltay = ibqy - state.isy; + ideltax = ibqx - game.state.isx; + ideltay = ibqy - game.state.isy; } /* Maximum movement is 1 quadrant in either or both axis */ if (ideltax > 1) ideltax = 1; @@ -465,62 +465,62 @@ void scom(int *ipage) { if (ideltay < -1) ideltay = -1; /* try moving in both x and y directions */ - iqx = state.isx + ideltax; - iqy = state.isy + ideltax; + iqx = game.state.isx + ideltax; + iqy = game.state.isy + ideltax; if (checkdest(iqx, iqy, flag, ipage)) { /* failed -- try some other maneuvers */ if (ideltax==0 || ideltay==0) { /* attempt angle move */ if (ideltax != 0) { - iqy = state.isy + 1; + iqy = game.state.isy + 1; if (checkdest(iqx, iqy, flag, ipage)) { - iqy = state.isy - 1; + iqy = game.state.isy - 1; checkdest(iqx, iqy, flag, ipage); } } else { - iqx = state.isx + 1; + iqx = game.state.isx + 1; if (checkdest(iqx, iqy, flag, ipage)) { - iqx = state.isx - 1; + iqx = game.state.isx - 1; checkdest(iqx, iqy, flag, ipage); } } } else { /* try moving just in x or y */ - iqy = state.isy; + iqy = game.state.isy; if (checkdest(iqx, iqy, flag, ipage)) { - iqy = state.isy + ideltay; - iqx = state.isx; + iqy = game.state.isy + ideltay; + iqx = game.state.isx; checkdest(iqx, iqy, flag, ipage); } } } /* check for a base */ - if (state.rembase == 0) { - frozen.future[FSCMOVE] = 1e30; + if (game.state.rembase == 0) { + game.future[FSCMOVE] = 1e30; } - else for (i=1; i<=state.rembase; i++) { - ibqx = state.baseqx[i]; - ibqy = state.baseqy[i]; - if (ibqx==state.isx && ibqy == state.isy && state.isx != batx && state.isy != baty) { + else for (i=1; i<=game.state.rembase; i++) { + ibqx = game.state.baseqx[i]; + ibqy = game.state.baseqy[i]; + if (ibqx==game.state.isx && ibqy == game.state.isy && game.state.isx != batx && game.state.isy != baty) { /* attack the base */ if (flag) return; /* no, don't attack base! */ iseenit = 0; isatb=1; - 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) + game.future[FSCDBAS] = game.state.date + 1.0 +2.0*Rand(); + if (batx != 0) game.future[FSCDBAS] += game.future[FCDBAS]-game.state.date; + if (game.damage[DRADIO] > 0 && condit != IHDOCKED) return; /* no warning */ iseenit = 1; if (*ipage == 0) pause(1); *ipage=1; proutn("Lt. Uhura- \"Captain, the starbase in"); - cramlc(1, state.isx, state.isy); + cramlc(1, game.state.isx, game.state.isy); skip(1); prout(" reports that it is under attack from the Klingon Super-commander."); proutn(" It can survive until stardate "); - cramf(frozen.future[FSCDBAS], 0, 1); + cramf(game.future[FSCDBAS], 0, 1); prout(" .\""); if (resting==0) return; prout("Mr. Spock- \"Captain, shall we cancel the rest period?\""); @@ -536,14 +536,14 @@ void scom(int *ipage) { idebug==0 && #endif (Rand() > 0.2 || - (frozen.damage[DRADIO] > 0.0 && condit != IHDOCKED) || - frozen.starch[state.isx][state.isy] > 0)) + (game.damage[DRADIO] > 0.0 && condit != IHDOCKED) || + game.starch[game.state.isx][game.state.isy] > 0)) return; if (*ipage==0) pause(1); *ipage = 1; prout("Lt. Uhura- \"Captain, Starfleet Intelligence reports"); proutn(" the Super-commander is in"); - cramlc(1, state.isx, state. isy); + cramlc(1, game.state.isx, game.state. isy); prout(".\""); return; } @@ -572,15 +572,15 @@ void movetho(void) { } /* Do nothing if we are blocked */ - if (frozen.quad[idx][idy]!= IHDOT && frozen.quad[idx][idy]!= IHWEB) return; - frozen.quad[ithx][ithy] = IHWEB; + if (game.quad[idx][idy]!= IHDOT && game.quad[idx][idy]!= IHWEB) return; + game.quad[ithx][ithy] = IHWEB; if (ithx != idx) { /* move in x axis */ im = fabs((double)idx - ithx)/((double)idx - ithx); while (ithx != idx) { ithx += im; - if (frozen.quad[ithx][ithy]==IHDOT) frozen.quad[ithx][ithy] = IHWEB; + if (game.quad[ithx][ithy]==IHDOT) game.quad[ithx][ithy] = IHWEB; } } else if (ithy != idy) { @@ -588,20 +588,20 @@ void movetho(void) { im = fabs((double)idy - ithy)/((double)idy - ithy); while (ithy != idy) { ithy += im; - if (frozen.quad[ithx][ithy]==IHDOT) frozen.quad[ithx][ithy] = IHWEB; + if (game.quad[ithx][ithy]==IHDOT) game.quad[ithx][ithy] = IHWEB; } } - frozen.quad[ithx][ithy] = IHT; + game.quad[ithx][ithy] = IHT; /* check to see if all holes plugged */ for (i = 1; i < 11; i++) { - if (frozen.quad[1][i]!=IHWEB && frozen.quad[1][i]!=IHT) return; - if (frozen.quad[10][i]!=IHWEB && frozen.quad[10][i]!=IHT) return; - if (frozen.quad[i][1]!=IHWEB && frozen.quad[i][1]!=IHT) return; - if (frozen.quad[i][10]!=IHWEB && frozen.quad[i][10]!=IHT) return; + if (game.quad[1][i]!=IHWEB && game.quad[1][i]!=IHT) return; + if (game.quad[10][i]!=IHWEB && game.quad[10][i]!=IHT) return; + if (game.quad[i][1]!=IHWEB && game.quad[i][1]!=IHT) return; + if (game.quad[i][10]!=IHWEB && game.quad[i][10]!=IHT) return; } /* All plugged up -- Tholian splits */ - frozen.quad[ithx][ithy]=IHWEB; + game.quad[ithx][ithy]=IHWEB; dropin(IHBLANK, &dum, &my); crmena(1,IHT, 2, ithx, ithy); prout(" completes web."); diff --git a/battle.c b/battle.c index 11a1ca1..1f043c6 100644 --- a/battle.c +++ b/battle.c @@ -14,7 +14,7 @@ void doshield(int i) { action = NRG; else { chew(); - if (frozen.damage[DSHIELD]) { + if (game.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 (frozen.damage[DSHIELD]) { + else if (game.damage[DSHIELD]) { prout("Shields damaged and down."); return; } @@ -158,12 +158,12 @@ 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 (frozen.damage[l] < 0) continue; + if (game.damage[l] < 0) continue; extradm = (10.0*type*Rand()+1.0)*damfac; - frozen.damage[l] += Time + extradm; /* Damage for at least time of travel! */ + game.damage[l] += Time + extradm; /* Damage for at least time of travel! */ } shldup = 0; - if (state.remkl) { + if (game.state.remkl) { pause(2); dreprt(); } @@ -197,7 +197,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit) { proutn(" - "); cramf(y, 0, 1); proutn(" "); - iquad=frozen.quad[ix][iy]; + iquad=game.quad[ix][iy]; if (iquad==IHDOT) continue; /* hit something */ skip(1); @@ -223,11 +223,11 @@ void torpedo(double course, double r, int inx, int iny, double *hit) { jx=ix+xx+0.5; jy=iy+yy+0.5; if (jx<1 || jx>10 || jy<1 ||jy > 10) return; - if (frozen.quad[jx][jy]==IHBLANK) { + if (game.quad[jx][jy]==IHBLANK) { finish(FHOLE); return; } - if (frozen.quad[jx][jy]!=IHDOT) { + if (game.quad[jx][jy]!=IHDOT) { /* can't move into object */ return; } @@ -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==frozen.kx[ll] && iy==frozen.ky[ll]) break; - kp = fabs(frozen.kpower[ll]); + if (ix==game.kx[ll] && iy==game.ky[ll]) break; + kp = fabs(game.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; - frozen.kpower[ll] -= (frozen.kpower[ll]<0 ? -h1 : h1); - if (frozen.kpower[ll] == 0) { + game.kpower[ll] -= (game.kpower[ll]<0 ? -h1 : h1); + if (game.kpower[ll] == 0) { deadkl(ix, iy, iquad, ix, iy); return; } @@ -274,47 +274,47 @@ void torpedo(double course, double r, int inx, int iny, double *hit) { prout(" damaged but not destroyed."); return; } - if (frozen.quad[jx][jy]==IHBLANK) { + if (game.quad[jx][jy]==IHBLANK) { prout(" buffeted into black hole."); deadkl(ix, iy, iquad, jx, jy); return; } - if (frozen.quad[jx][jy]!=IHDOT) { + if (game.quad[jx][jy]!=IHDOT) { /* can't move into object */ prout(" damaged but not destroyed."); return; } prout(" damaged--"); - frozen.kx[ll] = jx; - frozen.ky[ll] = jy; + game.kx[ll] = jx; + game.ky[ll] = jy; shoved = 1; break; case IHB: /* Hit a base */ prout("***STARBASE DESTROYED.."); - 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]; - state.baseqy[ll]=state.baseqy[state.rembase]; + if (game.starch[quadx][quady] < 0) game.starch[quadx][quady] = 0; + for (ll=1; ll<=game.state.rembase; ll++) { + if (game.state.baseqx[ll]==quadx && game.state.baseqy[ll]==quady) { + game.state.baseqx[ll]=game.state.baseqx[game.state.rembase]; + game.state.baseqy[ll]=game.state.baseqy[game.state.rembase]; break; } } - frozen.quad[ix][iy]=IHDOT; - state.rembase--; + game.quad[ix][iy]=IHDOT; + game.state.rembase--; basex=basey=0; - state.galaxy[quadx][quady] -= 10; - state.basekl++; + game.state.galaxy[quadx][quady] -= 10; + game.state.basekl++; newcnd(); return; case IHP: /* Hit a planet */ crmena(1, iquad, 2, ix, iy); prout(" destroyed."); - state.nplankl++; - state.newstuf[quadx][quady] -= 1; - state.plnets[iplnet] = nulplanet; + game.state.nplankl++; + game.state.newstuf[quadx][quady] -= 1; + game.state.plnets[iplnet] = nulplanet; iplnet = 0; plnetx = plnety = 0; - frozen.quad[ix][iy] = IHDOT; + game.quad[ix][iy] = IHDOT; if (landed==1) { /* captain parishes on planet */ finish(FDPLANET); @@ -337,7 +337,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit) { proutn("Mr. Spock-"); prouts(" \"Facinating!\""); skip(1); - frozen.quad[ix][iy] = IHDOT; + game.quad[ix][iy] = IHDOT; return; case IHBLANK: /* Black hole */ skip(1); @@ -357,7 +357,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit) { h1 = fabs(h1); if (h1 >= 600) { prout(" destroyed."); - frozen.quad[ix][iy] = IHDOT; + game.quad[ix][iy] = IHDOT; ithere = 0; ithx = ithy = 0; return; @@ -367,7 +367,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit) { return; } prout(" disappears."); - frozen.quad[ix][iy] = IHWEB; + game.quad[ix][iy] = IHWEB; ithere = ithx = ithy = 0; { int dum, my; @@ -385,13 +385,13 @@ void torpedo(double course, double r, int inx, int iny, double *hit) { break; } if (shoved) { - frozen.quad[jx][jy]=iquad; - frozen.quad[ix][iy]=IHDOT; + game.quad[jx][jy]=iquad; + game.quad[ix][iy]=IHDOT; proutn(" displaced by blast to"); cramlc(2, jx, jy); skip(1); for (ll=1; ll<=nenhere; ll++) - frozen.kdist[ll] = frozen.kavgd[ll] = sqrt(square(sectx-frozen.kx[ll])+square(secty-frozen.ky[ll])); + game.kdist[ll] = game.kavgd[ll] = sqrt(square(sectx-game.kx[ll])+square(secty-game.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 (frozen.damage[j] < 0.0 || (j == DSHUTTL && iscraft != 1) || + } while (game.damage[j] < 0.0 || (j == DSHUTTL && iscraft != 1) || j == DDRAY); cdam[l] = j; extradm = (hit*damfac)/(ncrit*(75.0+25.0*Rand())); - frozen.damage[j] += extradm; + game.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 (frozen.damage[DSHIELD] && shldup) { + if (game.damage[DSHIELD] && shldup) { prout("***Shields knocked down."); shldup=0; } @@ -461,15 +461,15 @@ void attack(int k) { skip(1); if (skill <= 2) i = 2; for (l=1; l <= nenhere; l++) { - if (frozen.kpower[l] < 0) continue; /* too weak to attack */ + if (game.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 (frozen.kpower[l] < 500) r *= 0.25; - jx = frozen.kx[l]; - jy = frozen.ky[l]; - iquad = frozen.quad[jx][jy]; + if (game.kpower[l] < 500) r *= 0.25; + jx = game.kx[l]; + jy = game.ky[l]; + iquad = game.quad[jx][jy]; itflag = (iquad == IHK && r > 0.0005) || k == 0 || (iquad==IHC && r > 0.015) || (iquad==IHR && r > 0.3) || @@ -479,24 +479,24 @@ 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 = frozen.kpower[l]*pow(dustfac,frozen.kavgd[l]); - frozen.kpower[l] *= 0.75; + hit = game.kpower[l]*pow(dustfac,game.kavgd[l]); + game.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 (frozen.damage[DSRSENS] <= 0.0) { + if (game.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*frozen.kpower[l]*r; + r += 0.002*game.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 || + if (game.state.remkl==0) finish(FWON); /* Klingons did themselves in! */ + if (game.state.galaxy[quadx][quady] == 1000 || alldone) return; /* Supernova or finished */ if (hit == 0) continue; } @@ -519,11 +519,11 @@ void attack(int k) { ihurt = 1; cramf(hit, 0, 2); proutn(" unit hit"); - if ((frozen.damage[DSRSENS] > 0 && itflag) || skill <= 2) { + if ((game.damage[DSRSENS] > 0 && itflag) || skill <= 2) { proutn(" on the "); crmshp(); } - if (frozen.damage[DSRSENS] <= 0.0 && itflag) { + if (game.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 (frozen.damage[DSHIELD] == 0) proutn("down, "); + else if (game.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++) - frozen.kavgd[l] = frozen.kdist[l]; + game.kavgd[l] = game.kdist[l]; sortkl(); return; } @@ -590,10 +590,10 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) { /* Decide what kind of enemy it is and update approriately */ if (type == IHR) { /* chalk up a Romulan */ - state.newstuf[quadx][quady] -= 10; + game.state.newstuf[quadx][quady] -= 10; irhere--; - state.nromkl++; - state.nromrem--; + game.state.nromkl++; + game.state.nromrem--; } else if (type == IHT) { /* Killed a Tholian */ @@ -601,62 +601,62 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) { } else { /* Some type of a Klingon */ - state.galaxy[quadx][quady] -= 100; + game.state.galaxy[quadx][quady] -= 100; klhere--; - state.remkl--; + game.state.remkl--; switch (type) { case IHC: comhere = 0; - for (i=1; i<=state.remcom; i++) - if (state.cx[i]==quadx && state.cy[i]==quady) break; - state.cx[i] = state.cx[state.remcom]; - state.cy[i] = state.cy[state.remcom]; - state.cx[state.remcom] = 0; - state.cy[state.remcom] = 0; - state.remcom--; - frozen.future[FTBEAM] = 1e30; - if (state.remcom != 0) - frozen.future[FTBEAM] = state.date + expran(1.0*incom/state.remcom); - state.killc++; + for (i=1; i<=game.state.remcom; i++) + if (game.state.cx[i]==quadx && game.state.cy[i]==quady) break; + game.state.cx[i] = game.state.cx[game.state.remcom]; + game.state.cy[i] = game.state.cy[game.state.remcom]; + game.state.cx[game.state.remcom] = 0; + game.state.cy[game.state.remcom] = 0; + game.state.remcom--; + game.future[FTBEAM] = 1e30; + if (game.state.remcom != 0) + game.future[FTBEAM] = game.state.date + expran(1.0*incom/game.state.remcom); + game.state.killc++; break; case IHK: - state.killk++; + game.state.killk++; break; case IHS: - state.nscrem = ishere = state.isx = state.isy = isatb = iscate = 0; - state.nsckill = 1; - frozen.future[FSCMOVE] = frozen.future[FSCDBAS] = 1e30; + game.state.nscrem = ishere = game.state.isx = game.state.isy = isatb = iscate = 0; + game.state.nsckill = 1; + game.future[FSCMOVE] = game.future[FSCDBAS] = 1e30; break; } } /* For each kind of enemy, finish message to player */ prout(" destroyed."); - frozen.quad[ix][iy] = IHDOT; - if (state.remkl==0) return; + game.quad[ix][iy] = IHDOT; + if (game.state.remkl==0) return; - state.remtime = state.remres/(state.remkl + 4*state.remcom); + game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom); if (type == IHT) return; /* Remove enemy ship from arrays describing local conditions */ for (i=1; i<=nenhere; i++) - if (frozen.kx[i]==ix && frozen.ky[i]==iy) break; + if (game.kx[i]==ix && game.ky[i]==iy) break; nenhere--; if (i <= nenhere) { for (j=i; j<=nenhere; j++) { - 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]; + game.kx[j] = game.kx[j+1]; + game.ky[j] = game.ky[j+1]; + game.kpower[j] = game.kpower[j+1]; + game.kavgd[j] = game.kdist[j] = game.kdist[j+1]; } } - 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; + game.kx[nenhere+1] = 0; + game.ky[nenhere+1] = 0; + game.kdist[nenhere+1] = 0; + game.kavgd[nenhere+1] = 0; + game.kpower[nenhere+1] = 0; return; } @@ -688,7 +688,7 @@ void photon(void) { ididit = 0; - if (frozen.damage[DPHOTON]) { + if (game.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."); - frozen.damage[DPHOTON] = damfac*(1.0+2.0*Rand()); + game.damage[DPHOTON] = damfac*(1.0+2.0*Rand()); break; } } @@ -814,9 +814,9 @@ void photon(void) { proutn("Torpedo track- "); } torpedo(course[i], r, sectx, secty, &dummy); - if (alldone || state.galaxy[quadx][quady]==1000) return; + if (alldone || game.state.galaxy[quadx][quady]==1000) return; } - if (state.remkl==0) finish(FWON); + if (game.state.remkl==0) finish(FWON); } @@ -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.\""); - frozen.damage[DPHASER] = damfac*(1.0 + Rand()) * (1.0+chekbrn); + game.damage[DPHASER] = damfac*(1.0 + Rand()) * (1.0+chekbrn); } } } @@ -884,19 +884,19 @@ void phasers(void) { skip(1); /* SR sensors and Computer */ - if (frozen.damage[DSRSENS]+frozen.damage[DCOMPTR] > 0) ipoop = 0; + if (game.damage[DSRSENS]+game.damage[DCOMPTR] > 0) ipoop = 0; if (condit == IHDOCKED) { prout("Phasers can't be fired through base shields."); chew(); return; } - if (frozen.damage[DPHASER] != 0) { + if (game.damage[DPHASER] != 0) { prout("Phaser control damaged."); chew(); return; } if (shldup) { - if (frozen.damage[DSHCTRL]) { + if (game.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(frozen.kpower[i])/(phasefac*pow(0.90,frozen.kdist[i])); + hits[i] = fabs(game.kpower[i])/(phasefac*pow(0.90,game.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 (frozen.damage[DCOMPTR]!=0) + if (game.damage[DCOMPTR]!=0) prout("Battle comuter damaged, manual file only."); else { skip(1); @@ -1058,8 +1058,8 @@ void phasers(void) { case MANUAL: rpow = 0.0; for (k = 1; k <= nenhere;) { - int ii = frozen.kx[k], jj = frozen.ky[k]; - int ienm = frozen.quad[ii][jj]; + int ii = game.kx[k], jj = game.ky[k]; + int ienm = game.quad[ii][jj]; if (msgflag) { proutn("Energy available= "); cramf(energy-.006-(ifast?200:0), 0, 2); @@ -1067,7 +1067,7 @@ void phasers(void) { msgflag = 0; rpow = 0.0; } - if (frozen.damage[DSRSENS] && !(abs(sectx-ii) < 2 && abs(secty-jj) < 2) && + if (game.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(frozen.kpower[k])/(phasefac*pow(0.9,frozen.kdist[k])))* + int irec=(fabs(game.kpower[k])/(phasefac*pow(0.9,game.kdist[k])))* (1.01+0.05*Rand()) + 1.0; kz = k; proutn("("); @@ -1176,26 +1176,26 @@ 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,frozen.kdist[kk]); - kpini = frozen.kpower[kk]; + hit = wham*pow(dustfac,game.kdist[kk]); + kpini = game.kpower[kk]; kp = fabs(kpini); if (phasefac*hit < kp) kp = phasefac*hit; - frozen.kpower[kk] -= (frozen.kpower[kk] < 0 ? -kp: kp); - kpow = frozen.kpower[kk]; - ii = frozen.kx[kk]; - jj = frozen.ky[kk]; + game.kpower[kk] -= (game.kpower[kk] < 0 ? -kp: kp); + kpow = game.kpower[kk]; + ii = game.kx[kk]; + jj = game.ky[kk]; if (hit > 0.005) { cramf(hit, 0, 2); proutn(" unit hit on "); } else proutn("Very small hit on "); - ienm = frozen.quad[ii][jj]; + ienm = game.quad[ii][jj]; crmena(0,ienm,2,ii,jj); skip(1); if (kpow == 0) { deadkl(ii, jj, ienm, ii, jj); - if (state.remkl==0) finish(FWON); + if (game.state.remkl==0) finish(FWON); if (alldone) return; kk--; /* don't do the increment */ } @@ -1206,7 +1206,7 @@ void hittem(double *hits) { cramlc(2,ii,jj); skip(1); prout(" has just lost its firepower.\""); - frozen.kpower[kk] = -kpow; + game.kpower[kk] = -kpow; } } return; diff --git a/events.c b/events.c index 99591de..1fad713 100644 --- a/events.c +++ b/events.c @@ -4,19 +4,19 @@ void events(void) { int ictbeam=0, ipage=0, istract=0, line, i, j, k, l, ixhold, iyhold; - double fintim = state.date + Time, datemin, xtime, repair, yank; + double fintim = game.state.date + Time, datemin, xtime, repair, yank; #ifdef DEBUG if (idebug) prout("EVENTS"); #endif - if (stdamtim == 1e30 && frozen.damage[DRADIO] != 0.0) { + if (stdamtim == 1e30 && game.damage[DRADIO] != 0.0) { /* chart will no longer be updated because radio is dead */ - stdamtim = state.date; + stdamtim = game.state.date; for (i=1; i <= 8 ; i++) for (j=1; j <= 8; j++) - if (frozen.starch[i][j] == 1) frozen.starch[i][j] = state.galaxy[i][j]+1000; + if (game.starch[i][j] == 1) game.starch[i][j] = game.state.galaxy[i][j]+1000; } for (;;) { @@ -25,44 +25,44 @@ void events(void) { if (alldone) return; datemin = fintim; for (l=1; l<=NEVENTS; l++) - if (frozen.future[l] <= datemin) { + if (game.future[l] <= datemin) { line = l; - datemin = frozen.future[l]; + datemin = game.future[l]; } - xtime = datemin-state.date; - state.date = datemin; + xtime = datemin-game.state.date; + game.state.date = datemin; /* Decrement Federation resources and recompute remaining time */ - state.remres -= (state.remkl+4*state.remcom)*xtime; - state.remtime = state.remres/(state.remkl+4*state.remcom); - if (state.remtime <=0) { + game.state.remres -= (game.state.remkl+4*game.state.remcom)*xtime; + game.state.remtime = game.state.remres/(game.state.remkl+4*game.state.remcom); + if (game.state.remtime <=0) { finish(FDEPLETE); return; } /* Is life support adequate? */ - if (frozen.damage[DLIFSUP] && condit != IHDOCKED) { - if (lsupres < xtime && frozen.damage[DLIFSUP] > lsupres) { + if (game.damage[DLIFSUP] && condit != IHDOCKED) { + if (lsupres < xtime && game.damage[DLIFSUP] > lsupres) { finish(FLIFESUP); return; } lsupres -= xtime; - if (frozen.damage[DLIFSUP] <= xtime) lsupres = inlsr; + if (game.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 (frozen.damage[l] > 0.0 && l != DDRAY) - frozen.damage[l] -= (frozen.damage[l]-repair > 0.0 ? repair : frozen.damage[l]); + if (game.damage[l] > 0.0 && l != DDRAY) + game.damage[l] -= (game.damage[l]-repair > 0.0 ? repair : game.damage[l]); /* If radio repaired, update star chart and attack reports */ - if (stdamtim != 1e30 && frozen.damage[DRADIO] == 0.0) { + if (stdamtim != 1e30 && game.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 (frozen.starch[i][j] > 999) frozen.starch[i][j] = 1; + if (game.starch[i][j] > 999) game.starch[i][j] = 1; if (iseenit==0) { attakreport(); iseenit = 1; @@ -78,37 +78,37 @@ void events(void) { if (ipage==0) pause(1); ipage=1; snova(0,0); - frozen.future[FSNOVA] = state.date + expran(0.5*intime); - if (state.galaxy[quadx][quady] == 1000) return; + game.future[FSNOVA] = game.state.date + expran(0.5*intime); + if (game.state.galaxy[quadx][quady] == 1000) return; break; case FSPY: /* Check with spy to see if S.C. should tractor beam */ - if (state.nscrem == 0 || + if (game.state.nscrem == 0 || ictbeam+istract > 0 || condit==IHDOCKED || isatb==1 || iscate==1) return; if (ientesc || (energy < 2000 && torps < 4 && shield < 1250) || - (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))) { + (game.damage[DPHASER]>0 && (game.damage[DPHOTON]>0 || torps < 4)) || + (game.damage[DSHIELD] > 0 && + (energy < 2500 || game.damage[DPHASER] > 0) && + (torps < 5 || game.damage[DPHOTON] > 0))) { /* Tractor-beam her! */ istract=1; - yank = square(state.isx-quadx) + square(state.isy-quady); + yank = square(game.state.isx-quadx) + square(game.state.isy-quady); /*********TBEAM CODE***********/ } else return; case FTBEAM: /* Tractor beam */ if (line==FTBEAM) { - if (state.remcom == 0) { - frozen.future[FTBEAM] = 1e30; + if (game.state.remcom == 0) { + game.future[FTBEAM] = 1e30; break; } - i = Rand()*state.remcom+1.0; - yank = square(state.cx[i]-quadx) + square(state.cy[i]-quady); + i = Rand()*game.state.remcom+1.0; + yank = square(game.state.cx[i]-quadx) + square(game.state.cy[i]-quady); if (istract || condit == IHDOCKED || yank == 0) { /* Drats! Have to reschedule */ - frozen.future[FTBEAM] = state.date + Time + - expran(1.5*intime/state.remcom); + game.future[FTBEAM] = game.state.date + Time + + expran(1.5*intime/game.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."); - frozen.damage[DSHUTTL] = -10; + game.damage[DSHUTTL] = -10; iscraft = -1; } else { @@ -143,12 +143,12 @@ void events(void) { } } if (line==0) { - quadx = state.isx; - quady = state.isy; + quadx = game.state.isx; + quady = game.state.isy; } else { - quadx = state.cx[i]; - quady = state.cy[i]; + quadx = game.state.cx[i]; + quady = game.state.cy[i]; } iran10(§x, §y); crmshp(); @@ -158,11 +158,11 @@ void events(void) { cramlc(2, sectx, secty); skip(1); if (resting) { - prout("(Remainder of rest/repair period cancellestate.)"); + prout("(Remainder of rest/repair period cancellegame.state.)"); resting = 0; } if (shldup==0) { - if (frozen.damage[DSHIELD]==0 && shield > 0) { + if (game.damage[DSHIELD]==0 && shield > 0) { doshield(2); /* Shldsup */ shldchg=0; } @@ -170,47 +170,47 @@ void events(void) { } newqad(0); /* Adjust finish time to time of tractor beaming */ - fintim = state.date+Time; - if (state.remcom <= 0) frozen.future[FTBEAM] = 1e30; - else frozen.future[FTBEAM] = state.date+Time+expran(1.5*intime/state.remcom); + fintim = game.state.date+Time; + if (game.state.remcom <= 0) game.future[FTBEAM] = 1e30; + else game.future[FTBEAM] = game.state.date+Time+expran(1.5*intime/game.state.remcom); break; case FSNAP: /* Snapshot of the universe (for time warp) */ - snapsht = state; - state.snap = 1; - frozen.future[FSNAP] = state.date + expran(0.5 * intime); + game.snapsht = game.state; + game.state.snap = 1; + game.future[FSNAP] = game.state.date + expran(0.5 * intime); break; case FBATTAK: /* Commander attacks starbase */ - if (state.remcom==0 || state.rembase==0) { + if (game.state.remcom==0 || game.state.rembase==0) { /* no can do */ - frozen.future[FBATTAK] = frozen.future[FCDBAS] = 1e30; + game.future[FBATTAK] = game.future[FCDBAS] = 1e30; break; } i = 0; - for (j=1; j<=state.rembase; j++) { - for (k=1; k<=state.remcom; k++) - if (state.baseqx[j]==state.cx[k] && state.baseqy[j]==state.cy[k] && - (state.baseqx[j]!=quadx || state.baseqy[j]!=quady) && - (state.baseqx[j]!=state.isx || state.baseqy[j]!=state.isy)) { + for (j=1; j<=game.state.rembase; j++) { + for (k=1; k<=game.state.remcom; k++) + if (game.state.baseqx[j]==game.state.cx[k] && game.state.baseqy[j]==game.state.cy[k] && + (game.state.baseqx[j]!=quadx || game.state.baseqy[j]!=quady) && + (game.state.baseqx[j]!=game.state.isx || game.state.baseqy[j]!=game.state.isy)) { i = 1; break; } if (i == 1) break; } - if (j>state.rembase) { + if (j>game.state.rembase) { /* no match found -- try later */ - frozen.future[FBATTAK] = state.date + expran(0.3*intime); - frozen.future[FCDBAS] = 1e30; + game.future[FBATTAK] = game.state.date + expran(0.3*intime); + game.future[FCDBAS] = 1e30; break; } /* commander + starbase combination found -- launch attack */ - batx = state.baseqx[j]; - baty = state.baseqy[j]; - frozen.future[FCDBAS] = state.date+1.0+3.0*Rand(); + batx = game.state.baseqx[j]; + baty = game.state.baseqy[j]; + game.future[FCDBAS] = game.state.date+1.0+3.0*Rand(); if (isatb) /* extra time if SC already attacking */ - frozen.future[FCDBAS] += frozen.future[FSCDBAS]-state.date; - frozen.future[FBATTAK] = frozen.future[FCDBAS] +expran(0.3*intime); + game.future[FCDBAS] += game.future[FSCDBAS]-game.state.date; + game.future[FBATTAK] = game.future[FCDBAS] +expran(0.3*intime); iseenit = 0; - if (frozen.damage[DRADIO] != 0.0 && + if (game.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(frozen.future[FCDBAS],1,1); + cramf(game.future[FCDBAS],1,1); prout(".\""); if (resting) { skip(1); @@ -234,21 +234,21 @@ void events(void) { } break; case FSCDBAS: /* Supercommander destroys base */ - frozen.future[FSCDBAS] = 1e30; + game.future[FSCDBAS] = 1e30; isatb = 2; - if (state.galaxy[state.isx][state.isy]%100 < 10) break; /* WAS RETURN! */ + if (game.state.galaxy[game.state.isx][game.state.isy]%100 < 10) break; /* WAS RETURN! */ ixhold = batx; iyhold = baty; - batx = state.isx; - baty = state.isy; + batx = game.state.isx; + baty = game.state.isy; case FCDBAS: /* Commander succeeds in destroying base */ if (line==FCDBAS) { - frozen.future[FCDBAS] = 1e30; + game.future[FCDBAS] = 1e30; /* find the lucky pair */ - for (i = 1; i <= state.remcom; i++) - if (state.cx[i]==batx && state.cy[i]==baty) break; - if (i > state.remcom || state.rembase == 0 || - state.galaxy[batx][baty] % 100 < 10) { + for (i = 1; i <= game.state.remcom; i++) + if (game.state.cx[i]==batx && game.state.cy[i]==baty) break; + if (i > game.state.remcom || game.state.rembase == 0 || + game.state.galaxy[batx][baty] % 100 < 10) { /* No action to take after all */ batx = baty = 0; break; @@ -256,18 +256,18 @@ void events(void) { } /* Code merges here for any commander destroying base */ /* Not perfect, but will have to do */ - if (frozen.starch[batx][baty] == -1) frozen.starch[batx][baty] = 0; + if (game.starch[batx][baty] == -1) game.starch[batx][baty] = 0; /* Handle case where base is in same quadrant as starship */ if (batx==quadx && baty==quady) { - if (frozen.starch[batx][baty] > 999) frozen.starch[batx][baty] -= 10; - frozen.quad[basex][basey]= IHDOT; + if (game.starch[batx][baty] > 999) game.starch[batx][baty] -= 10; + game.quad[basex][basey]= IHDOT; basex=basey=0; newcnd(); skip(1); - prout("Spock- \"Captain, I believe the starbase has been destroyestate.\""); + prout("Spock- \"Captain, I believe the starbase has been destroyegame.state.\""); } - else if (state.rembase != 1 && - (frozen.damage[DRADIO] <= 0.0 || condit == IHDOCKED)) { + else if (game.state.rembase != 1 && + (game.damage[DRADIO] <= 0.0 || condit == IHDOCKED)) { /* Get word via subspace radio */ if (ipage==0) pause(1); ipage = 1; @@ -280,13 +280,13 @@ void events(void) { else prout("a Klingon Commander"); } /* Remove Starbase from galaxy */ - state.galaxy[batx][baty] -= 10; - for (i=1; i <= state.rembase; i++) - if (state.baseqx[i]==batx && state.baseqy[i]==baty) { - state.baseqx[i]=state.baseqx[state.rembase]; - state.baseqy[i]=state.baseqy[state.rembase]; + game.state.galaxy[batx][baty] -= 10; + for (i=1; i <= game.state.rembase; i++) + if (game.state.baseqx[i]==batx && game.state.baseqy[i]==baty) { + game.state.baseqx[i]=game.state.baseqx[game.state.rembase]; + game.state.baseqy[i]=game.state.baseqy[game.state.rembase]; } - state.rembase--; + game.state.rembase--; if (isatb == 2) { /* reinstate a commander's base attack */ batx = ixhold; @@ -298,13 +298,13 @@ void events(void) { } break; case FSCMOVE: /* Supercommander moves */ - frozen.future[FSCMOVE] = state.date+0.2777; + game.future[FSCMOVE] = game.state.date+0.2777; if (ientesc+istract==0 && isatb!=1 && (iscate!=1 || justin==1)) scom(&ipage); break; case FDSPROB: /* Move deep space probe */ - frozen.future[FDSPROB] = state.date + 0.01; + game.future[FDSPROB] = game.state.date + 0.01; probex += probeinx; probey += probeiny; i = (int)(probex/10 +0.05); @@ -313,9 +313,9 @@ void events(void) { probecx = i; probecy = j; if (i < 1 || i > 8 || j < 1 || j > 8 || - state.galaxy[probecx][probecy] == 1000) { + game.state.galaxy[probecx][probecy] == 1000) { // Left galaxy or ran into supernova - if (frozen.damage[DRADIO]==0.0 || condit == IHDOCKED) { + if (game.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(".\""); } - frozen.future[FDSPROB] = 1e30; + game.future[FDSPROB] = 1e30; break; } - if (frozen.damage[DRADIO]==0.0 || condit == IHDOCKED) { + if (game.damage[DRADIO]==0.0 || condit == IHDOCKED) { if (ipage==0) pause(1); ipage = 1; skip(1); @@ -340,16 +340,16 @@ void events(void) { } /* Update star chart if Radio is working or have access to radio. */ - if (frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED) - frozen.starch[probecx][probecy] = frozen.damage[DRADIO] > 0.0 ? - state.galaxy[probecx][probecy]+1000 : 1; + if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED) + game.starch[probecx][probecy] = game.damage[DRADIO] > 0.0 ? + game.state.galaxy[probecx][probecy]+1000 : 1; proben--; // One less to travel if (proben == 0 && isarmed && - state.galaxy[probecx][probecy] % 10 > 0) { + game.state.galaxy[probecx][probecy] % 10 > 0) { /* lets blow the sucker! */ snova(1,0); - frozen.future[FDSPROB] = 1e30; - if (state.galaxy[quadx][quady] == 1000) return; + game.future[FDSPROB] = 1e30; + if (game.state.galaxy[quadx][quady] == 1000) return; } break; } @@ -374,7 +374,7 @@ void wait(void) { } origTime = delay = aaitem; if (delay <= 0.0) return; - if (delay >= state.remtime || nenhere != 0) { + if (delay >= game.state.remtime || nenhere != 0) { prout("Are you sure? "); if (ja() == 0) return; } @@ -385,7 +385,7 @@ void wait(void) { do { if (delay <= 0) resting = 0; if (resting == 0) { - cramf(state.remtime, 0, 2); + cramf(game.state.remtime, 0, 2); prout(" stardates left."); return; } @@ -405,8 +405,8 @@ void wait(void) { delay -= temp; /* Repair Deathray if long rest at starbase */ if (origTime-delay >= 9.99 && condit == IHDOCKED) - frozen.damage[DDRAY] = 0.0; - } while (state.galaxy[quadx][quady] != 1000); // leave if quadrant supernovas + game.damage[DDRAY] = 0.0; + } while (game.state.galaxy[quadx][quady] != 1000); // leave if quadrant supernovas resting = 0; Time = 0; @@ -424,11 +424,11 @@ void nova(int ix, int iy) { } /* handle initial nova */ - frozen.quad[ix][iy] = IHDOT; + game.quad[ix][iy] = IHDOT; crmena(1, IHSTAR, 2, ix, iy); prout(" novas."); - state.galaxy[quadx][quady] -= 1; - state.starkl++; + game.state.galaxy[quadx][quady] -= 1; + game.state.starkl++; /* Set up stack to recursively trigger adjacent stars */ bot = top = top2 = 1; @@ -444,7 +444,7 @@ void nova(int ix, int iy) { ii = hits[mm][1]+nn-2; jj = hits[mm][2]+j-2; if (ii < 1 || ii > 10 || jj < 1 || jj > 10) continue; - iquad = frozen.quad[ii][jj]; + iquad = game.quad[ii][jj]; switch (iquad) { // case IHDOT: /* Empty space ends reaction // case IHQUEST: @@ -462,38 +462,38 @@ void nova(int ix, int iy) { top2++; hits[top2][1]=ii; hits[top2][2]=jj; - state.galaxy[quadx][quady] -= 1; - state.starkl++; + game.state.galaxy[quadx][quady] -= 1; + game.state.starkl++; crmena(1, IHSTAR, 2, ii, jj); prout(" novas."); - frozen.quad[ii][jj] = IHDOT; + game.quad[ii][jj] = IHDOT; break; case IHP: /* Destroy planet */ - state.newstuf[quadx][quady] -= 1; - state.nplankl++; + game.state.newstuf[quadx][quady] -= 1; + game.state.nplankl++; crmena(1, IHP, 2, ii, jj); prout(" destroyed."); - state.plnets[iplnet] = nulplanet; + game.state.plnets[iplnet] = nulplanet; iplnet = plnetx = plnety = 0; if (landed == 1) { finish(FPNOVA); return; } - frozen.quad[ii][jj] = IHDOT; + game.quad[ii][jj] = IHDOT; break; case IHB: /* Destroy base */ - state.galaxy[quadx][quady] -= 10; - for (i = 1; i <= state.rembase; i++) - if (state.baseqx[i]==quadx && state.baseqy[i]==quady) break; - state.baseqx[i] = state.baseqx[state.rembase]; - state.baseqy[i] = state.baseqy[state.rembase]; - state.rembase--; + game.state.galaxy[quadx][quady] -= 10; + for (i = 1; i <= game.state.rembase; i++) + if (game.state.baseqx[i]==quadx && game.state.baseqy[i]==quady) break; + game.state.baseqx[i] = game.state.baseqx[game.state.rembase]; + game.state.baseqy[i] = game.state.baseqy[game.state.rembase]; + game.state.rembase--; basex = basey = 0; - state.basekl++; + game.state.basekl++; newcnd(); crmena(1, IHB, 2, ii, jj); prout(" destroyed."); - frozen.quad[ii][jj] = IHDOT; + game.quad[ii][jj] = IHDOT; break; case IHE: /* Buffet ship */ case IHF: @@ -506,7 +506,7 @@ void nova(int ix, int iy) { shield = 0.0; shldup = 0; prout("***Shields knocked out."); - frozen.damage[DSHIELD] += 0.005*damfac*Rand()*diff; + game.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 (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) { + if (game.kx[ll]==ii && game.ky[ll]==jj) break; + game.kpower[ll] -= 800.0; /* If firepower is lost, die */ + if (game.kpower[ll] <= 0.0) { deadkl(ii, jj, iquad, ii, jj); break; } @@ -541,7 +541,7 @@ void nova(int ix, int iy) { skip(1); break; } - iquad1 = frozen.quad[newcx][newcy]; + iquad1 = game.quad[newcx][newcy]; if (iquad1 == IHBLANK) { proutn(", blasted into "); crmena(0, IHBLANK, 2, newcx, newcy); @@ -556,12 +556,12 @@ void nova(int ix, int iy) { } proutn(", buffeted to"); cramlc(2, newcx, newcy); - frozen.quad[ii][jj] = IHDOT; - frozen.quad[newcx][newcy] = iquad; - frozen.kx[ll] = newcx; - frozen.ky[ll] = newcy; - frozen.kavgd[ll] = sqrt(square(sectx-newcx)+square(secty-newcy)); - frozen.kdist[ll] = frozen.kavgd[ll]; + game.quad[ii][jj] = IHDOT; + game.quad[newcx][newcy] = iquad; + game.kx[ll] = newcx; + game.ky[ll] = newcy; + game.kavgd[ll] = sqrt(square(sectx-newcx)+square(secty-newcy)); + game.kdist[ll] = game.kavgd[ll]; skip(1); break; } @@ -610,14 +610,14 @@ void snova(int insx, int insy) { left of universe */ for (nqx = 1; nqx<=8; nqx++) { for (nqy = 1; nqy<=8; nqy++) { - stars += state.galaxy[nqx][nqy] % 10; + stars += game.state.galaxy[nqx][nqy] % 10; } } if (stars == 0) return; /* nothing to supernova exists */ num = Rand()*stars + 1; for (nqx = 1; nqx<=8; nqx++) { for (nqy = 1; nqy<=8; nqy++) { - num -= state.galaxy[nqx][nqy] % 10; + num -= game.state.galaxy[nqx][nqy] % 10; if (num <= 0) break; } if (num <=0) break; @@ -635,10 +635,10 @@ 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 (frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED) { + if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED) { skip(1); proutn("Message from Starfleet Command Stardate "); - cramf(state.date, 0, 1); + cramf(game.state.date, 0, 1); skip(1); proutn(" Supernova in"); cramlc(1, nqx, nqy); @@ -648,10 +648,10 @@ void snova(int insx, int insy) { else { /* we are in the quadrant! */ insipient = 1; - num = Rand()* (state.galaxy[nqx][nqy]%10) + 1; + num = Rand()* (game.state.galaxy[nqx][nqy]%10) + 1; for (nsx=1; nsx < 10; nsx++) { for (nsy=1; nsy < 10; nsy++) { - if (frozen.quad[nsx][nsy]==IHSTAR) { + if (game.quad[nsx][nsy]==IHSTAR) { num--; if (num==0) break; } @@ -682,75 +682,75 @@ void snova(int insx, int insy) { } } /* destroy any Klingons in supernovaed quadrant */ - num=state.galaxy[nqx][nqy]; + num=game.state.galaxy[nqx][nqy]; kldead = num/100; comdead = iscdead = 0; - if (nqx==state.isx && nqy == state.isy) { + if (nqx==game.state.isx && nqy == game.state.isy) { /* did in the Supercommander! */ - state.nscrem = state.isx = state.isy = isatb = iscate = 0; + game.state.nscrem = game.state.isx = game.state.isy = isatb = iscate = 0; iscdead = 1; - frozen.future[FSCMOVE] = frozen.future[FSCDBAS] = 1e30; + game.future[FSCMOVE] = game.future[FSCDBAS] = 1e30; } - state.remkl -= kldead; - if (state.remcom) { - int maxloop = state.remcom, l; + game.state.remkl -= kldead; + if (game.state.remcom) { + int maxloop = game.state.remcom, l; for (l = 1; l <= maxloop; l++) { - if (state.cx[l] == nqx && state.cy[l] == nqy) { - state.cx[l] = state.cx[state.remcom]; - state.cy[l] = state.cy[state.remcom]; - state.cx[state.remcom] = state.cy[state.remcom] = 0; - state.remcom--; + if (game.state.cx[l] == nqx && game.state.cy[l] == nqy) { + game.state.cx[l] = game.state.cx[game.state.remcom]; + game.state.cy[l] = game.state.cy[game.state.remcom]; + game.state.cx[game.state.remcom] = game.state.cy[game.state.remcom] = 0; + game.state.remcom--; kldead--; comdead++; - if (state.remcom==0) frozen.future[FTBEAM] = 1e30; + if (game.state.remcom==0) game.future[FTBEAM] = 1e30; break; } } } /* destroy Romulans and planets in supernovaed quadrant */ - num = state.newstuf[nqx][nqy]; - state.newstuf[nqx][nqy] = 0; + num = game.state.newstuf[nqx][nqy]; + game.state.newstuf[nqx][nqy] = 0; nrmdead = num/10; - state.nromrem -= nrmdead; + game.state.nromrem -= nrmdead; npdead = num - nrmdead*10; if (npdead) { int l; for (l = 1; l <= inplan; l++) - if (state.plnets[l].x == nqx && state.plnets[l].y == nqy) { - state.plnets[l] = nulplanet; + if (game.state.plnets[l].x == nqx && game.state.plnets[l].y == nqy) { + game.state.plnets[l] = nulplanet; } } /* Destroy any base in supernovaed quadrant */ - if (state.rembase) { - int maxloop = state.rembase, l; + if (game.state.rembase) { + int maxloop = game.state.rembase, l; for (l = 1; l <= maxloop; l++) - if (state.baseqx[l]==nqx && state.baseqy[l]==nqy) { - state.baseqx[l] = state.baseqx[state.rembase]; - state.baseqy[l] = state.baseqy[state.rembase]; - state.baseqx[state.rembase] = state.baseqy[state.rembase] = 0; - state.rembase--; + if (game.state.baseqx[l]==nqx && game.state.baseqy[l]==nqy) { + game.state.baseqx[l] = game.state.baseqx[game.state.rembase]; + game.state.baseqy[l] = game.state.baseqy[game.state.rembase]; + game.state.baseqx[game.state.rembase] = game.state.baseqy[game.state.rembase] = 0; + game.state.rembase--; break; } } /* If starship caused supernova, tally up destruction */ if (insx) { - num = state.galaxy[nqx][nqy] % 100; - state.starkl += num % 10; - state.basekl += num/10; - state.killk += kldead; - state.killc += comdead; - state.nromkl += nrmdead; - state.nplankl += npdead; - state.nsckill += iscdead; + num = game.state.galaxy[nqx][nqy] % 100; + game.state.starkl += num % 10; + game.state.basekl += num/10; + game.state.killk += kldead; + game.state.killc += comdead; + game.state.nromkl += nrmdead; + game.state.nplankl += npdead; + game.state.nsckill += iscdead; } /* mark supernova in galaxy and in star chart */ if ((quadx == nqx && quady == nqy) || - frozen.damage[DRADIO] == 0 || + game.damage[DRADIO] == 0 || condit == IHDOCKED) - frozen.starch[nqx][nqy] = 1; - state.galaxy[nqx][nqy] = 1000; + game.starch[nqx][nqy] = 1; + game.state.galaxy[nqx][nqy] = 1000; /* If supernova destroys last klingons give special message */ - if (state.remkl==0 && (nqx != quadx || nqy != quady)) { + if (game.state.remkl==0 && (nqx != quadx || nqy != quady)) { skip(2); if (insx == 0) prout("Lucky you!"); proutn("A supernova in"); diff --git a/finish.c b/finish.c index f355b5a..e0fb221 100644 --- a/finish.c +++ b/finish.c @@ -5,7 +5,7 @@ void dstrct() { /* Finish with a BANG! */ chew(); - if (frozen.damage[DCOMPTR] != 0.0) { + if (game.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(frozen.passwd, citem) != 0) { + if (strcmp(game.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 (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]); + if (game.kpower[l]*game.kdist[l] <= whammo) + deadkl(game.kx[l],game.ky[l], game.quad[game.kx[l]][game.ky[l]], game.kx[l], game.ky[l]); l++; } } @@ -68,26 +68,26 @@ void finish(FINTYPE ifin) { int igotit = 0; alldone = 1; skip(3); - printf("It is stardate %.1f .\n\n", state.date); + printf("It is stardate %.1f .\n\n", game.state.date); switch (ifin) { case FWON: // Game has been won - if (state.nromrem != 0) + if (game.state.nromrem != 0) printf("The remaining %d Romulans surrender to Starfleet Command.\n", - state.nromrem); + game.state.nromrem); prout("You have smashed the Klingon invasion fleet and saved"); prout("the Federation."); gamewon=1; if (alive) { double badpt; - badpt = 5.*state.starkl + casual + 10.*state.nplankl + - 45.*nhelp+100.*state.basekl; + badpt = 5.*game.state.starkl + casual + 10.*game.state.nplankl + + 45.*nhelp+100.*game.state.basekl; if (ship == IHF) badpt += 100.0; else if (ship == 0) badpt += 200.0; if (badpt < 100.0) badpt = 0.0; // Close enough! - if (state.date-indate < 5.0 || + if (game.state.date-indate < 5.0 || // killsPerDate >= RateMax - (state.killk+state.killc+state.nsckill)/(state.date-indate) >= + (game.state.killk+game.state.killc+game.state.nsckill)/(game.state.date-indate) >= 0.1*skill*(skill+1.0) + 0.1 + 0.008*badpt) { skip(1); prout("In fact, you have done so well that Starfleet Command"); @@ -105,7 +105,7 @@ void finish(FINTYPE ifin) { prout("promotes you to Commodore Emeritus."); skip(1); prout("Now that you think you're really good, try playing"); - prout("the \"Emeritus\" frozen. It will splatter your ego."); + prout("the \"Emeritus\" game. It will splatter your ego."); break; case 5: skip(1); @@ -150,7 +150,7 @@ void finish(FINTYPE ifin) { prout("conquered. Your starship is now Klingon property,"); prout("and you are put on trial as a war criminal. On the"); proutn("basis of your record, you are "); - if (state.remkl*3.0 > inkling) { + if (game.state.remkl*3.0 > inkling) { prout("aquitted."); skip(1); prout("LIVE LONG AND PROSPER."); @@ -275,9 +275,9 @@ void finish(FINTYPE ifin) { if (ship==IHF) ship= 0; else if (ship == IHE) ship = IHF; alive = 0; - if (state.remkl != 0) { - double goodies = state.remres/inresor; - double baddies = (state.remkl + 2.0*state.remcom)/(inkling+2.0*incom); + if (game.state.remkl != 0) { + double goodies = game.state.remres/inresor; + double baddies = (game.state.remkl + 2.0*game.state.remcom)/(inkling+2.0*incom); if (goodies/baddies >= 1.0+0.5*Rand()) { prout("As a result of your actions, a treaty with the Klingon"); prout("Empire has been signed. The terms of the treaty are"); @@ -303,54 +303,54 @@ void finish(FINTYPE ifin) { } void score(void) { - double timused = state.date - indate; + double timused = game.state.date - indate; int ithperd, iwon, klship; pause(0); iskill = skill; - if ((timused == 0 || state.remkl != 0) && timused < 5.0) timused = 5.0; - perdate = (state.killc + state.killk + state.nsckill)/timused; + if ((timused == 0 || game.state.remkl != 0) && timused < 5.0) timused = 5.0; + perdate = (game.state.killc + game.state.killk + game.state.nsckill)/timused; ithperd = 500*perdate + 0.5; iwon = 0; if (gamewon) iwon = 100*skill; if (ship == IHE) klship = 0; else if (ship == IHF) klship = 1; else klship = 2; - if (gamewon == 0) state.nromrem = 0; // None captured if no win - iscore = 10*state.killk + 50*state.killc + ithperd + iwon - - 100*state.basekl - 100*klship - 45*nhelp -5*state.starkl - casual - + 20*state.nromkl + 200*state.nsckill - 10*state.nplankl + state.nromrem; + if (gamewon == 0) game.state.nromrem = 0; // None captured if no win + iscore = 10*game.state.killk + 50*game.state.killc + ithperd + iwon + - 100*game.state.basekl - 100*klship - 45*nhelp -5*game.state.starkl - casual + + 20*game.state.nromkl + 200*game.state.nsckill - 10*game.state.nplankl + game.state.nromrem; if (alive == 0) iscore -= 200; skip(2); prout("Your score --"); - if (state.nromkl) + if (game.state.nromkl) printf("%6d Romulans destroyed %5d\n", - state.nromkl,20*state.nromkl); - if (state.nromrem) + game.state.nromkl,20*game.state.nromkl); + if (game.state.nromrem) printf("%6d Romulans captured %5d\n", - state.nromrem, state.nromrem); - if (state.killk) + game.state.nromrem, game.state.nromrem); + if (game.state.killk) printf("%6d ordinary Klingons destroyed %5d\n", - state.killk, 10*state.killk); - if (state.killc) + game.state.killk, 10*game.state.killk); + if (game.state.killc) printf("%6d Klingon commanders destroyed %5d\n", - state.killc, 50*state.killc); - if (state.nsckill) + game.state.killc, 50*game.state.killc); + if (game.state.nsckill) printf("%6d Super-Commander destroyed %5d\n", - state.nsckill, 200*state.nsckill); + game.state.nsckill, 200*game.state.nsckill); if (ithperd) printf("%6.2f Klingons per stardate %5d\n", perdate, ithperd); - if (state.starkl) + if (game.state.starkl) printf("%6d stars destroyed by your action %5d\n", - state.starkl, -5*state.starkl); - if (state.nplankl) + game.state.starkl, -5*game.state.starkl); + if (game.state.nplankl) printf("%6d planets destroyed by your action %5d\n", - state.nplankl, -10*state.nplankl); - if (state.basekl) + game.state.nplankl, -10*game.state.nplankl); + if (game.state.basekl) printf("%6d bases destroyed by your action %5d\n", - state.basekl, -100*state.basekl); + game.state.basekl, -100*game.state.basekl); if (nhelp) printf("%6d calls for help from starbase %5d\n", nhelp, -45*nhelp); diff --git a/moving.c b/moving.c index 0f53518..2fdefb6 100644 --- a/moving.c +++ b/moving.c @@ -24,14 +24,14 @@ void move(void) { deltax /= bigger; /* If tractor beam is to occur, don't move full distance */ - if (state.date+Time >= frozen.future[FTBEAM]) { + if (game.state.date+Time >= game.future[FTBEAM]) { trbeam = 1; condit = IHRED; - dist = dist*(frozen.future[FTBEAM]-state.date)/Time + 0.1; - Time = frozen.future[FTBEAM] - state.date + 1e-5; + dist = dist*(game.future[FTBEAM]-game.state.date)/Time + 0.1; + Time = game.future[FTBEAM] - game.state.date + 1e-5; } /* Move within the quadrant */ - frozen.quad[sectx][secty] = IHDOT; + game.quad[sectx][secty] = IHDOT; x = sectx; y = secty; n = 10.0*dist*bigger+0.5; @@ -46,11 +46,11 @@ void move(void) { if (nenhere != 0 && iattak != 2) { newcnd(); for (l = 1; l <= nenhere; 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]); + 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]); } - if (state.galaxy[quadx][quady] != 1000) attack(0); + if (game.state.galaxy[quadx][quady] != 1000) attack(0); if (alldone) return; } /* compute final position -- new quadrant and sector */ @@ -101,11 +101,11 @@ void move(void) { proutn("\nEntering"); cramlc(1, quadx, quady); skip(1); - frozen.quad[sectx][secty] = ship; + game.quad[sectx][secty] = ship; newqad(0); return; } - iquad = frozen.quad[ix][iy]; + iquad = game.quad[ix][iy]; if (iquad != IHDOT) { /* object encountered in flight path */ stopegy = 50.0*dist/Time; @@ -170,18 +170,18 @@ void move(void) { finaly = secty; label100: /* No quadrant change -- compute new avg enemy distances */ - frozen.quad[sectx][secty] = ship; + game.quad[sectx][secty] = ship; if (nenhere) { for (l = 1; l <= nenhere; 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]); - frozen.kdist[l] = finald; + 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]); + game.kdist[l] = finald; } sortkl(); - if (state.galaxy[quadx][quady] != 1000 && iattak == 0) + if (game.state.galaxy[quadx][quady] != 1000 && iattak == 0) attack(0); - for (l = 1 ; l <= nenhere; l++) frozen.kavgd[l] = frozen.kdist[l]; + for (l = 1 ; l <= nenhere; l++) game.kavgd[l] = game.kdist[l]; } newcnd(); iattak = 0; @@ -210,7 +210,7 @@ void dock(void) { torps = intorps; lsupres = inlsr; if (stdamtim != 1e30 && - (frozen.future[FCDBAS] < 1e30 || isatb == 1) && iseenit == 0) { + (game.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 (frozen.damage[DCOMPTR]) { + if (game.damage[DCOMPTR]) { if (isprobe) prout("Computer damaged; manual navigation only"); else @@ -410,7 +410,7 @@ void impuls(void) { double power; ididit = 0; - if (frozen.damage[DIMPULS]) { + if (game.damage[DIMPULS]) { chew(); skip(1); prout("Engineer Scott- \"The impulse engines are damaged, Sir.\""); @@ -443,7 +443,7 @@ void impuls(void) { } /* Make sure enough time is left for the trip */ Time = dist/0.095; - if (Time >= state.remtime) { + if (Time >= game.state.remtime) { prout("First Officer Spock- \"Captain, our speed under impulse"); prout("power is only 0.95 sectors per stardate. Are you sure"); prout("we dare spend the time?\""); @@ -467,13 +467,13 @@ void warp(int i) { if (i!=2) { /* Not WARPX entry */ ididit = 0; - if (frozen.damage[DWARPEN] > 10.0) { + if (game.damage[DWARPEN] > 10.0) { chew(); skip(1); prout("Engineer Scott- \"The impulse engines are damaged, Sir.\""); return; } - if (frozen.damage[DWARPEN] > 0.0 && warpfac > 4.0) { + if (game.damage[DWARPEN] > 0.0 && warpfac > 4.0) { chew(); skip(1); prout("Engineer Scott- \"Sorry, Captain. Until this damage"); @@ -515,11 +515,11 @@ void warp(int i) { /* Make sure enough time is left for the trip */ Time = 10.0*dist/wfacsq; - if (Time >= 0.8*state.remtime) { + if (Time >= 0.8*game.state.remtime) { skip(1); prout("First Officer Spock- \"Captain, I compute that such"); proutn(" a trip would require approximately "); - cramf(100.0*Time/state.remtime, 0, 2); + cramf(100.0*Time/game.state.remtime, 0, 2); prout(" percent of our"); prout(" remaining time. Are you sure this is wise?\""); if (ja() == 0) { ididit = 0; return;} @@ -567,7 +567,7 @@ void warp(int i) { y += deltay; iy = y +0.5; if (iy < 1 || iy > 10) break; - if (frozen.quad[ix][iy] != IHDOT) { + if (game.quad[ix][iy] != IHDOT) { blooey = 0; twarp = 0; } @@ -584,7 +584,7 @@ void warp(int i) { Time = 10.0*dist/wfacsq; if (twarp) timwrp(); if (blooey) { - frozen.damage[DWARPEN] = damfac*(3.0*Rand()+1.0); + game.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 (frozen.damage[DWARPEN] > 10.0) { + if (game.damage[DWARPEN] > 10.0) { prout("Warp engines inoperative."); return; } - if (frozen.damage[DWARPEN] > 0.0 && aaitem > 4.0) { + if (game.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 (frozen.damage[DTRANSP]) { + if (game.damage[DTRANSP]) { finish(FPNOVA); return; } @@ -703,10 +703,10 @@ void atover(int igrab) { crmshp(); skip(1); prout("safely out of quadrant."); - frozen.starch[quadx][quady] = frozen.damage[DRADIO] > 0.0 ? state.galaxy[quadx][quady]+1000:1; + game.starch[quadx][quady] = game.damage[DRADIO] > 0.0 ? game.state.galaxy[quadx][quady]+1000:1; /* Try to use warp engines */ - if (frozen.damage[DWARPEN]) { + if (game.damage[DWARPEN]) { skip(1); prout("Warp engines damaged."); finish(FSNOVAED); @@ -735,37 +735,37 @@ void atover(int igrab) { return; } /* Repeat if another snova */ - } while (state.galaxy[quadx][quady] == 1000); - if (state.remkl==0) finish(FWON); /* Snova killed remaining enemy. */ + } while (game.state.galaxy[quadx][quady] == 1000); + if (game.state.remkl==0) finish(FWON); /* Snova killed remaining enemy. */ } void timwrp() { int l, ll, gotit; prout("***TIME WARP ENTERED."); - if (state.snap && Rand() < 0.5) { + if (game.state.snap && Rand() < 0.5) { /* Go back in time */ proutn("You are traveling backwards in time "); - cramf(state.date-snapsht.date, 0, 2); + cramf(game.state.date-game.snapsht.date, 0, 2); prout(" stardates."); - state = snapsht; - state.snap = 0; - if (state.remcom) { - frozen.future[FTBEAM] = state.date + expran(intime/state.remcom); - frozen.future[FBATTAK] = state.date + expran(0.3*intime); - } - frozen.future[FSNOVA] = state.date + expran(0.5*intime); - frozen.future[FSNAP] = state.date +expran(0.25*state.remtime); /* next snapshot will + game.state = game.snapsht; + game.state.snap = 0; + if (game.state.remcom) { + game.future[FTBEAM] = game.state.date + expran(intime/game.state.remcom); + game.future[FBATTAK] = game.state.date + expran(0.3*intime); + } + game.future[FSNOVA] = game.state.date + expran(0.5*intime); + game.future[FSNAP] = game.state.date +expran(0.25*game.state.remtime); /* next snapshot will be sooner */ - if (state.nscrem) frozen.future[FSCMOVE] = 0.2777; + if (game.state.nscrem) game.future[FSCMOVE] = 0.2777; isatb = 0; - frozen.future[FCDBAS] = frozen.future[FSCDBAS] = 1e30; + game.future[FCDBAS] = game.future[FSCDBAS] = 1e30; batx = baty = 0; /* Make sure Galileo is consistant -- Snapshot may have been taken when on planet, which would give us two Galileos! */ gotit = 0; for (l = 1; l <= inplan; l++) { - if (state.plnets[l].known == 2) { + if (game.state.plnets[l].known == 2) { gotit = 1; if (iscraft==1 && ship==IHE) { prout("Checkov- \"Security reports the Galileo has disappeared, Sir!"); @@ -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 && frozen.damage[DSHUTTL] >= 0.0) { + if (iscraft==0 && gotit==0 && game.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 (frozen.damage[DRADIO]==0.0 || stdamtim > state.date) { + if (game.damage[DRADIO]==0.0 || stdamtim > game.state.date) { for (l = 1; l <= 8; l++) for (ll = 1; ll <= 8; ll++) - if (frozen.starch[l][ll] > 1) - frozen.starch[l][ll]=frozen.damage[DRADIO]>0.0 ? state.galaxy[l][ll]+1000 :1; + if (game.starch[l][ll] > 1) + game.starch[l][ll]=game.damage[DRADIO]>0.0 ? game.state.galaxy[l][ll]+1000 :1; prout("Spock has reconstructed a correct star chart from memory"); - if (frozen.damage[DRADIO] > 0.0) stdamtim = state.date; + if (game.damage[DRADIO] > 0.0) stdamtim = game.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 */ - frozen.future[FTBEAM] += Time; - frozen.damage[DRADIO] += Time; + game.future[FTBEAM] += Time; + game.damage[DRADIO] += Time; } newqad(0); } @@ -816,16 +816,16 @@ void probe(void) { prout("Ye Faerie Queene has no deep space probes."); return; } - if (frozen.damage[DDSP] != 0.0) { + if (game.damage[DDSP] != 0.0) { chew(); skip(1); prout("Engineer Scott- \"The probe launcher is damaged, Sir.\""); return; } - if (frozen.future[FDSPROB] != 1e30) { + if (game.future[FDSPROB] != 1e30) { chew(); skip(1); - if (frozen.damage[DRADIO] != 0 && condit != IHDOCKED) { + if (game.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; - frozen.future[FDSPROB] = state.date + 0.01; // Time to move one sector + game.future[FDSPROB] = game.state.date + 0.01; // Time to move one sector prout("Ensign Chekov- \"The deep space probe is launched, Captain.\""); return; } @@ -886,11 +886,11 @@ void help(void) { prout("Lt. Uhura- \"But Captain, we're already docked.\""); return; } - if (frozen.damage[DRADIO] != 0) { + if (game.damage[DRADIO] != 0) { prout("Subspace radio damaged."); return; } - if (state.rembase==0) { + if (game.state.rembase==0) { prout("Lt. Uhura- \"Captain, I'm not getting any response from Starbase.\""); return; } @@ -908,20 +908,20 @@ void help(void) { } else { ddist = 1e30; - for (l = 1; l <= state.rembase; l++) { - xdist=10.0*sqrt(square(state.baseqx[l]-quadx)+square(state.baseqy[l]-quady)); + for (l = 1; l <= game.state.rembase; l++) { + xdist=10.0*sqrt(square(game.state.baseqx[l]-quadx)+square(game.state.baseqy[l]-quady)); if (xdist < ddist) { ddist = xdist; line = l; } } /* Since starbase not in quadrant, set up new quadrant */ - quadx = state.baseqx[line]; - quady = state.baseqy[line]; + quadx = game.state.baseqx[line]; + quady = game.state.baseqy[line]; newqad(1); } /* dematerialize starship */ - frozen.quad[sectx][secty]=IHDOT; + game.quad[sectx][secty]=IHDOT; proutn("Starbase in"); cramlc(1, quadx, quady); proutn(" responds--"); @@ -949,12 +949,12 @@ void help(void) { for (l = 1; l <= 5; l++) { ix = basex+3.0*Rand()-1; iy = basey+3.0*Rand()-1; - if (ix>=1 && ix<=10 && iy>=1 && iy<=10 && frozen.quad[ix][iy]==IHDOT) { + if (ix>=1 && ix<=10 && iy>=1 && iy<=10 && game.quad[ix][iy]==IHDOT) { /* found one -- finish up */ prout("succeeds."); sectx=ix; secty=iy; - frozen.quad[ix][iy]=ship; + game.quad[ix][iy]=ship; dock(); skip(1); prout("Lt. Uhura- \"Captain, we made it!\""); diff --git a/os2.c b/os2.c index c6a7835..ca0eb54 100644 --- a/os2.c +++ b/os2.c @@ -23,8 +23,8 @@ int getch(void) { struct termio oldstate, newstate; ioctl(0,TCGETA,&oldstate); newstate = oldstate; - newstate.c_iflag = 0; - newstate.c_lflag = 0; + newgame.state.c_iflag = 0; + newgame.state.c_lflag = 0; ioctl(0,TCSETA,&newstate); read(0, &chbuf, 1); ioctl(0,TCSETA,&oldstate); diff --git a/planets.c b/planets.c index ea9aa12..b95761f 100644 --- a/planets.c +++ b/planets.c @@ -11,7 +11,7 @@ static int consumeTime(void) { ididit = 1; #if 0 /* Don't wory about this */ - if (future[FTBEAM] <= state.date+Time && state.remcom != 0 && condit != IHDOCKED) { + if (future[FTBEAM] <= game.state.date+Time && game.state.remcom != 0 && condit != IHDOCKED) { /* We are about to be tractor beamed -- operation fails */ return 1; } @@ -21,7 +21,7 @@ static int consumeTime(void) { events(); /* Used to avoid if future[FSCMOVE] within time */ // future[FSNOVA] = asave; /*fails if game over, quadrant super-novas or we've moved to new quadrant*/ - if (alldone || state.galaxy[quadx][quady] == 1000 || justin != 0) return 1; + if (alldone || game.state.galaxy[quadx][quady] == 1000 || justin != 0) return 1; return 0; } @@ -32,22 +32,22 @@ void preport(void) { prout("Spock- \"Planet report follows, Captain.\""); skip(1); for (i = 1; i <= inplan; i++) { - if (state.plnets[i].known + if (game.state.plnets[i].known #ifdef DEBUG - || ( idebug && state.plnets[i].x !=0) + || ( idebug && game.state.plnets[i].x !=0) #endif ) { iknow = 1; #ifdef DEBUG - if (idebug && state.plnets[i].known==0) proutn("(Unknown) "); + if (idebug && game.state.plnets[i].known==0) proutn("(Unknown) "); #endif - cramlc(1, state.plnets[i].x, state.plnets[i].y); + cramlc(1, game.state.plnets[i].x, game.state.plnets[i].y); proutn(" class "); - proutn(classes[state.plnets[i].pclass]); + proutn(classes[game.state.plnets[i].pclass]); proutn(" "); - if (state.plnets[i].crystals == 0) proutn("no "); + if (game.state.plnets[i].crystals == 0) proutn("no "); prout("dilithium crystals present."); - if (state.plnets[i].known==2) + if (game.state.plnets[i].known==2) prout(" Shuttle Craft Galileo on surface."); } } @@ -64,7 +64,7 @@ void orbit(void) { prout("Already in standard orbit."); return; } - if (frozen.damage[DWARPEN] != 0 && frozen.damage[DIMPULS] != 0) { + if (game.damage[DWARPEN] != 0 && game.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 (frozen.damage[DSRSENS] != 0.0) { + if (game.damage[DSRSENS] != 0.0) { prout("Short range sensors damaged."); return; } @@ -102,23 +102,23 @@ void sensor(void) { proutn(" Planet at"); cramlc(2, plnetx, plnety); proutn(" is of class "); - proutn(classes[state.plnets[iplnet].pclass]); + proutn(classes[game.state.plnets[iplnet].pclass]); prout("."); - if (state.plnets[iplnet].known==2) + if (game.state.plnets[iplnet].known==2) prout(" Sensors show Galileo still on surface."); proutn(" Readings indicate"); - if (state.plnets[iplnet].crystals == 0) proutn(" no"); + if (game.state.plnets[iplnet].crystals == 0) proutn(" no"); prout(" dilithium crystals present.\""); - if (state.plnets[iplnet].known == 0) state.plnets[iplnet].known = 1; + if (game.state.plnets[iplnet].known == 0) game.state.plnets[iplnet].known = 1; return; } void beam(void) { chew(); skip(1); - if (frozen.damage[DTRANSP] != 0) { + if (game.damage[DTRANSP] != 0) { prout("Transporter damaged."); - if (frozen.damage[DSHUTTL]==0 && (state.plnets[iplnet].known==2 || iscraft == 1)) { + if (game.damage[DSHUTTL]==0 && (game.state.plnets[iplnet].known==2 || iscraft == 1)) { skip(1); prout("Spock- \"May I suggest the shuttle craft, Sir?\" "); if (ja() != 0) shuttle(); @@ -134,7 +134,7 @@ void beam(void) { prout("Impossible to transport through shields."); return; } - if (state.plnets[iplnet].known==0) { + if (game.state.plnets[iplnet].known==0) { prout("Spock- \"Captain, we have no information on this planet"); prout(" and Starfleet Regulations clearly state that in this situation"); prout(" you may not go down.\""); @@ -142,7 +142,7 @@ void beam(void) { } if (landed==1) { /* Coming from planet */ - if (state.plnets[iplnet].known==2) { + if (game.state.plnets[iplnet].known==2) { proutn("Spock- \"Wouldn't you rather take the Galileo?\" "); if (ja() != 0) { chew(); @@ -159,7 +159,7 @@ void beam(void) { } else { /* Going to planet */ - if (state.plnets[iplnet].crystals==0) { + if (game.state.plnets[iplnet].crystals==0) { prout("Spock- \"Captain, I fail to see the logic in"); prout(" exploring a planet with no dilithium crystals."); proutn(" Are you sure this is wise?\" "); @@ -188,7 +188,7 @@ void beam(void) { skip(2); prout("Transport complete."); landed = -landed; - if (landed==1 && state.plnets[iplnet].known==2) { + if (landed==1 && game.state.plnets[iplnet].known==2) { prout("The shuttle craft Galileo is here!"); } if (landed!=1 && imine==1) { @@ -208,7 +208,7 @@ void mine(void) { prout("Mining party not on planet."); return; } - if (state.plnets[iplnet].crystals == 0) { + if (game.state.plnets[iplnet].crystals == 0) { prout("No dilithium crystals on this planet."); return; } @@ -223,7 +223,7 @@ void mine(void) { prout("there's no reason to mine more at this time."); return; } - Time = (0.1+0.2*Rand())*state.plnets[iplnet].pclass; + Time = (0.1+0.2*Rand())*game.state.plnets[iplnet].pclass; if (consumeTime()) return; prout("Mining operation complete."); imine = 1; @@ -285,14 +285,14 @@ void shuttle(void) { chew(); skip(1); ididit = 0; - if(frozen.damage[DSHUTTL] != 0.0) { - if (frozen.damage[DSHUTTL] == -1.0) { - if (inorbit && state.plnets[iplnet].known == 2) + if(game.damage[DSHUTTL] != 0.0) { + if (game.damage[DSHUTTL] == -1.0) { + if (inorbit && game.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 (frozen.damage[DSHUTTL] > 0) + else if (game.damage[DSHUTTL] > 0) prout("The Galileo is damaged."); else prout("Shuttle craft is now serving Big Macs."); return; @@ -302,11 +302,11 @@ void shuttle(void) { prout(" not in standard orbit."); return; } - if ((state.plnets[iplnet].known != 2) && iscraft != 1) { + if ((game.state.plnets[iplnet].known != 2) && iscraft != 1) { prout("Shuttle craft not currently available."); return; } - if (landed==-1 && state.plnets[iplnet].known==2) { + if (landed==-1 && game.state.plnets[iplnet].known==2) { prout("You will have to beam down to retrieve the shuttle craft."); return; } @@ -314,17 +314,17 @@ void shuttle(void) { prout("Shuttle craft cannot pass through shields."); return; } - if (state.plnets[iplnet].known==0) { + if (game.state.plnets[iplnet].known==0) { prout("Spock- \"Captain, we have no information on this planet"); prout(" and Starfleet Regulations clearly state that in this situation"); prout(" you may not fly down.\""); return; } Time = 3.0e-5*height; - if (Time >= 0.8*state.remtime) { + if (Time >= 0.8*game.state.remtime) { prout("First Officer Spock- \"Captain, I compute that such"); prout(" a maneuver would require approximately "); - cramf(100*Time/state.remtime,0,4); + cramf(100*Time/game.state.remtime,0,4); prout("% of our"); prout("remaining time."); prout("Are you sure this is wise?\" "); @@ -337,7 +337,7 @@ void shuttle(void) { /* Kirk on planet */ if (iscraft==1) { /* Galileo on ship! */ - if (frozen.damage[DTRANSP]==0) { + if (game.damage[DTRANSP]==0) { proutn("Spock- \"Would you rather use the transporter?\" "); if (ja() != 0) { beam(); @@ -351,7 +351,7 @@ void shuttle(void) { iscraft = 0; skip(1); if (consumeTime()) return; - state.plnets[iplnet].known=2; + game.state.plnets[iplnet].known=2; prout("Trip complete."); return; } @@ -361,7 +361,7 @@ void shuttle(void) { prout("shuttle craft for the trip back to the Enterprise."); skip(1); prout("The short hop begins . . ."); - state.plnets[iplnet].known=1; + game.state.plnets[iplnet].known=1; icraft = 1; skip(1); landed = -1; @@ -388,7 +388,7 @@ void shuttle(void) { icraft = 1; iscraft = 0; if (consumeTime()) return; - state.plnets[iplnet].known = 2; + game.state.plnets[iplnet].known = 2; landed = 1; icraft = 0; prout("Trip complete"); @@ -411,7 +411,7 @@ void deathray(void) { prout("Sulu- \"But Sir, there are no enemies in this quadrant.\""); return; } - if (frozen.damage[DDRAY] > 0.0) { + if (game.damage[DDRAY] > 0.0) { prout("Death Ray is damaged."); return; } @@ -437,16 +437,16 @@ void deathray(void) { prouts("Sulu- \"Captain! It's working!\""); skip(2); while (nenhere > 0) - deadkl(frozen.kx[1],frozen.ky[1],frozen.quad[frozen.kx[1]][frozen.ky[1]],frozen.kx[1],frozen.ky[1]); + deadkl(game.kx[1],game.ky[1],game.quad[game.kx[1]][game.ky[1]],game.kx[1],game.ky[1]); prout("Ensign Chekov- \"Congratulations, Captain!\""); - if (state.remkl == 0) finish(FWON); + if (game.state.remkl == 0) finish(FWON); prout("Spock- \"Captain, I believe the `Experimental Death Ray'"); if (Rand() <= 0.05) { prout(" is still operational.\""); } else { prout(" has been rendered disfunctional.\""); - frozen.damage[DDRAY] = 39.95; + game.damage[DDRAY] = 39.95; } return; } @@ -488,7 +488,7 @@ void deathray(void) { prout(" Mr. Sulu."); for (i=1; i<=10; i++) for (j=1; j<=10; j++) - if (frozen.quad[i][j] == IHDOT) frozen.quad[i][j] = IHQUEST; + if (game.quad[i][j] == IHDOT) game.quad[i][j] = IHQUEST; prout(" Captain, our quadrant is now infested with"); prouts(" - - - - - - *THINGS*."); skip(1); diff --git a/reports.c b/reports.c index 5841aec..9475ab3 100644 --- a/reports.c +++ b/reports.c @@ -4,20 +4,20 @@ #include void attakreport(void) { - if (frozen.future[FCDBAS] < 1e30) { + if (game.future[FCDBAS] < 1e30) { proutn("Starbase in "); cramlc(1, batx, baty); prout(" is currently under attack."); proutn("It can hold out until Stardate "); - cramf(frozen.future[FCDBAS], 0,1); + cramf(game.future[FCDBAS], 0,1); prout("."); } if (isatb == 1) { proutn("Starbase in "); - cramlc(1, state.isx, state.isy); + cramlc(1, game.state.isx, game.state.isy); prout(" is under Super-commander attack."); proutn("It can hold out until Stardate "); - cramf(frozen.future[FSCDBAS], 0, 1); + cramf(game.future[FSCDBAS], 0, 1); prout("."); } } @@ -42,32 +42,32 @@ void report(int f) { case 5: s3="emeritus"; break; default: s3="skilled"; break; } - printf("\nYou %s playing a %s%s %s frozen.\n", + printf("\nYou %s playing a %s%s %s game.\n", 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",frozen.passwd); + if (f) printf("Your secret password is \"%s\"\n",game.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"); - else if (state.killk+state.nsckill > 0) prout(", but no Commanders."); + game.state.killk+game.state.killc+game.state.nsckill, inkling); + if (game.state.killc) printf(", including %d Commander%s.\n", game.state.killc, game.state.killc==1?"":"s"); + else if (game.state.killk+game.state.nsckill > 0) prout(", but no Commanders."); else prout("."); if (skill > 2) printf("The Super Commander has %sbeen destroyed.\n", - state.nscrem?"not ":""); - if (state.rembase != inbase) { + game.state.nscrem?"not ":""); + if (game.state.rembase != inbase) { proutn("There "); - if (inbase-state.rembase==1) proutn("has been 1 base"); + if (inbase-game.state.rembase==1) proutn("has been 1 base"); else { proutn("have been "); - crami(inbase-state.rembase, 1); + crami(inbase-game.state.rembase, 1); proutn(" bases"); } proutn(" destroyed, "); - crami(state.rembase, 1); + crami(game.state.rembase, 1); prout(" remaining."); } else printf("There are %d bases.\n", inbase); - if (frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED || iseenit) { + if (game.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 ((frozen.damage[DRADIO] == 0.0 || condit == IHDOCKED)&& - frozen.future[FDSPROB] != 1e30) { + if ((game.damage[DRADIO] == 0.0 || condit == IHDOCKED)&& + game.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 (frozen.damage[DLRSENS] != 0.0) { + if (game.damage[DLRSENS] != 0.0) { /* Now allow base's sensors if docked */ if (condit != IHDOCKED) { prout("LONG-RANGE SENSORS DAMAGED."); @@ -134,8 +134,8 @@ void lrscan(void) { if (x == 0 || x > 8 || y == 0 || y > 8) printf(" -1"); else { - printf("%5d", state.galaxy[x][y]); - frozen.starch[x][y] = frozen.damage[DRADIO] > 0 ? state.galaxy[x][y]+1000 :1; + printf("%5d", game.state.galaxy[x][y]); + game.starch[x][y] = game.damage[DRADIO] > 0 ? game.state.galaxy[x][y]+1000 :1; } } putchar('\n'); @@ -148,7 +148,7 @@ void dreprt(void) { chew(); for (i = 1; i <= ndevice; i++) { - if (frozen.damage[i] > 0.0) { + if (game.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(frozen.damage[i]+0.05, 8, 2); + cramf(game.damage[i]+0.05, 8, 2); proutn(" "); - cramf(docfac*frozen.damage[i]+0.005, 8, 2); + cramf(docfac*game.damage[i]+0.005, 8, 2); skip(1); } } @@ -170,7 +170,7 @@ void chart(int nn) { chew(); skip(1); - if (stdamtim != 1e30 && stdamtim != state.date && condit == IHDOCKED) { + if (stdamtim != 1e30 && stdamtim != game.state.date && condit == IHDOCKED) { prout("Spock- \"I revised the Star Chart from the"); prout(" starbase's records.\""); skip(1); @@ -179,14 +179,14 @@ void chart(int nn) { if (stdamtim != 1e30) { if (condit == IHDOCKED) { /* We are docked, so restore chart from base information */ - stdamtim = state.date; + stdamtim = game.state.date; for (i=1; i <= 8 ; i++) for (j=1; j <= 8; j++) - if (frozen.starch[i][j] == 1) frozen.starch[i][j] = state.galaxy[i][j]+1000; + if (game.starch[i][j] == 1) game.starch[i][j] = game.state.galaxy[i][j]+1000; } else { proutn("(Last surveillance update "); - cramf(state.date-stdamtim, 0, 1); + cramf(game.state.date-stdamtim, 0, 1); prout(" stardates ago.)"); } } @@ -198,14 +198,14 @@ void chart(int nn) { for (i = 1; i <= 8; i++) { printf("%d -", i); for (j = 1; j <= 8; j++) { - if (frozen.starch[i][j] < 0) + if (game.starch[i][j] < 0) printf(" .1."); - else if (frozen.starch[i][j] == 0) + else if (game.starch[i][j] == 0) printf(" ..."); - else if (frozen.starch[i][j] > 999) - printf("%5d", frozen.starch[i][j]-1000); + else if (game.starch[i][j] > 999) + printf("%5d", game.starch[i][j]-1000); else - printf("%5d", state.galaxy[i][j]); + printf("%5d", game.state.galaxy[i][j]); } prout(" -"); } @@ -227,7 +227,7 @@ void srscan(int l) { int goodScan=TRUE; switch (l) { case 1: // SRSCAN - if (frozen.damage[DSRSENS] != 0) { + if (game.damage[DSRSENS] != 0) { /* Allow base's sensors if docked */ if (condit != IHDOCKED) { prout("SHORT-RANGE SENSORS DAMAGED"); @@ -237,8 +237,8 @@ void srscan(int l) { prout("[Using starbase's sensors]"); } if (goodScan) - frozen.starch[quadx][quady] = frozen.damage[DRADIO]>0.0 ? - state.galaxy[quadx][quady]+1000:1; + game.starch[quadx][quady] = game.damage[DRADIO]>0.0 ? + game.state.galaxy[quadx][quady]+1000:1; scan(); if (isit("chart")) nn = TRUE; if (isit("no")) rightside = FALSE; @@ -270,7 +270,7 @@ void srscan(int l) { printf("%2d ", i); for (j = 1; j <= 10; j++) { if (goodScan || (abs(i-sectx)<= 1 && abs(j-secty) <= 1)) - printf("%c ",frozen.quad[i][j]); + printf("%c ",game.quad[i][j]); else printf("- "); } @@ -278,7 +278,7 @@ void srscan(int l) { if (rightside) { switch (jj) { case 1: - printf(" Stardate %.1f", state.date); + printf(" Stardate %.1f", game.state.date); break; case 2: if (condit != IHDOCKED) newcnd(); @@ -298,7 +298,7 @@ void srscan(int l) { break; case 4: printf(" Life Support "); - if (frozen.damage[DLIFSUP] != 0.0) { + if (game.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 (frozen.damage[DSHIELD] != 0) + if (game.damage[DSHIELD] != 0) printf("DAMAGED,"); else if (shldup) printf("UP,"); @@ -328,10 +328,10 @@ void srscan(int l) { (int)((100.0*shield)/inshld + 0.5), shield); break; case 9: - printf(" Klingons Left %d", state.remkl); + printf(" Klingons Left %d", game.state.remkl); break; case 10: - printf(" Time Left %.2f", state.remtime); + printf(" Time Left %.2f", game.state.remtime); break; } @@ -347,7 +347,7 @@ void eta(void) { int key, ix1, ix2, iy1, iy2, prompt=FALSE; int wfl; double ttime, twarp, tpower; - if (frozen.damage[DCOMPTR] != 0.0) { + if (game.damage[DCOMPTR] != 0.0) { prout("COMPUTER DAMAGED, USE A POCKET CALCULATOR."); skip(1); return; @@ -397,7 +397,7 @@ void eta(void) { proutn("Time or arrival date? "); if (scan()==IHREAL) { ttime = aaitem; - if (ttime > state.date) ttime -= state.date; // Actually a star date + if (ttime > game.state.date) ttime -= game.state.date; // Actually a star date if (ttime <= 1e-10 || (twarp=(floor(sqrt((10.0*dist)/ttime)*10.0)+1.0)/10.0) > 10) { prout("We'll never make it, sir."); @@ -455,7 +455,7 @@ void eta(void) { prout("."); if (wfl) { proutn("And we will arrive at stardate "); - cramf(state.date+ttime, 1, 1); + cramf(game.state.date+ttime, 1, 1); prout("."); } else if (twarp==1.0) @@ -465,16 +465,16 @@ void eta(void) { cramf(twarp, 1, 2); skip(1); proutn("and we will arrive at stardate "); - cramf(state.date+ttime, 1, 2); + cramf(game.state.date+ttime, 1, 2); prout("."); } - if (state.remtime < ttime) + if (game.state.remtime < ttime) prout("Unfortunately, the Federation will be destroyed by then."); if (twarp > 6.0) prout("You'll be taking risks at that speed, Captain"); - if ((isatb==1 && state.isy == ix1 && state.isx == iy1 && - frozen.future[FSCDBAS]< ttime+state.date)|| - (frozen.future[FCDBAS]0) { + if (game.damage[DSHUTTL]>0) { prout("Shuttle craft damaged."); return; } @@ -120,7 +116,7 @@ void abandn(void) { prout("Captain and crew escape in shuttle craft."); prout("Remainder of ship's complement beam down"); prout("to nearest habitable planet."); - if (state.rembase==0) { + if (game.state.rembase==0) { /* Ops! no place to go... */ finish(FABANDN); return; @@ -131,23 +127,23 @@ void abandn(void) { nprobes = 0; /* No probes */ prout("You are captured by Klingons and released to"); prout("the Federation in a prisoner-of-war exchange."); - nb = Rand()*state.rembase+1; + nb = Rand()*game.state.rembase+1; /* Set up quadrant and position FQ adjacient to base */ - if (quadx!=state.baseqx[nb] || quady!=state.baseqy[nb]) { - quadx = state.baseqx[nb]; - quady = state.baseqy[nb]; + if (quadx!=game.state.baseqx[nb] || quady!=game.state.baseqy[nb]) { + quadx = game.state.baseqx[nb]; + quady = game.state.baseqy[nb]; sectx = secty = 5; newqad(1); } for (;;) { /* position next to base by trial and error */ - frozen.quad[sectx][secty] = IHDOT; + game.quad[sectx][secty] = IHDOT; for (l = 1; l <= 10; l++) { sectx = 3.0*Rand() - 1.0 + basex; secty = 3.0*Rand() - 1.0 + basey; if (sectx >= 1 && sectx <= 10 && secty >= 1 && secty <= 10 && - frozen.quad[sectx][secty] == IHDOT) break; + game.quad[sectx][secty] == IHDOT) break; } if (l < 11) break; /* found a spot */ sectx=5; @@ -156,7 +152,7 @@ void abandn(void) { } } /* Get new commission */ - frozen.quad[sectx][secty] = ship = IHF; + game.quad[sectx][secty] = ship = IHF; prout("Starfleet puts you in command of another ship,"); prout("the Faerie Queene, which is antiquated but,"); prout("still useable."); @@ -165,8 +161,8 @@ void abandn(void) { iscraft=0; /* Gallileo disappears */ /* Resupply ship */ condit=IHDOCKED; - for (l = 1; l <= ndevice; l++) frozen.damage[l] = 0.0; - frozen.damage[DSHUTTL] = -1; + for (l = 1; l <= ndevice; l++) game.damage[l] = 0.0; + game.damage[DSHUTTL] = -1; energy = inenrg = 3000.0; shield = inshld = 1250.0; torps = intorps = 6; @@ -199,27 +195,27 @@ 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++) frozen.damage[i] = 0.0; + for (i=0; i <= ndevice; i++) game.damage[i] = 0.0; // Set up assorted game parameters batx = baty = 0; - state.date = indate = 100.0*(int)(31.0*Rand()+20.0); - state.killk = state.killc = nkinks = nhelp = resting = casual = state.nromkl = 0; - isatb = iscate = imine = icrystl = icraft = state.nsckill = state.nplankl = 0; + game.state.date = indate = 100.0*(int)(31.0*Rand()+20.0); + game.state.killk = game.state.killc = nkinks = nhelp = resting = casual = game.state.nromkl = 0; + isatb = iscate = imine = icrystl = icraft = game.state.nsckill = game.state.nplankl = 0; iscraft = 1; landed = -1; alive = 1; docfac = 0.25; for (i = 1; i <= 8; i++) - for (j = 1; j <= 8; j++) state.newstuf[i][j] = frozen.starch[i][j] = 0; + for (j = 1; j <= 8; j++) game.state.newstuf[i][j] = game.starch[i][j] = 0; // Initialize times for extraneous events - 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; + game.future[FSNOVA] = game.state.date + expran(0.5 * intime); + game.future[FTBEAM] = game.state.date + expran(1.5 * (intime / game.state.remcom)); + game.future[FSNAP] = game.state.date + 1.0 + Rand(); // Force an early snapshot + game.future[FBATTAK] = game.state.date + expran(0.3*intime); + game.future[FCDBAS] = 1e30; + game.future[FSCMOVE] = game.state.nscrem ? game.state.date+0.2777 : 1e30; + game.future[FSCDBAS] = 1e30; + game.future[FDSPROB] = 1e30; // Starchart is functional stdamtim = 1e30; // Put stars in the galaxy @@ -228,18 +224,18 @@ void setup(void) { for (j=1; j<=8; j++) { int k = Rand()*9.0 + 1.0; instar += k; - state.galaxy[i][j] = k; + game.state.galaxy[i][j] = k; } // Locate star bases in galaxy for (i = 1; i <= inbase; i++) { int contflag; do { do iran8(&ix, &iy); - while (state.galaxy[ix][iy] >= 10); + while (game.state.galaxy[ix][iy] >= 10); contflag = FALSE; for (j = i-1; j > 0; j--) { /* Improved placement algorithm to spread out bases */ - double distq = square(ix-state.baseqx[j]) + square(iy-state.baseqy[j]); + double distq = square(ix-game.state.baseqx[j]) + square(iy-game.state.baseqy[j]); if (distq < 6.0*(6-inbase) && Rand() < 0.75) { contflag = TRUE; #ifdef DEBUG @@ -255,13 +251,13 @@ void setup(void) { } } while (contflag); - state.baseqx[i] = ix; - state.baseqy[i] = iy; - frozen.starch[ix][iy] = -1; - state.galaxy[ix][iy] += 10; + game.state.baseqx[i] = ix; + game.state.baseqy[i] = iy; + game.starch[ix][iy] = -1; + game.state.galaxy[ix][iy] += 10; } // Position ordinary Klingon Battle Cruisers - krem = inkling - incom - state.nscrem; + krem = inkling - incom - game.state.nscrem; klumper = 0.25*skill*(9.0-length)+1.0; if (klumper > 9) klumper = 9; // Can't have more than 9 in quadrant do { @@ -271,8 +267,8 @@ void setup(void) { krem -= klump; klump *= 100; do iran8(&ix, &iy); - while (state.galaxy[ix][iy] + klump >= 1000); - state.galaxy[ix][iy] += klump; + while (game.state.galaxy[ix][iy] + klump >= 1000); + game.state.galaxy[ix][iy] += klump; } while (krem > 0); // Position Klingon Commander Ships #ifdef DEBUG @@ -283,47 +279,47 @@ void setup(void) { do { /* IF debugging, put commanders by bases, always! */ #ifdef DEBUG if (idebug && klumper <= inbase) { - ix = state.baseqx[klumper]; - iy = state.baseqy[klumper]; + ix = game.state.baseqx[klumper]; + iy = game.state.baseqy[klumper]; klumper++; } else #endif iran8(&ix, &iy); } - while ((state.galaxy[ix][iy] < 99 && Rand() < 0.75)|| - state.galaxy[ix][iy]>899); + while ((game.state.galaxy[ix][iy] < 99 && Rand() < 0.75)|| + game.state.galaxy[ix][iy]>899); // check for duplicate for (j = 1; j < i; j++) - if (state.cx[j]==ix && state.cy[j]==iy) break; + if (game.state.cx[j]==ix && game.state.cy[j]==iy) break; } while (j < i); - state.galaxy[ix][iy] += 100; - state.cx[i] = ix; - state.cy[i] = iy; + game.state.galaxy[ix][iy] += 100; + game.state.cx[i] = ix; + game.state.cy[i] = iy; } // Locate planets in galaxy for (i = 1; i <= inplan; i++) { do iran8(&ix, &iy); - while (state.newstuf[ix][iy] > 0); - state.newstuf[ix][iy] = 1; - state.plnets[i].x = ix; - state.plnets[i].y = iy; - state.plnets[i].pclass = Rand()*3.0 + 1.0; // Planet class M N or O - state.plnets[i].crystals = 1.5*Rand(); // 1 in 3 chance of crystals - state.plnets[i].known = 0; + while (game.state.newstuf[ix][iy] > 0); + game.state.newstuf[ix][iy] = 1; + game.state.plnets[i].x = ix; + game.state.plnets[i].y = iy; + game.state.plnets[i].pclass = Rand()*3.0 + 1.0; // Planet class M N or O + game.state.plnets[i].crystals = 1.5*Rand(); // 1 in 3 chance of crystals + game.state.plnets[i].known = 0; } // Locate Romulans - for (i = 1; i <= state.nromrem; i++) { + for (i = 1; i <= game.state.nromrem; i++) { iran8(&ix, &iy); - state.newstuf[ix][iy] += 10; + game.state.newstuf[ix][iy] += 10; } // Locate the Super Commander - if (state.nscrem > 0) { + if (game.state.nscrem > 0) { do iran8(&ix, &iy); - while (state.galaxy[ix][iy] >= 900); - state.isx = ix; - state.isy = iy; - state.galaxy[ix][iy] += 100; + while (game.state.galaxy[ix][iy] >= 900); + game.state.isx = ix; + game.state.isy = iy; + game.state.galaxy[ix][iy] += 100; } // Place thing (in tournament game, thingx == -1, don't want one!) if (Rand() < 0.1 && thingx != -1) { @@ -335,11 +331,11 @@ void setup(void) { // idate = date; skip(3); - state.snap = 0; + game.state.snap = 0; if (skill == 1) { printf("It is stardate %d. The Federation is being attacked by\n", - (int)state.date); + (int)game.state.date); printf("a deadly Klingon invasion force. As captain of the United\n" "Starship U.S.S. Enterprise, it is your mission to seek out\n" "and destroy this invasion force of %d battle cruisers.\n", @@ -353,12 +349,12 @@ void setup(void) { else { printf("Stardate %d.\n\n" "%d Klingons.\nAn unknown number of Romulans\n", - (int)state.date, inkling); - if (state.nscrem) printf("and one (GULP) Super-Commander.\n"); + (int)game.state.date, inkling); + if (game.state.nscrem) printf("and one (GULP) Super-Commander.\n"); printf("%d stardates\n%d starbases in ",(int)intime, inbase); } for (i = 1; i <= inbase; i++) { - cramlc(0, state.baseqx[i], state.baseqy[i]); + cramlc(0, game.state.baseqx[i], game.state.baseqy[i]); if (i < inbase) proutn(" "); } skip(2); @@ -368,7 +364,7 @@ void setup(void) { cramlc(2, sectx, secty); skip(2); prout("Good Luck!"); - if (state.nscrem) proutn(" YOU'LL NEED IT."); + if (game.state.nscrem) proutn(" YOU'LL NEED IT."); skip(1); newqad(0); if (nenhere) shldup=1.0; @@ -403,7 +399,7 @@ int choose(void) { if (isit("frozen")) { thaw(); chew(); - if (*frozen.passwd==0) continue; + if (*game.passwd==0) continue; randomize(); Rand(); Rand(); Rand(); Rand(); if (!alldone) thawed = 1; // No plaque if not finished @@ -445,54 +441,54 @@ int choose(void) { } while (TRUE) { scan(); - strcpy(frozen.passwd, citem); + strcpy(game.passwd, citem); chew(); - if (*frozen.passwd != 0) break; + if (*game.passwd != 0) break; proutn("Please type in a secret password-"); } #ifdef DEBUG - if (strcmp(frozen.passwd, "debug")==0) idebug = 1; + if (strcmp(game.passwd, "debug")==0) idebug = 1; #endif // Use parameters to generate initial values of things damfac = 0.5 * skill; - state.rembase = 3.0*Rand()+2.0; - inbase = state.rembase; + game.state.rembase = 3.0*Rand()+2.0; + inbase = game.state.rembase; inplan = (PLNETMAX/2) + (PLNETMAX/2+1)*Rand(); - state.nromrem = (2.0+Rand())*skill; - state.nscrem = (skill > 2? 1 : 0); - state.remtime = 7.0 * length; - intime = state.remtime; - state.remkl = 2.0*intime*((skill+1 - 2*Rand())*skill*0.1+.15); - inkling = state.remkl; + game.state.nromrem = (2.0+Rand())*skill; + game.state.nscrem = (skill > 2? 1 : 0); + game.state.remtime = 7.0 * length; + intime = game.state.remtime; + game.state.remkl = 2.0*intime*((skill+1 - 2*Rand())*skill*0.1+.15); + inkling = game.state.remkl; incom = skill + 0.0625*inkling*Rand(); - state.remcom= min(10, incom); - incom = state.remcom; - state.remres = (inkling+4*incom)*intime; - inresor = state.remres; + game.state.remcom= min(10, incom); + incom = game.state.remcom; + game.state.remres = (inkling+4*incom)*intime; + inresor = game.state.remres; if (inkling > 50) { - inbase = (state.rembase += 1); + inbase = (game.state.rembase += 1); } return FALSE; } void dropin(int iquad, int *ix, int *iy) { do iran10(ix, iy); - while (frozen.quad[*ix][*iy] != IHDOT); - frozen.quad[*ix][*iy] = iquad; + while (game.quad[*ix][*iy] != IHDOT); + game.quad[*ix][*iy] = iquad; } void newcnd(void) { condit = IHGREEN; if (energy < 1000.0) condit = IHYELLOW; - if (state.galaxy[quadx][quady] > 99 || state.newstuf[quadx][quady] > 9) + if (game.state.galaxy[quadx][quady] > 99 || game.state.newstuf[quadx][quady] > 9) condit = IHRED; } void newqad(int shutup) { - int quadnum = state.galaxy[quadx][quady]; - int newnum = state.newstuf[quadx][quady]; + int quadnum = game.state.galaxy[quadx][quady]; + int newnum = game.state.newstuf[quadx][quady]; int i, j, ix, iy, nplan; iattak = 1; @@ -518,7 +514,7 @@ void newqad(int shutup) { } // Clear quadrant for (i=1; i <= 10; i++) - for (j=1; j <= 10; j++) frozen.quad[i][j] = IHDOT; + for (j=1; j <= 10; j++) game.quad[i][j] = IHDOT; // cope with supernova if (quadnum > 999) { return; @@ -529,27 +525,27 @@ void newqad(int shutup) { nenhere = klhere + irhere; // Position Starship - frozen.quad[sectx][secty] = ship; + game.quad[sectx][secty] = ship; // Decide if quadrant needs a Tholian if ((skill < 3 && Rand() <= 0.02) || /* Lighten up if skill is low */ (skill == 3 && Rand() <= 0.05) || (skill > 3 && Rand() <= 0.08) #ifdef DEBUG - || strcmp(frozen.passwd, "tholianx")==0 + || strcmp(game.passwd, "tholianx")==0 #endif ) { do { ithx = Rand() > 0.5 ? 10 : 1; ithy = Rand() > 0.5 ? 10 : 1; - } while (frozen.quad[ithx][ithy] != IHDOT); - frozen.quad[ithx][ithy] = IHT; + } while (game.quad[ithx][ithy] != IHDOT); + game.quad[ithx][ithy] = IHT; ithere = 1; /* Reserve unocupied corners */ - if (frozen.quad[1][1]==IHDOT) frozen.quad[1][1] = 'X'; - if (frozen.quad[1][10]==IHDOT) frozen.quad[1][10] = 'X'; - if (frozen.quad[10][1]==IHDOT) frozen.quad[10][1] = 'X'; - if (frozen.quad[10][10]==IHDOT) frozen.quad[10][10] = 'X'; + if (game.quad[1][1]==IHDOT) game.quad[1][1] = 'X'; + if (game.quad[1][10]==IHDOT) game.quad[1][10] = 'X'; + if (game.quad[10][1]==IHDOT) game.quad[10][1] = 'X'; + if (game.quad[10][10]==IHDOT) game.quad[10][10] = 'X'; } if (quadnum >= 100) { @@ -557,25 +553,25 @@ void newqad(int shutup) { quadnum -= 100*klhere; for (i = 1; i <= klhere; i++) { dropin(IHK, &ix, &iy); - 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; + game.kx[i] = ix; + game.ky[i] = iy; + game.kdist[i] = game.kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy)); + game.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++) - if (state.cx[i]==quadx && state.cy[i]==quady) break; + for (i = 1; i <= game.state.remcom ; i++) + if (game.state.cx[i]==quadx && game.state.cy[i]==quady) break; - if (i <= state.remcom) { - frozen.quad[ix][iy] = IHC; - frozen.kpower[klhere] = 950.0+400.0*Rand()+50.0*skill; + if (i <= game.state.remcom) { + game.quad[ix][iy] = IHC; + game.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[frozen.kx[1]][frozen.ky[1]] = IHS; - frozen.kpower[1] = 1175.0 + 400.0*Rand() + 125.0*skill; + if (quadx == game.state.isx && quady == game.state.isy) { + game.quad[game.kx[1]][game.ky[1]] = IHS; + game.kpower[1] = 1175.0 + 400.0*Rand() + 125.0*skill; iscate = 1; ishere = 1; } @@ -583,10 +579,10 @@ void newqad(int shutup) { // Put in Romulans if needed for (i = klhere+1; i <= nenhere; i++) { dropin(IHR, &ix, &iy); - 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; + game.kx[i] = ix; + game.ky[i] = iy; + game.kdist[i] = game.kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy)); + game.kpower[i] = Rand()*400.0 + 450.0 + 50.0*skill; } sortkl(); // If quadrant needs a starbase, put it in @@ -598,7 +594,7 @@ void newqad(int shutup) { if (nplan) { // If quadrant needs a planet, put it in for (i=1; i <= inplan; i++) - if (state.plnets[i].x == quadx && state.plnets[i].y == quady) break; + if (game.state.plnets[i].x == quadx && game.state.plnets[i].y == quady) break; if (i <= inplan) { iplnet = i; dropin(IHP, &plnetx, &plnety); @@ -612,7 +608,7 @@ void newqad(int shutup) { // Check for RNZ if (irhere > 0 && klhere == 0 && basex == 0) { neutz = 1; - if (frozen.damage[DRADIO] <= 0.0) { + if (game.damage[DRADIO] <= 0.0) { skip(1); prout("LT. Uhura- \"Captain, an urgent message."); prout(" I'll put it on audio.\" CLICK"); @@ -627,7 +623,7 @@ void newqad(int shutup) { if (thingx == quadx && thingy == quady) { dropin(IHQUEST, &ix, &iy); thingx = thingy = 0; // Transient - if (frozen.damage[DSRSENS] == 0.0) { + if (game.damage[DSRSENS] == 0.0) { skip(1); prout("MR. SPOCK- \"Captain, this is most unusual."); prout(" Please examine your short-range scan.\""); @@ -641,10 +637,10 @@ void newqad(int shutup) { // Take out X's in corners if Tholian present if (ithere) { - if (frozen.quad[1][1]=='X') frozen.quad[1][1] = IHDOT; - if (frozen.quad[1][10]=='X') frozen.quad[1][10] = IHDOT; - if (frozen.quad[10][1]=='X') frozen.quad[10][1] = IHDOT; - if (frozen.quad[10][10]=='X') frozen.quad[10][10] = IHDOT; + if (game.quad[1][1]=='X') game.quad[1][1] = IHDOT; + if (game.quad[1][10]=='X') game.quad[1][10] = IHDOT; + if (game.quad[10][1]=='X') game.quad[10][1] = IHDOT; + if (game.quad[10][10]=='X') game.quad[10][10] = IHDOT; } } @@ -659,23 +655,23 @@ void sortkl(void) { do { sw = FALSE; for (j = 1; j < nenhere; j++) - if (frozen.kdist[j] > frozen.kdist[j+1]) { + if (game.kdist[j] > game.kdist[j+1]) { sw = TRUE; - 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; + t = game.kdist[j]; + game.kdist[j] = game.kdist[j+1]; + game.kdist[j+1] = t; + t = game.kavgd[j]; + game.kavgd[j] = game.kavgd[j+1]; + game.kavgd[j+1] = t; + k = game.kx[j]; + game.kx[j] = game.kx[j+1]; + game.kx[j+1] = k; + k = game.ky[j]; + game.ky[j] = game.ky[j+1]; + game.ky[j+1] = k; + t = game.kpower[j]; + game.kpower[j] = game.kpower[j+1]; + game.kpower[j+1] = t; } } while (sw); } diff --git a/sst.c b/sst.c index 55066eb..3120225 100644 --- a/sst.c +++ b/sst.c @@ -323,7 +323,7 @@ static void makemoves(void) { events(); if (alldone) break; // Events did us in } - if (state.galaxy[quadx][quady] == 1000) { // Galaxy went Nova! + if (game.state.galaxy[quadx][quady] == 1000) { // Galaxy went Nova! atover(0); continue; } @@ -331,7 +331,7 @@ static void makemoves(void) { if (hitme && justin==0) { attack(2); if (alldone) break; - if (state.galaxy[quadx][quady] == 1000) { // went NOVA! + if (game.state.galaxy[quadx][quady] == 1000) { // went NOVA! atover(0); hitme = TRUE; continue; @@ -657,7 +657,7 @@ void debugme(void) { key = scan(); if (key == IHALPHA && isit("y")) { damage[i] = 10.0; - if (i == DRADIO) stdamtim = state.date; + if (i == DRADIO) stdamtim = game.state.date; } } } @@ -676,12 +676,12 @@ void debugme(void) { case FSCMOVE: proutn("SC Move "); break; case FSCDBAS: proutn("SC Base Destroy "); break; } - cramf(future[i]-state.date, 8, 2); + cramf(future[i]-game.state.date, 8, 2); chew(); proutn(" ?"); key = scan(); if (key == IHREAL) { - future[i] = state.date + aaitem; + future[i] = game.state.date + aaitem; } } chew(); diff --git a/sst.h b/sst.h index e0f9bd5..c93fbc5 100644 --- a/sst.h +++ b/sst.h @@ -21,33 +21,33 @@ typedef struct { int pclass; /* class M, N, or O (1, 2, or 3) */ int crystals; /* has crystals */ int known; /* =1 contents known, =2 shuttle on this planet */ -} PLANETS; +} planet; -EXTERN struct foo { - int snap, // snapshot taken - remkl, // remaining klingons - remcom, // remaining commanders - rembase, // remaining bases - starkl, // destroyed stars - basekl, // destroyed bases - killk, // Klingons killed - killc, // commanders killed - galaxy[9][9], // The Galaxy (subscript 0 not used) - cx[11],cy[11], // Commander quadrant coordinates - baseqx[6], // Base quadrant X - baseqy[6], // Base quadrant Y - newstuf[9][9], // Extended galaxy goodies - isx, isy, // Coordinate of Super Commander - nscrem, // remaining super commanders - nromkl, // Romulans killed - nromrem, // Romulans remaining - nsckill, // super commanders killed - nplankl; // destroyed planets - PLANETS plnets[PLNETMAX+1]; // Planet information +typedef struct { + int snap, // snapshot taken + remkl, // remaining klingons + remcom, // remaining commanders + rembase, // remaining bases + starkl, // destroyed stars + basekl, // destroyed bases + killk, // Klingons killed + killc, // commanders killed + galaxy[9][9], // The Galaxy (subscript 0 not used) + cx[11],cy[11], // Commander quadrant coordinates + baseqx[6], // Base quadrant X + baseqy[6], // Base quadrant Y + newstuf[9][9], // Extended galaxy goodies + isx, isy, // Coordinate of Super Commander + nscrem, // remaining super commanders + nromkl, // Romulans killed + nromrem, // Romulans remaining + nsckill, // super commanders killed + nplankl; // destroyed planets + planet plnets[PLNETMAX+1]; // Planet information double date, // stardate - remres, // remaining resources + remres, // remaining resources remtime; // remaining time -} state, snapsht; // Data that is snapshot +} snapshot; // Data that is snapshot // Scalar variables that are needed for freezing the game // are placed in a structure. #defines are used to access by their @@ -55,6 +55,8 @@ EXTERN struct foo { // but I just didn't think of it back when I started. EXTERN struct foo2 { + snapshot state; + snapshot snapsht; char quad[11][11]; // contents of our quadrant double kpower[21]; // enemy energy levels double kdist[21]; // enemy distances @@ -129,7 +131,7 @@ EXTERN struct foo2 { proben, isarmed, nprobes; - double inresor, + double inresor, intime, inenrg, inshld, @@ -153,102 +155,104 @@ EXTERN struct foo2 { probey, probeinx, probeiny; -} frozen; +} game; -#define inkling frozen.inkling // Initial number of klingons -#define inbase frozen.inbase // Initial number of bases -#define incom frozen.incom // Initian number of commanders -#define instar frozen.instar // Initial stars -#define intorps frozen.intorps // Initial/Max torpedoes -#define condit frozen.condit // Condition (red, yellow, green docked) -#define torps frozen.torps // number of torpedoes -#define ship frozen.ship // Ship type -- 'E' is Enterprise -#define quadx frozen.quadx // where we are -#define quady frozen.quady // -#define sectx frozen.sectx // where we are -#define secty frozen.secty // -#define length frozen.length // length of game -#define skill frozen.skill // skill level -#define basex frozen.basex // position of base in current quad -#define basey frozen.basey // -#define klhere frozen.klhere // klingons here -#define comhere frozen.comhere // commanders here -#define casual frozen.casual // causalties -#define nhelp frozen.nhelp // calls for help -#define nkinks frozen.nkinks // -#define ididit frozen.ididit // Action taken -- allows enemy to attack -#define gamewon frozen.gamewon // Finished! -#define alive frozen.alive // We are alive (not killed) -#define justin frozen.justin // just entered quadrant -#define alldone frozen.alldone // game is now finished -#define shldchg frozen.shldchg // shield is changing (affects efficiency) -#define thingx frozen.thingx // location of strange object in galaxy -#define thingy frozen.thingy // -#define plnetx frozen.plnetx // location of planet in quadrant -#define plnety frozen.plnety // -#define inorbit frozen.inorbit // orbiting -#define landed frozen.landed // party on planet (1), on ship (-1) -#define iplnet frozen.iplnet // planet # in quadrant -#define imine frozen.imine // mining -#define inplan frozen.inplan // initial planets -#define nenhere frozen.nenhere // Number of enemies in quadrant -#define ishere frozen.ishere // Super-commander in quandrant -#define neutz frozen.neutz // Romulan Neutral Zone -#define irhere frozen.irhere // Romulans in quadrant -#define icraft frozen.icraft // Kirk in Galileo -#define ientesc frozen.ientesc // Attempted escape from supercommander -#define iscraft frozen.iscraft // =1 if craft on ship, -1 if removed from game -#define isatb frozen.isatb // =1 if SuperCommander is attacking base -#define iscate frozen.iscate // Super Commander is here +#define inkling game.inkling // Initial number of klingons +#define inbase game.inbase // Initial number of bases +#define incom game.incom // Initian number of commanders +#define instar game.instar // Initial stars +#define intorps game.intorps // Initial/Max torpedoes +#define condit game.condit // Condition (red, yellow, green docked) +#define torps game.torps // number of torpedoes +#define ship game.ship // Ship type -- 'E' is Enterprise +#define quadx game.quadx // where we are +#define quady game.quady // +#define sectx game.sectx // where we are +#define secty game.secty // +#define length game.length // length of game +#define skill game.skill // skill level +#define basex game.basex // position of base in current quad +#define basey game.basey // +#define klhere game.klhere // klingons here +#define comhere game.comhere // commanders here +#define casual game.casual // causalties +#define nhelp game.nhelp // calls for help +#define nkinks game.nkinks // +#define ididit game.ididit // Action taken -- allows enemy to attack +#define gamewon game.gamewon // Finished! +#define alive game.alive // We are alive (not killed) +#define justin game.justin // just entered quadrant +#define alldone game.alldone // game is now finished +#define shldchg game.shldchg // shield is changing (affects efficiency) +#define thingx game.thingx // location of strange object in galaxy +#define thingy game.thingy // +#define plnetx game.plnetx // location of planet in quadrant +#define plnety game.plnety // +#define inorbit game.inorbit // orbiting +#define landed game.landed // party on planet (1), on ship (-1) +#define iplnet game.iplnet // planet # in quadrant +#define imine game.imine // mining +#define inplan game.inplan // initial planets +#define nenhere game.nenhere // Number of enemies in quadrant +#define ishere game.ishere // Super-commander in quandrant +#define neutz game.neutz // Romulan Neutral Zone +#define irhere game.irhere // Romulans in quadrant +#define icraft game.icraft // Kirk in Galileo +#define ientesc game.ientesc // Attempted escape from supercommander +#define iscraft game.iscraft // =1 if craft on ship, -1 if removed from game +#define isatb game.isatb // =1 if SuperCommander is attacking base +#define iscate game.iscate // Super Commander is here #ifdef DEBUG -#define idebug frozen.idebug // Debug mode +#define idebug game.idebug // Debug mode #endif -#define iattak frozen.iattak // attack recursion elimination (was cracks[4]) -#define icrystl frozen.icrystl // dilithium crystals aboard -#define tourn frozen.tourn // Tournament number -#define thawed frozen.thawed // Thawed game -#define batx frozen.batx // Base coordinates being attacked -#define baty frozen.baty // -#define ithere frozen.ithere // Tholean is here -#define ithx frozen.ithx // coordinates of tholean -#define ithy frozen.ithy -#define iseenit frozen.iseenit // Seen base attack report -#define inresor frozen.inresor // initial resources -#define intime frozen.intime // initial time -#define inenrg frozen.inenrg // Initial/Max Energy -#define inshld frozen.inshld // Initial/Max Shield -#define inlsr frozen.inlsr // initial life support resources -#define indate frozen.indate // Initial date -#define energy frozen.energy // Energy level -#define shield frozen.shield // Shield level -#define shldup frozen.shldup // Shields are up -#define warpfac frozen.warpfac // Warp speed -#define wfacsq frozen.wfacsq // squared warp factor -#define lsupres frozen.lsupres // life support reserves -#define dist frozen.dist // movement distance -#define direc frozen.direc // movement direction -#define Time frozen.Time // time taken by current operation -#define docfac frozen.docfac // repair factor when docking (constant?) -#define resting frozen.resting // rest time -#define damfac frozen.damfac // damage factor -#define stdamtim frozen.stdamtim // time that star chart was damaged -#define cryprob frozen.cryprob // probability that crystal will work -#define probex frozen.probex // location of probe -#define probey frozen.probey -#define probecx frozen.probecx // current probe quadrant -#define probecy frozen.probecy -#define probeinx frozen.probeinx // Probe x,y increment -#define probeiny frozen.probeiny -#define proben frozen.proben // number of moves for probe -#define isarmed frozen.isarmed // Probe is armed -#define nprobes frozen.nprobes // number of probes available +#define iattak game.iattak // attack recursion elimination (was cracks[4]) +#define icrystl game.icrystl // dilithium crystals aboard +#define tourn game.tourn // Tournament number +#define thawed game.thawed // Thawed game +#define batx game.batx // Base coordinates being attacked +#define baty game.baty // +#define ithere game.ithere // Tholean is here +#define ithx game.ithx // coordinates of tholean +#define ithy game.ithy +#define iseenit game.iseenit // Seen base attack report +#define inresor game.inresor // initial resources +#define intime game.intime // initial time +#define inenrg game.inenrg // Initial/Max Energy +#define inshld game.inshld // Initial/Max Shield +#define inlsr game.inlsr // initial life support resources +#define indate game.indate // Initial date +#define energy game.energy // Energy level +#define shield game.shield // Shield level +#define shldup game.shldup // Shields are up +#define warpfac game.warpfac // Warp speed +#define wfacsq game.wfacsq // squared warp factor +#define lsupres game.lsupres // life support reserves +#define dist game.dist // movement distance +#define direc game.direc // movement direction +#define Time game.Time // time taken by current operation +#define docfac game.docfac // repair factor when docking (constant?) +#define resting game.resting // rest time +#define damfac game.damfac // damage factor +#define stdamtim game.stdamtim // time that star chart was damaged +#define cryprob game.cryprob // probability that crystal will work +#define probex game.probex // location of probe +#define probey game.probey +#define probecx game.probecx // current probe quadrant +#define probecy game.probecy +#define probeinx game.probeinx // Probe x,y increment +#define probeiny game.probeiny +#define proben game.proben // number of moves for probe +#define isarmed game.isarmed // Probe is armed +#define nprobes game.nprobes // number of probes available /* the following global state doesn't need to be saved */ EXTERN int fromcommandline; // Game start from command line options EXTERN char *device[ndevice+1]; -EXTERN PLANETS nulplanet; // zeroed planet structure +EXTERN planet nulplanet; // zeroed planet structure EXTERN int iscore, iskill; // Common PLAQ EXTERN double perdate; +EXTERN double aaitem; +EXTERN char citem[10]; typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE, FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM, @@ -256,11 +260,6 @@ typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE, FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE, FHOLE} FINTYPE ; - -EXTERN double aaitem; -EXTERN char citem[10]; - - /* Define devices */ #define DSRSENS 1 #define DLRSENS 2 @@ -291,7 +290,7 @@ EXTERN char citem[10]; #define FDSPROB 8 // Move deep space probe #ifdef INCLUDED -PLANETS nulplanet = {0}; +planet nulplanet = {0}; char *device[ndevice+1] = { "", "S. R. Sensors",