10 #define SSTDOC DATA_DIR"/"DOC_NAME
12 #define SSTDOC DOC_NAME
15 #define min(x, y) ((x)<(y)?(x):(y))
16 #define max(x, y) ((x)>(y)?(x):(y))
20 #define PHASEFAC (2.0)
22 #define NINHAB (GALSIZE * GALSIZE / 2)
23 #define MAXUNINHAB (10)
24 #define PLNETMAX (NINHAB + MAXUNINHAB)
29 * These macros hide the difference between 0-origin and 1-origin addressing.
30 * They're a step towards de-FORTRANizing the code.
32 #define VALID_QUADRANT(x, y) ((x)>=1 && (x)<=GALSIZE && (y)>=1 && (y)<=GALSIZE)
33 #define VALID_SECTOR(x, y) ((x)>=1 && (x)<=QUADSIZE && (y)>=1 && (y)<=QUADSIZE)
34 #define for_quadrants(i) for (i = 1; i <= GALSIZE; i++)
35 #define for_sectors(i) for (i = 1; i <= QUADSIZE; i++)
36 #define for_commanders(i) for (i = 1; i <= game.state.remcom; i++)
37 #define for_local_enemies(i) for (i = 1; i <= game.nenhere; i++)
38 #define for_starbases(i) for (i = 1; i <= game.state.rembase; i++)
41 int x; /* Quadrant location of planet */
43 enum {M=0, N=1, O=2} pclass;
44 int inhabited; /* if NZ, an index into a name array */
45 #define UNINHABITED -1
46 int crystals; /* has crystals */
47 #define MINED -1 /* used to have crystals, but they were mined out */
48 enum {unknown, known, shuttle_down} known;
51 #define DESTROY(pl) memset(pl, '\0', sizeof(planet))
54 int snap, // snapshot taken
55 remkl, // remaining klingons
56 remcom, // remaining commanders
57 nscrem, // remaining super commanders
58 rembase, // remaining bases
59 starkl, // destroyed stars
60 basekl, // destroyed bases
61 cx[QUADSIZE+1],cy[QUADSIZE+1], // Commander quadrant coordinates
62 baseqx[BASEMAX+1], // Base quadrant X
63 baseqy[BASEMAX+1], // Base quadrant Y
64 isx, isy, // Coordinate of Super Commander
65 nromrem, // Romulans remaining
66 nplankl; // destroyed planets
67 planet plnets[PLNETMAX]; // Planet information
68 double date, // stardate
69 remres, // remaining resources
70 remtime; // remaining time
79 } galaxy[GALSIZE+1][GALSIZE+1]; // The Galaxy (subscript 0 not used)
84 } chart[GALSIZE+1][GALSIZE+1]; // the starchart (subscript 0 not used)
85 } snapshot; // Data that is snapshot
87 #define NKILLK (game.inkling - game.state.remkl)
88 #define NKILLC (game.incom - game.state.remcom)
89 #define NKILLSC (game.inscom - game.state.nscrem)
90 #define NKILLROM (game.inrom - game.state.nromrem)
91 #define KLINGREM (game.state.remkl + game.state.remcom + game.state.nscrem)
92 #define INKLINGTOT (game.inkling + game.incom + game.inscom)
93 #define KLINGKILLED (INKLINGTOT - KLINGREM)
96 #define SKILL_NOVICE 1
99 #define SKILL_EXPERT 4
100 #define SKILL_EMERITUS 5
103 #define OPTION_ALL 0xffffffff
104 #define OPTION_TTY 0x00000001 /* old interface */
105 #define OPTION_CURSES 0x00000002 /* new interface */
106 #define OPTION_IOMODES 0x00000003 /* cover both interfaces */
107 #define OPTION_PLANETS 0x00000004 /* planets and mining */
108 #define OPTION_THOLIAN 0x00000008 /* Tholians and their webs */
109 #define OPTION_THINGY 0x00000010 /* Space Thingy can shoot back */
110 #define OPTION_PROBE 0x00000020 /* deep-space probes */
111 #define OPTION_SHOWME 0x00000040 /* bracket Enterprise in chart */
112 #define OPTION_RAMMING 0x00000080 /* enemies may ram Enterprise */
113 #define OPTION_MVBADDY 0x00000100 /* more enemies can move */
114 #define OPTION_BLKHOLE 0x00000200 /* black hole may timewarp you */
115 #define OPTION_BASE 0x00000400 /* bases have good shields */
116 #define OPTION_WORLDS 0x00000800 /* logic for inhabited worlds */
117 #define OPTION_PLAIN 0x01000000 /* user chose plain game */
118 #define OPTION_ALMY 0x02000000 /* user chose Almy variant */
134 #define DDRAY 13 // Added deathray
135 #define DDSP 14 // Added deep space probe
136 #define NDEVICES (15) // Number of devices
140 /* Define future events */
141 #define FSPY 0 // Spy event happens always (no future[] entry)
142 // can cause SC to tractor beam Enterprise
143 #define FSNOVA 1 // Supernova
144 #define FTBEAM 2 // Commander tractor beams Enterprise
145 #define FSNAP 3 // Snapshot for time warp
146 #define FBATTAK 4 // Commander attacks base
147 #define FCDBAS 5 // Commander destroys base
148 #define FSCMOVE 6 // Supercommander moves (might attack base)
149 #define FSCDBAS 7 // Supercommander destroys base
150 #define FDSPROB 8 // Move deep space probe
153 #define SSTMAGIC "SST2.0\n"
156 char magic[sizeof(SSTMAGIC)];
157 unsigned long options;
160 char quad[QUADSIZE+1][QUADSIZE+1]; // contents of our quadrant
161 double kpower[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy energy levels
162 double kdist[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy distances
163 double kavgd[(QUADSIZE+1)*(QUADSIZE+1)]; // average distances
164 double damage[NDEVICES]; // damage encountered
165 double future[NEVENTS]; // future events
166 char passwd[10]; // Self Destruct password
167 int kx[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy sector locations
168 int ky[(QUADSIZE+1)*(QUADSIZE+1)];
169 int inkling, // Initial number of klingons
170 inbase, // Initial number of bases
171 incom, // Initial number of commanders
172 inscom, // Initial number of commanders
173 inrom, // Initial number of commanders
174 instar, // Initial stars
175 intorps, // Initial/Max torpedoes
176 condit, // Condition (red/yellow/green/docked)
177 torps, // number of torpedoes
178 ship, // Ship type -- 'E' is Enterprise
179 quadx, // where we are
181 sectx, // where we are
183 length, // length of game
184 skill, // skill level
185 basex, // position of base in current quadrant
187 klhere, // klingons here
188 comhere, // commanders here
189 casual, // causalties
190 nhelp, // calls for help
191 nkinks, // count of energy-barrier crossings
192 ididit, // Action taken -- allows enemy to attack
193 gamewon, // Finished!
194 alive, // We are alive (not killed)
195 justin, // just entered quadrant
196 alldone, // game is now finished
197 shldchg, // shield is changing (affects efficiency)
198 plnetx, // location of planet in quadrant
201 landed, // party on planet (1), on ship (-1)
202 iplnet, // planet # in quadrant
204 inplan, // initial planets
205 nenhere, // number of enemies in quadrant
206 ishere, // super-commander in quandrant
207 neutz, // Romulan Neutral Zone
208 irhere, // Romulans in quadrant
209 icraft, // Kirk in Galileo
210 ientesc, // attempted escape from supercommander
211 iscraft, // =1 if craft on ship, -1 if removed from game
212 isatb, // =1 if super commander is attacking base
213 iscate, // super commander is here
215 idebug, // debug mode
217 iattak, // attack recursion elimination (was cracks[4])
218 icrystl, // dilithium crystals aboard
219 tourn, // tournament number
220 thawed, // thawed game
221 batx, // base coordinates being attacked
223 ithere, // Tholian is here
224 ithx, // coordinates of Tholian
226 iseenit, // seen base attack report
227 probecx, // current probe quadrant
229 proben, // number of moves for probe
230 isarmed, // probe is armed
231 nprobes; // number of probes available
232 double inresor, // initial resources
233 intime, // initial time
234 inenrg, // initial/max energy
235 inshld, // initial/max shield
236 inlsr, // initial life support resources
237 indate, // initial date
238 energy, // energy level
239 shield, // shield level
240 shldup, // shields are up
241 warpfac, // warp speed
242 wfacsq, // squared warp factor
243 lsupres, // life support reserves
244 dist, // movement distance
245 direc, // movement direction
246 optime, // time taken by current operation
247 docfac, // repair factor when docking (constant?)
248 resting, // rest time
249 damfac, // damage factor
250 lastchart, // time star chart was last updated
251 cryprob, // probability that crystal will work
252 probex, // location of probe
254 probeinx, // probe x,y increment
256 height; // height of orbit around planet
258 extern struct game game;
260 /* the following global state doesn't need to be saved */
261 extern char *device[NDEVICES];
262 extern int iscore, iskill; // Common PLAQ
263 extern double perdate;
264 extern double aaitem;
265 extern char citem[10];
267 /* the Space Thingy's global state should *not* be saved! */
268 extern int thingx, thingy, iqhere, iqengry;
270 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
271 FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
272 FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
273 FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
275 enum loctype {neither, quadrant, sector};
307 /* Function prototypes */
332 void finish(FINTYPE);
345 void prout(char *, ...);
346 void proutn(char *, ...);
352 char *cramlc(enum loctype, int, int);
353 double expran(double);
355 void iran(int, int *, int *);
356 #define square(i) ((i)*(i))
357 void dropin(int, int*, int*);
361 void ram(int, int, int, int);
362 void crmena(int, int, int, int, int);
363 void deadkl(int, int, int, int, int);
366 void torpedo(double, double, int, int, double *, int, int);
368 void pause_game(int);
370 void snova(int, int);
372 void hittem(double *);
373 void prouts(char *, ...);
378 void drawmaps(short);
381 void usecrystals(void);
385 void attakreport(int);
389 void setwnd(WINDOW *);
391 void boom(int ii, int jj);
392 void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad);
393 void cgetline(char *, int);
395 void setpassword(void);
396 void commandhook(char *, int);
397 void makechart(void);
398 void enqueue(char *);
399 char *systemname(planet *);
401 /* mode arguments for srscan() */
403 #define SCAN_REQUEST 2
404 #define SCAN_STATUS 3
405 #define SCAN_NO_LEFTSIDE 4
407 extern WINDOW *curwnd;
408 extern WINDOW *fullscreen_window;
409 extern WINDOW *srscan_window;
410 extern WINDOW *report_window;
411 extern WINDOW *lrscan_window;
412 extern WINDOW *message_window;
413 extern WINDOW *prompt_window;
415 extern void clreol(void);
416 extern void clrscr(void);
417 extern void textcolor(int color);
418 extern void highvideo(void);
422 BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
423 DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE