]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - sail/extern.h
1 /* $NetBSD: extern.h,v 1.38 2011/08/29 20:30:37 joerg 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>
45 /* command line flags */
46 extern bool randomize
; /* -x, give first available ship */
47 extern bool longfmt
; /* -l, print score in long format */
48 extern bool nobells
; /* -b, don't ring bell before Signal */
50 /* other initial data */
53 #define MAXNAMESIZE 20
54 extern char myname
[MAXNAMESIZE
];
56 #define dieroll() ((random()) % 6 + 1)
57 #define sqr(a) ((a) * (a))
58 #define min(a,b) ((a) < (b) ? (a) : (b))
60 #define grappled(a) ((a)->file->ngrap)
61 #define fouled(a) ((a)->file->nfoul)
62 #define snagged(a) (grappled(a) + fouled(a))
64 #define grappled2(a, b) ((a)->file->grap[(b)->file->index].sn_count)
65 #define fouled2(a, b) ((a)->file->foul[(b)->file->index].sn_count)
66 #define snagged2(a, b) (grappled2(a, b) + fouled2(a, b))
68 #define Xgrappled2(a, b) ((a)->file->grap[(b)->file->index].sn_turn < turn-1 \
69 ? grappled2(a, b) : 0)
70 #define Xfouled2(a, b) ((a)->file->foul[(b)->file->index].sn_turn < turn-1 \
72 #define Xsnagged2(a, b) (Xgrappled2(a, b) + Xfouled2(a, b))
74 #define cleangrapple(a, b, c) Cleansnag(a, b, c, 1)
75 #define cleanfoul(a, b, c) Cleansnag(a, b, c, 2)
76 #define cleansnag(a, b, c) Cleansnag(a, b, c, 3)
78 #define sterncolour(sp) ((sp)->file->stern+'0'-((sp)->file->captured ? 10 : 0))
79 #define sternrow(sp) ((sp)->file->row + dr[(sp)->file->dir])
80 #define sterncol(sp) ((sp)->file->col + dc[(sp)->file->dir])
82 #define capship(sp) ((sp)->file->captured?(sp)->file->captured:(sp))
84 #define readyname(r) ((r) & R_LOADING ? '*' : ((r) & R_INITIAL ? '!' : ' '))
86 /* loadL and loadR, should match loadname[] */
87 #define L_EMPTY 0 /* should be 0, don't change */
95 * readyL and readyR, these are bits, except R_EMPTY
97 #define R_EMPTY 0 /* not loaded and not loading */
98 #define R_LOADING 1 /* loading */
99 #define R_DOUBLE 2 /* loading double */
100 #define R_LOADED 4 /* loaded */
101 #define R_INITIAL 8 /* loaded initial */
108 char l_name
[MAXNAMESIZE
];
126 #define NSCENE /*nscene*/ 32
142 char captain
[MAXNAMESIZE
]; /* 0 */
143 short points
; /* 20 */
144 unsigned char loadL
; /* 22 */
145 unsigned char loadR
; /* 24 */
146 unsigned char readyL
; /* 26 */
147 unsigned char readyR
; /* 28 */
148 struct BP OBP
[NBP
]; /* 30 */
149 struct BP DBP
[NBP
]; /* 48 */
150 char struck
; /* 66 */
151 struct ship
*captured
; /* 68 */
152 short pcrew
; /* 70 */
153 char movebuf
[10]; /* 72 */
157 struct snag foul
[NSHIP
]; /* 84 */
158 struct snag grap
[NSHIP
]; /* 124 */
163 char explode
; /* 232 */
173 const char *shipname
; /* 0 */
174 struct shipspecs
*specs
; /* 2 */
175 unsigned char nationality
; /* 4 */
176 short shiprow
; /* 6 */
177 short shipcol
; /* 8 */
178 char shipdir
; /* 10 */
179 struct File
*file
; /* 12 */
183 char winddir
; /* 0 */
184 char windspeed
; /* 2 */
185 char windchange
; /* 4 */
186 unsigned char vessels
; /* 12 */
187 const char *name
; /* 14 */
188 struct ship ship
[NSHIP
]; /* 16 */
190 extern struct scenario scene
[NSCENE
];
215 extern struct scenario
*cc
; /* the current scenario */
216 extern struct ship
*ls
; /* &cc->ship[cc->vessels] */
218 #define SHIP(s) (&cc->ship[s])
219 #define foreachship(sp) for ((sp) = cc->ship; (sp) < ls; (sp)++)
224 extern const struct windeffects WET
[7][6];
229 extern const struct Tables RigTable
[11][6];
230 extern const struct Tables HullTable
[11][6];
232 extern const char AMMO
[9][4];
233 extern const char HDT
[9][10];
234 extern const char HDTrake
[9][10];
235 extern const char QUAL
[9][5];
236 extern const char MT
[9][3];
238 extern const char *const countryname
[];
239 extern const char *const shortclassname
[];
240 extern const char *const classname
[];
241 extern const char *const directionname
[];
242 extern const char *const qualname
[];
243 extern const char loadname
[];
245 extern const char rangeofshot
[];
247 extern const char dr
[], dc
[];
250 extern int windspeed
;
255 extern int hasdriver
;
259 void table(struct ship
*, struct ship
*, int, int, int, int);
260 void Cleansnag(struct ship
*, struct ship
*, int, int);
264 void boardcomp(void);
266 void compcombat(void);
270 void thinkofgrapples(void);
272 void prizecheck(void);
273 void closeon(struct ship
*, struct ship
*, char *, size_t, int, int, bool);
277 void sendbp(struct ship
*, struct ship
*, int, int);
278 int is_toughmelee(struct ship
*, struct ship
*, int, int);
280 void checksails(void);
283 void ungrap(struct ship
*, struct ship
*);
284 void grap(struct ship
*, struct ship
*);
287 void subtract(struct ship
*, struct ship
*, int, int [3], int);
288 int mensent(struct ship
*, struct ship
*, int[3], struct ship
**, int *, int);
292 void startdriver(void);
295 int maxturns(struct ship
*, bool *);
296 int maxmove(struct ship
*, int, int);
299 void lo_curses(void);
303 int range(struct ship
*, struct ship
*);
304 struct ship
*closestenemy(struct ship
*, int, int);
305 int gunsbear(struct ship
*, struct ship
*);
306 int portside(struct ship
*, struct ship
*, int);
307 int colours(struct ship
*);
308 void logger(struct ship
*);
311 int meleeing(struct ship
*, struct ship
*);
312 int boarding(struct ship
*, int);
313 void unboard(struct ship
*, struct ship
*, int);
316 void leave(int) __dead
;
317 void choke(int) __dead
;
322 void play(void) __dead
;
325 void acceptcombat(void);
326 void grapungrap(void);
327 void unfoulplayer(void);
330 void changesail(void);
331 void acceptsignal(void);
333 const char *saywhat(struct ship
*, int);
334 void eyeball(struct ship
*);
337 void acceptmove(void);
338 void acceptboard(void);
342 void loadplayer(void);
345 void initscreen(void);
346 void cleanupscreen(void);
347 void Signal(const char *, struct ship
*, ...) __printflike(1,3);
348 void Msg(const char *, ...) __printflike(1,2);
349 int sgetch(const char *, struct ship
*, int);
350 void sgetstr(const char *, char *, int);
351 void centerview(void);
355 void rightview(void);
359 void pl_main_init(void);
360 void pl_main_uninit(void);
361 __dead
void pl_main(void);
364 void fmtship(char *, size_t, const char *, struct ship
*);
365 void makesignal(struct ship
*, const char *, struct ship
*, ...)
367 void makemsg(struct ship
*, const char *, ...) __printflike(2, 3);
368 int sync_exists(int);
370 void sync_close(int);
373 void send_captain(struct ship
*ship
, const char *astr
);
374 void send_captured(struct ship
*ship
, long a
);
375 void send_class(struct ship
*ship
, long a
);
376 void send_crew(struct ship
*ship
, long a
, long b
, long c
);
377 void send_dbp(struct ship
*ship
, long a
, long b
, long c
, long d
);
378 void send_drift(struct ship
*ship
, long a
);
379 void send_explode(struct ship
*ship
, long a
);
380 void send_foul(struct ship
*ship
, long a
);
381 void send_gunl(struct ship
*ship
, long a
, long b
);
382 void send_gunr(struct ship
*ship
, long a
, long b
);
383 void send_hull(struct ship
*ship
, long a
);
384 void send_move(struct ship
*ship
, const char *astr
);
385 void send_obp(struct ship
*ship
, long a
, long b
, long c
, long d
);
386 void send_pcrew(struct ship
*ship
, long a
);
387 void send_unfoul(struct ship
*ship
, long a
, long b
);
388 void send_points(struct ship
*ship
, long a
);
389 void send_qual(struct ship
*ship
, long a
);
390 void send_ungrap(struct ship
*ship
, long a
, long b
);
391 void send_rigg(struct ship
*ship
, long a
, long b
, long c
, long d
);
392 void send_col(struct ship
*ship
, long a
);
393 void send_dir(struct ship
*ship
, long a
);
394 void send_row(struct ship
*ship
, long a
);
395 void send_signal(struct ship
*ship
, const char *astr
);
396 void send_sink(struct ship
*ship
, long a
);
397 void send_struck(struct ship
*ship
, long a
);
398 void send_ta(struct ship
*ship
, long a
);
399 void send_alive(void);
400 void send_turn(long a
);
401 void send_wind(long a
, long b
);
402 void send_fs(struct ship
*ship
, long a
);
403 void send_grap(struct ship
*ship
, long a
);
404 void send_rig1(struct ship
*ship
, long a
);
405 void send_rig2(struct ship
*ship
, long a
);
406 void send_rig3(struct ship
*ship
, long a
);
407 void send_rig4(struct ship
*ship
, long a
);
408 void send_begin(struct ship
*ship
);
409 void send_end(struct ship
*ship
);
410 void send_ddead(void);