Home | History | Annotate | Line # | Download | only in huntd
answer.c revision 1.18
      1  1.18  dholland /*	$NetBSD: answer.c,v 1.18 2014/03/29 22:29:55 dholland Exp $	*/
      2   1.1       mrg /*
      3   1.6       wiz  * Copyright (c) 1983-2003, Regents of the University of California.
      4   1.6       wiz  * All rights reserved.
      5   1.6       wiz  *
      6   1.6       wiz  * Redistribution and use in source and binary forms, with or without
      7   1.6       wiz  * modification, are permitted provided that the following conditions are
      8   1.6       wiz  * met:
      9   1.6       wiz  *
     10   1.6       wiz  * + Redistributions of source code must retain the above copyright
     11   1.6       wiz  *   notice, this list of conditions and the following disclaimer.
     12   1.6       wiz  * + Redistributions in binary form must reproduce the above copyright
     13   1.6       wiz  *   notice, this list of conditions and the following disclaimer in the
     14   1.6       wiz  *   documentation and/or other materials provided with the distribution.
     15   1.6       wiz  * + Neither the name of the University of California, San Francisco nor
     16   1.6       wiz  *   the names of its contributors may be used to endorse or promote
     17   1.6       wiz  *   products derived from this software without specific prior written
     18   1.6       wiz  *   permission.
     19   1.6       wiz  *
     20   1.6       wiz  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
     21   1.6       wiz  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22   1.6       wiz  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
     23   1.6       wiz  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     24   1.6       wiz  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     25   1.6       wiz  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     26   1.6       wiz  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27   1.6       wiz  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28   1.6       wiz  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29   1.6       wiz  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     30   1.6       wiz  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31   1.1       mrg  */
     32   1.1       mrg 
     33   1.3     lukem #include <sys/cdefs.h>
     34   1.3     lukem #ifndef lint
     35  1.18  dholland __RCSID("$NetBSD: answer.c,v 1.18 2014/03/29 22:29:55 dholland Exp $");
     36   1.3     lukem #endif /* not lint */
     37   1.3     lukem 
     38  1.14  dholland #include <ctype.h>
     39  1.14  dholland #include <errno.h>
     40  1.14  dholland #include <fcntl.h>
     41  1.14  dholland #include <stdlib.h>
     42  1.14  dholland #include <unistd.h>
     43  1.14  dholland #include "hunt.h"
     44   1.1       mrg 
     45  1.14  dholland #define SCOREDECAY	15
     46   1.1       mrg 
     47  1.14  dholland static char Ttyname[NAMELEN];
     48   1.1       mrg 
     49  1.15  dholland static IDENT *get_ident(uint32_t, uint32_t, char *, char);
     50  1.15  dholland static void stmonitor(PLAYER *);
     51  1.15  dholland static void stplayer(PLAYER *, int);
     52  1.15  dholland 
     53   1.3     lukem int
     54  1.13  dholland answer(void)
     55   1.1       mrg {
     56  1.14  dholland 	PLAYER *pp;
     57  1.14  dholland 	int newsock;
     58  1.14  dholland 	static u_long mode;
     59  1.14  dholland 	static char name[NAMELEN];
     60  1.14  dholland 	static char team;
     61  1.14  dholland 	static int enter_status;
     62  1.14  dholland 	static socklen_t socklen;
     63  1.14  dholland 	static uint32_t machine;
     64  1.14  dholland 	static uint32_t uid;
     65  1.14  dholland 	static SOCKET sockstruct;
     66  1.14  dholland 	char *cp1, *cp2;
     67  1.14  dholland 	int flags;
     68  1.16  dholland 	uint32_t version;
     69  1.14  dholland 	int i;
     70   1.1       mrg 
     71  1.14  dholland #ifdef INTERNET
     72   1.1       mrg 	socklen = sizeof sockstruct;
     73  1.14  dholland #else
     74   1.1       mrg 	socklen = sizeof sockstruct - 1;
     75  1.14  dholland #endif
     76   1.1       mrg 	errno = 0;
     77   1.1       mrg 	newsock = accept(Socket, (struct sockaddr *) &sockstruct, &socklen);
     78   1.1       mrg 	if (newsock < 0)
     79   1.1       mrg 	{
     80   1.1       mrg 		if (errno == EINTR)
     81  1.17  dholland 			return false;
     82  1.18  dholland 		complain(LOG_ERR, "accept");
     83   1.1       mrg 		cleanup(1);
     84   1.1       mrg 	}
     85   1.1       mrg 
     86  1.14  dholland #ifdef INTERNET
     87   1.1       mrg 	machine = ntohl(((struct sockaddr_in *) &sockstruct)->sin_addr.s_addr);
     88  1.14  dholland #else
     89   1.1       mrg 	if (machine == 0)
     90   1.1       mrg 		machine = gethostid();
     91  1.14  dholland #endif
     92  1.16  dholland 	version = htonl((uint32_t) HUNT_VERSION);
     93  1.12  dholland 	(void) write(newsock, &version, LONGLEN);
     94  1.12  dholland 	(void) read(newsock, &uid, LONGLEN);
     95   1.9  dholland 	uid = ntohl(uid);
     96   1.1       mrg 	(void) read(newsock, name, NAMELEN);
     97   1.1       mrg 	(void) read(newsock, &team, 1);
     98  1.12  dholland 	(void) read(newsock, &enter_status, LONGLEN);
     99   1.1       mrg 	enter_status = ntohl((unsigned long) enter_status);
    100   1.1       mrg 	(void) read(newsock, Ttyname, NAMELEN);
    101  1.12  dholland 	(void) read(newsock, &mode, sizeof mode);
    102   1.1       mrg 	mode = ntohl(mode);
    103   1.1       mrg 
    104   1.1       mrg 	/*
    105  1.10  dholland 	 * Ensure null termination.
    106  1.10  dholland 	 */
    107  1.10  dholland 	name[sizeof(name)-1] = '\0';
    108  1.10  dholland 	Ttyname[sizeof(Ttyname)-1] = '\0';
    109  1.10  dholland 
    110  1.10  dholland 	/*
    111   1.1       mrg 	 * Turn off blocking I/O, so a slow or dead terminal won't stop
    112   1.1       mrg 	 * the game.  All subsequent reads check how many bytes they read.
    113   1.1       mrg 	 */
    114   1.1       mrg 	flags = fcntl(newsock, F_GETFL, 0);
    115   1.1       mrg 	flags |= O_NDELAY;
    116   1.1       mrg 	(void) fcntl(newsock, F_SETFL, flags);
    117   1.1       mrg 
    118   1.1       mrg 	/*
    119   1.1       mrg 	 * Make sure the name contains only printable characters
    120   1.1       mrg 	 * since we use control characters for cursor control
    121   1.1       mrg 	 * between driver and player processes
    122   1.1       mrg 	 */
    123   1.1       mrg 	for (cp1 = cp2 = name; *cp1 != '\0'; cp1++)
    124   1.7       dsl 		if (isprint((unsigned char)*cp1) || *cp1 == ' ')
    125   1.1       mrg 			*cp2++ = *cp1;
    126   1.1       mrg 	*cp2 = '\0';
    127   1.1       mrg 
    128  1.14  dholland #ifdef INTERNET
    129   1.1       mrg 	if (mode == C_MESSAGE) {
    130   1.1       mrg 		char	buf[BUFSIZ + 1];
    131   1.1       mrg 		int	n;
    132   1.1       mrg 
    133   1.1       mrg 		if (team == ' ')
    134  1.11  dholland 			(void) snprintf(buf, sizeof(buf), "%s: ", name);
    135   1.1       mrg 		else
    136  1.11  dholland 			(void) snprintf(buf, sizeof(buf), "%s[%c]: ", name,
    137  1.11  dholland 					team);
    138   1.1       mrg 		n = strlen(buf);
    139   1.1       mrg 		for (pp = Player; pp < End_player; pp++) {
    140   1.1       mrg 			cgoto(pp, HEIGHT, 0);
    141   1.1       mrg 			outstr(pp, buf, n);
    142   1.1       mrg 		}
    143   1.1       mrg 		while ((n = read(newsock, buf, BUFSIZ)) > 0)
    144   1.1       mrg 			for (pp = Player; pp < End_player; pp++)
    145   1.1       mrg 				outstr(pp, buf, n);
    146   1.1       mrg 		for (pp = Player; pp < End_player; pp++) {
    147   1.1       mrg 			ce(pp);
    148   1.1       mrg 			sendcom(pp, REFRESH);
    149   1.1       mrg 			sendcom(pp, READY, 0);
    150   1.1       mrg 			(void) fflush(pp->p_output);
    151   1.1       mrg 		}
    152   1.1       mrg 		(void) close(newsock);
    153  1.17  dholland 		return false;
    154   1.1       mrg 	}
    155   1.1       mrg 	else
    156  1.14  dholland #endif
    157  1.14  dholland #ifdef MONITOR
    158   1.1       mrg 	if (mode == C_MONITOR)
    159   1.4   mycroft 		if (End_monitor < &Monitor[MAXMON]) {
    160   1.1       mrg 			pp = End_monitor++;
    161   1.4   mycroft 			i = pp - Monitor + MAXPL + 3;
    162   1.4   mycroft 		} else {
    163   1.1       mrg 			socklen = 0;
    164  1.12  dholland 			(void) write(newsock, &socklen,
    165   1.1       mrg 				sizeof socklen);
    166   1.1       mrg 			(void) close(newsock);
    167  1.17  dholland 			return false;
    168   1.1       mrg 		}
    169   1.1       mrg 	else
    170  1.14  dholland #endif
    171   1.4   mycroft 		if (End_player < &Player[MAXPL]) {
    172   1.1       mrg 			pp = End_player++;
    173   1.4   mycroft 			i = pp - Player + 3;
    174   1.4   mycroft 		} else {
    175   1.1       mrg 			socklen = 0;
    176  1.12  dholland 			(void) write(newsock, &socklen,
    177   1.1       mrg 				sizeof socklen);
    178   1.1       mrg 			(void) close(newsock);
    179  1.17  dholland 			return false;
    180   1.1       mrg 		}
    181   1.1       mrg 
    182   1.1       mrg #ifdef MONITOR
    183   1.1       mrg 	if (mode == C_MONITOR && team == ' ')
    184   1.1       mrg 		team = '*';
    185   1.1       mrg #endif
    186   1.1       mrg 	pp->p_ident = get_ident(machine, uid, name, team);
    187   1.1       mrg 	pp->p_output = fdopen(newsock, "w");
    188   1.1       mrg 	pp->p_death[0] = '\0';
    189   1.1       mrg 	pp->p_fd = newsock;
    190   1.4   mycroft 	fdset[i].fd = newsock;
    191   1.4   mycroft 	fdset[i].events = POLLIN;
    192   1.1       mrg 
    193   1.1       mrg 	pp->p_y = 0;
    194   1.1       mrg 	pp->p_x = 0;
    195   1.1       mrg 
    196  1.14  dholland #ifdef MONITOR
    197   1.1       mrg 	if (mode == C_MONITOR)
    198   1.1       mrg 		stmonitor(pp);
    199   1.1       mrg 	else
    200  1.14  dholland #endif
    201   1.1       mrg 		stplayer(pp, enter_status);
    202  1.17  dholland 	return true;
    203   1.1       mrg }
    204   1.1       mrg 
    205  1.14  dholland #ifdef MONITOR
    206  1.15  dholland static void
    207  1.13  dholland stmonitor(PLAYER *pp)
    208   1.1       mrg {
    209  1.14  dholland 	int line;
    210  1.14  dholland 	PLAYER *npp;
    211   1.1       mrg 
    212   1.1       mrg 	memcpy(pp->p_maze, Maze, sizeof Maze);
    213   1.1       mrg 
    214   1.1       mrg 	drawmaze(pp);
    215   1.1       mrg 
    216  1.11  dholland 	(void) snprintf(Buf, sizeof(Buf), "%5.5s%c%-10.10s %c", " ",
    217  1.11  dholland 		stat_char(pp),
    218   1.1       mrg 		pp->p_ident->i_name, pp->p_ident->i_team);
    219   1.1       mrg 	line = STAT_MON_ROW + 1 + (pp - Monitor);
    220   1.1       mrg 	for (npp = Player; npp < End_player; npp++) {
    221   1.1       mrg 		cgoto(npp, line, STAT_NAME_COL);
    222   1.1       mrg 		outstr(npp, Buf, STAT_NAME_LEN);
    223   1.1       mrg 	}
    224   1.1       mrg 	for (npp = Monitor; npp < End_monitor; npp++) {
    225   1.1       mrg 		cgoto(npp, line, STAT_NAME_COL);
    226   1.1       mrg 		outstr(npp, Buf, STAT_NAME_LEN);
    227   1.1       mrg 	}
    228   1.1       mrg 
    229   1.1       mrg 	sendcom(pp, REFRESH);
    230   1.1       mrg 	sendcom(pp, READY, 0);
    231   1.1       mrg 	(void) fflush(pp->p_output);
    232   1.1       mrg }
    233  1.14  dholland #endif
    234   1.1       mrg 
    235  1.15  dholland static void
    236  1.13  dholland stplayer(PLAYER *newpp, int enter_status)
    237   1.1       mrg {
    238  1.14  dholland 	int x, y;
    239  1.14  dholland 	PLAYER *pp;
    240   1.1       mrg 
    241   1.1       mrg 	Nplayer++;
    242   1.1       mrg 
    243   1.1       mrg 	for (y = 0; y < UBOUND; y++)
    244   1.1       mrg 		for (x = 0; x < WIDTH; x++)
    245   1.1       mrg 			newpp->p_maze[y][x] = Maze[y][x];
    246   1.1       mrg 	for (     ; y < DBOUND; y++) {
    247   1.1       mrg 		for (x = 0; x < LBOUND; x++)
    248   1.1       mrg 			newpp->p_maze[y][x] = Maze[y][x];
    249   1.1       mrg 		for (     ; x < RBOUND; x++)
    250   1.1       mrg 			newpp->p_maze[y][x] = SPACE;
    251   1.1       mrg 		for (     ; x < WIDTH;  x++)
    252   1.1       mrg 			newpp->p_maze[y][x] = Maze[y][x];
    253   1.1       mrg 	}
    254   1.1       mrg 	for (     ; y < HEIGHT; y++)
    255   1.1       mrg 		for (x = 0; x < WIDTH; x++)
    256   1.1       mrg 			newpp->p_maze[y][x] = Maze[y][x];
    257   1.1       mrg 
    258   1.1       mrg 	do {
    259   1.1       mrg 		x = rand_num(WIDTH - 1) + 1;
    260   1.1       mrg 		y = rand_num(HEIGHT - 1) + 1;
    261   1.1       mrg 	} while (Maze[y][x] != SPACE);
    262   1.1       mrg 	newpp->p_over = SPACE;
    263   1.1       mrg 	newpp->p_x = x;
    264   1.1       mrg 	newpp->p_y = y;
    265  1.17  dholland 	newpp->p_undershot = false;
    266   1.1       mrg 
    267  1.14  dholland #ifdef FLY
    268   1.1       mrg 	if (enter_status == Q_FLY) {
    269   1.1       mrg 		newpp->p_flying = rand_num(20);
    270   1.1       mrg 		newpp->p_flyx = 2 * rand_num(6) - 5;
    271   1.1       mrg 		newpp->p_flyy = 2 * rand_num(6) - 5;
    272   1.1       mrg 		newpp->p_face = FLYER;
    273   1.1       mrg 	}
    274   1.1       mrg 	else
    275  1.14  dholland #endif
    276   1.1       mrg 	{
    277   1.1       mrg 		newpp->p_flying = -1;
    278   1.1       mrg 		newpp->p_face = rand_dir();
    279   1.1       mrg 	}
    280   1.1       mrg 	newpp->p_damage = 0;
    281   1.1       mrg 	newpp->p_damcap = MAXDAM;
    282   1.1       mrg 	newpp->p_nchar = 0;
    283   1.1       mrg 	newpp->p_ncount = 0;
    284   1.1       mrg 	newpp->p_nexec = 0;
    285   1.1       mrg 	newpp->p_ammo = ISHOTS;
    286  1.14  dholland #ifdef BOOTS
    287   1.1       mrg 	newpp->p_nboots = 0;
    288  1.14  dholland #endif
    289   1.1       mrg 	if (enter_status == Q_SCAN) {
    290   1.1       mrg 		newpp->p_scan = SCANLEN;
    291   1.1       mrg 		newpp->p_cloak = 0;
    292   1.1       mrg 	}
    293   1.1       mrg 	else {
    294   1.1       mrg 		newpp->p_scan = 0;
    295   1.1       mrg 		newpp->p_cloak = CLOAKLEN;
    296   1.1       mrg 	}
    297   1.1       mrg 	newpp->p_ncshot = 0;
    298   1.1       mrg 
    299   1.1       mrg 	do {
    300   1.1       mrg 		x = rand_num(WIDTH - 1) + 1;
    301   1.1       mrg 		y = rand_num(HEIGHT - 1) + 1;
    302   1.1       mrg 	} while (Maze[y][x] != SPACE);
    303   1.1       mrg 	Maze[y][x] = GMINE;
    304  1.14  dholland #ifdef MONITOR
    305   1.1       mrg 	for (pp = Monitor; pp < End_monitor; pp++)
    306   1.1       mrg 		check(pp, y, x);
    307  1.14  dholland #endif
    308   1.1       mrg 
    309   1.1       mrg 	do {
    310   1.1       mrg 		x = rand_num(WIDTH - 1) + 1;
    311   1.1       mrg 		y = rand_num(HEIGHT - 1) + 1;
    312   1.1       mrg 	} while (Maze[y][x] != SPACE);
    313   1.1       mrg 	Maze[y][x] = MINE;
    314  1.14  dholland #ifdef MONITOR
    315   1.1       mrg 	for (pp = Monitor; pp < End_monitor; pp++)
    316   1.1       mrg 		check(pp, y, x);
    317  1.14  dholland #endif
    318   1.1       mrg 
    319  1.11  dholland 	(void) snprintf(Buf, sizeof(Buf), "%5.2f%c%-10.10s %c",
    320  1.11  dholland 		newpp->p_ident->i_score,
    321   1.1       mrg 		stat_char(newpp), newpp->p_ident->i_name,
    322   1.1       mrg 		newpp->p_ident->i_team);
    323   1.1       mrg 	y = STAT_PLAY_ROW + 1 + (newpp - Player);
    324   1.1       mrg 	for (pp = Player; pp < End_player; pp++) {
    325   1.1       mrg 		if (pp != newpp) {
    326  1.10  dholland 			char	smallbuf[16];
    327   1.1       mrg 
    328   1.1       mrg 			pp->p_ammo += NSHOTS;
    329   1.1       mrg 			newpp->p_ammo += NSHOTS;
    330   1.1       mrg 			cgoto(pp, y, STAT_NAME_COL);
    331   1.1       mrg 			outstr(pp, Buf, STAT_NAME_LEN);
    332  1.11  dholland 			(void) snprintf(smallbuf, sizeof(smallbuf),
    333  1.11  dholland 					"%3d", pp->p_ammo);
    334   1.1       mrg 			cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
    335   1.1       mrg 			outstr(pp, smallbuf, 3);
    336   1.1       mrg 		}
    337   1.1       mrg 	}
    338  1.14  dholland #ifdef MONITOR
    339   1.1       mrg 	for (pp = Monitor; pp < End_monitor; pp++) {
    340   1.1       mrg 		cgoto(pp, y, STAT_NAME_COL);
    341   1.1       mrg 		outstr(pp, Buf, STAT_NAME_LEN);
    342   1.1       mrg 	}
    343  1.14  dholland #endif
    344   1.1       mrg 
    345   1.1       mrg 	drawmaze(newpp);
    346  1.17  dholland 	drawplayer(newpp, true);
    347   1.1       mrg 	look(newpp);
    348  1.14  dholland #ifdef FLY
    349   1.1       mrg 	if (enter_status == Q_FLY)
    350   1.1       mrg 		/* Make sure that the position you enter in will be erased */
    351   1.1       mrg 		showexpl(newpp->p_y, newpp->p_x, FLYER);
    352  1.14  dholland #endif
    353   1.1       mrg 	sendcom(newpp, REFRESH);
    354   1.1       mrg 	sendcom(newpp, READY, 0);
    355   1.1       mrg 	(void) fflush(newpp->p_output);
    356   1.1       mrg }
    357   1.1       mrg 
    358   1.1       mrg /*
    359   1.1       mrg  * rand_dir:
    360   1.1       mrg  *	Return a random direction
    361   1.1       mrg  */
    362   1.3     lukem int
    363  1.13  dholland rand_dir(void)
    364   1.1       mrg {
    365   1.1       mrg 	switch (rand_num(4)) {
    366   1.1       mrg 	  case 0:
    367   1.1       mrg 		return LEFTS;
    368   1.1       mrg 	  case 1:
    369   1.1       mrg 		return RIGHT;
    370   1.1       mrg 	  case 2:
    371   1.1       mrg 		return BELOW;
    372   1.1       mrg 	  case 3:
    373   1.1       mrg 		return ABOVE;
    374   1.1       mrg 	}
    375   1.1       mrg 	/* NOTREACHED */
    376   1.3     lukem 	return(-1);
    377   1.1       mrg }
    378   1.1       mrg 
    379   1.1       mrg /*
    380   1.1       mrg  * get_ident:
    381   1.1       mrg  *	Get the score structure of a player
    382   1.1       mrg  */
    383  1.15  dholland static IDENT *
    384  1.13  dholland get_ident(uint32_t machine, uint32_t uid, char *name, char team)
    385   1.1       mrg {
    386  1.14  dholland 	IDENT *ip;
    387  1.14  dholland 	static IDENT punt;
    388   1.1       mrg 
    389   1.1       mrg 	for (ip = Scores; ip != NULL; ip = ip->i_next)
    390   1.1       mrg 		if (ip->i_machine == machine
    391   1.1       mrg 		&&  ip->i_uid == uid
    392   1.1       mrg 		&&  ip->i_team == team
    393   1.1       mrg 		&&  strncmp(ip->i_name, name, NAMELEN) == 0)
    394   1.1       mrg 			break;
    395   1.1       mrg 
    396   1.1       mrg 	if (ip != NULL) {
    397   1.1       mrg 		if (ip->i_entries < SCOREDECAY)
    398   1.1       mrg 			ip->i_entries++;
    399   1.1       mrg 		else
    400   1.1       mrg 			ip->i_kills = (ip->i_kills * (SCOREDECAY - 1))
    401   1.1       mrg 				/ SCOREDECAY;
    402   1.1       mrg 		ip->i_score = ip->i_kills / (double) ip->i_entries;
    403   1.1       mrg 	}
    404   1.1       mrg 	else {
    405  1.12  dholland 		ip = malloc(sizeof(*ip));
    406   1.1       mrg 		if (ip == NULL) {
    407   1.1       mrg 			/* Fourth down, time to punt */
    408   1.1       mrg 			ip = &punt;
    409   1.1       mrg 		}
    410   1.1       mrg 		ip->i_machine = machine;
    411   1.1       mrg 		ip->i_team = team;
    412   1.1       mrg 		ip->i_uid = uid;
    413   1.1       mrg 		strncpy(ip->i_name, name, NAMELEN);
    414   1.1       mrg 		ip->i_kills = 0;
    415   1.1       mrg 		ip->i_entries = 1;
    416   1.1       mrg 		ip->i_score = 0;
    417   1.1       mrg 		ip->i_absorbed = 0;
    418   1.1       mrg 		ip->i_faced = 0;
    419   1.1       mrg 		ip->i_shot = 0;
    420   1.1       mrg 		ip->i_robbed = 0;
    421   1.1       mrg 		ip->i_slime = 0;
    422   1.1       mrg 		ip->i_missed = 0;
    423   1.1       mrg 		ip->i_ducked = 0;
    424   1.1       mrg 		ip->i_gkills = ip->i_bkills = ip->i_deaths = 0;
    425   1.1       mrg 		ip->i_stillb = ip->i_saved = 0;
    426   1.1       mrg 		ip->i_next = Scores;
    427   1.1       mrg 		Scores = ip;
    428   1.1       mrg 	}
    429   1.1       mrg 
    430   1.1       mrg 	return ip;
    431   1.1       mrg }
    432