]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - trek/trek.h
Warnsify and remove local implementations of libc functions.
[bsdgames-darwin.git] / trek / trek.h
1 /* $NetBSD: trek.h,v 1.5 1997/10/12 21:25:23 christos Exp $ */
2
3 /*
4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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.
22 *
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
33 * SUCH DAMAGE.
34 *
35 * @(#)trek.h 8.1 (Berkeley) 5/31/93
36 */
37
38 /*
39 ** Global Declarations
40 **
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
44 ** program file.
45 **
46 ** So far as I know, nothing in here must be preinitialized to
47 ** zero.
48 **
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"
54 */
55
56 /* external function definitions */
57
58 /********************* GALAXY **************************/
59
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 */
64
65 struct quad /* definition for each quadrant */
66 {
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) */
73 };
74
75 # define Q_DISTRESSED 0200
76 # define Q_SYSTEM 077
77
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
84 *
85 * starchart ("scanned") conventions:
86 * 0 -> 999 taken as is
87 * -1 not yet scanned ("...")
88 * 1000 supernova ("///")
89 * 1001 starbase + ??? (".1.")
90 */
91
92 /* ascii names of systems */
93 extern char *Systemname[NINHAB];
94
95 /* quadrant definition */
96 struct quad Quad[NQUADS][NQUADS];
97
98 /* defines for sector map (below) */
99 # define EMPTY '.'
100 # define STAR '*'
101 # define BASE '#'
102 # define ENTERPRISE 'E'
103 # define QUEENE 'Q'
104 # define KLINGON 'K'
105 # define INHABIT '@'
106 # define HOLE ' '
107
108 /* current sector map */
109 char Sect[NSECTS][NSECTS];
110
111
112
113 /************************ DEVICES ******************************/
114
115 # define NDEV 16 /* max number of devices */
116
117 /* device tokens */
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 */
132
133 /* device names */
134 struct device
135 {
136 char *name; /* device name */
137 char *person; /* the person who fixes it */
138 };
139
140 struct device Device[NDEV];
141
142 /*************************** EVENTS ****************************/
143
144 # define NEVENTS 12 /* number of different event types */
145
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 */
156
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 */
160
161 struct event
162 {
163 unsigned char x, y; /* coordinates */
164 double date; /* trap stardate */
165 char evcode; /* event type */
166 unsigned char systemname; /* starsystem name */
167 };
168 /* systemname conventions:
169 * 1 -> NINHAB index into Systemname table for reported distress calls
170 *
171 * evcode conventions:
172 * 1 -> NEVENTS-1 event type
173 * + E_HIDDEN unreported (SSradio out)
174 * + E_GHOST actually already expired
175 * 0 unallocated
176 */
177
178 # define MAXEVENTS 25 /* max number of concurrently pending events */
179
180 struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */
181
182 /***************************** KLINGONS *******************************/
183
184 struct kling
185 {
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 */
191 };
192
193 # define MAXKLQUAD 9 /* maximum klingons per quadrant */
194
195 /********************** MISCELLANEOUS ***************************/
196
197 /* condition codes */
198 # define GREEN 0
199 # define DOCKED 1
200 # define YELLOW 2
201 # define RED 3
202
203 /* starbase coordinates */
204 # define MAXBASES 9 /* maximum number of starbases in galaxy */
205
206 /* distress calls */
207 # define MAXDISTR 5 /* maximum concurrent distress calls */
208
209 /* phaser banks */
210 # define NBANKS 6 /* number of phaser banks */
211
212 struct xy
213 {
214 unsigned char x, y; /* coordinates */
215 };
216
217
218 extern struct cvntab Skitab[];
219 extern struct cvntab Lentab[];
220
221 /*
222 * note that much of the stuff in the following structs CAN NOT
223 * be moved around!!!!
224 */
225
226
227 /* information regarding the state of the starship */
228 struct
229 {
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 char *shipname; /* name of current starship */
249 char ship; /* current starship */
250 int distressed; /* number of distress calls */
251 } Ship;
252
253 /* sinsbad is set if SINS is working but not calibrated */
254
255 /* game related information, mostly scoring */
256 struct
257 {
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 */
272 } Game;
273
274 /* per move information */
275 struct
276 {
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 */
283 } Move;
284
285 /* parametric information */
286 struct
287 {
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) */
317 } Param;
318
319 /* Sum of damage probabilities must add to 1000 */
320
321 /* other information kept in a snapshot */
322 struct
323 {
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 */
332 } Now;
333
334 /* Other stuff, not dumped in a snapshot */
335 struct
336 {
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 */
344 } Etc;
345
346 /*
347 * eventptr is a pointer to the event[] entry of the last
348 * scheduled event of each type. Zero if no such event scheduled.
349 */
350
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 */
358
359 /* you lose codes */
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 */
373
374 /****************** COMPILE OPTIONS ***********************/
375
376 /* Trace info */
377 # define xTRACE 1
378 int Trace;
379
380 /* abandon.c */
381 void abandon __P((int));
382
383 /* attack.c */
384 void attack __P((int));
385
386 /* autover.c */
387 void autover __P((void));
388
389 /* capture.c */
390 void capture __P((int));
391 struct kling *selectklingon __P((void));
392
393 /* cgetc.c */
394 char cgetc __P((int));
395
396 /* check_out.c */
397 int check_out __P((int));
398
399 /* checkcond.c */
400 void checkcond __P((void));
401
402 /* compkl.c */
403 void compkldist __P((int));
404
405 /* computer.c */
406 void computer __P((int));
407
408 /* damage.c */
409 void damage __P((int, double));
410
411 /* damaged.c */
412 int damaged __P((int));
413
414 /* dcrept.c */
415 void dcrept __P((int));
416
417 /* destruct.c */
418 void destruct __P((int));
419
420 /* dock.c */
421 void dock __P((int));
422 void undock __P((int));
423
424 /* dumpgame.c */
425 void dumpgame __P((int));
426 int restartgame __P((void));
427
428 /* dumpme.c */
429 void dumpme __P((int));
430
431 /* dumpssradio.c */
432 int dumpssradio __P((void));
433
434 /* events.c */
435 int events __P((int));
436
437 /* externs.c */
438
439 /* getcodi.c */
440 int getcodi __P((int *, double *));
441
442 /* help.c */
443 void help __P((int));
444
445 /* impulse.c */
446 void impulse __P((int));
447
448 /* initquad.c */
449 void initquad __P((int));
450 void sector __P((int *, int *));
451
452 /* kill.c */
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));
457
458 /* klmove.c */
459 void klmove __P((int));
460
461 /* lose.c */
462 void lose __P((int));
463
464 /* lrscan.c */
465 void lrscan __P((int));
466
467 /* move.c */
468 double move __P((int, int, double, double));
469
470 /* nova.c */
471 void nova __P((int, int ));
472
473 /* out.c */
474 void out __P((int));
475
476 /* phaser.c */
477 void phaser __P((int));
478
479 /* play.c */
480 void myreset __P((int));
481 void play __P((void));
482
483 /* ram.c */
484 void ram __P((int, int ));
485
486 /* ranf.c */
487 int ranf __P((int));
488 double franf __P((void));
489
490 /* rest.c */
491 void rest __P((int));
492
493 /* schedule.c */
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));
499
500 /* score.c */
501 long score __P((void));
502
503 /* setup.c */
504 void setup __P((void));
505
506 /* setwarp.c */
507 void setwarp __P((int));
508
509 /* shield.c */
510 void shield __P((int));
511
512 /* snova.c */
513 void snova __P((int, int ));
514
515 /* srscan.c */
516 void srscan __P((int));
517
518 /* systemname.c */
519 char *systemname __P((struct quad *));
520
521 /* torped.c */
522 void torped __P((int));
523
524 /* visual.c */
525 void visual __P((int));
526
527 /* warp.c */
528 void dowarp __P((int));
529 void warp __P((int, int, double));
530
531 /* win.c */
532 void win __P((void));