Use /tmp for logs, as /usr/tmp is not available under Ubuntu.
[super-star-trek.git] / src / setup.c
index 1948b8a90305e452acd075035e80d20a4428f8cf..efd70473264e899205ab14fbcdb4de3cb2b6984c 100644 (file)
@@ -104,7 +104,6 @@ bool thaw(void)
         * Some planets marked Class G and P here will be displayed as class M \
         * because of the way planets are generated. This is a known bug. \
         */ \
-       "ERROR", \
        /* Federation Worlds */ \
        _("Andoria (Fesoan)"),  /* several episodes */ \
        _("Tellar Prime (Miracht)"),    /* TOS: "Journey to Babel" */ \
@@ -192,7 +191,8 @@ void setup(bool needprompt)
     setup_names();
 
     //  Decide how many of everything
-    if (choose(needprompt)) return; // frozen game
+    if (choose(needprompt))
+       return; // frozen game
     // Prepare the Enterprise
     game.alldone = game.gamewon = false;
     game.ship = IHE;
@@ -222,9 +222,9 @@ void setup(bool needprompt)
     game.landed = false;
     game.alive = true;
     game.docfac = 0.25;
-    for_quadrants(i)
-       for_quadrants(j) {
-       struct quadrant *quad = &game.state.galaxy[i][j];
+    for (i = 1; i <= GALSIZE; i++)
+       for (j = 1; j <= GALSIZE; j++) {
+           struct quadrant *quad = &game.state.galaxy[i][j];
            quad->charted = 0;
            quad->planet = NOPLANET;
            quad->romulans = 0;
@@ -255,8 +255,8 @@ void setup(bool needprompt)
     game.lastchart = FOREVER;
     // Put stars in the galaxy
     game.instar = 0;
-    for_quadrants(i)
-       for_quadrants(j) {
+    for (i = 1; i <= GALSIZE; i++)
+       for (j = 1; j <= GALSIZE; j++) {
            int k = Rand()*9.0 + 1.0;
            game.instar += k;
            game.state.galaxy[i][j].stars = k;
@@ -336,7 +336,7 @@ void setup(bool needprompt)
        do w = randplace(GALSIZE); 
        while (game.state.galaxy[w.x][w.y].planet != NOPLANET);
        game.state.planets[i].w = w;
-       if (i < NINHAB) {
+       if ((game.options & OPTION_WORLDS) && i < NINHAB) {
            game.state.planets[i].pclass = M;   // All inhabited planets are class M
            game.state.planets[i].crystals = absent;
            game.state.planets[i].known = known;
@@ -347,8 +347,7 @@ void setup(bool needprompt)
            game.state.planets[i].known = unknown;
            game.state.planets[i].inhabited = UNINHABITED;
        }
-       if ((game.options & OPTION_WORLDS) || i >= NINHAB)
-           game.state.galaxy[w.x][w.y].planet = i;
+       game.state.galaxy[w.x][w.y].planet = i;
     }
     // Locate Romulans
     for (i = 1; i <= game.state.nromrem; i++) {
@@ -378,7 +377,7 @@ void setup(bool needprompt)
        prout(_("a deadly Klingon invasion force. As captain of the United"));
        prout(_("Starship U.S.S. Enterprise, it is your mission to seek out"));
        prout(_("and destroy this invasion force of %d battle cruisers."),
-             INKLINGTOT);
+             (game.inkling + game.incom + game.inscom));
        prout(_("You have an initial allotment of %d stardates to complete"), (int)game.intime);
        prout(_("your mission.  As you proceed you may be given more time."));
        skip(1);
@@ -388,7 +387,7 @@ void setup(bool needprompt)
     else {
        prout(_("Stardate %d."), (int)game.state.date);
        skip(1);
-       prout(_("%d Klingons."), INKLINGTOT);
+       prout(_("%d Klingons."), game.inkling + game.incom + game.inscom);
        prout(_("An unknown number of Romulans."));
        if (game.state.nscrem)
            prout(_("And one (GULP) Super-Commander."));
@@ -427,7 +426,8 @@ bool choose(bool needprompt)
        if (needprompt) /* Can start with command line options */
            proutn(_("Would you like a regular, tournament, or saved game? "));
        scan();
-       if (strlen(citem)==0) continue; // Try again
+       if (strlen(citem)==0) // Try again
+           continue;
        if (isit("tournament")) {
            while (scan() == IHEOL) {
                proutn(_("Type in tournament number-"));
@@ -525,8 +525,11 @@ bool choose(bool needprompt)
     game.damfac = 0.5 * game.skill;
     game.state.rembase = 2.0 + Rand()*(BASEMAX-2.0);
     game.inbase = game.state.rembase;
+    game.inplan = 0;
     if (game.options & OPTION_PLANETS)
-       game.inplan = NINHAB + (MAXUNINHAB/2) + (MAXUNINHAB/2+1)*Rand();
+       game.inplan += (MAXUNINHAB/2) + (MAXUNINHAB/2+1)*Rand();
+    if (game.options & OPTION_WORLDS)
+       game.inplan += NINHAB;
     game.state.nromrem = game.inrom = (2.0+Rand())*game.skill;
     game.state.nscrem = game.inscom = (game.skill > SKILL_FAIR ? 1 : 0);
     game.state.remtime = 7.0 * game.length;
@@ -605,8 +608,8 @@ void newqad(bool shutup)
        game.ientesc = true;
     }
     // Clear quadrant
-    for_sectors(i)
-       for_sectors(j) 
+    for (i = 1; i <= QUADSIZE; i++)
+       for (j = 1; j <= QUADSIZE; j++)
            game.quad[i][j] = IHDOT;
     q = &game.state.galaxy[game.quadrant.x][game.quadrant.y];
     // cope with supernova
@@ -625,7 +628,7 @@ void newqad(bool shutup)
        for (i = 1; i <= game.klhere; i++)
            w = newkling(i);
        // If we need a commander, promote a Klingon
-       for_commanders(i)
+       for (i = 1; i <= game.state.remcom; i++)
            if (same(game.state.kcmdr[i], game.quadrant))
                break;
                        
@@ -669,7 +672,7 @@ void newqad(bool shutup)
        dropin(IHSTAR);
 
     // Check for RNZ
-    if (game.irhere > 0 && game.klhere == 0 && (q->planet == NOPLANET || game.state.planets[q->planet].inhabited == UNINHABITED)) {
+    if (game.irhere > 0 && game.klhere == 0) {
        game.neutz = true;
        if (!damaged(DRADIO)) {
            skip(1);
@@ -729,7 +732,7 @@ void newqad(bool shutup)
        }
     }
 
-    sortkl();
+    sortklings();
 
     // Put in a few black holes
     for (i = 1; i <= 3; i++)
@@ -749,7 +752,7 @@ void newqad(bool shutup)
     }          
 }
 
-void sortkl(void) 
+void sortklings(void) 
 /* sort Klingons by distance from us */
 {
     double t;