Write(CAPTURED) after using it.
[unix-history] / usr / src / games / sail / extern.h
CommitLineData
261fa12c 1/*
6ca45914 2 * @(#)extern.h 2.3 83/12/17
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
6ca45914
EW
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)
b3a57661 29
2a43399b 30#define sterncolour(sp) ((sp)->file->stern+'0'-((sp)->file->captured?10:0))
b3a57661
EW
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
261fa12c 45
b3a57661
EW
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
6ca45914 70#define W_MOVE 13
b3a57661
EW
71#define W_OBP 14
72#define W_PCREW 15
6ca45914 73#define W_UNFOUL 16
b3a57661
EW
74#define W_POINTS 17
75#define W_QUAL 18
6ca45914 76#define W_UNGRAP 19
b3a57661 77#define W_RIGG 20
6ca45914
EW
78#define W_COL 21
79#define W_DIR 22
80#define W_ROW 23
b3a57661
EW
81#define W_SIGNAL 24
82#define W_SINK 25
83#define W_STRUCK 26
84#define W_TA 27
6c17b19a 85#define W_ALIVE 28
b3a57661
EW
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
6c17b19a
EW
94#define W_BEGIN 37
95#define W_END 38
261fa12c
CL
96
97struct logs {
b3a57661
EW
98 char l_name[20];
99 int l_uid;
100 int l_shipnum;
101 int l_gamenum;
102 int l_netpoints;
261fa12c
CL
103};
104
2016bd8e 105struct BP {
1eda8103 106 short turnsent;
b3a57661 107 struct ship *toship;
1eda8103 108 short mensent;
261fa12c
CL
109};
110
2016bd8e 111struct snag {
6ca45914
EW
112 short sn_count;
113 short sn_turn;
261fa12c
CL
114};
115
d95a9c3b 116#define NSCENE nscene
b3a57661
EW
117#define NSHIP 10
118#define NBP 3
119
d95a9c3b 120#define NNATION 8
b3a57661
EW
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
d95a9c3b
EW
126#define N_D 5
127#define N_K 6
128#define N_O 7
261fa12c 129
2016bd8e 130struct File {
6ca45914 131 int index;
b3a57661 132 char captain[20]; /* 0 */
1eda8103
EW
133 short points; /* 20 */
134 char loadL; /* 22 */
135 char loadR; /* 24 */
136 char readyL; /* 26 */
137 char readyR; /* 28 */
b3a57661
EW
138 struct BP OBP[NBP]; /* 30 */
139 struct BP DBP[NBP]; /* 48 */
1eda8103 140 char struck; /* 66 */
b3a57661 141 struct ship *captured; /* 68 */
1eda8103 142 short pcrew; /* 70 */
6ca45914 143 char movebuf[10]; /* 72 */
1eda8103 144 char drift; /* 82 */
6ca45914
EW
145 short nfoul;
146 short ngrap;
147 struct snag foul[NSHIP]; /* 84 */
148 struct snag grap[NSHIP]; /* 124 */
1eda8103
EW
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;
261fa12c
CL
160};
161
b3a57661
EW
162struct ship {
163 char *shipname; /* 0 */
164 struct shipspecs *specs; /* 2 */
1eda8103
EW
165 char nationality; /* 4 */
166 short shiprow; /* 6 */
167 short shipcol; /* 8 */
168 char shipdir; /* 10 */
b3a57661
EW
169 struct File *file; /* 12 */
170};
261fa12c
CL
171
172struct scenario {
1eda8103
EW
173 char winddir; /* 0 */
174 char windspeed; /* 2 */
175 char windchange; /* 4 */
1eda8103 176 char vessels; /* 12 */
b3a57661
EW
177 char *name; /* 14 */
178 struct ship ship[NSHIP]; /* 16 */
261fa12c 179};
d95a9c3b
EW
180struct scenario scene[];
181int nscene;
261fa12c
CL
182
183struct shipspecs {
1eda8103
EW
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;
261fa12c 203};
2016bd8e 204struct shipspecs specs[];
261fa12c 205
b3a57661
EW
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
2016bd8e 212struct windeffects {
1eda8103 213 char A, B, C, D;
2016bd8e
EW
214};
215struct windeffects WET[7][6];
216
217struct Tables {
1eda8103 218 char H, G, C, R;
2016bd8e
EW
219};
220struct Tables RigTable[11][6];
221struct Tables HullTable[11][6];
261fa12c 222
1eda8103
EW
223char AMMO[9][4];
224char HDT[9][10];
225char HDTrake[9][10];
226char QUAL[9][5];
227char MT[9][3];
261fa12c 228
b3a57661
EW
229char *countryname[];
230char *classname[];
231char *directionname[];
232char *qualname[];
233char loadname[];
234
1eda8103 235char rangeofshot[];
b3a57661
EW
236
237char dr[], dc[];
238
6c17b19a
EW
239int winddir;
240int windspeed;
241int turn;
b3a57661 242int game;
6c17b19a
EW
243int alive;
244int people;
0f5fabce 245char isplayer;
261fa12c 246
261fa12c 247char *info();
261fa12c 248char *quality();
261fa12c 249double arctan();
b3a57661
EW
250char *saywhat();
251struct ship *closestenemy();
252
253char *calloc();
254char *strcpy();
255char *strcat();
256char *strncpy();
257char *getenv();
258char *gets();