More BSD features.
[super-star-trek.git] / src / sst.h
index c4a7a99e32b8eef6de34bd8538fc3e464628fc28..8651afd849224e987eff13a79403326a6b2a5c45 100644 (file)
--- a/src/sst.h
+++ b/src/sst.h
@@ -20,8 +20,6 @@
 #define min(x, y)      ((x)<(y)?(x):(y))
 #define max(x, y)      ((x)>(y)?(x):(y))
 
-// #define DEBUG
-
 #define PHASEFAC (2.0)
 #define GALSIZE        (8)
 #define NINHAB (GALSIZE * GALSIZE / 2)
@@ -60,6 +58,8 @@ typedef struct {
 
 typedef struct {
     int snap,          // snapshot taken
+       crew,           // crew complement
+#define FULLCREW       428     /* BSD Trek was 387, that's wrong */
        remkl,                  // remaining klingons
        remcom,                 // remaining commanders
        nscrem,                 // remaining super commanders
@@ -67,25 +67,25 @@ typedef struct {
        starkl,                 // destroyed stars
        basekl,                 // destroyed bases
        nromrem,                // Romulans remaining
-       nplankl;                // destroyed planets
-       planet plnets[PLNETMAX];  // Planet information
-       double date,            // stardate
-           remres,             // remaining resources
-           remtime;            // remaining time
+       nplankl,                // destroyed uninhabited planets
+       nworldkl;               // destroyed inhabited planets
+    planet plnets[PLNETMAX];  // Planet information
+    double date,               // stardate
+       remres,         // remaining resources
+       remtime;                // remaining time
     coord baseq[BASEMAX+1];    // Base quadrant coordinates
     coord kcmdr[QUADSIZE+1];   // Commander quadrant coordinates
     coord kscmdr;              // Supercommander quadrant coordinates
     struct quadrant {
        int stars;
-       planet *planet;
+       int planet;
+#define NOPLANET       -1
        bool starbase;
        int klingons;
        int romulans;
        bool supernova;
        bool charted;
-#ifdef EXPERIMENTAL
        enum {secure, distressed, enslaved} status;
-#endif /* EXPERIMENTAL */
     } galaxy[GALSIZE+1][GALSIZE+1];    // The Galaxy (subscript 0 not used)
     struct page {
        int stars;
@@ -94,6 +94,9 @@ typedef struct {
     } chart[GALSIZE+1][GALSIZE+1];     // the starchart (subscript 0 not used)
 } snapshot;                            // Data that is snapshot
 
+#define MAXKLGAME      127
+#define MAXKLQUAD      9
+
 #define NKILLK (game.inkling - game.state.remkl)
 #define NKILLC (game.incom - game.state.remcom)
 #define NKILLSC (game.inscom - game.state.nscrem)
@@ -145,6 +148,8 @@ typedef struct {
 #define DDSP    14  // Added deep space probe
 #define NDEVICES (15)  // Number of devices
 
+#define damaged(dev)   game.damage[dev] != 0.0
+
 #define FOREVER        1e30
 
 /* Define future events */
@@ -158,28 +163,26 @@ typedef struct {
 #define FSCMOVE 6   // Supercommander moves (might attack base)
 #define FSCDBAS 7   // Supercommander destroys base
 #define FDSPROB 8   // Move deep space probe
-#ifndef EXPERIMENTAL
-#define NEVENTS (9)
-#else /* EXPERIMENTAL */
 #define FDISTR 9   // Emit distress call from an inhabited world 
 #define FENSLV 10  // Inhabited word is enslaved */
 #define FREPRO 11  // Klingons build a ship in an enslaved system
 #define NEVENTS (12)
-#endif /* EXPERIMENTAL */
+
+typedef struct {
+    double date;
+    coord quadrant;
+} event;
 
 /*
  * abstract out the event handling -- underlying data structures will change
  * when we implement stateful events
  */
-extern void unschedule(int);
+extern event *unschedule(int);
 extern int is_scheduled(int);
-extern void schedule(int, double);
+extern event *schedule(int, double);
 extern void postpone(int, double);
 extern double scheduled(int);
-
-#ifdef EXPERIMENTAL
-#define        MAXDISTR        5       /* maximum concurrent distress calls */
-#endif /* EXPERIMENTAL */
+#define findevent(evtype)      &game.future[evtype]
 
 #define SSTMAGIC       "SST2.0\n"
 
@@ -193,7 +196,7 @@ struct game {
     double kdist[(QUADSIZE+1)*(QUADSIZE+1)];           // enemy distances
     double kavgd[(QUADSIZE+1)*(QUADSIZE+1)];           // average distances
     double damage[NDEVICES];   // damage encountered
-    double future[NEVENTS];    // future events
+    event future[NEVENTS];     // future events
     char passwd[10];           // Self Destruct password
     coord ks[(QUADSIZE+1)*(QUADSIZE+1)];       // enemy sector locations
     coord quadrant, sector;    // where we are
@@ -203,25 +206,27 @@ struct game {
     coord plnet;               // location of planet in quadrant
     coord probec;      // current probe quadrant
     bool gamewon,      // Finished!
-       ididit,         // Action taken -- allows enemy to attack
-       alive,          // We are alive (not killed)
+       ididit,         // action taken -- allows enemy to attack
+       alive,          // we are alive (not killed)
        justin,         // just entered quadrant
+       shldup,         // shields are up
+       resting,        // rest time
        alldone,        // game is now finished
        neutz,          // Romulan Neutral Zone
-       isatb,          // =1 if super commander is attacking base
        isarmed,        // probe is armed
-       thawed,         // thawed game
-       iscate;         // super commander is here
-    int inkling,       // Initial number of klingons
-       inbase,         // Initial number of bases
-       incom,          // Initial number of commanders
-       inscom,         // Initial number of commanders
-       inrom,          // Initial number of commanders
-       instar,         // Initial stars
-       intorps,        // Initial/Max torpedoes
-       condit,         // Condition (red/yellow/green/docked)
+       inorbit,        // orbiting a planet
+       thawed;         // thawed game
+    int inkling,       // initial number of klingons
+       inbase,         // initial number of bases
+       incom,          // initial number of commanders
+       inscom,         // initial number of commanders
+       inrom,          // initial number of commanders
+       instar,         // initial stars
+       intorps,        // initial/Max torpedoes
+       condit,         // condition (red/yellow/green/docked)
        torps,          // number of torpedoes
-       ship,           // Ship type -- 'E' is Enterprise
+       ship,           // ship type -- 'E' is Enterprise
+       abandoned,      // count of crew abandoned in space
        length,         // length of game
        skill,          // skill level
        klhere,         // klingons here
@@ -230,7 +235,6 @@ struct game {
        nhelp,          // calls for help
        nkinks,         // count of energy-barrier crossings
        shldchg,        // shield is changing (affects efficiency)
-       inorbit,        // orbiting
        landed,         // party on planet (1), on ship (-1)
        iplnet,         // planet # in quadrant
        imine,          // mining
@@ -241,17 +245,13 @@ struct game {
        icraft,         // Kirk in Galileo
        ientesc,        // attempted escape from supercommander
        iscraft,        // =1 if craft on ship, -1 if removed from game
-#ifdef DEBUG
-       idebug,         // debug mode
-#endif
+       isatb,          // =1 if super commander is attacking base
+       iscate,         // super commander is here
        iattak,         // attack recursion elimination (was cracks[4])
        icrystl,        // dilithium crystals aboard
        tourn,          // tournament number
        ithere,         // Tholian is here 
        iseenit,        // seen base attack report
-#ifdef EXPERIMENTAL
-       ndistr,         //* count of distress calls */ 
-#endif /* EXPERIMENTAL */
        proben,         // number of moves for probe
        nprobes;        // number of probes available
     double inresor,    // initial resources
@@ -262,7 +262,6 @@ struct game {
        indate,         // initial date
        energy,         // energy level
        shield,         // shield level
-       shldup,         // shields are up
        warpfac,        // warp speed
        wfacsq,         // squared warp factor
        lsupres,        // life support reserves
@@ -270,7 +269,6 @@ struct game {
        direc,          // movement direction
        optime,         // time taken by current operation
        docfac,         // repair factor when docking (constant?)
-       resting,        // rest time
        damfac,         // damage factor
        lastchart,      // time star chart was last updated
        cryprob,        // probability that crystal will work
@@ -288,6 +286,9 @@ extern int iscore, iskill; // Common PLAQ
 extern double perdate;
 extern double aaitem;
 extern char citem[10];
+extern int seed;
+extern bool idebug;
+extern FILE *logfp, *replayfp;
 
 /* the Space Thingy's global state should *not* be saved! */
 extern coord thing;
@@ -297,7 +298,7 @@ typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
               FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
                          FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
                          FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
-                         FHOLE} FINTYPE ;
+             FHOLE, FCREW} FINTYPE ;
 enum loctype {neither, quadrant, sector};
 
 #define IHR 'R'
@@ -336,9 +337,9 @@ int srscan(int);
 void lrscan(void);
 void phasers(void);
 void photon(void);
-void warp(int);
+void warp(bool);
 void doshield(int);
-void dock(int);
+void dock(bool);
 void dreprt(void);
 void chart(int);
 void rechart(void);
@@ -389,7 +390,7 @@ void huh(void);
 void pause_game(int);
 void nova(int, int);
 void snova(int, int);
-void scom(int *);
+void scom(bool *);
 void hittem(double *);
 void prouts(char *, ...);
 int isit(char *);
@@ -417,7 +418,7 @@ void setpassword(void);
 void commandhook(char *, bool);
 void makechart(void);
 void enqueue(char *);
-char *systemname(planet *);
+char *systemname(int);
 void newkling(int, coord *);
 
 /* mode arguments for srscan() */