]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - trek/trek.h
1 /* $NetBSD: trek.h,v 1.6 1999/07/21 13:19:11 hubertf 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. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * @(#)trek.h 8.1 (Berkeley) 5/31/93
39 ** Global Declarations
41 ** Virtually all non-local variable declarations are made in this
42 ** file. Exceptions are those things which are initialized, which
43 ** are defined in "externs.c", and things which are local to one
46 ** So far as I know, nothing in here must be preinitialized to
49 ** You may have problems from the loader if you move this to a
50 ** different machine. These things actually get allocated in each
51 ** source file, which UNIX allows; however, you may (on other
52 ** systems) have to change everything in here to be "extern" and
53 ** actually allocate stuff in "externs.c"
56 /* external function definitions */
58 /********************* GALAXY **************************/
60 /* galactic parameters */
61 # define NSECTS 10 /* dimensions of quadrant in sectors */
62 # define NQUADS 8 /* dimension of galazy in quadrants */
63 # define NINHAB 32 /* number of quadrants which are inhabited */
65 struct quad
/* definition for each quadrant */
67 unsigned char bases
; /* number of bases in this quadrant */
68 char klings
; /* number of Klingons in this quadrant */
69 char holes
; /* number of black holes in this quadrant */
70 int scanned
; /* star chart entry (see below) */
71 short stars
; /* number of stars in this quadrant */
72 char qsystemname
; /* starsystem name (see below) */
75 # define Q_DISTRESSED 0200
78 /* systemname conventions:
79 * 1 -> NINHAB index into Systemname table for live system.
80 * + Q_DISTRESSED distressed starsystem -- systemname & Q_SYSTEM
81 * is the index into the Event table which will
82 * have the system name
83 * 0 dead or nonexistent starsystem
85 * starchart ("scanned") conventions:
86 * 0 -> 999 taken as is
87 * -1 not yet scanned ("...")
88 * 1000 supernova ("///")
89 * 1001 starbase + ??? (".1.")
92 /* ascii names of systems */
93 extern const char *const Systemname
[NINHAB
];
95 /* quadrant definition */
96 struct quad Quad
[NQUADS
][NQUADS
];
98 /* defines for sector map (below) */
102 # define ENTERPRISE 'E'
108 /* current sector map */
109 char Sect
[NSECTS
][NSECTS
];
113 /************************ DEVICES ******************************/
115 # define NDEV 16 /* max number of devices */
118 # define WARP 0 /* warp engines */
119 # define SRSCAN 1 /* short range scanners */
120 # define LRSCAN 2 /* long range scanners */
121 # define PHASER 3 /* phaser control */
122 # define TORPED 4 /* photon torpedo control */
123 # define IMPULSE 5 /* impulse engines */
124 # define SHIELD 6 /* shield control */
125 # define COMPUTER 7 /* on board computer */
126 # define SSRADIO 8 /* subspace radio */
127 # define LIFESUP 9 /* life support systems */
128 # define SINS 10 /* Space Inertial Navigation System */
129 # define CLOAK 11 /* cloaking device */
130 # define XPORTER 12 /* transporter */
131 # define SHUTTLE 13 /* shuttlecraft */
136 const char *name
; /* device name */
137 const char *person
; /* the person who fixes it */
140 const struct device Device
[NDEV
];
142 /*************************** EVENTS ****************************/
144 # define NEVENTS 12 /* number of different event types */
146 # define E_LRTB 1 /* long range tractor beam */
147 # define E_KATSB 2 /* Klingon attacks starbase */
148 # define E_KDESB 3 /* Klingon destroys starbase */
149 # define E_ISSUE 4 /* distress call is issued */
150 # define E_ENSLV 5 /* Klingons enslave a quadrant */
151 # define E_REPRO 6 /* a Klingon is reproduced */
152 # define E_FIXDV 7 /* fix a device */
153 # define E_ATTACK 8 /* Klingon attack during rest period */
154 # define E_SNAP 9 /* take a snapshot for time warp */
155 # define E_SNOVA 10 /* supernova occurs */
157 # define E_GHOST 0100 /* ghost of a distress call if ssradio out */
158 # define E_HIDDEN 0200 /* event that is unreportable because ssradio out */
159 # define E_EVENT 077 /* mask to get event code */
163 unsigned char x
, y
; /* coordinates */
164 double date
; /* trap stardate */
165 char evcode
; /* event type */
166 unsigned char systemname
; /* starsystem name */
168 /* systemname conventions:
169 * 1 -> NINHAB index into Systemname table for reported distress calls
171 * evcode conventions:
172 * 1 -> NEVENTS-1 event type
173 * + E_HIDDEN unreported (SSradio out)
174 * + E_GHOST actually already expired
178 # define MAXEVENTS 25 /* max number of concurrently pending events */
180 struct event Event
[MAXEVENTS
]; /* dynamic event list; one entry per pending event */
182 /***************************** KLINGONS *******************************/
186 unsigned char x
, y
; /* coordinates */
187 int power
; /* power left */
188 double dist
; /* distance to Enterprise */
189 double avgdist
; /* average over this move */
190 char srndreq
; /* set if surrender has been requested */
193 # define MAXKLQUAD 9 /* maximum klingons per quadrant */
195 /********************** MISCELLANEOUS ***************************/
197 /* condition codes */
203 /* starbase coordinates */
204 # define MAXBASES 9 /* maximum number of starbases in galaxy */
207 # define MAXDISTR 5 /* maximum concurrent distress calls */
210 # define NBANKS 6 /* number of phaser banks */
214 unsigned char x
, y
; /* coordinates */
218 extern const struct cvntab Skitab
[];
219 extern const struct cvntab Lentab
[];
222 * note that much of the stuff in the following structs CAN NOT
223 * be moved around!!!!
227 /* information regarding the state of the starship */
230 double warp
; /* warp factor */
231 double warp2
; /* warp factor squared */
232 double warp3
; /* warp factor cubed */
233 char shldup
; /* shield up flag */
234 char cloaked
; /* set if cloaking device on */
235 int energy
; /* starship's energy */
236 int shield
; /* energy in shields */
237 double reserves
; /* life support reserves */
238 int crew
; /* ship's complement */
239 int brigfree
; /* space left in brig */
240 char torped
; /* torpedoes */
241 char cloakgood
; /* set if we have moved */
242 int quadx
; /* quadrant x coord */
243 int quady
; /* quadrant y coord */
244 int sectx
; /* sector x coord */
245 int secty
; /* sector y coord */
246 unsigned char cond
; /* condition code */
247 char sinsbad
; /* Space Inertial Navigation System condition */
248 const char *shipname
; /* name of current starship */
249 char ship
; /* current starship */
250 int distressed
; /* number of distress calls */
253 /* sinsbad is set if SINS is working but not calibrated */
255 /* game related information, mostly scoring */
258 int killk
; /* number of klingons killed */
259 int deaths
; /* number of deaths onboard Enterprise */
260 char negenbar
; /* number of hits on negative energy barrier */
261 char killb
; /* number of starbases killed */
262 int kills
; /* number of stars killed */
263 char skill
; /* skill rating of player */
264 char length
; /* length of game */
265 char killed
; /* set if you were killed */
266 char killinhab
; /* number of inhabited starsystems killed */
267 char tourn
; /* set if a tournament game */
268 char passwd
[15]; /* game password */
269 char snap
; /* set if snapshot taken */
270 char helps
; /* number of help calls */
271 int captives
; /* total number of captives taken */
274 /* per move information */
277 char free
; /* set if a move is free */
278 char endgame
; /* end of game flag */
279 char shldchg
; /* set if shields changed this move */
280 char newquad
; /* set if just entered this quadrant */
281 char resting
; /* set if this move is a rest */
282 double time
; /* time used this move */
285 /* parametric information */
288 unsigned char bases
; /* number of starbases */
289 char klings
; /* number of klingons */
290 double date
; /* stardate */
291 double time
; /* time left */
292 double resource
; /* Federation resources */
293 int energy
; /* starship's energy */
294 int shield
; /* energy in shields */
295 double reserves
; /* life support reserves */
296 int crew
; /* size of ship's complement */
297 int brigfree
; /* max possible number of captives */
298 char torped
; /* photon torpedos */
299 double damfac
[NDEV
]; /* damage factor */
300 double dockfac
; /* docked repair time factor */
301 double regenfac
; /* regeneration factor */
302 int stopengy
; /* energy to do emergency stop */
303 int shupengy
; /* energy to put up shields */
304 int klingpwr
; /* Klingon initial power */
305 int warptime
; /* time chewer multiplier */
306 double phasfac
; /* Klingon phaser power eater factor */
307 char moveprob
[6]; /* probability that a Klingon moves */
308 double movefac
[6]; /* Klingon move distance multiplier */
309 double eventdly
[NEVENTS
]; /* event time multipliers */
310 double navigcrud
[2]; /* navigation crudup factor */
311 int cloakenergy
; /* cloaking device energy per stardate */
312 double damprob
[NDEV
]; /* damage probability */
313 double hitfac
; /* Klingon attack factor */
314 int klingcrew
; /* number of Klingons in a crew */
315 double srndrprob
; /* surrender probability */
316 int energylow
; /* low energy mark (cond YELLOW) */
319 /* Sum of damage probabilities must add to 1000 */
321 /* other information kept in a snapshot */
324 unsigned char bases
; /* number of starbases */
325 char klings
; /* number of klingons */
326 double date
; /* stardate */
327 double time
; /* time left */
328 double resource
; /* Federation resources */
329 char distressed
; /* number of currently distressed quadrants */
330 struct event
*eventptr
[NEVENTS
]; /* pointer to event structs */
331 struct xy base
[MAXBASES
]; /* locations of starbases */
334 /* Other stuff, not dumped in a snapshot */
337 struct kling klingon
[MAXKLQUAD
]; /* sorted Klingon list */
338 short nkling
; /* number of Klingons in this sector */
339 /* < 0 means automatic override mode */
340 char fast
; /* set if speed > 300 baud */
341 struct xy starbase
; /* starbase in current quadrant */
342 char snapshot
[sizeof Quad
+ sizeof Event
+ sizeof Now
]; /* snapshot for time warp */
343 char statreport
; /* set to get a status report on a srscan */
347 * eventptr is a pointer to the event[] entry of the last
348 * scheduled event of each type. Zero if no such event scheduled.
351 /* Klingon move indicies */
352 # define KM_OB 0 /* Old quadrant, Before attack */
353 # define KM_OA 1 /* Old quadrant, After attack */
354 # define KM_EB 2 /* Enter quadrant, Before attack */
355 # define KM_EA 3 /* Enter quadrant, After attack */
356 # define KM_LB 4 /* Leave quadrant, Before attack */
357 # define KM_LA 5 /* Leave quadrant, After attack */
360 # define L_NOTIME 1 /* ran out of time */
361 # define L_NOENGY 2 /* ran out of energy */
362 # define L_DSTRYD 3 /* destroyed by a Klingon */
363 # define L_NEGENB 4 /* ran into the negative energy barrier */
364 # define L_SUICID 5 /* destroyed in a nova */
365 # define L_SNOVA 6 /* destroyed in a supernova */
366 # define L_NOLIFE 7 /* life support died (so did you) */
367 # define L_NOHELP 8 /* you could not be rematerialized */
368 # define L_TOOFAST 9 /* pretty stupid going at warp 10 */
369 # define L_STAR 10 /* ran into a star */
370 # define L_DSTRCT 11 /* self destructed */
371 # define L_CAPTURED 12 /* captured by Klingons */
372 # define L_NOCREW 13 /* you ran out of crew */
374 /****************** COMPILE OPTIONS ***********************/
381 void abandon
__P((int));
384 void attack
__P((int));
387 void autover
__P((void));
390 void capture
__P((int));
391 struct kling
*selectklingon
__P((void));
394 char cgetc
__P((int));
397 int check_out
__P((int));
400 void checkcond
__P((void));
403 void compkldist
__P((int));
406 void computer
__P((int));
409 void damage
__P((int, double));
412 int damaged
__P((int));
415 void dcrept
__P((int));
418 void destruct
__P((int));
421 void dock
__P((int));
422 void undock
__P((int));
425 void dumpgame
__P((int));
426 int restartgame
__P((void));
429 void dumpme
__P((int));
432 int dumpssradio
__P((void));
435 int events
__P((int));
440 int getcodi
__P((int *, double *));
443 void help
__P((int));
446 void impulse
__P((int));
449 void initquad
__P((int));
450 void sector
__P((int *, int *));
453 void killk
__P((int, int ));
454 void killb
__P((int, int ));
455 void kills
__P((int, int , int));
456 void killd
__P((int, int , int));
459 void klmove
__P((int));
462 void lose
__P((int));
465 void lrscan
__P((int));
468 double move
__P((int, int, double, double));
471 void nova
__P((int, int ));
477 void phaser
__P((int));
480 void myreset
__P((int));
481 void play
__P((void));
484 void ram
__P((int, int ));
488 double franf
__P((void));
491 void rest
__P((int));
494 struct event
*schedule
__P((int, double, int, int , int));
495 void reschedule
__P((struct event
*, double));
496 void unschedule
__P((struct event
*));
497 struct event
*xsched
__P((int, int, int, int , int ));
498 void xresched
__P((struct event
*, int, int));
501 long score
__P((void));
504 void setup
__P((void));
507 void setwarp
__P((int));
510 void shield
__P((int));
513 void snova
__P((int, int ));
516 void srscan
__P((int));
519 const char *systemname
__P((const struct quad
*));
522 void torped
__P((int));
525 void visual
__P((int));
528 void dowarp
__P((int));
529 void warp
__P((int, int, double));
532 void win
__P((void));