all one C structure array now. Also back out "Bases left" report.
* Code to hurl you out of quadrant if a supernova occurs as you warp in
seems to hang.
-* Regenerate Thingy at random location when unfreezing a game.
+* "Bases left" report doesn't look right in the -t version.
+
+* Orbit height is negative.
iqx = quadx+(lookx+(QUADSIZE-1))/QUADSIZE - 1;
iqy = quady+(looky+(QUADSIZE-1))/QUADSIZE - 1;
if (iqx < 1 || iqx > GALSIZE || iqy < 1 || iqy > GALSIZE ||
- NOEXIT(game.state.galaxy[iqx][iqy]))
+ game.state.galaxy[iqx][iqy].supernova ||
+ game.state.galaxy[iqx][iqy].klingons > 8)
return 0; /* no can do -- neg energy, supernovae, or >8 Klingons */
if (ienm == IHR) return 0; /* Romulans cannot escape! */
if (irun == 0) {
nenhere--;
if (condit != IHDOCKED) newcnd();
/* Handle global matters related to escape */
- game.state.galaxy[quadx][quady] -= KLINGON_PLACE;
- game.state.galaxy[iqx][iqy] += KLINGON_PLACE;
+ game.state.galaxy[quadx][quady].klingons--;
+ game.state.galaxy[iqx][iqy].klingons++;
if (ienm==IHS) {
ishere=0;
iscate=0;
if ((iqx==quadx && iqy==quady) ||
iqx < 1 || iqx > GALSIZE || iqy < 1 || iqy > GALSIZE ||
- NOEXIT(game.state.galaxy[iqx][iqy])) return 1;
+ game.state.galaxy[iqx][iqy].supernova ||
+ game.state.galaxy[iqx][iqy].klingons > 8)
+ return 1;
if (flag) {
/* Avoid quadrants with bases if we want to avoid Enterprise */
for (i = 1; i <= game.state.rembase; i++)
}
if (justin && !iscate) return 1;
/* do the move */
- game.state.galaxy[game.state.isx][game.state.isy] -= KLINGON_PLACE;
+ game.state.galaxy[game.state.isx][game.state.isy].klingons--;
game.state.isx = iqx;
game.state.isy = iqy;
- game.state.galaxy[game.state.isx][game.state.isy] += KLINGON_PLACE;
+ game.state.galaxy[game.state.isx][game.state.isy].klingons++;
if (ishere) {
/* SC has scooted, Remove him from current quadrant */
iscate=0;
game.state.plnets[i].crystals == 1) {
/* destroy the planet */
DESTROY(&game.state.plnets[i]);
- game.state.newstuf[game.state.isx][game.state.isy] -= 1;
+ game.state.galaxy[game.state.isx][game.state.isy].planets -= 1;
if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED) {
if (*ipage==0) pause_game(1);
*ipage = 1;
ibqy = game.state.baseqy[i];
if ((ibqx == quadx && ibqy == quady) ||
(ibqx == batx && ibqy == baty) ||
- NOEXIT(game.state.galaxy[ibqx][ibqy])) continue;
+ game.state.galaxy[ibqx][ibqy].supernova ||
+ game.state.galaxy[ibqx][ibqy].klingons > 8)
+ continue;
/* if there is a commander, an no other base is appropriate,
we will take the one with the commander */
for (j = 1; j <= game.state.remcom; j++) {
#endif
(Rand() > 0.2 ||
(game.damage[DRADIO] > 0.0 && condit != IHDOCKED) ||
- game.starch[game.state.isx][game.state.isy] > 0))
+ !game.state.galaxy[game.state.isx][game.state.isy].charted))
return;
if (*ipage==0) pause_game(1);
*ipage = 1;
case IHB: /* Hit a base */
skip(1);
prout("***STARBASE DESTROYED..");
- if (game.starch[quadx][quady] < 0) game.starch[quadx][quady] = 0;
for (ll=1; ll<=game.state.rembase; ll++) {
if (game.state.baseqx[ll]==quadx && game.state.baseqy[ll]==quady) {
game.state.baseqx[ll]=game.state.baseqx[game.state.rembase];
game.quad[ix][iy]=IHDOT;
game.state.rembase--;
basex=basey=0;
- game.state.galaxy[quadx][quady] -= BASE_PLACE;
+ game.state.galaxy[quadx][quady].starbase--;
+ game.state.chart[quadx][quady].starbase--;
game.state.basekl++;
newcnd();
return;
crmena(1, iquad, 2, ix, iy);
prout(" destroyed.");
game.state.nplankl++;
- game.state.newstuf[quadx][quady] -= 1;
+ game.state.galaxy[quadx][quady].planets--;
DESTROY(&game.state.plnets[iplnet]);
iplnet = 0;
plnetx = plnety = 0;
r = (Rand()+Rand())*0.5 -0.5;
r += 0.002*game.kpower[l]*r;
torpedo(course, r, jx, jy, &hit, 0, 1, 1);
- if (game.state.remkl==0) finish(FWON); /* Klingons did themselves in! */
- if (game.state.galaxy[quadx][quady] == SUPERNOVA_PLACE ||
- alldone) return; /* Supernova or finished */
+ if (game.state.remkl==0)
+ finish(FWON); /* Klingons did themselves in! */
+ if (game.state.galaxy[quadx][quady].supernova || alldone)
+ return; /* Supernova or finished */
if (hit == 0) continue;
}
if (shldup != 0 || shldchg != 0 || condit==IHDOCKED) {
/* Decide what kind of enemy it is and update approriately */
if (type == IHR) {
/* chalk up a Romulan */
- game.state.newstuf[quadx][quady] -= ROMULAN_PLACE;
+ game.state.galaxy[quadx][quady].romulans--;
irhere--;
game.state.nromkl++;
game.state.nromrem--;
}
else {
/* Some type of a Klingon */
- game.state.galaxy[quadx][quady] -= KLINGON_PLACE;
+ game.state.galaxy[quadx][quady].klingons--;
klhere--;
game.state.remkl--;
switch (type) {
if (shldup || condit == IHDOCKED)
r *= 1.0 + 0.0001*shield;
torpedo(course[i], r, sectx, secty, &dummy, 0, i, n);
- if (alldone||game.state.galaxy[quadx][quady]==SUPERNOVA_PLACE)
+ if (alldone || game.state.galaxy[quadx][quady].supernova)
return;
}
if (game.state.remkl==0) finish(FWON);
{
int ictbeam=0, ipage=0, istract=0, line, i=0, j, k, l, ixhold=0, iyhold=0;
double fintim = game.state.date + Time, datemin, xtime, repair, yank=0;
+ int radio_was_broken;
#ifdef DEBUG
if (idebug) prout("EVENTS");
#endif
- if (stdamtim == 1e30 && game.damage[DRADIO] != 0.0) {
- /* chart will no longer be updated because radio is dead */
- stdamtim = game.state.date;
- for (i=1; i <= GALSIZE ; i++)
- for (j=1; j <= GALSIZE; j++)
- if (game.starch[i][j] == 1)
- game.starch[i][j] = game.state.galaxy[i][j]+SUPERNOVA_PLACE;
- }
+ radio_was_broken = (game.damage[DRADIO] != 0.0);
for (;;) {
/* Select earliest extraneous event, line==0 if no events */
if (game.damage[l] > 0.0 && l != DDRAY)
game.damage[l] -= (game.damage[l]-repair > 0.0 ? repair : game.damage[l]);
/* If radio repaired, update star chart and attack reports */
- if (stdamtim != 1e30 && game.damage[DRADIO] == 0.0) {
+ if (radio_was_broken && game.damage[DRADIO] == 0.0) {
stdamtim = 1e30;
prout("Lt. Uhura- \"Captain, the sub-space radio is working and");
prout(" surveillance reports are coming in.");
skip(1);
- for (i=1; i <= GALSIZE ; i++)
- for (j=1; j <= GALSIZE; j++)
- if (game.starch[i][j] >= SUPERNOVA_PLACE) game.starch[i][j] = 1;
if (iseenit==0) {
attakreport(0);
iseenit = 1;
}
- skip(1);
+ rechart();
prout(" The star chart is now up to date.\"");
skip(1);
}
ipage=1;
snova(0,0);
game.future[FSNOVA] = game.state.date + expran(0.5*intime);
- if (game.state.galaxy[quadx][quady] == SUPERNOVA_PLACE) return;
+ if (game.state.galaxy[quadx][quady].supernova) return;
break;
case FSPY: /* Check with spy to see if S.C. should tractor beam */
if (game.state.nscrem == 0 ||
case FSCDBAS: /* Supercommander destroys base */
game.future[FSCDBAS] = 1e30;
isatb = 2;
- if (!BASES(game.state.galaxy[game.state.isx][game.state.isy]))
+ if (!game.state.galaxy[game.state.isx][game.state.isy].starbase)
break; /* WAS RETURN! */
ixhold = batx;
iyhold = baty;
game.future[FCDBAS] = 1e30;
/* find the lucky pair */
for (i = 1; i <= game.state.remcom; i++)
- if (game.state.cx[i]==batx && game.state.cy[i]==baty) break;
+ if (game.state.cx[i]==batx && game.state.cy[i]==baty)
+ break;
if (i > game.state.remcom || game.state.rembase == 0 ||
- !BASES(game.state.galaxy[batx][baty])) {
+ !game.state.galaxy[batx][baty].starbase) {
/* No action to take after all */
batx = baty = 0;
break;
}
/* Code merges here for any commander destroying base */
/* Not perfect, but will have to do */
- if (game.starch[batx][baty] == -1) game.starch[batx][baty] = 0;
/* Handle case where base is in same quadrant as starship */
if (batx==quadx && baty==quady) {
- if (game.starch[batx][baty] >= SUPERNOVA_PLACE) game.starch[batx][baty] -= BASE_PLACE;
+ game.state.chart[batx][baty].starbase = FALSE;
game.quad[basex][basey]= IHDOT;
basex=basey=0;
newcnd();
prout(" has been destroyed by");
if (isatb==2) prout("the Klingon Super-Commander");
else prout("a Klingon Commander");
+ game.state.chart[batx][baty].starbase = FALSE;
}
/* Remove Starbase from galaxy */
- game.state.galaxy[batx][baty] -= BASE_PLACE;
+ game.state.galaxy[batx][baty].starbase = FALSE;
for (i=1; i <= game.state.rembase; i++)
if (game.state.baseqx[i]==batx && game.state.baseqy[i]==baty) {
game.state.baseqx[i]=game.state.baseqx[game.state.rembase];
probecx = i;
probecy = j;
if (i < 1 || i > GALSIZE || j < 1 || j > GALSIZE ||
- game.state.galaxy[probecx][probecy] == SUPERNOVA_PLACE) {
+ game.state.galaxy[probecx][probecy].supernova) {
// Left galaxy or ran into supernova
if (game.damage[DRADIO]==0.0 || condit == IHDOCKED) {
if (ipage==0) pause_game(1);
}
/* Update star chart if Radio is working or have access to
radio. */
- if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED)
- game.starch[probecx][probecy] = game.damage[DRADIO] > 0.0 ?
- game.state.galaxy[probecx][probecy]+SUPERNOVA_PLACE : 1;
+ if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED) {
+ game.state.chart[probecx][probecy].klingons = game.state.galaxy[probecx][probecy].klingons;
+ game.state.chart[probecx][probecy].starbase = game.state.galaxy[probecx][probecy].starbase;
+ game.state.chart[probecx][probecy].stars = game.state.galaxy[probecx][probecy].stars;
+ game.state.galaxy[probecx][probecy].charted = TRUE;
+ }
proben--; // One less to travel
if (proben == 0 && isarmed &&
- STARS(game.state.galaxy[probecx][probecy])) {
+ game.state.galaxy[probecx][probecy].stars) {
/* lets blow the sucker! */
snova(1,0);
game.future[FDSPROB] = 1e30;
- if (game.state.galaxy[quadx][quady] == SUPERNOVA_PLACE) return;
+ if (game.state.galaxy[quadx][quady].supernova)
+ return;
}
break;
}
if (origTime-delay >= 9.99 && condit == IHDOCKED)
game.damage[DDRAY] = 0.0;
} while
- (game.state.galaxy[quadx][quady] != SUPERNOVA_PLACE); // leave if quadrant supernovas
+ // leave if quadrant supernovas
+ (!game.state.galaxy[quadx][quady].supernova);
resting = 0;
Time = 0;
game.quad[ix][iy] = IHDOT;
crmena(1, IHSTAR, 2, ix, iy);
prout(" novas.");
- game.state.galaxy[quadx][quady] -= 1;
+ game.state.galaxy[quadx][quady].stars--;
game.state.starkl++;
/* Set up stack to recursively trigger adjacent stars */
top2++;
hits[top2][1]=ii;
hits[top2][2]=jj;
- game.state.galaxy[quadx][quady] -= 1;
+ game.state.galaxy[quadx][quady].stars -= 1;
game.state.starkl++;
crmena(1, IHSTAR, 2, ii, jj);
prout(" novas.");
game.quad[ii][jj] = IHDOT;
break;
case IHP: /* Destroy planet */
- game.state.newstuf[quadx][quady] -= 1;
+ game.state.galaxy[quadx][quady].planets -= 1;
game.state.nplankl++;
crmena(1, IHP, 2, ii, jj);
prout(" destroyed.");
game.quad[ii][jj] = IHDOT;
break;
case IHB: /* Destroy base */
- game.state.galaxy[quadx][quady] -= BASE_PLACE;
+ game.state.galaxy[quadx][quady].starbase = FALSE;
for (i = 1; i <= game.state.rembase; i++)
- if (game.state.baseqx[i]==quadx && game.state.baseqy[i]==quady) break;
+ if (game.state.baseqx[i]==quadx && game.state.baseqy[i]==quady)
+ break;
game.state.baseqx[i] = game.state.baseqx[game.state.rembase];
game.state.baseqy[i] = game.state.baseqy[game.state.rembase];
game.state.rembase--;
void snova(int insx, int insy)
{
- int comdead, nqx=0, nqy=0, nsx, nsy, num, kldead, iscdead;
+ int comdead, nqx=0, nqy=0, nsx, nsy, num=0, kldead, iscdead;
int nrmdead, npdead;
int incipient=0;
left of universe */
for (nqx = 1; nqx<=GALSIZE; nqx++) {
for (nqy = 1; nqy<=GALSIZE; nqy++) {
- stars += STARS(game.state.galaxy[nqx][nqy]);
+ stars += game.state.galaxy[nqx][nqy].stars;
}
}
if (stars == 0) return; /* nothing to supernova exists */
num = Rand()*stars + 1;
for (nqx = 1; nqx<=GALSIZE; nqx++) {
for (nqy = 1; nqy<=GALSIZE; nqy++) {
- num -= STARS(game.state.galaxy[nqx][nqy]);
+ num -= game.state.galaxy[nqx][nqy].stars;
if (num <= 0) break;
}
if (num <=0) break;
else {
/* we are in the quadrant! */
incipient = 1;
- num = Rand()* STARS(game.state.galaxy[nqx][nqy]) + 1;
+ num = Rand()* game.state.galaxy[nqx][nqy].stars + 1;
for (nsx=1; nsx < QUADSIZE; nsx++) {
for (nsy=1; nsy < QUADSIZE; nsy++) {
if (game.quad[nsx][nsy]==IHSTAR) {
}
}
/* destroy any Klingons in supernovaed quadrant */
- num=game.state.galaxy[nqx][nqy];
- kldead = num/100;
+ kldead = game.state.galaxy[nqx][nqy].klingons;
+ game.state.galaxy[nqx][nqy].klingons = 0;
comdead = iscdead = 0;
if (nqx==game.state.isx && nqy == game.state.isy) {
/* did in the Supercommander! */
}
}
/* destroy Romulans and planets in supernovaed quadrant */
- num = game.state.newstuf[nqx][nqy];
- game.state.newstuf[nqx][nqy] = 0;
- nrmdead = num/10;
+ nrmdead = game.state.galaxy[nqx][nqy].romulans;
+ game.state.galaxy[nqx][nqy].romulans = 0;
game.state.nromrem -= nrmdead;
npdead = num - nrmdead*10;
if (npdead) {
}
/* If starship caused supernova, tally up destruction */
if (insx) {
- num = game.state.galaxy[nqx][nqy] % 100;
- game.state.starkl += num % 10;
- game.state.basekl += num/10;
+ game.state.starkl += game.state.galaxy[nqx][nqy].stars;
+ game.state.basekl += game.state.galaxy[nqx][nqy].starbase;
game.state.killk += kldead;
game.state.killc += comdead;
game.state.nromkl += nrmdead;
if ((quadx == nqx && quady == nqy) ||
game.damage[DRADIO] == 0 ||
condit == IHDOCKED)
- game.starch[nqx][nqy] = 1;
- game.state.galaxy[nqx][nqy] = SUPERNOVA_PLACE;
+ game.state.galaxy[nqx][nqy].supernova = TRUE;
/* If supernova destroys last klingons give special message */
if (game.state.remkl==0 && (nqx != quadx || nqy != quady)) {
skip(2);
void setpassword(void)
{
- if (!game.options & OPTION_CURSES) {
+ if (!(game.options & OPTION_CURSES)) {
while (TRUE) {
scan();
strcpy(game.passwd, citem);
* that attacks only happen if Klingons
* are present and your skill is good.
*/
- if (skill > SKILL_GOOD && klhere > 0 && game.state.galaxy[quadx][quady] != SUPERNOVA_PLACE)
+ if (skill > SKILL_GOOD && klhere > 0 && !game.state.galaxy[quadx][quady].supernova)
attack(0);
if (alldone) return;
}
game.kdist[l] = finald;
}
sortkl();
- if (game.state.galaxy[quadx][quady] != SUPERNOVA_PLACE && iattak == 0)
+ if (!game.state.galaxy[quadx][quady].supernova && iattak == 0)
attack(0);
for (l = 1 ; l <= nenhere; l++) game.kavgd[l] = game.kdist[l];
}
if (landed == 1 && !isprobe) {
prout("Dummy! You can't leave standard orbit until you");
- proutn("are back abourt the ");
+ proutn("are back aboard the ");
crmshp();
prout(".");
chew();
crmshp();
skip(1);
prout("safely out of quadrant.");
- game.starch[quadx][quady] = game.damage[DRADIO] > 0.0 ? game.state.galaxy[quadx][quady]+SUPERNOVA_PLACE:1;
-
+ if (game.damage[DRADIO] == 0.0)
+ game.state.galaxy[quadx][quady].charted = TRUE;
/* Try to use warp engines */
if (game.damage[DWARPEN]) {
skip(1);
finish(FSNOVAED);
return;
}
+ } while
/* Repeat if another snova */
- } while (game.state.galaxy[quadx][quady] == SUPERNOVA_PLACE);
- if (game.state.remkl==0) finish(FWON); /* Snova killed remaining enemy. */
+ (game.state.galaxy[quadx][quady].supernova);
+ if (game.state.remkl==0)
+ finish(FWON); /* Snova killed remaining enemy. */
}
void timwrp()
{
- int l, ll, gotit;
+ int l, gotit;
prout("***TIME WARP ENTERED.");
if (game.state.snap && Rand() < 0.5) {
/* Go back in time */
prout("Checkov- \"Security reports the Galileo has reappeared in the dock!\"");
iscraft = 1;
}
-
- /* Revert star chart to earlier era, if it was known then*/
- if (game.damage[DRADIO]==0.0 || stdamtim > game.state.date) {
- for (l = 1; l <= GALSIZE; l++)
- for (ll = 1; ll <= GALSIZE; ll++)
- if (game.starch[l][ll] > 1)
- game.starch[l][ll]=game.damage[DRADIO]>0.0 ? game.state.galaxy[l][ll]+SUPERNOVA_PLACE :1;
- prout("Spock has reconstructed a correct star chart from memory");
- if (game.damage[DRADIO] > 0.0) stdamtim = game.state.date;
- }
+ /*
+ * There used to be code to do the actual reconstrction here,
+ * but the starchart is now part of the snapshotted galaxy state.
+ */
+ prout("Spock has reconstructed a correct star chart from memory");
}
else {
/* Go forward in time */
events(); /* Used to avoid if future[FSCMOVE] within time */
// future[FSNOVA] = asave;
/*fails if game over, quadrant super-novas or we've moved to new quadrant*/
- if (alldone || game.state.galaxy[quadx][quady] == SUPERNOVA_PLACE || justin != 0) return 1;
+ if (alldone || game.state.galaxy[quadx][quady].supernova || justin != 0) return 1;
return 0;
}
if (x == 0 || x > GALSIZE || y == 0 || y > GALSIZE)
proutn(" -1");
else {
- if (game.state.galaxy[x][y]<SUPERNOVA_PLACE) proutn(" %3d", game.state.galaxy[x][y]);
- else proutn("***");
- game.starch[x][y] = game.damage[DRADIO] > 0 ? game.state.galaxy[x][y]+SUPERNOVA_PLACE : 1;
+ if (!game.damage[DRADIO])
+ game.state.galaxy[x][y].charted = TRUE;
+ game.state.chart[x][y].klingons = game.state.galaxy[x][y].klingons;
+ game.state.chart[x][y].starbase = game.state.galaxy[x][y].starbase;
+ game.state.chart[x][y].stars = game.state.galaxy[x][y].stars;
+ if (game.state.galaxy[x][y].supernova)
+ proutn("***");
+ else
+ proutn(" %-3d", game.state.chart[x][y].klingons*100 + game.state.chart[x][y].starbase * 10 + game.state.chart[x][y].stars);
}
}
prout(" ");
if (!jdam) prout("All devices functional.");
}
+void rechart(void)
+/* update the chart in the Enterprise's computer from galaxy data */
+{
+ int i, j;
+ stdamtim = game.state.date;
+ for (i=1; i <= GALSIZE ; i++)
+ for (j=1; j <= GALSIZE; j++)
+ if (game.state.galaxy[i][j].charted) {
+ game.state.chart[i][j].klingons = game.state.galaxy[i][j].klingons;
+ game.state.chart[i][j].starbase = game.state.galaxy[i][j].starbase;
+ game.state.chart[i][j].stars = game.state.galaxy[i][j].stars;
+ }
+}
+
void chart(int nn)
{
int i,j;
if (stdamtim != 1e30) {
if (condit == IHDOCKED) {
/* We are docked, so restore chart from base information */
- stdamtim = game.state.date;
- for (i=1; i <= GALSIZE ; i++)
- for (j=1; j <= GALSIZE; j++)
- if (game.starch[i][j] == 1) game.starch[i][j] = game.state.galaxy[i][j]+SUPERNOVA_PLACE;
+ rechart();
}
- else {
- proutn("(Last surveillance update %d stardates ago.",
+ else if (game.state.date-stdamtim) {
+ prout("(Last surveillance update %d stardates ago).",
(int)(game.state.date-stdamtim));
}
}
+ else if (game.damage[DRADIO] == 0.0)
+ rechart();
prout(" 1 2 3 4 5 6 7 8");
for (i = 1; i <= GALSIZE; i++) {
for (j = 1; j <= GALSIZE; j++) {
char buf[4];
proutn(" ");
- if (game.starch[i][j] == CHART_UNKNOWN)
- strcpy(buf, ".1.");
- else if (game.starch[i][j] == 0)
- strcpy(buf, "...");
- else if (game.state.galaxy[i][j]>=SUPERNOVA_PLACE)
+ if (game.state.galaxy[i][j].supernova)
strcpy(buf, "***");
+ else if (!game.state.galaxy[i][j].charted && game.state.galaxy[i][j].starbase)
+ strcpy(buf, ".1.");
+ else if (game.state.galaxy[i][j].charted)
+ sprintf(buf, "%d%d%d", game.state.chart[i][j].klingons, game.state.chart[i][j].starbase, game.state.chart[i][j].stars);
else
- sprintf(buf, "%03d", game.state.galaxy[i][j]);
+ strcpy(buf, "...");
for (cp = buf; cp < buf + sizeof(buf); cp++)
if (*cp == '0')
*cp = '.';
case 10:
attakreport(1);
break;
- /*
- * Note: attakreport() can in some cases produce two lines of
- * output. If that happens, and QUADSIZE is the normal 10, items
- * 11 and up will be printed past the bottom of the quadrant display.
- * Under the curses display logic they will get lost because they're
- * written outside the report window.
- */
- case 11: /* ESR */
- proutn("Bases Left %d", game.state.rembase);
- break;
}
}
int srscan(int l)
{
static char requests[][3] =
- {"","da","co","po","ls","wa","en","to","sh","kl","ti", "ba"};
+ {"","da","co","po","ls","wa","en","to","sh","kl","ti"};
int leftside=TRUE, rightside=TRUE, i, j, jj, req=0, nn=FALSE;
int goodScan=TRUE;
switch (l) {
prout(" [Using Base's sensors]");
}
else proutn(" Short-range scan\n\r");
- if (goodScan) game.starch[quadx][quady] = game.damage[DRADIO]>0.0 ? game.state.galaxy[quadx][quady]+SUPERNOVA_PLACE:1;
+ if (goodScan && !game.damage[DRADIO]) {
+ game.state.chart[quadx][quady].klingons = game.state.galaxy[quadx][quady].klingons;
+ game.state.chart[quadx][quady].starbase = game.state.galaxy[quadx][quady].starbase;
+ game.state.chart[quadx][quady].stars = game.state.galaxy[quadx][quady].stars;
+ game.state.galaxy[quadx][quady].charted = TRUE;
+ }
scan();
if (isit("chart")) nn = TRUE;
if (isit("no")) rightside = FALSE;
alive = 1;
docfac = 0.25;
for (i = 1; i <= GALSIZE; i++)
- for (j = 1; j <= GALSIZE; j++) game.state.newstuf[i][j] = game.starch[i][j] = 0;
+ for (j = 1; j <= GALSIZE; j++) {
+ game.state.galaxy[i][j].charted = 0;
+ game.state.galaxy[i][j].planets = 0;
+ game.state.galaxy[i][j].romulans = 0;
+ }
// Initialize times for extraneous events
game.future[FSNOVA] = game.state.date + expran(0.5 * intime);
game.future[FTBEAM] = game.state.date + expran(1.5 * (intime / game.state.remcom));
for (j=1; j<=GALSIZE; j++) {
int k = Rand()*9.0 + 1.0;
instar += k;
- game.state.galaxy[i][j] = k * STAR_PLACE;
+ game.state.galaxy[i][j].stars = k;
}
// Locate star bases in galaxy
for (i = 1; i <= inbase; i++) {
int contflag;
do {
do iran(GALSIZE, &ix, &iy);
- while (BASES(game.state.galaxy[ix][iy]));
+ while (game.state.galaxy[ix][iy].starbase);
contflag = FALSE;
for (j = i-1; j > 0; j--) {
/* Improved placement algorithm to spread out bases */
game.state.baseqx[i] = ix;
game.state.baseqy[i] = iy;
- game.starch[ix][iy] = CHART_UNKNOWN;
- game.state.galaxy[ix][iy] += BASE_PLACE;
+ game.state.galaxy[ix][iy].starbase = 1;
+ game.state.chart[ix][iy].starbase = 1;
}
// Position ordinary Klingon Battle Cruisers
krem = inkling - incom - game.state.nscrem;
int klump = (1.0 - r*r)*klumper;
if (klump > krem) klump = krem;
krem -= klump;
- klump *= KLINGON_PLACE;
- do iran(GALSIZE, &ix, &iy);
- while (game.state.galaxy[ix][iy] + klump >= SUPERNOVA_PLACE);
- game.state.galaxy[ix][iy] += klump;
+ do iran(GALSIZE,&ix,&iy); while (game.state.galaxy[ix][iy].supernova);
+ game.state.galaxy[ix][iy].klingons += klump;
} while (krem > 0);
// Position Klingon Commander Ships
#ifdef DEBUG
#endif
iran(GALSIZE, &ix, &iy);
}
- while ((game.state.galaxy[ix][iy] <= KLINGON_PLACE && Rand() < 0.75)||
- NOEXIT(game.state.galaxy[ix][iy]));
+ while ((!game.state.galaxy[ix][iy].klingons && Rand() < 0.75)||
+ game.state.galaxy[ix][iy].supernova||
+ game.state.galaxy[ix][iy].klingons > 8);
// check for duplicate
for (j = 1; j < i; j++)
if (game.state.cx[j]==ix && game.state.cy[j]==iy) break;
} while (j < i);
- game.state.galaxy[ix][iy] += KLINGON_PLACE;
+ game.state.galaxy[ix][iy].klingons++;
game.state.cx[i] = ix;
game.state.cy[i] = iy;
}
// Locate planets in galaxy
for (i = 0; i < inplan; i++) {
- do iran(GALSIZE, &ix, &iy);
- while (game.state.newstuf[ix][iy] > 0);
- game.state.newstuf[ix][iy] = 1;
+ do iran(GALSIZE, &ix, &iy); while (game.state.galaxy[ix][iy].planets);
+ game.state.galaxy[ix][iy].planets = 1;
game.state.plnets[i].x = ix;
game.state.plnets[i].y = iy;
game.state.plnets[i].pclass = Rand()*3.0; // Planet class M N or O
// Locate Romulans
for (i = 1; i <= game.state.nromrem; i++) {
iran(GALSIZE, &ix, &iy);
- game.state.newstuf[ix][iy] += ROMULAN_PLACE;
+ game.state.galaxy[ix][iy].romulans = 1;
}
// Locate the Super Commander
if (game.state.nscrem > 0) {
do iran(GALSIZE, &ix, &iy);
- while (game.state.galaxy[ix][iy] >= 900);
+ while (game.state.galaxy[ix][iy].supernova || game.state.galaxy[ix][iy].klingons > 8);
game.state.isx = ix;
game.state.isy = iy;
- game.state.galaxy[ix][iy] += KLINGON_PLACE;
+ game.state.galaxy[ix][iy].klingons++;
}
// Place thing (in tournament game, thingx == -1, don't want one!)
if (thingx != -1) {
{
condit = IHGREEN;
if (energy < 1000.0) condit = IHYELLOW;
- if (game.state.galaxy[quadx][quady] >= KLINGON_PLACE || game.state.newstuf[quadx][quady] >= ROMULAN_PLACE)
+ if (game.state.galaxy[quadx][quady].klingons || game.state.galaxy[quadx][quady].romulans)
condit = IHRED;
if (!alive) condit=IHDEAD;
}
void newqad(int shutup)
{
- int quadnum = game.state.galaxy[quadx][quady];
- int newnum = game.state.newstuf[quadx][quady];
int i, j, ix, iy, nplan;
iattak = 1;
}
// Clear quadrant
for (i=1; i <= QUADSIZE; i++)
- for (j=1; j <= QUADSIZE; j++) game.quad[i][j] = IHDOT;
+ for (j=1; j <= QUADSIZE; j++)
+ game.quad[i][j] = IHDOT;
// cope with supernova
- if (quadnum >= SUPERNOVA_PLACE) {
+ if (game.state.galaxy[quadx][quady].supernova)
return;
- }
- klhere = KLINGONS(quadnum);
- irhere = ROMULANS(newnum);
- nplan = newnum%10;
+ klhere = game.state.galaxy[quadx][quady].klingons;
+ irhere = game.state.galaxy[quadx][quady].romulans;
+ nplan = game.state.galaxy[quadx][quady].planets;
nenhere = klhere + irhere;
// Position Starship
game.quad[sectx][secty] = ship;
- if (quadnum >= KLINGON_PLACE) {
+ if (game.state.galaxy[quadx][quady].klingons) {
// Position ordinary Klingons
- quadnum -= KLINGON_PLACE*klhere;
for (i = 1; i <= klhere; i++) {
dropin(IHK, &ix, &iy);
game.kx[i] = ix;
game.kpower[i] = Rand()*400.0 + 450.0 + 50.0*skill;
}
// If quadrant needs a starbase, put it in
- if (quadnum >= BASE_PLACE) {
- quadnum -= BASE_PLACE;
+ if (game.state.galaxy[quadx][quady].starbase)
dropin(IHB, &basex, &basey);
- }
if (nplan) {
// If quadrant needs a planet, put it in
// Check for condition
newcnd();
// And finally the stars
- for (i = 1; i <= quadnum; i++) dropin(IHSTAR, &ix, &iy);
+ for (i = 1; i <= game.state.galaxy[quadx][quady].stars; i++)
+ dropin(IHSTAR, &ix, &iy);
// Check for RNZ
if (irhere > 0 && klhere == 0) {
// Put in a few black holes
for (i = 1; i <= 3; i++)
- if (Rand() > 0.5) dropin(IHBLANK, &ix, &iy);
+ if (Rand() > 0.5)
+ dropin(IHBLANK, &ix, &iy);
// Take out X's in corners if Tholian present
if (ithere) {
<listitem><para>
Status report now indicates if dilithium crystals are on board.
</para></listitem>
+<listitem><para>
+At Dave's prompting, restored the Space Thingy's original elusive behavior.
+</para></listitem>
</itemizedlist>
<para>Here are some good pages on the history of Star Trek games:</para>
2. Status report now indicates when dilithium crystals are on board.
- 3. Can now report starbases left in scrscan.
-
- 4. Per Dave Matuszek's remarks, Thingy state is not saved across games.
+ 3. Per Dave Matuszek's remarks, Thingy state is not saved across games.
*/
/* the input queue */
events();
if (alldone) break; // Events did us in
}
- if (game.state.galaxy[quadx][quady] == SUPERNOVA_PLACE) { // Galaxy went Nova!
+ if (game.state.galaxy[quadx][quady].supernova) { // Galaxy went Nova!
atover(0);
continue;
}
if (hitme && justin==0) {
attack(2);
if (alldone) break;
- if (game.state.galaxy[quadx][quady] == SUPERNOVA_PLACE) { // went NOVA!
+ if (game.state.galaxy[quadx][quady].supernova) { // went NOVA!
atover(0);
hitme = TRUE;
continue;
basekl, // destroyed bases
killk, // Klingons killed
killc, // commanders killed
- galaxy[GALSIZE+1][GALSIZE+1], // The Galaxy (subscript 0 not used)
cx[QUADSIZE+1],cy[QUADSIZE+1], // Commander quadrant coordinates
baseqx[BASEMAX], // Base quadrant X
baseqy[BASEMAX], // Base quadrant Y
- newstuf[GALSIZE+1][GALSIZE+1], // Extended galaxy goodies
isx, isy, // Coordinate of Super Commander
nscrem, // remaining super commanders
nromkl, // Romulans killed
double date, // stardate
remres, // remaining resources
remtime; // remaining time
+ struct {
+ int stars;
+ int planets;
+ int starbase;
+ int klingons;
+ int romulans;
+ int supernova;
+ int charted;
+ } galaxy[GALSIZE+1][GALSIZE+1]; // The Galaxy (subscript 0 not used)
+ struct {
+ int stars;
+ int starbase;
+ int klingons;
+ } chart[GALSIZE+1][GALSIZE+1]; // the starchart (subscript 0 not used)
} snapshot; // Data that is snapshot
-/*
- * This is how the integers in the galaxy array are encoded.
- * Someday these should turn into structure fields.
- */
-#define SUPERNOVA_PLACE 1000
-#define KLINGON_PLACE 100
-#define BASE_PLACE 10
-#define STAR_PLACE 1
-#define KLINGONS(n) ((n)/KLINGON_PLACE)
-#define BASES(n) (((n)%KLINGON_PLACE)/BASE_PLACE)
-#define STARS(n) ((n)%BASE_PLACE)
-#define NOEXIT(s) ((s) > 899) /* supernova or >8 Klingons */
-
-/* for newstuff */
-#define ROMULAN_PLACE 10
-#define ROMULANS(n) ((n)/ROMULAN_PLACE)
-
-/* for starch */
-#define CHART_UNKNOWN -1
-
#define SKILL_NONE 0
#define SKILL_NOVICE 1
#define SKILL_FAIR 2
char passwd[10]; // Self Destruct password
int kx[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy sector locations
int ky[(QUADSIZE+1)*(QUADSIZE+1)];
- int starch[GALSIZE+1][GALSIZE+1]; // star chart
/* members with macro definitions start here */
int inkling,
inbase,
void dock(int);
void dreprt(void);
void chart(int);
+void rechart(void);
void impuls(void);
void wait(void);
void setwrp(void);