Yet more history.
[super-star-trek.git] / sst.c
diff --git a/sst.c b/sst.c
index c97204b0c1ccdec6a25cdec2ef8918a74c62fbab..e27f7fb125a0d2348235f5893cd16e33e88ae708 100644 (file)
--- a/sst.c
+++ b/sst.c
 
 Dave Matuszek says:
 
-  SRSCAN, MOVE, PHASERS, CALL, STATUS, IMPULSE, PHOTONS, ABANDON,
-  LRSCAN, WARP, SHIELDS, DESTRUCT, CHART, REST, DOCK, QUIT, and DAMAGE
-  were in the original non-"super" version.
+   SRSCAN, MOVE, PHASERS, CALL, STATUS, IMPULSE, PHOTONS, ABANDON,
+   LRSCAN, WARP, SHIELDS, DESTRUCT, CHART, REST, DOCK, QUIT, and DAMAGE
+   were in the original non-"super" version.
 
-  Tholians weren't in the original. Dave is dubious about their merits.
-  There weren't even planets.  He says the bit about the Galileo getting
-  turned into a McDonald's is "consistant with our original vision".
+   Tholians weren't in the original. Dave is dubious about their merits.
 
-  Dilithium crystals weren't in the original.  Dave is OK with this idea.
+   Planets and dilithium crystals weren't in the original.  Dave is OK
+   with this idea. He says the bit about the Galileo getting
+   turned into a McDonald's is "consistant with our original vision".
 
-  Dave also says the Space Thingy should not be preserved across saved games,
-  so you can't prove to others that you've seen it.  He says it shouldn't
-  fire back, either.  It should so nothing except scream and disappear
-  when hit by photon torpedos.  It's OK that it moves when rammed, but it
-  didn't in the original.
+   Dave also says the Space Thingy should not be preserved across saved
+   games, so you can't prove to others that you've seen it.  He says it
+   shouldn't fire back, either.  It should do nothing except scream and
+   disappear when hit by photon torpedos.  It's OK that it may move
+   when attacked, but it didn't in the original.
 
-  The Faerie Queen was in the original.
+   The Faerie Queen, black holes, and time warping were in the original.
 
 Here are Tom Almy's changes:
 
- Compared to original version, I've changed the "help" command to
  Compared to original version, I've changed the "help" command to
    "call" and the "terminate" command to "quit" to better match
    user expectations. The DECUS version apparently made those changes
    as well as changing "freeze" to "save". However I like "freeze".
@@ -82,7 +82,7 @@ Here are Stas Sergeev's changes:
       chasing SCom can take an eternity).
 
    5. Probe target you enter is now the destination quadrant. Before I don't 
-      remember what it was, but it was something I had difficulty using)
+      remember what it was, but it was something I had difficulty using.
 
    6. Secret password is now autogenerated.
 
@@ -107,16 +107,15 @@ Here are Stas Sergeev's changes:
 
 Eric Raymond's changes:
 
- Mainly, I translated this C code out of FORTRAN into C -- created #defines
-   for a lot of magic numbers and refactored the heck out of it.
+Mainly, I translated this C code out of FORTRAN into C -- created #defines
+for a lot of magic numbers and refactored the heck out of it.
 
    1. "sos" and "call" becomes "mayday", "freeze" and "save" are both good.
 
    2. Status report now indicates when dilithium crystals are on board.
 
-   3. Can now report starbases left in scrscan.
-
-   */
+   3. Per Dave Matuszek's remarks, Thingy state is not saved across games.
+*/
 
 /* the input queue */
 static char line[128], *linep = line;
