]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - hunt/huntd/hunt.h
Remove empty header file.
[bsdgames-darwin.git] / hunt / huntd / hunt.h
1 /* $NetBSD: hunt.h,v 1.22 2014/03/29 20:16:09 dholland Exp $ */
2
3 /*
4 * Copyright (c) 1983-2003, Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met:
10 *
11 * + Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * + Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * + Neither the name of the University of California, San Francisco nor
17 * the names of its contributors may be used to endorse or promote
18 * products derived from this software without specific prior written
19 * permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #include <stdbool.h>
35 #include <stdio.h>
36 #include <string.h>
37
38 #ifdef LOG
39 #include <syslog.h>
40 #endif
41
42 #include <sys/ioctl.h>
43 #include <sys/types.h>
44 #include <sys/uio.h>
45 #include <sys/poll.h>
46
47 #ifdef INTERNET
48 #include <netinet/in.h>
49 #include <netdb.h>
50 #include <arpa/inet.h>
51 #include <net/if.h>
52 #else
53 #include <sys/un.h>
54 #endif
55
56 #ifdef INTERNET
57 #define SOCK_FAMILY AF_INET
58 #else
59 #define SOCK_FAMILY AF_UNIX
60 #define AF_UNIX_HACK /* 4.2 hack; leaves files around */
61 #endif
62
63 /*
64 * Preprocessor define dependencies
65 */
66 #if defined(VOLCANO) && !defined(OOZE)
67 #define OOZE
68 #endif
69 #if defined(BOOTS) && !defined(FLY)
70 #define FLY
71 #endif
72 #if !defined(REFLECT) && !defined(RANDOM)
73 #define RANDOM
74 #endif
75
76 /* decrement version number for each change in startup protocol */
77 #define HUNT_VERSION -1
78
79 #define ADDCH ('a' | 0200)
80 #define MOVE ('m' | 0200)
81 #define REFRESH ('r' | 0200)
82 #define CLRTOEOL ('c' | 0200)
83 #define ENDWIN ('e' | 0200)
84 #define CLEAR ('C' | 0200)
85 #define REDRAW ('R' | 0200)
86 #define LAST_PLAYER ('l' | 0200)
87 #define BELL ('b' | 0200)
88 #define READY ('g' | 0200)
89
90 /*
91 * Choose MAXPL and MAXMON carefully. The screen is assumed to be
92 * 23 lines high and will only tolerate (MAXPL == 17 && MAXMON == 0)
93 * or (MAXPL + MAXMON <= 16).
94 */
95 #ifdef MONITOR
96 #define MAXPL 15
97 #define MAXMON 1
98 #else
99 #define MAXPL 17
100 #define MAXMON 0
101 #endif
102 #define SHORTLEN 2 /* sizeof (network short) */
103 #define LONGLEN 4 /* sizeof (network long) */
104 #define NAMELEN 20
105 #define MSGLEN SCREEN_WIDTH
106 #define DECAY 50.0
107
108 #define NASCII 128
109
110 #define WIDTH 51
111 #define WIDTH2 64 /* Next power of 2 >= WIDTH (for fast access) */
112 #define HEIGHT 23
113 #define UBOUND 1
114 #define DBOUND (HEIGHT - 1)
115 #define LBOUND 1
116 #define RBOUND (WIDTH - 1)
117
118 #define SCREEN_HEIGHT 24
119 #define SCREEN_WIDTH 80
120 #define SCREEN_WIDTH2 128 /* Next power of 2 >= SCREEN_WIDTH */
121
122 #define STAT_LABEL_COL 60
123 #define STAT_VALUE_COL 74
124 #define STAT_NAME_COL 61
125 #define STAT_SCAN_COL (STAT_NAME_COL + 5)
126 #define STAT_AMMO_ROW 0
127 #define STAT_GUN_ROW 1
128 #define STAT_DAM_ROW 2
129 #define STAT_KILL_ROW 3
130 #define STAT_PLAY_ROW 5
131 #ifdef MONITOR
132 #define STAT_MON_ROW (STAT_PLAY_ROW + MAXPL + 1)
133 #endif
134 #define STAT_NAME_LEN 18
135
136 #define DOOR '#'
137 #define WALL1 '-'
138 #define WALL2 '|'
139 #define WALL3 '+'
140 #ifdef REFLECT
141 #define WALL4 '/'
142 #define WALL5 '\\'
143 #endif
144 #define KNIFE 'K'
145 #define SHOT ':'
146 #define GRENADE 'o'
147 #define SATCHEL 'O'
148 #define BOMB '@'
149 #define MINE ';'
150 #define GMINE 'g'
151 #ifdef OOZE
152 #define SLIME '$'
153 #endif
154 #ifdef VOLCANO
155 #define LAVA '~'
156 #endif
157 #ifdef DRONE
158 #define DSHOT '?'
159 #endif
160 #ifdef FLY
161 #define FALL 'F'
162 #endif
163 #ifdef BOOTS
164 #define NBOOTS 2
165 #define BOOT 'b'
166 #define BOOT_PAIR 'B'
167 #endif
168 #define SPACE ' '
169
170 #define ABOVE 'i'
171 #define BELOW '!'
172 #define RIGHT '}'
173 #define LEFTS '{'
174 #ifdef FLY
175 #define FLYER '&'
176 #define isplayer(c) (c == LEFTS || c == RIGHT ||\
177 c == ABOVE || c == BELOW || c == FLYER)
178 #else
179 #define isplayer(c) (c == LEFTS || c == RIGHT ||\
180 c == ABOVE || c == BELOW)
181 #endif
182
183 #define NORTH 01
184 #define SOUTH 02
185 #define EAST 010
186 #define WEST 020
187
188 #undef CTRL
189 #define CTRL(x) ((x) & 037)
190
191 #define BULSPD 5 /* bullets movement speed */
192 #define ISHOTS 15
193 #define NSHOTS 5
194 #define MAXNCSHOT 2
195 #define MAXDAM 10
196 #define MINDAM 5
197 #define STABDAM 2
198
199 #define BULREQ 1
200 #define GRENREQ 9
201 #define SATREQ 25
202 #define BOMB7REQ 49
203 #define BOMB9REQ 81
204 #define BOMB11REQ 121
205 #define BOMB13REQ 169
206 #define BOMB15REQ 225
207 #define BOMB17REQ 289
208 #define BOMB19REQ 361
209 #define BOMB21REQ 441
210 #define MAXBOMB 11
211 #ifdef DRONE
212 #define MINDSHOT 2 /* At least a satchel bomb */
213 #endif
214 extern int shot_req[];
215 extern int shot_type[];
216 #ifdef OOZE
217 #define SLIME_FACTOR 3
218 #define SLIMEREQ 5
219 #define SSLIMEREQ 10
220 #define SLIME2REQ 15
221 #define SLIME3REQ 20
222 #define MAXSLIME 4
223 #define SLIMESPEED 5
224 extern int slime_req[];
225 #endif
226 #ifdef VOLCANO
227 #define LAVASPEED 1
228 #endif
229
230 #define CLOAKLEN 20
231 #define SCANLEN (Nplayer * 20)
232 #define EXPLEN 4
233
234 #define Q_QUIT 0
235 #define Q_CLOAK 1
236 #define Q_FLY 2
237 #define Q_SCAN 3
238 #define Q_MESSAGE 4
239
240 #define C_PLAYER 0
241 #define C_MONITOR 1
242 #define C_MESSAGE 2
243 #define C_SCORES 3
244
245 #ifdef MONITOR
246 #define C_TESTMSG() (Query_driver ? C_MESSAGE :\
247 (Show_scores ? C_SCORES :\
248 (Am_monitor ? C_MONITOR :\
249 C_PLAYER)))
250 #else
251 #define C_TESTMSG() (Show_scores ? C_SCORES :\
252 (Query_driver ? C_MESSAGE :\
253 C_PLAYER))
254 #endif
255
256 #ifdef FLY
257 #define _scan_char(pp) (((pp)->p_scan < 0) ? ' ' : '*')
258 #define _cloak_char(pp) (((pp)->p_cloak < 0) ? _scan_char(pp) : '+')
259 #define stat_char(pp) (((pp)->p_flying < 0) ? _cloak_char(pp) : FLYER)
260 #else
261 #define _scan_char(pp) (((pp)->p_scan < 0) ? ' ' : '*')
262 #define stat_char(pp) (((pp)->p_cloak < 0) ? _scan_char(pp) : '+')
263 #endif
264
265 typedef struct bullet_def BULLET;
266 typedef struct expl_def EXPL;
267 typedef struct player_def PLAYER;
268 typedef struct ident_def IDENT;
269 typedef struct regen_def REGEN;
270 #ifdef INTERNET
271 typedef struct sockaddr_in SOCKET;
272 #else
273 typedef struct sockaddr_un SOCKET;
274 #endif
275
276 struct ident_def {
277 char i_name[NAMELEN];
278 char i_team;
279 uint32_t i_machine;
280 uint32_t i_uid;
281 float i_kills;
282 int i_entries;
283 float i_score;
284 int i_absorbed;
285 int i_faced;
286 int i_shot;
287 int i_robbed;
288 int i_slime;
289 int i_missed;
290 int i_ducked;
291 int i_gkills, i_bkills, i_deaths, i_stillb, i_saved;
292 IDENT *i_next;
293 };
294
295 struct player_def {
296 IDENT *p_ident;
297 char p_over;
298 int p_face;
299 int p_undershot;
300 #ifdef FLY
301 int p_flying;
302 int p_flyx, p_flyy;
303 #endif
304 #ifdef BOOTS
305 int p_nboots;
306 #endif
307 FILE *p_output;
308 int p_fd;
309 int p_mask;
310 int p_damage;
311 int p_damcap;
312 int p_ammo;
313 int p_ncshot;
314 int p_scan;
315 int p_cloak;
316 int p_x, p_y;
317 int p_ncount;
318 int p_nexec;
319 long p_nchar;
320 char p_death[MSGLEN];
321 char p_maze[HEIGHT][WIDTH2];
322 int p_curx, p_cury;
323 int p_lastx, p_lasty;
324 char p_cbuf[BUFSIZ];
325 };
326
327 struct bullet_def {
328 int b_x, b_y;
329 int b_face;
330 int b_charge;
331 char b_type;
332 char b_size;
333 char b_over;
334 PLAYER *b_owner;
335 IDENT *b_score;
336 bool b_expl;
337 BULLET *b_next;
338 };
339
340 struct expl_def {
341 int e_x, e_y;
342 char e_char;
343 EXPL *e_next;
344 };
345
346 struct regen_def {
347 int r_x, r_y;
348 REGEN *r_next;
349 };
350
351 /*
352 * external variables
353 */
354
355 extern bool Last_player;
356
357 extern char Buf[BUFSIZ], Maze[HEIGHT][WIDTH2], Orig_maze[HEIGHT][WIDTH2];
358
359 extern const char *Driver;
360
361 extern int Nplayer, Socket, Status;
362 extern struct pollfd fdset[];
363
364 #ifdef INTERNET
365 extern u_short Test_port;
366 #else
367 extern char *Sock_name, *Stat_name;
368 #endif
369
370 #ifdef VOLCANO
371 extern int volcano;
372 #endif
373
374 extern int See_over[NASCII];
375
376 extern BULLET *Bullets;
377
378 extern EXPL *Expl[EXPLEN];
379 extern EXPL *Last_expl;
380
381 extern IDENT *Scores;
382
383 extern PLAYER Player[MAXPL], *End_player;
384 #ifdef BOOTS
385 extern PLAYER Boot[NBOOTS];
386 #endif
387
388 #ifdef MONITOR
389 extern bool Am_monitor;
390 extern PLAYER Monitor[MAXMON], *End_monitor;
391 #endif
392
393 #ifdef INTERNET
394 extern char *Send_message;
395 #endif
396
397 extern char map_key[256];
398 extern bool no_beep;
399
400 /*
401 * function types
402 */
403
404 void add_shot(int, int, int, char, int, PLAYER *, int, char);
405 int answer(void);
406 void bad_con(void) __dead;
407 void bad_ver(void) __dead;
408 void ce(PLAYER *);
409 void cgoto(PLAYER *, int, int);
410 void check(PLAYER *, int, int);
411 void checkdam(PLAYER *, PLAYER *, IDENT *, int, char);
412 void clearwalls(void);
413 void clear_eol(void);
414 void clear_the_screen(void);
415 void clrscr(PLAYER *);
416 BULLET *create_shot(int, int, int, char, int, int, PLAYER *,
417 IDENT *, int, char);
418 void do_connect(char *, char, long);
419 void do_message(void);
420 void drawmaze(PLAYER *);
421 void drawplayer(PLAYER *, bool);
422 void execute(PLAYER *);
423 void faketalk(void);
424 void fixshots(int, int, char);
425 void get_local_name(const char *);
426 int get_remote_name(char *);
427 BULLET *is_bullet(int, int);
428 void look(PLAYER *);
429 void makemaze(void);
430 void message(PLAYER *, const char *);
431 void mon_execute(PLAYER *);
432 void moveshots(void);
433 void open_ctl(void);
434 bool opposite(int, char);
435 void otto(int, int, char);
436 void outch(PLAYER *, int);
437 void outstr(PLAYER *, const char *, int);
438 PLAYER *play_at(int, int);
439 void playit(void);
440 void put_ch(char);
441 void put_str(char *);
442 int quit(int);
443 int rand_dir(void);
444 int rand_num(int);
445 void rollexpl(void);
446 void sendcom(PLAYER *, int, ...);
447 void showexpl(int, int, char);
448 void showstat(PLAYER *);
449 void cleanup(int) __dead;
450 void intr(int);
451 void tstp(int);