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