X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=events.c;h=194901df53c3f9d2e69e1b0d9edca42ab070d6ed;hb=cf91699c89b88f76dcf63c60624635184e8cb7eb;hp=1fad7134a47b2b0ae5acbdf5e1059003826e05b3;hpb=48763357ef69f0b711fc332b13e2170ab914d881;p=super-star-trek.git diff --git a/events.c b/events.c index 1fad713..194901d 100644 --- a/events.c +++ b/events.c @@ -2,10 +2,8 @@ #include void events(void) { - - int ictbeam=0, ipage=0, istract=0, line, i, j, k, l, ixhold, iyhold; - double fintim = game.state.date + Time, datemin, xtime, repair, yank; - + 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; #ifdef DEBUG if (idebug) prout("EVENTS"); @@ -25,7 +23,7 @@ void events(void) { if (alldone) return; datemin = fintim; for (l=1; l<=NEVENTS; l++) - if (game.future[l] <= datemin) { + if (game.future[l] < datemin) { line = l; datemin = game.future[l]; } @@ -51,7 +49,7 @@ void events(void) { repair = xtime; if (condit == IHDOCKED) repair /= docfac; /* Don't fix Deathray here */ - for (l=1; l<=ndevice; l++) + for (l=1; l<=NDEVICES; l++) 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 */ @@ -64,7 +62,7 @@ void events(void) { for (j=1; j <= 8; j++) if (game.starch[i][j] > 999) game.starch[i][j] = 1; if (iseenit==0) { - attakreport(); + attakreport(0); iseenit = 1; } skip(1); @@ -75,7 +73,7 @@ void events(void) { Time -= xtime; switch (line) { case FSNOVA: /* Supernova */ - if (ipage==0) pause(1); + if (ipage==0) pause_game(1); ipage=1; snova(0,0); game.future[FSNOVA] = game.state.date + expran(0.5*intime); @@ -114,7 +112,7 @@ void events(void) { } /* tractor beaming cases merge here */ yank = sqrt(yank); - if (ipage==0) pause(1); + if (ipage==0) pause_game(1); ipage=1; Time = (10.0/(7.5*7.5))*yank; /* 7.5 is yank rate (warp 7.5) */ ictbeam = 1; @@ -152,11 +150,10 @@ void events(void) { } iran10(§x, §y); crmshp(); - proutn(" is pulled to"); - cramlc(1, quadx, quady); + proutn(" is pulled to "); + proutn(cramlc(quadrant, quadx, quady)); proutn(", "); - cramlc(2, sectx, secty); - skip(1); + prout(cramlc(sector, sectx, secty)); if (resting) { prout("(Remainder of rest/repair period cancellegame.state.)"); resting = 0; @@ -171,6 +168,7 @@ void events(void) { newqad(0); /* Adjust finish time to time of tractor beaming */ fintim = game.state.date+Time; + attack(0); if (game.state.remcom <= 0) game.future[FTBEAM] = 1e30; else game.future[FTBEAM] = game.state.date+Time+expran(1.5*intime/game.state.remcom); break; @@ -213,15 +211,14 @@ void events(void) { if (game.damage[DRADIO] != 0.0 && condit != IHDOCKED) break; /* No warning :-( */ iseenit = 1; - if (ipage==0) pause(1); + if (ipage==0) pause_game(1); ipage = 1; skip(1); - proutn("Lt. Uhura- \"Captain, the starbase in"); - cramlc(1, batx, baty); - skip(1); - prout(" reports that it is under atttack and that it can"); - proutn(" hold out only until stardate "); - cramf(game.future[FCDBAS],1,1); + proutn("Lt. Uhura- \"Captain, the starbase in "); + prout(cramlc(quadrant, batx, baty)); + prout(" reports that it is under attack and that it can"); + proutn(" hold out only until stardate %d", + (int)game.future[FCDBAS]); prout(".\""); if (resting) { skip(1); @@ -269,12 +266,12 @@ void events(void) { else if (game.state.rembase != 1 && (game.damage[DRADIO] <= 0.0 || condit == IHDOCKED)) { /* Get word via subspace radio */ - if (ipage==0) pause(1); + if (ipage==0) pause_game(1); ipage = 1; skip(1); prout("Lt. Uhura- \"Captain, Starfleet Command reports that"); - proutn(" the starbase in"); - cramlc(1, batx, baty); + proutn(" the starbase in "); + proutn(cramlc(quadrant, batx, baty)); prout(" has been destroyed by"); if (isatb==2) prout("the Klingon Super-Commander"); else prout("a Klingon Commander"); @@ -316,7 +313,7 @@ void events(void) { game.state.galaxy[probecx][probecy] == 1000) { // Left galaxy or ran into supernova if (game.damage[DRADIO]==0.0 || condit == IHDOCKED) { - if (ipage==0) pause(1); + if (ipage==0) pause_game(1); ipage = 1; skip(1); proutn("Lt. Uhura- \"The deep space probe "); @@ -330,11 +327,11 @@ void events(void) { break; } if (game.damage[DRADIO]==0.0 || condit == IHDOCKED) { - if (ipage==0) pause(1); + if (ipage==0) pause_game(1); ipage = 1; skip(1); proutn("Lt. Uhura- \"The deep space probe is now in "); - cramlc(1, probecx, probecy); + proutn(cramlc(quadrant, probecx, probecy)); prout(".\""); } } @@ -375,7 +372,7 @@ void wait(void) { origTime = delay = aaitem; if (delay <= 0.0) return; if (delay >= game.state.remtime || nenhere != 0) { - prout("Are you sure? "); + proutn("Are you sure? "); if (ja() == 0) return; } @@ -385,8 +382,7 @@ void wait(void) { do { if (delay <= 0) resting = 0; if (resting == 0) { - cramf(game.state.remtime, 0, 2); - prout(" stardates left."); + prout("%d stardates left.", (int)game.state.remtime); return; } temp = Time = delay; @@ -397,7 +393,6 @@ void wait(void) { Time = temp; } if (Time < delay) attack(0); - if (nenhere==0) movetho(); if (alldone) return; events(); ididit = 1; @@ -415,7 +410,7 @@ void wait(void) { void nova(int ix, int iy) { static double course[] = {0.0, 10.5, 12.0, 1.5, 9.0, 0.0, 3.0, 7.5, 6.0, 4.5}; - int bot, top, top2, burst, hits[11][3], kount, icx, icy, mm, nn, j; + int bot, top, top2, hits[11][3], kount, icx, icy, mm, nn, j; int iquad, iquad1, i, ll, newcx, newcy, ii, jj; if (Rand() < 0.05) { /* Wow! We've supernova'ed */ @@ -473,7 +468,7 @@ void nova(int ix, int iy) { game.state.nplankl++; crmena(1, IHP, 2, ii, jj); prout(" destroyed."); - game.state.plnets[iplnet] = nulplanet; + DESTROY(&game.state.plnets[iplnet]); iplnet = plnetx = plnety = 0; if (landed == 1) { finish(FPNOVA); @@ -554,8 +549,8 @@ void nova(int ix, int iy) { skip(1); break; } - proutn(", buffeted to"); - cramlc(2, newcx, newcy); + proutn(", buffeted to "); + proutn(cramlc(sector, newcx, newcy)); game.quad[ii][jj] = IHDOT; game.quad[newcx][newcy] = iquad; game.kx[ll] = newcx; @@ -583,7 +578,7 @@ void nova(int ix, int iy) { skip(1); prout("Force of nova displaces starship."); iattak=2; /* Eliminates recursion problem */ - move(); + imove(); Time = 10.0*dist/16.0; return; } @@ -637,12 +632,9 @@ void snova(int insx, int insy) { /* it isn't here, or we just entered (treat as inroute) */ if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED) { skip(1); - proutn("Message from Starfleet Command Stardate "); - cramf(game.state.date, 0, 1); - skip(1); - proutn(" Supernova in"); - cramlc(1, nqx, nqy); - prout("; caution advised."); + prout("Message from Starfleet Command Stardate %.2f", game.state.date); + prout(" Supernova in %s; caution advised.", + cramlc(quadrant, nqx, nqy)); } } else { @@ -668,9 +660,7 @@ void snova(int insx, int insy) { skip(1); prouts("***RED ALERT! RED ALERT!"); skip(1); - proutn("***Incipient supernova detected at"); - cramlc(2, nsx, nsy); - skip(1); + prout("***Incipient supernova detected at ", cramlc(sector, nsx, nsy)); nqx = quadx; nqy = quady; if (square(nsx-sectx) + square(nsy-secty) <= 2.1) { @@ -715,9 +705,9 @@ void snova(int insx, int insy) { npdead = num - nrmdead*10; if (npdead) { int l; - for (l = 1; l <= inplan; l++) + for (l = 0; l < inplan; l++) if (game.state.plnets[l].x == nqx && game.state.plnets[l].y == nqy) { - game.state.plnets[l] = nulplanet; + DESTROY(&game.state.plnets[l]); } } /* Destroy any base in supernovaed quadrant */ @@ -753,9 +743,8 @@ void snova(int insx, int insy) { if (game.state.remkl==0 && (nqx != quadx || nqy != quady)) { skip(2); if (insx == 0) prout("Lucky you!"); - proutn("A supernova in"); - cramlc(1, nqx, nqy); - prout(" has just destroyed the last Klingons."); + proutn("A supernova in %s has just destroyed the last Klingons.", + cramlc(quadrant, nqx, nqy)); finish(FWON); return; }