More magic-number hunting -- BASEMAX this time.
[super-star-trek.git] / setup.c
diff --git a/setup.c b/setup.c
index 58f45f175b8d12593d592c00f8f0a3ead10edf4a..572d92284d088680fb9527e5fdad451a5aa53d12 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -1,6 +1,5 @@
 #include <time.h>
 #include <sys/stat.h>
-#include "conio.h"
 #include "sst.h"
 
 #ifdef __linux__
@@ -15,7 +14,7 @@ void prelim(void) {
        skip(2);
        prout("-SUPER- STAR TREK");
        skip(1);
-#ifndef __HISTORICAL__
+#ifdef __HISTORICAL__
        prout("Latest update-21 Sept 78");
        skip(1);
 #endif /* __HISTORICAL__ */
@@ -155,11 +154,11 @@ void abandn(void) {
                for (;;) {
                        /* position next to base by trial and error */
                        game.quad[sectx][secty] = IHDOT;
-                       for (l = 1; l <= 10; l++) {
+                       for (l = 1; l <= QUADSIZE; l++) {
                                sectx = 3.0*Rand() - 1.0 + basex;
                                secty = 3.0*Rand() - 1.0 + basey;
-                               if (sectx >= 1 && sectx <= 10 &&
-                                       secty >= 1 && secty <= 10 &&
+                               if (sectx >= 1 && sectx <= QUADSIZE &&
+                                       secty >= 1 && secty <= QUADSIZE &&
                                        game.quad[sectx][secty] == IHDOT) break;
                        }
                        if (l < 11) break; /* found a spot */
@@ -223,8 +222,8 @@ void setup(int needprompt) {
        landed = -1;
        alive = 1;
        docfac = 0.25;
-       for (i = 1; i <= 8; i++)
-               for (j = 1; j <= 8; j++) game.state.newstuf[i][j] = game.starch[i][j] = 0;
+       for (i = 1; i <= GALSIZE; i++)
+               for (j = 1; j <= GALSIZE; j++) game.state.newstuf[i][j] = game.starch[i][j] = 0;
        // Initialize times for extraneous events
        game.future[FSNOVA] = game.state.date + expran(0.5 * intime);
        game.future[FTBEAM] = game.state.date + expran(1.5 * (intime / game.state.remcom));
@@ -238,8 +237,8 @@ void setup(int needprompt) {
        stdamtim = 1e30;
        // Put stars in the galaxy
        instar = 0;
-       for (i=1; i<=8; i++)
-               for (j=1; j<=8; j++) {
+       for (i=1; i<=GALSIZE; i++)
+               for (j=1; j<=GALSIZE; j++) {
                        int k = Rand()*9.0 + 1.0;
                        instar += k;
                        game.state.galaxy[i][j] = k;
@@ -254,7 +253,7 @@ 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*(6-inbase) && Rand() < 0.75) {
+                               if (distq < 6.0*(BASEMAX-inbase) && Rand() < 0.75) {
                                        contflag = TRUE;
 #ifdef DEBUG
                                        proutn("DEBUG: Abandoning base #%d at %d-%d\n", i, ix, iy);
@@ -262,7 +261,7 @@ void setup(int needprompt) {
                                        break;
                                }
 #ifdef DEBUG
-                               else if (distq < 6.0 * (6-inbase)) {
+                               else if (distq < 6.0 * (BASEMAX-inbase)) {
                                        proutn("DEBUG: saving base #%d, close to #%d\n", i, j);
                                }
 #endif
@@ -385,9 +384,7 @@ void setup(int needprompt) {
        skip(2);
        prout("Good Luck!");
        if (game.state.nscrem) prout("  YOU'LL NEED IT.");
-#ifdef SERGEEV
-        getche();
-#endif /* SERGEEV */
+        waitfor();
        newqad(0);
         if (nenhere-iqhere-ithere) shldup=1.0;
        if (neutz) attack(0);   // bad luck to start in a Romulan Neutral Zone
@@ -420,19 +417,13 @@ int choose(int needprompt) {
                        srand((unsigned int)(int)aaitem);
                        break;
                }
-               if (isit("frozen") || isit("frozen")) {
+               if (isit("saved") || isit("frozen")) {
                         if (thaw()) continue;
                        chew();
-#ifndef SERGEEV
                        if (*game.passwd==0) continue;
-                       randomize();
-                       Rand(); Rand(); Rand(); Rand();
-#endif
                        if (!alldone) thawed = 1; // No plaque if not finished
                         report();
-#ifdef SERGEEV
-                        getche();
-#endif /* SERGEEV */
+                        waitfor();
                        return TRUE;
                }
                 if (isit("regular")) break;
@@ -463,18 +454,7 @@ int choose(int needprompt) {
                        else if (skill == 0) proutn("Are you a Novice, Fair, Good, Expert, or Emeritus player? ");
                }
        }
-#ifndef SERGEEV
-       while (TRUE) {
-               scan();
-               strcpy(game.passwd, citem);
-               chew();
-               if (*game.passwd != 0) break;
-               proutn("Please type in a secret password-");
-       }
-#else
-        for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));
-        game.passwd[3]=0;
-#endif /* SERGEEV */
+       setpassword();
 #ifdef DEBUG
        if (strcmp(game.passwd, "debug")==0) idebug = 1;
 #endif
@@ -545,8 +525,8 @@ void newqad(int shutup) {
                ientesc = 1;
        }
        // Clear quadrant
-       for (i=1; i <= 10; i++)
-               for (j=1; j <= 10; j++) game.quad[i][j] = IHDOT;
+       for (i=1; i <= QUADSIZE; i++)
+               for (j=1; j <= QUADSIZE; j++) game.quad[i][j] = IHDOT;
        // cope with supernova
        if (quadnum > 999) {
                return;
@@ -670,9 +650,9 @@ void newqad(int shutup) {
                 game.kpower[nenhere] = Rand()*400.0 +100.0 +25.0*skill;
                 /* Reserve unocupied corners */
                 if (game.quad[1][1]==IHDOT) game.quad[1][1] = 'X';
-                if (game.quad[1][10]==IHDOT) game.quad[1][10] = 'X';
-                if (game.quad[10][1]==IHDOT) game.quad[10][1] = 'X';
-                if (game.quad[10][10]==IHDOT) game.quad[10][10] = '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';
         }
         sortkl();
 
@@ -683,9 +663,9 @@ void newqad(int shutup) {
        // Take out X's in corners if Tholian present
        if (ithere) {
                if (game.quad[1][1]=='X') game.quad[1][1] = IHDOT;
-               if (game.quad[1][10]=='X') game.quad[1][10] = IHDOT;
-               if (game.quad[10][1]=='X') game.quad[10][1] = IHDOT;
-               if (game.quad[10][10]=='X') game.quad[10][10] = 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;
        }               
 }