Change state variables to names that will be easy to replace.
iqx = quadx+(lookx+9)/10 - 1;\r
iqy = quady+(looky+9)/10 - 1;\r
if (iqx < 1 || iqx > 8 || iqy < 1 || iqy > 8 ||\r
- d.galaxy[iqx][iqy] > 899)\r
+ state.galaxy[iqx][iqy] > 899)\r
return 0; /* no can do -- neg energy, supernovae, or >8 Klingons */\r
if (ienm == IHR) return 0; /* Romulans cannot escape! */\r
if (irun == 0) {\r
/* avoid intruding on another commander's territory */\r
if (ienm == IHC) {\r
- for (l = 1; l <= d.remcom; l++)\r
- if (d.cx[l]==iqx && d.cy[l]==iqy) return 0;\r
+ for (l = 1; l <= state.remcom; l++)\r
+ if (state.cx[l]==iqx && state.cy[l]==iqy) return 0;\r
/* refuse to leave if currently attacking starbase */\r
if (batx==quadx && baty==quady) return 0;\r
}\r
nenhere--;\r
if (condit != IHDOCKED) newcnd();\r
/* Handle global matters related to escape */\r
- d.galaxy[quadx][quady] -= 100;\r
- d.galaxy[iqx][iqy] += 100;\r
+ state.galaxy[quadx][quady] -= 100;\r
+ state.galaxy[iqx][iqy] += 100;\r
if (ienm==IHS) {\r
ishere=0;\r
iscate=0;\r
ientesc=0;\r
isatb=0;\r
- future[FSCMOVE]=0.2777+d.date;\r
+ future[FSCMOVE]=0.2777+state.date;\r
future[FSCDBAS]=1e30;\r
- d.isx=iqx;\r
- d.isy=iqy;\r
+ state.isx=iqx;\r
+ state.isy=iqy;\r
}\r
else {\r
- for (l=1; l<=d.remcom; l++) {\r
- if (d.cx[l]==quadx && d.cy[l]==quady) {\r
- d.cx[l]=iqx;\r
- d.cy[l]=iqy;\r
+ for (l=1; l<=state.remcom; l++) {\r
+ if (state.cx[l]==quadx && state.cy[l]==quady) {\r
+ state.cx[l]=iqx;\r
+ state.cy[l]=iqy;\r
break;\r
}\r
}\r
\r
if ((iqx==quadx && iqy==quady) ||\r
iqx < 1 || iqx > 8 || iqy < 1 || iqy > 8 ||\r
- d.galaxy[iqx][iqy] > 899) return 1;\r
+ state.galaxy[iqx][iqy] > 899) return 1;\r
if (flag) {\r
/* Avoid quadrants with bases if we want to avoid Enterprise */\r
- for (i = 1; i <= d.rembase; i++)\r
- if (d.baseqx[i]==iqx && d.baseqy[i]==iqy) return 1;\r
+ for (i = 1; i <= state.rembase; i++)\r
+ if (state.baseqx[i]==iqx && state.baseqy[i]==iqy) return 1;\r
}\r
\r
/* do the move */\r
- d.galaxy[d.isx][d.isy] -= 100;\r
- d.isx = iqx;\r
- d.isy = iqy;\r
- d.galaxy[d.isx][d.isy] += 100;\r
+ state.galaxy[state.isx][state.isy] -= 100;\r
+ state.isx = iqx;\r
+ state.isy = iqy;\r
+ state.galaxy[state.isx][state.isy] += 100;\r
if (iscate) {\r
/* SC has scooted, Remove him from current quadrant */\r
iscate=0;\r
}\r
/* check for a helpful planet */\r
for (i = 1; i <= inplan; i++) {\r
- if (d.plnets[i].x==d.isx && d.plnets[i].y==d.isy &&\r
- d.plnets[i].crystals == 1) {\r
+ if (state.plnets[i].x==state.isx && state.plnets[i].y==state.isy &&\r
+ state.plnets[i].crystals == 1) {\r
/* destroy the planet */\r
- d.plnets[i] = nulplanet;\r
- d.newstuf[d.isx][d.isy] -= 1;\r
+ state.plnets[i] = nulplanet;\r
+ state.newstuf[state.isx][state.isy] -= 1;\r
if (damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
if (*ipage==0) pause(1);\r
*ipage = 1;\r
prout("Lt. Uhura- \"Captain, Starfleet Intelligence reports");\r
proutn(" a planet in");\r
- cramlc(1, d.isx, d.isy);\r
+ cramlc(1, state.isx, state.isy);\r
prout(" has been destroyed");\r
prout(" by the Super-commander.\"");\r
}\r
#endif\r
\r
/* Decide on being active or passive */\r
- flag = ((d.killc+d.killk)/(d.date+0.01-indate) < 0.1*skill*(skill+1.0) ||\r
- (d.date-indate) < 3.0);\r
+ flag = ((state.killc+state.killk)/(state.date+0.01-indate) < 0.1*skill*(skill+1.0) ||\r
+ (state.date-indate) < 3.0);\r
if (iscate==0 && flag) {\r
/* compute move away from Enterprise */\r
- ideltax = d.isx-quadx;\r
- ideltay = d.isy-quady;\r
+ ideltax = state.isx-quadx;\r
+ ideltay = state.isy-quady;\r
if (sqrt(ideltax*(double)ideltax+ideltay*(double)ideltay) > 2.0) {\r
/* circulate in space */\r
- ideltax = d.isy-quady;\r
- ideltay = quadx-d.isx;\r
+ ideltax = state.isy-quady;\r
+ ideltay = quadx-state.isx;\r
}\r
}\r
else {\r
/* compute distances to starbases */\r
- if (d.rembase <= 0) {\r
+ if (state.rembase <= 0) {\r
/* nothing left to do */\r
future[FSCMOVE] = 1e30;\r
return;\r
}\r
- sx = d.isx;\r
- sy = d.isy;\r
- for (i = 1; i <= d.rembase; i++) {\r
+ sx = state.isx;\r
+ sy = state.isy;\r
+ for (i = 1; i <= state.rembase; i++) {\r
basetbl[i] = i;\r
- ibqx = d.baseqx[i];\r
- ibqy = d.baseqy[i];\r
+ ibqx = state.baseqx[i];\r
+ ibqy = state.baseqy[i];\r
bdist[i] = sqrt(square(ibqx-sx) + square(ibqy-sy));\r
}\r
- if (d.rembase > 1) {\r
+ if (state.rembase > 1) {\r
/* sort into nearest first order */\r
int iswitch;\r
do {\r
iswitch = 0;\r
- for (i=1; i < d.rembase-1; i++) {\r
+ for (i=1; i < state.rembase-1; i++) {\r
if (bdist[i] > bdist[i+1]) {\r
int ti = basetbl[i];\r
double t = bdist[i];\r
without too many Klingons, and not already under attack. */\r
ifindit = iwhichb = 0;\r
\r
- for (i2 = 1; i2 <= d.rembase; i2++) {\r
+ for (i2 = 1; i2 <= state.rembase; i2++) {\r
i = basetbl[i2]; /* bug in original had it not finding nearest*/\r
- ibqx = d.baseqx[i];\r
- ibqy = d.baseqy[i];\r
+ ibqx = state.baseqx[i];\r
+ ibqy = state.baseqy[i];\r
if ((ibqx == quadx && ibqy == quady) ||\r
(ibqx == batx && ibqy == baty) ||\r
- d.galaxy[ibqx][ibqy] > 899) continue;\r
+ state.galaxy[ibqx][ibqy] > 899) continue;\r
/* if there is a commander, an no other base is appropriate,\r
we will take the one with the commander */\r
- for (j = 1; j <= d.remcom; j++) {\r
- if (ibqx==d.cx[j] && ibqy==d.cy[j] && ifindit!= 2) {\r
+ for (j = 1; j <= state.remcom; j++) {\r
+ if (ibqx==state.cx[j] && ibqy==state.cy[j] && ifindit!= 2) {\r
ifindit = 2;\r
iwhichb = i;\r
break;\r
}\r
}\r
- if (j > d.remcom) { /* no commander -- use this one */\r
+ if (j > state.remcom) { /* no commander -- use this one */\r
ifindit = 1;\r
iwhichb = i;\r
break;\r
}\r
}\r
if (ifindit==0) return; /* Nothing suitable -- wait until next time*/\r
- ibqx = d.baseqx[iwhichb];\r
- ibqy = d.baseqy[iwhichb];\r
+ ibqx = state.baseqx[iwhichb];\r
+ ibqy = state.baseqy[iwhichb];\r
/* decide how to move toward base */\r
- ideltax = ibqx - d.isx;\r
- ideltay = ibqy - d.isy;\r
+ ideltax = ibqx - state.isx;\r
+ ideltay = ibqy - state.isy;\r
}\r
/* Maximum movement is 1 quadrant in either or both axis */\r
if (ideltax > 1) ideltax = 1;\r
if (ideltay < -1) ideltay = -1;\r
\r
/* try moving in both x and y directions */\r
- iqx = d.isx + ideltax;\r
- iqy = d.isy + ideltax;\r
+ iqx = state.isx + ideltax;\r
+ iqy = state.isy + ideltax;\r
if (checkdest(iqx, iqy, flag, ipage)) {\r
/* failed -- try some other maneuvers */\r
if (ideltax==0 || ideltay==0) {\r
/* attempt angle move */\r
if (ideltax != 0) {\r
- iqy = d.isy + 1;\r
+ iqy = state.isy + 1;\r
if (checkdest(iqx, iqy, flag, ipage)) {\r
- iqy = d.isy - 1;\r
+ iqy = state.isy - 1;\r
checkdest(iqx, iqy, flag, ipage);\r
}\r
}\r
else {\r
- iqx = d.isx + 1;\r
+ iqx = state.isx + 1;\r
if (checkdest(iqx, iqy, flag, ipage)) {\r
- iqx = d.isx - 1;\r
+ iqx = state.isx - 1;\r
checkdest(iqx, iqy, flag, ipage);\r
}\r
}\r
}\r
else {\r
/* try moving just in x or y */\r
- iqy = d.isy;\r
+ iqy = state.isy;\r
if (checkdest(iqx, iqy, flag, ipage)) {\r
- iqy = d.isy + ideltay;\r
- iqx = d.isx;\r
+ iqy = state.isy + ideltay;\r
+ iqx = state.isx;\r
checkdest(iqx, iqy, flag, ipage);\r
}\r
}\r
}\r
/* check for a base */\r
- if (d.rembase == 0) {\r
+ if (state.rembase == 0) {\r
future[FSCMOVE] = 1e30;\r
}\r
- else for (i=1; i<=d.rembase; i++) {\r
- ibqx = d.baseqx[i];\r
- ibqy = d.baseqy[i];\r
- if (ibqx==d.isx && ibqy == d.isy && d.isx != batx && d.isy != baty) {\r
+ else for (i=1; i<=state.rembase; i++) {\r
+ ibqx = state.baseqx[i];\r
+ ibqy = state.baseqy[i];\r
+ if (ibqx==state.isx && ibqy == state.isy && state.isx != batx && state.isy != baty) {\r
/* attack the base */\r
if (flag) return; /* no, don't attack base! */\r
iseenit = 0;\r
isatb=1;\r
- future[FSCDBAS] = d.date + 1.0 +2.0*Rand();\r
- if (batx != 0) future[FSCDBAS] += future[FCDBAS]-d.date;\r
+ future[FSCDBAS] = state.date + 1.0 +2.0*Rand();\r
+ if (batx != 0) future[FSCDBAS] += future[FCDBAS]-state.date;\r
if (damage[DRADIO] > 0 && condit != IHDOCKED)\r
return; /* no warning */\r
iseenit = 1;\r
if (*ipage == 0) pause(1);\r
*ipage=1;\r
proutn("Lt. Uhura- \"Captain, the starbase in");\r
- cramlc(1, d.isx, d.isy);\r
+ cramlc(1, state.isx, state.isy);\r
skip(1);\r
prout(" reports that it is under attack from the Klingon Super-commander.");\r
proutn(" It can survive until stardate ");\r
#endif\r
(Rand() > 0.2 ||\r
(damage[DRADIO] > 0.0 && condit != IHDOCKED) ||\r
- starch[d.isx][d.isy] > 0))\r
+ starch[state.isx][state.isy] > 0))\r
return;\r
if (*ipage==0) pause(1);\r
*ipage = 1;\r
prout("Lt. Uhura- \"Captain, Starfleet Intelligence reports");\r
proutn(" the Super-commander is in");\r
- cramlc(1, d.isx, d.isy);\r
+ cramlc(1, state.isx, state. isy);\r
prout(".\"");\r
return;\r
}\r
damage[l] += Time + extradm; /* Damage for at least time of travel! */\r
}\r
shldup = 0;\r
- if (d.remkl) {\r
+ if (state.remkl) {\r
pause(2);\r
dreprt();\r
}\r
case IHB: /* Hit a base */\r
prout("***STARBASE DESTROYED..");\r
if (starch[quadx][quady] < 0) starch[quadx][quady] = 0;\r
- for (ll=1; ll<=d.rembase; ll++) {\r
- if (d.baseqx[ll]==quadx && d.baseqy[ll]==quady) {\r
- d.baseqx[ll]=d.baseqx[d.rembase];\r
- d.baseqy[ll]=d.baseqy[d.rembase];\r
+ for (ll=1; ll<=state.rembase; ll++) {\r
+ if (state.baseqx[ll]==quadx && state.baseqy[ll]==quady) {\r
+ state.baseqx[ll]=state.baseqx[state.rembase];\r
+ state.baseqy[ll]=state.baseqy[state.rembase];\r
break;\r
}\r
}\r
quad[ix][iy]=IHDOT;\r
- d.rembase--;\r
+ state.rembase--;\r
basex=basey=0;\r
- d.galaxy[quadx][quady] -= 10;\r
- d.basekl++;\r
+ state.galaxy[quadx][quady] -= 10;\r
+ state.basekl++;\r
newcnd();\r
return;\r
case IHP: /* Hit a planet */\r
crmena(1, iquad, 2, ix, iy);\r
prout(" destroyed.");\r
- d.nplankl++;\r
- d.newstuf[quadx][quady] -= 1;\r
- d.plnets[iplnet] = nulplanet;\r
+ state.nplankl++;\r
+ state.newstuf[quadx][quady] -= 1;\r
+ state.plnets[iplnet] = nulplanet;\r
iplnet = 0;\r
plnetx = plnety = 0;\r
quad[ix][iy] = IHDOT;\r
r = (Rand()+Rand())*0.5 -0.5;\r
r += 0.002*kpower[l]*r;\r
torpedo(course, r, jx, jy, &hit);\r
- if (d.remkl==0) finish(FWON); /* Klingons did themselves in! */\r
- if (d.galaxy[quadx][quady] == 1000 ||\r
+ if (state.remkl==0) finish(FWON); /* Klingons did themselves in! */\r
+ if (state.galaxy[quadx][quady] == 1000 ||\r
alldone) return; /* Supernova or finished */\r
if (hit == 0) continue;\r
}\r
/* Decide what kind of enemy it is and update approriately */\r
if (type == IHR) {\r
/* chalk up a Romulan */\r
- d.newstuf[quadx][quady] -= 10;\r
+ state.newstuf[quadx][quady] -= 10;\r
irhere--;\r
- d.nromkl++;\r
- d.nromrem--;\r
+ state.nromkl++;\r
+ state.nromrem--;\r
}\r
else if (type == IHT) {\r
/* Killed a Tholian */\r
}\r
else {\r
/* Some type of a Klingon */\r
- d.galaxy[quadx][quady] -= 100;\r
+ state.galaxy[quadx][quady] -= 100;\r
klhere--;\r
- d.remkl--;\r
+ state.remkl--;\r
switch (type) {\r
case IHC:\r
comhere = 0;\r
- for (i=1; i<=d.remcom; i++)\r
- if (d.cx[i]==quadx && d.cy[i]==quady) break;\r
- d.cx[i] = d.cx[d.remcom];\r
- d.cy[i] = d.cy[d.remcom];\r
- d.cx[d.remcom] = 0;\r
- d.cy[d.remcom] = 0;\r
- d.remcom--;\r
+ for (i=1; i<=state.remcom; i++)\r
+ if (state.cx[i]==quadx && state.cy[i]==quady) break;\r
+ state.cx[i] = state.cx[state.remcom];\r
+ state.cy[i] = state.cy[state.remcom];\r
+ state.cx[state.remcom] = 0;\r
+ state.cy[state.remcom] = 0;\r
+ state.remcom--;\r
future[FTBEAM] = 1e30;\r
- if (d.remcom != 0)\r
- future[FTBEAM] = d.date + expran(1.0*incom/d.remcom);\r
- d.killc++;\r
+ if (state.remcom != 0)\r
+ future[FTBEAM] = state.date + expran(1.0*incom/state.remcom);\r
+ state.killc++;\r
break;\r
case IHK:\r
- d.killk++;\r
+ state.killk++;\r
break;\r
case IHS:\r
- d.nscrem = ishere = d.isx = d.isy = isatb = iscate = 0;\r
- d.nsckill = 1;\r
+ state.nscrem = ishere = state.isx = state.isy = isatb = iscate = 0;\r
+ state.nsckill = 1;\r
future[FSCMOVE] = future[FSCDBAS] = 1e30;\r
break;\r
}\r
}\r
\r
/* For each kind of enemy, finish message to player */\r
- prout(" destroyed.");\r
+ prout(" destroyestate.");\r
quad[ix][iy] = IHDOT;\r
- if (d.remkl==0) return;\r
+ if (state.remkl==0) return;\r
\r
- d.remtime = d.remres/(d.remkl + 4*d.remcom);\r
+ state.remtime = state.remres/(state.remkl + 4*state.remcom);\r
\r
if (type == IHT) return;\r
\r
proutn("Torpedo track- ");\r
}\r
torpedo(course[i], r, sectx, secty, &dummy);\r
- if (alldone || d.galaxy[quadx][quady]==1000) return;\r
+ if (alldone || state.galaxy[quadx][quady]==1000) return;\r
}\r
- if (d.remkl==0) finish(FWON);\r
+ if (state.remkl==0) finish(FWON);\r
}\r
\r
\r
skip(1);\r
if (kpow == 0) {\r
deadkl(ii, jj, ienm, ii, jj);\r
- if (d.remkl==0) finish(FWON);\r
+ if (state.remkl==0) finish(FWON);\r
if (alldone) return;\r
kk--; /* don't do the increment */\r
}\r
void events(void) {\r
\r
int ictbeam=0, ipage=0, istract=0, line, i, j, k, l, ixhold, iyhold;\r
- double fintim = d.date + Time, datemin, xtime, repair, yank;\r
+ double fintim = state.date + Time, datemin, xtime, repair, yank;\r
\r
\r
#ifdef DEBUG\r
\r
if (stdamtim == 1e30 && damage[DRADIO] != 0.0) {\r
/* chart will no longer be updated because radio is dead */\r
- stdamtim = d.date;\r
+ stdamtim = state.date;\r
for (i=1; i <= 8 ; i++)\r
for (j=1; j <= 8; j++)\r
- if (starch[i][j] == 1) starch[i][j] = d.galaxy[i][j]+1000;\r
+ if (starch[i][j] == 1) starch[i][j] = state.galaxy[i][j]+1000;\r
}\r
\r
for (;;) {\r
line = l;\r
datemin = future[l];\r
}\r
- xtime = datemin-d.date;\r
- d.date = datemin;\r
+ xtime = datemin-state.date;\r
+ state.date = datemin;\r
/* Decrement Federation resources and recompute remaining time */\r
- d.remres -= (d.remkl+4*d.remcom)*xtime;\r
- d.remtime = d.remres/(d.remkl+4*d.remcom);\r
- if (d.remtime <=0) {\r
+ state.remres -= (state.remkl+4*state.remcom)*xtime;\r
+ state.remtime = state.remres/(state.remkl+4*state.remcom);\r
+ if (state.remtime <=0) {\r
finish(FDEPLETE);\r
return;\r
}\r
if (ipage==0) pause(1);\r
ipage=1;\r
snova(0,0);\r
- future[FSNOVA] = d.date + expran(0.5*intime);\r
- if (d.galaxy[quadx][quady] == 1000) return;\r
+ future[FSNOVA] = state.date + expran(0.5*intime);\r
+ if (state.galaxy[quadx][quady] == 1000) return;\r
break;\r
case FSPY: /* Check with spy to see if S.C. should tractor beam */\r
- if (d.nscrem == 0 ||\r
+ if (state.nscrem == 0 ||\r
ictbeam+istract > 0 ||\r
condit==IHDOCKED || isatb==1 || iscate==1) return;\r
if (ientesc ||\r
(torps < 5 || damage[DPHOTON] > 0))) {\r
/* Tractor-beam her! */\r
istract=1;\r
- yank = square(d.isx-quadx) + square(d.isy-quady);\r
+ yank = square(state.isx-quadx) + square(state.isy-quady);\r
/*********TBEAM CODE***********/\r
}\r
else return;\r
case FTBEAM: /* Tractor beam */\r
if (line==FTBEAM) {\r
- if (d.remcom == 0) {\r
+ if (state.remcom == 0) {\r
future[FTBEAM] = 1e30;\r
break;\r
}\r
- i = Rand()*d.remcom+1.0;\r
- yank = square(d.cx[i]-quadx) + square(d.cy[i]-quady);\r
+ i = Rand()*state.remcom+1.0;\r
+ yank = square(state.cx[i]-quadx) + square(state.cy[i]-quady);\r
if (istract || condit == IHDOCKED || yank == 0) {\r
/* Drats! Have to reschedule */\r
- future[FTBEAM] = d.date + Time +\r
- expran(1.5*intime/d.remcom);\r
+ future[FTBEAM] = state.date + Time +\r
+ expran(1.5*intime/state.remcom);\r
break;\r
}\r
}\r
}\r
}\r
if (line==0) {\r
- quadx = d.isx;\r
- quady = d.isy;\r
+ quadx = state.isx;\r
+ quady = state.isy;\r
}\r
else {\r
- quadx = d.cx[i];\r
- quady = d.cy[i];\r
+ quadx = state.cx[i];\r
+ quady = state.cy[i];\r
}\r
iran10(§x, §y);\r
crmshp();\r
cramlc(2, sectx, secty);\r
skip(1);\r
if (resting) {\r
- prout("(Remainder of rest/repair period cancelled.)");\r
+ prout("(Remainder of rest/repair period cancellestate.)");\r
resting = 0;\r
}\r
if (shldup==0) {\r
}\r
newqad(0);\r
/* Adjust finish time to time of tractor beaming */\r
- fintim = d.date+Time;\r
- if (d.remcom <= 0) future[FTBEAM] = 1e30;\r
- else future[FTBEAM] = d.date+Time+expran(1.5*intime/d.remcom);\r
+ fintim = state.date+Time;\r
+ if (state.remcom <= 0) future[FTBEAM] = 1e30;\r
+ else future[FTBEAM] = state.date+Time+expran(1.5*intime/state.remcom);\r
break;\r
case FSNAP: /* Snapshot of the universe (for time warp) */\r
- snapsht = d;\r
- d.snap = 1;\r
- future[FSNAP] = d.date + expran(0.5 * intime);\r
+ snapsht = state;\r
+ state.snap = 1;\r
+ future[FSNAP] = state.date + expran(0.5 * intime);\r
break;\r
case FBATTAK: /* Commander attacks starbase */\r
- if (d.remcom==0 || d.rembase==0) {\r
+ if (state.remcom==0 || state.rembase==0) {\r
/* no can do */\r
future[FBATTAK] = future[FCDBAS] = 1e30;\r
break;\r
}\r
i = 0;\r
- for (j=1; j<=d.rembase; j++) {\r
- for (k=1; k<=d.remcom; k++)\r
- if (d.baseqx[j]==d.cx[k] && d.baseqy[j]==d.cy[k] &&\r
- (d.baseqx[j]!=quadx || d.baseqy[j]!=quady) &&\r
- (d.baseqx[j]!=d.isx || d.baseqy[j]!=d.isy)) {\r
+ for (j=1; j<=state.rembase; j++) {\r
+ for (k=1; k<=state.remcom; k++)\r
+ if (state.baseqx[j]==state.cx[k] && state.baseqy[j]==state.cy[k] &&\r
+ (state.baseqx[j]!=quadx || state.baseqy[j]!=quady) &&\r
+ (state.baseqx[j]!=state.isx || state.baseqy[j]!=state.isy)) {\r
i = 1;\r
break;\r
}\r
if (i == 1) break;\r
}\r
- if (j>d.rembase) {\r
+ if (j>state.rembase) {\r
/* no match found -- try later */\r
- future[FBATTAK] = d.date + expran(0.3*intime);\r
+ future[FBATTAK] = state.date + expran(0.3*intime);\r
future[FCDBAS] = 1e30;\r
break;\r
}\r
/* commander + starbase combination found -- launch attack */\r
- batx = d.baseqx[j];\r
- baty = d.baseqy[j];\r
- future[FCDBAS] = d.date+1.0+3.0*Rand();\r
+ batx = state.baseqx[j];\r
+ baty = state.baseqy[j];\r
+ future[FCDBAS] = state.date+1.0+3.0*Rand();\r
if (isatb) /* extra time if SC already attacking */\r
- future[FCDBAS] += future[FSCDBAS]-d.date;\r
+ future[FCDBAS] += future[FSCDBAS]-state.date;\r
future[FBATTAK] = future[FCDBAS] +expran(0.3*intime);\r
iseenit = 0;\r
if (damage[DRADIO] != 0.0 &&\r
case FSCDBAS: /* Supercommander destroys base */\r
future[FSCDBAS] = 1e30;\r
isatb = 2;\r
- if (d.galaxy[d.isx][d.isy]%100 < 10) break; /* WAS RETURN! */\r
+ if (state.galaxy[state.isx][state.isy]%100 < 10) break; /* WAS RETURN! */\r
ixhold = batx;\r
iyhold = baty;\r
- batx = d.isx;\r
- baty = d.isy;\r
+ batx = state.isx;\r
+ baty = state.isy;\r
case FCDBAS: /* Commander succeeds in destroying base */\r
if (line==FCDBAS) {\r
future[FCDBAS] = 1e30;\r
/* find the lucky pair */\r
- for (i = 1; i <= d.remcom; i++)\r
- if (d.cx[i]==batx && d.cy[i]==baty) break;\r
- if (i > d.remcom || d.rembase == 0 ||\r
- d.galaxy[batx][baty] % 100 < 10) {\r
+ for (i = 1; i <= state.remcom; i++)\r
+ if (state.cx[i]==batx && state.cy[i]==baty) break;\r
+ if (i > state.remcom || state.rembase == 0 ||\r
+ state.galaxy[batx][baty] % 100 < 10) {\r
/* No action to take after all */\r
batx = baty = 0;\r
break;\r
basex=basey=0;\r
newcnd();\r
skip(1);\r
- prout("Spock- \"Captain, I believe the starbase has been destroyed.\"");\r
+ prout("Spock- \"Captain, I believe the starbase has been destroyestate.\"");\r
}\r
- else if (d.rembase != 1 &&\r
+ else if (state.rembase != 1 &&\r
(damage[DRADIO] <= 0.0 || condit == IHDOCKED)) {\r
/* Get word via subspace radio */\r
if (ipage==0) pause(1);\r
else prout("a Klingon Commander");\r
}\r
/* Remove Starbase from galaxy */\r
- d.galaxy[batx][baty] -= 10;\r
- for (i=1; i <= d.rembase; i++)\r
- if (d.baseqx[i]==batx && d.baseqy[i]==baty) {\r
- d.baseqx[i]=d.baseqx[d.rembase];\r
- d.baseqy[i]=d.baseqy[d.rembase];\r
+ state.galaxy[batx][baty] -= 10;\r
+ for (i=1; i <= state.rembase; i++)\r
+ if (state.baseqx[i]==batx && state.baseqy[i]==baty) {\r
+ state.baseqx[i]=state.baseqx[state.rembase];\r
+ state.baseqy[i]=state.baseqy[state.rembase];\r
}\r
- d.rembase--;\r
+ state.rembase--;\r
if (isatb == 2) {\r
/* reinstate a commander's base attack */\r
batx = ixhold;\r
}\r
break;\r
case FSCMOVE: /* Supercommander moves */\r
- future[FSCMOVE] = d.date+0.2777;\r
+ future[FSCMOVE] = state.date+0.2777;\r
if (ientesc+istract==0 &&\r
isatb!=1 &&\r
(iscate!=1 || justin==1)) scom(&ipage);\r
break;\r
case FDSPROB: /* Move deep space probe */\r
- future[FDSPROB] = d.date + 0.01;\r
+ future[FDSPROB] = state.date + 0.01;\r
probex += probeinx;\r
probey += probeiny;\r
i = (int)(probex/10 +0.05);\r
probecx = i;\r
probecy = j;\r
if (i < 1 || i > 8 || j < 1 || j > 8 ||\r
- d.galaxy[probecx][probecy] == 1000) {\r
+ state.galaxy[probecx][probecy] == 1000) {\r
// Left galaxy or ran into supernova\r
if (damage[DRADIO]==0.0 || condit == IHDOCKED) {\r
if (ipage==0) pause(1);\r
radio. */\r
if (damage[DRADIO] == 0.0 || condit == IHDOCKED)\r
starch[probecx][probecy] = damage[DRADIO] > 0.0 ?\r
- d.galaxy[probecx][probecy]+1000 : 1;\r
+ state.galaxy[probecx][probecy]+1000 : 1;\r
proben--; // One less to travel\r
if (proben == 0 && isarmed &&\r
- d.galaxy[probecx][probecy] % 10 > 0) {\r
+ state.galaxy[probecx][probecy] % 10 > 0) {\r
/* lets blow the sucker! */\r
snova(1,0);\r
future[FDSPROB] = 1e30;\r
- if (d.galaxy[quadx][quady] == 1000) return;\r
+ if (state.galaxy[quadx][quady] == 1000) return;\r
}\r
break;\r
}\r
}\r
origTime = delay = aaitem;\r
if (delay <= 0.0) return;\r
- if (delay >= d.remtime || nenhere != 0) {\r
+ if (delay >= state.remtime || nenhere != 0) {\r
prout("Are you sure? ");\r
if (ja() == 0) return;\r
}\r
do {\r
if (delay <= 0) resting = 0;\r
if (resting == 0) {\r
- cramf(d.remtime, 0, 2);\r
+ cramf(state.remtime, 0, 2);\r
prout(" stardates left.");\r
return;\r
}\r
/* Repair Deathray if long rest at starbase */\r
if (origTime-delay >= 9.99 && condit == IHDOCKED)\r
damage[DDRAY] = 0.0;\r
- } while (d.galaxy[quadx][quady] != 1000); // leave if quadrant supernovas\r
+ } while (state.galaxy[quadx][quady] != 1000); // leave if quadrant supernovas\r
\r
resting = 0;\r
Time = 0;\r
quad[ix][iy] = IHDOT;\r
crmena(1, IHSTAR, 2, ix, iy);\r
prout(" novas.");\r
- d.galaxy[quadx][quady] -= 1;\r
- d.starkl++;\r
+ state.galaxy[quadx][quady] -= 1;\r
+ state.starkl++;\r
\r
/* Set up stack to recursively trigger adjacent stars */\r
bot = top = top2 = 1;\r
top2++;\r
hits[top2][1]=ii;\r
hits[top2][2]=jj;\r
- d.galaxy[quadx][quady] -= 1;\r
- d.starkl++;\r
+ state.galaxy[quadx][quady] -= 1;\r
+ state.starkl++;\r
crmena(1, IHSTAR, 2, ii, jj);\r
prout(" novas.");\r
quad[ii][jj] = IHDOT;\r
break;\r
case IHP: /* Destroy planet */\r
- d.newstuf[quadx][quady] -= 1;\r
- d.nplankl++;\r
+ state.newstuf[quadx][quady] -= 1;\r
+ state.nplankl++;\r
crmena(1, IHP, 2, ii, jj);\r
prout(" destroyed.");\r
- d.plnets[iplnet] = nulplanet;\r
+ state.plnets[iplnet] = nulplanet;\r
iplnet = plnetx = plnety = 0;\r
if (landed == 1) {\r
finish(FPNOVA);\r
quad[ii][jj] = IHDOT;\r
break;\r
case IHB: /* Destroy base */\r
- d.galaxy[quadx][quady] -= 10;\r
- for (i = 1; i <= d.rembase; i++)\r
- if (d.baseqx[i]==quadx && d.baseqy[i]==quady) break;\r
- d.baseqx[i] = d.baseqx[d.rembase];\r
- d.baseqy[i] = d.baseqy[d.rembase];\r
- d.rembase--;\r
+ state.galaxy[quadx][quady] -= 10;\r
+ for (i = 1; i <= state.rembase; i++)\r
+ if (state.baseqx[i]==quadx && state.baseqy[i]==quady) break;\r
+ state.baseqx[i] = state.baseqx[state.rembase];\r
+ state.baseqy[i] = state.baseqy[state.rembase];\r
+ state.rembase--;\r
basex = basey = 0;\r
- d.basekl++;\r
+ state.basekl++;\r
newcnd();\r
crmena(1, IHB, 2, ii, jj);\r
prout(" destroyed.");\r
left of universe */\r
for (nqx = 1; nqx<=8; nqx++) {\r
for (nqy = 1; nqy<=8; nqy++) {\r
- stars += d.galaxy[nqx][nqy] % 10;\r
+ stars += state.galaxy[nqx][nqy] % 10;\r
}\r
}\r
if (stars == 0) return; /* nothing to supernova exists */\r
num = Rand()*stars + 1;\r
for (nqx = 1; nqx<=8; nqx++) {\r
for (nqy = 1; nqy<=8; nqy++) {\r
- num -= d.galaxy[nqx][nqy] % 10;\r
+ num -= state.galaxy[nqx][nqy] % 10;\r
if (num <= 0) break;\r
}\r
if (num <=0) break;\r
if (damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
skip(1);\r
proutn("Message from Starfleet Command Stardate ");\r
- cramf(d.date, 0, 1);\r
+ cramf(state.date, 0, 1);\r
skip(1);\r
proutn(" Supernova in");\r
cramlc(1, nqx, nqy);\r
else {\r
/* we are in the quadrant! */\r
insipient = 1;\r
- num = Rand()* (d.galaxy[nqx][nqy]%10) + 1;\r
+ num = Rand()* (state.galaxy[nqx][nqy]%10) + 1;\r
for (nsx=1; nsx < 10; nsx++) {\r
for (nsy=1; nsy < 10; nsy++) {\r
if (quad[nsx][nsy]==IHSTAR) {\r
}\r
}\r
/* destroy any Klingons in supernovaed quadrant */\r
- num=d.galaxy[nqx][nqy];\r
+ num=state.galaxy[nqx][nqy];\r
kldead = num/100;\r
comdead = iscdead = 0;\r
- if (nqx==d.isx && nqy == d.isy) {\r
+ if (nqx==state.isx && nqy == state.isy) {\r
/* did in the Supercommander! */\r
- d.nscrem = d.isx = d.isy = isatb = iscate = 0;\r
+ state.nscrem = state.isx = state.isy = isatb = iscate = 0;\r
iscdead = 1;\r
future[FSCMOVE] = future[FSCDBAS] = 1e30;\r
}\r
- d.remkl -= kldead;\r
- if (d.remcom) {\r
- int maxloop = d.remcom, l;\r
+ state.remkl -= kldead;\r
+ if (state.remcom) {\r
+ int maxloop = state.remcom, l;\r
for (l = 1; l <= maxloop; l++) {\r
- if (d.cx[l] == nqx && d.cy[l] == nqy) {\r
- d.cx[l] = d.cx[d.remcom];\r
- d.cy[l] = d.cy[d.remcom];\r
- d.cx[d.remcom] = d.cy[d.remcom] = 0;\r
- d.remcom--;\r
+ if (state.cx[l] == nqx && state.cy[l] == nqy) {\r
+ state.cx[l] = state.cx[state.remcom];\r
+ state.cy[l] = state.cy[state.remcom];\r
+ state.cx[state.remcom] = state.cy[state.remcom] = 0;\r
+ state.remcom--;\r
kldead--;\r
comdead++;\r
- if (d.remcom==0) future[FTBEAM] = 1e30;\r
+ if (state.remcom==0) future[FTBEAM] = 1e30;\r
break;\r
}\r
}\r
}\r
/* destroy Romulans and planets in supernovaed quadrant */\r
- num = d.newstuf[nqx][nqy];\r
- d.newstuf[nqx][nqy] = 0;\r
+ num = state.newstuf[nqx][nqy];\r
+ state.newstuf[nqx][nqy] = 0;\r
nrmdead = num/10;\r
- d.nromrem -= nrmdead;\r
+ state.nromrem -= nrmdead;\r
npdead = num - nrmdead*10;\r
if (npdead) {\r
int l;\r
for (l = 1; l <= inplan; l++)\r
- if (d.plnets[l].x == nqx && d.plnets[l].y == nqy) {\r
- d.plnets[l] = nulplanet;\r
+ if (state.plnets[l].x == nqx && state.plnets[l].y == nqy) {\r
+ state.plnets[l] = nulplanet;\r
}\r
}\r
/* Destroy any base in supernovaed quadrant */\r
- if (d.rembase) {\r
- int maxloop = d.rembase, l;\r
+ if (state.rembase) {\r
+ int maxloop = state.rembase, l;\r
for (l = 1; l <= maxloop; l++)\r
- if (d.baseqx[l]==nqx && d.baseqy[l]==nqy) {\r
- d.baseqx[l] = d.baseqx[d.rembase];\r
- d.baseqy[l] = d.baseqy[d.rembase];\r
- d.baseqx[d.rembase] = d.baseqy[d.rembase] = 0;\r
- d.rembase--;\r
+ if (state.baseqx[l]==nqx && state.baseqy[l]==nqy) {\r
+ state.baseqx[l] = state.baseqx[state.rembase];\r
+ state.baseqy[l] = state.baseqy[state.rembase];\r
+ state.baseqx[state.rembase] = state.baseqy[state.rembase] = 0;\r
+ state.rembase--;\r
break;\r
}\r
}\r
/* If starship caused supernova, tally up destruction */\r
if (insx) {\r
- num = d.galaxy[nqx][nqy] % 100;\r
- d.starkl += num % 10;\r
- d.basekl += num/10;\r
- d.killk += kldead;\r
- d.killc += comdead;\r
- d.nromkl += nrmdead;\r
- d.nplankl += npdead;\r
- d.nsckill += iscdead;\r
+ num = state.galaxy[nqx][nqy] % 100;\r
+ state.starkl += num % 10;\r
+ state.basekl += num/10;\r
+ state.killk += kldead;\r
+ state.killc += comdead;\r
+ state.nromkl += nrmdead;\r
+ state.nplankl += npdead;\r
+ state.nsckill += iscdead;\r
}\r
/* mark supernova in galaxy and in star chart */\r
if ((quadx == nqx && quady == nqy) ||\r
damage[DRADIO] == 0 ||\r
condit == IHDOCKED)\r
starch[nqx][nqy] = 1;\r
- d.galaxy[nqx][nqy] = 1000;\r
+ state.galaxy[nqx][nqy] = 1000;\r
/* If supernova destroys last klingons give special message */\r
- if (d.remkl==0 && (nqx != quadx || nqy != quady)) {\r
+ if (state.remkl==0 && (nqx != quadx || nqy != quady)) {\r
skip(2);\r
if (insx == 0) prout("Lucky you!");\r
proutn("A supernova in");\r
int igotit = 0;\r
alldone = 1;\r
skip(3);\r
- printf("It is stardate %.1f .\n\n", d.date);\r
+ printf("It is stardate %.1f .\n\n", state.date);\r
switch (ifin) {\r
case FWON: // Game has been won\r
- if (d.nromrem != 0)\r
+ if (state.nromrem != 0)\r
printf("The remaining %d Romulans surrender to Starfleet Command.\n",\r
- d.nromrem);\r
+ state.nromrem);\r
\r
prout("You have smashed the Klingon invasion fleet and saved");\r
prout("the Federation.");\r
gamewon=1;\r
if (alive) {\r
double badpt;\r
- badpt = 5.*d.starkl + casual + 10.*d.nplankl +\r
- 45.*nhelp+100.*d.basekl;\r
+ badpt = 5.*state.starkl + casual + 10.*state.nplankl +\r
+ 45.*nhelp+100.*state.basekl;\r
if (ship == IHF) badpt += 100.0;\r
else if (ship == 0) badpt += 200.0;\r
if (badpt < 100.0) badpt = 0.0; // Close enough!\r
- if (d.date-indate < 5.0 ||\r
+ if (state.date-indate < 5.0 ||\r
// killsPerDate >= RateMax\r
- (d.killk+d.killc+d.nsckill)/(d.date-indate) >=\r
+ (state.killk+state.killc+state.nsckill)/(state.date-indate) >=\r
0.1*skill*(skill+1.0) + 0.1 + 0.008*badpt) {\r
skip(1);\r
prout("In fact, you have done so well that Starfleet Command");\r
prout("promotes you to Commodore Emeritus.");\r
skip(1);\r
prout("Now that you think you're really good, try playing");\r
- prout("the \"Emeritus\" game. It will splatter your ego.");\r
+ prout("the \"Emeritus\" frozen. It will splatter your ego.");\r
break;\r
case 5:\r
skip(1);\r
prout("conquered. Your starship is now Klingon property,");\r
prout("and you are put on trial as a war criminal. On the");\r
proutn("basis of your record, you are ");\r
- if (d.remkl*3.0 > inkling) {\r
+ if (state.remkl*3.0 > inkling) {\r
prout("aquitted.");\r
skip(1);\r
prout("LIVE LONG AND PROSPER.");\r
if (ship==IHF) ship= 0;\r
else if (ship == IHE) ship = IHF;\r
alive = 0;\r
- if (d.remkl != 0) {\r
- double goodies = d.remres/inresor;\r
- double baddies = (d.remkl + 2.0*d.remcom)/(inkling+2.0*incom);\r
+ if (state.remkl != 0) {\r
+ double goodies = state.remres/inresor;\r
+ double baddies = (state.remkl + 2.0*state.remcom)/(inkling+2.0*incom);\r
if (goodies/baddies >= 1.0+0.5*Rand()) {\r
prout("As a result of your actions, a treaty with the Klingon");\r
prout("Empire has been signed. The terms of the treaty are");\r
}\r
\r
void score(void) {\r
- double timused = d.date - indate;\r
+ double timused = state.date - indate;\r
int ithperd, iwon, klship;\r
\r
pause(0);\r
\r
iskill = skill;\r
- if ((timused == 0 || d.remkl != 0) && timused < 5.0) timused = 5.0;\r
- perdate = (d.killc + d.killk + d.nsckill)/timused;\r
+ if ((timused == 0 || state.remkl != 0) && timused < 5.0) timused = 5.0;\r
+ perdate = (state.killc + state.killk + state.nsckill)/timused;\r
ithperd = 500*perdate + 0.5;\r
iwon = 0;\r
if (gamewon) iwon = 100*skill;\r
if (ship == IHE) klship = 0;\r
else if (ship == IHF) klship = 1;\r
else klship = 2;\r
- if (gamewon == 0) d.nromrem = 0; // None captured if no win\r
- iscore = 10*d.killk + 50*d.killc + ithperd + iwon\r
- - 100*d.basekl - 100*klship - 45*nhelp -5*d.starkl - casual\r
- + 20*d.nromkl + 200*d.nsckill - 10*d.nplankl + d.nromrem;\r
+ if (gamewon == 0) state.nromrem = 0; // None captured if no win\r
+ iscore = 10*state.killk + 50*state.killc + ithperd + iwon\r
+ - 100*state.basekl - 100*klship - 45*nhelp -5*state.starkl - casual\r
+ + 20*state.nromkl + 200*state.nsckill - 10*state.nplankl + state.nromrem;\r
if (alive == 0) iscore -= 200;\r
skip(2);\r
prout("Your score --");\r
- if (d.nromkl)\r
+ if (state.nromkl)\r
printf("%6d Romulans destroyed %5d\n",\r
- d.nromkl,20*d.nromkl);\r
- if (d.nromrem)\r
+ state.nromkl,20*state.nromkl);\r
+ if (state.nromrem)\r
printf("%6d Romulans captured %5d\n",\r
- d.nromrem, d.nromrem);\r
- if (d.killk)\r
+ state.nromrem, state.nromrem);\r
+ if (state.killk)\r
printf("%6d ordinary Klingons destroyed %5d\n",\r
- d.killk, 10*d.killk);\r
- if (d.killc)\r
+ state.killk, 10*state.killk);\r
+ if (state.killc)\r
printf("%6d Klingon commanders destroyed %5d\n",\r
- d.killc, 50*d.killc);\r
- if (d.nsckill)\r
+ state.killc, 50*state.killc);\r
+ if (state.nsckill)\r
printf("%6d Super-Commander destroyed %5d\n",\r
- d.nsckill, 200*d.nsckill);\r
+ state.nsckill, 200*state.nsckill);\r
if (ithperd)\r
printf("%6.2f Klingons per stardate %5d\n",\r
perdate, ithperd);\r
- if (d.starkl)\r
+ if (state.starkl)\r
printf("%6d stars destroyed by your action %5d\n",\r
- d.starkl, -5*d.starkl);\r
- if (d.nplankl)\r
+ state.starkl, -5*state.starkl);\r
+ if (state.nplankl)\r
printf("%6d planets destroyed by your action %5d\n",\r
- d.nplankl, -10*d.nplankl);\r
- if (d.basekl)\r
+ state.nplankl, -10*state.nplankl);\r
+ if (state.basekl)\r
printf("%6d bases destroyed by your action %5d\n",\r
- d.basekl, -100*d.basekl);\r
+ state.basekl, -100*state.basekl);\r
if (nhelp)\r
printf("%6d calls for help from starbase %5d\n",\r
nhelp, -45*nhelp);\r
deltax /= bigger;\r
\r
/* If tractor beam is to occur, don't move full distance */\r
- if (d.date+Time >= future[FTBEAM]) {\r
+ if (state.date+Time >= future[FTBEAM]) {\r
trbeam = 1;\r
condit = IHRED;\r
- dist = dist*(future[FTBEAM]-d.date)/Time + 0.1;\r
- Time = future[FTBEAM] - d.date + 1e-5;\r
+ dist = dist*(future[FTBEAM]-state.date)/Time + 0.1;\r
+ Time = future[FTBEAM] - state.date + 1e-5;\r
}\r
/* Move within the quadrant */\r
quad[sectx][secty] = IHDOT;\r
(iy-ky[l])*(double)(iy-ky[l]));\r
kavgd[l] = 0.5 * (finald+kdist[l]);\r
}\r
- if (d.galaxy[quadx][quady] != 1000) attack(0);\r
+ if (state.galaxy[quadx][quady] != 1000) attack(0);\r
if (alldone) return;\r
}\r
/* compute final position -- new quadrant and sector */\r
kdist[l] = finald;\r
}\r
sortkl();\r
- if (d.galaxy[quadx][quady] != 1000 && iattak == 0)\r
+ if (state.galaxy[quadx][quady] != 1000 && iattak == 0)\r
attack(0);\r
for (l = 1 ; l <= nenhere; l++) kavgd[l] = kdist[l];\r
}\r
}\r
/* Make sure enough time is left for the trip */\r
Time = dist/0.095;\r
- if (Time >= d.remtime) {\r
+ if (Time >= state.remtime) {\r
prout("First Officer Spock- \"Captain, our speed under impulse");\r
prout("power is only 0.95 sectors per stardate. Are you sure");\r
prout("we dare spend the time?\"");\r
\r
/* Make sure enough time is left for the trip */\r
Time = 10.0*dist/wfacsq;\r
- if (Time >= 0.8*d.remtime) {\r
+ if (Time >= 0.8*state.remtime) {\r
skip(1);\r
prout("First Officer Spock- \"Captain, I compute that such");\r
proutn(" a trip would require approximately ");\r
- cramf(100.0*Time/d.remtime, 0, 2);\r
+ cramf(100.0*Time/state.remtime, 0, 2);\r
prout(" percent of our");\r
prout(" remaining time. Are you sure this is wise?\"");\r
if (ja() == 0) { ididit = 0; return;}\r
crmshp();\r
skip(1);\r
prout("safely out of quadrant.");\r
- starch[quadx][quady] = damage[DRADIO] > 0.0 ? d.galaxy[quadx][quady]+1000:1;\r
+ starch[quadx][quady] = damage[DRADIO] > 0.0 ? state.galaxy[quadx][quady]+1000:1;\r
\r
/* Try to use warp engines */\r
if (damage[DWARPEN]) {\r
return;\r
}\r
/* Repeat if another snova */\r
- } while (d.galaxy[quadx][quady] == 1000);\r
- if (d.remkl==0) finish(FWON); /* Snova killed remaining enemy. */\r
+ } while (state.galaxy[quadx][quady] == 1000);\r
+ if (state.remkl==0) finish(FWON); /* Snova killed remaining enemy. */\r
}\r
\r
void timwrp() {\r
int l, ll, gotit;\r
prout("***TIME WARP ENTERED.");\r
- if (d.snap && Rand() < 0.5) {\r
+ if (state.snap && Rand() < 0.5) {\r
/* Go back in time */\r
proutn("You are traveling backwards in time ");\r
- cramf(d.date-snapsht.date, 0, 2);\r
+ cramf(state.date-snapsht.date, 0, 2);\r
prout(" stardates.");\r
- d = snapsht;\r
- d.snap = 0;\r
- if (d.remcom) {\r
- future[FTBEAM] = d.date + expran(intime/d.remcom);\r
- future[FBATTAK] = d.date + expran(0.3*intime);\r
- }\r
- future[FSNOVA] = d.date + expran(0.5*intime);\r
- future[FSNAP] = d.date +expran(0.25*d.remtime); /* next snapshot will\r
+ state = snapsht;\r
+ state.snap = 0;\r
+ if (state.remcom) {\r
+ future[FTBEAM] = state.date + expran(intime/state.remcom);\r
+ future[FBATTAK] = state.date + expran(0.3*intime);\r
+ }\r
+ future[FSNOVA] = state.date + expran(0.5*intime);\r
+ future[FSNAP] = state.date +expran(0.25*state.remtime); /* next snapshot will\r
be sooner */\r
- if (d.nscrem) future[FSCMOVE] = 0.2777;\r
+ if (state.nscrem) future[FSCMOVE] = 0.2777;\r
isatb = 0;\r
future[FCDBAS] = future[FSCDBAS] = 1e30;\r
batx = baty = 0;\r
when on planet, which would give us two Galileos! */\r
gotit = 0;\r
for (l = 1; l <= inplan; l++) {\r
- if (d.plnets[l].known == 2) {\r
+ if (state.plnets[l].known == 2) {\r
gotit = 1;\r
if (iscraft==1 && ship==IHE) {\r
prout("Checkov- \"Security reports the Galileo has disappeared, Sir!");\r
}\r
\r
/* Revert star chart to earlier era, if it was known then*/\r
- if (damage[DRADIO]==0.0 || stdamtim > d.date) {\r
+ if (damage[DRADIO]==0.0 || stdamtim > state.date) {\r
for (l = 1; l <= 8; l++)\r
for (ll = 1; ll <= 8; ll++)\r
if (starch[l][ll] > 1)\r
- starch[l][ll]=damage[DRADIO]>0.0 ? d.galaxy[l][ll]+1000 :1;\r
+ starch[l][ll]=damage[DRADIO]>0.0 ? state.galaxy[l][ll]+1000 :1;\r
prout("Spock has reconstructed a correct star chart from memory");\r
- if (damage[DRADIO] > 0.0) stdamtim = d.date;\r
+ if (damage[DRADIO] > 0.0) stdamtim = state.date;\r
}\r
}\r
else {\r
probey = quady*10 + secty - 1;\r
probecx = quadx;\r
probecy = quady;\r
- future[FDSPROB] = d.date + 0.01; // Time to move one sector\r
+ future[FDSPROB] = state.date + 0.01; // Time to move one sector\r
prout("Ensign Chekov- \"The deep space probe is launched, Captain.\"");\r
return;\r
}\r
prout("Subspace radio damaged.");\r
return;\r
}\r
- if (d.rembase==0) {\r
+ if (state.rembase==0) {\r
prout("Lt. Uhura- \"Captain, I'm not getting any response from Starbase.\"");\r
return;\r
}\r
}\r
else {\r
ddist = 1e30;\r
- for (l = 1; l <= d.rembase; l++) {\r
- xdist=10.0*sqrt(square(d.baseqx[l]-quadx)+square(d.baseqy[l]-quady));\r
+ for (l = 1; l <= state.rembase; l++) {\r
+ xdist=10.0*sqrt(square(state.baseqx[l]-quadx)+square(state.baseqy[l]-quady));\r
if (xdist < ddist) {\r
ddist = xdist;\r
line = l;\r
}\r
}\r
/* Since starbase not in quadrant, set up new quadrant */\r
- quadx = d.baseqx[line];\r
- quady = d.baseqy[line];\r
+ quadx = state.baseqx[line];\r
+ quady = state.baseqy[line];\r
newqad(1);\r
}\r
/* dematerialize starship */\r
ididit = 1;\r
#if 0\r
/* Don't wory about this */\r
- if (future[FTBEAM] <= d.date+Time && d.remcom != 0 && condit != IHDOCKED) {\r
+ if (future[FTBEAM] <= state.date+Time && state.remcom != 0 && condit != IHDOCKED) {\r
/* We are about to be tractor beamed -- operation fails */\r
return 1;\r
}\r
events(); /* Used to avoid if future[FSCMOVE] within time */\r
// future[FSNOVA] = asave;\r
/*fails if game over, quadrant super-novas or we've moved to new quadrant*/\r
- if (alldone || d.galaxy[quadx][quady] == 1000 || justin != 0) return 1;\r
+ if (alldone || state.galaxy[quadx][quady] == 1000 || justin != 0) return 1;\r
return 0;\r
}\r
\r
prout("Spock- \"Planet report follows, Captain.\"");\r
skip(1);\r
for (i = 1; i <= inplan; i++) {\r
- if (d.plnets[i].known\r
+ if (state.plnets[i].known\r
#ifdef DEBUG\r
- || ( idebug && d.plnets[i].x !=0)\r
+ || ( idebug && state.plnets[i].x !=0)\r
#endif\r
) {\r
iknow = 1;\r
#ifdef DEBUG\r
- if (idebug && d.plnets[i].known==0) proutn("(Unknown) ");\r
+ if (idebug && state.plnets[i].known==0) proutn("(Unknown) ");\r
#endif\r
- cramlc(1, d.plnets[i].x, d.plnets[i].y);\r
+ cramlc(1, state.plnets[i].x, state.plnets[i].y);\r
proutn(" class ");\r
- proutn(classes[d.plnets[i].pclass]);\r
+ proutn(classes[state.plnets[i].pclass]);\r
proutn(" ");\r
- if (d.plnets[i].crystals == 0) proutn("no ");\r
+ if (state.plnets[i].crystals == 0) proutn("no ");\r
prout("dilithium crystals present.");\r
- if (d.plnets[i].known==2) \r
+ if (state.plnets[i].known==2) \r
prout(" Shuttle Craft Galileo on surface.");\r
}\r
}\r
proutn(" Planet at");\r
cramlc(2, plnetx, plnety);\r
proutn(" is of class ");\r
- proutn(classes[d.plnets[iplnet].pclass]);\r
+ proutn(classes[state.plnets[iplnet].pclass]);\r
prout(".");\r
- if (d.plnets[iplnet].known==2) \r
+ if (state.plnets[iplnet].known==2) \r
prout(" Sensors show Galileo still on surface.");\r
proutn(" Readings indicate");\r
- if (d.plnets[iplnet].crystals == 0) proutn(" no");\r
+ if (state.plnets[iplnet].crystals == 0) proutn(" no");\r
prout(" dilithium crystals present.\"");\r
- if (d.plnets[iplnet].known == 0) d.plnets[iplnet].known = 1;\r
+ if (state.plnets[iplnet].known == 0) state.plnets[iplnet].known = 1;\r
return;\r
}\r
\r
skip(1);\r
if (damage[DTRANSP] != 0) {\r
prout("Transporter damaged.");\r
- if (damage[DSHUTTL]==0 && (d.plnets[iplnet].known==2 || iscraft == 1)) {\r
+ if (damage[DSHUTTL]==0 && (state.plnets[iplnet].known==2 || iscraft == 1)) {\r
skip(1);\r
prout("Spock- \"May I suggest the shuttle craft, Sir?\" ");\r
if (ja() != 0) shuttle();\r
prout("Impossible to transport through shields.");\r
return;\r
}\r
- if (d.plnets[iplnet].known==0) {\r
+ if (state.plnets[iplnet].known==0) {\r
prout("Spock- \"Captain, we have no information on this planet");\r
prout(" and Starfleet Regulations clearly state that in this situation");\r
prout(" you may not go down.\"");\r
}\r
if (landed==1) {\r
/* Coming from planet */\r
- if (d.plnets[iplnet].known==2) {\r
+ if (state.plnets[iplnet].known==2) {\r
proutn("Spock- \"Wouldn't you rather take the Galileo?\" ");\r
if (ja() != 0) {\r
chew();\r
}\r
else {\r
/* Going to planet */\r
- if (d.plnets[iplnet].crystals==0) {\r
+ if (state.plnets[iplnet].crystals==0) {\r
prout("Spock- \"Captain, I fail to see the logic in");\r
prout(" exploring a planet with no dilithium crystals.");\r
proutn(" Are you sure this is wise?\" ");\r
skip(2);\r
prout("Transport complete.");\r
landed = -landed;\r
- if (landed==1 && d.plnets[iplnet].known==2) {\r
+ if (landed==1 && state.plnets[iplnet].known==2) {\r
prout("The shuttle craft Galileo is here!");\r
}\r
if (landed!=1 && imine==1) {\r
prout("Mining party not on planet.");\r
return;\r
}\r
- if (d.plnets[iplnet].crystals == 0) {\r
+ if (state.plnets[iplnet].crystals == 0) {\r
prout("No dilithium crystals on this planet.");\r
return;\r
}\r
prout("there's no reason to mine more at this time.");\r
return;\r
}\r
- Time = (0.1+0.2*Rand())*d.plnets[iplnet].pclass;\r
+ Time = (0.1+0.2*Rand())*state.plnets[iplnet].pclass;\r
if (consumeTime()) return;\r
prout("Mining operation complete.");\r
imine = 1;\r
ididit = 0;\r
if(damage[DSHUTTL] != 0.0) {\r
if (damage[DSHUTTL] == -1.0) {\r
- if (inorbit && d.plnets[iplnet].known == 2)\r
+ if (inorbit && state.plnets[iplnet].known == 2)\r
prout("Ye Faerie Queene has no shuttle craft bay to dock it at.");\r
else\r
prout("Ye Faerie Queene had no shuttle craft.");\r
prout(" not in standard orbit.");\r
return;\r
}\r
- if ((d.plnets[iplnet].known != 2) && iscraft != 1) {\r
+ if ((state.plnets[iplnet].known != 2) && iscraft != 1) {\r
prout("Shuttle craft not currently available.");\r
return;\r
}\r
- if (landed==-1 && d.plnets[iplnet].known==2) {\r
+ if (landed==-1 && state.plnets[iplnet].known==2) {\r
prout("You will have to beam down to retrieve the shuttle craft.");\r
return;\r
}\r
prout("Shuttle craft cannot pass through shields.");\r
return;\r
}\r
- if (d.plnets[iplnet].known==0) {\r
+ if (state.plnets[iplnet].known==0) {\r
prout("Spock- \"Captain, we have no information on this planet");\r
prout(" and Starfleet Regulations clearly state that in this situation");\r
prout(" you may not fly down.\"");\r
return;\r
}\r
Time = 3.0e-5*height;\r
- if (Time >= 0.8*d.remtime) {\r
+ if (Time >= 0.8*state.remtime) {\r
prout("First Officer Spock- \"Captain, I compute that such");\r
prout(" a maneuver would require approximately ");\r
- cramf(100*Time/d.remtime,0,4);\r
+ cramf(100*Time/state.remtime,0,4);\r
prout("% of our");\r
prout("remaining time.");\r
prout("Are you sure this is wise?\" ");\r
iscraft = 0;\r
skip(1);\r
if (consumeTime()) return;\r
- d.plnets[iplnet].known=2;\r
+ state.plnets[iplnet].known=2;\r
prout("Trip complete.");\r
return;\r
}\r
prout("shuttle craft for the trip back to the Enterprise.");\r
skip(1);\r
prout("The short hop begins . . .");\r
- d.plnets[iplnet].known=1;\r
+ state.plnets[iplnet].known=1;\r
icraft = 1;\r
skip(1);\r
landed = -1;\r
icraft = 1;\r
iscraft = 0;\r
if (consumeTime()) return;\r
- d.plnets[iplnet].known = 2;\r
+ state.plnets[iplnet].known = 2;\r
landed = 1;\r
icraft = 0;\r
prout("Trip complete");\r
while (nenhere > 0)\r
deadkl(kx[1],ky[1],quad[kx[1]][ky[1]],kx[1],ky[1]);\r
prout("Ensign Chekov- \"Congratulations, Captain!\"");\r
- if (d.remkl == 0) finish(FWON);\r
+ if (state.remkl == 0) finish(FWON);\r
prout("Spock- \"Captain, I believe the `Experimental Death Ray'");\r
if (Rand() <= 0.05) {\r
prout(" is still operational.\"");\r
}\r
if (isatb == 1) {\r
proutn("Starbase in ");\r
- cramlc(1, d.isx, d.isy);\r
+ cramlc(1, state.isx, state.isy);\r
prout(" is under Super-commander attack.");\r
proutn("It can hold out until Stardate ");\r
cramf(future[FSCDBAS], 0, 1);\r
case 5: s3="emeritus"; break;\r
default: s3="skilled"; break;\r
}\r
- printf("\nYou %s playing a %s%s %s game.\n",\r
+ printf("\nYou %s playing a %s%s %s frozen.\n",\r
alldone? "were": "are now", s1, s2, s3);\r
if (skill>3 && thawed && !alldone) prout("No plaque is allowed.");\r
if (tourn) printf("This is tournament game %d.\n", tourn);\r
if (f) printf("Your secret password is \"%s\"\n",passwd);\r
printf("%d of %d Klingons have been killed",\r
- d.killk+d.killc+d.nsckill, inkling);\r
- if (d.killc) printf(", including %d Commander%s.\n", d.killc, d.killc==1?"":"s");\r
- else if (d.killk+d.nsckill > 0) prout(", but no Commanders.");\r
+ state.killk+state.killc+state.nsckill, inkling);\r
+ if (state.killc) printf(", including %d Commander%s.\n", state.killc, state.killc==1?"":"s");\r
+ else if (state.killk+state.nsckill > 0) prout(", but no Commanders.");\r
else prout(".");\r
if (skill > 2) printf("The Super Commander has %sbeen destroyed.\n",\r
- d.nscrem?"not ":"");\r
- if (d.rembase != inbase) {\r
+ state.nscrem?"not ":"");\r
+ if (state.rembase != inbase) {\r
proutn("There ");\r
- if (inbase-d.rembase==1) proutn("has been 1 base");\r
+ if (inbase-state.rembase==1) proutn("has been 1 base");\r
else {\r
proutn("have been ");\r
- crami(inbase-d.rembase, 1);\r
+ crami(inbase-state.rembase, 1);\r
proutn(" bases");\r
}\r
proutn(" destroyed, ");\r
- crami(d.rembase, 1);\r
+ crami(state.rembase, 1);\r
prout(" remaining.");\r
}\r
else printf("There are %d bases.\n", inbase);\r
if (x == 0 || x > 8 || y == 0 || y > 8)\r
printf(" -1");\r
else {\r
- printf("%5d", d.galaxy[x][y]);\r
- starch[x][y] = damage[DRADIO] > 0 ? d.galaxy[x][y]+1000 :1;\r
+ printf("%5d", state.galaxy[x][y]);\r
+ starch[x][y] = damage[DRADIO] > 0 ? state.galaxy[x][y]+1000 :1;\r
}\r
}\r
putchar('\n');\r
\r
chew();\r
skip(1);\r
- if (stdamtim != 1e30 && stdamtim != d.date && condit == IHDOCKED) {\r
+ if (stdamtim != 1e30 && stdamtim != state.date && condit == IHDOCKED) {\r
prout("Spock- \"I revised the Star Chart from the");\r
prout(" starbase's records.\"");\r
skip(1);\r
if (stdamtim != 1e30) {\r
if (condit == IHDOCKED) {\r
/* We are docked, so restore chart from base information */\r
- stdamtim = d.date;\r
+ stdamtim = state.date;\r
for (i=1; i <= 8 ; i++)\r
for (j=1; j <= 8; j++)\r
- if (starch[i][j] == 1) starch[i][j] = d.galaxy[i][j]+1000;\r
+ if (starch[i][j] == 1) starch[i][j] = state.galaxy[i][j]+1000;\r
}\r
else {\r
proutn("(Last surveillance update ");\r
- cramf(d.date-stdamtim, 0, 1);\r
+ cramf(state.date-stdamtim, 0, 1);\r
prout(" stardates ago.)");\r
}\r
}\r
else if (starch[i][j] > 999)\r
printf("%5d", starch[i][j]-1000);\r
else\r
- printf("%5d", d.galaxy[i][j]);\r
+ printf("%5d", state.galaxy[i][j]);\r
}\r
prout(" -");\r
}\r
}\r
if (goodScan)\r
starch[quadx][quady] = damage[DRADIO]>0.0 ?\r
- d.galaxy[quadx][quady]+1000:1;\r
+ state.galaxy[quadx][quady]+1000:1;\r
scan();\r
if (isit("chart")) nn = TRUE;\r
if (isit("no")) rightside = FALSE;\r
if (rightside) {\r
switch (jj) {\r
case 1:\r
- printf(" Stardate %.1f", d.date);\r
+ printf(" Stardate %.1f", state.date);\r
break;\r
case 2:\r
if (condit != IHDOCKED) newcnd();\r
(int)((100.0*shield)/inshld + 0.5), shield);\r
break;\r
case 9:\r
- printf(" Klingons Left %d", d.remkl);\r
+ printf(" Klingons Left %d", state.remkl);\r
break;\r
case 10:\r
- printf(" Time Left %.2f", d.remtime);\r
+ printf(" Time Left %.2f", state.remtime);\r
break;\r
}\r
\r
proutn("Time or arrival date? ");\r
if (scan()==IHREAL) {\r
ttime = aaitem;\r
- if (ttime > d.date) ttime -= d.date; // Actually a star date\r
+ if (ttime > state.date) ttime -= state.date; // Actually a star date\r
if (ttime <= 1e-10 ||\r
(twarp=(floor(sqrt((10.0*dist)/ttime)*10.0)+1.0)/10.0) > 10) {\r
prout("We'll never make it, sir.");\r
prout(".");\r
if (wfl) {\r
proutn("And we will arrive at stardate ");\r
- cramf(d.date+ttime, 1, 1);\r
+ cramf(state.date+ttime, 1, 1);\r
prout(".");\r
}\r
else if (twarp==1.0)\r
cramf(twarp, 1, 2);\r
skip(1);\r
proutn("and we will arrive at stardate ");\r
- cramf(d.date+ttime, 1, 2);\r
+ cramf(state.date+ttime, 1, 2);\r
prout(".");\r
}\r
- if (d.remtime < ttime)\r
+ if (state.remtime < ttime)\r
prout("Unfortunately, the Federation will be destroyed by then.");\r
if (twarp > 6.0)\r
prout("You'll be taking risks at that speed, Captain");\r
- if ((isatb==1 && d.isy == ix1 && d.isx == iy1 &&\r
- future[FSCDBAS]< ttime+d.date)||\r
- (future[FCDBAS]<ttime+d.date && baty==ix1 && batx == iy1))\r
+ if ((isatb==1 && state.isy == ix1 && state.isx == iy1 &&\r
+ future[FSCDBAS]< ttime+state.date)||\r
+ (future[FCDBAS]<ttime+state.date && baty==ix1 && batx == iy1))\r
prout("The starbase there will be destroyed by then.");\r
proutn("New warp factor to try? ");\r
if (scan() == IHREAL) {\r
skip(1);\r
return;\r
}\r
- fwrite(&d, sizeof(d), 1, fp);\r
+ fwrite(&state, sizeof(state), 1, fp);\r
fwrite(&snapsht, sizeof(snapsht), 1, fp);\r
fwrite(quad, sizeof(quad), 1, fp);\r
fwrite(kx, sizeof(kx), 1, fp);\r
fwrite(kavgd, sizeof(kavgd), 1, fp);\r
fwrite(damage, sizeof(damage), 1, fp);\r
fwrite(future, sizeof(future), 1, fp);\r
- fwrite(&game, sizeof(game), 1, fp);\r
+ fwrite(&frozen, sizeof(frozen), 1, fp);\r
fwrite(passwd, sizeof(passwd), 1, fp);\r
\r
fclose(fp);\r
skip(1);\r
return;\r
}\r
- fread(&d, sizeof(d), 1, fp);\r
+ fread(&state, sizeof(state), 1, fp);\r
fread(&snapsht, sizeof(snapsht), 1, fp);\r
fread(quad, sizeof(quad), 1, fp);\r
fread(kx, sizeof(kx), 1, fp);\r
fread(kavgd, sizeof(kavgd), 1, fp);\r
fread(damage, sizeof(damage), 1, fp);\r
fread(future, sizeof(future), 1, fp);\r
- fread(&game, sizeof(game), 1, fp);\r
+ fread(&frozen, sizeof(frozen), 1, fp);\r
fread(passwd, sizeof(passwd), 1, fp);\r
\r
fclose(fp);\r
prout("Captain and crew escape in shuttle craft.");\r
prout("Remainder of ship's complement beam down");\r
prout("to nearest habitable planet.");\r
- if (d.rembase==0) {\r
+ if (state.rembase==0) {\r
/* Ops! no place to go... */\r
finish(FABANDN);\r
return;\r
nprobes = 0; /* No probes */\r
prout("You are captured by Klingons and released to");\r
prout("the Federation in a prisoner-of-war exchange.");\r
- nb = Rand()*d.rembase+1;\r
+ nb = Rand()*state.rembase+1;\r
/* Set up quadrant and position FQ adjacient to base */\r
- if (quadx!=d.baseqx[nb] || quady!=d.baseqy[nb]) {\r
- quadx = d.baseqx[nb];\r
- quady = d.baseqy[nb];\r
+ if (quadx!=state.baseqx[nb] || quady!=state.baseqy[nb]) {\r
+ quadx = state.baseqx[nb];\r
+ quady = state.baseqy[nb];\r
sectx = secty = 5;\r
newqad(1);\r
}\r
for (i=0; i <= ndevice; i++) damage[i] = 0.0;\r
// Set up assorted game parameters\r
batx = baty = 0;\r
- d.date = indate = 100.0*(int)(31.0*Rand()+20.0);\r
- d.killk = d.killc = nkinks = nhelp = resting = casual = d.nromkl = 0;\r
- isatb = iscate = imine = icrystl = icraft = d.nsckill = d.nplankl = 0;\r
+ state.date = indate = 100.0*(int)(31.0*Rand()+20.0);\r
+ state.killk = state.killc = nkinks = nhelp = resting = casual = state.nromkl = 0;\r
+ isatb = iscate = imine = icrystl = icraft = state.nsckill = state.nplankl = 0;\r
iscraft = 1;\r
landed = -1;\r
alive = 1;\r
docfac = 0.25;\r
for (i = 1; i <= 8; i++)\r
- for (j = 1; j <= 8; j++) d.newstuf[i][j] = starch[i][j] = 0;\r
+ for (j = 1; j <= 8; j++) state.newstuf[i][j] = starch[i][j] = 0;\r
// Initialize times for extraneous events\r
- future[FSNOVA] = d.date + expran(0.5 * intime);\r
- future[FTBEAM] = d.date + expran(1.5 * (intime / d.remcom));\r
- future[FSNAP] = d.date + 1.0 + Rand(); // Force an early snapshot\r
- future[FBATTAK] = d.date + expran(0.3*intime);\r
+ future[FSNOVA] = state.date + expran(0.5 * intime);\r
+ future[FTBEAM] = state.date + expran(1.5 * (intime / state.remcom));\r
+ future[FSNAP] = state.date + 1.0 + Rand(); // Force an early snapshot\r
+ future[FBATTAK] = state.date + expran(0.3*intime);\r
future[FCDBAS] = 1e30;\r
- future[FSCMOVE] = d.nscrem ? d.date+0.2777 : 1e30;\r
+ future[FSCMOVE] = state.nscrem ? state.date+0.2777 : 1e30;\r
future[FSCDBAS] = 1e30;\r
future[FDSPROB] = 1e30;\r
// Starchart is functional\r
for (j=1; j<=8; j++) {\r
int k = Rand()*9.0 + 1.0;\r
instar += k;\r
- d.galaxy[i][j] = k;\r
+ state.galaxy[i][j] = k;\r
}\r
// Locate star bases in galaxy\r
for (i = 1; i <= inbase; i++) {\r
int contflag;\r
do {\r
do iran8(&ix, &iy);\r
- while (d.galaxy[ix][iy] >= 10);\r
+ while (state.galaxy[ix][iy] >= 10);\r
contflag = FALSE;\r
for (j = i-1; j > 0; j--) {\r
/* Improved placement algorithm to spread out bases */\r
- double distq = square(ix-d.baseqx[j]) + square(iy-d.baseqy[j]);\r
+ double distq = square(ix-state.baseqx[j]) + square(iy-state.baseqy[j]);\r
if (distq < 6.0*(6-inbase) && Rand() < 0.75) {\r
contflag = TRUE;\r
#ifdef DEBUG\r
}\r
} while (contflag);\r
\r
- d.baseqx[i] = ix;\r
- d.baseqy[i] = iy;\r
+ state.baseqx[i] = ix;\r
+ state.baseqy[i] = iy;\r
starch[ix][iy] = -1;\r
- d.galaxy[ix][iy] += 10;\r
+ state.galaxy[ix][iy] += 10;\r
}\r
// Position ordinary Klingon Battle Cruisers\r
- krem = inkling - incom - d.nscrem;\r
+ krem = inkling - incom - state.nscrem;\r
klumper = 0.25*skill*(9.0-length)+1.0;\r
if (klumper > 9) klumper = 9; // Can't have more than 9 in quadrant\r
do {\r
krem -= klump;\r
klump *= 100;\r
do iran8(&ix, &iy);\r
- while (d.galaxy[ix][iy] + klump >= 1000);\r
- d.galaxy[ix][iy] += klump;\r
+ while (state.galaxy[ix][iy] + klump >= 1000);\r
+ state.galaxy[ix][iy] += klump;\r
} while (krem > 0);\r
// Position Klingon Commander Ships\r
#ifdef DEBUG\r
do { /* IF debugging, put commanders by bases, always! */\r
#ifdef DEBUG\r
if (idebug && klumper <= inbase) {\r
- ix = d.baseqx[klumper];\r
- iy = d.baseqy[klumper];\r
+ ix = state.baseqx[klumper];\r
+ iy = state.baseqy[klumper];\r
klumper++;\r
}\r
else\r
#endif\r
iran8(&ix, &iy);\r
}\r
- while ((d.galaxy[ix][iy] < 99 && Rand() < 0.75)||\r
- d.galaxy[ix][iy]>899);\r
+ while ((state.galaxy[ix][iy] < 99 && Rand() < 0.75)||\r
+ state.galaxy[ix][iy]>899);\r
// check for duplicate\r
for (j = 1; j < i; j++)\r
- if (d.cx[j]==ix && d.cy[j]==iy) break;\r
+ if (state.cx[j]==ix && state.cy[j]==iy) break;\r
} while (j < i);\r
- d.galaxy[ix][iy] += 100;\r
- d.cx[i] = ix;\r
- d.cy[i] = iy;\r
+ state.galaxy[ix][iy] += 100;\r
+ state.cx[i] = ix;\r
+ state.cy[i] = iy;\r
}\r
// Locate planets in galaxy\r
for (i = 1; i <= inplan; i++) {\r
do iran8(&ix, &iy);\r
- while (d.newstuf[ix][iy] > 0);\r
- d.newstuf[ix][iy] = 1;\r
- d.plnets[i].x = ix;\r
- d.plnets[i].y = iy;\r
- d.plnets[i].pclass = Rand()*3.0 + 1.0; // Planet class M N or O\r
- d.plnets[i].crystals = 1.5*Rand(); // 1 in 3 chance of crystals\r
- d.plnets[i].known = 0;\r
+ while (state.newstuf[ix][iy] > 0);\r
+ state.newstuf[ix][iy] = 1;\r
+ state.plnets[i].x = ix;\r
+ state.plnets[i].y = iy;\r
+ state.plnets[i].pclass = Rand()*3.0 + 1.0; // Planet class M N or O\r
+ state.plnets[i].crystals = 1.5*Rand(); // 1 in 3 chance of crystals\r
+ state.plnets[i].known = 0;\r
}\r
// Locate Romulans\r
- for (i = 1; i <= d.nromrem; i++) {\r
+ for (i = 1; i <= state.nromrem; i++) {\r
iran8(&ix, &iy);\r
- d.newstuf[ix][iy] += 10;\r
+ state.newstuf[ix][iy] += 10;\r
}\r
// Locate the Super Commander\r
- if (d.nscrem > 0) {\r
+ if (state.nscrem > 0) {\r
do iran8(&ix, &iy);\r
- while (d.galaxy[ix][iy] >= 900);\r
- d.isx = ix;\r
- d.isy = iy;\r
- d.galaxy[ix][iy] += 100;\r
+ while (state.galaxy[ix][iy] >= 900);\r
+ state.isx = ix;\r
+ state.isy = iy;\r
+ state.galaxy[ix][iy] += 100;\r
}\r
// Place thing (in tournament game, thingx == -1, don't want one!)\r
if (Rand() < 0.1 && thingx != -1) {\r
\r
// idate = date;\r
skip(3);\r
- d.snap = 0;\r
+ state.snap = 0;\r
\r
if (skill == 1) {\r
printf("It is stardate %d. The Federation is being attacked by\n",\r
- (int)d.date);\r
+ (int)state.date);\r
printf("a deadly Klingon invasion force. As captain of the United\n"\r
"Starship U.S.S. Enterprise, it is your mission to seek out\n"\r
"and destroy this invasion force of %d battle cruisers.\n",\r
else {\r
printf("Stardate %d.\n\n"\r
"%d Klingons.\nAn unknown number of Romulans\n",\r
- (int)d.date, inkling);\r
- if (d.nscrem) printf("and one (GULP) Super-Commander.\n");\r
+ (int)state.date, inkling);\r
+ if (state.nscrem) printf("and one (GULP) Super-Commander.\n");\r
printf("%d stardates\n%d starbases in ",(int)intime, inbase);\r
}\r
for (i = 1; i <= inbase; i++) {\r
- cramlc(0, d.baseqx[i], d.baseqy[i]);\r
+ cramlc(0, state.baseqx[i], state.baseqy[i]);\r
if (i < inbase) proutn(" ");\r
}\r
skip(2);\r
cramlc(2, sectx, secty);\r
skip(2);\r
prout("Good Luck!");\r
- if (d.nscrem) proutn(" YOU'LL NEED IT.");\r
+ if (state.nscrem) proutn(" YOU'LL NEED IT.");\r
skip(1);\r
newqad(0);\r
if (nenhere) shldup=1.0;\r
\r
// Use parameters to generate initial values of things\r
damfac = 0.5 * skill;\r
- d.rembase = 3.0*Rand()+2.0;\r
- inbase = d.rembase;\r
+ state.rembase = 3.0*Rand()+2.0;\r
+ inbase = state.rembase;\r
inplan = (PLNETMAX/2) + (PLNETMAX/2+1)*Rand();\r
- d.nromrem = (2.0+Rand())*skill;\r
- d.nscrem = (skill > 2? 1 : 0);\r
- d.remtime = 7.0 * length;\r
- intime = d.remtime;\r
- d.remkl = 2.0*intime*((skill+1 - 2*Rand())*skill*0.1+.15);\r
- inkling = d.remkl;\r
+ state.nromrem = (2.0+Rand())*skill;\r
+ state.nscrem = (skill > 2? 1 : 0);\r
+ state.remtime = 7.0 * length;\r
+ intime = state.remtime;\r
+ state.remkl = 2.0*intime*((skill+1 - 2*Rand())*skill*0.1+.15);\r
+ inkling = state.remkl;\r
incom = skill + 0.0625*inkling*Rand();\r
- d.remcom= min(10, incom);\r
- incom = d.remcom;\r
- d.remres = (inkling+4*incom)*intime;\r
- inresor = d.remres;\r
+ state.remcom= min(10, incom);\r
+ incom = state.remcom;\r
+ state.remres = (inkling+4*incom)*intime;\r
+ inresor = state.remres;\r
if (inkling > 50) {\r
- inbase = (d.rembase += 1);\r
+ inbase = (state.rembase += 1);\r
}\r
return FALSE;\r
}\r
void newcnd(void) {\r
condit = IHGREEN;\r
if (energy < 1000.0) condit = IHYELLOW;\r
- if (d.galaxy[quadx][quady] > 99 || d.newstuf[quadx][quady] > 9)\r
+ if (state.galaxy[quadx][quady] > 99 || state.newstuf[quadx][quady] > 9)\r
condit = IHRED;\r
}\r
\r
\r
void newqad(int shutup) {\r
- int quadnum = d.galaxy[quadx][quady];\r
- int newnum = d.newstuf[quadx][quady];\r
+ int quadnum = state.galaxy[quadx][quady];\r
+ int newnum = state.newstuf[quadx][quady];\r
int i, j, ix, iy, nplan;\r
\r
iattak = 1;\r
kpower[i] = Rand()*150.0 +300.0 +25.0*skill;\r
}\r
// If we need a commander, promote a Klingon\r
- for (i = 1; i <= d.remcom ; i++) \r
- if (d.cx[i]==quadx && d.cy[i]==quady) break;\r
+ for (i = 1; i <= state.remcom ; i++) \r
+ if (state.cx[i]==quadx && state.cy[i]==quady) break;\r
\r
- if (i <= d.remcom) {\r
+ if (i <= state.remcom) {\r
quad[ix][iy] = IHC;\r
kpower[klhere] = 950.0+400.0*Rand()+50.0*skill;\r
comhere = 1;\r
}\r
\r
// If we need a super-commander, promote a Klingon\r
- if (quadx == d.isx && quady == d.isy) {\r
+ if (quadx == state.isx && quady == state.isy) {\r
quad[kx[1]][ky[1]] = IHS;\r
kpower[1] = 1175.0 + 400.0*Rand() + 125.0*skill;\r
iscate = 1;\r
if (nplan) {\r
// If quadrant needs a planet, put it in\r
for (i=1; i <= inplan; i++)\r
- if (d.plnets[i].x == quadx && d.plnets[i].y == quady) break;\r
+ if (state.plnets[i].x == quadx && state.plnets[i].y == quady) break;\r
if (i <= inplan) {\r
iplnet = i;\r
dropin(IHP, &plnetx, &plnety);\r
events();\r
if (alldone) break; // Events did us in\r
}\r
- if (d.galaxy[quadx][quady] == 1000) { // Galaxy went Nova!\r
+ if (state.galaxy[quadx][quady] == 1000) { // Galaxy went Nova!\r
atover(0);\r
continue;\r
}\r
if (hitme && justin==0) {\r
attack(2);\r
if (alldone) break;\r
- if (d.galaxy[quadx][quady] == 1000) { // went NOVA! \r
+ if (state.galaxy[quadx][quady] == 1000) { // went NOVA! \r
atover(0);\r
hitme = TRUE;\r
continue;\r
key = scan();\r
if (key == IHALPHA && isit("y")) {\r
damage[i] = 10.0;\r
- if (i == DRADIO) stdamtim = d.date;\r
+ if (i == DRADIO) stdamtim = state.date;\r
}\r
}\r
}\r
case FSCMOVE: proutn("SC Move "); break;\r
case FSCDBAS: proutn("SC Base Destroy "); break;\r
}\r
- cramf(future[i]-d.date, 8, 2);\r
+ cramf(future[i]-state.date, 8, 2);\r
chew();\r
proutn(" ?");\r
key = scan();\r
if (key == IHREAL) {\r
- future[i] = d.date + aaitem;\r
+ future[i] = state.date + aaitem;\r
}\r
}\r
chew();\r
double date, // stardate\r
remres, // remaining resources\r
remtime; // remaining time\r
-} d, snapsht; // Data that is snapshot\r
+} state, snapsht; // Data that is snapshot\r
\r
EXTERN char\r
quad[11][11]; // contents of our quadrant\r
probey,\r
probeinx,\r
probeiny;\r
-} game;\r
+} frozen;\r
\r
-#define inkling game.inkling // Initial number of klingons\r
-#define inbase game.inbase // Initial number of bases\r
-#define incom game.incom // Initian number of commanders\r
-#define instar game.instar // Initial stars\r
-#define intorps game.intorps // Initial/Max torpedoes\r
-#define condit game.condit // Condition (red, yellow, green docked)\r
-#define torps game.torps // number of torpedoes\r
-#define ship game.ship // Ship type -- 'E' is Enterprise\r
-#define quadx game.quadx // where we are\r
-#define quady game.quady //\r
-#define sectx game.sectx // where we are\r
-#define secty game.secty //\r
-#define length game.length // length of game\r
-#define skill game.skill // skill level\r
-#define basex game.basex // position of base in current quad\r
-#define basey game.basey //\r
-#define klhere game.klhere // klingons here\r
-#define comhere game.comhere // commanders here\r
-#define casual game.casual // causalties\r
-#define nhelp game.nhelp // calls for help\r
-#define nkinks game.nkinks //\r
-#define ididit game.ididit // Action taken -- allows enemy to attack\r
-#define gamewon game.gamewon // Finished!\r
-#define alive game.alive // We are alive (not killed)\r
-#define justin game.justin // just entered quadrant\r
-#define alldone game.alldone // game is now finished\r
-#define shldchg game.shldchg // shield is changing (affects efficiency)\r
-#define thingx game.thingx // location of strange object in galaxy\r
-#define thingy game.thingy //\r
-#define plnetx game.plnetx // location of planet in quadrant\r
-#define plnety game.plnety //\r
-#define inorbit game.inorbit // orbiting\r
-#define landed game.landed // party on planet (1), on ship (-1)\r
-#define iplnet game.iplnet // planet # in quadrant\r
-#define imine game.imine // mining\r
-#define inplan game.inplan // initial planets\r
-#define nenhere game.nenhere // Number of enemies in quadrant\r
-#define ishere game.ishere // Super-commander in quandrant\r
-#define neutz game.neutz // Romulan Neutral Zone\r
-#define irhere game.irhere // Romulans in quadrant\r
-#define icraft game.icraft // Kirk in Galileo\r
-#define ientesc game.ientesc // Attempted escape from supercommander\r
-#define iscraft game.iscraft // =1 if craft on ship, -1 if removed from game\r
-#define isatb game.isatb // =1 if SuperCommander is attacking base\r
-#define iscate game.iscate // Super Commander is here\r
+#define inkling frozen.inkling // Initial number of klingons\r
+#define inbase frozen.inbase // Initial number of bases\r
+#define incom frozen.incom // Initian number of commanders\r
+#define instar frozen.instar // Initial stars\r
+#define intorps frozen.intorps // Initial/Max torpedoes\r
+#define condit frozen.condit // Condition (red, yellow, green docked)\r
+#define torps frozen.torps // number of torpedoes\r
+#define ship frozen.ship // Ship type -- 'E' is Enterprise\r
+#define quadx frozen.quadx // where we are\r
+#define quady frozen.quady //\r
+#define sectx frozen.sectx // where we are\r
+#define secty frozen.secty //\r
+#define length frozen.length // length of game\r
+#define skill frozen.skill // skill level\r
+#define basex frozen.basex // position of base in current quad\r
+#define basey frozen.basey //\r
+#define klhere frozen.klhere // klingons here\r
+#define comhere frozen.comhere // commanders here\r
+#define casual frozen.casual // causalties\r
+#define nhelp frozen.nhelp // calls for help\r
+#define nkinks frozen.nkinks //\r
+#define ididit frozen.ididit // Action taken -- allows enemy to attack\r
+#define gamewon frozen.gamewon // Finished!\r
+#define alive frozen.alive // We are alive (not killed)\r
+#define justin frozen.justin // just entered quadrant\r
+#define alldone frozen.alldone // game is now finished\r
+#define shldchg frozen.shldchg // shield is changing (affects efficiency)\r
+#define thingx frozen.thingx // location of strange object in galaxy\r
+#define thingy frozen.thingy //\r
+#define plnetx frozen.plnetx // location of planet in quadrant\r
+#define plnety frozen.plnety //\r
+#define inorbit frozen.inorbit // orbiting\r
+#define landed frozen.landed // party on planet (1), on ship (-1)\r
+#define iplnet frozen.iplnet // planet # in quadrant\r
+#define imine frozen.imine // mining\r
+#define inplan frozen.inplan // initial planets\r
+#define nenhere frozen.nenhere // Number of enemies in quadrant\r
+#define ishere frozen.ishere // Super-commander in quandrant\r
+#define neutz frozen.neutz // Romulan Neutral Zone\r
+#define irhere frozen.irhere // Romulans in quadrant\r
+#define icraft frozen.icraft // Kirk in Galileo\r
+#define ientesc frozen.ientesc // Attempted escape from supercommander\r
+#define iscraft frozen.iscraft // =1 if craft on ship, -1 if removed from game\r
+#define isatb frozen.isatb // =1 if SuperCommander is attacking base\r
+#define iscate frozen.iscate // Super Commander is here\r
#ifdef DEBUG\r
-#define idebug game.idebug // Debug mode\r
+#define idebug frozen.idebug // Debug mode\r
#endif\r
-#define iattak game.iattak // attack recursion elimination (was cracks[4])\r
-#define icrystl game.icrystl // dilithium crystals aboard\r
-#define tourn game.tourn // Tournament number\r
-#define thawed game.thawed // Thawed game\r
-#define batx game.batx // Base coordinates being attacked\r
-#define baty game.baty //\r
-#define ithere game.ithere // Tholean is here \r
-#define ithx game.ithx // coordinates of tholean\r
-#define ithy game.ithy\r
-#define iseenit game.iseenit // Seen base attack report\r
-#define inresor game.inresor // initial resources\r
-#define intime game.intime // initial time\r
-#define inenrg game.inenrg // Initial/Max Energy\r
-#define inshld game.inshld // Initial/Max Shield\r
-#define inlsr game.inlsr // initial life support resources\r
-#define indate game.indate // Initial date\r
-#define energy game.energy // Energy level\r
-#define shield game.shield // Shield level\r
-#define shldup game.shldup // Shields are up\r
-#define warpfac game.warpfac // Warp speed\r
-#define wfacsq game.wfacsq // squared warp factor\r
-#define lsupres game.lsupres // life support reserves\r
-#define dist game.dist // movement distance\r
-#define direc game.direc // movement direction\r
-#define Time game.Time // time taken by current operation\r
-#define docfac game.docfac // repair factor when docking (constant?)\r
-#define resting game.resting // rest time\r
-#define damfac game.damfac // damage factor\r
-#define stdamtim game.stdamtim // time that star chart was damaged\r
-#define cryprob game.cryprob // probability that crystal will work\r
-#define probex game.probex // location of probe\r
-#define probey game.probey\r
-#define probecx game.probecx // current probe quadrant\r
-#define probecy game.probecy \r
-#define probeinx game.probeinx // Probe x,y increment\r
-#define probeiny game.probeiny \r
-#define proben game.proben // number of moves for probe\r
-#define isarmed game.isarmed // Probe is armed\r
-#define nprobes game.nprobes // number of probes available\r
+#define iattak frozen.iattak // attack recursion elimination (was cracks[4])\r
+#define icrystl frozen.icrystl // dilithium crystals aboard\r
+#define tourn frozen.tourn // Tournament number\r
+#define thawed frozen.thawed // Thawed game\r
+#define batx frozen.batx // Base coordinates being attacked\r
+#define baty frozen.baty //\r
+#define ithere frozen.ithere // Tholean is here \r
+#define ithx frozen.ithx // coordinates of tholean\r
+#define ithy frozen.ithy\r
+#define iseenit frozen.iseenit // Seen base attack report\r
+#define inresor frozen.inresor // initial resources\r
+#define intime frozen.intime // initial time\r
+#define inenrg frozen.inenrg // Initial/Max Energy\r
+#define inshld frozen.inshld // Initial/Max Shield\r
+#define inlsr frozen.inlsr // initial life support resources\r
+#define indate frozen.indate // Initial date\r
+#define energy frozen.energy // Energy level\r
+#define shield frozen.shield // Shield level\r
+#define shldup frozen.shldup // Shields are up\r
+#define warpfac frozen.warpfac // Warp speed\r
+#define wfacsq frozen.wfacsq // squared warp factor\r
+#define lsupres frozen.lsupres // life support reserves\r
+#define dist frozen.dist // movement distance\r
+#define direc frozen.direc // movement direction\r
+#define Time frozen.Time // time taken by current operation\r
+#define docfac frozen.docfac // repair factor when docking (constant?)\r
+#define resting frozen.resting // rest time\r
+#define damfac frozen.damfac // damage factor\r
+#define stdamtim frozen.stdamtim // time that star chart was damaged\r
+#define cryprob frozen.cryprob // probability that crystal will work\r
+#define probex frozen.probex // location of probe\r
+#define probey frozen.probey\r
+#define probecx frozen.probecx // current probe quadrant\r
+#define probecy frozen.probecy \r
+#define probeinx frozen.probeinx // Probe x,y increment\r
+#define probeiny frozen.probeiny \r
+#define proben frozen.proben // number of moves for probe\r
+#define isarmed frozen.isarmed // Probe is armed\r
+#define nprobes frozen.nprobes // number of probes available\r
\r
EXTERN int\r
kx[21], // enemy sector locations\r