]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - trek/trek.h
1 /* $NetBSD: trek.h,v 1.11 2005/02/15 12:54:50 jsm Exp $ */
4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * @(#)trek.h 8.1 (Berkeley) 5/31/93
35 ** Global Declarations
37 ** Virtually all non-local variable declarations are made in this
38 ** file. Exceptions are those things which are initialized, which
39 ** are defined in "externs.c", and things which are local to one
42 ** So far as I know, nothing in here must be preinitialized to
46 /* external function definitions */
48 /********************* GALAXY **************************/
50 /* galactic parameters */
51 # define NSECTS 10 /* dimensions of quadrant in sectors */
52 # define NQUADS 8 /* dimension of galazy in quadrants */
53 # define NINHAB 32 /* number of quadrants which are inhabited */
55 struct quad
/* definition for each quadrant */
57 unsigned char bases
; /* number of bases in this quadrant */
58 char klings
; /* number of Klingons in this quadrant */
59 char holes
; /* number of black holes in this quadrant */
60 int scanned
; /* star chart entry (see below) */
61 short stars
; /* number of stars in this quadrant */
62 char qsystemname
; /* starsystem name (see below) */
65 # define Q_DISTRESSED 0200
68 /* systemname conventions:
69 * 1 -> NINHAB index into Systemname table for live system.
70 * + Q_DISTRESSED distressed starsystem -- systemname & Q_SYSTEM
71 * is the index into the Event table which will
72 * have the system name
73 * 0 dead or nonexistent starsystem
75 * starchart ("scanned") conventions:
76 * 0 -> 999 taken as is
77 * -1 not yet scanned ("...")
78 * 1000 supernova ("///")
79 * 1001 starbase + ??? (".1.")
82 /* ascii names of systems */
83 extern const char *const Systemname
[NINHAB
];
85 /* quadrant definition */
86 extern struct quad Quad
[NQUADS
][NQUADS
];
88 /* defines for sector map (below) */
92 # define ENTERPRISE 'E'
98 /* current sector map */
99 extern char Sect
[NSECTS
][NSECTS
];
103 /************************ DEVICES ******************************/
105 # define NDEV 16 /* max number of devices */
108 # define WARP 0 /* warp engines */
109 # define SRSCAN 1 /* short range scanners */
110 # define LRSCAN 2 /* long range scanners */
111 # define PHASER 3 /* phaser control */
112 # define TORPED 4 /* photon torpedo control */
113 # define IMPULSE 5 /* impulse engines */
114 # define SHIELD 6 /* shield control */
115 # define COMPUTER 7 /* on board computer */
116 # define SSRADIO 8 /* subspace radio */
117 # define LIFESUP 9 /* life support systems */
118 # define SINS 10 /* Space Inertial Navigation System */
119 # define CLOAK 11 /* cloaking device */
120 # define XPORTER 12 /* transporter */
121 # define SHUTTLE 13 /* shuttlecraft */
126 const char *name
; /* device name */
127 const char *person
; /* the person who fixes it */
130 extern const struct device Device
[NDEV
];
132 /*************************** EVENTS ****************************/
134 # define NEVENTS 12 /* number of different event types */
136 # define E_LRTB 1 /* long range tractor beam */
137 # define E_KATSB 2 /* Klingon attacks starbase */
138 # define E_KDESB 3 /* Klingon destroys starbase */
139 # define E_ISSUE 4 /* distress call is issued */
140 # define E_ENSLV 5 /* Klingons enslave a quadrant */
141 # define E_REPRO 6 /* a Klingon is reproduced */
142 # define E_FIXDV 7 /* fix a device */
143 # define E_ATTACK 8 /* Klingon attack during rest period */
144 # define E_SNAP 9 /* take a snapshot for time warp */
145 # define E_SNOVA 10 /* supernova occurs */
147 # define E_GHOST 0100 /* ghost of a distress call if ssradio out */
148 # define E_HIDDEN 0200 /* event that is unreportable because ssradio out */
149 # define E_EVENT 077 /* mask to get event code */
153 unsigned char x
, y
; /* coordinates */
154 double date
; /* trap stardate */
155 char evcode
; /* event type */
156 unsigned char systemname
; /* starsystem name */
158 /* systemname conventions:
159 * 1 -> NINHAB index into Systemname table for reported distress calls
161 * evcode conventions:
162 * 1 -> NEVENTS-1 event type
163 * + E_HIDDEN unreported (SSradio out)
164 * + E_GHOST actually already expired
168 # define MAXEVENTS 25 /* max number of concurrently pending events */
170 extern struct event Event
[MAXEVENTS
]; /* dynamic event list; one entry per pending event */
172 /***************************** KLINGONS *******************************/
176 unsigned char x
, y
; /* coordinates */
177 int power
; /* power left */
178 double dist
; /* distance to Enterprise */
179 double avgdist
; /* average over this move */
180 char srndreq
; /* set if surrender has been requested */
183 # define MAXKLQUAD 9 /* maximum klingons per quadrant */
185 /********************** MISCELLANEOUS ***************************/
187 /* condition codes */
193 /* starbase coordinates */
194 # define MAXBASES 9 /* maximum number of starbases in galaxy */
197 # define MAXDISTR 5 /* maximum concurrent distress calls */
200 # define NBANKS 6 /* number of phaser banks */
204 unsigned char x
, y
; /* coordinates */
209 * note that much of the stuff in the following structs CAN NOT
210 * be moved around!!!!
214 /* information regarding the state of the starship */
217 double warp
; /* warp factor */
218 double warp2
; /* warp factor squared */
219 double warp3
; /* warp factor cubed */
220 char shldup
; /* shield up flag */
221 char cloaked
; /* set if cloaking device on */
222 int energy
; /* starship's energy */
223 int shield
; /* energy in shields */
224 double reserves
; /* life support reserves */
225 int crew
; /* ship's complement */
226 int brigfree
; /* space left in brig */
227 char torped
; /* torpedoes */
228 char cloakgood
; /* set if we have moved */
229 int quadx
; /* quadrant x coord */
230 int quady
; /* quadrant y coord */
231 int sectx
; /* sector x coord */
232 int secty
; /* sector y coord */
233 unsigned char cond
; /* condition code */
234 char sinsbad
; /* Space Inertial Navigation System condition */
235 const char *shipname
; /* name of current starship */
236 char ship
; /* current starship */
237 int distressed
; /* number of distress calls */
239 extern struct Ship_struct Ship
;
241 /* sinsbad is set if SINS is working but not calibrated */
243 /* game related information, mostly scoring */
246 int killk
; /* number of klingons killed */
247 int deaths
; /* number of deaths onboard Enterprise */
248 char negenbar
; /* number of hits on negative energy barrier */
249 char killb
; /* number of starbases killed */
250 int kills
; /* number of stars killed */
251 char skill
; /* skill rating of player */
252 char length
; /* length of game */
253 char killed
; /* set if you were killed */
254 char killinhab
; /* number of inhabited starsystems killed */
255 char tourn
; /* set if a tournament game */
256 char passwd
[15]; /* game password */
257 char snap
; /* set if snapshot taken */
258 char helps
; /* number of help calls */
259 int captives
; /* total number of captives taken */
261 extern struct Game_struct Game
;
263 /* per move information */
266 char free
; /* set if a move is free */
267 char endgame
; /* end of game flag */
268 char shldchg
; /* set if shields changed this move */
269 char newquad
; /* set if just entered this quadrant */
270 char resting
; /* set if this move is a rest */
271 double time
; /* time used this move */
273 extern struct Move_struct Move
;
275 /* parametric information */
278 unsigned char bases
; /* number of starbases */
279 char klings
; /* number of klingons */
280 double date
; /* stardate */
281 double time
; /* time left */
282 double resource
; /* Federation resources */
283 int energy
; /* starship's energy */
284 int shield
; /* energy in shields */
285 double reserves
; /* life support reserves */
286 int crew
; /* size of ship's complement */
287 int brigfree
; /* max possible number of captives */
288 char torped
; /* photon torpedos */
289 double damfac
[NDEV
]; /* damage factor */
290 double dockfac
; /* docked repair time factor */
291 double regenfac
; /* regeneration factor */
292 int stopengy
; /* energy to do emergency stop */
293 int shupengy
; /* energy to put up shields */
294 int klingpwr
; /* Klingon initial power */
295 int warptime
; /* time chewer multiplier */
296 double phasfac
; /* Klingon phaser power eater factor */
297 char moveprob
[6]; /* probability that a Klingon moves */
298 double movefac
[6]; /* Klingon move distance multiplier */
299 double eventdly
[NEVENTS
]; /* event time multipliers */
300 double navigcrud
[2]; /* navigation crudup factor */
301 int cloakenergy
; /* cloaking device energy per stardate */
302 double damprob
[NDEV
]; /* damage probability */
303 double hitfac
; /* Klingon attack factor */
304 int klingcrew
; /* number of Klingons in a crew */
305 double srndrprob
; /* surrender probability */
306 int energylow
; /* low energy mark (cond YELLOW) */
308 extern struct Param_struct Param
;
310 /* Sum of damage probabilities must add to 1000 */
312 /* other information kept in a snapshot */
315 unsigned char bases
; /* number of starbases */
316 char klings
; /* number of klingons */
317 double date
; /* stardate */
318 double time
; /* time left */
319 double resource
; /* Federation resources */
320 char distressed
; /* number of currently distressed quadrants */
321 struct event
*eventptr
[NEVENTS
]; /* pointer to event structs */
322 struct xy base
[MAXBASES
]; /* locations of starbases */
324 extern struct Now_struct Now
;
326 /* Other stuff, not dumped in a snapshot */
329 struct kling klingon
[MAXKLQUAD
]; /* sorted Klingon list */
330 short nkling
; /* number of Klingons in this sector */
331 /* < 0 means automatic override mode */
332 char fast
; /* set if speed > 300 baud */
333 struct xy starbase
; /* starbase in current quadrant */
334 char snapshot
[sizeof Quad
+ sizeof Event
+ sizeof Now
]; /* snapshot for time warp */
335 char statreport
; /* set to get a status report on a srscan */
337 extern struct Etc_struct Etc
;
340 * eventptr is a pointer to the event[] entry of the last
341 * scheduled event of each type. Zero if no such event scheduled.
344 /* Klingon move indicies */
345 # define KM_OB 0 /* Old quadrant, Before attack */
346 # define KM_OA 1 /* Old quadrant, After attack */
347 # define KM_EB 2 /* Enter quadrant, Before attack */
348 # define KM_EA 3 /* Enter quadrant, After attack */
349 # define KM_LB 4 /* Leave quadrant, Before attack */
350 # define KM_LA 5 /* Leave quadrant, After attack */
353 # define L_NOTIME 1 /* ran out of time */
354 # define L_NOENGY 2 /* ran out of energy */
355 # define L_DSTRYD 3 /* destroyed by a Klingon */
356 # define L_NEGENB 4 /* ran into the negative energy barrier */
357 # define L_SUICID 5 /* destroyed in a nova */
358 # define L_SNOVA 6 /* destroyed in a supernova */
359 # define L_NOLIFE 7 /* life support died (so did you) */
360 # define L_NOHELP 8 /* you could not be rematerialized */
361 # define L_TOOFAST 9 /* pretty stupid going at warp 10 */
362 # define L_STAR 10 /* ran into a star */
363 # define L_DSTRCT 11 /* self destructed */
364 # define L_CAPTURED 12 /* captured by Klingons */
365 # define L_NOCREW 13 /* you ran out of crew */
367 /****************** COMPILE OPTIONS ***********************/
384 struct kling
*selectklingon(void);
393 void checkcond(void);
396 void compkldist(int);
402 void damage(int, double);
419 int restartgame(void);
425 int dumpssradio(void);
433 int getcodi(int *, double *);
443 void sector(int *, int *);
446 void killk(int, int );
447 void killb(int, int );
448 void kills(int, int , int);
449 void killd(int, int , int);
455 void lose(int) __attribute__((__noreturn__
));
461 double move(int, int, double, double);
464 void nova(int, int );
473 void myreset(int) __attribute__((__noreturn__
));
474 void play(void) __attribute__((__noreturn__
));
487 struct event
*schedule(int, double, int, int , int);
488 void reschedule(struct event
*, double);
489 void unschedule(struct event
*);
490 struct event
*xsched(int, int, int, int , int );
491 void xresched(struct event
*, int, int);
506 void snova(int, int );
512 const char *systemname(const struct quad
*);
522 void warp(int, int, double);
525 void win(void) __attribute__((__noreturn__
));