X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=setup.c;h=40e610bcc87bbc25915699275a2cebe7908db54f;hp=f4a037333a4a922334f1eeacb981cd52c7d85628;hb=0ddb264313c09bbefa443bb9d67b7bb95fcf58c8;hpb=e536fe754b3a9be00dcaee8f6ec50ea2d8c7a184 diff --git a/setup.c b/setup.c index f4a0373..40e610b 100644 --- a/setup.c +++ b/setup.c @@ -156,11 +156,10 @@ void abandn(void) for (;;) { /* position next to base by trial and error */ game.quad[sectx][secty] = IHDOT; - for (l = 1; l <= QUADSIZE; l++) { + for_sectors(l) { sectx = 3.0*Rand() - 1.0 + basex; secty = 3.0*Rand() - 1.0 + basey; - if (sectx >= 1 && sectx <= QUADSIZE && - secty >= 1 && secty <= QUADSIZE && + if (VALID_SECTOR(sectx, secty) && game.quad[sectx][secty] == IHDOT) break; } if (l < QUADSIZE+1) break; /* found a spot */ @@ -227,8 +226,8 @@ void setup(int needprompt) landed = -1; alive = 1; docfac = 0.25; - for (i = 1; i <= GALSIZE; i++) - for (j = 1; j <= GALSIZE; j++) { + for_quadrants(i) + for_quadrants(j) { game.state.galaxy[i][j].charted = 0; game.state.galaxy[i][j].planets = 0; game.state.galaxy[i][j].romulans = 0; @@ -238,16 +237,16 @@ void setup(int needprompt) game.future[FTBEAM] = game.state.date + expran(1.5 * (intime / game.state.remcom)); game.future[FSNAP] = game.state.date + 1.0 + Rand(); // Force an early snapshot game.future[FBATTAK] = game.state.date + expran(0.3*intime); - game.future[FCDBAS] = 1e30; - game.future[FSCMOVE] = game.state.nscrem ? game.state.date+0.2777 : 1e30; - game.future[FSCDBAS] = 1e30; - game.future[FDSPROB] = 1e30; - // Starchart is functional - stdamtim = 1e30; + game.future[FCDBAS] = FOREVER; + game.future[FSCMOVE] = game.state.nscrem ? game.state.date+0.2777 : FOREVER; + game.future[FSCDBAS] = FOREVER; + game.future[FDSPROB] = FOREVER; + // Starchart is functional but we've never seen it + lastchart = FOREVER; // Put stars in the galaxy instar = 0; - for (i=1; i<=GALSIZE; i++) - for (j=1; j<=GALSIZE; j++) { + for_quadrants(i) + for_quadrants(j) { int k = Rand()*9.0 + 1.0; instar += k; game.state.galaxy[i][j].stars = k; @@ -262,16 +261,16 @@ void setup(int needprompt) for (j = i-1; j > 0; j--) { /* Improved placement algorithm to spread out bases */ double distq = square(ix-game.state.baseqx[j]) + square(iy-game.state.baseqy[j]); - if (distq < 6.0*(BASEMAX-inbase) && Rand() < 0.75) { + if (distq < 6.0*(BASEMAX+1-inbase) && Rand() < 0.75) { contflag = TRUE; #ifdef DEBUG - proutn("DEBUG: Abandoning base #%d at %d-%d\n", i, ix, iy); + prout("DEBUG: Abandoning base #%d at %d-%d", i, ix, iy); #endif break; } #ifdef DEBUG - else if (distq < 6.0 * (BASEMAX-inbase)) { - proutn("DEBUG: saving base #%d, close to #%d\n", i, j); + else if (distq < 6.0 * (BASEMAX+1-inbase)) { + prout("DEBUG: saving base #%d, close to #%d", i, j); } #endif } @@ -291,7 +290,9 @@ void setup(int needprompt) int klump = (1.0 - r*r)*klumper; if (klump > krem) klump = krem; krem -= klump; - do iran(GALSIZE,&ix,&iy); while (game.state.galaxy[ix][iy].supernova); + do iran(GALSIZE,&ix,&iy); + while (game.state.galaxy[ix][iy].supernova || + game.state.galaxy[ix][iy].klingons + klump > 9); game.state.galaxy[ix][iy].klingons += klump; } while (krem > 0); // Position Klingon Commander Ships @@ -470,7 +471,7 @@ int choose(int needprompt) // Use parameters to generate initial values of things damfac = 0.5 * skill; - game.state.rembase = 3.0*Rand()+2.0; + game.state.rembase = 2.0 + Rand()*(BASEMAX-2.0); inbase = game.state.rembase; if (game.options & OPTION_PLANETS) inplan = (PLNETMAX/2) + (PLNETMAX/2+1)*Rand(); @@ -478,11 +479,11 @@ int choose(int needprompt) game.state.nscrem = (skill > SKILL_FAIR ? 1 : 0); game.state.remtime = 7.0 * length; intime = game.state.remtime; - game.state.remkl = 2.0*intime*((skill+1 - 2*Rand())*skill*0.1+.15); - inkling = game.state.remkl; + inkling = 2.0*intime*((skill+1 - 2*Rand())*skill*0.1+.15); incom = skill + 0.0625*inkling*Rand(); game.state.remcom= min(10, incom); incom = game.state.remcom; + game.state.remkl = inkling + incom + game.state.nscrem; game.state.remres = (inkling+4*incom)*intime; inresor = game.state.remres; if (inkling > 50) { @@ -536,8 +537,8 @@ void newqad(int shutup) ientesc = 1; } // Clear quadrant - for (i=1; i <= QUADSIZE; i++) - for (j=1; j <= QUADSIZE; j++) + for_sectors(i) + for_sectors(j) game.quad[i][j] = IHDOT; // cope with supernova if (game.state.galaxy[quadx][quady].supernova) @@ -560,7 +561,7 @@ void newqad(int shutup) game.kpower[i] = Rand()*150.0 +300.0 +25.0*skill; } // If we need a commander, promote a Klingon - for (i = 1; i <= game.state.remcom ; i++) + for_commanders(i) if (game.state.cx[i]==quadx && game.state.cy[i]==quady) break; if (i <= game.state.remcom) {