Home | History | Annotate | Line # | Download | only in huntd
hunt.h revision 1.27
      1 /*	$NetBSD: hunt.h,v 1.27 2014/03/29 22:29:55 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, Socket;
    149 extern struct pollfd fdset[];
    150 
    151 extern int See_over[NASCII];
    152 
    153 extern BULLET *Bullets;
    154 
    155 extern IDENT *Scores;
    156 
    157 extern PLAYER Player[MAXPL], *End_player;
    158 #ifdef BOOTS
    159 extern PLAYER Boot[NBOOTS];
    160 #endif
    161 
    162 #ifdef MONITOR
    163 extern PLAYER Monitor[MAXMON], *End_monitor;
    164 #endif
    165 
    166 /*
    167  * function types
    168  */
    169 
    170 /* in answer.c */
    171 int answer(void);
    172 int rand_dir(void);
    173 
    174 /* in draw.c */
    175 void drawmaze(PLAYER *);
    176 void look(PLAYER *);
    177 void check(PLAYER *, int, int);
    178 void showstat(PLAYER *);
    179 void drawplayer(PLAYER *, bool);
    180 void message(PLAYER *, const char *);
    181 
    182 /* in driver.c */
    183 void checkdam(PLAYER *, PLAYER *, IDENT *, int, char);
    184 int rand_num(int);
    185 __dead void cleanup(int);
    186 
    187 /* in execute.c */
    188 void mon_execute(PLAYER *);	/* ifdef MONITOR only */
    189 void execute(PLAYER *);
    190 void add_shot(int, int, int, char, int, PLAYER *, int, char);
    191 BULLET *create_shot(int, int, int, char, int, int, PLAYER *,
    192 		    IDENT *, int, char);
    193 
    194 /* in expl.c */
    195 void showexpl(int, int, char);
    196 void rollexpl(void);
    197 void clearwalls(void);
    198 
    199 /* in makemaze.c */
    200 void makemaze(void);
    201 
    202 /* in shots.c */
    203 void moveshots(void);
    204 PLAYER *play_at(int, int);
    205 bool opposite(int, char);
    206 BULLET *is_bullet(int, int);
    207 void fixshots(int, int, char);
    208 
    209 /* in support.c */
    210 __printflike(2, 3) void complain(int level, const char *fmt, ...);
    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