X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=sst.h;h=8705b8480ce06277cbb4e6c410e2e658f35a99c7;hp=b34312068646182ccd7a1eb77a100f3715adfa14;hb=d5826a672dd4afc591476655b4905cb6542cd89c;hpb=f14a35629e403d9b2cd4e406e80666671fd2a594 diff --git a/sst.h b/sst.h index b343120..8705b84 100644 --- a/sst.h +++ b/sst.h @@ -10,55 +10,70 @@ // #define DEBUG -#define ndevice (15) // Number of devices -#define phasefac (2.0) +#define NDEVICES (15) // Number of devices +#define PHASEFAC (2.0) #define PLNETMAX (10) #define NEVENTS (8) typedef struct { - int x; /* Quadrant location of planet */ - int y; - int pclass; /* class M, N, or O (1, 2, or 3) */ - int crystals; /* has crystals */ - int known; /* =1 contents known, =2 shuttle on this planet */ -} PLANETS; + int x; /* Quadrant location of planet */ + int y; + enum {M=0, N=1, O=2} pclass; + int crystals; /* has crystals */ + enum {unknown, known, shuttle_down} known; +} planet; -EXTERN struct foo { - int snap, // snapshot taken - remkl, // remaining klingons - remcom, // remaining commanders - rembase, // remaining bases - starkl, // destroyed stars - basekl, // destroyed bases - killk, // Klingons killed - killc, // commanders killed - galaxy[9][9], // The Galaxy (subscript 0 not used) - cx[11],cy[11], // Commander quadrant coordinates - baseqx[6], // Base quadrant X - baseqy[6], // Base quadrant Y - newstuf[9][9], // Extended galaxy goodies - isx, isy, // Coordinate of Super Commander - nscrem, // remaining super commanders - nromkl, // Romulans killed - nromrem, // Romulans remaining - nsckill, // super commanders killed - nplankl; // destroyed planets - PLANETS plnets[PLNETMAX+1]; // Planet information +#define DESTROY(pl) memset(pl, '\0', sizeof(planet)) + +typedef struct { + int snap, // snapshot taken + remkl, // remaining klingons + remcom, // remaining commanders + rembase, // remaining bases + starkl, // destroyed stars + basekl, // destroyed bases + killk, // Klingons killed + killc, // commanders killed + galaxy[9][9], // The Galaxy (subscript 0 not used) + cx[11],cy[11], // Commander quadrant coordinates + baseqx[6], // Base quadrant X + baseqy[6], // Base quadrant Y + newstuf[9][9], // Extended galaxy goodies + isx, isy, // Coordinate of Super Commander + nscrem, // remaining super commanders + nromkl, // Romulans killed + nromrem, // Romulans remaining + nsckill, // super commanders killed + nplankl; // destroyed planets + planet plnets[PLNETMAX]; // Planet information double date, // stardate - remres, // remaining resources + remres, // remaining resources remtime; // remaining time -} d, snapsht; // Data that is snapshot - -EXTERN char - quad[11][11]; // contents of our quadrant +} snapshot; // Data that is snapshot // Scalar variables that are needed for freezing the game // are placed in a structure. #defines are used to access by their // original names. Gee, I could have done this with the d structure, // but I just didn't think of it back when I started. -EXTERN struct foo2 { - int inkling, +#define SSTMAGIC "SST2.0\n" + +EXTERN struct { + char magic[sizeof(SSTMAGIC)]; + snapshot state; + snapshot snapsht; + char quad[11][11]; // contents of our quadrant + double kpower[21]; // enemy energy levels + double kdist[21]; // enemy distances + double kavgd[21]; // average distances + double damage[NDEVICES+1]; // damage encountered + double future[NEVENTS+1]; // future events + char passwd[10]; // Self Destruct password + int kx[21]; // enemy sector locations + int ky[21]; + int starch[9][9]; // star chart + /* members with macro definitions start here */ + int inkling, inbase, incom, instar, @@ -121,7 +136,7 @@ EXTERN struct foo2 { proben, isarmed, nprobes; - double inresor, + double inresor, intime, inenrg, inshld, @@ -235,39 +250,20 @@ EXTERN struct foo2 { #define isarmed game.isarmed // Probe is armed #define nprobes game.nprobes // number of probes available -EXTERN int - kx[21], // enemy sector locations - ky[21], - starch[9][9]; // star chart - +/* the following global state doesn't need to be saved */ EXTERN int fromcommandline; // Game start from command line options - - -EXTERN char passwd[10], // Self Destruct password - *device[ndevice+1]; - -EXTERN PLANETS nulplanet; // zeroed planet structure - -EXTERN double - kpower[21], // enemy energy levels - kdist[21], // enemy distances - kavgd[21], // average distances - damage[ndevice+1], // damage encountered - future[NEVENTS+1]; // future events - +EXTERN char *device[NDEVICES+1]; EXTERN int iscore, iskill; // Common PLAQ EXTERN double perdate; +EXTERN double aaitem; +EXTERN char citem[10]; typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE, FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM, FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET, FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE, FHOLE} FINTYPE ; - - -EXTERN double aaitem; -EXTERN char citem[10]; - +enum loctype {neither, quadrant, sector}; /* Define devices */ #define DSRSENS 1 @@ -299,8 +295,7 @@ EXTERN char citem[10]; #define FDSPROB 8 // Move deep space probe #ifdef INCLUDED -PLANETS nulplanet = {0}; -char *device[ndevice+1] = { +char *device[NDEVICES+1] = { "", "S. R. Sensors", "L. R. Sensors", @@ -379,14 +374,14 @@ int scan(void); void chew(void); void chew2(void); void skip(int); -void prout(char *s); -void proutn(char *s); +void prout(char *, ...); +void proutn(char *, ...); void stars(void); void newqad(int); int ja(void); void cramen(int); void crmshp(void); -void cramlc(int, int, int); +char *cramlc(enum loctype, int, int); double expran(double); double Rand(void); void iran8(int *, int *); @@ -402,15 +397,13 @@ void deadkl(int, int, int, int, int); void timwrp(void); void movcom(void); void torpedo(double, double, int, int, double *); -void cramf(double, int, int); -void crami(int, int); void huh(void); void pause(int); void nova(int, int); void snova(int, int); void scom(int *); void hittem(double *); -void prouts(char *); +void prouts(char *, ...); int isit(char *); void preport(void); void orbit(void);