diff options
Diffstat (limited to 'hunt/huntd')
-rw-r--r-- | hunt/huntd/answer.c | 48 | ||||
-rw-r--r-- | hunt/huntd/ctl.c | 8 | ||||
-rw-r--r-- | hunt/huntd/ctl_transact.c | 17 | ||||
-rw-r--r-- | hunt/huntd/draw.c | 94 | ||||
-rw-r--r-- | hunt/huntd/driver.c | 149 | ||||
-rw-r--r-- | hunt/huntd/execute.c | 96 | ||||
-rw-r--r-- | hunt/huntd/expl.c | 42 | ||||
-rw-r--r-- | hunt/huntd/extern.c | 12 | ||||
-rw-r--r-- | hunt/huntd/faketalk.c | 26 | ||||
-rw-r--r-- | hunt/huntd/get_names.c | 19 | ||||
-rw-r--r-- | hunt/huntd/hunt.h | 77 | ||||
-rw-r--r-- | hunt/huntd/makemaze.c | 49 | ||||
-rw-r--r-- | hunt/huntd/pathname.c | 6 | ||||
-rw-r--r-- | hunt/huntd/shots.c | 146 | ||||
-rw-r--r-- | hunt/huntd/talk_ctl.h | 4 | ||||
-rw-r--r-- | hunt/huntd/terminal.c | 71 |
16 files changed, 573 insertions, 291 deletions
diff --git a/hunt/huntd/answer.c b/hunt/huntd/answer.c index fe8e2376..c78fcea2 100644 --- a/hunt/huntd/answer.c +++ b/hunt/huntd/answer.c @@ -1,22 +1,31 @@ +/* $NetBSD: answer.c,v 1.3 1997/10/10 16:32:50 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California */ -# include "hunt.h" +#include <sys/cdefs.h> +#ifndef lint +__RCSID("$NetBSD: answer.c,v 1.3 1997/10/10 16:32:50 lukem Exp $"); +#endif /* not lint */ + # include <ctype.h> # include <errno.h> # include <fcntl.h> +# include <stdlib.h> +# include <unistd.h> +# include "hunt.h" # define SCOREDECAY 15 static char Ttyname[NAMELEN]; +int answer() { - register PLAYER *pp; - register int newsock; + PLAYER *pp; + int newsock; static u_long mode; static char name[NAMELEN]; static char team; @@ -25,7 +34,7 @@ answer() static u_long machine; static u_long uid; static SOCKET sockstruct; - register char *cp1, *cp2; + char *cp1, *cp2; int flags; long version; @@ -143,8 +152,7 @@ answer() pp->p_output = fdopen(newsock, "w"); pp->p_death[0] = '\0'; pp->p_fd = newsock; - pp->p_mask = (1 << pp->p_fd); - Fds_mask |= pp->p_mask; + FD_SET(pp->p_fd, &Fds_mask); if (pp->p_fd >= Num_fds) Num_fds = pp->p_fd + 1; @@ -161,11 +169,12 @@ answer() } # ifdef MONITOR +void stmonitor(pp) -register PLAYER *pp; + PLAYER *pp; { - register int line; - register PLAYER *npp; + int line; + PLAYER *npp; memcpy(pp->p_maze, Maze, sizeof Maze); @@ -189,12 +198,13 @@ register PLAYER *pp; } # endif +void stplayer(newpp, enter_status) -register PLAYER *newpp; -int enter_status; + PLAYER *newpp; + int enter_status; { - register int x, y; - register PLAYER *pp; + int x, y; + PLAYER *pp; Nplayer++; @@ -315,6 +325,7 @@ int enter_status; * rand_dir: * Return a random direction */ +int rand_dir() { switch (rand_num(4)) { @@ -328,6 +339,7 @@ rand_dir() return ABOVE; } /* NOTREACHED */ + return(-1); } /* @@ -336,12 +348,12 @@ rand_dir() */ IDENT * get_ident(machine, uid, name, team) -u_long machine; -u_long uid; -char *name; -char team; + u_long machine; + u_long uid; + char *name; + char team; { - register IDENT *ip; + IDENT *ip; static IDENT punt; for (ip = Scores; ip != NULL; ip = ip->i_next) diff --git a/hunt/huntd/ctl.c b/hunt/huntd/ctl.c index 59449930..b7066f65 100644 --- a/hunt/huntd/ctl.c +++ b/hunt/huntd/ctl.c @@ -1,3 +1,4 @@ +/* $NetBSD: ctl.c,v 1.2 1997/10/10 16:32:54 lukem Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement @@ -8,9 +9,14 @@ #if defined(TALK_43) || defined(TALK_42) +#include <sys/cdefs.h> #ifndef lint +#if 0 static char sccsid[] = "@(#)ctl.c 5.2 (Berkeley) 3/13/86"; +#else +__RCSID("$NetBSD: ctl.c,v 1.2 1997/10/10 16:32:54 lukem Exp $"); #endif +#endif /* not lint */ /* * This file handles haggling with the various talk daemons to @@ -18,6 +24,7 @@ static char sccsid[] = "@(#)ctl.c 5.2 (Berkeley) 3/13/86"; * the progress */ +#include "hunt.h" #include "talk_ctl.h" struct sockaddr_in daemon_addr = { AF_INET }; @@ -34,6 +41,7 @@ int ctl_sockt; CTL_MSG msg; /* open the ctl socket */ +void open_ctl() { int length; diff --git a/hunt/huntd/ctl_transact.c b/hunt/huntd/ctl_transact.c index 1f23c487..cfbe0e65 100644 --- a/hunt/huntd/ctl_transact.c +++ b/hunt/huntd/ctl_transact.c @@ -1,3 +1,4 @@ +/* $NetBSD: ctl_transact.c,v 1.2 1997/10/10 16:33:01 lukem Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement @@ -8,12 +9,19 @@ #if defined(TALK_43) || defined(TALK_42) +#include <sys/cdefs.h> #ifndef lint +#if 0 static char sccsid[] = "@(#)ctl_transact.c 5.2 (Berkeley) 3/13/86"; +#else +__RCSID("$NetBSD: ctl_transact.c,v 1.2 1997/10/10 16:33:01 lukem Exp $"); #endif +#endif /* not lint */ -#include "talk_ctl.h" #include <sys/time.h> +#include <unistd.h> +#include "hunt.h" +#include "talk_ctl.h" #define CTL_WAIT 2 /* time to wait for a response, in seconds */ #define MAX_RETRY 5 @@ -23,19 +31,22 @@ static char sccsid[] = "@(#)ctl_transact.c 5.2 (Berkeley) 3/13/86"; * not recieved an acknowledgement within a reasonable amount * of time */ +void ctl_transact(target, msg, type, rp) struct in_addr target; CTL_MSG msg; int type; CTL_RESPONSE *rp; { - int read_mask, ctl_mask, nready, cc, retries; + fd_set read_mask, ctl_mask; + int nready, cc, retries; struct timeval wait; + nready = 0; msg.type = type; daemon_addr.sin_addr = target; daemon_addr.sin_port = daemon_port; - ctl_mask = 1 << ctl_sockt; + FD_SET(ctl_sockt, &ctl_mask); /* * Keep sending the message until a response of diff --git a/hunt/huntd/draw.c b/hunt/huntd/draw.c index bbadbe16..ee53641c 100644 --- a/hunt/huntd/draw.c +++ b/hunt/huntd/draw.c @@ -1,18 +1,25 @@ +/* $NetBSD: draw.c,v 1.2 1997/10/10 16:33:04 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California */ +#include <sys/cdefs.h> +#ifndef lint +__RCSID("$NetBSD: draw.c,v 1.2 1997/10/10 16:33:04 lukem Exp $"); +#endif /* not lint */ + # include "hunt.h" +void drawmaze(pp) -register PLAYER *pp; + PLAYER *pp; { - register int x; - register char *sp; - register int y; - register char *endp; + int x; + char *sp; + int y; + char *endp; clrscr(pp); outstr(pp, pp->p_maze[0], WIDTH); @@ -38,11 +45,12 @@ register PLAYER *pp; * drawstatus - put up the status lines (this assumes the screen * size is 80x24 with the maze being 64x24) */ +void drawstatus(pp) -register PLAYER *pp; + PLAYER *pp; { - register int i; - register PLAYER *np; + int i; + PLAYER *np; cgoto(pp, STAT_AMMO_ROW, STAT_LABEL_COL); outstr(pp, "Ammo:", 5); @@ -89,10 +97,11 @@ register PLAYER *pp; # endif } +void look(pp) -register PLAYER *pp; + PLAYER *pp; { - register int x, y; + int x, y; x = pp->p_x; y = pp->p_y; @@ -136,12 +145,13 @@ register PLAYER *pp; cgoto(pp, y, x); } +void see(pp, face) -register PLAYER *pp; -int face; + PLAYER *pp; + int face; { - register char *sp; - register int y, x, i, cnt; + char *sp; + int y, x, i, cnt; x = pp->p_x; y = pp->p_y; @@ -149,7 +159,7 @@ int face; switch (face) { case LEFTS: sp = &Maze[y][x]; - for (i = 0; See_over[*--sp]; i++) + for (i = 0; See_over[(int)*--sp]; i++) continue; if (i == 0) @@ -173,7 +183,7 @@ int face; break; case RIGHT: sp = &Maze[y][++x]; - for (i = 0; See_over[*sp++]; i++) + for (i = 0; See_over[(int)*sp++]; i++) continue; if (i == 0) @@ -197,7 +207,7 @@ int face; break; case ABOVE: sp = &Maze[--y][x]; - if (!See_over[*sp]) + if (!See_over[(int)*sp]) break; do { --y; @@ -205,11 +215,11 @@ int face; check(pp, y, x - 1); check(pp, y, x ); check(pp, y, x + 1); - } while (See_over[*sp]); + } while (See_over[(int)*sp]); break; case BELOW: sp = &Maze[++y][x]; - if (!See_over[*sp]) + if (!See_over[(int)*sp]) break; do { y++; @@ -217,18 +227,19 @@ int face; check(pp, y, x - 1); check(pp, y, x ); check(pp, y, x + 1); - } while (See_over[*sp]); + } while (See_over[(int)*sp]); break; } } +void check(pp, y, x) -PLAYER *pp; -int y, x; + PLAYER *pp; + int y, x; { - register int index; - register int ch; - register PLAYER *rpp; + int index; + int ch; + PLAYER *rpp; index = y * sizeof Maze[0] + x; ch = ((char *) Maze)[index]; @@ -249,12 +260,13 @@ int y, x; * showstat * Update the status of players */ +void showstat(pp) -register PLAYER *pp; + PLAYER *pp; { - register PLAYER *np; - register int y; - register char c; + PLAYER *np; + int y; + char c; y = STAT_PLAY_ROW + 1 + (pp - Player); c = stat_char(pp); @@ -275,12 +287,13 @@ register PLAYER *pp; * Draw the player on the screen and show him to everyone who's scanning * unless he is cloaked. */ +void drawplayer(pp, draw) -PLAYER *pp; -FLAG draw; + PLAYER *pp; + FLAG draw; { - register PLAYER *newp; - register int x, y; + PLAYER *newp; + int x, y; x = pp->p_x; y = pp->p_y; @@ -312,9 +325,10 @@ FLAG draw; showstat(pp); } +void message(pp, s) -register PLAYER *pp; -char *s; + PLAYER *pp; + char *s; { cgoto(pp, HEIGHT, 0); outstr(pp, s, strlen(s)); @@ -326,8 +340,9 @@ char *s; * Turn a character into the right direction character if we are * looking at the current player. */ +char translate(ch) -char ch; + char ch; { switch (ch) { case LEFTS: @@ -346,11 +361,12 @@ char ch; * player_sym: * Return the player symbol */ +int player_sym(pp, y, x) -PLAYER *pp; -int y, x; + PLAYER *pp; + int y, x; { - register PLAYER *npp; + PLAYER *npp; npp = play_at(y, x); if (npp->p_ident->i_team == ' ') diff --git a/hunt/huntd/driver.c b/hunt/huntd/driver.c index f7f0c9d6..1f3b47a3 100644 --- a/hunt/huntd/driver.c +++ b/hunt/huntd/driver.c @@ -1,14 +1,24 @@ +/* $NetBSD: driver.c,v 1.2 1997/10/10 16:33:08 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California */ -# include "hunt.h" -# include <signal.h> -# include <errno.h> +#include <sys/cdefs.h> +#ifndef lint +__RCSID("$NetBSD: driver.c,v 1.2 1997/10/10 16:33:08 lukem Exp $"); +#endif /* not lint */ + # include <sys/ioctl.h> +# include <sys/stat.h> # include <sys/time.h> +# include <err.h> +# include <errno.h> +# include <signal.h> +# include <stdlib.h> +# include <unistd.h> +# include "hunt.h" # ifndef pdp11 # define RN (((Seed = Seed * 11109 + 13849) >> 16) & 0xffff) @@ -33,26 +43,33 @@ u_short stat_port; /* port # of statistics tcp socket */ # define DAEMON_SIZE (sizeof Daemon - 1) # endif -extern SIGNAL_TYPE cleanup(); +static void clear_scores __P((void)); +static int havechar __P((PLAYER *)); +static void init __P((void)); + int main __P((int, char *[], char *[])); +static void makeboots __P((void)); +static void send_stats __P((void)); +static void zap __P((PLAYER *, FLAG)); + /* * main: * The main program. */ +int main(ac, av, ep) -int ac; -char **av, **ep; + int ac; + char **av, **ep; { - register PLAYER *pp; - register int had_char; + PLAYER *pp; + int had_char; # ifdef INTERNET - register long test_mask; - u_short msg; - short port_num, reply; - int namelen; - SOCKET test; + u_short msg; + short port_num, reply; + int namelen; + SOCKET test; # endif - static long read_fds; + static fd_set read_fds; static FLAG first = TRUE; static FLAG server = FALSE; extern int optind; @@ -67,7 +84,7 @@ char **av, **ep; ep++; Last_arg = ep[-1] + strlen(ep[-1]); - while ((c = getopt(ac, av, "sp:")) != EOF) { + while ((c = getopt(ac, av, "sp:")) != -1) { switch (c) { case 's': server = TRUE; @@ -88,19 +105,13 @@ erred: goto erred; init(); - Sock_mask = (1 << Socket); - Stat_mask = (1 << Status); -# ifdef INTERNET - test_mask = (1 << Test_socket); -# endif again: do { read_fds = Fds_mask; errno = 0; - while (select(Num_fds, &read_fds, (int *) NULL, - (int *) NULL, (struct timeval *) NULL) < 0) + while (select(Num_fds, &read_fds, NULL, NULL, NULL) < 0) { if (errno != EINTR) # ifdef LOG @@ -112,7 +123,7 @@ again: } Have_inp = read_fds; # ifdef INTERNET - if (read_fds & test_mask) { + if (FD_ISSET(Test_socket, &read_fds)) { namelen = DAEMON_SIZE; port_num = htons(sock_port); (void) recvfrom(Test_socket, (char *) &msg, sizeof msg, @@ -176,7 +187,7 @@ again: pp++; # endif } - if (read_fds & Sock_mask) + if (FD_ISSET(Socket, &read_fds)) if (answer()) { # ifdef INTERNET if (first && standard_port) @@ -184,17 +195,17 @@ again: # endif first = FALSE; } - if (read_fds & Stat_mask) + if (FD_ISSET(Status, &read_fds)) send_stats(); for (pp = Player; pp < End_player; pp++) { - if (read_fds & pp->p_mask) + if (FD_ISSET(pp->p_fd, &read_fds)) sendcom(pp, READY, pp->p_nexec); pp->p_nexec = 0; (void) fflush(pp->p_output); } # ifdef MONITOR for (pp = Monitor; pp < End_monitor; pp++) { - if (read_fds & pp->p_mask) + if (FD_ISSET(pp->p_fd, &read_fds)) sendcom(pp, READY, pp->p_nexec); pp->p_nexec = 0; (void) fflush(pp->p_output); @@ -203,8 +214,7 @@ again: } while (Nplayer > 0); read_fds = Fds_mask; - if (select(Num_fds, &read_fds, (int *) NULL, (int *) NULL, - &linger) > 0) { + if (select(Num_fds, &read_fds, NULL, NULL, &linger) > 0) { goto again; } if (server) { @@ -223,19 +233,22 @@ again: zap(pp, FALSE); # endif cleanup(0); + /* NOTREACHED */ + return(0); } /* * init: * Initialize the global parameters. */ +static void init() { - register int i; + int i; # ifdef INTERNET - auto SOCKET test_port; - auto int msg; - auto int len; + SOCKET test_port; + int msg; + int len; # endif # ifndef DEBUG @@ -354,7 +367,8 @@ init() /* * Initialize minimal select mask */ - Fds_mask = (1 << Socket) | (1 << Status); + FD_SET(Socket, &Fds_mask); + FD_SET(Status, &Fds_mask); Num_fds = ((Socket > Status) ? Socket : Status) + 1; # ifdef INTERNET @@ -384,7 +398,7 @@ init() (void) listen(Test_socket, 5); } - Fds_mask |= (1 << Test_socket); + FD_SET(Test_socket, &Fds_mask); if (Test_socket + 1 > Num_fds) Num_fds = Test_socket + 1; # endif @@ -413,10 +427,11 @@ init() * makeboots: * Put the boots in the maze */ +static void makeboots() { - register int x, y; - register PLAYER *pp; + int x, y; + PLAYER *pp; do { x = rand_num(WIDTH - 1) + 1; @@ -433,13 +448,14 @@ makeboots() * checkdam: * Check the damage to the given player, and see if s/he is killed */ +void checkdam(ouch, gotcha, credit, amt, shot_type) -register PLAYER *ouch, *gotcha; -register IDENT *credit; -int amt; -char shot_type; + PLAYER *ouch, *gotcha; + IDENT *credit; + int amt; + char shot_type; { - register char *cp; + char *cp; if (ouch->p_death[0] != '\0') return; @@ -566,15 +582,16 @@ char shot_type; * zap: * Kill off a player and take him out of the game. */ +static void zap(pp, was_player) -register PLAYER *pp; -FLAG was_player; + PLAYER *pp; + FLAG was_player; { - register int i, len; - register BULLET *bp; - register PLAYER *np; - register int x, y; - int savefd, savemask; + int i, len; + BULLET *bp; + PLAYER *np; + int x, y; + int savefd; if (was_player) { if (pp->p_undershot) @@ -598,7 +615,6 @@ FLAG was_player; cgoto(pp, HEIGHT, 0); savefd = pp->p_fd; - savemask = pp->p_mask; # ifdef MONITOR if (was_player) { @@ -653,7 +669,7 @@ FLAG was_player; if (np->p_flying < 0) break; if (np >= &Boot[NBOOTS]) - abort(1, "Too many boots"); + err(1, "Too many boots"); np->p_undershot = FALSE; np->p_x = pp->p_x; np->p_y = pp->p_y; @@ -776,7 +792,7 @@ FLAG was_player; } # endif - Fds_mask &= ~savemask; + FD_CLR(savefd, &Fds_mask); if (Num_fds == savefd + 1) { Num_fds = Socket; # ifdef INTERNET @@ -799,8 +815,9 @@ FLAG was_player; * rand_num: * Return a random number in a given range. */ +int rand_num(range) -int range; + int range; { return (range == 0 ? 0 : RN % range); } @@ -811,16 +828,16 @@ int range; * we do, read them, stash them away, and return TRUE; else return * FALSE. */ +static int havechar(pp) -register PLAYER *pp; + PLAYER *pp; { - extern int errno; if (pp->p_ncount < pp->p_nchar) return TRUE; - if (!(Have_inp & pp->p_mask)) + if (!FD_ISSET(pp->p_fd, &Have_inp)) return FALSE; - Have_inp &= ~pp->p_mask; + FD_CLR(pp->p_fd, &Have_inp); check_again: errno = 0; if ((pp->p_nchar = read(pp->p_fd, pp->p_cbuf, sizeof pp->p_cbuf)) <= 0) @@ -839,9 +856,9 @@ check_again: */ SIGNAL_TYPE cleanup(eval) -int eval; + int eval; { - register PLAYER *pp; + PLAYER *pp; for (pp = Player; pp < End_player; pp++) { cgoto(pp, HEIGHT, 0); @@ -869,13 +886,14 @@ int eval; * send_stats: * Print stats to requestor */ +static void send_stats() { - register IDENT *ip; - register FILE *fp; - int s; - SOCKET sockstruct; - int socklen; + IDENT *ip; + FILE *fp; + int s; + SOCKET sockstruct; + int socklen; /* * Get the output stream ready @@ -944,9 +962,10 @@ send_stats() * clear_scores: * Clear out the scores so the next session start clean */ +static void clear_scores() { - register IDENT *ip, *nextip; + IDENT *ip, *nextip; for (ip = Scores; ip != NULL; ip = nextip) { nextip = ip->i_next; diff --git a/hunt/huntd/execute.c b/hunt/huntd/execute.c index c961d486..30046448 100644 --- a/hunt/huntd/execute.c +++ b/hunt/huntd/execute.c @@ -1,20 +1,37 @@ +/* $NetBSD: execute.c,v 1.2 1997/10/10 16:33:13 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California */ +#include <sys/cdefs.h> +#ifndef lint +__RCSID("$NetBSD: execute.c,v 1.2 1997/10/10 16:33:13 lukem Exp $"); +#endif /* not lint */ + +# include <stdlib.h> # include "hunt.h" +static void cloak __P((PLAYER *)); +static void face __P((PLAYER *, int)); +static void fire __P((PLAYER *, int)); +static void fire_slime __P((PLAYER *, int)); +static void move_player __P((PLAYER *, int)); +static void pickup __P((PLAYER *, int, int, int, int)); +static void scan __P((PLAYER *)); + + # ifdef MONITOR /* * mon_execute: * Execute a single monitor command */ +void mon_execute(pp) -register PLAYER *pp; + PLAYER *pp; { - register char ch; + char ch; ch = pp->p_cbuf[pp->p_ncount++]; switch (ch) { @@ -32,10 +49,11 @@ register PLAYER *pp; * execute: * Execute a single command */ +void execute(pp) -register PLAYER *pp; + PLAYER *pp; { - register char ch; + char ch; ch = pp->p_cbuf[pp->p_ncount++]; @@ -148,14 +166,15 @@ register PLAYER *pp; * move_player: * Execute a move in the given direction */ +static void move_player(pp, dir) -register PLAYER *pp; -int dir; + PLAYER *pp; + int dir; { - register PLAYER *newp; - register int x, y; - register FLAG moved; - register BULLET *bp; + PLAYER *newp; + int x, y; + FLAG moved; + BULLET *bp; y = pp->p_y; x = pp->p_x; @@ -283,9 +302,10 @@ int dir; * face: * Change the direction the player is facing */ +static void face(pp, dir) -register PLAYER *pp; -register int dir; + PLAYER *pp; + int dir; { if (pp->p_face != dir) { pp->p_face = dir; @@ -297,9 +317,10 @@ register int dir; * fire: * Fire a shot of the given type in the given direction */ +static void fire(pp, req_index) -register PLAYER *pp; -register int req_index; + PLAYER *pp; + int req_index; { if (pp == NULL) return; @@ -345,9 +366,10 @@ register int req_index; * fire_slime: * Fire a slime shot in the given direction */ +static void fire_slime(pp, req_index) -register PLAYER *pp; -register int req_index; + PLAYER *pp; + int req_index; { if (pp == NULL) return; @@ -393,6 +415,7 @@ register int req_index; * add_shot: * Create a shot with the given properties */ +void add_shot(type, y, x, face, charge, owner, expl, over) int type; int y, x; @@ -402,8 +425,8 @@ PLAYER *owner; int expl; char over; { - register BULLET *bp; - register int size; + BULLET *bp; + int size; switch (type) { case SHOT: @@ -436,17 +459,17 @@ char over; BULLET * create_shot(type, y, x, face, charge, size, owner, score, expl, over) -int type; -int y, x; -char face; -int charge; -int size; -PLAYER *owner; -IDENT *score; -int expl; -char over; + int type; + int y, x; + char face; + int charge; + int size; + PLAYER *owner; + IDENT *score; + int expl; + char over; { - register BULLET *bp; + BULLET *bp; bp = (BULLET *) malloc(sizeof (BULLET)); /* NOSTRICT */ if (bp == NULL) { @@ -474,8 +497,9 @@ char over; * cloak: * Turn on or increase length of a cloak */ +static void cloak(pp) -register PLAYER *pp; + PLAYER *pp; { if (pp->p_ammo <= 0) { message(pp, "No more charges"); @@ -503,8 +527,9 @@ register PLAYER *pp; * scan: * Turn on or increase length of a scan */ +static void scan(pp) -register PLAYER *pp; + PLAYER *pp; { if (pp->p_ammo <= 0) { message(pp, "No more charges"); @@ -526,13 +551,14 @@ register PLAYER *pp; * pickup: * check whether the object blew up or whether he picked it up */ +void pickup(pp, y, x, prob, obj) -register PLAYER *pp; -register int y, x; -int prob; -int obj; + PLAYER *pp; + int y, x; + int prob; + int obj; { - register int req; + int req; switch (obj) { case MINE: diff --git a/hunt/huntd/expl.c b/hunt/huntd/expl.c index 59f7eee2..74a8f585 100644 --- a/hunt/huntd/expl.c +++ b/hunt/huntd/expl.c @@ -1,21 +1,32 @@ +/* $NetBSD: expl.c,v 1.2 1997/10/10 16:33:18 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California */ +#include <sys/cdefs.h> +#ifndef lint +__RCSID("$NetBSD: expl.c,v 1.2 1997/10/10 16:33:18 lukem Exp $"); +#endif /* not lint */ + +# include <stdlib.h> # include "hunt.h" +static void remove_wall __P((int, int)); + + /* * showexpl: * Show the explosions as they currently are */ +void showexpl(y, x, type) -register int y, x; -char type; + int y, x; + char type; { - register PLAYER *pp; - register EXPL *ep; + PLAYER *pp; + EXPL *ep; if (y < 0 || y >= HEIGHT) return; @@ -69,13 +80,14 @@ char type; * Roll the explosions over, so the next one in the list is at the * top */ +void rollexpl() { - register EXPL *ep; - register PLAYER *pp; - register int y, x; - register char c; - register EXPL *nextep; + EXPL *ep; + PLAYER *pp; + int y, x; + char c; + EXPL *nextep; for (ep = Expl[EXPLEN - 1]; ep != NULL; ep = nextep) { nextep = ep->e_next; @@ -114,15 +126,16 @@ static REGEN *rem_index = removed; * if there is no space left over, put the a wall at * the location currently pointed at. */ +static void remove_wall(y, x) -int y, x; + int y, x; { - register REGEN *r; + REGEN *r; # if defined(MONITOR) || defined(FLY) - register PLAYER *pp; + PLAYER *pp; # endif # ifdef FLY - register char save_char; + char save_char = 0; # endif r = rem_index; @@ -201,9 +214,10 @@ found: * clearwalls: * Clear out the walls array */ +void clearwalls() { - register REGEN *rp; + REGEN *rp; for (rp = removed; rp < &removed[MAXREMOVE]; rp++) rp->r_y = 0; diff --git a/hunt/huntd/extern.c b/hunt/huntd/extern.c index 64e5fccf..e25ba836 100644 --- a/hunt/huntd/extern.c +++ b/hunt/huntd/extern.c @@ -1,9 +1,15 @@ +/* $NetBSD: extern.c,v 1.2 1997/10/10 16:33:24 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California */ +#include <sys/cdefs.h> +#ifndef lint +__RCSID("$NetBSD: extern.c,v 1.2 1997/10/10 16:33:24 lukem Exp $"); +#endif /* not lint */ + # include "hunt.h" # ifdef MONITOR @@ -14,14 +20,12 @@ char Buf[BUFSIZ]; /* general scribbling buffer */ char Maze[HEIGHT][WIDTH2]; /* the maze */ char Orig_maze[HEIGHT][WIDTH2]; /* the original maze */ -long Fds_mask; /* mask for the file descriptors */ -int Have_inp; /* which file descriptors have input */ +fd_set Fds_mask; /* mask for the file descriptors */ +fd_set Have_inp; /* which file descriptors have input */ int Nplayer = 0; /* number of players */ int Num_fds; /* number of maximum file descriptor */ int Socket; /* main socket */ -long Sock_mask; /* select mask for main socket */ int Status; /* stat socket */ -long Stat_mask; /* select mask for stat socket */ int See_over[NASCII]; /* lookup table for determining whether * character represents "transparent" * item */ diff --git a/hunt/huntd/faketalk.c b/hunt/huntd/faketalk.c index 48f17990..e594b12e 100644 --- a/hunt/huntd/faketalk.c +++ b/hunt/huntd/faketalk.c @@ -1,3 +1,4 @@ +/* $NetBSD: faketalk.c,v 1.3 1997/10/10 16:33:31 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold @@ -8,18 +9,25 @@ * specifies the terms and conditions for redistribution. */ +#include <sys/cdefs.h> +#ifndef lint +__RCSID("$NetBSD: faketalk.c,v 1.3 1997/10/10 16:33:31 lukem Exp $"); +#endif /* not lint */ + #include "bsd.h" #if defined(TALK_43) || defined(TALK_42) +# include <sys/time.h> +# include <sys/wait.h> +# include <ctype.h> +# include <netdb.h> +# include <signal.h> # include <stdio.h> # include <string.h> -# include <netdb.h> +# include <unistd.h> +# include "hunt.h" # include "talk_ctl.h" -# include <ctype.h> -# include <signal.h> -# include <sys/time.h> -extern int errno; # define TRUE 1 # define FALSE 0 @@ -36,12 +44,16 @@ extern int errno; extern char *my_machine_name; extern char *First_arg, *Last_arg; +static void do_announce __P((char *)); +SIGNAL_TYPE exorcise __P((int)); + /* * exorcise - disspell zombies */ SIGNAL_TYPE -exorcise() +exorcise(dummy) + int dummy; { (void) wait(0); } @@ -51,6 +63,7 @@ exorcise() * and fake a talk request to each address thus found. */ +void faketalk() { struct servent *sp; @@ -171,6 +184,7 @@ faketalk() * These are used to delete the invitations. */ +static void do_announce(s) char *s; { diff --git a/hunt/huntd/get_names.c b/hunt/huntd/get_names.c index e8a101a0..2d1cbe4d 100644 --- a/hunt/huntd/get_names.c +++ b/hunt/huntd/get_names.c @@ -1,30 +1,36 @@ +/* $NetBSD: get_names.c,v 1.2 1997/10/10 16:33:35 lukem Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ +#include <sys/cdefs.h> +#ifndef lint +__RCSID("$NetBSD: get_names.c,v 1.2 1997/10/10 16:33:35 lukem Exp $"); +#endif /* not lint */ + #include "bsd.h" #if defined(TALK_43) || defined(TALK_42) +# include <sys/param.h> +# include <netdb.h> # include <stdio.h> # include <string.h> +# include <unistd.h> +# include "hunt.h" # include "talk_ctl.h" -# include <sys/param.h> -# include <netdb.h> extern CTL_MSG msg; -struct hostent *gethostbyname(); -struct servent *getservbyname(); - static char hostname[MAXHOSTNAMELEN]; char *my_machine_name; /* * Determine the local user and machine */ +void get_local_name(my_name) char *my_name; { @@ -75,6 +81,7 @@ get_local_name(my_name) /* * Determine the remote user and machine */ +int get_remote_name(his_address) char *his_address; { @@ -109,7 +116,7 @@ get_remote_name(his_address) msg.r_name[NAME_SIZE - 1] = '\0'; /* if he is on the same machine, then simply copy */ - if (bcmp((char *) &his_machine_name, (char *) &my_machine_name, + if (memcmp((char *) &his_machine_name, (char *) &my_machine_name, sizeof(his_machine_name)) == 0) memcpy(&his_machine_addr, &my_machine_addr, sizeof(his_machine_name)); diff --git a/hunt/huntd/hunt.h b/hunt/huntd/hunt.h index 3225f44f..a48dc98d 100644 --- a/hunt/huntd/hunt.h +++ b/hunt/huntd/hunt.h @@ -345,8 +345,8 @@ extern char Buf[BUFSIZ], Maze[HEIGHT][WIDTH2], Orig_maze[HEIGHT][WIDTH2]; extern char *Sock_name, *Driver; -extern int errno, Have_inp, Nplayer, Num_fds, Socket, Status; -extern long Fds_mask, Sock_mask, Stat_mask; +extern int errno, Nplayer, Num_fds, Socket, Status; +extern fd_set Fds_mask, Have_inp; # ifdef INTERNET extern u_short Test_port; @@ -388,13 +388,66 @@ extern FLAG no_beep; * function types */ -extern char *getenv(); -extern void *malloc(), *realloc(); - -extern IDENT *get_ident(); - -extern int moveshots(); - -extern BULLET *is_bullet(), *create_shot(); - -extern PLAYER *play_at(); +void add_shot __P((int, int, int, char, int, PLAYER *, int, char)); +int answer __P((void)); +void bad_con __P((void)); +void bad_ver __P((void)); +int broadcast_vec __P((int, struct sockaddr **)); +void ce __P((PLAYER *)); +void cgoto __P((PLAYER *, int, int)); +void check __P((PLAYER *, int, int)); +void checkdam __P((PLAYER *, PLAYER *, IDENT *, int, char)); +void clearwalls __P((void)); +void clear_eol __P((void)); +void clear_the_screen __P((void)); +void clrscr __P((PLAYER *)); +BULLET *create_shot __P((int, int, int, char, int, int, PLAYER *, + IDENT *, int, char)); +void do_connect __P((char *, char, long)); +void do_message __P((void)); +void drawmaze __P((PLAYER *)); +void drawplayer __P((PLAYER *, FLAG)); +void drawstatus __P((PLAYER *)); +void execute __P((PLAYER *)); +void faketalk __P((void)); +void find_driver __P((FLAG)); +void fixshots __P((int, int, char)); +IDENT *get_ident __P((u_long, u_long, char *, char)); +void get_local_name __P((char *)); +int get_remote_name __P((char *)); +BULLET *is_bullet __P((int, int)); +void look __P((PLAYER *)); +void makemaze __P((void)); +void message __P((PLAYER *, char *)); +void mon_execute __P((PLAYER *)); +void moveshots __P((void)); +void open_ctl __P((void)); +int opposite __P((int, char)); +void otto __P((int, int, char)); +void outch __P((PLAYER *, int)); +void outstr __P((PLAYER *, char *, int)); +int player_sym __P((PLAYER *, int, int)); +PLAYER *play_at __P((int, int)); +void playit __P((void)); +void put_ch __P((char)); +void put_str __P((char *)); +int quit __P((int)); +int rand_dir __P((void)); +int rand_num __P((int)); +void redraw_screen __P((void)); +void rmnl __P((char *)); +void rollexpl __P((void)); +void see __P((PLAYER *, int)); +void sendcom __P((PLAYER *, int, ...)); +void showexpl __P((int, int, char)); +void showstat __P((PLAYER *)); +void start_driver __P((void)); +void stmonitor __P((PLAYER *)); +void stplayer __P((PLAYER *, int)); +char translate __P((char)); +SIGNAL_TYPE cleanup __P((int)); +SIGNAL_TYPE intr __P((int)); +SIGNAL_TYPE sigalrm __P((int)); +SIGNAL_TYPE sigemt __P((int)); +SIGNAL_TYPE sigterm __P((int)); +SIGNAL_TYPE tstp __P((int)); diff --git a/hunt/huntd/makemaze.c b/hunt/huntd/makemaze.c index d0e88960..bcc21c61 100644 --- a/hunt/huntd/makemaze.c +++ b/hunt/huntd/makemaze.c @@ -1,18 +1,30 @@ +/* $NetBSD: makemaze.c,v 1.2 1997/10/10 16:33:43 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California */ +#include <sys/cdefs.h> +#ifndef lint +__RCSID("$NetBSD: makemaze.c,v 1.2 1997/10/10 16:33:43 lukem Exp $"); +#endif /* not lint */ + # include "hunt.h" # define ISCLEAR(y,x) (Maze[y][x] == SPACE) # define ODD(n) ((n) & 01) +static int candig __P((int, int)); +static void dig __P((int, int)); +static void dig_maze __P((int, int)); +static void remap __P((void)); + +void makemaze() { - register char *sp; - register int y, x; + char *sp; + int y, x; /* * fill maze with walls @@ -43,13 +55,14 @@ int incr[NDIR][2] = { {0, 1}, {1, 0}, {0, -1}, {-1, 0} }; +static void dig(y, x) -int y, x; + int y, x; { - register int *dp; - register int *ip; - register int ny, nx; - register int *endp; + int *dp; + int *ip; + int ny, nx; + int *endp; Maze[y][x] = SPACE; /* Clear this spot */ dp = dirs[rand_num(NPERM)]; @@ -67,10 +80,11 @@ int y, x; * candig: * Is it legal to clear this spot? */ +static int candig(y, x) -register int y, x; + int y, x; { - register int i; + int i; if (ODD(x) && ODD(y)) return FALSE; /* can't touch ODD spots */ @@ -97,17 +111,19 @@ register int y, x; return TRUE; /* OK */ } +void dig_maze(x, y) -int x, y; + int x, y; { - register int tx, ty; - register int i, j; - int order[4]; + int tx, ty; + int i, j; + int order[4]; #define MNORTH 0x1 #define MSOUTH 0x2 #define MEAST 0x4 #define MWEST 0x8 + tx = ty = 0; Maze[y][x] = SPACE; order[0] = MNORTH; for (i = 1; i < 4; i++) { @@ -143,11 +159,12 @@ int x, y; } } +void remap() { - register int y, x; - register char *sp; - register int stat; + int y, x; + char *sp; + int stat; for (y = 0; y < HEIGHT; y++) for (x = 0; x < WIDTH; x++) { diff --git a/hunt/huntd/pathname.c b/hunt/huntd/pathname.c index 90b4d380..0f909f78 100644 --- a/hunt/huntd/pathname.c +++ b/hunt/huntd/pathname.c @@ -1,9 +1,15 @@ +/* $NetBSD: pathname.c,v 1.2 1997/10/10 16:33:49 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California */ +#include <sys/cdefs.h> +#ifndef lint +__RCSID("$NetBSD: pathname.c,v 1.2 1997/10/10 16:33:49 lukem Exp $"); +#endif /* not lint */ + /* * There is no particular significance to the numbers assigned * to Test_port. They're just random numbers greater than the diff --git a/hunt/huntd/shots.c b/hunt/huntd/shots.c index 3aa7284c..d0dfcf90 100644 --- a/hunt/huntd/shots.c +++ b/hunt/huntd/shots.c @@ -1,25 +1,49 @@ +/* $NetBSD: shots.c,v 1.2 1997/10/10 16:33:54 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California */ -# include "hunt.h" +#include <sys/cdefs.h> +#ifndef lint +__RCSID("$NetBSD: shots.c,v 1.2 1997/10/10 16:33:54 lukem Exp $"); +#endif /* not lint */ + # include <signal.h> +# include <stdlib.h> +# include "hunt.h" # define PLUS_DELTA(x, max) if (x < max) x++; else x-- # define MINUS_DELTA(x, min) if (x > min) x--; else x++ +static void chkshot __P((BULLET *, BULLET *)); +static void chkslime __P((BULLET *, BULLET *)); +static void explshot __P((BULLET *, int, int)); +static void find_under __P((BULLET *, BULLET *)); +static int iswall __P((int, int)); +static void mark_boot __P((BULLET *)); +static void mark_player __P((BULLET *)); +#ifdef DRONE +static void move_drone __P((BULLET *)); +#endif +static void move_flyer __P((PLAYER *)); +static int move_normal_shot __P((BULLET *)); +static void move_slime __P((BULLET *, int, BULLET *)); +static void save_bullet __P((BULLET *)); +static void zapshot __P((BULLET *, BULLET *)); + /* * moveshots: * Move the shots already in the air, taking explosions into account */ +void moveshots() { - register BULLET *bp, *next; - register PLAYER *pp; - register int x, y; - register BULLET *blist; + BULLET *bp, *next; + PLAYER *pp; + int x, y; + BULLET *blist; rollexpl(); if (Bullets == NULL) @@ -132,11 +156,12 @@ ret: * move_normal_shot: * Move a normal shot along its trajectory */ +static int move_normal_shot(bp) -register BULLET *bp; + BULLET *bp; { - register int i, x, y; - register PLAYER *pp; + int i, x, y; + PLAYER *pp; for (i = 0; i < BULSPD; i++) { if (bp->b_expl) @@ -318,12 +343,13 @@ register BULLET *bp; * move_drone: * Move the drone to the next square */ +static void move_drone(bp) -register BULLET *bp; + BULLET *bp; { - register int mask, count; - register int n, dir; - register PLAYER *pp; + int mask, count; + int n, dir; + PLAYER *pp; /* * See if we can give someone a blast @@ -461,8 +487,9 @@ drone_move: * save_bullet: * Put this bullet back onto the bullet list */ +static void save_bullet(bp) -register BULLET *bp; + BULLET *bp; { bp->b_over = Maze[bp->b_y][bp->b_x]; switch (bp->b_over) { @@ -512,10 +539,11 @@ register BULLET *bp; * move_flyer: * Update the position of a player in flight */ +static void move_flyer(pp) -register PLAYER *pp; + PLAYER *pp; { - register int x, y; + int x, y; if (pp->p_undershot) { fixshots(pp->p_y, pp->p_x, pp->p_over); @@ -602,16 +630,18 @@ again: * chkshot * Handle explosions */ +static void chkshot(bp, next) -register BULLET *bp; -BULLET *next; + BULLET *bp; + BULLET *next; { - register int y, x; - register int dy, dx, absdy; - register int delta, damage; - register char expl; - register PLAYER *pp; + int y, x; + int dy, dx, absdy; + int delta, damage; + char expl; + PLAYER *pp; + delta = 0; switch (bp->b_type) { case SHOT: case MINE: @@ -694,11 +724,12 @@ BULLET *next; * chkslime: * handle slime shot exploding */ +static void chkslime(bp, next) -register BULLET *bp; -BULLET *next; + BULLET *bp; + BULLET *next; { - register BULLET *nbp; + BULLET *nbp; switch (Maze[bp->b_y][bp->b_x]) { case WALL1: @@ -741,14 +772,15 @@ BULLET *next; * move the given slime shot speed times and add it back if * it hasn't fizzled yet */ +void move_slime(bp, speed, next) -register BULLET *bp; -register int speed; -BULLET *next; + BULLET *bp; + int speed; + BULLET *next; { - register int i, j, dirmask, count; - register PLAYER *pp; - register BULLET *nbp; + int i, j, dirmask, count; + PLAYER *pp; + BULLET *nbp; if (speed == 0) { if (bp->b_charge <= 0) @@ -900,8 +932,9 @@ BULLET *next; * iswall: * returns whether the given location is a wall */ +static int iswall(y, x) -register int y, x; + int y, x; { if (y < 0 || x < 0 || y >= HEIGHT || x >= WIDTH) return TRUE; @@ -932,11 +965,12 @@ register int y, x; * zapshot: * Take a shot out of the air. */ +static void zapshot(blist, obp) -register BULLET *blist, *obp; + BULLET *blist, *obp; { - register BULLET *bp; - register FLAG explode; + BULLET *bp; + FLAG explode; explode = FALSE; for (bp = blist; bp != NULL; bp = bp->b_next) { @@ -956,11 +990,12 @@ register BULLET *blist, *obp; * explshot - * Make all shots at this location blow up */ +void explshot(blist, y, x) -register BULLET *blist; -register int y, x; + BULLET *blist; + int y, x; { - register BULLET *bp; + BULLET *bp; for (bp = blist; bp != NULL; bp = bp->b_next) if (bp->b_x == x && bp->b_y == y) { @@ -976,9 +1011,9 @@ register int y, x; */ PLAYER * play_at(y, x) -register int y, x; + int y, x; { - register PLAYER *pp; + PLAYER *pp; for (pp = Player; pp < End_player; pp++) if (pp->p_x == x && pp->p_y == y) @@ -993,9 +1028,10 @@ register int y, x; * Return TRUE if the bullet direction faces the opposite direction * of the player in the maze */ +int opposite(face, dir) -int face; -char dir; + int face; + char dir; { switch (face) { case LEFTS: @@ -1018,9 +1054,9 @@ char dir; */ BULLET * is_bullet(y, x) -register int y, x; + int y, x; { - register BULLET *bp; + BULLET *bp; for (bp = Bullets; bp != NULL; bp = bp->b_next) if (bp->b_y == y && bp->b_x == x) @@ -1033,11 +1069,12 @@ register int y, x; * change the underlying character of the shots at a location * to the given character. */ +void fixshots(y, x, over) -register int y, x; -char over; + int y, x; + char over; { - register BULLET *bp; + BULLET *bp; for (bp = Bullets; bp != NULL; bp = bp->b_next) if (bp->b_y == y && bp->b_x == x) @@ -1049,10 +1086,11 @@ char over; * find the underlying character for a bullet when it lands * on another bullet. */ +static void find_under(blist, bp) -register BULLET *blist, *bp; + BULLET *blist, *bp; { - register BULLET *nbp; + BULLET *nbp; for (nbp = blist; nbp != NULL; nbp = nbp->b_next) if (bp->b_y == nbp->b_y && bp->b_x == nbp->b_x) { @@ -1065,10 +1103,11 @@ register BULLET *blist, *bp; * mark_player: * mark a player as under a shot */ +static void mark_player(bp) -register BULLET *bp; + BULLET *bp; { - register PLAYER *pp; + PLAYER *pp; for (pp = Player; pp < End_player; pp++) if (pp->p_y == bp->b_y && pp->p_x == bp->b_x) { @@ -1082,10 +1121,11 @@ register BULLET *bp; * mark_boot: * mark a boot as under a shot */ +static void mark_boot(bp) -register BULLET *bp; + BULLET *bp; { - register PLAYER *pp; + PLAYER *pp; for (pp = Boot; pp < &Boot[NBOOTS]; pp++) if (pp->p_y == bp->b_y && pp->p_x == bp->b_x) { diff --git a/hunt/huntd/talk_ctl.h b/hunt/huntd/talk_ctl.h index 2b73f820..59071ec3 100644 --- a/hunt/huntd/talk_ctl.h +++ b/hunt/huntd/talk_ctl.h @@ -62,8 +62,6 @@ typedef struct ctl_msg { #include <syslog.h> #endif -extern int errno; - extern struct sockaddr_in daemon_addr; extern struct sockaddr_in ctl_addr; extern struct sockaddr_in my_addr; @@ -78,3 +76,5 @@ extern CTL_MSG msg; #else #define p_error(str) perror(str) #endif + +void ctl_transact __P((struct in_addr, CTL_MSG, int, CTL_RESPONSE *)); diff --git a/hunt/huntd/terminal.c b/hunt/huntd/terminal.c index 13d34850..94493531 100644 --- a/hunt/huntd/terminal.c +++ b/hunt/huntd/terminal.c @@ -1,9 +1,20 @@ +/* $NetBSD: terminal.c,v 1.2 1997/10/10 16:34:05 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold * San Francisco, California */ +#include <sys/cdefs.h> +#ifndef lint +__RCSID("$NetBSD: terminal.c,v 1.2 1997/10/10 16:34:05 lukem Exp $"); +#endif /* not lint */ + +#if __STDC__ +#include <stdarg.h> +#else +#include <varargs.h> +#endif # include "hunt.h" # define TERM_WIDTH 80 /* Assume terminals are 80-char wide */ @@ -12,9 +23,10 @@ * Move the cursor to the given position on the given player's * terminal. */ +void cgoto(pp, y, x) -register PLAYER *pp; -register int y, x; + PLAYER *pp; + int y, x; { if (x == pp->p_curx && y == pp->p_cury) return; @@ -27,9 +39,10 @@ register int y, x; * outch: * Put out a single character. */ +void outch(pp, ch) -register PLAYER *pp; -char ch; + PLAYER *pp; + char ch; { if (++pp->p_curx >= TERM_WIDTH) { pp->p_curx = 0; @@ -42,10 +55,11 @@ char ch; * outstr: * Put out a string of the given length. */ +void outstr(pp, str, len) -register PLAYER *pp; -register char *str; -register int len; + PLAYER *pp; + char *str; + int len; { pp->p_curx += len; pp->p_cury += (pp->p_curx / TERM_WIDTH); @@ -58,8 +72,9 @@ register int len; * clrscr: * Clear the screen, and reset the current position on the screen. */ +void clrscr(pp) -register PLAYER *pp; + PLAYER *pp; { sendcom(pp, CLEAR); pp->p_cury = 0; @@ -70,41 +85,61 @@ register PLAYER *pp; * ce: * Clear to the end of the line */ +void ce(pp) -PLAYER *pp; + PLAYER *pp; { sendcom(pp, CLRTOEOL); } +#if 0 /* XXX lukem*/ /* * ref; * Refresh the screen */ +void ref(pp) -register PLAYER *pp; + PLAYER *pp; { sendcom(pp, REFRESH); } +#endif /* * sendcom: * Send a command to the given user */ -/* VARARGS2 */ -sendcom(pp, command, arg1, arg2) -register PLAYER *pp; -register int command; -int arg1, arg2; +void +#if __STDC__ +sendcom(PLAYER *pp, int command, ...) +#else +sendcom(pp, command, va_alist) + PLAYER *pp; + int command; + va_dcl +#endif { + va_list ap; + int arg1, arg2; +#if __STDC__ + va_start(ap, command); +#else + va_start(ap); +#endif (void) putc(command, pp->p_output); switch (command & 0377) { - case MOVE: + case MOVE: + arg1 = va_arg(ap, int); + arg2 = va_arg(ap, int); (void) putc(arg1, pp->p_output); (void) putc(arg2, pp->p_output); break; - case ADDCH: - case READY: + case ADDCH: + case READY: + arg1 = va_arg(ap, int); (void) putc(arg1, pp->p_output); break; } + + va_end(ap); /* No return needed for void functions. */ } |