if (my != 0) my = my*motion < 0 ? -1 : 1;\r
nextx = comx;\r
nexty = comy;\r
- quad[comx][comy] = IHDOT;\r
+ frozen.quad[comx][comy] = IHDOT;\r
/* main move loop */\r
for (ll = 1; ll <= nsteps; ll++) {\r
#ifdef DEBUG\r
looky = nexty + krawly;\r
krawly = -krawly;\r
}\r
- else if (quad[lookx][looky] != IHDOT) {\r
+ else if (frozen.quad[lookx][looky] != IHDOT) {\r
/* See if we should ram ship */\r
- if (quad[lookx][looky] == ship &&\r
+ if (frozen.quad[lookx][looky] == ship &&\r
(ienm == IHC || ienm == IHS)) {\r
ram(1, ienm, comx, comy);\r
return;\r
else break; /* done early */\r
}\r
/* Put commander in place within same quadrant */\r
- quad[nextx][nexty] = ienm;\r
+ frozen.quad[nextx][nexty] = ienm;\r
if (nextx != comx || nexty != comy) {\r
/* it moved */\r
kx[loccom] = nextx;\r
if (comhere) for (i = 1; i <= nenhere; i++) {\r
ix = kx[i];\r
iy = ky[i];\r
- if (quad[ix][iy] == IHC) {\r
+ if (frozen.quad[ix][iy] == IHC) {\r
movebaddy(ix, iy, i, IHC);\r
break;\r
}\r
if (ishere) for (i = 1; i <= nenhere; i++) {\r
ix = kx[i];\r
iy = ky[i];\r
- if (quad[ix][iy] == IHS) {\r
+ if (frozen.quad[ix][iy] == IHS) {\r
movebaddy(ix, iy, i, IHS);\r
break;\r
}\r
if (skill > 3) for (i = 1; i <= nenhere; i++) {\r
ix = kx[i];\r
iy = ky[i];\r
- if (quad[ix][iy] == IHK || quad[ix][iy] == IHR)\r
- movebaddy(ix, iy, i, quad[ix][iy]);\r
+ if (frozen.quad[ix][iy] == IHK || frozen.quad[ix][iy] == IHR)\r
+ movebaddy(ix, iy, i, frozen.quad[ix][iy]);\r
}\r
\r
sortkl();\r
ientesc=0;\r
future[FSCDBAS]=1e30;\r
for (i = 1; i <= nenhere; i++) \r
- if (quad[kx[i]][ky[i]] == IHS) break;\r
- quad[kx[i]][ky[i]] = IHDOT;\r
+ if (frozen.quad[kx[i]][ky[i]] == IHS) break;\r
+ frozen.quad[kx[i]][ky[i]] = IHDOT;\r
kx[i] = kx[nenhere];\r
ky[i] = ky[nenhere];\r
kdist[i] = kdist[nenhere];\r
}\r
\r
/* Do nothing if we are blocked */\r
- if (quad[idx][idy]!= IHDOT && quad[idx][idy]!= IHWEB) return;\r
- quad[ithx][ithy] = IHWEB;\r
+ if (frozen.quad[idx][idy]!= IHDOT && frozen.quad[idx][idy]!= IHWEB) return;\r
+ frozen.quad[ithx][ithy] = IHWEB;\r
\r
if (ithx != idx) {\r
/* move in x axis */\r
im = fabs((double)idx - ithx)/((double)idx - ithx);\r
while (ithx != idx) {\r
ithx += im;\r
- if (quad[ithx][ithy]==IHDOT) quad[ithx][ithy] = IHWEB;\r
+ if (frozen.quad[ithx][ithy]==IHDOT) frozen.quad[ithx][ithy] = IHWEB;\r
}\r
}\r
else if (ithy != idy) {\r
im = fabs((double)idy - ithy)/((double)idy - ithy);\r
while (ithy != idy) {\r
ithy += im;\r
- if (quad[ithx][ithy]==IHDOT) quad[ithx][ithy] = IHWEB;\r
+ if (frozen.quad[ithx][ithy]==IHDOT) frozen.quad[ithx][ithy] = IHWEB;\r
}\r
}\r
- quad[ithx][ithy] = IHT;\r
+ frozen.quad[ithx][ithy] = IHT;\r
\r
/* check to see if all holes plugged */\r
for (i = 1; i < 11; i++) {\r
- if (quad[1][i]!=IHWEB && quad[1][i]!=IHT) return;\r
- if (quad[10][i]!=IHWEB && quad[10][i]!=IHT) return;\r
- if (quad[i][1]!=IHWEB && quad[i][1]!=IHT) return;\r
- if (quad[i][10]!=IHWEB && quad[i][10]!=IHT) return;\r
+ if (frozen.quad[1][i]!=IHWEB && frozen.quad[1][i]!=IHT) return;\r
+ if (frozen.quad[10][i]!=IHWEB && frozen.quad[10][i]!=IHT) return;\r
+ if (frozen.quad[i][1]!=IHWEB && frozen.quad[i][1]!=IHT) return;\r
+ if (frozen.quad[i][10]!=IHWEB && frozen.quad[i][10]!=IHT) return;\r
}\r
/* All plugged up -- Tholian splits */\r
- quad[ithx][ithy]=IHWEB;\r
+ frozen.quad[ithx][ithy]=IHWEB;\r
dropin(IHBLANK, &dum, &my);\r
crmena(1,IHT, 2, ithx, ithy);\r
prout(" completes web.");\r
proutn(" - ");\r
cramf(y, 0, 1);\r
proutn(" ");\r
- iquad=quad[ix][iy];\r
+ iquad=frozen.quad[ix][iy];\r
if (iquad==IHDOT) continue;\r
/* hit something */\r
skip(1);\r
jx=ix+xx+0.5;\r
jy=iy+yy+0.5;\r
if (jx<1 || jx>10 || jy<1 ||jy > 10) return;\r
- if (quad[jx][jy]==IHBLANK) {\r
+ if (frozen.quad[jx][jy]==IHBLANK) {\r
finish(FHOLE);\r
return;\r
}\r
- if (quad[jx][jy]!=IHDOT) {\r
+ if (frozen.quad[jx][jy]!=IHDOT) {\r
/* can't move into object */\r
return;\r
}\r
prout(" damaged but not destroyed.");\r
return;\r
}\r
- if (quad[jx][jy]==IHBLANK) {\r
+ if (frozen.quad[jx][jy]==IHBLANK) {\r
prout(" buffeted into black hole.");\r
deadkl(ix, iy, iquad, jx, jy);\r
return;\r
}\r
- if (quad[jx][jy]!=IHDOT) {\r
+ if (frozen.quad[jx][jy]!=IHDOT) {\r
/* can't move into object */\r
prout(" damaged but not destroyed.");\r
return;\r
break;\r
}\r
}\r
- quad[ix][iy]=IHDOT;\r
+ frozen.quad[ix][iy]=IHDOT;\r
state.rembase--;\r
basex=basey=0;\r
state.galaxy[quadx][quady] -= 10;\r
state.plnets[iplnet] = nulplanet;\r
iplnet = 0;\r
plnetx = plnety = 0;\r
- quad[ix][iy] = IHDOT;\r
+ frozen.quad[ix][iy] = IHDOT;\r
if (landed==1) {\r
/* captain parishes on planet */\r
finish(FDPLANET);\r
proutn("Mr. Spock-");\r
prouts(" \"Facinating!\"");\r
skip(1);\r
- quad[ix][iy] = IHDOT;\r
+ frozen.quad[ix][iy] = IHDOT;\r
return;\r
case IHBLANK: /* Black hole */\r
skip(1);\r
h1 = fabs(h1);\r
if (h1 >= 600) {\r
prout(" destroyed.");\r
- quad[ix][iy] = IHDOT;\r
+ frozen.quad[ix][iy] = IHDOT;\r
ithere = 0;\r
ithx = ithy = 0;\r
return;\r
return;\r
}\r
prout(" disappears.");\r
- quad[ix][iy] = IHWEB;\r
+ frozen.quad[ix][iy] = IHWEB;\r
ithere = ithx = ithy = 0;\r
{\r
int dum, my;\r
break;\r
}\r
if (shoved) {\r
- quad[jx][jy]=iquad;\r
- quad[ix][iy]=IHDOT;\r
+ frozen.quad[jx][jy]=iquad;\r
+ frozen.quad[ix][iy]=IHDOT;\r
proutn(" displaced by blast to");\r
cramlc(2, jx, jy);\r
skip(1);\r
if (kpower[l] < 500) r *= 0.25; \r
jx = kx[l];\r
jy = ky[l];\r
- iquad = quad[jx][jy];\r
+ iquad = frozen.quad[jx][jy];\r
itflag = (iquad == IHK && r > 0.0005) || k == 0 ||\r
(iquad==IHC && r > 0.015) ||\r
(iquad==IHR && r > 0.3) ||\r
\r
/* For each kind of enemy, finish message to player */\r
prout(" destroyestate.");\r
- quad[ix][iy] = IHDOT;\r
+ frozen.quad[ix][iy] = IHDOT;\r
if (state.remkl==0) return;\r
\r
state.remtime = state.remres/(state.remkl + 4*state.remcom);\r
rpow = 0.0;\r
for (k = 1; k <= nenhere;) {\r
int ii = kx[k], jj = ky[k];\r
- int ienm = quad[ii][jj];\r
+ int ienm = frozen.quad[ii][jj];\r
if (msgflag) {\r
proutn("Energy available= ");\r
cramf(energy-.006-(ifast?200:0), 0, 2);\r
}\r
else\r
proutn("Very small hit on ");\r
- ienm = quad[ii][jj];\r
+ ienm = frozen.quad[ii][jj];\r
crmena(0,ienm,2,ii,jj);\r
skip(1);\r
if (kpow == 0) {\r
/* Handle case where base is in same quadrant as starship */\r
if (batx==quadx && baty==quady) {\r
if (starch[batx][baty] > 999) starch[batx][baty] -= 10;\r
- quad[basex][basey]= IHDOT;\r
+ frozen.quad[basex][basey]= IHDOT;\r
basex=basey=0;\r
newcnd();\r
skip(1);\r
}\r
\r
/* handle initial nova */\r
- quad[ix][iy] = IHDOT;\r
+ frozen.quad[ix][iy] = IHDOT;\r
crmena(1, IHSTAR, 2, ix, iy);\r
prout(" novas.");\r
state.galaxy[quadx][quady] -= 1;\r
ii = hits[mm][1]+nn-2;\r
jj = hits[mm][2]+j-2;\r
if (ii < 1 || ii > 10 || jj < 1 || jj > 10) continue;\r
- iquad = quad[ii][jj];\r
+ iquad = frozen.quad[ii][jj];\r
switch (iquad) {\r
// case IHDOT: /* Empty space ends reaction\r
// case IHQUEST:\r
state.starkl++;\r
crmena(1, IHSTAR, 2, ii, jj);\r
prout(" novas.");\r
- quad[ii][jj] = IHDOT;\r
+ frozen.quad[ii][jj] = IHDOT;\r
break;\r
case IHP: /* Destroy planet */\r
state.newstuf[quadx][quady] -= 1;\r
finish(FPNOVA);\r
return;\r
}\r
- quad[ii][jj] = IHDOT;\r
+ frozen.quad[ii][jj] = IHDOT;\r
break;\r
case IHB: /* Destroy base */\r
state.galaxy[quadx][quady] -= 10;\r
newcnd();\r
crmena(1, IHB, 2, ii, jj);\r
prout(" destroyed.");\r
- quad[ii][jj] = IHDOT;\r
+ frozen.quad[ii][jj] = IHDOT;\r
break;\r
case IHE: /* Buffet ship */\r
case IHF:\r
skip(1);\r
break;\r
}\r
- iquad1 = quad[newcx][newcy];\r
+ iquad1 = frozen.quad[newcx][newcy];\r
if (iquad1 == IHBLANK) {\r
proutn(", blasted into ");\r
crmena(0, IHBLANK, 2, newcx, newcy);\r
}\r
proutn(", buffeted to");\r
cramlc(2, newcx, newcy);\r
- quad[ii][jj] = IHDOT;\r
- quad[newcx][newcy] = iquad;\r
+ frozen.quad[ii][jj] = IHDOT;\r
+ frozen.quad[newcx][newcy] = iquad;\r
kx[ll] = newcx;\r
ky[ll] = newcy;\r
kavgd[ll] = sqrt(square(sectx-newcx)+square(secty-newcy));\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
+ if (frozen.quad[nsx][nsy]==IHSTAR) {\r
num--;\r
if (num==0) break;\r
}\r
int l=1;\r
while (l <= nenhere) {\r
if (kpower[l]*kdist[l] <= whammo) \r
- deadkl(kx[l],ky[l], quad[kx[l]][ky[l]], kx[l], ky[l]);\r
+ deadkl(kx[l],ky[l], frozen.quad[kx[l]][ky[l]], kx[l], ky[l]);\r
l++;\r
}\r
}\r
Time = future[FTBEAM] - state.date + 1e-5;\r
}\r
/* Move within the quadrant */\r
- quad[sectx][secty] = IHDOT;\r
+ frozen.quad[sectx][secty] = IHDOT;\r
x = sectx;\r
y = secty;\r
n = 10.0*dist*bigger+0.5;\r
proutn("\nEntering");\r
cramlc(1, quadx, quady);\r
skip(1);\r
- quad[sectx][secty] = ship;\r
+ frozen.quad[sectx][secty] = ship;\r
newqad(0);\r
return;\r
}\r
- iquad = quad[ix][iy];\r
+ iquad = frozen.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
+ frozen.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
y += deltay;\r
iy = y +0.5;\r
if (iy < 1 || iy > 10) break;\r
- if (quad[ix][iy] != IHDOT) {\r
+ if (frozen.quad[ix][iy] != IHDOT) {\r
blooey = 0;\r
twarp = 0;\r
}\r
newqad(1);\r
}\r
/* dematerialize starship */\r
- quad[sectx][secty]=IHDOT;\r
+ frozen.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 && frozen.quad[ix][iy]==IHDOT) {\r
/* found one -- finish up */\r
prout("succeeds.");\r
sectx=ix;\r
secty=iy;\r
- quad[ix][iy]=ship;\r
+ frozen.quad[ix][iy]=ship;\r
dock();\r
skip(1);\r
prout("Lt. Uhura- \"Captain, we made it!\"");\r
prouts("Sulu- \"Captain! It's working!\"");\r
skip(2);\r
while (nenhere > 0)\r
- deadkl(kx[1],ky[1],quad[kx[1]][ky[1]],kx[1],ky[1]);\r
+ deadkl(kx[1],ky[1],frozen.quad[kx[1]][ky[1]],kx[1],ky[1]);\r
prout("Ensign Chekov- \"Congratulations, Captain!\"");\r
if (state.remkl == 0) finish(FWON);\r
prout("Spock- \"Captain, I believe the `Experimental Death Ray'");\r
prout(" Mr. Sulu.");\r
for (i=1; i<=10; i++)\r
for (j=1; j<=10; j++)\r
- if (quad[i][j] == IHDOT) quad[i][j] = IHQUEST;\r
+ if (frozen.quad[i][j] == IHDOT) frozen.quad[i][j] = IHQUEST;\r
prout(" Captain, our quadrant is now infested with");\r
prouts(" - - - - - - *THINGS*.");\r
skip(1);\r
printf("%2d ", i);\r
for (j = 1; j <= 10; j++) {\r
if (goodScan || (abs(i-sectx)<= 1 && abs(j-secty) <= 1))\r
- printf("%c ",quad[i][j]);\r
+ printf("%c ",frozen.quad[i][j]);\r
else\r
printf("- ");\r
}\r
}\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(ky, sizeof(ky), 1, fp);\r
fwrite(starch, sizeof(starch), 1, fp);\r
}\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(ky, sizeof(ky), 1, fp);\r
fread(starch, sizeof(starch), 1, fp);\r
}\r
for (;;) {\r
/* position next to base by trial and error */\r
- quad[sectx][secty] = IHDOT;\r
+ frozen.quad[sectx][secty] = IHDOT;\r
for (l = 1; l <= 10; l++) {\r
sectx = 3.0*Rand() - 1.0 + basex;\r
secty = 3.0*Rand() - 1.0 + basey;\r
if (sectx >= 1 && sectx <= 10 &&\r
secty >= 1 && secty <= 10 &&\r
- quad[sectx][secty] == IHDOT) break;\r
+ frozen.quad[sectx][secty] == IHDOT) break;\r
}\r
if (l < 11) break; /* found a spot */\r
sectx=5;\r
}\r
}\r
/* Get new commission */\r
- quad[sectx][secty] = ship = IHF;\r
+ frozen.quad[sectx][secty] = ship = IHF;\r
prout("Starfleet puts you in command of another ship,");\r
prout("the Faerie Queene, which is antiquated but,");\r
prout("still useable.");\r
\r
void dropin(int iquad, int *ix, int *iy) {\r
do iran10(ix, iy);\r
- while (quad[*ix][*iy] != IHDOT);\r
- quad[*ix][*iy] = iquad;\r
+ while (frozen.quad[*ix][*iy] != IHDOT);\r
+ frozen.quad[*ix][*iy] = iquad;\r
}\r
\r
void newcnd(void) {\r
}\r
// Clear quadrant\r
for (i=1; i <= 10; i++)\r
- for (j=1; j <= 10; j++) quad[i][j] = IHDOT;\r
+ for (j=1; j <= 10; j++) frozen.quad[i][j] = IHDOT;\r
// cope with supernova\r
if (quadnum > 999) {\r
return;\r
nenhere = klhere + irhere;\r
\r
// Position Starship\r
- quad[sectx][secty] = ship;\r
+ frozen.quad[sectx][secty] = ship;\r
\r
// Decide if quadrant needs a Tholian\r
if ((skill < 3 && Rand() <= 0.02) || /* Lighten up if skill is low */\r
do {\r
ithx = Rand() > 0.5 ? 10 : 1;\r
ithy = Rand() > 0.5 ? 10 : 1;\r
- } while (quad[ithx][ithy] != IHDOT);\r
- quad[ithx][ithy] = IHT;\r
+ } while (frozen.quad[ithx][ithy] != IHDOT);\r
+ frozen.quad[ithx][ithy] = IHT;\r
ithere = 1;\r
/* Reserve unocupied corners */\r
- if (quad[1][1]==IHDOT) quad[1][1] = 'X';\r
- if (quad[1][10]==IHDOT) quad[1][10] = 'X';\r
- if (quad[10][1]==IHDOT) quad[10][1] = 'X';\r
- if (quad[10][10]==IHDOT) quad[10][10] = 'X';\r
+ if (frozen.quad[1][1]==IHDOT) frozen.quad[1][1] = 'X';\r
+ if (frozen.quad[1][10]==IHDOT) frozen.quad[1][10] = 'X';\r
+ if (frozen.quad[10][1]==IHDOT) frozen.quad[10][1] = 'X';\r
+ if (frozen.quad[10][10]==IHDOT) frozen.quad[10][10] = 'X';\r
}\r
\r
if (quadnum >= 100) {\r
if (state.cx[i]==quadx && state.cy[i]==quady) break;\r
\r
if (i <= state.remcom) {\r
- quad[ix][iy] = IHC;\r
+ frozen.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 == state.isx && quady == state.isy) {\r
- quad[kx[1]][ky[1]] = IHS;\r
+ frozen.quad[kx[1]][ky[1]] = IHS;\r
kpower[1] = 1175.0 + 400.0*Rand() + 125.0*skill;\r
iscate = 1;\r
ishere = 1;\r
\r
// Take out X's in corners if Tholian present\r
if (ithere) {\r
- if (quad[1][1]=='X') quad[1][1] = IHDOT;\r
- if (quad[1][10]=='X') quad[1][10] = IHDOT;\r
- if (quad[10][1]=='X') quad[10][1] = IHDOT;\r
- if (quad[10][10]=='X') quad[10][10] = IHDOT;\r
+ if (frozen.quad[1][1]=='X') frozen.quad[1][1] = IHDOT;\r
+ if (frozen.quad[1][10]=='X') frozen.quad[1][10] = IHDOT;\r
+ if (frozen.quad[10][1]=='X') frozen.quad[10][1] = IHDOT;\r
+ if (frozen.quad[10][10]=='X') frozen.quad[10][10] = IHDOT;\r
} \r
}\r
\r
remtime; // remaining time\r
} state, snapsht; // Data that is snapshot\r
\r
-EXTERN char\r
- quad[11][11]; // contents of our quadrant\r
-\r
// Scalar variables that are needed for freezing the game\r
// are placed in a structure. #defines are used to access by their\r
// original names. Gee, I could have done this with the d structure,\r
// but I just didn't think of it back when I started.\r
\r
EXTERN struct foo2 {\r
+ char quad[11][11]; // contents of our quadrant\r
int inkling,\r
inbase,\r
incom,\r