13 #define SSTDOC DATA_DIR"/"DOC_NAME
15 #define SSTDOC DOC_NAME
18 #define _(str) gettext(str)
20 #define min(x, y) ((x)<(y)?(x):(y))
21 #define max(x, y) ((x)>(y)?(x):(y))
25 #define PHASEFAC (2.0)
27 #define NINHAB (GALSIZE * GALSIZE / 2)
28 #define MAXUNINHAB (10)
29 #define PLNETMAX (NINHAB + MAXUNINHAB)
34 * These macros hide the difference between 0-origin and 1-origin addressing.
35 * They're a step towards de-FORTRANizing the code.
37 #define VALID_QUADRANT(x, y) ((x)>=1 && (x)<=GALSIZE && (y)>=1 && (y)<=GALSIZE)
38 #define VALID_SECTOR(x, y) ((x)>=1 && (x)<=QUADSIZE && (y)>=1 && (y)<=QUADSIZE)
39 #define for_quadrants(i) for (i = 1; i <= GALSIZE; i++)
40 #define for_sectors(i) for (i = 1; i <= QUADSIZE; i++)
41 #define for_commanders(i) for (i = 1; i <= game.state.remcom; i++)
42 #define for_local_enemies(i) for (i = 1; i <= game.nenhere; i++)
43 #define for_starbases(i) for (i = 1; i <= game.state.rembase; i++)
45 typedef struct {int x; int y;} coord;
47 #define same(c1, c2) (c1.x == c2.x && c1.y == c2.y)
51 enum {M=0, N=1, O=2} pclass;
52 int inhabited; /* if NZ, an index into a name array */
53 #define UNINHABITED -1
54 int crystals; /* has crystals */
55 #define MINED -1 /* used to have crystals, but they were mined out */
56 enum {unknown, known, shuttle_down} known;
59 #define DESTROY(pl) memset(pl, '\0', sizeof(planet))
62 int snap, // snapshot taken
63 remkl, // remaining klingons
64 remcom, // remaining commanders
65 nscrem, // remaining super commanders
66 rembase, // remaining bases
67 starkl, // destroyed stars
68 basekl, // destroyed bases
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
75 coord baseq[BASEMAX+1]; // Base quadrant coordinates
76 coord kcmdr[QUADSIZE+1]; // Commander quadrant coordinates
77 coord kscmdr; // Supercommander quadrant coordinates
87 enum {secure, distressed, enslaved} status;
88 #endif /* EXPERIMENTAL */
89 } galaxy[GALSIZE+1][GALSIZE+1]; // The Galaxy (subscript 0 not used)
94 } chart[GALSIZE+1][GALSIZE+1]; // the starchart (subscript 0 not used)
95 } snapshot; // Data that is snapshot
97 #define NKILLK (game.inkling - game.state.remkl)
98 #define NKILLC (game.incom - game.state.remcom)
99 #define NKILLSC (game.inscom - game.state.nscrem)
100 #define NKILLROM (game.inrom - game.state.nromrem)
101 #define KLINGREM (game.state.remkl + game.state.remcom + game.state.nscrem)
102 #define INKLINGTOT (game.inkling + game.incom + game.inscom)
103 #define KLINGKILLED (INKLINGTOT - KLINGREM)
106 #define SKILL_NOVICE 1
109 #define SKILL_EXPERT 4
110 #define SKILL_EMERITUS 5
113 #define OPTION_ALL 0xffffffff
114 #define OPTION_TTY 0x00000001 /* old interface */
115 #define OPTION_CURSES 0x00000002 /* new interface */
116 #define OPTION_IOMODES 0x00000003 /* cover both interfaces */
117 #define OPTION_PLANETS 0x00000004 /* planets and mining */
118 #define OPTION_THOLIAN 0x00000008 /* Tholians and their webs */
119 #define OPTION_THINGY 0x00000010 /* Space Thingy can shoot back */
120 #define OPTION_PROBE 0x00000020 /* deep-space probes */
121 #define OPTION_SHOWME 0x00000040 /* bracket Enterprise in chart */
122 #define OPTION_RAMMING 0x00000080 /* enemies may ram Enterprise */
123 #define OPTION_MVBADDY 0x00000100 /* more enemies can move */
124 #define OPTION_BLKHOLE 0x00000200 /* black hole may timewarp you */
125 #define OPTION_BASE 0x00000400 /* bases have good shields */
126 #define OPTION_WORLDS 0x00000800 /* logic for inhabited worlds */
127 #define OPTION_PLAIN 0x01000000 /* user chose plain game */
128 #define OPTION_ALMY 0x02000000 /* user chose Almy variant */
144 #define DDRAY 13 // Added deathray
145 #define DDSP 14 // Added deep space probe
146 #define NDEVICES (15) // Number of devices
150 /* Define future events */
151 #define FSPY 0 // Spy event happens always (no future[] entry)
152 // can cause SC to tractor beam Enterprise
153 #define FSNOVA 1 // Supernova
154 #define FTBEAM 2 // Commander tractor beams Enterprise
155 #define FSNAP 3 // Snapshot for time warp
156 #define FBATTAK 4 // Commander attacks base
157 #define FCDBAS 5 // Commander destroys base
158 #define FSCMOVE 6 // Supercommander moves (might attack base)
159 #define FSCDBAS 7 // Supercommander destroys base
160 #define FDSPROB 8 // Move deep space probe
163 #else /* EXPERIMENTAL */
164 #define FDISTR 9 // Emit distress call from an inhabited world
165 #define FENSLV 10 // Inhabited word is enslaved */
166 #define FREPRO 11 // Klingons build a ship in an enslaved system
168 #endif /* EXPERIMENTAL */
171 * abstract out the event handling -- underlying data structures will change
172 * when we implement stateful events
174 extern void unschedule(int);
175 extern int is_scheduled(int);
176 extern void schedule(int, double);
177 extern void postpone(int, double);
178 extern double scheduled(int);
181 #define MAXDISTR 5 /* maximum concurrent distress calls */
182 #endif /* EXPERIMENTAL */
184 #define SSTMAGIC "SST2.0\n"
187 char magic[sizeof(SSTMAGIC)];
188 unsigned long options;
191 char quad[QUADSIZE+1][QUADSIZE+1]; // contents of our quadrant
192 double kpower[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy energy levels
193 double kdist[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy distances
194 double kavgd[(QUADSIZE+1)*(QUADSIZE+1)]; // average distances
195 double damage[NDEVICES]; // damage encountered
196 double future[NEVENTS]; // future events
197 char passwd[10]; // Self Destruct password
198 coord ks[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy sector locations
199 coord quadrant, sector; // where we are
200 coord tholian; // coordinates of Tholian
201 coord base; // position of base in current quadrant
202 coord battle; // base coordinates being attacked
203 coord plnet; // location of planet in quadrant
204 coord probec; // current probe quadrant
205 bool gamewon, // Finished!
206 ididit, // Action taken -- allows enemy to attack
207 alive, // We are alive (not killed)
208 justin, // just entered quadrant
209 alldone, // game is now finished
210 neutz, // Romulan Neutral Zone
211 isatb, // =1 if super commander is attacking base
212 isarmed, // probe is armed
213 thawed, // thawed game
214 iscate; // super commander is here
215 int inkling, // Initial number of klingons
216 inbase, // Initial number of bases
217 incom, // Initial number of commanders
218 inscom, // Initial number of commanders
219 inrom, // Initial number of commanders
220 instar, // Initial stars
221 intorps, // Initial/Max torpedoes
222 condit, // Condition (red/yellow/green/docked)
223 torps, // number of torpedoes
224 ship, // Ship type -- 'E' is Enterprise
225 length, // length of game
226 skill, // skill level
227 klhere, // klingons here
228 comhere, // commanders here
229 casual, // causalties
230 nhelp, // calls for help
231 nkinks, // count of energy-barrier crossings
232 shldchg, // shield is changing (affects efficiency)
234 landed, // party on planet (1), on ship (-1)
235 iplnet, // planet # in quadrant
237 inplan, // initial planets
238 nenhere, // number of enemies in quadrant
239 ishere, // super-commander in quandrant
240 irhere, // Romulans in quadrant
241 icraft, // Kirk in Galileo
242 ientesc, // attempted escape from supercommander
243 iscraft, // =1 if craft on ship, -1 if removed from game
245 idebug, // debug mode
247 iattak, // attack recursion elimination (was cracks[4])
248 icrystl, // dilithium crystals aboard
249 tourn, // tournament number
250 ithere, // Tholian is here
251 iseenit, // seen base attack report
253 ndistr, //* count of distress calls */
254 #endif /* EXPERIMENTAL */
255 proben, // number of moves for probe
256 nprobes; // number of probes available
257 double inresor, // initial resources
258 intime, // initial time
259 inenrg, // initial/max energy
260 inshld, // initial/max shield
261 inlsr, // initial life support resources
262 indate, // initial date
263 energy, // energy level
264 shield, // shield level
265 shldup, // shields are up
266 warpfac, // warp speed
267 wfacsq, // squared warp factor
268 lsupres, // life support reserves
269 dist, // movement distance
270 direc, // movement direction
271 optime, // time taken by current operation
272 docfac, // repair factor when docking (constant?)
273 resting, // rest time
274 damfac, // damage factor
275 lastchart, // time star chart was last updated
276 cryprob, // probability that crystal will work
277 probex, // location of probe
279 probeinx, // probe x,y increment
281 height; // height of orbit around planet
283 extern struct game game;
285 /* the following global state doesn't need to be saved */
286 extern char *device[NDEVICES];
287 extern int iscore, iskill; // Common PLAQ
288 extern double perdate;
289 extern double aaitem;
290 extern char citem[10];
292 /* the Space Thingy's global state should *not* be saved! */
294 extern int iqhere, iqengry;
296 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
297 FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
298 FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
299 FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
301 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, coord w);
374 double expran(double);
376 void iran(int, int *, int *);
377 #define square(i) ((i)*(i))
378 void dropin(int, coord*);
382 void ram(int, int, coord);
383 void crmena(int, int, int, coord w);
384 void deadkl(coord, 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 *, bool);
418 void makechart(void);
419 void enqueue(char *);
420 char *systemname(planet *);
421 void newkling(int, coord *);
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