]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - trek/trek.h
1 /* $NetBSD: trek.h,v 1.8 1999/09/17 17:06:08 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. 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
50 /* external function definitions */
52 /********************* GALAXY **************************/
54 /* galactic parameters */
55 # define NSECTS 10 /* dimensions of quadrant in sectors */
56 # define NQUADS 8 /* dimension of galazy in quadrants */
57 # define NINHAB 32 /* number of quadrants which are inhabited */
59 struct quad
/* definition for each quadrant */
61 unsigned char bases
; /* number of bases in this quadrant */
62 char klings
; /* number of Klingons in this quadrant */
63 char holes
; /* number of black holes in this quadrant */
64 int scanned
; /* star chart entry (see below) */
65 short stars
; /* number of stars in this quadrant */
66 char qsystemname
; /* starsystem name (see below) */
69 # define Q_DISTRESSED 0200
72 /* systemname conventions:
73 * 1 -> NINHAB index into Systemname table for live system.
74 * + Q_DISTRESSED distressed starsystem -- systemname & Q_SYSTEM
75 * is the index into the Event table which will
76 * have the system name
77 * 0 dead or nonexistent starsystem
79 * starchart ("scanned") conventions:
80 * 0 -> 999 taken as is
81 * -1 not yet scanned ("...")
82 * 1000 supernova ("///")
83 * 1001 starbase + ??? (".1.")
86 /* ascii names of systems */
87 extern const char *const Systemname
[NINHAB
];
89 /* quadrant definition */
90 extern struct quad Quad
[NQUADS
][NQUADS
];
92 /* defines for sector map (below) */
96 # define ENTERPRISE 'E'
102 /* current sector map */
103 extern char Sect
[NSECTS
][NSECTS
];
107 /************************ DEVICES ******************************/
109 # define NDEV 16 /* max number of devices */
112 # define WARP 0 /* warp engines */
113 # define SRSCAN 1 /* short range scanners */
114 # define LRSCAN 2 /* long range scanners */
115 # define PHASER 3 /* phaser control */
116 # define TORPED 4 /* photon torpedo control */
117 # define IMPULSE 5 /* impulse engines */
118 # define SHIELD 6 /* shield control */
119 # define COMPUTER 7 /* on board computer */
120 # define SSRADIO 8 /* subspace radio */
121 # define LIFESUP 9 /* life support systems */
122 # define SINS 10 /* Space Inertial Navigation System */
123 # define CLOAK 11 /* cloaking device */
124 # define XPORTER 12 /* transporter */
125 # define SHUTTLE 13 /* shuttlecraft */
130 const char *name
; /* device name */
131 const char *person
; /* the person who fixes it */
134 extern const struct device Device
[NDEV
];
136 /*************************** EVENTS ****************************/
138 # define NEVENTS 12 /* number of different event types */
140 # define E_LRTB 1 /* long range tractor beam */
141 # define E_KATSB 2 /* Klingon attacks starbase */
142 # define E_KDESB 3 /* Klingon destroys starbase */
143 # define E_ISSUE 4 /* distress call is issued */
144 # define E_ENSLV 5 /* Klingons enslave a quadrant */
145 # define E_REPRO 6 /* a Klingon is reproduced */
146 # define E_FIXDV 7 /* fix a device */
147 # define E_ATTACK 8 /* Klingon attack during rest period */
148 # define E_SNAP 9 /* take a snapshot for time warp */
149 # define E_SNOVA 10 /* supernova occurs */
151 # define E_GHOST 0100 /* ghost of a distress call if ssradio out */
152 # define E_HIDDEN 0200 /* event that is unreportable because ssradio out */
153 # define E_EVENT 077 /* mask to get event code */
157 unsigned char x
, y
; /* coordinates */
158 double date
; /* trap stardate */
159 char evcode
; /* event type */
160 unsigned char systemname
; /* starsystem name */
162 /* systemname conventions:
163 * 1 -> NINHAB index into Systemname table for reported distress calls
165 * evcode conventions:
166 * 1 -> NEVENTS-1 event type
167 * + E_HIDDEN unreported (SSradio out)
168 * + E_GHOST actually already expired
172 # define MAXEVENTS 25 /* max number of concurrently pending events */
174 extern struct event Event
[MAXEVENTS
]; /* dynamic event list; one entry per pending event */
176 /***************************** KLINGONS *******************************/
180 unsigned char x
, y
; /* coordinates */
181 int power
; /* power left */
182 double dist
; /* distance to Enterprise */
183 double avgdist
; /* average over this move */
184 char srndreq
; /* set if surrender has been requested */
187 # define MAXKLQUAD 9 /* maximum klingons per quadrant */
189 /********************** MISCELLANEOUS ***************************/
191 /* condition codes */
197 /* starbase coordinates */
198 # define MAXBASES 9 /* maximum number of starbases in galaxy */
201 # define MAXDISTR 5 /* maximum concurrent distress calls */
204 # define NBANKS 6 /* number of phaser banks */
208 unsigned char x
, y
; /* coordinates */
212 extern const struct cvntab Skitab
[];
213 extern const struct cvntab Lentab
[];
216 * note that much of the stuff in the following structs CAN NOT
217 * be moved around!!!!
221 /* information regarding the state of the starship */
224 double warp
; /* warp factor */
225 double warp2
; /* warp factor squared */
226 double warp3
; /* warp factor cubed */
227 char shldup
; /* shield up flag */
228 char cloaked
; /* set if cloaking device on */
229 int energy
; /* starship's energy */
230 int shield
; /* energy in shields */
231 double reserves
; /* life support reserves */
232 int crew
; /* ship's complement */
233 int brigfree
; /* space left in brig */
234 char torped
; /* torpedoes */
235 char cloakgood
; /* set if we have moved */
236 int quadx
; /* quadrant x coord */
237 int quady
; /* quadrant y coord */
238 int sectx
; /* sector x coord */
239 int secty
; /* sector y coord */
240 unsigned char cond
; /* condition code */
241 char sinsbad
; /* Space Inertial Navigation System condition */
242 const char *shipname
; /* name of current starship */
243 char ship
; /* current starship */
244 int distressed
; /* number of distress calls */
246 extern struct Ship_struct Ship
;
248 /* sinsbad is set if SINS is working but not calibrated */
250 /* game related information, mostly scoring */
253 int killk
; /* number of klingons killed */
254 int deaths
; /* number of deaths onboard Enterprise */
255 char negenbar
; /* number of hits on negative energy barrier */
256 char killb
; /* number of starbases killed */
257 int kills
; /* number of stars killed */
258 char skill
; /* skill rating of player */
259 char length
; /* length of game */
260 char killed
; /* set if you were killed */
261 char killinhab
; /* number of inhabited starsystems killed */
262 char tourn
; /* set if a tournament game */
263 char passwd
[15]; /* game password */
264 char snap
; /* set if snapshot taken */
265 char helps
; /* number of help calls */
266 int captives
; /* total number of captives taken */
268 extern struct Game_struct Game
;
270 /* per move information */
273 char free
; /* set if a move is free */
274 char endgame
; /* end of game flag */
275 char shldchg
; /* set if shields changed this move */
276 char newquad
; /* set if just entered this quadrant */
277 char resting
; /* set if this move is a rest */
278 double time
; /* time used this move */
280 extern struct Move_struct Move
;
282 /* parametric information */
285 unsigned char bases
; /* number of starbases */
286 char klings
; /* number of klingons */
287 double date
; /* stardate */
288 double time
; /* time left */
289 double resource
; /* Federation resources */
290 int energy
; /* starship's energy */
291 int shield
; /* energy in shields */
292 double reserves
; /* life support reserves */
293 int crew
; /* size of ship's complement */
294 int brigfree
; /* max possible number of captives */
295 char torped
; /* photon torpedos */
296 double damfac
[NDEV
]; /* damage factor */
297 double dockfac
; /* docked repair time factor */
298 double regenfac
; /* regeneration factor */
299 int stopengy
; /* energy to do emergency stop */
300 int shupengy
; /* energy to put up shields */
301 int klingpwr
; /* Klingon initial power */
302 int warptime
; /* time chewer multiplier */
303 double phasfac
; /* Klingon phaser power eater factor */
304 char moveprob
[6]; /* probability that a Klingon moves */
305 double movefac
[6]; /* Klingon move distance multiplier */
306 double eventdly
[NEVENTS
]; /* event time multipliers */
307 double navigcrud
[2]; /* navigation crudup factor */
308 int cloakenergy
; /* cloaking device energy per stardate */
309 double damprob
[NDEV
]; /* damage probability */
310 double hitfac
; /* Klingon attack factor */
311 int klingcrew
; /* number of Klingons in a crew */
312 double srndrprob
; /* surrender probability */
313 int energylow
; /* low energy mark (cond YELLOW) */
315 extern struct Param_struct Param
;
317 /* Sum of damage probabilities must add to 1000 */
319 /* other information kept in a snapshot */
322 unsigned char bases
; /* number of starbases */
323 char klings
; /* number of klingons */
324 double date
; /* stardate */
325 double time
; /* time left */
326 double resource
; /* Federation resources */
327 char distressed
; /* number of currently distressed quadrants */
328 struct event
*eventptr
[NEVENTS
]; /* pointer to event structs */
329 struct xy base
[MAXBASES
]; /* locations of starbases */
331 extern struct Now_struct Now
;
333 /* Other stuff, not dumped in a snapshot */
336 struct kling klingon
[MAXKLQUAD
]; /* sorted Klingon list */
337 short nkling
; /* number of Klingons in this sector */
338 /* < 0 means automatic override mode */
339 char fast
; /* set if speed > 300 baud */
340 struct xy starbase
; /* starbase in current quadrant */
341 char snapshot
[sizeof Quad
+ sizeof Event
+ sizeof Now
]; /* snapshot for time warp */
342 char statreport
; /* set to get a status report on a srscan */
344 extern struct Etc_struct Etc
;
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)) __attribute__((__noreturn__
));
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)) __attribute__((__noreturn__
));
481 void play
__P((void)) __attribute__((__noreturn__
));
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)) __attribute__((__noreturn__
));