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. 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 * @(#)externs.h 8.1 (Berkeley) 5/31/93
34 * $DragonFly: src/games/sail/externs.h,v 1.4 2006/09/03 17:33:13 pavalos Exp $
50 extern jmp_buf restart;
55 /* command line flags */
56 extern char debug; /* -D */
57 extern char randomize; /* -x, give first available ship */
58 extern char longfmt; /* -l, print score in long format */
59 extern char nobells; /* -b, don't ring bell before Signal */
61 /* other initial modes */
62 extern char issetuid; /* running setuid */
64 #define die() (random() % 6 + 1)
65 #define sqr(a) ((a) * (a))
66 #define abs(a) ((a) > 0 ? (a) : -(a))
67 #define min(a,b) ((a) < (b) ? (a) : (b))
69 #define grappled(a) ((a)->file->ngrap)
70 #define fouled(a) ((a)->file->nfoul)
71 #define snagged(a) (grappled(a) + fouled(a))
73 #define grappled2(a, b) ((a)->file->grap[(b)->file->index].sn_count)
74 #define fouled2(a, b) ((a)->file->foul[(b)->file->index].sn_count)
75 #define snagged2(a, b) (grappled2(a, b) + fouled2(a, b))
77 #define Xgrappled2(a, b) ((a)->file->grap[(b)->file->index].sn_turn < turn-1 ? grappled2(a, b) : 0)
78 #define Xfouled2(a, b) ((a)->file->foul[(b)->file->index].sn_turn < turn-1 ? fouled2(a, b) : 0)
79 #define Xsnagged2(a, b) (Xgrappled2(a, b) + Xfouled2(a, b))
81 #define cleangrapple(a, b, c) Cleansnag(a, b, c, 1)
82 #define cleanfoul(a, b, c) Cleansnag(a, b, c, 2)
83 #define cleansnag(a, b, c) Cleansnag(a, b, c, 3)
85 #define sterncolour(sp) ((sp)->file->stern+'0'-((sp)->file->captured?10:0))
86 #define sternrow(sp) ((sp)->file->row + dr[(sp)->file->dir])
87 #define sterncol(sp) ((sp)->file->col + dc[(sp)->file->dir])
89 #define capship(sp) ((sp)->file->captured?(sp)->file->captured:(sp))
91 #define readyname(r) ((r) & R_LOADING ? '*' : ((r) & R_INITIAL ? '!' : ' '))
93 /* loadL and loadR, should match loadname[] */
94 #define L_EMPTY 0 /* should be 0, don't change */
102 * readyL and readyR, these are bits, except R_EMPTY
104 #define R_EMPTY 0 /* not loaded and not loading */
105 #define R_LOADING 1 /* loading */
106 #define R_DOUBLE 2 /* loading double */
107 #define R_LOADED 4 /* loaded */
108 #define R_INITIAL 8 /* loaded initial */
173 #define NSCENE nscene
189 char captain[20]; /* 0 */
190 short points; /* 20 */
191 unsigned char loadL; /* 22 */
192 unsigned char loadR; /* 24 */
193 char readyL; /* 26 */
194 char readyR; /* 28 */
195 struct BP OBP[NBP]; /* 30 */
196 struct BP DBP[NBP]; /* 48 */
197 char struck; /* 66 */
198 struct ship *captured; /* 68 */
199 short pcrew; /* 70 */
200 char movebuf[60]; /* 72 */
201 char drift; /* 132 */
204 struct snag foul[NSHIP]; /* 134 */
205 struct snag grap[NSHIP]; /* 144 */
210 char explode; /* 282 */
220 const char *shipname; /* 0 */
221 struct shipspecs *specs; /* 2 */
222 unsigned char nationality; /* 4 */
223 short shiprow; /* 6 */
224 short shipcol; /* 8 */
225 char shipdir; /* 10 */
226 struct File *file; /* 12 */
230 char winddir; /* 0 */
231 char windspeed; /* 2 */
232 char windchange; /* 4 */
233 unsigned char vessels; /* 12 */
234 const char *name; /* 14 */
235 struct ship ship[NSHIP]; /* 16 */
237 extern struct scenario scene[];
261 extern struct shipspecs specs[];
263 extern struct scenario *cc; /* the current scenario */
264 extern struct ship *ls; /* &cc->ship[cc->vessels] */
266 #define SHIP(s) (&cc->ship[s])
267 #define foreachship(sp) for ((sp) = cc->ship; (sp) < ls; (sp)++)
272 extern struct windeffects WET[7][6];
277 extern struct Tables RigTable[11][6];
278 extern struct Tables HullTable[11][6];
280 extern char AMMO[9][4];
281 extern char HDT[9][10];
282 extern char HDTrake[9][10];
283 extern char QUAL[9][5];
284 extern char MT[9][3];
286 extern const char *countryname[];
287 extern const char *classname[];
288 extern const char *directionname[];
289 extern const char *qualname[];
290 extern char loadname[];
292 extern char rangeofshot[];
294 extern char dr[], dc[];
297 extern int windspeed;
302 extern char hasdriver;
305 void table(int, int, int, struct ship *, struct ship *, int);
306 void Cleansnag(struct ship *, struct ship *, char, char);
310 void boardcomp(void);
312 void compcombat(void);
316 void thinkofgrapples(void);
318 void prizecheck(void);
319 void closeon(struct ship *, struct ship *, char *, int, int, int);
323 void sendbp(struct ship *, struct ship *, int, char);
324 int toughmelee(struct ship *, struct ship *, int, int);
326 void checksails(void);
329 void ungrap(struct ship *, struct ship *);
330 void grap(struct ship *, struct ship *);
333 void subtract(struct ship *, int, int [3], struct ship *, int);
334 int mensent(struct ship *, struct ship *, int [3], struct ship **, int *, char);
340 int maxturns(struct ship *, char *);
341 int maxmove(struct ship *, int, int);
347 int range(struct ship *, struct ship *);
348 struct ship *closestenemy(struct ship *, char, char);
349 char gunsbear(struct ship *, struct ship *);
350 int portside(struct ship *, struct ship *, int);
351 char colours(struct ship *);
352 void write_log(struct ship *);
355 bool meleeing(struct ship *, struct ship *);
356 bool boarding(struct ship *, char);
357 void unboard(struct ship *, struct ship *, char);
368 void acceptcombat(void);
369 void grapungrap(void);
370 void unfoulplayer(void);
373 void changesail(void);
374 void acceptsignal(void);
376 const char *saywhat(struct ship *, char);
377 void eyeball(struct ship *);
380 void acceptmove(void);
381 void acceptboard(void);
385 void loadplayer(void);
388 void initscreen(void);
389 void cleanupscreen(void);
391 void Signal(const char *, struct ship *, ...);
392 int sgetch(const char *, struct ship *, char);
393 void sgetstr(const char *, char *, int);
394 void draw_screen(void);
395 void draw_view(void);
396 void draw_turn(void);
397 void draw_stat(void);
398 void draw_slot(void);
399 void draw_board(void);
400 void centerview(void);
404 void rightview(void);
410 void fmtship(char *, size_t, const char *, struct ship *);
411 void makesignal(struct ship *, const char *, struct ship *, ...);
412 bool sync_exists(int);
414 void sync_close(char);
415 void Write(int, struct ship *, char, int, int, int, int);