#include <math.h>\r
\r
void events(void) {\r
-\r
- int ictbeam=0, ipage=0, istract=0, line, i, j, k, l, ixhold, iyhold;\r
- double fintim = game.state.date + Time, datemin, xtime, repair, yank;\r
- \r
+ int ictbeam=0, ipage=0, istract=0, line, i=0, j, k, l, ixhold=0, iyhold=0;\r
+ double fintim = game.state.date + Time, datemin, xtime, repair, yank=0;\r
\r
#ifdef DEBUG\r
if (idebug) prout("EVENTS");\r
if (alldone) return;\r
datemin = fintim;\r
for (l=1; l<=NEVENTS; l++)\r
- if (game.future[l] <= datemin) {\r
+ if (game.future[l] < datemin) {\r
line = l;\r
datemin = game.future[l];\r
}\r
repair = xtime;\r
if (condit == IHDOCKED) repair /= docfac;\r
/* Don't fix Deathray here */\r
- for (l=1; l<=ndevice; l++)\r
+ for (l=1; l<=NDEVICES; l++)\r
if (game.damage[l] > 0.0 && l != DDRAY)\r
game.damage[l] -= (game.damage[l]-repair > 0.0 ? repair : game.damage[l]);\r
/* If radio repaired, update star chart and attack reports */\r
for (j=1; j <= 8; j++)\r
if (game.starch[i][j] > 999) game.starch[i][j] = 1;\r
if (iseenit==0) {\r
- attakreport();\r
+ attakreport(0);\r
iseenit = 1;\r
}\r
skip(1);\r
Time -= xtime;\r
switch (line) {\r
case FSNOVA: /* Supernova */\r
- if (ipage==0) pause(1);\r
+ if (ipage==0) pause_game(1);\r
ipage=1;\r
snova(0,0);\r
game.future[FSNOVA] = game.state.date + expran(0.5*intime);\r
}\r
/* tractor beaming cases merge here */\r
yank = sqrt(yank);\r
- if (ipage==0) pause(1);\r
+ if (ipage==0) pause_game(1);\r
ipage=1;\r
Time = (10.0/(7.5*7.5))*yank; /* 7.5 is yank rate (warp 7.5) */\r
ictbeam = 1;\r
}\r
iran10(§x, §y);\r
crmshp();\r
- proutn(" is pulled to");\r
- cramlc(1, quadx, quady);\r
+ proutn(" is pulled to ");\r
+ proutn(cramlc(quadrant, quadx, quady));\r
proutn(", ");\r
- cramlc(2, sectx, secty);\r
- skip(1);\r
+ prout(cramlc(sector, sectx, secty));\r
if (resting) {\r
prout("(Remainder of rest/repair period cancellegame.state.)");\r
resting = 0;\r
newqad(0);\r
/* Adjust finish time to time of tractor beaming */\r
fintim = game.state.date+Time;\r
+ attack(0);\r
if (game.state.remcom <= 0) game.future[FTBEAM] = 1e30;\r
else game.future[FTBEAM] = game.state.date+Time+expran(1.5*intime/game.state.remcom);\r
break;\r
if (game.damage[DRADIO] != 0.0 &&\r
condit != IHDOCKED) break; /* No warning :-( */\r
iseenit = 1;\r
- if (ipage==0) pause(1);\r
+ if (ipage==0) pause_game(1);\r
ipage = 1;\r
skip(1);\r
- proutn("Lt. Uhura- \"Captain, the starbase in");\r
- cramlc(1, batx, baty);\r
- skip(1);\r
- prout(" reports that it is under atttack and that it can");\r
- proutn(" hold out only until stardate ");\r
- cramf(game.future[FCDBAS],1,1);\r
+ proutn("Lt. Uhura- \"Captain, the starbase in ");\r
+ prout(cramlc(quadrant, batx, baty));\r
+ prout(" reports that it is under attack and that it can");\r
+ proutn(" hold out only until stardate %d",\r
+ (int)game.future[FCDBAS]);\r
prout(".\"");\r
if (resting) {\r
skip(1);\r
else if (game.state.rembase != 1 &&\r
(game.damage[DRADIO] <= 0.0 || condit == IHDOCKED)) {\r
/* Get word via subspace radio */\r
- if (ipage==0) pause(1);\r
+ if (ipage==0) pause_game(1);\r
ipage = 1;\r
skip(1);\r
prout("Lt. Uhura- \"Captain, Starfleet Command reports that");\r
- proutn(" the starbase in");\r
- cramlc(1, batx, baty);\r
+ proutn(" the starbase in ");\r
+ proutn(cramlc(quadrant, batx, baty));\r
prout(" has been destroyed by");\r
if (isatb==2) prout("the Klingon Super-Commander");\r
else prout("a Klingon Commander");\r
game.state.galaxy[probecx][probecy] == 1000) {\r
// Left galaxy or ran into supernova\r
if (game.damage[DRADIO]==0.0 || condit == IHDOCKED) {\r
- if (ipage==0) pause(1);\r
+ if (ipage==0) pause_game(1);\r
ipage = 1;\r
skip(1);\r
proutn("Lt. Uhura- \"The deep space probe ");\r
break;\r
}\r
if (game.damage[DRADIO]==0.0 || condit == IHDOCKED) {\r
- if (ipage==0) pause(1);\r
+ if (ipage==0) pause_game(1);\r
ipage = 1;\r
skip(1);\r
proutn("Lt. Uhura- \"The deep space probe is now in ");\r
- cramlc(1, probecx, probecy);\r
+ proutn(cramlc(quadrant, probecx, probecy));\r
prout(".\"");\r
}\r
}\r
origTime = delay = aaitem;\r
if (delay <= 0.0) return;\r
if (delay >= game.state.remtime || nenhere != 0) {\r
- prout("Are you sure? ");\r
+ proutn("Are you sure? ");\r
if (ja() == 0) return;\r
}\r
\r
do {\r
if (delay <= 0) resting = 0;\r
if (resting == 0) {\r
- cramf(game.state.remtime, 0, 2);\r
- prout(" stardates left.");\r
+ prout("%d stardates left.", (int)game.state.remtime);\r
return;\r
}\r
temp = Time = delay;\r
Time = temp;\r
}\r
if (Time < delay) attack(0);\r
- if (nenhere==0) movetho();\r
if (alldone) return;\r
events();\r
ididit = 1;\r
void nova(int ix, int iy) {\r
static double course[] =\r
{0.0, 10.5, 12.0, 1.5, 9.0, 0.0, 3.0, 7.5, 6.0, 4.5};\r
- int bot, top, top2, burst, hits[11][3], kount, icx, icy, mm, nn, j;\r
+ int bot, top, top2, hits[11][3], kount, icx, icy, mm, nn, j;\r
int iquad, iquad1, i, ll, newcx, newcy, ii, jj;\r
if (Rand() < 0.05) {\r
/* Wow! We've supernova'ed */\r
game.state.nplankl++;\r
crmena(1, IHP, 2, ii, jj);\r
prout(" destroyed.");\r
- game.state.plnets[iplnet] = nulplanet;\r
+ DESTROY(&game.state.plnets[iplnet]);\r
iplnet = plnetx = plnety = 0;\r
if (landed == 1) {\r
finish(FPNOVA);\r
skip(1);\r
break;\r
}\r
- proutn(", buffeted to");\r
- cramlc(2, newcx, newcy);\r
+ proutn(", buffeted to ");\r
+ proutn(cramlc(sector, newcx, newcy));\r
game.quad[ii][jj] = IHDOT;\r
game.quad[newcx][newcy] = iquad;\r
game.kx[ll] = newcx;\r
skip(1);\r
prout("Force of nova displaces starship.");\r
iattak=2; /* Eliminates recursion problem */\r
- move();\r
+ imove();\r
Time = 10.0*dist/16.0;\r
return;\r
}\r
/* it isn't here, or we just entered (treat as inroute) */\r
if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
skip(1);\r
- proutn("Message from Starfleet Command Stardate ");\r
- cramf(game.state.date, 0, 1);\r
- skip(1);\r
- proutn(" Supernova in");\r
- cramlc(1, nqx, nqy);\r
- prout("; caution advised.");\r
+ prout("Message from Starfleet Command Stardate %.2f", game.state.date);\r
+ prout(" Supernova in %s; caution advised.",\r
+ cramlc(quadrant, nqx, nqy));\r
}\r
}\r
else {\r
skip(1);\r
prouts("***RED ALERT! RED ALERT!");\r
skip(1);\r
- proutn("***Incipient supernova detected at");\r
- cramlc(2, nsx, nsy);\r
- skip(1);\r
+ prout("***Incipient supernova detected at ", cramlc(sector, nsx, nsy));\r
nqx = quadx;\r
nqy = quady;\r
if (square(nsx-sectx) + square(nsy-secty) <= 2.1) {\r
npdead = num - nrmdead*10;\r
if (npdead) {\r
int l;\r
- for (l = 1; l <= inplan; l++)\r
+ for (l = 0; l < inplan; l++)\r
if (game.state.plnets[l].x == nqx && game.state.plnets[l].y == nqy) {\r
- game.state.plnets[l] = nulplanet;\r
+ DESTROY(&game.state.plnets[l]);\r
}\r
}\r
/* Destroy any base in supernovaed quadrant */\r
if (game.state.remkl==0 && (nqx != quadx || nqy != quady)) {\r
skip(2);\r
if (insx == 0) prout("Lucky you!");\r
- proutn("A supernova in");\r
- cramlc(1, nqx, nqy);\r
- prout(" has just destroyed the last Klingons.");\r
+ proutn("A supernova in %s has just destroyed the last Klingons.",\r
+ cramlc(quadrant, nqx, nqy));\r
finish(FWON);\r
return;\r
}\r