@@ -196,8 +195,8 @@ commands[] = {
        {"DEBUG",       DEBUGCMD,       0},
 #define MAYDAY 32
        {"MAYDAY",      MAYDAY,         0},
-       {"SOS",         MAYDAY,         0},
-       {"CALL",        MAYDAY,         0},
+       //{"SOS",               MAYDAY,         0},
+       //{"CALL",      MAYDAY,         0},
 #define QUIT   33
        {"QUIT",        QUIT,           0},
 #define HELP   34
@@ -205,12 +204,13 @@ commands[] = {
 };
 
 #define NUMCOMMANDS    sizeof(commands)/sizeof(commands[0])
+#define ACCEPT(i)      (!commands[i].option || (commands[i].option & game.options))
 
 static void listCommands(void) {
     int i, k = 0;
     proutn("LEGAL COMMANDS ARE:");
     for (i = 0; i < NUMCOMMANDS; i++) {
-       if (commands[i].option && !(commands[i].option & game.options))
+       if (!ACCEPT(i))
            continue;
        if (k % 5 == 0)
            skip(1);
@@ -238,7 +238,7 @@ static void helpme(void)
        setwnd(message_window);
        if (key == IHEOL) return;
        for (i = 0; i < NUMCOMMANDS; i++) {
-           if (strcasecmp(commands[i].name, citem)==0) {
+           if (ACCEPT(i) && strcasecmp(commands[i].name, citem)==0) {
                i = commands[i].value;
                break;
            }
@@ -303,7 +303,7 @@ void enqueue(char *s)
 
 static void makemoves(void) 
 {
-    int i, v, hitme;
+    int i, v = 0, hitme;
     clrscr();
     setwnd(message_window);
     while (TRUE) { /* command loop */
@@ -326,13 +326,14 @@ static void makemoves(void)
            setwnd(message_window);
            clrscr();
            for (i=0; i < ABANDON; i++)
-               if (isit(commands[i].name)) {
+               if (ACCEPT(i) && isit(commands[i].name)) {
                    v = commands[i].value;
                    break;
                }
-           if (i < ABANDON) break;
+           if (i < ABANDON && (!commands[i].option || (commands[i].option & game.options))) 
+               break;
            for (; i < NUMCOMMANDS; i++)
-               if (strcasecmp(commands[i].name, citem) == 0) {
+               if (ACCEPT(i) && strcasecmp(commands[i].name, citem) == 0) {
                    v = commands[i].value;
                    break;
                }
@@ -385,18 +386,18 @@ static void makemoves(void)
        case IMPULSE:                   // impulse
            impuls();
            break;
-       case REST:              // rest
+       case REST:                      // rest
            wait();
            if (ididit) hitme = TRUE;
            break;
-       case WARP:              // warp
+       case WARP:                      // warp
            setwrp();
            break;
-       case SCORE:                // score
+       case SCORE:                     // score
            score();
            break;
        case SENSORS:                   // sensors
-           sensor(TRUE);
+           sensor();
            break;
        case ORBIT:                     // orbit
            orbit();
@@ -429,13 +430,13 @@ static void makemoves(void)
        case COMMANDS:
            listCommands();
            break;
-       case EMEXIT:            // Emergency exit
-           clrscr();   // Hide screen
-           freeze(TRUE);       // forced save
-           exit(1);            // And quick exit
+       case EMEXIT:                    // Emergency exit
+           clrscr();                   // Hide screen
+           freeze(TRUE);               // forced save
+           exit(1);                    // And quick exit
            break;
        case PROBE:
-           probe();            // Launch probe
+           probe();                    // Launch probe
            if (ididit) hitme = TRUE;
            break;
        case ABANDON:                   // Abandon Ship
@@ -450,21 +451,21 @@ static void makemoves(void)
            if (skill > SKILL_GOOD)
                prout("WARNING--Saved games produce no plaques!");
            break;
-       case DEATHRAY:          // Try a desparation measure
+       case DEATHRAY:                  // Try a desparation measure
            deathray();
            if (ididit) hitme = TRUE;
            break;
-       case DEBUGCMD:          // What do we want for debug???
+       case DEBUGCMD:                  // What do we want for debug???
 #ifdef DEBUG
            debugme();
 #endif
            break;
-       case MAYDAY:            // Call for help
+       case MAYDAY:                    // Call for help
            help();
            if (ididit) hitme = TRUE;
            break;
        case QUIT:
-           alldone = 1;        // quit the game
+           alldone = 1;                // quit the game
 #ifdef DEBUG
            if (idebug) score();
 #endif
@@ -481,16 +482,16 @@ static void makemoves(void)
 #endif
            if (Time != 0.0) {
                events();
-               if (alldone) break;             // Events did us in
+               if (alldone) break;     // Events did us in
            }
-           if (game.state.galaxy[quadx][quady] == SUPERNOVA_PLACE) { // Galaxy went Nova!
+           if (game.state.galaxy[quadx][quady].supernova) { // Galaxy went Nova!
                atover(0);
                continue;
            }
            if (hitme && justin==0) {
                attack(2);
                if (alldone) break;
-               if (game.state.galaxy[quadx][quady] == SUPERNOVA_PLACE) {       // went NOVA! 
+               if (game.state.galaxy[quadx][quady].supernova) {        // went NOVA! 
                    atover(0);
                    hitme = TRUE;
                    continue;
@@ -507,9 +508,9 @@ int main(int argc, char **argv)
 {
     int i, option;
 
-    game.options = OPTION_ALL &~ OPTION_IOMODES;
+    game.options = OPTION_ALL &~ (OPTION_IOMODES | OPTION_SHOWME);
     if (getenv("TERM"))
-       game.options |= OPTION_CURSES;
+       game.options |= OPTION_CURSES | OPTION_SHOWME;
     else
        game.options |= OPTION_TTY;
 
@@ -536,7 +537,7 @@ int main(int argc, char **argv)
     while (TRUE) { /* Play a game */
        setwnd(fullscreen_window);
 #ifdef DEBUG
-       prout("INITIAL OPTIONS: %0lx\n", game.options);
+       prout("INITIAL OPTIONS: %0lx", game.options);
 #endif /* DEBUG */
        clrscr();
        prelim();
@@ -747,10 +748,9 @@ void debugme(void)
     proutn("Reset damage? ");
     if (ja() != 0) {
        int i;
-       for (i=0; i <= NDEVICES; i++) 
+       for (i=0; i < NDEVICES; i++) 
            if (game.damage[i] > 0.0) 
                game.damage[i] = 0.0;
-       stdamtim = 1e30;
     }
     proutn("Toggle idebug? ");
     if (ja() != 0) {
@@ -761,7 +761,7 @@ void debugme(void)
     proutn("Cause selective damage? ");
     if (ja() != 0) {
        int i, key;
-       for (i=1; i <= NDEVICES; i++) {
+       for (i=0; i < NDEVICES; i++) {
            proutn("Kill ");
            proutn(device[i]);
            proutn("? ");
@@ -769,7 +769,6 @@ void debugme(void)
            key = scan();
            if (key == IHALPHA &&  isit("y")) {
                game.damage[i] = 10.0;
-               if (i == DRADIO) stdamtim = game.state.date;
            }
        }
     }
@@ -778,7 +777,7 @@ void debugme(void)
        int i;
        for (i = 1; i < NEVENTS; i++) {
            int key;
-           if (game.future[i] == 1e30) continue;
+           if (game.future[i] == FOREVER) continue;
            switch (i) {
            case FSNOVA:  proutn("Supernova       "); break;
            case FTBEAM:  proutn("T Beam          "); break;
@@ -798,5 +797,10 @@ void debugme(void)
        }
        chew();
     }
+    proutn("Induce supernova here? ");
+    if (ja() != 0) {
+       game.state.galaxy[quadx][quady].supernova = TRUE;
+       atover(1);
+    }
 }
 #endif