]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - sail/extern.h
1 /* $NetBSD: extern.h,v 1.27 2004/02/08 00:32:48 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. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * @(#)externs.h 8.1 (Berkeley) 5/31/93
34 #include <sys/types.h>
44 /* command line flags */
45 extern int randomize
; /* -x, give first available ship */
46 extern int longfmt
; /* -l, print score in long format */
47 extern int nobells
; /* -b, don't ring bell before Signal */
49 /* other initial modes */
53 #define dieroll() ((random()) % 6 + 1)
54 #define sqr(a) ((a) * (a))
55 #define min(a,b) ((a) < (b) ? (a) : (b))
57 #define grappled(a) ((a)->file->ngrap)
58 #define fouled(a) ((a)->file->nfoul)
59 #define snagged(a) (grappled(a) + fouled(a))
61 #define grappled2(a, b) ((a)->file->grap[(b)->file->index].sn_count)
62 #define fouled2(a, b) ((a)->file->foul[(b)->file->index].sn_count)
63 #define snagged2(a, b) (grappled2(a, b) + fouled2(a, b))
65 #define Xgrappled2(a, b) ((a)->file->grap[(b)->file->index].sn_turn < turn-1 ? grappled2(a, b) : 0)
66 #define Xfouled2(a, b) ((a)->file->foul[(b)->file->index].sn_turn < turn-1 ? fouled2(a, b) : 0)
67 #define Xsnagged2(a, b) (Xgrappled2(a, b) + Xfouled2(a, b))
69 #define cleangrapple(a, b, c) Cleansnag(a, b, c, 1)
70 #define cleanfoul(a, b, c) Cleansnag(a, b, c, 2)
71 #define cleansnag(a, b, c) Cleansnag(a, b, c, 3)
73 #define sterncolour(sp) ((sp)->file->stern+'0'-((sp)->file->captured?10:0))
74 #define sternrow(sp) ((sp)->file->row + dr[(sp)->file->dir])
75 #define sterncol(sp) ((sp)->file->col + dc[(sp)->file->dir])
77 #define capship(sp) ((sp)->file->captured?(sp)->file->captured:(sp))
79 #define readyname(r) ((r) & R_LOADING ? '*' : ((r) & R_INITIAL ? '!' : ' '))
81 /* loadL and loadR, should match loadname[] */
82 #define L_EMPTY 0 /* should be 0, don't change */
90 * readyL and readyR, these are bits, except R_EMPTY
92 #define R_EMPTY 0 /* not loaded and not loading */
93 #define R_LOADING 1 /* loading */
94 #define R_DOUBLE 2 /* loading double */
95 #define R_LOADED 4 /* loaded */
96 #define R_INITIAL 8 /* loaded initial */
161 #define NSCENE nscene
177 char captain
[20]; /* 0 */
178 short points
; /* 20 */
179 unsigned char loadL
; /* 22 */
180 unsigned char loadR
; /* 24 */
181 unsigned char readyL
; /* 26 */
182 unsigned char readyR
; /* 28 */
183 struct BP OBP
[NBP
]; /* 30 */
184 struct BP DBP
[NBP
]; /* 48 */
185 char struck
; /* 66 */
186 struct ship
*captured
; /* 68 */
187 short pcrew
; /* 70 */
188 char movebuf
[10]; /* 72 */
192 struct snag foul
[NSHIP
]; /* 84 */
193 struct snag grap
[NSHIP
]; /* 124 */
198 char explode
; /* 232 */
208 const char *shipname
; /* 0 */
209 struct shipspecs
*specs
; /* 2 */
210 unsigned char nationality
; /* 4 */
211 short shiprow
; /* 6 */
212 short shipcol
; /* 8 */
213 char shipdir
; /* 10 */
214 struct File
*file
; /* 12 */
218 char winddir
; /* 0 */
219 char windspeed
; /* 2 */
220 char windchange
; /* 4 */
221 unsigned char vessels
; /* 12 */
222 const char *name
; /* 14 */
223 struct ship ship
[NSHIP
]; /* 16 */
225 extern struct scenario scene
[];
249 extern struct shipspecs specs
[];
251 extern struct scenario
*cc
; /* the current scenario */
252 extern struct ship
*ls
; /* &cc->ship[cc->vessels] */
254 #define SHIP(s) (&cc->ship[s])
255 #define foreachship(sp) for ((sp) = cc->ship; (sp) < ls; (sp)++)
260 extern const struct windeffects WET
[7][6];
265 extern const struct Tables RigTable
[11][6];
266 extern const struct Tables HullTable
[11][6];
268 extern const char AMMO
[9][4];
269 extern const char HDT
[9][10];
270 extern const char HDTrake
[9][10];
271 extern const char QUAL
[9][5];
272 extern const char MT
[9][3];
274 extern const char *const countryname
[];
275 extern const char *const classname
[];
276 extern const char *const directionname
[];
277 extern const char *const qualname
[];
278 extern const char loadname
[];
280 extern const char rangeofshot
[];
282 extern const char dr
[], dc
[];
285 extern int windspeed
;
290 extern int hasdriver
;
293 void table (struct ship
*, struct ship
*, int, int, int, int);
294 void Cleansnag (struct ship
*, struct ship
*, int, int);
298 void boardcomp (void);
300 void compcombat (void);
304 void thinkofgrapples (void);
306 void prizecheck (void);
307 void closeon (struct ship
*, struct ship
*, char *, int, int, int);
311 void sendbp (struct ship
*, struct ship
*, int, int);
312 int is_toughmelee (struct ship
*, struct ship
*, int, int);
314 void checksails (void);
317 void ungrap (struct ship
*, struct ship
*);
318 void grap (struct ship
*, struct ship
*);
321 void subtract (struct ship
*, struct ship
*, int, int [3], int);
322 int mensent (struct ship
*, struct ship
*, int[3], struct ship
**, int *,
329 int maxturns (struct ship
*, char *);
330 int maxmove (struct ship
*, int, int);
336 int range (struct ship
*, struct ship
*);
337 struct ship
*closestenemy (struct ship
*, int, int);
338 int gunsbear (struct ship
*, struct ship
*);
339 int portside (struct ship
*, struct ship
*, int);
340 int colours (struct ship
*);
341 void logger (struct ship
*);
344 int meleeing (struct ship
*, struct ship
*);
345 int boarding (struct ship
*, int);
346 void unboard (struct ship
*, struct ship
*, int);
349 void leave (int) __attribute__((__noreturn__
));
350 void choke (int) __attribute__((__noreturn__
));
354 void play (void) __attribute__((__noreturn__
));
357 void acceptcombat (void);
358 void grapungrap (void);
359 void unfoulplayer (void);
362 void changesail (void);
363 void acceptsignal (void);
365 const char *saywhat (struct ship
*, int);
366 void eyeball (struct ship
*);
369 void acceptmove (void);
370 void acceptboard (void);
374 void loadplayer (void);
377 void initscreen (void);
378 void cleanupscreen (void);
380 void Signal (const char *, struct ship
*, ...)
381 __attribute__((__format__(__printf__
,1,3)));
382 void Msg (const char *, ...)
383 __attribute__((__format__(__printf__
,1,2)));
384 void prompt (const char *, struct ship
*);
385 int sgetch (const char *, struct ship
*, int);
386 void sgetstr (const char *, char *, int);
387 void draw_screen (void);
388 void draw_view (void);
389 void draw_turn (void);
390 void draw_stat (void);
391 void draw_slot (void);
392 void draw_board (void);
393 void centerview (void);
395 void downview (void);
396 void leftview (void);
397 void rightview (void);
403 void fmtship (char *, size_t, const char *, struct ship
*);
404 void makesignal (struct ship
*, const char *, struct ship
*, ...)
405 __attribute__((__format__(__printf__
,2,4)));
406 void makemsg (struct ship
*, const char *, ...)
407 __attribute__((__format__(__printf__
,2,3)));
408 int sync_exists (int);
409 int sync_open (void);
410 void sync_close (int);
411 void Write (int, struct ship
*, long, long, long, long);
412 void Writestr (int, struct ship
*, const char *);