|
|
1.1 ! root 1: /* ! 2: * Hunt ! 3: * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold ! 4: * San Francisco, California ! 5: * ! 6: * Copyright (c) 1985 Regents of the University of California. ! 7: * All rights reserved. The Berkeley software License Agreement ! 8: * specifies the terms and conditions for redistribution. ! 9: */ ! 10: ! 11: # include "bsd.h" ! 12: ! 13: # ifndef BSD_RELEASE ! 14: # define index strchr ! 15: # define rindex strrchr ! 16: # define bcopy(s,d,c) memcpy(d,s,c) ! 17: # endif ! 18: ! 19: # include <stdio.h> ! 20: # ifdef LOG ! 21: # include <syslog.h> ! 22: # endif LOG ! 23: # ifndef TERMINFO ! 24: # include <sgtty.h> ! 25: # else ! 26: # include <sys/ioctl.h> ! 27: # endif ! 28: # include <sys/types.h> ! 29: # include <sys/uio.h> ! 30: # include <sys/socket.h> ! 31: # ifdef INTERNET ! 32: # include <netinet/in.h> ! 33: # include <netdb.h> ! 34: # ifndef HPUX ! 35: # include <arpa/inet.h> ! 36: # else ! 37: extern char *inet_ntoa(); ! 38: # endif ! 39: # ifdef BROADCAST ! 40: # include <net/if.h> ! 41: # endif BROADCAST ! 42: # else INTERNET ! 43: # include <sys/un.h> ! 44: # endif INTERNET ! 45: ! 46: # ifdef INTERNET ! 47: # define SOCK_FAMILY AF_INET ! 48: # else INTERNET ! 49: # define SOCK_FAMILY AF_UNIX ! 50: # define AF_UNIX_HACK /* 4.2 hack; leaves files around */ ! 51: # endif INTERNET ! 52: ! 53: /* ! 54: * Preprocessor define dependencies ! 55: */ ! 56: # if defined(VOLCANO) && !defined(SLIME) ! 57: # define SLIME ! 58: # endif ! 59: # if defined(BOOTS) && !defined(FLY) ! 60: # define FLY ! 61: # endif ! 62: # if !defined(REFLECT) && !defined(RANDOM) ! 63: # define RANDOM ! 64: # endif ! 65: ! 66: /* decrement version number for each change in startup protocol */ ! 67: # define HUNT_VERSION -1 ! 68: ! 69: # define ADDCH ('a' | 0200) ! 70: # define MOVE ('m' | 0200) ! 71: # define REFRESH ('r' | 0200) ! 72: # define CLRTOEOL ('c' | 0200) ! 73: # define ENDWIN ('e' | 0200) ! 74: # define CLEAR ('C' | 0200) ! 75: # define REDRAW ('R' | 0200) ! 76: # define LAST_PLAYER ('l' | 0200) ! 77: # define BELL ('b' | 0200) ! 78: # define READY ('g' | 0200) ! 79: ! 80: /* ! 81: * Choose MAXPL and MAXMON carefully. The screen is assumed to be ! 82: * 23 lines high and will only tolerate (MAXPL == 17 && MAXMON == 0) ! 83: * or (MAXPL + MAXMON <= 16). ! 84: */ ! 85: # ifdef MONITOR ! 86: # define MAXPL 15 ! 87: # define MAXMON 1 ! 88: # else ! 89: # define MAXPL 17 ! 90: # endif MONITOR ! 91: # define SHORTLEN 2 /* sizeof (network short) */ ! 92: # define LONGLEN 4 /* sizeof (network long) */ ! 93: # define NAMELEN 20 ! 94: # define MSGLEN SCREEN_WIDTH ! 95: # define DECAY 50.0 ! 96: ! 97: # define NASCII 128 ! 98: ! 99: # define WIDTH 51 ! 100: # define WIDTH2 64 /* Next power of 2 >= WIDTH (for fast access) */ ! 101: # define HEIGHT 23 ! 102: # define UBOUND 1 ! 103: # define DBOUND (HEIGHT - 1) ! 104: # define LBOUND 1 ! 105: # define RBOUND (WIDTH - 1) ! 106: ! 107: # define SCREEN_HEIGHT 24 ! 108: # define SCREEN_WIDTH 80 ! 109: # define SCREEN_WIDTH2 128 /* Next power of 2 >= SCREEN_WIDTH */ ! 110: ! 111: # define STAT_LABEL_COL 60 ! 112: # define STAT_VALUE_COL 74 ! 113: # define STAT_NAME_COL 61 ! 114: # define STAT_SCAN_COL (STAT_NAME_COL + 5) ! 115: # define STAT_AMMO_ROW 0 ! 116: # define STAT_GUN_ROW 1 ! 117: # define STAT_DAM_ROW 2 ! 118: # define STAT_KILL_ROW 3 ! 119: # define STAT_PLAY_ROW 5 ! 120: # ifdef MONITOR ! 121: # define STAT_MON_ROW (STAT_PLAY_ROW + MAXPL + 1) ! 122: # endif MONITOR ! 123: # define STAT_NAME_LEN 18 ! 124: ! 125: # define DOOR '#' ! 126: # define WALL1 '-' ! 127: # define WALL2 '|' ! 128: # define WALL3 '+' ! 129: # ifdef REFLECT ! 130: # define WALL4 '/' ! 131: # define WALL5 '\\' ! 132: # endif REFLECT ! 133: # define KNIFE 'K' ! 134: # define SHOT ':' ! 135: # define GRENADE 'o' ! 136: # define SATCHEL 'O' ! 137: # define BOMB '@' ! 138: # define MINE ';' ! 139: # define GMINE 'g' ! 140: # ifdef OOZE ! 141: # define SLIME '$' ! 142: # endif OOZE ! 143: # ifdef VOLCANO ! 144: # define LAVA '~' ! 145: # endif VOLCANO ! 146: # ifdef DRONE ! 147: # define DSHOT '?' ! 148: # endif DRONE ! 149: # ifdef FLY ! 150: # define FALL 'F' ! 151: # endif FLY ! 152: # ifdef BOOTS ! 153: # define NBOOTS 2 ! 154: # define BOOT 'b' ! 155: # define BOOT_PAIR 'B' ! 156: # endif ! 157: # define SPACE ' ' ! 158: ! 159: # define ABOVE 'i' ! 160: # define BELOW '!' ! 161: # define RIGHT '}' ! 162: # define LEFTS '{' ! 163: # ifdef FLY ! 164: # define FLYER '&' ! 165: # define isplayer(c) (c == LEFTS || c == RIGHT ||\ ! 166: c == ABOVE || c == BELOW || c == FLYER) ! 167: # else ! 168: # define isplayer(c) (c == LEFTS || c == RIGHT ||\ ! 169: c == ABOVE || c == BELOW) ! 170: # endif FLY ! 171: ! 172: # define NORTH 01 ! 173: # define SOUTH 02 ! 174: # define EAST 010 ! 175: # define WEST 020 ! 176: ! 177: # ifndef TRUE ! 178: # define TRUE 1 ! 179: # define FALSE 0 ! 180: # endif TRUE ! 181: # undef CTRL ! 182: # define CTRL(x) ('x' & 037) ! 183: ! 184: # define BULSPD 5 /* bullets movement speed */ ! 185: # define ISHOTS 15 ! 186: # define NSHOTS 5 ! 187: # define MAXNCSHOT 2 ! 188: # define MAXDAM 10 ! 189: # define MINDAM 5 ! 190: # define STABDAM 2 ! 191: ! 192: # define BULREQ 1 ! 193: # define GRENREQ 9 ! 194: # define SATREQ 25 ! 195: # define BOMB7REQ 49 ! 196: # define BOMB9REQ 81 ! 197: # define BOMB11REQ 121 ! 198: # define BOMB13REQ 169 ! 199: # define BOMB15REQ 225 ! 200: # define BOMB17REQ 289 ! 201: # define BOMB19REQ 361 ! 202: # define BOMB21REQ 441 ! 203: # define MAXBOMB 11 ! 204: # ifdef DRONE ! 205: # define MINDSHOT 2 /* At least a satchel bomb */ ! 206: # endif ! 207: extern int shot_req[]; ! 208: extern int shot_type[]; ! 209: # ifdef OOZE ! 210: # define SLIME_FACTOR 3 ! 211: # define SLIMEREQ 5 ! 212: # define SSLIMEREQ 10 ! 213: # define SLIME2REQ 15 ! 214: # define SLIME3REQ 20 ! 215: # define MAXSLIME 4 ! 216: # define SLIMESPEED 5 ! 217: extern int slime_req[]; ! 218: # endif OOZE ! 219: # ifdef VOLCANO ! 220: # define LAVASPEED 1 ! 221: # endif VOLCANO ! 222: ! 223: # define CLOAKLEN 20 ! 224: # define SCANLEN (Nplayer * 20) ! 225: # define EXPLEN 4 ! 226: ! 227: # define Q_QUIT 0 ! 228: # define Q_CLOAK 1 ! 229: # define Q_FLY 2 ! 230: # define Q_SCAN 3 ! 231: # define Q_MESSAGE 4 ! 232: ! 233: # define C_PLAYER 0 ! 234: # define C_MONITOR 1 ! 235: # define C_MESSAGE 2 ! 236: # define C_SCORES 3 ! 237: ! 238: # ifdef MONITOR ! 239: # define C_TESTMSG() (Query_driver ? C_MESSAGE :\ ! 240: (Show_scores ? C_SCORES :\ ! 241: (Am_monitor ? C_MONITOR :\ ! 242: C_PLAYER))) ! 243: # else ! 244: # define C_TESTMSG() (Show_scores ? C_SCORES :\ ! 245: (Query_driver ? C_MESSAGE :\ ! 246: C_PLAYER)) ! 247: # endif ! 248: ! 249: # ifdef FLY ! 250: # define _scan_char(pp) (((pp)->p_scan < 0) ? ' ' : '*') ! 251: # define _cloak_char(pp) (((pp)->p_cloak < 0) ? _scan_char(pp) : '+') ! 252: # define stat_char(pp) (((pp)->p_flying < 0) ? _cloak_char(pp) : FLYER) ! 253: # else FLY ! 254: # define _scan_char(pp) (((pp)->p_scan < 0) ? ' ' : '*') ! 255: # define stat_char(pp) (((pp)->p_cloak < 0) ? _scan_char(pp) : '+') ! 256: # endif FLY ! 257: ! 258: typedef int FLAG; ! 259: typedef struct bullet_def BULLET; ! 260: typedef struct expl_def EXPL; ! 261: typedef struct player_def PLAYER; ! 262: typedef struct ident_def IDENT; ! 263: typedef struct regen_def REGEN; ! 264: # ifdef INTERNET ! 265: typedef struct sockaddr_in SOCKET; ! 266: # else INTERNET ! 267: typedef struct sockaddr_un SOCKET; ! 268: # endif INTERNET ! 269: typedef struct sgttyb TTYB; ! 270: ! 271: struct ident_def { ! 272: char i_name[NAMELEN]; ! 273: char i_team; ! 274: long i_machine; ! 275: long i_uid; ! 276: float i_kills; ! 277: int i_entries; ! 278: float i_score; ! 279: int i_absorbed; ! 280: int i_faced; ! 281: int i_shot; ! 282: int i_robbed; ! 283: int i_slime; ! 284: int i_missed; ! 285: int i_ducked; ! 286: int i_gkills, i_bkills, i_deaths, i_stillb, i_saved; ! 287: IDENT *i_next; ! 288: }; ! 289: ! 290: struct player_def { ! 291: IDENT *p_ident; ! 292: char p_over; ! 293: int p_face; ! 294: int p_undershot; ! 295: # ifdef FLY ! 296: int p_flying; ! 297: int p_flyx, p_flyy; ! 298: # endif FLY ! 299: # ifdef BOOTS ! 300: int p_nboots; ! 301: # endif ! 302: FILE *p_output; ! 303: int p_fd; ! 304: int p_mask; ! 305: int p_damage; ! 306: int p_damcap; ! 307: int p_ammo; ! 308: int p_ncshot; ! 309: int p_scan; ! 310: int p_cloak; ! 311: int p_x, p_y; ! 312: int p_ncount; ! 313: int p_nexec; ! 314: long p_nchar; ! 315: char p_death[MSGLEN]; ! 316: char p_maze[HEIGHT][WIDTH2]; ! 317: int p_curx, p_cury; ! 318: int p_lastx, p_lasty; ! 319: char p_cbuf[BUFSIZ]; ! 320: }; ! 321: ! 322: struct bullet_def { ! 323: int b_x, b_y; ! 324: int b_face; ! 325: int b_charge; ! 326: char b_type; ! 327: char b_size; ! 328: char b_over; ! 329: PLAYER *b_owner; ! 330: IDENT *b_score; ! 331: FLAG b_expl; ! 332: BULLET *b_next; ! 333: }; ! 334: ! 335: struct expl_def { ! 336: int e_x, e_y; ! 337: char e_char; ! 338: EXPL *e_next; ! 339: }; ! 340: ! 341: struct regen_def { ! 342: int r_x, r_y; ! 343: REGEN *r_next; ! 344: }; ! 345: ! 346: /* ! 347: * external variables ! 348: */ ! 349: ! 350: extern FLAG Last_player; ! 351: ! 352: extern char Buf[BUFSIZ], Maze[HEIGHT][WIDTH2], Orig_maze[HEIGHT][WIDTH2]; ! 353: ! 354: extern char *Sock_name, *Driver; ! 355: ! 356: extern int errno, Have_inp, Nplayer, Num_fds, Socket, Status; ! 357: extern long Fds_mask, Sock_mask, Stat_mask; ! 358: ! 359: # ifdef INTERNET ! 360: extern u_short Test_port; ! 361: # else INTERNET ! 362: extern char *Sock_name; ! 363: # endif INTERNET ! 364: ! 365: # ifdef VOLCANO ! 366: extern int volcano; ! 367: # endif VOLCANO ! 368: ! 369: extern int See_over[NASCII]; ! 370: ! 371: extern BULLET *Bullets; ! 372: ! 373: extern EXPL *Expl[EXPLEN]; ! 374: extern EXPL *Last_expl; ! 375: ! 376: extern IDENT *Scores; ! 377: ! 378: extern PLAYER Player[MAXPL], *End_player; ! 379: # ifdef BOOTS ! 380: extern PLAYER Boot[NBOOTS]; ! 381: # endif BOOTS ! 382: ! 383: # ifdef MONITOR ! 384: extern FLAG Am_monitor; ! 385: extern PLAYER Monitor[MAXMON], *End_monitor; ! 386: # endif MONITOR ! 387: ! 388: # ifdef INTERNET ! 389: extern char *Send_message; ! 390: # endif ! 391: ! 392: extern char map_key[256]; ! 393: extern FLAG no_beep; ! 394: ! 395: /* ! 396: * function types ! 397: */ ! 398: ! 399: extern char *getenv(), *malloc(), *strcpy(), *strncpy(), *realloc(); ! 400: ! 401: # ifndef htons ! 402: extern u_short htons(), ntohs(); ! 403: # endif ! 404: # ifndef htonl ! 405: extern u_long htonl(), ntohl(); ! 406: # endif ! 407: ! 408: extern IDENT *get_ident(); ! 409: ! 410: extern int moveshots(); ! 411: ! 412: extern BULLET *is_bullet(), *create_shot(); ! 413: ! 414: extern PLAYER *play_at();
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.