11 #define min(x, y) ((x)<(y)?(x):(y))
12 #define max(x, y) ((x)>(y)?(x):(y))
16 #define NDEVICES (15) // Number of devices
17 #define PHASEFAC (2.0)
22 int x; /* Quadrant location of planet */
24 enum {M=0, N=1, O=2} pclass;
25 int crystals; /* has crystals */
26 enum {unknown, known, shuttle_down} known;
29 #define DESTROY(pl) memset(pl, '\0', sizeof(planet))
32 int snap, // snapshot taken
33 remkl, // remaining klingons
34 remcom, // remaining commanders
35 rembase, // remaining bases
36 starkl, // destroyed stars
37 basekl, // destroyed bases
38 killk, // Klingons killed
39 killc, // commanders killed
40 galaxy[9][9], // The Galaxy (subscript 0 not used)
41 cx[11],cy[11], // Commander quadrant coordinates
42 baseqx[6], // Base quadrant X
43 baseqy[6], // Base quadrant Y
44 newstuf[9][9], // Extended galaxy goodies
45 isx, isy, // Coordinate of Super Commander
46 nscrem, // remaining super commanders
47 nromkl, // Romulans killed
48 nromrem, // Romulans remaining
49 nsckill, // super commanders killed
50 nplankl; // destroyed planets
51 planet plnets[PLNETMAX]; // Planet information
52 double date, // stardate
53 remres, // remaining resources
54 remtime; // remaining time
55 } snapshot; // Data that is snapshot
57 // Scalar variables that are needed for freezing the game
58 // are placed in a structure. #defines are used to access by their
59 // original names. Gee, I could have done this with the d structure,
60 // but I just didn't think of it back when I started.
62 #define SSTMAGIC "SST2.0\n"
67 char magic[sizeof(SSTMAGIC)];
70 char quad[11][11]; // contents of our quadrant
71 double kpower[21]; // enemy energy levels
72 double kdist[21]; // enemy distances
73 double kavgd[21]; // average distances
74 double damage[NDEVICES+1]; // damage encountered
75 double future[NEVENTS+1]; // future events
76 char passwd[10]; // Self Destruct password
77 int kx[21]; // enemy sector locations
79 int starch[9][9]; // star chart
80 /* members with macro definitions start here */
172 #define inkling game.inkling // Initial number of klingons
173 #define inbase game.inbase // Initial number of bases
174 #define incom game.incom // Initian number of commanders
175 #define instar game.instar // Initial stars
176 #define intorps game.intorps // Initial/Max torpedoes
177 #define condit game.condit // Condition (red, yellow, green docked)
178 #define torps game.torps // number of torpedoes
179 #define ship game.ship // Ship type -- 'E' is Enterprise
180 #define quadx game.quadx // where we are
181 #define quady game.quady //
182 #define sectx game.sectx // where we are
183 #define secty game.secty //
184 #define length game.length // length of game
185 #define skill game.skill // skill level
186 #define basex game.basex // position of base in current quad
187 #define basey game.basey //
188 #define klhere game.klhere // klingons here
189 #define comhere game.comhere // commanders here
190 #define casual game.casual // causalties
191 #define nhelp game.nhelp // calls for help
192 #define nkinks game.nkinks //
193 #define ididit game.ididit // Action taken -- allows enemy to attack
194 #define gamewon game.gamewon // Finished!
195 #define alive game.alive // We are alive (not killed)
196 #define justin game.justin // just entered quadrant
197 #define alldone game.alldone // game is now finished
198 #define shldchg game.shldchg // shield is changing (affects efficiency)
199 #define thingx game.thingx // location of strange object in galaxy
200 #define thingy game.thingy //
201 #define plnetx game.plnetx // location of planet in quadrant
202 #define plnety game.plnety //
203 #define inorbit game.inorbit // orbiting
204 #define landed game.landed // party on planet (1), on ship (-1)
205 #define iplnet game.iplnet // planet # in quadrant
206 #define imine game.imine // mining
207 #define inplan game.inplan // initial planets
208 #define nenhere game.nenhere // Number of enemies in quadrant
209 #define ishere game.ishere // Super-commander in quandrant
210 #define neutz game.neutz // Romulan Neutral Zone
211 #define irhere game.irhere // Romulans in quadrant
212 #define iqhere game.iqhere // Thing in quadrant
213 #define iqengry game.iqengry // Thing attacking
214 #define icraft game.icraft // Kirk in Galileo
215 #define ientesc game.ientesc // Attempted escape from supercommander
216 #define iscraft game.iscraft // =1 if craft on ship, -1 if removed from game
217 #define isatb game.isatb // =1 if SuperCommander is attacking base
218 #define iscate game.iscate // Super Commander is here
220 #define idebug game.idebug // Debug mode
222 #define iattak game.iattak // attack recursion elimination (was cracks[4])
223 #define icrystl game.icrystl // dilithium crystals aboard
224 #define tourn game.tourn // Tournament number
225 #define thawed game.thawed // Thawed game
226 #define batx game.batx // Base coordinates being attacked
227 #define baty game.baty //
228 #define ithere game.ithere // Tholean is here
229 #define ithx game.ithx // coordinates of tholean
230 #define ithy game.ithy
231 #define iseenit game.iseenit // Seen base attack report
232 #define inresor game.inresor // initial resources
233 #define intime game.intime // initial time
234 #define inenrg game.inenrg // Initial/Max Energy
235 #define inshld game.inshld // Initial/Max Shield
236 #define inlsr game.inlsr // initial life support resources
237 #define indate game.indate // Initial date
238 #define energy game.energy // Energy level
239 #define shield game.shield // Shield level
240 #define shldup game.shldup // Shields are up
241 #define warpfac game.warpfac // Warp speed
242 #define wfacsq game.wfacsq // squared warp factor
243 #define lsupres game.lsupres // life support reserves
244 #define dist game.dist // movement distance
245 #define direc game.direc // movement direction
246 #define Time game.Time // time taken by current operation
247 #define docfac game.docfac // repair factor when docking (constant?)
248 #define resting game.resting // rest time
249 #define damfac game.damfac // damage factor
250 #define stdamtim game.stdamtim // time that star chart was damaged
251 #define cryprob game.cryprob // probability that crystal will work
252 #define probex game.probex // location of probe
253 #define probey game.probey
254 #define probecx game.probecx // current probe quadrant
255 #define probecy game.probecy
256 #define probeinx game.probeinx // Probe x,y increment
257 #define probeiny game.probeiny
258 #define proben game.proben // number of moves for probe
259 #define isarmed game.isarmed // Probe is armed
260 #define nprobes game.nprobes // number of probes available
262 /* the following global state doesn't need to be saved */
263 EXTERN char *device[NDEVICES+1];
264 EXTERN int iscore, iskill; // Common PLAQ
265 EXTERN double perdate;
266 EXTERN double aaitem;
267 EXTERN char citem[10];
269 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
270 FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
271 FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
272 FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
274 enum loctype {neither, quadrant, sector};
290 #define DDRAY 14 // Added deathray
291 #define DDSP 15 // Added deep space probe
293 /* Define future events */
294 #define FSPY 0 // Spy event happens always (no future[] entry)
295 // can cause SC to tractor beam Enterprise
296 #define FSNOVA 1 // Supernova
297 #define FTBEAM 2 // Commander tractor beams Enterprise
298 #define FSNAP 3 // Snapshot for time warp
299 #define FBATTAK 4 // Commander attacks base
300 #define FCDBAS 5 // Commander destroys base
301 #define FSCMOVE 6 // Supercommander moves (might attack base)
302 #define FSCDBAS 7 // Supercommander destroys base
303 #define FDSPROB 8 // Move deep space probe
306 char *device[NDEVICES+1] = {
354 /* Function prototypes */
378 void finish(FINTYPE);
391 void prout(char *, ...);
392 void proutn(char *, ...);
398 char *cramlc(enum loctype, int, int);
399 double expran(double);
401 void iran8(int *, int *);
402 void iran10(int *, int *);
403 #define square(i) ((i)*(i))
404 void dropin(int, int*, int*);
408 void ram(int, int, int, int);
409 void crmena(int, int, int, int, int);
410 void deadkl(int, int, int, int, int);
413 void torpedo(double, double, int, int, double *, int);
415 void pause_game(int);
417 void snova(int, int);
419 void hittem(double *);
420 void prouts(char *, ...);
426 void drawmaps(short);
429 void usecrystals(void);
433 void attakreport(int);
440 void getline(char *, int);
442 void setpassword(void);
443 void commandhook(char *, int);
446 int wndleft,wndtop,wndright,wndbottom;
449 /* these need to track io.c:wnd */
450 #define FULLSCREEN_WINDOW 0
451 #define LEFTUPPER_WINDOW 1
452 #define SRSCAN_WINDOW 2
453 #define LRSCAN_WINDOW 3
454 #define LOWER_WINDOW 4
455 #define BOTTOM_WINDOW 5