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))
23 #define PHASEFAC (2.0)
25 #define NINHAB (GALSIZE * GALSIZE / 2)
26 #define MAXUNINHAB (10)
27 #define PLNETMAX (NINHAB + MAXUNINHAB)
32 * These macros hide the difference between 0-origin and 1-origin addressing.
33 * They're a step towards de-FORTRANizing the code.
35 #define VALID_QUADRANT(x, y) ((x)>=1 && (x)<=GALSIZE && (y)>=1 && (y)<=GALSIZE)
36 #define VALID_SECTOR(x, y) ((x)>=1 && (x)<=QUADSIZE && (y)>=1 && (y)<=QUADSIZE)
37 #define for_quadrants(i) for (i = 1; i <= GALSIZE; i++)
38 #define for_sectors(i) for (i = 1; i <= QUADSIZE; i++)
39 #define for_commanders(i) for (i = 1; i <= game.state.remcom; i++)
40 #define for_local_enemies(i) for (i = 1; i <= game.nenhere; i++)
41 #define for_starbases(i) for (i = 1; i <= game.state.rembase; i++)
43 typedef struct {int x; int y;} coord;
45 #define same(c1, c2) (c1.x == c2.x && c1.y == c2.y)
49 enum {M=0, N=1, O=2} pclass;
50 int inhabited; /* if NZ, an index into a name array */
51 #define UNINHABITED -1
52 int crystals; /* has crystals */
53 #define MINED -1 /* used to have crystals, but they were mined out */
54 enum {unknown, known, shuttle_down} known;
57 #define DESTROY(pl) memset(pl, '\0', sizeof(planet))
60 int snap, // snapshot taken
61 remkl, // remaining klingons
62 remcom, // remaining commanders
63 nscrem, // remaining super commanders
64 rembase, // remaining bases
65 starkl, // destroyed stars
66 basekl, // destroyed bases
67 nromrem, // Romulans remaining
68 nplankl, // destroyed uninhabited planets
69 nworldkl; // destroyed inhabited planets
70 planet plnets[PLNETMAX]; // Planet information
71 double date, // stardate
72 remres, // remaining resources
73 remtime; // remaining time
74 coord baseq[BASEMAX+1]; // Base quadrant coordinates
75 coord kcmdr[QUADSIZE+1]; // Commander quadrant coordinates
76 coord kscmdr; // Supercommander quadrant coordinates
86 enum {secure, distressed, enslaved} status;
87 } galaxy[GALSIZE+1][GALSIZE+1]; // The Galaxy (subscript 0 not used)
92 } chart[GALSIZE+1][GALSIZE+1]; // the starchart (subscript 0 not used)
93 } snapshot; // Data that is snapshot
98 #define NKILLK (game.inkling - game.state.remkl)
99 #define NKILLC (game.incom - game.state.remcom)
100 #define NKILLSC (game.inscom - game.state.nscrem)
101 #define NKILLROM (game.inrom - game.state.nromrem)
102 #define KLINGREM (game.state.remkl + game.state.remcom + game.state.nscrem)
103 #define INKLINGTOT (game.inkling + game.incom + game.inscom)
104 #define KLINGKILLED (INKLINGTOT - KLINGREM)
107 #define SKILL_NOVICE 1
110 #define SKILL_EXPERT 4
111 #define SKILL_EMERITUS 5
114 #define OPTION_ALL 0xffffffff
115 #define OPTION_TTY 0x00000001 /* old interface */
116 #define OPTION_CURSES 0x00000002 /* new interface */
117 #define OPTION_IOMODES 0x00000003 /* cover both interfaces */
118 #define OPTION_PLANETS 0x00000004 /* planets and mining */
119 #define OPTION_THOLIAN 0x00000008 /* Tholians and their webs */
120 #define OPTION_THINGY 0x00000010 /* Space Thingy can shoot back */
121 #define OPTION_PROBE 0x00000020 /* deep-space probes */
122 #define OPTION_SHOWME 0x00000040 /* bracket Enterprise in chart */
123 #define OPTION_RAMMING 0x00000080 /* enemies may ram Enterprise */
124 #define OPTION_MVBADDY 0x00000100 /* more enemies can move */
125 #define OPTION_BLKHOLE 0x00000200 /* black hole may timewarp you */
126 #define OPTION_BASE 0x00000400 /* bases have good shields */
127 #define OPTION_WORLDS 0x00000800 /* logic for inhabited worlds */
128 #define OPTION_PLAIN 0x01000000 /* user chose plain game */
129 #define OPTION_ALMY 0x02000000 /* user chose Almy variant */
145 #define DDRAY 13 // Added deathray
146 #define DDSP 14 // Added deep space probe
147 #define NDEVICES (15) // Number of devices
151 /* Define future events */
152 #define FSPY 0 // Spy event happens always (no future[] entry)
153 // can cause SC to tractor beam Enterprise
154 #define FSNOVA 1 // Supernova
155 #define FTBEAM 2 // Commander tractor beams Enterprise
156 #define FSNAP 3 // Snapshot for time warp
157 #define FBATTAK 4 // Commander attacks base
158 #define FCDBAS 5 // Commander destroys base
159 #define FSCMOVE 6 // Supercommander moves (might attack base)
160 #define FSCDBAS 7 // Supercommander destroys base
161 #define FDSPROB 8 // Move deep space probe
162 #define FDISTR 9 // Emit distress call from an inhabited world
163 #define FENSLV 10 // Inhabited word is enslaved */
164 #define FREPRO 11 // Klingons build a ship in an enslaved system
173 * abstract out the event handling -- underlying data structures will change
174 * when we implement stateful events
176 extern event *unschedule(int);
177 extern int is_scheduled(int);
178 extern event *schedule(int, double);
179 extern void postpone(int, double);
180 extern double scheduled(int);
181 #define findevent(evtype) &game.future[evtype]
183 #define SSTMAGIC "SST2.0\n"
186 char magic[sizeof(SSTMAGIC)];
187 unsigned long options;
190 char quad[QUADSIZE+1][QUADSIZE+1]; // contents of our quadrant
191 double kpower[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy energy levels
192 double kdist[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy distances
193 double kavgd[(QUADSIZE+1)*(QUADSIZE+1)]; // average distances
194 double damage[NDEVICES]; // damage encountered
195 event future[NEVENTS]; // future events
196 char passwd[10]; // Self Destruct password
197 coord ks[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy sector locations
198 coord quadrant, sector; // where we are
199 coord tholian; // coordinates of Tholian
200 coord base; // position of base in current quadrant
201 coord battle; // base coordinates being attacked
202 coord plnet; // location of planet in quadrant
203 coord probec; // current probe quadrant
204 bool gamewon, // Finished!
205 ididit, // action taken -- allows enemy to attack
206 alive, // we are alive (not killed)
207 justin, // just entered quadrant
208 shldup, // shields are up
209 resting, // rest time
210 alldone, // game is now finished
211 neutz, // Romulan Neutral Zone
212 isarmed, // probe is armed
213 inorbit, // orbiting a planet
214 thawed; // thawed game
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)
233 landed, // party on planet (1), on ship (-1)
234 iplnet, // planet # in quadrant
236 inplan, // initial planets
237 nenhere, // number of enemies in quadrant
238 ishere, // super-commander in quandrant
239 irhere, // Romulans in quadrant
240 icraft, // Kirk in Galileo
241 ientesc, // attempted escape from supercommander
242 iscraft, // =1 if craft on ship, -1 if removed from game
243 isatb, // =1 if super commander is attacking base
244 iscate, // super commander is here
245 iattak, // attack recursion elimination (was cracks[4])
246 icrystl, // dilithium crystals aboard
247 tourn, // tournament number
248 ithere, // Tholian is here
249 iseenit, // seen base attack report
250 proben, // number of moves for probe
251 nprobes; // number of probes available
252 double inresor, // initial resources
253 intime, // initial time
254 inenrg, // initial/max energy
255 inshld, // initial/max shield
256 inlsr, // initial life support resources
257 indate, // initial date
258 energy, // energy level
259 shield, // shield level
260 warpfac, // warp speed
261 wfacsq, // squared warp factor
262 lsupres, // life support reserves
263 dist, // movement distance
264 direc, // movement direction
265 optime, // time taken by current operation
266 docfac, // repair factor when docking (constant?)
267 damfac, // damage factor
268 lastchart, // time star chart was last updated
269 cryprob, // probability that crystal will work
270 probex, // location of probe
272 probeinx, // probe x,y increment
274 height; // height of orbit around planet
276 extern struct game game;
278 /* the following global state doesn't need to be saved */
279 extern char *device[NDEVICES];
280 extern int iscore, iskill; // Common PLAQ
281 extern double perdate;
282 extern double aaitem;
283 extern char citem[10];
286 extern FILE *logfp, *replayfp;
288 /* the Space Thingy's global state should *not* be saved! */
290 extern int iqhere, iqengry;
292 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
293 FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
294 FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
295 FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
297 enum loctype {neither, quadrant, sector};
324 /* Function prototypes */
349 void finish(FINTYPE);
362 void prout(char *, ...);
363 void proutn(char *, ...);
369 char *cramlc(enum loctype, coord w);
370 double expran(double);
372 void iran(int, int *, int *);
373 #define square(i) ((i)*(i))
374 void dropin(int, coord*);
378 void ram(int, int, coord);
379 void crmena(int, int, int, coord w);
380 void deadkl(coord, int, int, int);
383 void torpedo(double, double, int, int, double *, int, int);
385 void pause_game(int);
387 void snova(int, int);
389 void hittem(double *);
390 void prouts(char *, ...);
395 void drawmaps(short);
398 void usecrystals(void);
402 void attakreport(int);
406 void setwnd(WINDOW *);
408 void boom(int ii, int jj);
409 void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad);
410 void cgetline(char *, int);
412 void setpassword(void);
413 void commandhook(char *, bool);
414 void makechart(void);
415 void enqueue(char *);
416 char *systemname(int);
417 void newkling(int, coord *);
419 /* mode arguments for srscan() */
421 #define SCAN_REQUEST 2
422 #define SCAN_STATUS 3
423 #define SCAN_NO_LEFTSIDE 4
425 extern WINDOW *curwnd;
426 extern WINDOW *fullscreen_window;
427 extern WINDOW *srscan_window;
428 extern WINDOW *report_window;
429 extern WINDOW *lrscan_window;
430 extern WINDOW *message_window;
431 extern WINDOW *prompt_window;
433 extern void clreol(void);
434 extern void clrscr(void);
435 extern void textcolor(int color);
436 extern void highvideo(void);
440 BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
441 DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE