hunt.h revision 1.28 1 /* $NetBSD: hunt.h,v 1.28 2014/03/30 00:26:58 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 #include <syslog.h>
38
39 #include <sys/ioctl.h>
40 #include <sys/types.h>
41 #include <sys/uio.h>
42 #include <sys/poll.h>
43
44 #ifdef INTERNET
45 #include <netinet/in.h>
46 #include <netdb.h>
47 #include <arpa/inet.h>
48 #include <net/if.h>
49 #else
50 #include <sys/un.h>
51 #endif
52
53 #include "hunt_common.h"
54
55 extern const int shot_req[];
56 extern const int shot_type[];
57 #ifdef OOZE
58 extern const int slime_req[];
59 #endif
60
61 typedef struct bullet_def BULLET;
62 typedef struct expl_def EXPL;
63 typedef struct player_def PLAYER;
64 typedef struct ident_def IDENT;
65 typedef struct regen_def REGEN;
66
67 struct ident_def {
68 char i_name[NAMELEN];
69 char i_team;
70 uint32_t i_machine;
71 uint32_t i_uid;
72 float i_kills;
73 int i_entries;
74 float i_score;
75 int i_absorbed;
76 int i_faced;
77 int i_shot;
78 int i_robbed;
79 int i_slime;
80 int i_missed;
81 int i_ducked;
82 int i_gkills, i_bkills, i_deaths, i_stillb, i_saved;
83 IDENT *i_next;
84 };
85
86 struct player_def {
87 IDENT *p_ident;
88 char p_over;
89 int p_face;
90 int p_undershot;
91 #ifdef FLY
92 int p_flying;
93 int p_flyx, p_flyy;
94 #endif
95 #ifdef BOOTS
96 int p_nboots;
97 #endif
98 FILE *p_output;
99 int p_fd;
100 int p_mask;
101 int p_damage;
102 int p_damcap;
103 int p_ammo;
104 int p_ncshot;
105 int p_scan;
106 int p_cloak;
107 int p_x, p_y;
108 int p_ncount;
109 int p_nexec;
110 long p_nchar;
111 char p_death[MSGLEN];
112 char p_maze[HEIGHT][WIDTH2];
113 int p_curx, p_cury;
114 int p_lastx, p_lasty;
115 char p_cbuf[BUFSIZ];
116 };
117
118 struct bullet_def {
119 int b_x, b_y;
120 int b_face;
121 int b_charge;
122 char b_type;
123 char b_size;
124 char b_over;
125 PLAYER *b_owner;
126 IDENT *b_score;
127 bool b_expl;
128 BULLET *b_next;
129 };
130
131 struct expl_def {
132 int e_x, e_y;
133 char e_char;
134 EXPL *e_next;
135 };
136
137 struct regen_def {
138 int r_x, r_y;
139 REGEN *r_next;
140 };
141
142 /*
143 * external variables
144 */
145
146 extern char Buf[BUFSIZ], Maze[HEIGHT][WIDTH2], Orig_maze[HEIGHT][WIDTH2];
147
148 extern int Nplayer;
149 extern int huntsock;
150 extern struct pollfd fdset[];
151
152 extern int See_over[NASCII];
153
154 extern BULLET *Bullets;
155
156 extern IDENT *Scores;
157
158 extern PLAYER Player[MAXPL], *End_player;
159 #ifdef BOOTS
160 extern PLAYER Boot[NBOOTS];
161 #endif
162
163 #ifdef MONITOR
164 extern PLAYER Monitor[MAXMON], *End_monitor;
165 #endif
166
167 /*
168 * function types
169 */
170
171 /* in answer.c */
172 int answer(void);
173 int rand_dir(void);
174
175 /* in draw.c */
176 void drawmaze(PLAYER *);
177 void look(PLAYER *);
178 void check(PLAYER *, int, int);
179 void showstat(PLAYER *);
180 void drawplayer(PLAYER *, bool);
181 void message(PLAYER *, const char *);
182
183 /* in driver.c */
184 void checkdam(PLAYER *, PLAYER *, IDENT *, int, char);
185 int rand_num(int);
186 __dead void cleanup(int);
187
188 /* in execute.c */
189 void mon_execute(PLAYER *); /* ifdef MONITOR only */
190 void execute(PLAYER *);
191 void add_shot(int, int, int, char, int, PLAYER *, int, char);
192 BULLET *create_shot(int, int, int, char, int, int, PLAYER *,
193 IDENT *, int, char);
194
195 /* in expl.c */
196 void showexpl(int, int, char);
197 void rollexpl(void);
198 void clearwalls(void);
199
200 /* in makemaze.c */
201 void makemaze(void);
202
203 /* in shots.c */
204 void moveshots(void);
205 PLAYER *play_at(int, int);
206 bool opposite(int, char);
207 BULLET *is_bullet(int, int);
208 void fixshots(int, int, char);
209
210 /* in support.c */
211 __printflike(2, 3) void complain(int level, const char *fmt, ...);
212
213 /* in terminal.c */
214 void cgoto(PLAYER *, int, int);
215 void outch(PLAYER *, int);
216 void outstr(PLAYER *, const char *, int);
217 void clrscr(PLAYER *);
218 void ce(PLAYER *);
219 void sendcom(PLAYER *, int, ...);
220