diff options
Diffstat (limited to 'hunt/huntd/answer.c')
-rw-r--r-- | hunt/huntd/answer.c | 120 |
1 files changed, 60 insertions, 60 deletions
diff --git a/hunt/huntd/answer.c b/hunt/huntd/answer.c index df355151..74f162ed 100644 --- a/hunt/huntd/answer.c +++ b/hunt/huntd/answer.c @@ -1,4 +1,4 @@ -/* $NetBSD: answer.c,v 1.13 2009/07/04 02:37:20 dholland Exp $ */ +/* $NetBSD: answer.c,v 1.14 2009/07/04 04:29:54 dholland Exp $ */ /* * Copyright (c) 1983-2003, Regents of the University of California. * All rights reserved. @@ -32,63 +32,63 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: answer.c,v 1.13 2009/07/04 02:37:20 dholland Exp $"); +__RCSID("$NetBSD: answer.c,v 1.14 2009/07/04 04:29:54 dholland Exp $"); #endif /* not lint */ -# include <ctype.h> -# include <errno.h> -# include <fcntl.h> -# include <stdlib.h> -# include <unistd.h> -# include "hunt.h" +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> +#include <stdlib.h> +#include <unistd.h> +#include "hunt.h" -# define SCOREDECAY 15 +#define SCOREDECAY 15 -static char Ttyname[NAMELEN]; +static char Ttyname[NAMELEN]; int answer(void) { - PLAYER *pp; - int newsock; - static u_long mode; - static char name[NAMELEN]; - static char team; - static int enter_status; - static socklen_t socklen; - static uint32_t machine; - static uint32_t uid; - static SOCKET sockstruct; - char *cp1, *cp2; - int flags; - u_int32_t version; - int i; - -# ifdef INTERNET + PLAYER *pp; + int newsock; + static u_long mode; + static char name[NAMELEN]; + static char team; + static int enter_status; + static socklen_t socklen; + static uint32_t machine; + static uint32_t uid; + static SOCKET sockstruct; + char *cp1, *cp2; + int flags; + u_int32_t version; + int i; + +#ifdef INTERNET socklen = sizeof sockstruct; -# else +#else socklen = sizeof sockstruct - 1; -# endif +#endif errno = 0; newsock = accept(Socket, (struct sockaddr *) &sockstruct, &socklen); if (newsock < 0) { if (errno == EINTR) return FALSE; -# ifdef LOG +#ifdef LOG syslog(LOG_ERR, "accept: %m"); -# else +#else perror("accept"); -# endif +#endif cleanup(1); } -# ifdef INTERNET +#ifdef INTERNET machine = ntohl(((struct sockaddr_in *) &sockstruct)->sin_addr.s_addr); -# else +#else if (machine == 0) machine = gethostid(); -# endif +#endif version = htonl((u_int32_t) HUNT_VERSION); (void) write(newsock, &version, LONGLEN); (void) read(newsock, &uid, LONGLEN); @@ -125,7 +125,7 @@ answer(void) *cp2++ = *cp1; *cp2 = '\0'; -# ifdef INTERNET +#ifdef INTERNET if (mode == C_MESSAGE) { char buf[BUFSIZ + 1]; int n; @@ -153,8 +153,8 @@ answer(void) return FALSE; } else -# endif -# ifdef MONITOR +#endif +#ifdef MONITOR if (mode == C_MONITOR) if (End_monitor < &Monitor[MAXMON]) { pp = End_monitor++; @@ -167,7 +167,7 @@ answer(void) return FALSE; } else -# endif +#endif if (End_player < &Player[MAXPL]) { pp = End_player++; i = pp - Player + 3; @@ -193,21 +193,21 @@ answer(void) pp->p_y = 0; pp->p_x = 0; -# ifdef MONITOR +#ifdef MONITOR if (mode == C_MONITOR) stmonitor(pp); else -# endif +#endif stplayer(pp, enter_status); return TRUE; } -# ifdef MONITOR +#ifdef MONITOR void stmonitor(PLAYER *pp) { - int line; - PLAYER *npp; + int line; + PLAYER *npp; memcpy(pp->p_maze, Maze, sizeof Maze); @@ -230,13 +230,13 @@ stmonitor(PLAYER *pp) sendcom(pp, READY, 0); (void) fflush(pp->p_output); } -# endif +#endif void stplayer(PLAYER *newpp, int enter_status) { - int x, y; - PLAYER *pp; + int x, y; + PLAYER *pp; Nplayer++; @@ -264,7 +264,7 @@ stplayer(PLAYER *newpp, int enter_status) newpp->p_y = y; newpp->p_undershot = FALSE; -# ifdef FLY +#ifdef FLY if (enter_status == Q_FLY) { newpp->p_flying = rand_num(20); newpp->p_flyx = 2 * rand_num(6) - 5; @@ -272,7 +272,7 @@ stplayer(PLAYER *newpp, int enter_status) newpp->p_face = FLYER; } else -# endif +#endif { newpp->p_flying = -1; newpp->p_face = rand_dir(); @@ -283,9 +283,9 @@ stplayer(PLAYER *newpp, int enter_status) newpp->p_ncount = 0; newpp->p_nexec = 0; newpp->p_ammo = ISHOTS; -# ifdef BOOTS +#ifdef BOOTS newpp->p_nboots = 0; -# endif +#endif if (enter_status == Q_SCAN) { newpp->p_scan = SCANLEN; newpp->p_cloak = 0; @@ -301,20 +301,20 @@ stplayer(PLAYER *newpp, int enter_status) y = rand_num(HEIGHT - 1) + 1; } while (Maze[y][x] != SPACE); Maze[y][x] = GMINE; -# ifdef MONITOR +#ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) check(pp, y, x); -# endif +#endif do { x = rand_num(WIDTH - 1) + 1; y = rand_num(HEIGHT - 1) + 1; } while (Maze[y][x] != SPACE); Maze[y][x] = MINE; -# ifdef MONITOR +#ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) check(pp, y, x); -# endif +#endif (void) snprintf(Buf, sizeof(Buf), "%5.2f%c%-10.10s %c", newpp->p_ident->i_score, @@ -335,21 +335,21 @@ stplayer(PLAYER *newpp, int enter_status) outstr(pp, smallbuf, 3); } } -# ifdef MONITOR +#ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) { cgoto(pp, y, STAT_NAME_COL); outstr(pp, Buf, STAT_NAME_LEN); } -# endif +#endif drawmaze(newpp); drawplayer(newpp, TRUE); look(newpp); -# ifdef FLY +#ifdef FLY if (enter_status == Q_FLY) /* Make sure that the position you enter in will be erased */ showexpl(newpp->p_y, newpp->p_x, FLYER); -# endif +#endif sendcom(newpp, REFRESH); sendcom(newpp, READY, 0); (void) fflush(newpp->p_output); @@ -383,8 +383,8 @@ rand_dir(void) IDENT * get_ident(uint32_t machine, uint32_t uid, char *name, char team) { - IDENT *ip; - static IDENT punt; + IDENT *ip; + static IDENT punt; for (ip = Scores; ip != NULL; ip = ip->i_next) if (ip->i_machine == machine |