Clean up a warning.
[super-star-trek.git] / sst.c
diff --git a/sst.c b/sst.c
index 3d394c67b4da2097edf5f027d119589227e3c5e3..e95fa2a8528ee15d1fad305d31c103381886f71b 100644 (file)
--- a/sst.c
+++ b/sst.c
@@ -15,107 +15,147 @@ 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.
+   were in the original non-"super" version of UT FORTRAN Star Trek.
 
    Tholians weren't in the original. Dave is dubious about their merits.
+   (They are now controlled by OPTION_THOLIAN and turned off if the game
+   type is "plain".)
 
    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".
+   with this idea. (It's now controlled by OPTION_PLANETS and turned 
+   off if the game type is "plain".)
+
+   Dave says the bit about the Galileo getting turned into a
+   McDonald's is "consistant with our original vision".  (This has been
+   left permanently enabled, as it can only happen if OPTION_PLANETS
+   is on.)
 
    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.
+   when attacked, but it didn't in the original.  (Whether the Thingy
+   can fire back is now controlled by OPTION_THINGY and turned off if the
+   game type is "plain" or "almy".  The no-save behavior has been restored.)
 
    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
-   "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".
-
-   When I got a later version of Super Star Trek that I was converting
-   from, I added the emexit command.
-
-   That later version also mentions srscan and lrscan working when
-   docked (using the starbase's scanners), so I made some changes here
-   to do this (and indicating that fact to the player), and then realized
-   the base would have a subspace radio as well -- doing a Chart when docked
-   updates the star chart, and all radio reports will be heard. The Dock
-   command will also give a report if a base is under attack.
-
-   Movecom no longer reports movement if sensors are damaged so you wouldn't
-   otherwise know it.
-
-   Also added:
-
-   1. Better base positioning at startup
-
-   2. Deathray improvement (but keeping original failure alternatives)
-
-   3. Tholian Web.
-
-   4. Enemies can ram the Enterprise. Regular Klingons and Romulans can
-      move in Expert and Emeritus games. This code could use improvement.
-
-   5. The deep space probe looks interesting! DECUS version
-
-   6. Perhaps cloaking to be added later? BSD version
+   In early 1997, I got the bright idea to look for references to
+   "Super Star Trek" on the World Wide Web. There weren't many hits,
+   but there was one that came up with 1979 Fortran sources! This
+   version had a few additional features that mine didn't have,
+   however mine had some feature it didn't have. So I merged its
+   features that I liked. I also took a peek at the DECUS version (a
+   port, less sources, to the PDP-10), and some other variations.
+
+   1, Compared to the original UT 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".
+      (Both "freeze" and "save" work in SST2K.)
+
+   2. The experimental deathray originally had only a 5% chance of
+      success, but could be used repeatedly. I guess after a couple
+      years of use, it was less "experimental" because the 1979
+      version had a 70% success rate. However it was prone to breaking
+      after use. I upgraded the deathray, but kept the original set of
+      failure modes (great humor!).  (Now controlled by OPTION_DEATHRAY
+      and turned off if game type is "plain".)
+
+   3. The 1979 version also mentions srscan and lrscan working when
+      docked (using the starbase's scanners), so I made some changes here
+      to do this (and indicating that fact to the player), and then realized
+      the base would have a subspace radio as well -- doing a Chart when docked
+      updates the star chart, and all radio reports will be heard. The Dock
+      command will also give a report if a base is under attack.
+
+   4. Tholian Web from the 1979 version.  (Now controlled by
+      OPTION_THOLIAN and turned off if game type is "plain".)
+
+   5. Enemies can ram the Enterprise. (Now controlled by OPTION_RAMMING
+      and turned off if game type is "plain".)
+
+   6. Regular Klingons and Romulans can move in Expert and Emeritus games. 
+      This code could use improvement. (Now controlled by OPTION_MVBADDY
+      and turned off if game type is "plain".)
+
+   7. The deep-space probe feature from the DECUS version.  (Now controlled
+      by OPTION_PROBE and turned off if game type is "plain").
+
+   8. 'emexit' command from the 1979 version.
+
+   9. Bugfix: Klingon commander movements are no longer reported if long-range 
+      sensors are damaged.
+
+   10. Bugfix: Better base positioning at startup (more spread out).
+      That made sense to add because most people abort games with 
+      bad base placement.
+
+   In June 2002, I fixed two known bugs and a documentation typo.
+   In June 2004 I fixed a number of bugs involving: 1) parsing invalid
+   numbers, 2) manual phasers when SR scan is damaged and commander is
+   present, 3) time warping into the future, 4) hang when moving
+   klingons in crowded quadrants.  (These fixes are in SST2K.)
 
 Here are Stas Sergeev's changes:
 
    1. The Space Thingy can be shoved, if you ram it, and can fire back if 
