More elimination of FORTAN-style if statements.
[super-star-trek.git] / src / setup.c
index aef792a38cfa9f07b5581940e367929327c61c52..852212b0739732cc5d6a0ca0a017d7d52bb18123 100644 (file)
@@ -192,7 +192,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;
@@ -296,7 +297,8 @@ void setup(bool needprompt)
     do {
        double r = Rand();
        int klump = (1.0 - r*r)*klumper;
-       if (klump > krem) klump = krem;
+       if (klump > krem)
+           klump = krem;
        krem -= klump;
        do w = randplace(GALSIZE);
        while (game.state.galaxy[w.x][w.y].supernova ||
@@ -334,17 +336,17 @@ void setup(bool needprompt)
     for (i = 0; i < game.inplan; i++) {
        do w = randplace(GALSIZE); 
        while (game.state.galaxy[w.x][w.y].planet != NOPLANET);
-       game.state.plnets[i].w = w;
+       game.state.planets[i].w = w;
        if (i < NINHAB) {
-           game.state.plnets[i].pclass = M;    // All inhabited planets are class M
-           game.state.plnets[i].crystals = absent;
-           game.state.plnets[i].known = known;
-           game.state.plnets[i].inhabited = i;
+           game.state.planets[i].pclass = M;   // All inhabited planets are class M
+           game.state.planets[i].crystals = absent;
+           game.state.planets[i].known = known;
+           game.state.planets[i].inhabited = i;
        } else {
-           game.state.plnets[i].pclass = Rand()*3.0; // Planet class M N or O
-           game.state.plnets[i].crystals = Rand()*1.5;         // 1 in 3 chance of crystals
-           game.state.plnets[i].known = unknown;
-           game.state.plnets[i].inhabited = UNINHABITED;
+           game.state.planets[i].pclass = Rand()*3.0; // Planet class M N or O
+           game.state.planets[i].crystals = Rand()*1.5;                // 1 in 3 chance of crystals
+           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;
@@ -389,7 +391,8 @@ void setup(bool needprompt)
        skip(1);
        prout(_("%d Klingons."), INKLINGTOT);
        prout(_("An unknown number of Romulans."));
-       if (game.state.nscrem) prout(_("And one (GULP) Super-Commander."));
+       if (game.state.nscrem)
+           prout(_("And one (GULP) Super-Commander."));
        prout(_("%d stardates."),(int)game.intime);
        proutn(_("%d starbases in "), game.inbase);
     }
@@ -404,11 +407,14 @@ void setup(bool needprompt)
     proutn(cramlc(sector, game.sector));
     skip(2);
     prout(_("Good Luck!"));
-    if (game.state.nscrem) prout(_("  YOU'LL NEED IT."));
+    if (game.state.nscrem)
+       prout(_("  YOU'LL NEED IT."));
     waitfor();
     newqad(false);
-    if (game.nenhere-iqhere-game.ithere) game.shldup = true;
-    if (game.neutz) attack(false);     // bad luck to start in a Romulan Neutral Zone
+    if (game.nenhere-iqhere-game.ithere)
+       game.shldup = true;
+    if (game.neutz)    // bad luck to start in a Romulan Neutral Zone
+       attack(false);
 }
 
 bool choose(bool needprompt) 
@@ -422,7 +428,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-"));
@@ -437,15 +444,19 @@ bool choose(bool needprompt)
            break;
        }
        if (isit("saved") || isit("frozen")) {
-           if (thaw()) continue;
+           if (thaw())
+               continue;
            chew();
-           if (*game.passwd==0) continue;
-           if (!game.alldone) game.thawed = 1; // No plaque if not finished
+           if (*game.passwd==0)
+               continue;
+           if (!game.alldone)
+               game.thawed = true; // No plaque if not finished
            report();
            waitfor();
            return true;
        }
-       if (isit("regular")) break;
+       if (isit("regular"))
+           break;
        proutn(_("What is \""));
        proutn(citem);
        prout("\"?");
@@ -453,14 +464,22 @@ bool choose(bool needprompt)
     }
     while (game.length==0 || game.skill==SKILL_NONE) {
        if (scan() == IHALPHA) {
-           if (isit("short")) game.length = 1;
-           else if (isit("medium")) game.length = 2;
-           else if (isit("long")) game.length = 4;
-           else if (isit("novice")) game.skill = SKILL_NOVICE;
-           else if (isit("fair")) game.skill = SKILL_FAIR;
-           else if (isit("good")) game.skill = SKILL_GOOD;
-           else if (isit("expert")) game.skill = SKILL_EXPERT;
-           else if (isit("emeritus")) game.skill = SKILL_EMERITUS;
+           if (isit("short"))
+               game.length = 1;
+           else if (isit("medium"))
+               game.length = 2;
+           else if (isit("long"))
+               game.length = 4;
+           else if (isit("novice"))
+               game.skill = SKILL_NOVICE;
+           else if (isit("fair"))
+               game.skill = SKILL_FAIR;
+           else if (isit("good"))
+               game.skill = SKILL_GOOD;
+           else if (isit("expert"))
+               game.skill = SKILL_EXPERT;
+           else if (isit("emeritus"))
+               game.skill = SKILL_EMERITUS;
            else {
                proutn(_("What is \""));
                proutn(citem);
@@ -469,8 +488,10 @@ bool choose(bool needprompt)
        }
        else {
            chew();
-           if (game.length==0) proutn(_("Would you like a Short, Medium, or Long game? "));
-           else if (game.skill == SKILL_NONE) proutn(_("Are you a Novice, Fair, Good, Expert, or Emeritus player? "));
+           if (game.length==0)
+               proutn(_("Would you like a Short, Medium, or Long game? "));
+           else if (game.skill == SKILL_NONE)
+               proutn(_("Are you a Novice, Fair, Good, Expert, or Emeritus player? "));
        }
     }
     // Choose game options -- added by ESR for SST2K
@@ -538,10 +559,12 @@ void newcnd(void)
 /* update our alert status */
 {
     game.condition = green;
-    if (game.energy < 1000.0) game.condition = yellow;
+    if (game.energy < 1000.0)
+       game.condition = yellow;
     if (game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons || game.state.galaxy[game.quadrant.x][game.quadrant.y].romulans)
        game.condition = red;
-    if (!game.alive) game.condition=dead;
+    if (!game.alive)
+       game.condition=dead;
 }
 
 coord newkling(int i)
@@ -636,7 +659,7 @@ void newqad(bool shutup)
     // If quadrant needs a planet, put it in
     if (q->planet != NOPLANET) {
        game.iplnet = q->planet;
-       if (game.state.plnets[q->planet].inhabited == UNINHABITED)
+       if (game.state.planets[q->planet].inhabited == UNINHABITED)
            game.plnet = dropin(IHP);
        else
            game.plnet = dropin(IHW);
@@ -648,7 +671,7 @@ void newqad(bool shutup)
        dropin(IHSTAR);
 
     // Check for RNZ
-    if (game.irhere > 0 && game.klhere == 0 && (q->planet == NOPLANET || game.state.plnets[q->planet].inhabited == UNINHABITED)) {
+    if (game.irhere > 0 && game.klhere == 0 && (q->planet == NOPLANET || game.state.planets[q->planet].inhabited == UNINHABITED)) {
        game.neutz = true;
        if (!damaged(DRADIO)) {
            skip(1);
@@ -697,10 +720,14 @@ void newqad(bool shutup)
                distance(game.sector, game.tholian);
            game.kpower[game.nenhere] = Rand()*400.0 +100.0 +25.0*game.skill;
            /* Reserve unocupied corners */
-           if (game.quad[1][1]==IHDOT) game.quad[1][1] = 'X';
-           if (game.quad[1][QUADSIZE]==IHDOT) game.quad[1][QUADSIZE] = 'X';
-           if (game.quad[QUADSIZE][1]==IHDOT) game.quad[QUADSIZE][1] = 'X';
-           if (game.quad[QUADSIZE][QUADSIZE]==IHDOT) game.quad[QUADSIZE][QUADSIZE] = 'X';
+           if (game.quad[1][1]==IHDOT)
+               game.quad[1][1] = 'X';
+           if (game.quad[1][QUADSIZE]==IHDOT)
+               game.quad[1][QUADSIZE] = 'X';
+           if (game.quad[QUADSIZE][1]==IHDOT)
+               game.quad[QUADSIZE][1] = 'X';
+           if (game.quad[QUADSIZE][QUADSIZE]==IHDOT)
+               game.quad[QUADSIZE][QUADSIZE] = 'X';
        }
     }
 
@@ -713,10 +740,14 @@ void newqad(bool shutup)
 
     // Take out X's in corners if Tholian present
     if (game.ithere) {
-       if (game.quad[1][1]=='X') game.quad[1][1] = IHDOT;
-       if (game.quad[1][QUADSIZE]=='X') game.quad[1][QUADSIZE] = IHDOT;
-       if (game.quad[QUADSIZE][1]=='X') game.quad[QUADSIZE][1] = IHDOT;
-       if (game.quad[QUADSIZE][QUADSIZE]=='X') game.quad[QUADSIZE][QUADSIZE] = IHDOT;
+       if (game.quad[1][1]=='X')
+           game.quad[1][1] = IHDOT;
+       if (game.quad[1][QUADSIZE]=='X')
+           game.quad[1][QUADSIZE] = IHDOT;
+       if (game.quad[QUADSIZE][1]=='X')
+           game.quad[QUADSIZE][1] = IHDOT;
+       if (game.quad[QUADSIZE][QUADSIZE]=='X')
+           game.quad[QUADSIZE][QUADSIZE] = IHDOT;
     }          
 }
 
@@ -729,7 +760,8 @@ void sortkl(void)
 
     // The author liked bubble sort. So we will use it. :-(
 
-    if (game.nenhere-iqhere-game.ithere < 2) return;
+    if (game.nenhere-iqhere-game.ithere < 2)
+       return;
 
     do {
        sw = false;
@@ -764,11 +796,13 @@ void setpassword(void)
            proutn(_("Please type in a secret password- "));
            scan();
            strcpy(game.passwd, citem);
-           if (*game.passwd != 0) break;
+           if (*game.passwd != 0)
+               break;
        }
     } else {
        int i;
-        for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));
+        for(i=0;i<3;i++)
+           game.passwd[i]=(char)(97+(int)(Rand()*25));
         game.passwd[3]=0;
     }
 }