deltax /= bigger;\r
\r
/* If tractor beam is to occur, don't move full distance */\r
- if (d.date+Time >= future[FTBEAM]) {\r
+ if (game.state.date+Time >= game.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*(game.future[FTBEAM]-game.state.date)/Time + 0.1;\r
+ Time = game.future[FTBEAM] - game.state.date + 1e-5;\r
}\r
/* Move within the quadrant */\r
- quad[sectx][secty] = IHDOT;\r
+ game.quad[sectx][secty] = IHDOT;\r
x = sectx;\r
y = secty;\r
n = 10.0*dist*bigger+0.5;\r
if (nenhere != 0 && iattak != 2) {\r
newcnd();\r
for (l = 1; l <= nenhere; l++) {\r
- finald = sqrt((ix-kx[l])*(double)(ix-kx[l]) +\r
- (iy-ky[l])*(double)(iy-ky[l]));\r
- kavgd[l] = 0.5 * (finald+kdist[l]);\r
+ finald = sqrt((ix-game.kx[l])*(double)(ix-game.kx[l]) +\r
+ (iy-game.ky[l])*(double)(iy-game.ky[l]));\r
+ game.kavgd[l] = 0.5 * (finald+game.kdist[l]);\r
}\r
- if (d.galaxy[quadx][quady] != 1000) attack(0);\r
+ if (game.state.galaxy[quadx][quady] != 1000) attack(0);\r
if (alldone) return;\r
}\r
/* compute final position -- new quadrant and sector */\r
proutn("\nEntering");\r
cramlc(1, quadx, quady);\r
skip(1);\r
- quad[sectx][secty] = ship;\r
+ game.quad[sectx][secty] = ship;\r
newqad(0);\r
return;\r
}\r
- iquad = quad[ix][iy];\r
+ iquad = game.quad[ix][iy];\r
if (iquad != IHDOT) {\r
/* object encountered in flight path */\r
stopegy = 50.0*dist/Time;\r
finaly = secty;\r
label100:\r
/* No quadrant change -- compute new avg enemy distances */\r
- quad[sectx][secty] = ship;\r
+ game.quad[sectx][secty] = ship;\r
if (nenhere) {\r
for (l = 1; l <= nenhere; l++) {\r
- finald = sqrt((ix-kx[l])*(double)(ix-kx[l]) +\r
- (iy-ky[l])*(double)(iy-ky[l]));\r
- kavgd[l] = 0.5 * (finald+kdist[l]);\r
- kdist[l] = finald;\r
+ finald = sqrt((ix-game.kx[l])*(double)(ix-game.kx[l]) +\r
+ (iy-game.ky[l])*(double)(iy-game.ky[l]));\r
+ game.kavgd[l] = 0.5 * (finald+game.kdist[l]);\r
+ game.kdist[l] = finald;\r
}\r
sortkl();\r
- if (d.galaxy[quadx][quady] != 1000 && iattak == 0)\r
+ if (game.state.galaxy[quadx][quady] != 1000 && iattak == 0)\r
attack(0);\r
- for (l = 1 ; l <= nenhere; l++) kavgd[l] = kdist[l];\r
+ for (l = 1 ; l <= nenhere; l++) game.kavgd[l] = game.kdist[l];\r
}\r
newcnd();\r
iattak = 0;\r
torps = intorps;\r
lsupres = inlsr;\r
if (stdamtim != 1e30 &&\r
- (future[FCDBAS] < 1e30 || isatb == 1) && iseenit == 0) {\r
+ (game.future[FCDBAS] < 1e30 || isatb == 1) && iseenit == 0) {\r
/* get attack report from base */\r
prout("Lt. Uhura- \"Captain, an important message from the starbase:\"");\r
attakreport();\r
return;\r
}\r
while (automatic == -1) {\r
- if (damage[DCOMPTR]) {\r
+ if (game.damage[DCOMPTR]) {\r
if (isprobe)\r
prout("Computer damaged; manual navigation only");\r
else\r
double power;\r
\r
ididit = 0;\r
- if (damage[DIMPULS]) {\r
+ if (game.damage[DIMPULS]) {\r
chew();\r
skip(1);\r
prout("Engineer Scott- \"The impulse engines are damaged, Sir.\"");\r
}\r
/* Make sure enough time is left for the trip */\r
Time = dist/0.095;\r
- if (Time >= d.remtime) {\r
+ if (Time >= game.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
if (i!=2) { /* Not WARPX entry */\r
ididit = 0;\r
- if (damage[DWARPEN] > 10.0) {\r
+ if (game.damage[DWARPEN] > 10.0) {\r
chew();\r
skip(1);\r
prout("Engineer Scott- \"The impulse engines are damaged, Sir.\"");\r
return;\r
}\r
- if (damage[DWARPEN] > 0.0 && warpfac > 4.0) {\r
+ if (game.damage[DWARPEN] > 0.0 && warpfac > 4.0) {\r
chew();\r
skip(1);\r
prout("Engineer Scott- \"Sorry, Captain. Until this damage");\r
prout("We can't do it, Captain. We haven't the energy.");\r
}\r
else {\r
- proutn("We haven't the energy, but we could do it at warp ");\r
- crami(iwarp, 1);\r
- if (shldup)\r
- prout(",\nif you'll lower the shields.");\r
+ proutn("We haven't the energy, but we could do it at warp %d", iwarp);\r
+ if (shldup) {\r
+ prout(",");\r
+ prout("if you'll lower the shields.");\r
+ }\r
else\r
prout(".");\r
}\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*game.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/game.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
y += deltay;\r
iy = y +0.5;\r
if (iy < 1 || iy > 10) break;\r
- if (quad[ix][iy] != IHDOT) {\r
+ if (game.quad[ix][iy] != IHDOT) {\r
blooey = 0;\r
twarp = 0;\r
}\r
Time = 10.0*dist/wfacsq;\r
if (twarp) timwrp();\r
if (blooey) {\r
- damage[DWARPEN] = damfac*(3.0*Rand()+1.0);\r
+ game.damage[DWARPEN] = damfac*(3.0*Rand()+1.0);\r
skip(1);\r
prout("Engineering to bridge--");\r
prout(" Scott here. The warp engines are damaged.");\r
huh();\r
return;\r
}\r
- if (damage[DWARPEN] > 10.0) {\r
+ if (game.damage[DWARPEN] > 10.0) {\r
prout("Warp engines inoperative.");\r
return;\r
}\r
- if (damage[DWARPEN] > 0.0 && aaitem > 4.0) {\r
+ if (game.damage[DWARPEN] > 0.0 && aaitem > 4.0) {\r
prout("Engineer Scott- \"I'm doing my best, Captain,\n"\r
" but right now we can only go warp 4.\"");\r
return;\r
chew();\r
/* is captain on planet? */\r
if (landed==1) {\r
- if (damage[DTRANSP]) {\r
+ if (game.damage[DTRANSP]) {\r
finish(FPNOVA);\r
return;\r
}\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
+ game.starch[quadx][quady] = game.damage[DRADIO] > 0.0 ? game.state.galaxy[quadx][quady]+1000:1;\r
\r
/* Try to use warp engines */\r
- if (damage[DWARPEN]) {\r
+ if (game.damage[DWARPEN]) {\r
skip(1);\r
prout("Warp engines damaged.");\r
finish(FSNOVAED);\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 (game.state.galaxy[quadx][quady] == 1000);\r
+ if (game.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 (game.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(game.state.date-game.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
+ game.state = game.snapsht;\r
+ game.state.snap = 0;\r
+ if (game.state.remcom) {\r
+ game.future[FTBEAM] = game.state.date + expran(intime/game.state.remcom);\r
+ game.future[FBATTAK] = game.state.date + expran(0.3*intime);\r
+ }\r
+ game.future[FSNOVA] = game.state.date + expran(0.5*intime);\r
+ game.future[FSNAP] = game.state.date +expran(0.25*game.state.remtime); /* next snapshot will\r
be sooner */\r
- if (d.nscrem) future[FSCMOVE] = 0.2777;\r
+ if (game.state.nscrem) game.future[FSCMOVE] = 0.2777;\r
isatb = 0;\r
- future[FCDBAS] = future[FSCDBAS] = 1e30;\r
+ game.future[FCDBAS] = game.future[FSCDBAS] = 1e30;\r
batx = baty = 0;\r
\r
/* Make sure Galileo is consistant -- Snapshot may have been taken\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
+ for (l = 0; l < inplan; l++) {\r
+ if (game.state.plnets[l].known == shuttle_down) {\r
gotit = 1;\r
if (iscraft==1 && ship==IHE) {\r
prout("Checkov- \"Security reports the Galileo has disappeared, Sir!");\r
}\r
/* Likewise, if in the original time the Galileo was abandoned, but\r
was on ship earlier, it would have vanished -- lets restore it */\r
- if (iscraft==0 && gotit==0 && damage[DSHUTTL] >= 0.0) {\r
+ if (iscraft==0 && gotit==0 && game.damage[DSHUTTL] >= 0.0) {\r
prout("Checkov- \"Security reports the Galileo has reappeared in the dock!\"");\r
iscraft = 1;\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 (game.damage[DRADIO]==0.0 || stdamtim > game.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
+ if (game.starch[l][ll] > 1)\r
+ game.starch[l][ll]=game.damage[DRADIO]>0.0 ? game.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 (game.damage[DRADIO] > 0.0) stdamtim = game.state.date;\r
}\r
}\r
else {\r
cramf(Time, 1, 2);\r
prout(" stardates.");\r
/* cheat to make sure no tractor beams occur during time warp */\r
- future[FTBEAM] += Time;\r
- damage[DRADIO] += Time;\r
+ game.future[FTBEAM] += Time;\r
+ game.damage[DRADIO] += Time;\r
}\r
newqad(0);\r
}\r
prout("Ye Faerie Queene has no deep space probes.");\r
return;\r
}\r
- if (damage[DDSP] != 0.0) {\r
+ if (game.damage[DDSP] != 0.0) {\r
chew();\r
skip(1);\r
prout("Engineer Scott- \"The probe launcher is damaged, Sir.\"");\r
return;\r
}\r
- if (future[FDSPROB] != 1e30) {\r
+ if (game.future[FDSPROB] != 1e30) {\r
chew();\r
skip(1);\r
- if (damage[DRADIO] != 0 && condit != IHDOCKED) {\r
+ if (game.damage[DRADIO] != 0 && condit != IHDOCKED) {\r
prout("Spock- \"Records show the previous probe has not yet");\r
prout(" reached its destination.\"");\r
}\r
\r
if (key == IHEOL) {\r
/* slow mode, so let Kirk know how many probes there are left */\r
- crami(nprobes,1);\r
- prout(nprobes==1 ? " probe left." : " probes left.");\r
+ prout(nprobes==1 ? "%d probe left." : "%d probes left.", nprobes);\r
proutn("Are you sure you want to fire a probe? ");\r
if (ja()==0) return;\r
}\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
+ game.future[FDSPROB] = game.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("Lt. Uhura- \"But Captain, we're already docked.\"");\r
return;\r
}\r
- if (damage[DRADIO] != 0) {\r
+ if (game.damage[DRADIO] != 0) {\r
prout("Subspace radio damaged.");\r
return;\r
}\r
- if (d.rembase==0) {\r
+ if (game.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 <= game.state.rembase; l++) {\r
+ xdist=10.0*sqrt(square(game.state.baseqx[l]-quadx)+square(game.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 = game.state.baseqx[line];\r
+ quady = game.state.baseqy[line];\r
newqad(1);\r
}\r
/* dematerialize starship */\r
- quad[sectx][secty]=IHDOT;\r
+ game.quad[sectx][secty]=IHDOT;\r
proutn("Starbase in");\r
cramlc(1, quadx, quady);\r
proutn(" responds--");\r
for (l = 1; l <= 5; l++) {\r
ix = basex+3.0*Rand()-1;\r
iy = basey+3.0*Rand()-1;\r
- if (ix>=1 && ix<=10 && iy>=1 && iy<=10 && quad[ix][iy]==IHDOT) {\r
+ if (ix>=1 && ix<=10 && iy>=1 && iy<=10 && game.quad[ix][iy]==IHDOT) {\r
/* found one -- finish up */\r
prout("succeeds.");\r
sectx=ix;\r
secty=iy;\r
- quad[ix][iy]=ship;\r
+ game.quad[ix][iy]=ship;\r
dock();\r
skip(1);\r
prout("Lt. Uhura- \"Captain, we made it!\"");\r