-      fired upon.
-
-   2. The Tholian can be hit with phasers
+      fired upon. (Now controlled by OPTION_THINGY and turned off if game 
+      type is "plain" or "almy".)
 
-   3. When you are docked, base covers you with an almost invincible shields 
-      (a commander can still ram you, or a Romulan can destroy the base,
+   2. When you are docked, base covers you with an almost invincible shield. 
+      (A commander can still ram you, or a Romulan can destroy the base,
       or a SCom can even succeed with direct attack IIRC, but this rarely 
-      happens).
+      happens.)  (Now controlled by OPTION_BASE and turned off if game 
+      type is "plain" or "almy".)
+
+   3. Ramming a black hole is no longer instant death.  There is a
+      chance you might get timewarped instead. (Now controlled by 
+      OPTION_BLKHOLE and turned off if game type is "plain" or "almy".)
+
+   4. The Tholian can be hit with phasers.
 
-   4. SCom can't escape from you if no more enemies remain (without this, 
-      chasing SCom can take an eternity).
+   5. SCom can't escape from you if no more enemies remain 
+      (without this, 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)
+   6. 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.
 
-   6. Secret password is now autogenerated.
+   7. Secret password is now autogenerated.
 
-   7. "Plaque" is adjusted for A4 paper :-)
+   8. "Plaque" is adjusted for A4 paper :-)
 
-   8. Phasers now tells you how much energy needed, but only if the computer 
-       is alive.
+   9. Phasers now tells you how much energy needed, but only if the computer 
+      is alive.
 
-   9. Planets are auto-scanned when you enter the quadrant.
+   10. Planets are auto-scanned when you enter the quadrant.
 
-   10. Mining or using crystals in presense of enemy now yields an attack.
+   11. Mining or using crystals in presense of enemy now yields an attack.
        There are other minor adjustments to what yields an attack
        and what does not.
 
-   11. Ramming a black hole is no longer instant death.  There is a
-       chance you might get timewarped instead.
-
    12. "freeze" command reverts to "save", most people will understand this
-        better anyway.
+       better anyway. (SST2K recognizes both.)
 
-   13. Screen-oriented interface, with sensor scans always up.
+   13. Screen-oriented interface, with sensor scans always up.  (SST2K
+       supports both screen-oriented and TTY modes.)
 
 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. Per Dave Matuszek's remarks, Thingy state is not saved across games.
-   */
+   3. Per Dave Matuszek's remarks, Thingy state is never saved across games.
+
+   4. Added game option selection so you can play a close (but not bug-for-
+      bug identical) approximation of older versions.
+*/
 
 /* the input queue */
 static char line[128], *linep = line;
@@ -196,7 +236,7 @@ commands[] = {
 #define MAYDAY 32
        {"MAYDAY",      MAYDAY,         0},
        //{"SOS",               MAYDAY,         0},
-       {"CALL",        MAYDAY,         0},
+       //{"CALL",      MAYDAY,         0},
 #define QUIT   33
        {"QUIT",        QUIT,           0},
 #define HELP   34
@@ -386,14 +426,14 @@ 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
@@ -430,13 +470,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
@@ -451,21 +491,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
@@ -482,7 +522,7 @@ 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) { // Galaxy went Nova!
                atover(0);
@@ -508,9 +548,9 @@ int main(int argc, char **argv)
 {
     int i, option;
 
-    game.options = OPTION_ALL &~ OPTION_IOMODES;
+    game.options = OPTION_ALL &~ (OPTION_IOMODES | OPTION_SHOWME | OPTION_PLAIN | OPTION_ALMY);
     if (getenv("TERM"))
-       game.options |= OPTION_CURSES;
+       game.options |= OPTION_CURSES | OPTION_SHOWME;
     else
        game.options |= OPTION_TTY;
 
@@ -537,7 +577,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();
@@ -751,7 +791,6 @@ void debugme(void)
        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) {
@@ -770,7 +809,6 @@ void debugme(void)
            key = scan();
            if (key == IHALPHA &&  isit("y")) {
                game.damage[i] = 10.0;
-               if (i == DRADIO) stdamtim = game.state.date;
            }
        }
     }
@@ -779,7 +817,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;
@@ -799,5 +837,10 @@ void debugme(void)
        }
        chew();
     }
+    proutn("Induce supernova here? ");
+    if (ja() != 0) {
+       game.state.galaxy[quadx][quady].supernova = TRUE;
+       atover(1);
+    }
 }
 #endif