X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=src%2Fsst.h;h=e9a805f5aaaaab0a1709169131a72b02a9e44176;hp=182634d6c2da8b741ebaf6a22fc87bd529aecd7b;hb=4c3ff8ac78499d53339de7d67081e99582a9fb75;hpb=c81e0f1dc6cd1fe5c56e9d521ee1d262932e3a2b diff --git a/src/sst.h b/src/sst.h index 182634d..e9a805f 100644 --- a/src/sst.h +++ b/src/sst.h @@ -7,6 +7,7 @@ #include #include #include +#include #ifdef DATA_DIR #define SSTDOC DATA_DIR"/"DOC_NAME @@ -19,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) @@ -66,33 +65,36 @@ 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 starbase; + int planet; +#define NOPLANET -1 + bool starbase; int klingons; int romulans; - int supernova; - int charted; -#ifdef EXPERIMENTAL + bool supernova; + bool charted; enum {secure, distressed, enslaved} status; -#endif /* EXPERIMENTAL */ } galaxy[GALSIZE+1][GALSIZE+1]; // The Galaxy (subscript 0 not used) - struct { + struct page { int stars; int starbase; int klingons; } 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) @@ -157,28 +159,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" @@ -192,7 +192,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 @@ -201,16 +201,27 @@ struct game { coord battle; // base coordinates being attacked coord plnet; // location of planet in quadrant coord probec; // current probe quadrant - 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) + bool gamewon, // Finished! + 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 + isarmed, // probe is armed + 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 length, // length of game skill, // skill level klhere, // klingons here @@ -218,40 +229,25 @@ struct game { casual, // causalties nhelp, // calls for help nkinks, // count of energy-barrier crossings - ididit, // Action taken -- allows enemy to attack - gamewon, // Finished! - alive, // We are alive (not killed) - justin, // just entered quadrant - alldone, // game is now finished shldchg, // shield is changing (affects efficiency) - inorbit, // orbiting landed, // party on planet (1), on ship (-1) iplnet, // planet # in quadrant imine, // mining inplan, // initial planets nenhere, // number of enemies in quadrant ishere, // super-commander in quandrant - neutz, // Romulan Neutral Zone irhere, // Romulans in quadrant icraft, // Kirk in Galileo ientesc, // attempted escape from supercommander iscraft, // =1 if craft on ship, -1 if removed from game isatb, // =1 if super commander is attacking base iscate, // super commander is here -#ifdef DEBUG - idebug, // debug mode -#endif iattak, // attack recursion elimination (was cracks[4]) icrystl, // dilithium crystals aboard tourn, // tournament number - thawed, // thawed game ithere, // Tholian is here iseenit, // seen base attack report -#ifdef EXPERIMENTAL - ndistr, //* count of distress calls */ -#endif /* EXPERIMENTAL */ proben, // number of moves for probe - isarmed, // probe is armed nprobes; // number of probes available double inresor, // initial resources intime, // initial time @@ -261,7 +257,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 @@ -269,7 +264,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 @@ -287,6 +281,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; @@ -299,11 +296,6 @@ typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE, FHOLE} FINTYPE ; enum loctype {neither, quadrant, sector}; -#ifndef TRUE -#define TRUE (1) -#define FALSE (0) -#endif - #define IHR 'R' #define IHK 'K' #define IHC 'C' @@ -332,7 +324,7 @@ enum loctype {neither, quadrant, sector}; /* Function prototypes */ void prelim(void); void attack(int); -int choose(int); +bool choose(bool); void setup(int); void score(void); void atover(int); @@ -340,7 +332,7 @@ 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 dreprt(void); @@ -357,7 +349,7 @@ void abandn(void); void finish(FINTYPE); void dstrct(void); void kaboom(void); -void freeze(int); +void freeze(bool); int thaw(void); void plaque(void); int scan(void); @@ -371,7 +363,7 @@ void prout(char *, ...); void proutn(char *, ...); void stars(void); void newqad(int); -int ja(void); +bool ja(void); void cramen(int); void crmshp(void); char *cramlc(enum loctype, coord w); @@ -385,7 +377,7 @@ void sortkl(void); void imove(void); void ram(int, int, coord); void crmena(int, int, int, coord w); -void deadkl(int, int, int, int, int); +void deadkl(coord, int, int, int); void timwrp(void); void movcom(void); void torpedo(double, double, int, int, double *, int, int); @@ -418,10 +410,10 @@ void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad); void cgetline(char *, int); void waitfor(void); void setpassword(void); -void commandhook(char *, int); +void commandhook(char *, bool); void makechart(void); void enqueue(char *); -char *systemname(planet *); +char *systemname(int); void newkling(int, coord *); /* mode arguments for srscan() */