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
83 } galaxy[GALSIZE+1][GALSIZE+1]; // The Galaxy (subscript 0 not used)
88 } chart[GALSIZE+1][GALSIZE+1]; // the starchart (subscript 0 not used)
89 } snapshot; // Data that is snapshot
91 #define NKILLK (game.inkling - game.state.remkl)
92 #define NKILLC (game.incom - game.state.remcom)
93 #define NKILLSC (game.inscom - game.state.nscrem)
94 #define NKILLROM (game.inrom - game.state.nromrem)
95 #define KLINGREM (game.state.remkl + game.state.remcom + game.state.nscrem)
96 #define INKLINGTOT (game.inkling + game.incom + game.inscom)
97 #define KLINGKILLED (INKLINGTOT - KLINGREM)
100 #define SKILL_NOVICE 1
103 #define SKILL_EXPERT 4
104 #define SKILL_EMERITUS 5
107 #define OPTION_ALL 0xffffffff
108 #define OPTION_TTY 0x00000001 /* old interface */
109 #define OPTION_CURSES 0x00000002 /* new interface */
110 #define OPTION_IOMODES 0x00000003 /* cover both interfaces */
111 #define OPTION_PLANETS 0x00000004 /* planets and mining */
112 #define OPTION_THOLIAN 0x00000008 /* Tholians and their webs */
113 #define OPTION_THINGY 0x00000010 /* Space Thingy can shoot back */
114 #define OPTION_PROBE 0x00000020 /* deep-space probes */
115 #define OPTION_SHOWME 0x00000040 /* bracket Enterprise in chart */
116 #define OPTION_RAMMING 0x00000080 /* enemies may ram Enterprise */
117 #define OPTION_MVBADDY 0x00000100 /* more enemies can move */
118 #define OPTION_BLKHOLE 0x00000200 /* black hole may timewarp you */
119 #define OPTION_BASE 0x00000400 /* bases have good shields */
120 #define OPTION_WORLDS 0x00000800 /* logic for inhabited worlds */
121 #define OPTION_PLAIN 0x01000000 /* user chose plain game */
122 #define OPTION_ALMY 0x02000000 /* user chose Almy variant */
138 #define DDRAY 13 // Added deathray
139 #define DDSP 14 // Added deep space probe
140 #define NDEVICES (15) // Number of devices
144 /* Define future events */
145 #define FSPY 0 // Spy event happens always (no future[] entry)
146 // can cause SC to tractor beam Enterprise
147 #define FSNOVA 1 // Supernova
148 #define FTBEAM 2 // Commander tractor beams Enterprise
149 #define FSNAP 3 // Snapshot for time warp
150 #define FBATTAK 4 // Commander attacks base
151 #define FCDBAS 5 // Commander destroys base
152 #define FSCMOVE 6 // Supercommander moves (might attack base)
153 #define FSCDBAS 7 // Supercommander destroys base
154 #define FDSPROB 8 // Move deep space probe
157 #define SSTMAGIC "SST2.0\n"
160 char magic[sizeof(SSTMAGIC)];
161 unsigned long options;
164 char quad[QUADSIZE+1][QUADSIZE+1]; // contents of our quadrant
165 double kpower[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy energy levels
166 double kdist[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy distances
167 double kavgd[(QUADSIZE+1)*(QUADSIZE+1)]; // average distances
168 double damage[NDEVICES]; // damage encountered
169 double future[NEVENTS]; // future events
170 char passwd[10]; // Self Destruct password
171 int kx[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy sector locations
172 int ky[(QUADSIZE+1)*(QUADSIZE+1)];
173 int inkling, // Initial number of klingons
174 inbase, // Initial number of bases
175 incom, // Initial number of commanders
176 inscom, // Initial number of commanders
177 inrom, // Initial number of commanders
178 instar, // Initial stars
179 intorps, // Initial/Max torpedoes
180 condit, // Condition (red/yellow/green/docked)
181 torps, // number of torpedoes
182 ship, // Ship type -- 'E' is Enterprise
183 quadx, // where we are
185 sectx, // where we are
187 length, // length of game
188 skill, // skill level
189 basex, // position of base in current quadrant
191 klhere, // klingons here
192 comhere, // commanders here
193 casual, // causalties
194 nhelp, // calls for help
195 nkinks, // count of energy-barrier crossings
196 ididit, // Action taken -- allows enemy to attack
197 gamewon, // Finished!
198 alive, // We are alive (not killed)
199 justin, // just entered quadrant
200 alldone, // game is now finished
201 shldchg, // shield is changing (affects efficiency)
202 plnetx, // location of planet in quadrant
205 landed, // party on planet (1), on ship (-1)
206 iplnet, // planet # in quadrant
208 inplan, // initial planets
209 nenhere, // number of enemies in quadrant
210 ishere, // super-commander in quandrant
211 neutz, // Romulan Neutral Zone
212 irhere, // Romulans in quadrant
213 icraft, // Kirk in Galileo
214 ientesc, // attempted escape from supercommander
215 iscraft, // =1 if craft on ship, -1 if removed from game
216 isatb, // =1 if super commander is attacking base
217 iscate, // super commander is here
219 idebug, // debug mode
221 iattak, // attack recursion elimination (was cracks[4])
222 icrystl, // dilithium crystals aboard
223 tourn, // tournament number
224 thawed, // thawed game
225 batx, // base coordinates being attacked
227 ithere, // Tholian is here
228 ithx, // coordinates of Tholian
230 iseenit, // seen base attack report
231 probecx, // current probe quadrant
233 proben, // number of moves for probe
234 isarmed, // probe is armed
235 nprobes; // number of probes available
236 double inresor, // initial resources
237 intime, // initial time
238 inenrg, // initial/max energy
239 inshld, // initial/max shield
240 inlsr, // initial life support resources
241 indate, // initial date
242 energy, // energy level
243 shield, // shield level
244 shldup, // shields are up
245 warpfac, // warp speed
246 wfacsq, // squared warp factor
247 lsupres, // life support reserves
248 dist, // movement distance
249 direc, // movement direction
250 optime, // time taken by current operation
251 docfac, // repair factor when docking (constant?)
252 resting, // rest time
253 damfac, // damage factor
254 lastchart, // time star chart was last updated
255 cryprob, // probability that crystal will work
256 probex, // location of probe
258 probeinx, // probe x,y increment
260 height; // height of orbit around planet
262 extern struct game game;
264 /* the following global state doesn't need to be saved */
265 extern char *device[NDEVICES];
266 extern int iscore, iskill; // Common PLAQ
267 extern double perdate;
268 extern double aaitem;
269 extern char citem[10];
271 /* the Space Thingy's global state should *not* be saved! */
272 extern int thingx, thingy, iqhere, iqengry;
274 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
275 FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
276 FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
277 FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
279 enum loctype {neither, quadrant, sector};
311 /* Function prototypes */
336 void finish(FINTYPE);
349 void prout(char *, ...);
350 void proutn(char *, ...);
356 char *cramlc(enum loctype, int, int);
357 double expran(double);
359 void iran(int, int *, int *);
360 #define square(i) ((i)*(i))
361 void dropin(int, int*, int*);
365 void ram(int, int, int, int);
366 void crmena(int, int, int, int, int);
367 void deadkl(int, int, int, int, int);
370 void torpedo(double, double, int, int, double *, int, int);
372 void pause_game(int);
374 void snova(int, int);
376 void hittem(double *);
377 void prouts(char *, ...);
382 void drawmaps(short);
385 void usecrystals(void);
389 void attakreport(int);
393 void setwnd(WINDOW *);
395 void boom(int ii, int jj);
396 void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad);
397 void cgetline(char *, int);
399 void setpassword(void);
400 void commandhook(char *, int);
401 void makechart(void);
402 void enqueue(char *);
403 char *systemname(planet *);
405 /* mode arguments for srscan() */
407 #define SCAN_REQUEST 2
408 #define SCAN_STATUS 3
409 #define SCAN_NO_LEFTSIDE 4
411 extern WINDOW *curwnd;
412 extern WINDOW *fullscreen_window;
413 extern WINDOW *srscan_window;
414 extern WINDOW *report_window;
415 extern WINDOW *lrscan_window;
416 extern WINDOW *message_window;
417 extern WINDOW *prompt_window;
419 extern void clreol(void);
420 extern void clrscr(void);
421 extern void textcolor(int color);
422 extern void highvideo(void);
426 BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
427 DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE