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 * abstract out the event handling -- underlying data structures will change
169 * when we implement stateful events
171 extern void unschedule(int);
172 extern int is_scheduled(int);
173 extern void schedule(int, double);
174 extern void postpone(int, double);
175 extern double scheduled(int);
178 #define MAXDISTR 5 /* maximum concurrent distress calls */
179 #endif /* EXPERIMENTAL */
181 #define SSTMAGIC "SST2.0\n"
184 char magic[sizeof(SSTMAGIC)];
185 unsigned long options;
188 char quad[QUADSIZE+1][QUADSIZE+1]; // contents of our quadrant
189 double kpower[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy energy levels
190 double kdist[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy distances
191 double kavgd[(QUADSIZE+1)*(QUADSIZE+1)]; // average distances
192 double damage[NDEVICES]; // damage encountered
193 double future[NEVENTS]; // future events
194 char passwd[10]; // Self Destruct password
195 int kx[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy sector locations
196 int ky[(QUADSIZE+1)*(QUADSIZE+1)];
197 int inkling, // Initial number of klingons
198 inbase, // Initial number of bases
199 incom, // Initial number of commanders
200 inscom, // Initial number of commanders
201 inrom, // Initial number of commanders
202 instar, // Initial stars
203 intorps, // Initial/Max torpedoes
204 condit, // Condition (red/yellow/green/docked)
205 torps, // number of torpedoes
206 ship, // Ship type -- 'E' is Enterprise
207 quadx, // where we are
209 sectx, // where we are
211 length, // length of game
212 skill, // skill level
213 basex, // position of base in current quadrant
215 klhere, // klingons here
216 comhere, // commanders here
217 casual, // causalties
218 nhelp, // calls for help
219 nkinks, // count of energy-barrier crossings
220 ididit, // Action taken -- allows enemy to attack
221 gamewon, // Finished!
222 alive, // We are alive (not killed)
223 justin, // just entered quadrant
224 alldone, // game is now finished
225 shldchg, // shield is changing (affects efficiency)
226 plnetx, // location of planet in quadrant
229 landed, // party on planet (1), on ship (-1)
230 iplnet, // planet # in quadrant
232 inplan, // initial planets
233 nenhere, // number of enemies in quadrant
234 ishere, // super-commander in quandrant
235 neutz, // Romulan Neutral Zone
236 irhere, // Romulans in quadrant
237 icraft, // Kirk in Galileo
238 ientesc, // attempted escape from supercommander
239 iscraft, // =1 if craft on ship, -1 if removed from game
240 isatb, // =1 if super commander is attacking base
241 iscate, // super commander is here
243 idebug, // debug mode
245 iattak, // attack recursion elimination (was cracks[4])
246 icrystl, // dilithium crystals aboard
247 tourn, // tournament number
248 thawed, // thawed game
249 batx, // base coordinates being attacked
251 ithere, // Tholian is here
252 ithx, // coordinates of Tholian
254 iseenit, // seen base attack report
256 ndistr, //* count of distress calls */
257 #endif /* EXPERIMENTAL */
258 probecx, // current probe quadrant
260 proben, // number of moves for probe
261 isarmed, // probe is armed
262 nprobes; // number of probes available
263 double inresor, // initial resources
264 intime, // initial time
265 inenrg, // initial/max energy
266 inshld, // initial/max shield
267 inlsr, // initial life support resources
268 indate, // initial date
269 energy, // energy level
270 shield, // shield level
271 shldup, // shields are up
272 warpfac, // warp speed
273 wfacsq, // squared warp factor
274 lsupres, // life support reserves
275 dist, // movement distance
276 direc, // movement direction
277 optime, // time taken by current operation
278 docfac, // repair factor when docking (constant?)
279 resting, // rest time
280 damfac, // damage factor
281 lastchart, // time star chart was last updated
282 cryprob, // probability that crystal will work
283 probex, // location of probe
285 probeinx, // probe x,y increment
287 height; // height of orbit around planet
289 extern struct game game;
291 /* the following global state doesn't need to be saved */
292 extern char *device[NDEVICES];
293 extern int iscore, iskill; // Common PLAQ
294 extern double perdate;
295 extern double aaitem;
296 extern char citem[10];
298 /* the Space Thingy's global state should *not* be saved! */
299 extern int thingx, thingy, iqhere, iqengry;
301 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
302 FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
303 FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
304 FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
306 enum loctype {neither, quadrant, sector};
338 /* Function prototypes */
363 void finish(FINTYPE);
376 void prout(char *, ...);
377 void proutn(char *, ...);
383 char *cramlc(enum loctype, int, int);
384 double expran(double);
386 void iran(int, int *, int *);
387 #define square(i) ((i)*(i))
388 void dropin(int, int*, int*);
392 void ram(int, int, int, int);
393 void crmena(int, int, int, int, int);
394 void deadkl(int, int, int, int, int);
397 void torpedo(double, double, int, int, double *, int, int);
399 void pause_game(int);
401 void snova(int, int);
403 void hittem(double *);
404 void prouts(char *, ...);
409 void drawmaps(short);
412 void usecrystals(void);
416 void attakreport(int);
420 void setwnd(WINDOW *);
422 void boom(int ii, int jj);
423 void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad);
424 void cgetline(char *, int);
426 void setpassword(void);
427 void commandhook(char *, int);
428 void makechart(void);
429 void enqueue(char *);
430 char *systemname(planet *);
431 void newkling(int, int *, int *);
433 /* mode arguments for srscan() */
435 #define SCAN_REQUEST 2
436 #define SCAN_STATUS 3
437 #define SCAN_NO_LEFTSIDE 4
439 extern WINDOW *curwnd;
440 extern WINDOW *fullscreen_window;
441 extern WINDOW *srscan_window;
442 extern WINDOW *report_window;
443 extern WINDOW *lrscan_window;
444 extern WINDOW *message_window;
445 extern WINDOW *prompt_window;
447 extern void clreol(void);
448 extern void clrscr(void);
449 extern void textcolor(int color);
450 extern void highvideo(void);
454 BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
455 DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE