new version
[unix-history] / usr / src / games / sail / extern.h
CommitLineData
261fa12c 1/*
ce837792 2 * @(#)extern.h 2.1 83/10/31
261fa12c
CL
3 */
4#include <stdio.h>
5#include <signal.h>
6#include <ctype.h>
7#include "machdep.h"
8
b3a57661
EW
9#define die() ((rand() >> 3) % 6 + 1)
10#define sqr(a) ((a) * (a))
11#define abs(a) ((a) > 0 ? (a) : -(a))
12#define min(a,b) ((a) < (b) ? (a) : (b))
13
14#define grappled(a) Snagged(a, 1)
15#define fouled(a) Snagged(a, 0)
16#define snagged(a) (Snagged(a, 0) || Snagged(a, 1))
17#define grappled2(a,b) Snagged2(a, b, 1, 0)
18#define fouled2(a,b) Snagged2(a, b, 0, 0)
19#define snagged2(a,b) (Snagged2(a, b, 0, 0) || Snagged2(a, b, 1, 0))
20#define Xgrappled2(a,b) Snagged2(a, b, 1, 1)
21#define Xfouled2(a,b) Snagged2(a, b, 0, 1)
22#define Xsnagged2(a,b) (Snagged2(a, b, 0, 1) || Snagged2(a, b, 1, 1))
23
24#define sterncolour(sp) ((sp)->file->stern+'0'-((sp)->file->captured?16:0))
25#define sternrow(sp) ((sp)->file->row + dr[(sp)->file->dir])
26#define sterncol(sp) ((sp)->file->col + dc[(sp)->file->dir])
27
28#define capship(sp) ((sp)->file->captured?(sp)->file->captured:(sp))
29
30#define readyname(r) ((r) & R_LOADING ? '*' : ((r) & R_INITIAL ? '!' : ' '))
31
32/* loadL and loadR, should match loadname[] */
33#define L_EMPTY 0 /* should be 0, don't change */
34#define L_GRAPE 1
35#define L_CHAIN 2
36#define L_ROUND 3
37#define L_DOUBLE 4
38#define L_EXPLODE 5
261fa12c 39
b3a57661
EW
40/*
41 * readyL and readyR, these are bits, except R_EMPTY
42 */
43#define R_EMPTY 0 /* not loaded and not loading */
44#define R_LOADING 1 /* loading */
45#define R_DOUBLE 2 /* loading double */
46#define R_LOADED 4 /* loaded */
47#define R_INITIAL 8 /* loaded initial */
48
49#define HULL 0
50#define RIGGING 1
51
52#define W_CAPTAIN 1
53#define W_CAPTURED 2
54#define W_CLASS 3
55#define W_CREW 4
56#define W_DBP 5
57#define W_DRIFT 6
58#define W_EXPLODE 7
59#define W_FILE 8
60#define W_FOUL 9
61#define W_GUNL 10
62#define W_GUNR 11
63#define W_HULL 12
64#define W_LAST 13
65#define W_OBP 14
66#define W_PCREW 15
6c17b19a 67/* 16 */
b3a57661
EW
68#define W_POINTS 17
69#define W_QUAL 18
70/* 19 */
71#define W_RIGG 20
72#define W_SHIPCOL 21
73#define W_SHIPDIR 22
74#define W_SHIPROW 23
75#define W_SIGNAL 24
76#define W_SINK 25
77#define W_STRUCK 26
78#define W_TA 27
6c17b19a 79#define W_ALIVE 28
b3a57661
EW
80#define W_TURN 29
81#define W_WIND 30
82#define W_FS 31
83#define W_GRAP 32
84#define W_RIG1 33
85#define W_RIG2 34
86#define W_RIG3 35
87#define W_RIG4 36
6c17b19a
EW
88#define W_BEGIN 37
89#define W_END 38
261fa12c
CL
90
91struct logs {
b3a57661
EW
92 char l_name[20];
93 int l_uid;
94 int l_shipnum;
95 int l_gamenum;
96 int l_netpoints;
261fa12c
CL
97};
98
2016bd8e 99struct BP {
1eda8103 100 short turnsent;
b3a57661 101 struct ship *toship;
1eda8103 102 short mensent;
261fa12c
CL
103};
104
2016bd8e 105struct snag {
1eda8103 106 short turnfoul;
b3a57661 107 struct ship *toship;
261fa12c
CL
108};
109
d95a9c3b 110#define NSCENE nscene
b3a57661
EW
111#define NSHIP 10
112#define NBP 3
113
d95a9c3b 114#define NNATION 8
b3a57661
EW
115#define N_A 0
116#define N_B 1
117#define N_S 2
118#define N_F 3
119#define N_J 4
d95a9c3b
EW
120#define N_D 5
121#define N_K 6
122#define N_O 7
261fa12c 123
2016bd8e 124struct File {
b3a57661 125 char captain[20]; /* 0 */
1eda8103
EW
126 short points; /* 20 */
127 char loadL; /* 22 */
128 char loadR; /* 24 */
129 char readyL; /* 26 */
130 char readyR; /* 28 */
b3a57661
EW
131 struct BP OBP[NBP]; /* 30 */
132 struct BP DBP[NBP]; /* 48 */
1eda8103 133 char struck; /* 66 */
b3a57661 134 struct ship *captured; /* 68 */
1eda8103 135 short pcrew; /* 70 */
b3a57661 136 char last[10]; /* 72 */
1eda8103 137 char drift; /* 82 */
b3a57661
EW
138 struct snag fouls[NSHIP]; /* 84 */
139 struct snag grapples[NSHIP]; /* 124 */
1eda8103
EW
140 char RH; /* 224 */
141 char RG; /* 226 */
142 char RR; /* 228 */
143 char FS; /* 230 */
144 char explode; /* 232 */
145 char sink; /* 234 */
146 char dir;
147 short col;
148 short row;
149 char loadwith;
150 char stern;
261fa12c
CL
151};
152
b3a57661
EW
153struct ship {
154 char *shipname; /* 0 */
155 struct shipspecs *specs; /* 2 */
1eda8103
EW
156 char nationality; /* 4 */
157 short shiprow; /* 6 */
158 short shipcol; /* 8 */
159 char shipdir; /* 10 */
b3a57661
EW
160 struct File *file; /* 12 */
161};
261fa12c
CL
162
163struct scenario {
1eda8103
EW
164 char winddir; /* 0 */
165 char windspeed; /* 2 */
166 char windchange; /* 4 */
1eda8103 167 char vessels; /* 12 */
b3a57661
EW
168 char *name; /* 14 */
169 struct ship ship[NSHIP]; /* 16 */
261fa12c 170};
d95a9c3b
EW
171struct scenario scene[];
172int nscene;
261fa12c
CL
173
174struct shipspecs {
1eda8103
EW
175 char bs;
176 char fs;
177 char ta;
178 short guns;
179 char class;
180 char hull;
181 char qual;
182 char crew1;
183 char crew2;
184 char crew3;
185 char gunL;
186 char gunR;
187 char carL;
188 char carR;
189 char rig1;
190 char rig2;
191 char rig3;
192 char rig4;
193 short pts;
261fa12c 194};
2016bd8e 195struct shipspecs specs[];
261fa12c 196
b3a57661
EW
197struct scenario *cc; /* the current scenario */
198struct ship *ls; /* &cc->ship[cc->vessels] */
199
200#define SHIP(s) (&cc->ship[s])
201#define foreachship(sp) for ((sp) = cc->ship; (sp) < ls; (sp)++)
202
2016bd8e 203struct windeffects {
1eda8103 204 char A, B, C, D;
2016bd8e
EW
205};
206struct windeffects WET[7][6];
207
208struct Tables {
1eda8103 209 char H, G, C, R;
2016bd8e
EW
210};
211struct Tables RigTable[11][6];
212struct Tables HullTable[11][6];
261fa12c 213
1eda8103
EW
214char AMMO[9][4];
215char HDT[9][10];
216char HDTrake[9][10];
217char QUAL[9][5];
218char MT[9][3];
261fa12c 219
b3a57661
EW
220char *countryname[];
221char *classname[];
222char *directionname[];
223char *qualname[];
224char loadname[];
225
1eda8103 226char rangeofshot[];
b3a57661
EW
227
228char dr[], dc[];
229
6c17b19a
EW
230int winddir;
231int windspeed;
232int turn;
b3a57661 233int game;
6c17b19a
EW
234int alive;
235int people;
0f5fabce 236char isplayer;
261fa12c 237
261fa12c 238char *info();
261fa12c 239char *quality();
261fa12c 240double arctan();
b3a57661
EW
241char *saywhat();
242struct ship *closestenemy();
243
244char *calloc();
245char *strcpy();
246char *strcat();
247char *strncpy();
248char *getenv();
249char *gets();