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