]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - sail/extern.h
1 /* $NetBSD: extern.h,v 1.14 2000/02/09 22:27:55 jsm Exp $ */
4 * Copyright (c) 1983, 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 * @(#)externs.h 8.1 (Berkeley) 5/31/93
43 #include <sys/types.h>
48 extern jmp_buf restart
;
53 /* command line flags */
54 extern char debug
; /* -D */
55 extern char randomize
; /* -x, give first available ship */
56 extern char longfmt
; /* -l, print score in long format */
57 extern char nobells
; /* -b, don't ring bell before Signal */
59 /* other initial modes */
63 #define die() ((rand() >> 3) % 6 + 1)
64 #define sqr(a) ((a) * (a))
65 #define abs(a) ((a) > 0 ? (a) : -(a))
66 #define min(a,b) ((a) < (b) ? (a) : (b))
68 #define grappled(a) ((a)->file->ngrap)
69 #define fouled(a) ((a)->file->nfoul)
70 #define snagged(a) (grappled(a) + fouled(a))
72 #define grappled2(a, b) ((a)->file->grap[(b)->file->index].sn_count)
73 #define fouled2(a, b) ((a)->file->foul[(b)->file->index].sn_count)
74 #define snagged2(a, b) (grappled2(a, b) + fouled2(a, b))
76 #define Xgrappled2(a, b) ((a)->file->grap[(b)->file->index].sn_turn < turn-1 ? grappled2(a, b) : 0)
77 #define Xfouled2(a, b) ((a)->file->foul[(b)->file->index].sn_turn < turn-1 ? fouled2(a, b) : 0)
78 #define Xsnagged2(a, b) (Xgrappled2(a, b) + Xfouled2(a, b))
80 #define cleangrapple(a, b, c) Cleansnag(a, b, c, 1)
81 #define cleanfoul(a, b, c) Cleansnag(a, b, c, 2)
82 #define cleansnag(a, b, c) Cleansnag(a, b, c, 3)
84 #define sterncolour(sp) ((sp)->file->stern+'0'-((sp)->file->captured?10:0))
85 #define sternrow(sp) ((sp)->file->row + dr[(sp)->file->dir])
86 #define sterncol(sp) ((sp)->file->col + dc[(sp)->file->dir])
88 #define capship(sp) ((sp)->file->captured?(sp)->file->captured:(sp))
90 #define readyname(r) ((r) & R_LOADING ? '*' : ((r) & R_INITIAL ? '!' : ' '))
92 /* loadL and loadR, should match loadname[] */
93 #define L_EMPTY 0 /* should be 0, don't change */
101 * readyL and readyR, these are bits, except R_EMPTY
103 #define R_EMPTY 0 /* not loaded and not loading */
104 #define R_LOADING 1 /* loading */
105 #define R_DOUBLE 2 /* loading double */
106 #define R_LOADED 4 /* loaded */
107 #define R_INITIAL 8 /* loaded initial */
172 #define NSCENE nscene
188 char captain
[20]; /* 0 */
189 short points
; /* 20 */
190 unsigned char loadL
; /* 22 */
191 unsigned char loadR
; /* 24 */
192 unsigned char readyL
; /* 26 */
193 unsigned char readyR
; /* 28 */
194 struct BP OBP
[NBP
]; /* 30 */
195 struct BP DBP
[NBP
]; /* 48 */
196 char struck
; /* 66 */
197 struct ship
*captured
; /* 68 */
198 short pcrew
; /* 70 */
199 char movebuf
[10]; /* 72 */
203 struct snag foul
[NSHIP
]; /* 84 */
204 struct snag grap
[NSHIP
]; /* 124 */
209 char explode
; /* 232 */
219 const char *shipname
; /* 0 */
220 struct shipspecs
*specs
; /* 2 */
221 unsigned char nationality
; /* 4 */
222 short shiprow
; /* 6 */
223 short shipcol
; /* 8 */
224 char shipdir
; /* 10 */
225 struct File
*file
; /* 12 */
229 char winddir
; /* 0 */
230 char windspeed
; /* 2 */
231 char windchange
; /* 4 */
232 unsigned char vessels
; /* 12 */
233 const char *name
; /* 14 */
234 struct ship ship
[NSHIP
]; /* 16 */
236 extern struct scenario scene
[];
260 extern struct shipspecs specs
[];
262 extern struct scenario
*cc
; /* the current scenario */
263 extern struct ship
*ls
; /* &cc->ship[cc->vessels] */
265 #define SHIP(s) (&cc->ship[s])
266 #define foreachship(sp) for ((sp) = cc->ship; (sp) < ls; (sp)++)
271 extern const struct windeffects WET
[7][6];
276 extern const struct Tables RigTable
[11][6];
277 extern const struct Tables HullTable
[11][6];
279 extern const char AMMO
[9][4];
280 extern const char HDT
[9][10];
281 extern const char HDTrake
[9][10];
282 extern const char QUAL
[9][5];
283 extern const char MT
[9][3];
285 extern const char *const countryname
[];
286 extern const char *const classname
[];
287 extern const char *const directionname
[];
288 extern const char *const qualname
[];
289 extern const char loadname
[];
291 extern const char rangeofshot
[];
293 extern const char dr
[], dc
[];
296 extern int windspeed
;
301 extern char hasdriver
;
304 void table
__P((int, int, int, struct ship
*, struct ship
*, int));
305 void Cleansnag
__P((struct ship
*, struct ship
*, int, int));
308 void unfoul
__P((void));
309 void boardcomp
__P((void));
310 int fightitout
__P((struct ship
*, struct ship
*, int));
311 void resolve
__P((void));
312 void compcombat
__P((void));
313 int next
__P((void));
316 void thinkofgrapples
__P((void));
317 void checkup
__P((void));
318 void prizecheck
__P((void));
319 int str_end
__P((const char *));
320 void closeon
__P((struct ship
*, struct ship
*, char[], int, int, int));
321 int score
__P((char[], struct ship
*, struct ship
*, int));
322 void move_ship
__P((const char *, struct ship
*, unsigned char *, short *, short *, char *));
323 void try __P((char[], char [], int, int, int, int, int, struct ship
*,
324 struct ship
*, int *, int));
325 void rmend
__P((char *));
328 void moveall
__P((void));
329 int stillmoving
__P((int));
330 int is_isolated
__P((struct ship
*));
331 int push
__P((struct ship
*, struct ship
*));
332 void step
__P((int, struct ship
*, char *));
333 void sendbp
__P((struct ship
*, struct ship
*, int, int));
334 int is_toughmelee
__P((struct ship
*, struct ship
*, int, int));
335 void reload
__P((void));
336 void checksails
__P((void));
339 void ungrap
__P((struct ship
*, struct ship
*));
340 void grap
__P((struct ship
*, struct ship
*));
343 void subtract
__P((struct ship
*, int, int [3], struct ship
*, int));
344 int mensent
__P((struct ship
*, struct ship
*, int[3], struct ship
**, int *,
348 int dr_main
__P((void));
351 int maxturns
__P((struct ship
*, char *));
352 int maxmove
__P((struct ship
*, int, int));
355 int lo_main
__P((void));
358 int range
__P((struct ship
*, struct ship
*));
359 struct ship
*closestenemy
__P((struct ship
*, int, int));
360 int angle
__P((int, int));
361 int gunsbear
__P((struct ship
*, struct ship
*));
362 int portside
__P((struct ship
*, struct ship
*, int));
363 int colours
__P((struct ship
*));
364 void logger
__P((struct ship
*));
367 int meleeing
__P((struct ship
*, struct ship
*));
368 int boarding
__P((struct ship
*, int));
369 void unboard
__P((struct ship
*, struct ship
*, int));
372 void leave
__P((int)) __attribute__((__noreturn__
));
373 void choke
__P((int)) __attribute__((__noreturn__
));
374 void child
__P((int));
377 void play
__P((void)) __attribute__((__noreturn__
));
380 void acceptcombat
__P((void));
381 void grapungrap
__P((void));
382 void unfoulplayer
__P((void));
385 void changesail
__P((void));
386 void acceptsignal
__P((void));
387 void lookout
__P((void));
388 const char *saywhat
__P((struct ship
*, int));
389 void eyeball
__P((struct ship
*));
392 void acceptmove
__P((void));
393 void acceptboard
__P((void));
394 void parties
__P((int[3], struct ship
*, int, int));
397 void repair
__P((void));
398 int turned
__P((void));
399 void loadplayer
__P((void));
402 void initscreen
__P((void));
403 void cleanupscreen
__P((void));
404 void newturn
__P((int));
405 void Signal
__P((const char *, struct ship
*, ...))
406 __attribute__((__format__(__printf__
,1,3)));
407 void Msg
__P((const char *, ...))
408 __attribute__((__format__(__printf__
,1,2)));
409 void Scroll
__P((void));
410 void prompt
__P((const char *, struct ship
*));
411 void endprompt
__P((int));
412 int sgetch
__P((const char *, struct ship
*, int));
413 void sgetstr
__P((const char *, char *, int));
414 void draw_screen
__P((void));
415 void draw_view
__P((void));
416 void draw_turn
__P((void));
417 void draw_stat
__P((void));
418 void draw_slot
__P((void));
419 void draw_board
__P((void));
420 void centerview
__P((void));
421 void upview
__P((void));
422 void downview
__P((void));
423 void leftview
__P((void));
424 void rightview
__P((void));
425 void adjustview
__P((void));
428 int pl_main
__P((void));
429 void initialize
__P((void));
432 void fmtship
__P((char *, size_t, const char *, struct ship
*));
433 void makesignal
__P((struct ship
*, const char *, struct ship
*, ...))
434 __attribute__((__format__(__printf__
,2,4)));
435 void makemsg
__P((struct ship
*, const char *, ...))
436 __attribute__((__format__(__printf__
,2,3)));
437 int sync_exists
__P((int));
438 int sync_open
__P((void));
439 void sync_close
__P((int));
440 void Write
__P((int, struct ship
*, long, long, long, long));
441 void Writestr
__P((int, struct ship
*, const char *));
442 int Sync
__P((void));
443 int sync_update
__P((int, struct ship
*, const char *, long, long, long, long));