2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
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. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * @(#)externs.h 8.1 (Berkeley) 5/31/93
30 * $DragonFly: src/games/sail/externs.h,v 1.4 2006/09/03 17:33:13 pavalos Exp $
46 extern jmp_buf restart;
51 /* command line flags */
52 extern char debug; /* -D */
53 extern char randomize; /* -x, give first available ship */
54 extern char longfmt; /* -l, print score in long format */
55 extern char nobells; /* -b, don't ring bell before Signal */
57 /* other initial modes */
58 extern char issetuid; /* running setuid */
60 #define die() (random() % 6 + 1)
61 #define sqr(a) ((a) * (a))
62 #define abs(a) ((a) > 0 ? (a) : -(a))
63 #define min(a,b) ((a) < (b) ? (a) : (b))
65 #define grappled(a) ((a)->file->ngrap)
66 #define fouled(a) ((a)->file->nfoul)
67 #define snagged(a) (grappled(a) + fouled(a))
69 #define grappled2(a, b) ((a)->file->grap[(b)->file->index].sn_count)
70 #define fouled2(a, b) ((a)->file->foul[(b)->file->index].sn_count)
71 #define snagged2(a, b) (grappled2(a, b) + fouled2(a, b))
73 #define Xgrappled2(a, b) ((a)->file->grap[(b)->file->index].sn_turn < turn-1 \
74 ? grappled2(a, b) : 0)
75 #define Xfouled2(a, b) ((a)->file->foul[(b)->file->index].sn_turn < turn-1 \
77 #define Xsnagged2(a, b) (Xgrappled2(a, b) + Xfouled2(a, b))
79 #define cleangrapple(a, b, c) Cleansnag(a, b, c, 1)
80 #define cleanfoul(a, b, c) Cleansnag(a, b, c, 2)
81 #define cleansnag(a, b, c) Cleansnag(a, b, c, 3)
83 #define sterncolour(sp) ((sp)->file->stern+'0'-((sp)->file->captured ? 10 : 0))
84 #define sternrow(sp) ((sp)->file->row + dr[(sp)->file->dir])
85 #define sterncol(sp) ((sp)->file->col + dc[(sp)->file->dir])
87 #define capship(sp) ((sp)->file->captured?(sp)->file->captured:(sp))
89 #define readyname(r) ((r) & R_LOADING ? '*' : ((r) & R_INITIAL ? '!' : ' '))
91 /* loadL and loadR, should match loadname[] */
92 #define L_EMPTY 0 /* should be 0, don't change */
100 * readyL and readyR, these are bits, except R_EMPTY
102 #define R_EMPTY 0 /* not loaded and not loading */
103 #define R_LOADING 1 /* loading */
104 #define R_DOUBLE 2 /* loading double */
105 #define R_LOADED 4 /* loaded */
106 #define R_INITIAL 8 /* loaded initial */
171 #define NSCENE nscene
187 char captain[20]; /* 0 */
188 short points; /* 20 */
189 unsigned char loadL; /* 22 */
190 unsigned char loadR; /* 24 */
191 char readyL; /* 26 */
192 char readyR; /* 28 */
193 struct BP OBP[NBP]; /* 30 */
194 struct BP DBP[NBP]; /* 48 */
195 char struck; /* 66 */
196 struct ship *captured; /* 68 */
197 short pcrew; /* 70 */
198 char movebuf[60]; /* 72 */
199 char drift; /* 132 */
202 struct snag foul[NSHIP]; /* 134 */
203 struct snag grap[NSHIP]; /* 144 */
208 char explode; /* 282 */
218 const char *shipname; /* 0 */
219 struct shipspecs *specs; /* 2 */
220 unsigned char nationality; /* 4 */
221 short shiprow; /* 6 */
222 short shipcol; /* 8 */
223 char shipdir; /* 10 */
224 struct File *file; /* 12 */
228 char winddir; /* 0 */
229 char windspeed; /* 2 */
230 char windchange; /* 4 */
231 unsigned char vessels; /* 12 */
232 const char *name; /* 14 */
233 struct ship ship[NSHIP]; /* 16 */
235 extern struct scenario scene[];
259 extern struct shipspecs specs[];
261 extern struct scenario *cc; /* the current scenario */
262 extern struct ship *ls; /* &cc->ship[cc->vessels] */
264 #define SHIP(s) (&cc->ship[s])
265 #define foreachship(sp) for ((sp) = cc->ship; (sp) < ls; (sp)++)
270 extern struct windeffects WET[7][6];
275 extern struct Tables RigTable[11][6];
276 extern struct Tables HullTable[11][6];
278 extern char AMMO[9][4];
279 extern char HDT[9][10];
280 extern char HDTrake[9][10];
281 extern char QUAL[9][5];
282 extern char MT[9][3];
284 extern const char *countryname[];
285 extern const char *classname[];
286 extern const char *directionname[];
287 extern const char *qualname[];
288 extern char loadname[];
290 extern char rangeofshot[];
292 extern char dr[], dc[];
295 extern int windspeed;
300 extern char hasdriver;
303 void table(int, int, int, struct ship *, struct ship *, int);
304 void Cleansnag(struct ship *, struct ship *, char, char);
308 void boardcomp(void);
310 void compcombat(void);
314 void thinkofgrapples(void);
316 void prizecheck(void);
317 void closeon(struct ship *, struct ship *, char *, int, int, int);
321 void sendbp(struct ship *, struct ship *, int, char);
322 int toughmelee(struct ship *, struct ship *, int, int);
324 void checksails(void);
327 void ungrap(struct ship *, struct ship *);
328 void grap(struct ship *, struct ship *);
331 void subtract(struct ship *, int, int [3], struct ship *, int);
332 int mensent(struct ship *, struct ship *, int [3], struct ship **, int *, char);
338 int maxturns(struct ship *, char *);
339 int maxmove(struct ship *, int, int);
345 int range(struct ship *, struct ship *);
346 struct ship *closestenemy(struct ship *, char, char);
347 char gunsbear(struct ship *, struct ship *);
348 int portside(struct ship *, struct ship *, int);
349 char colours(struct ship *);
350 void write_log(struct ship *);
353 bool meleeing(struct ship *, struct ship *);
354 bool boarding(struct ship *, char);
355 void unboard(struct ship *, struct ship *, char);
366 void acceptcombat(void);
367 void grapungrap(void);
368 void unfoulplayer(void);
371 void changesail(void);
372 void acceptsignal(void);
374 const char *saywhat(struct ship *, char);
375 void eyeball(struct ship *);
378 void acceptmove(void);
379 void acceptboard(void);
383 void loadplayer(void);
386 void initscreen(void);
387 void cleanupscreen(void);
389 void Signal(const char *, struct ship *, ...);
390 int sgetch(const char *, struct ship *, char);
391 void sgetstr(const char *, char *, int);
392 void draw_screen(void);
393 void draw_view(void);
394 void draw_turn(void);
395 void draw_stat(void);
396 void draw_slot(void);
397 void draw_board(void);
398 void centerview(void);
402 void rightview(void);
408 void fmtship(char *, size_t, const char *, struct ship *);
409 void makesignal(struct ship *, const char *, struct ship *, ...);
410 bool sync_exists(int);
412 void sync_close(char);
413 void Write(int, struct ship *, int, int, int, int);
414 void Writestr(int, struct ship *, const char *);