2 * Copyright (c) 1983 Regents of the University of California.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * from: @(#)externs.h 5.4 (Berkeley) 6/1/90
34 * $Id: externs.h,v 1.2 1993/08/01 18:51:57 mycroft Exp $
50 /* command line flags */
52 char randomize
; /* -x, give first available ship */
53 char longfmt
; /* -l, print score in long format */
54 char nobells
; /* -b, don't ring bell before Signal */
56 /* other initial modes */
57 char issetuid
; /* running setuid */
59 #define die() ((rand() >> 3) % 6 + 1)
60 #define sqr(a) ((a) * (a))
61 #define abs(a) ((a) > 0 ? (a) : -(a))
62 #define min(a,b) ((a) < (b) ? (a) : (b))
64 #define grappled(a) ((a)->file->ngrap)
65 #define fouled(a) ((a)->file->nfoul)
66 #define snagged(a) (grappled(a) + fouled(a))
68 #define grappled2(a, b) ((a)->file->grap[(b)->file->index].sn_count)
69 #define fouled2(a, b) ((a)->file->foul[(b)->file->index].sn_count)
70 #define snagged2(a, b) (grappled2(a, b) + fouled2(a, b))
72 #define Xgrappled2(a, b) ((a)->file->grap[(b)->file->index].sn_turn < turn-1 ? grappled2(a, b) : 0)
73 #define Xfouled2(a, b) ((a)->file->foul[(b)->file->index].sn_turn < turn-1 ? fouled2(a, b) : 0)
74 #define Xsnagged2(a, b) (Xgrappled2(a, b) + Xfouled2(a, b))
76 #define cleangrapple(a, b, c) Cleansnag(a, b, c, 1)
77 #define cleanfoul(a, b, c) Cleansnag(a, b, c, 2)
78 #define cleansnag(a, b, c) Cleansnag(a, b, c, 3)
80 #define sterncolour(sp) ((sp)->file->stern+'0'-((sp)->file->captured?10:0))
81 #define sternrow(sp) ((sp)->file->row + dr[(sp)->file->dir])
82 #define sterncol(sp) ((sp)->file->col + dc[(sp)->file->dir])
84 #define capship(sp) ((sp)->file->captured?(sp)->file->captured:(sp))
86 #define readyname(r) ((r) & R_LOADING ? '*' : ((r) & R_INITIAL ? '!' : ' '))
88 /* loadL and loadR, should match loadname[] */
89 #define L_EMPTY 0 /* should be 0, don't change */
97 * readyL and readyR, these are bits, except R_EMPTY
99 #define R_EMPTY 0 /* not loaded and not loading */
100 #define R_LOADING 1 /* loading */
101 #define R_DOUBLE 2 /* loading double */
102 #define R_LOADED 4 /* loaded */
103 #define R_INITIAL 8 /* loaded initial */
168 #define NSCENE nscene
184 char captain
[20]; /* 0 */
185 short points
; /* 20 */
188 char readyL
; /* 26 */
189 char readyR
; /* 28 */
190 struct BP OBP
[NBP
]; /* 30 */
191 struct BP DBP
[NBP
]; /* 48 */
192 char struck
; /* 66 */
193 struct ship
*captured
; /* 68 */
194 short pcrew
; /* 70 */
195 char movebuf
[10]; /* 72 */
199 struct snag foul
[NSHIP
]; /* 84 */
200 struct snag grap
[NSHIP
]; /* 124 */
205 char explode
; /* 232 */
215 char *shipname
; /* 0 */
216 struct shipspecs
*specs
; /* 2 */
217 char nationality
; /* 4 */
218 short shiprow
; /* 6 */
219 short shipcol
; /* 8 */
220 char shipdir
; /* 10 */
221 struct File
*file
; /* 12 */
225 char winddir
; /* 0 */
226 char windspeed
; /* 2 */
227 char windchange
; /* 4 */
228 char vessels
; /* 12 */
230 struct ship ship
[NSHIP
]; /* 16 */
232 struct scenario scene
[];
256 struct shipspecs specs
[];
258 struct scenario
*cc
; /* the current scenario */
259 struct ship
*ls
; /* &cc->ship[cc->vessels] */
261 #define SHIP(s) (&cc->ship[s])
262 #define foreachship(sp) for ((sp) = cc->ship; (sp) < ls; (sp)++)
267 struct windeffects WET
[7][6];
272 struct Tables RigTable
[11][6];
273 struct Tables HullTable
[11][6];
283 char *directionname
[];
303 struct ship
*closestenemy();