12 #define SSTDOC DATA_DIR"/"DOC_NAME
14 #define SSTDOC DOC_NAME
17 #define _(str) gettext(str)
19 #define min(x, y) ((x)<(y)?(x):(y))
20 #define max(x, y) ((x)>(y)?(x):(y))
24 #define PHASEFAC (2.0)
26 #define NINHAB (GALSIZE * GALSIZE / 2)
27 #define MAXUNINHAB (10)
28 #define PLNETMAX (NINHAB + MAXUNINHAB)
33 * These macros hide the difference between 0-origin and 1-origin addressing.
34 * They're a step towards de-FORTRANizing the code.
36 #define VALID_QUADRANT(x, y) ((x)>=1 && (x)<=GALSIZE && (y)>=1 && (y)<=GALSIZE)
37 #define VALID_SECTOR(x, y) ((x)>=1 && (x)<=QUADSIZE && (y)>=1 && (y)<=QUADSIZE)
38 #define for_quadrants(i) for (i = 1; i <= GALSIZE; i++)
39 #define for_sectors(i) for (i = 1; i <= QUADSIZE; i++)
40 #define for_commanders(i) for (i = 1; i <= game.state.remcom; i++)
41 #define for_local_enemies(i) for (i = 1; i <= game.nenhere; i++)
42 #define for_starbases(i) for (i = 1; i <= game.state.rembase; i++)
45 int x; /* Quadrant location of planet */
47 enum {M=0, N=1, O=2} pclass;
48 int inhabited; /* if NZ, an index into a name array */
49 #define UNINHABITED -1
50 int crystals; /* has crystals */
51 #define MINED -1 /* used to have crystals, but they were mined out */
52 enum {unknown, known, shuttle_down} known;
55 #define DESTROY(pl) memset(pl, '\0', sizeof(planet))
58 int snap, // snapshot taken
59 remkl, // remaining klingons
60 remcom, // remaining commanders
61 nscrem, // remaining super commanders
62 rembase, // remaining bases
63 starkl, // destroyed stars
64 basekl, // destroyed bases
65 cx[QUADSIZE+1],cy[QUADSIZE+1], // Commander quadrant coordinates
66 baseqx[BASEMAX+1], // Base quadrant X
67 baseqy[BASEMAX+1], // Base quadrant Y
68 isx, isy, // Coordinate of Super Commander
69 nromrem, // Romulans remaining
70 nplankl; // destroyed planets
71 planet plnets[PLNETMAX]; // Planet information
72 double date, // stardate
73 remres, // remaining resources
74 remtime; // remaining time
84 enum {secure, distressed, enslaved} status;
85 #endif /* EXPERIMENTAL */
86 } galaxy[GALSIZE+1][GALSIZE+1]; // The Galaxy (subscript 0 not used)
91 } chart[GALSIZE+1][GALSIZE+1]; // the starchart (subscript 0 not used)
92 } snapshot; // Data that is snapshot
94 #define NKILLK (game.inkling - game.state.remkl)
95 #define NKILLC (game.incom - game.state.remcom)
96 #define NKILLSC (game.inscom - game.state.nscrem)
97 #define NKILLROM (game.inrom - game.state.nromrem)
98 #define KLINGREM (game.state.remkl + game.state.remcom + game.state.nscrem)
99 #define INKLINGTOT (game.inkling + game.incom + game.inscom)
100 #define KLINGKILLED (INKLINGTOT - KLINGREM)
103 #define SKILL_NOVICE 1
106 #define SKILL_EXPERT 4
107 #define SKILL_EMERITUS 5
110 #define OPTION_ALL 0xffffffff
111 #define OPTION_TTY 0x00000001 /* old interface */
112 #define OPTION_CURSES 0x00000002 /* new interface */
113 #define OPTION_IOMODES 0x00000003 /* cover both interfaces */
114 #define OPTION_PLANETS 0x00000004 /* planets and mining */
115 #define OPTION_THOLIAN 0x00000008 /* Tholians and their webs */
116 #define OPTION_THINGY 0x00000010 /* Space Thingy can shoot back */
117 #define OPTION_PROBE 0x00000020 /* deep-space probes */
118 #define OPTION_SHOWME 0x00000040 /* bracket Enterprise in chart */
119 #define OPTION_RAMMING 0x00000080 /* enemies may ram Enterprise */
120 #define OPTION_MVBADDY 0x00000100 /* more enemies can move */
121 #define OPTION_BLKHOLE 0x00000200 /* black hole may timewarp you */
122 #define OPTION_BASE 0x00000400 /* bases have good shields */
123 #define OPTION_WORLDS 0x00000800 /* logic for inhabited worlds */
124 #define OPTION_PLAIN 0x01000000 /* user chose plain game */
125 #define OPTION_ALMY 0x02000000 /* user chose Almy variant */
141 #define DDRAY 13 // Added deathray
142 #define DDSP 14 // Added deep space probe
143 #define NDEVICES (15) // Number of devices
147 /* Define future events */
148 #define FSPY 0 // Spy event happens always (no future[] entry)
149 // can cause SC to tractor beam Enterprise
150 #define FSNOVA 1 // Supernova
151 #define FTBEAM 2 // Commander tractor beams Enterprise
152 #define FSNAP 3 // Snapshot for time warp
153 #define FBATTAK 4 // Commander attacks base
154 #define FCDBAS 5 // Commander destroys base
155 #define FSCMOVE 6 // Supercommander moves (might attack base)
156 #define FSCDBAS 7 // Supercommander destroys base
157 #define FDSPROB 8 // Move deep space probe
160 #else /* EXPERIMENTAL */
161 #define FDISTR 9 // Emit distress call from an inhabited world
162 #define FENSLV 10 // Inhabited word is enslaved */
163 #define FREPRO 11 // Klingons build a ship in an enslaved system
165 #endif /* EXPERIMENTAL */
168 #define MAXDISTR 5 /* maximum concurrent distress calls */
169 #endif /* EXPERIMENTAL */
171 #define SSTMAGIC "SST2.0\n"
174 char magic[sizeof(SSTMAGIC)];
175 unsigned long options;
178 char quad[QUADSIZE+1][QUADSIZE+1]; // contents of our quadrant
179 double kpower[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy energy levels
180 double kdist[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy distances
181 double kavgd[(QUADSIZE+1)*(QUADSIZE+1)]; // average distances
182 double damage[NDEVICES]; // damage encountered
183 double future[NEVENTS]; // future events
184 char passwd[10]; // Self Destruct password
185 int kx[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy sector locations
186 int ky[(QUADSIZE+1)*(QUADSIZE+1)];
187 int inkling, // Initial number of klingons
188 inbase, // Initial number of bases
189 incom, // Initial number of commanders
190 inscom, // Initial number of commanders
191 inrom, // Initial number of commanders
192 instar, // Initial stars
193 intorps, // Initial/Max torpedoes
194 condit, // Condition (red/yellow/green/docked)
195 torps, // number of torpedoes
196 ship, // Ship type -- 'E' is Enterprise
197 quadx, // where we are
199 sectx, // where we are
201 length, // length of game
202 skill, // skill level
203 basex, // position of base in current quadrant
205 klhere, // klingons here
206 comhere, // commanders here
207 casual, // causalties
208 nhelp, // calls for help
209 nkinks, // count of energy-barrier crossings
210 ididit, // Action taken -- allows enemy to attack
211 gamewon, // Finished!
212 alive, // We are alive (not killed)
213 justin, // just entered quadrant
214 alldone, // game is now finished
215 shldchg, // shield is changing (affects efficiency)
216 plnetx, // location of planet in quadrant
219 landed, // party on planet (1), on ship (-1)
220 iplnet, // planet # in quadrant
222 inplan, // initial planets
223 nenhere, // number of enemies in quadrant
224 ishere, // super-commander in quandrant
225 neutz, // Romulan Neutral Zone
226 irhere, // Romulans in quadrant
227 icraft, // Kirk in Galileo
228 ientesc, // attempted escape from supercommander
229 iscraft, // =1 if craft on ship, -1 if removed from game
230 isatb, // =1 if super commander is attacking base
231 iscate, // super commander is here
233 idebug, // debug mode
235 iattak, // attack recursion elimination (was cracks[4])
236 icrystl, // dilithium crystals aboard
237 tourn, // tournament number
238 thawed, // thawed game
239 batx, // base coordinates being attacked
241 ithere, // Tholian is here
242 ithx, // coordinates of Tholian
244 iseenit, // seen base attack report
246 ndistr, //* count of distress calls */
247 #endif /* EXPERIMENTAL */
248 probecx, // current probe quadrant
250 proben, // number of moves for probe
251 isarmed, // probe is armed
252 nprobes; // number of probes available
253 double inresor, // initial resources
254 intime, // initial time
255 inenrg, // initial/max energy
256 inshld, // initial/max shield
257 inlsr, // initial life support resources
258 indate, // initial date
259 energy, // energy level
260 shield, // shield level
261 shldup, // shields are up
262 warpfac, // warp speed
263 wfacsq, // squared warp factor
264 lsupres, // life support reserves
265 dist, // movement distance
266 direc, // movement direction
267 optime, // time taken by current operation
268 docfac, // repair factor when docking (constant?)
269 resting, // rest time
270 damfac, // damage factor
271 lastchart, // time star chart was last updated
272 cryprob, // probability that crystal will work
273 probex, // location of probe
275 probeinx, // probe x,y increment
277 height; // height of orbit around planet
279 extern struct game game;
281 /* the following global state doesn't need to be saved */
282 extern char *device[NDEVICES];
283 extern int iscore, iskill; // Common PLAQ
284 extern double perdate;
285 extern double aaitem;
286 extern char citem[10];
288 /* the Space Thingy's global state should *not* be saved! */
289 extern int thingx, thingy, iqhere, iqengry;
291 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
292 FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
293 FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
294 FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
296 enum loctype {neither, quadrant, sector};
328 /* Function prototypes */
353 void finish(FINTYPE);
366 void prout(char *, ...);
367 void proutn(char *, ...);
373 char *cramlc(enum loctype, int, int);
374 double expran(double);
376 void iran(int, int *, int *);
377 #define square(i) ((i)*(i))
378 void dropin(int, int*, int*);
382 void ram(int, int, int, int);
383 void crmena(int, int, int, int, int);
384 void deadkl(int, int, int, int, int);
387 void torpedo(double, double, int, int, double *, int, int);
389 void pause_game(int);
391 void snova(int, int);
393 void hittem(double *);
394 void prouts(char *, ...);
399 void drawmaps(short);
402 void usecrystals(void);
406 void attakreport(int);
410 void setwnd(WINDOW *);
412 void boom(int ii, int jj);
413 void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad);
414 void cgetline(char *, int);
416 void setpassword(void);
417 void commandhook(char *, int);
418 void makechart(void);
419 void enqueue(char *);
420 char *systemname(planet *);
421 void newkling(int, int *, int *);
423 /* mode arguments for srscan() */
425 #define SCAN_REQUEST 2
426 #define SCAN_STATUS 3
427 #define SCAN_NO_LEFTSIDE 4
429 extern WINDOW *curwnd;
430 extern WINDOW *fullscreen_window;
431 extern WINDOW *srscan_window;
432 extern WINDOW *report_window;
433 extern WINDOW *lrscan_window;
434 extern WINDOW *message_window;
435 extern WINDOW *prompt_window;
437 extern void clreol(void);
438 extern void clrscr(void);
439 extern void textcolor(int color);
440 extern void highvideo(void);
444 BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
445 DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE