X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=src%2Fevents.c;h=b4b61214b14cecd18efcb09c2c836c9b7c9aa153;hp=b82aff7caa9b65addeaf47cdb725b20cf5c64722;hb=2c5438d3c22fe863ad8054d214f2afdd061ad43a;hpb=9aef5f5aae5fde0ed2b462945750c7aee59b3c1e diff --git a/src/events.c b/src/events.c index b82aff7..b4b6121 100644 --- a/src/events.c +++ b/src/events.c @@ -147,7 +147,7 @@ void events(void) prout(_(" surveillance reports are coming in.")); skip(1); if (!game.iseenit) { - attakreport(false); + attackreport(false); game.iseenit = true; } rechart(); @@ -159,7 +159,7 @@ void events(void) switch (evcode) { case FSNOVA: /* Supernova */ pause_game(true); - snova(false, NULL); + supernova(false, NULL); schedule(FSNOVA, expran(0.5*game.intime)); if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova) return; @@ -270,8 +270,8 @@ void events(void) break; } i = 0; - for_starbases(j) { - for_commanders(k) + for (j = 1; j <= game.state.rembase; j++) { + for (k = 1; k <= game.state.remcom; k++) if (same(game.state.baseq[j], game.state.kcmdr[k]) && !same(game.state.baseq[j], game.quadrant) && !same(game.state.baseq[j], game.state.kscmdr)) { @@ -320,7 +320,7 @@ void events(void) if (evcode==FCDBAS) { unschedule(FCDBAS); /* find the lucky pair */ - for_commanders(i) + for (i = 1; i <= game.state.remcom; i++) if (same(game.state.kcmdr[i], game.battle)) break; if (i > game.state.remcom || game.state.rembase == 0 || @@ -358,7 +358,7 @@ void events(void) } /* Remove Starbase from galaxy */ game.state.galaxy[game.battle.x][game.battle.y].starbase = false; - for_starbases(i) + for (i = 1; i <= game.state.rembase; i++) if (same(game.state.baseq[i], game.battle)) game.state.baseq[i] = game.state.baseq[game.state.rembase]; game.state.rembase--; @@ -374,7 +374,7 @@ void events(void) schedule(FSCMOVE, 0.2777); if (!game.ientesc && !istract && game.isatb != 1 && (!game.iscate || !game.justin)) - scom(); + supercommander(); break; case FDSPROB: /* Move deep space probe */ schedule(FDSPROB, 0.01); @@ -423,7 +423,7 @@ void events(void) game.proben--; // One less to travel if (game.proben == 0 && game.isarmed && pdest->stars) { /* lets blow the sucker! */ - snova(true, &game.probec); + supernova(true, &game.probec); unschedule(FDSPROB); if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova) return; @@ -434,10 +434,10 @@ void events(void) /* try a whole bunch of times to find something suitable */ i = 100; do { - /* need a quadrant which is not the current one, - which has some stars which are inhabited and - not already under attack, which is not - supernova'ed, and which has some Klingons in it */ + // need a quadrant which is not the current one, + // which has some stars which are inhabited and + // not already under attack, which is not + // supernova'ed, and which has some Klingons in it w = randplace(GALSIZE); q = &game.state.galaxy[w.x][w.y]; } while (--i && @@ -488,10 +488,8 @@ void events(void) } break; case FREPRO: /* Klingon reproduces */ - /* - * If we ever switch to a real event queue, we'll need to - * explicitly retrieve and restore the x and y. - */ + // If we ever switch to a real event queue, we'll need to + // explicitly retrieve and restore the x and y. ev = schedule(FREPRO, expran(1.0 * game.intime)); /* see if current distress call still active */ q = &game.state.galaxy[ev->quadrant.x][ev->quadrant.y]; @@ -635,7 +633,7 @@ void nova(coord nov) if (Rand() < 0.05) { /* Wow! We've supernova'ed */ - snova(false, &nov); + supernova(false, &nov); return; } @@ -674,7 +672,7 @@ void nova(coord nov) case IHSTAR: /* Affect another star */ if (Rand() < 0.05) { /* This star supernovas */ - snova(false, &scratch); + supernova(false, &scratch); return; } top2++; @@ -691,7 +689,7 @@ void nova(coord nov) game.state.nplankl++; crmena(true, IHP, sector, scratch); prout(_(" destroyed.")); - DESTROY(&game.state.planets[game.iplnet]); + game.state.planets[game.iplnet].pclass = destroyed; game.iplnet = 0; invalidate(game.plnet); if (game.landed) { @@ -702,7 +700,7 @@ void nova(coord nov) break; case IHB: /* Destroy base */ game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase = false; - for_starbases(i) + for (i = 1; i <= game.state.rembase; i++) if (same(game.state.baseq[i], game.quadrant)) break; game.state.baseq[i] = game.state.baseq[game.state.rembase]; @@ -746,7 +744,7 @@ void nova(coord nov) case IHC: /* Damage/destroy big enemies */ case IHS: case IHR: - for_local_enemies(ll) + for (ll = 1; ll <= game.nenhere; ll++) if (same(game.ks[ll], scratch)) break; game.kpower[ll] -= 800.0; /* If firepower is lost, die */ @@ -814,7 +812,7 @@ void nova(coord nov) } -void snova(bool induced, coord *w) +void supernova(bool induced, coord *w) /* star goes supernova */ { int num = 0, nrmdead, npdead, kldead; @@ -827,15 +825,14 @@ void snova(bool induced, coord *w) /* Scheduled supernova -- select star */ /* logic changed here so that we won't favor quadrants in top left of universe */ - for_quadrants(nq.x) { - for_quadrants(nq.y) { + for (nq.x = 1; nq.x <= GALSIZE; nq.x++) + for (nq.y = 1; nq.y <= GALSIZE; nq.y++) stars += game.state.galaxy[nq.x][nq.y].stars; - } - } - if (stars == 0) return; /* nothing to supernova exists */ + if (stars == 0) + return; /* nothing to supernova exists */ num = Rand()*stars + 1; - for_quadrants(nq.x) { - for_quadrants(nq.y) { + for (nq.x = 1; nq.x <= GALSIZE; nq.x++) { + for (nq.y = 1; nq.y <= GALSIZE; nq.y++) { num -= game.state.galaxy[nq.x][nq.y].stars; if (num <= 0) break; @@ -863,8 +860,8 @@ void snova(bool induced, coord *w) coord ns; /* we are in the quadrant! */ num = Rand()* game.state.galaxy[nq.x][nq.y].stars + 1; - for_sectors(ns.x) { - for_sectors(ns.y) { + for (ns.x = 1; ns.x <= QUADSIZE; ns.x++) { + for (ns.y = 1; ns.y <= QUADSIZE; ns.y++) { if (game.quad[ns.x][ns.y]==IHSTAR) { num--; if (num==0) @@ -922,7 +919,7 @@ void snova(bool induced, coord *w) int loop; for (loop = 0; loop < game.inplan; loop++) if (same(game.state.planets[loop].w, nq)) { - DESTROY(&game.state.planets[loop]); + game.state.planets[loop].pclass = destroyed; } } /* Destroy any base in supernovaed quadrant */