1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34: # include "bsd.h"
35:
36: # include <errno.h>
37: # include <stdio.h>
38: # include <string.h>
39: # ifdef LOG
40: # include <syslog.h>
41: # endif
42: # if !defined(TERMINFO) && BSD_RELEASE < 44
43: # include <sgtty.h>
44: # else
45: # include <sys/ioctl.h>
46: # endif
47: # include <sys/types.h>
48: # include <sys/uio.h>
49: # include <sys/poll.h>
50: # ifdef INTERNET
51: # include <netinet/in.h>
52: # include <netdb.h>
53: # include <arpa/inet.h>
54: # ifdef BROADCAST
55: # include <net/if.h>
56: # endif
57: # else
58: # include <sys/un.h>
59: # endif
60:
61: # ifdef INTERNET
62: # define SOCK_FAMILY AF_INET
63: # else
64: # define SOCK_FAMILY AF_UNIX
65: # define AF_UNIX_HACK
66: # endif
67:
68:
69:
70:
71: # if defined(VOLCANO) && !defined(OOZE)
72: # define OOZE
73: # endif
74: # if defined(BOOTS) && !defined(FLY)
75: # define FLY
76: # endif
77: # if !defined(REFLECT) && !defined(RANDOM)
78: # define RANDOM
79: # endif
80: # ifdef TERMINFO
81:
82:
83: # define USE_CURSES
84: # endif
85:
86:
87: # define HUNT_VERSION -1
88:
89: # define ADDCH ('a' | 0200)
90: # define MOVE ('m' | 0200)
91: # define REFRESH ('r' | 0200)
92: # define CLRTOEOL ('c' | 0200)
93: # define ENDWIN ('e' | 0200)
94: # define CLEAR ('C' | 0200)
95: # define REDRAW ('R' | 0200)
96: # define LAST_PLAYER ('l' | 0200)
97: # define BELL ('b' | 0200)
98: # define READY ('g' | 0200)
99:
100:
101:
102:
103:
104:
105: # ifdef MONITOR
106: # define MAXPL 15
107: # define MAXMON 1
108: # else
109: # define MAXPL 17
110: # define MAXMON 0
111: # endif
112: # define SHORTLEN 2
113: # define LONGLEN 4
114: # define NAMELEN 20
115: # define MSGLEN SCREEN_WIDTH
116: # define DECAY 50.0
117:
118: # define NASCII 128
119:
120: # define WIDTH 51
121: # define WIDTH2 64
122: # define HEIGHT 23
123: # define UBOUND 1
124: # define DBOUND (HEIGHT - 1)
125: # define LBOUND 1
126: # define RBOUND (WIDTH - 1)
127:
128: # define SCREEN_HEIGHT 24
129: # define SCREEN_WIDTH 80
130: # define SCREEN_WIDTH2 128
131:
132: # define STAT_LABEL_COL 60
133: # define STAT_VALUE_COL 74
134: # define STAT_NAME_COL 61
135: # define STAT_SCAN_COL (STAT_NAME_COL + 5)
136: # define STAT_AMMO_ROW 0
137: # define STAT_GUN_ROW 1
138: # define STAT_DAM_ROW 2
139: # define STAT_KILL_ROW 3
140: # define STAT_PLAY_ROW 5
141: # ifdef MONITOR
142: # define STAT_MON_ROW (STAT_PLAY_ROW + MAXPL + 1)
143: # endif
144: # define STAT_NAME_LEN 18
145:
146: # define DOOR '#'
147: # define WALL1 '-'
148: # define WALL2 '|'
149: # define WALL3 '+'
150: # ifdef REFLECT
151: # define WALL4 '/'
152: # define WALL5 '\\'
153: # endif
154: # define KNIFE 'K'
155: # define SHOT ':'
156: # define GRENADE 'o'
157: # define SATCHEL 'O'
158: # define BOMB '@'
159: # define MINE ';'
160: # define GMINE 'g'
161: # ifdef OOZE
162: # define SLIME '$'
163: # endif
164: # ifdef VOLCANO
165: # define LAVA '~'
166: # endif
167: # ifdef DRONE
168: # define DSHOT '?'
169: # endif
170: # ifdef FLY
171: # define FALL 'F'
172: # endif
173: # ifdef BOOTS
174: # define NBOOTS 2
175: # define BOOT 'b'
176: # define BOOT_PAIR 'B'
177: # endif
178: # define SPACE ' '
179:
180: # define ABOVE 'i'
181: # define BELOW '!'
182: # define RIGHT '}'
183: # define LEFTS '{'
184: # ifdef FLY
185: # define FLYER '&'
186: # define is_player(c) (c == LEFTS || c == RIGHT ||\
187: c == ABOVE || c == BELOW || c == FLYER)
188: # else
189: # define is_player(c) (c == LEFTS || c == RIGHT ||\
190: c == ABOVE || c == BELOW)
191: # endif
192:
193: # define NORTH 01
194: # define SOUTH 02
195: # define EAST 010
196: # define WEST 020
197:
198: # ifndef TRUE
199: # define TRUE 1
200: # define FALSE 0
201: # endif
202: # undef CTRL
203: # define CTRL(x) ((x) & 037)
204:
205: # define BULSPD 5
206: # define ISHOTS 15
207: # define NSHOTS 5
208: # define MAXNCSHOT 2
209: # define MAXDAM 10
210: # define MINDAM 5
211: # define STABDAM 2
212:
213: # define BULREQ 1
214: # define GRENREQ 9
215: # define SATREQ 25
216: # define BOMB7REQ 49
217: # define BOMB9REQ 81
218: # define BOMB11REQ 121
219: # define BOMB13REQ 169
220: # define BOMB15REQ 225
221: # define BOMB17REQ 289
222: # define BOMB19REQ 361
223: # define BOMB21REQ 441
224: # define MAXBOMB 11
225: # ifdef DRONE
226: # define MINDSHOT 2
227: # endif
228: extern int shot_req[];
229: extern int shot_type[];
230: # ifdef OOZE
231: # define SLIME_FACTOR 3
232: # define SLIMEREQ 5
233: # define SSLIMEREQ 10
234: # define SLIME2REQ 15
235: # define SLIME3REQ 20
236: # define MAXSLIME 4
237: # define SLIMESPEED 5
238: extern int slime_req[];
239: # endif
240: # ifdef VOLCANO
241: # define LAVASPEED 1
242: # endif
243:
244: # define CLOAKLEN 20
245: # define SCANLEN (Nplayer * 20)
246: # define EXPLEN 4
247:
248: # define Q_QUIT 0
249: # define Q_CLOAK 1
250: # define Q_FLY 2
251: # define Q_SCAN 3
252: # define Q_MESSAGE 4
253:
254: # define C_PLAYER 0
255: # define C_MONITOR 1
256: # define C_MESSAGE 2
257: # define C_SCORES 3
258:
259: # ifdef MONITOR
260: # define C_TESTMSG() (Query_driver ? C_MESSAGE :\
261: (Show_scores ? C_SCORES :\
262: (Am_monitor ? C_MONITOR :\
263: C_PLAYER)))
264: # else
265: # define C_TESTMSG() (Show_scores ? C_SCORES :\
266: (Query_driver ? C_MESSAGE :\
267: C_PLAYER))
268: # endif
269:
270: # ifdef FLY
271: # define _scan_char(pp) (((pp)->p_scan < 0) ? ' ' : '*')
272: # define _cloak_char(pp) (((pp)->p_cloak < 0) ? _scan_char(pp) : '+')
273: # define stat_char(pp) (((pp)->p_flying < 0) ? _cloak_char(pp) : FLYER)
274: # else
275: # define _scan_char(pp) (((pp)->p_scan < 0) ? ' ' : '*')
276: # define stat_char(pp) (((pp)->p_cloak < 0) ? _scan_char(pp) : '+')
277: # endif
278:
279: typedef int FLAG;
280: typedef struct bullet_def BULLET;
281: typedef struct expl_def EXPL;
282: typedef struct player_def PLAYER;
283: typedef struct ident_def IDENT;
284: typedef struct regen_def REGEN;
285: # ifdef INTERNET
286: typedef struct sockaddr_in SOCKET;
287: # else
288: typedef struct sockaddr_un SOCKET;
289: # endif
290:
291: struct ident_def {
292: char i_name[NAMELEN];
293: char i_team;
294: long i_machine;
295: long i_uid;
296: float i_kills;
297: int i_entries;
298: float i_score;
299: int i_absorbed;
300: int i_faced;
301: int i_shot;
302: int i_robbed;
303: int i_slime;
304: int i_missed;
305: int i_ducked;
306: int i_gkills, i_bkills, i_deaths, i_stillb, i_saved;
307: IDENT *i_next;
308: };
309:
310: struct player_def {
311: IDENT *p_ident;
312: char p_over;
313: int p_face;
314: int p_undershot;
315: # ifdef FLY
316: int p_flying;
317: int p_flyx, p_flyy;
318: # endif
319: # ifdef BOOTS
320: int p_nboots;
321: # endif
322: FILE *p_output;
323: int p_fd;
324: int p_mask;
325: int p_damage;
326: int p_damcap;
327: int p_ammo;
328: int p_ncshot;
329: int p_scan;
330: int p_cloak;
331: int p_x, p_y;
332: int p_ncount;
333: int p_nexec;
334: long p_nchar;
335: char p_death[MSGLEN];
336: char p_maze[HEIGHT][WIDTH2];
337: int p_curx, p_cury;
338: int p_lastx, p_lasty;
339: char p_cbuf[BUFSIZ];
340: };
341:
342: struct bullet_def {
343: int b_x, b_y;
344: int b_face;
345: int b_charge;
346: char b_type;
347: char b_size;
348: char b_over;
349: PLAYER *b_owner;
350: IDENT *b_score;
351: FLAG b_expl;
352: BULLET *b_next;
353: };
354:
355: struct expl_def {
356: int e_x, e_y;
357: char e_char;
358: EXPL *e_next;
359: };
360:
361: struct regen_def {
362: int r_x, r_y;
363: REGEN *r_next;
364: };
365:
366:
367:
368:
369:
370: extern FLAG Last_player;
371:
372: extern char Buf[BUFSIZ], Maze[HEIGHT][WIDTH2], Orig_maze[HEIGHT][WIDTH2];
373:
374: extern const char *Driver;
375:
376: extern int Nplayer, Socket, Status;
377: extern struct pollfd fdset[];
378:
379: # ifdef INTERNET
380: extern u_short Test_port;
381: # else
382: extern char *Sock_name, *Stat_name;
383: # endif
384:
385: # ifdef VOLCANO
386: extern int volcano;
387: # endif
388:
389: extern int See_over[NASCII];
390:
391: extern BULLET *Bullets;
392:
393: extern EXPL *Expl[EXPLEN];
394: extern EXPL *Last_expl;
395:
396: extern IDENT *Scores;
397:
398: extern PLAYER Player[MAXPL], *End_player;
399: # ifdef BOOTS
400: extern PLAYER Boot[NBOOTS];
401: # endif
402:
403: # ifdef MONITOR
404: extern FLAG Am_monitor;
405: extern PLAYER Monitor[MAXMON], *End_monitor;
406: # endif
407:
408: # ifdef INTERNET
409: extern char *Send_message;
410: # endif
411:
412: extern char map_key[256];
413: extern FLAG no_beep;
414:
415:
416:
417:
418:
419: void add_shot(int, int, int, char, int, PLAYER *, int, char);
420: int answer(void);
421: void bad_con(void) __attribute__((__noreturn__));
422: void bad_ver(void) __attribute__((__noreturn__));
423: int broadcast_vec(int, struct sockaddr **);
424: void ce(PLAYER *);
425: void cgoto(PLAYER *, int, int);
426: void check(PLAYER *, int, int);
427: void checkdam(PLAYER *, PLAYER *, IDENT *, int, char);
428: void clearwalls(void);
429: void clear_eol(void);
430: void clear_the_screen(void);
431: void clrscr(PLAYER *);
432: BULLET *create_shot(int, int, int, char, int, int, PLAYER *,
433: IDENT *, int, char);
434: void do_connect(const char *, char, long);
435: void do_message(void);
436: void drawmaze(PLAYER *);
437: void drawplayer(PLAYER *, FLAG);
438: void drawstatus(PLAYER *);
439: void execute(PLAYER *);
440: void faketalk(void);
441: void find_driver(FLAG);
442: void fixshots(int, int, char);
443: IDENT *get_ident(u_long, u_long, const char *, char);
444: void get_local_name(const char *);
445: int get_remote_name(char *);
446: BULLET *is_bullet(int, int);
447: void look(PLAYER *);
448: void makemaze(void);
449: void message(PLAYER *, const char *);
450: void mon_execute(PLAYER *);
451: void moveshots(void);
452: void open_ctl(void);
453: int opposite(int, char);
454: void otto(int, int, char);
455: void outch(PLAYER *, int);
456: void outstr(PLAYER *, const char *, int);
457: int player_sym(const PLAYER *, int, int);
458: PLAYER *play_at(int, int);
459: void playit(void);
460: void put_ch(char);
461: # ifndef USE_CURSES
462: void put_str(const char *);
463: # endif
464: int quit(int);
465: int rand_dir(void);
466: int rand_num(int);
467: void redraw_screen(void);
468: void rmnl(char *);
469: void rollexpl(void);
470: void see(PLAYER *, int);
471: void sendcom(PLAYER *, int, ...);
472: void showexpl(int, int, char);
473: void showstat(PLAYER *);
474: void start_driver(void);
475: void stmonitor(PLAYER *);
476: void stplayer(PLAYER *, int);
477: char translate(char);
478: SIGNAL_TYPE cleanup(int) __attribute__((__noreturn__));
479: SIGNAL_TYPE intr(int);
480: SIGNAL_TYPE sigalrm(int);
481: SIGNAL_TYPE sigemt(int) __attribute__((__noreturn__));
482: SIGNAL_TYPE sigterm(int) __attribute__((__noreturn__));
483: SIGNAL_TYPE sigusr1(int) __attribute__((__noreturn__));
484: SIGNAL_TYPE tstp(int);