driver.c revision 1.17 1 1.17 dholland /* $NetBSD: driver.c,v 1.17 2009/07/04 04:29:54 dholland Exp $ */
2 1.1 mrg /*
3 1.9 wiz * Copyright (c) 1983-2003, Regents of the University of California.
4 1.9 wiz * All rights reserved.
5 1.9 wiz *
6 1.9 wiz * Redistribution and use in source and binary forms, with or without
7 1.9 wiz * modification, are permitted provided that the following conditions are
8 1.9 wiz * met:
9 1.9 wiz *
10 1.9 wiz * + Redistributions of source code must retain the above copyright
11 1.9 wiz * notice, this list of conditions and the following disclaimer.
12 1.9 wiz * + Redistributions in binary form must reproduce the above copyright
13 1.9 wiz * notice, this list of conditions and the following disclaimer in the
14 1.9 wiz * documentation and/or other materials provided with the distribution.
15 1.9 wiz * + Neither the name of the University of California, San Francisco nor
16 1.9 wiz * the names of its contributors may be used to endorse or promote
17 1.9 wiz * products derived from this software without specific prior written
18 1.9 wiz * permission.
19 1.9 wiz *
20 1.9 wiz * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21 1.9 wiz * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 1.9 wiz * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 1.9 wiz * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 1.9 wiz * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 1.9 wiz * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 1.9 wiz * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.9 wiz * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.9 wiz * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.9 wiz * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 1.9 wiz * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1 mrg */
32 1.1 mrg
33 1.2 lukem #include <sys/cdefs.h>
34 1.2 lukem #ifndef lint
35 1.17 dholland __RCSID("$NetBSD: driver.c,v 1.17 2009/07/04 04:29:54 dholland Exp $");
36 1.2 lukem #endif /* not lint */
37 1.2 lukem
38 1.17 dholland #include <sys/ioctl.h>
39 1.17 dholland #include <sys/stat.h>
40 1.17 dholland #include <sys/time.h>
41 1.17 dholland #include <err.h>
42 1.17 dholland #include <errno.h>
43 1.17 dholland #include <signal.h>
44 1.17 dholland #include <stdlib.h>
45 1.17 dholland #include <unistd.h>
46 1.17 dholland #include"hunt.h"
47 1.17 dholland
48 1.17 dholland #ifndef pdp11
49 1.17 dholland #define RN (((Seed = Seed * 11109 + 13849) >> 16) & 0xffff)
50 1.17 dholland #else
51 1.17 dholland #define RN ((Seed = Seed * 11109 + 13849) & 0x7fff)
52 1.17 dholland #endif
53 1.17 dholland
54 1.17 dholland int Seed = 0;
55 1.17 dholland
56 1.17 dholland
57 1.17 dholland SOCKET Daemon;
58 1.17 dholland char *First_arg; /* pointer to argv[0] */
59 1.17 dholland char *Last_arg; /* pointer to end of argv/environ */
60 1.17 dholland
61 1.17 dholland #ifdef INTERNET
62 1.17 dholland int Test_socket; /* test socket to answer datagrams */
63 1.17 dholland FLAG inetd_spawned; /* invoked via inetd */
64 1.17 dholland FLAG standard_port = TRUE; /* true if listening on standard port */
65 1.1 mrg u_short sock_port; /* port # of tcp listen socket */
66 1.1 mrg u_short stat_port; /* port # of statistics tcp socket */
67 1.17 dholland #define DAEMON_SIZE (sizeof Daemon)
68 1.17 dholland #else
69 1.17 dholland #define DAEMON_SIZE (sizeof Daemon - 1)
70 1.17 dholland #endif
71 1.17 dholland
72 1.17 dholland static void clear_scores(void);
73 1.17 dholland static int havechar(PLAYER *, int);
74 1.17 dholland static void init(void);
75 1.17 dholland int main(int, char *[], char *[]);
76 1.17 dholland static void makeboots(void);
77 1.17 dholland static void send_stats(void);
78 1.17 dholland static void zap(PLAYER *, FLAG, int);
79 1.2 lukem
80 1.1 mrg
81 1.1 mrg /*
82 1.1 mrg * main:
83 1.1 mrg * The main program.
84 1.1 mrg */
85 1.2 lukem int
86 1.16 dholland main(int ac, char **av, char **ep)
87 1.1 mrg {
88 1.17 dholland PLAYER *pp;
89 1.17 dholland #ifdef INTERNET
90 1.17 dholland u_short msg;
91 1.17 dholland short port_num, reply;
92 1.17 dholland socklen_t namelen;
93 1.17 dholland SOCKET test;
94 1.17 dholland #endif
95 1.17 dholland static FLAG first = TRUE;
96 1.17 dholland static FLAG server = FALSE;
97 1.17 dholland int c, i;
98 1.17 dholland const int linger = 90 * 1000;
99 1.1 mrg
100 1.1 mrg First_arg = av[0];
101 1.1 mrg if (ep == NULL || *ep == NULL)
102 1.1 mrg ep = av + ac;
103 1.1 mrg while (*ep)
104 1.1 mrg ep++;
105 1.1 mrg Last_arg = ep[-1] + strlen(ep[-1]);
106 1.1 mrg
107 1.2 lukem while ((c = getopt(ac, av, "sp:")) != -1) {
108 1.1 mrg switch (c) {
109 1.1 mrg case 's':
110 1.1 mrg server = TRUE;
111 1.1 mrg break;
112 1.17 dholland #ifdef INTERNET
113 1.1 mrg case 'p':
114 1.1 mrg standard_port = FALSE;
115 1.1 mrg Test_port = atoi(optarg);
116 1.1 mrg break;
117 1.17 dholland #endif
118 1.1 mrg default:
119 1.1 mrg erred:
120 1.1 mrg fprintf(stderr, "Usage: %s [-s] [-p port]\n", av[0]);
121 1.1 mrg exit(1);
122 1.1 mrg }
123 1.1 mrg }
124 1.1 mrg if (optind < ac)
125 1.1 mrg goto erred;
126 1.1 mrg
127 1.1 mrg init();
128 1.1 mrg
129 1.1 mrg
130 1.1 mrg again:
131 1.1 mrg do {
132 1.1 mrg errno = 0;
133 1.8 mycroft while (poll(fdset, 3+MAXPL+MAXMON, INFTIM) < 0)
134 1.1 mrg {
135 1.1 mrg if (errno != EINTR)
136 1.17 dholland #ifdef LOG
137 1.12 elad syslog(LOG_WARNING, "poll: %m");
138 1.17 dholland #else
139 1.12 elad warn("poll");
140 1.17 dholland #endif
141 1.1 mrg errno = 0;
142 1.1 mrg }
143 1.17 dholland #ifdef INTERNET
144 1.8 mycroft if (fdset[2].revents & POLLIN) {
145 1.1 mrg namelen = DAEMON_SIZE;
146 1.1 mrg port_num = htons(sock_port);
147 1.15 dholland (void) recvfrom(Test_socket, &msg, sizeof msg,
148 1.1 mrg 0, (struct sockaddr *) &test, &namelen);
149 1.1 mrg switch (ntohs(msg)) {
150 1.1 mrg case C_MESSAGE:
151 1.1 mrg if (Nplayer <= 0)
152 1.1 mrg break;
153 1.1 mrg reply = htons((u_short) Nplayer);
154 1.15 dholland (void) sendto(Test_socket, &reply,
155 1.1 mrg sizeof reply, 0,
156 1.1 mrg (struct sockaddr *) &test, DAEMON_SIZE);
157 1.1 mrg break;
158 1.1 mrg case C_SCORES:
159 1.1 mrg reply = htons(stat_port);
160 1.15 dholland (void) sendto(Test_socket, &reply,
161 1.1 mrg sizeof reply, 0,
162 1.1 mrg (struct sockaddr *) &test, DAEMON_SIZE);
163 1.1 mrg break;
164 1.1 mrg case C_PLAYER:
165 1.1 mrg case C_MONITOR:
166 1.1 mrg if (msg == C_MONITOR && Nplayer <= 0)
167 1.1 mrg break;
168 1.1 mrg reply = htons(sock_port);
169 1.15 dholland (void) sendto(Test_socket, &reply,
170 1.1 mrg sizeof reply, 0,
171 1.1 mrg (struct sockaddr *) &test, DAEMON_SIZE);
172 1.1 mrg break;
173 1.1 mrg }
174 1.1 mrg }
175 1.17 dholland #endif
176 1.8 mycroft {
177 1.8 mycroft for (pp = Player, i = 0; pp < End_player; pp++, i++)
178 1.8 mycroft if (havechar(pp, i + 3)) {
179 1.1 mrg execute(pp);
180 1.1 mrg pp->p_nexec++;
181 1.1 mrg }
182 1.17 dholland #ifdef MONITOR
183 1.8 mycroft for (pp = Monitor, i = 0; pp < End_monitor; pp++, i++)
184 1.8 mycroft if (havechar(pp, i + MAXPL + 3)) {
185 1.1 mrg mon_execute(pp);
186 1.1 mrg pp->p_nexec++;
187 1.1 mrg }
188 1.17 dholland #endif
189 1.1 mrg moveshots();
190 1.8 mycroft for (pp = Player, i = 0; pp < End_player; )
191 1.1 mrg if (pp->p_death[0] != '\0')
192 1.8 mycroft zap(pp, TRUE, i + 3);
193 1.1 mrg else
194 1.8 mycroft pp++, i++;
195 1.17 dholland #ifdef MONITOR
196 1.8 mycroft for (pp = Monitor, i = 0; pp < End_monitor; )
197 1.1 mrg if (pp->p_death[0] != '\0')
198 1.8 mycroft zap(pp, FALSE, i + MAXPL + 3);
199 1.1 mrg else
200 1.8 mycroft pp++, i++;
201 1.17 dholland #endif
202 1.1 mrg }
203 1.8 mycroft if (fdset[0].revents & POLLIN)
204 1.1 mrg if (answer()) {
205 1.17 dholland #ifdef INTERNET
206 1.1 mrg if (first && standard_port)
207 1.1 mrg faketalk();
208 1.17 dholland #endif
209 1.1 mrg first = FALSE;
210 1.1 mrg }
211 1.8 mycroft if (fdset[1].revents & POLLIN)
212 1.1 mrg send_stats();
213 1.8 mycroft for (pp = Player, i = 0; pp < End_player; pp++, i++) {
214 1.8 mycroft if (fdset[i + 3].revents & POLLIN)
215 1.1 mrg sendcom(pp, READY, pp->p_nexec);
216 1.1 mrg pp->p_nexec = 0;
217 1.1 mrg (void) fflush(pp->p_output);
218 1.1 mrg }
219 1.17 dholland #ifdef MONITOR
220 1.8 mycroft for (pp = Monitor, i = 0; pp < End_monitor; pp++, i++) {
221 1.8 mycroft if (fdset[i + MAXPL + 3].revents & POLLIN)
222 1.1 mrg sendcom(pp, READY, pp->p_nexec);
223 1.1 mrg pp->p_nexec = 0;
224 1.1 mrg (void) fflush(pp->p_output);
225 1.1 mrg }
226 1.17 dholland #endif
227 1.1 mrg } while (Nplayer > 0);
228 1.1 mrg
229 1.8 mycroft if (poll(fdset, 3+MAXPL+MAXMON, linger) > 0) {
230 1.1 mrg goto again;
231 1.1 mrg }
232 1.1 mrg if (server) {
233 1.1 mrg clear_scores();
234 1.1 mrg makemaze();
235 1.1 mrg clearwalls();
236 1.17 dholland #ifdef BOOTS
237 1.1 mrg makeboots();
238 1.17 dholland #endif
239 1.1 mrg first = TRUE;
240 1.1 mrg goto again;
241 1.1 mrg }
242 1.1 mrg
243 1.17 dholland #ifdef MONITOR
244 1.8 mycroft for (pp = Monitor, i = 0; pp < End_monitor; i++)
245 1.8 mycroft zap(pp, FALSE, i + MAXPL + 3);
246 1.17 dholland #endif
247 1.1 mrg cleanup(0);
248 1.2 lukem /* NOTREACHED */
249 1.2 lukem return(0);
250 1.1 mrg }
251 1.1 mrg
252 1.1 mrg /*
253 1.1 mrg * init:
254 1.1 mrg * Initialize the global parameters.
255 1.1 mrg */
256 1.2 lukem static void
257 1.16 dholland init(void)
258 1.1 mrg {
259 1.17 dholland int i;
260 1.17 dholland #ifdef INTERNET
261 1.17 dholland SOCKET test_port;
262 1.17 dholland int msg;
263 1.17 dholland socklen_t len;
264 1.17 dholland #endif
265 1.1 mrg
266 1.17 dholland #ifndef DEBUG
267 1.17 dholland #ifdef TIOCNOTTY
268 1.1 mrg (void) ioctl(fileno(stdout), TIOCNOTTY, NULL);
269 1.17 dholland #endif
270 1.1 mrg (void) setpgrp(getpid(), getpid());
271 1.1 mrg (void) signal(SIGHUP, SIG_IGN);
272 1.1 mrg (void) signal(SIGINT, SIG_IGN);
273 1.1 mrg (void) signal(SIGQUIT, SIG_IGN);
274 1.1 mrg (void) signal(SIGTERM, cleanup);
275 1.17 dholland #endif
276 1.1 mrg
277 1.4 mrg (void) chdir("/var/tmp"); /* just in case it core dumps */
278 1.1 mrg (void) umask(0); /* No privacy at all! */
279 1.1 mrg (void) signal(SIGPIPE, SIG_IGN);
280 1.1 mrg
281 1.17 dholland #ifdef LOG
282 1.17 dholland #ifdef SYSLOG_43
283 1.7 lukem openlog("huntd", LOG_PID, LOG_DAEMON);
284 1.17 dholland #endif
285 1.17 dholland #ifdef SYSLOG_42
286 1.7 lukem openlog("huntd", LOG_PID);
287 1.17 dholland #endif
288 1.17 dholland #endif
289 1.1 mrg
290 1.1 mrg /*
291 1.1 mrg * Initialize statistics socket
292 1.1 mrg */
293 1.17 dholland #ifdef INTERNET
294 1.1 mrg Daemon.sin_family = SOCK_FAMILY;
295 1.1 mrg Daemon.sin_addr.s_addr = INADDR_ANY;
296 1.1 mrg Daemon.sin_port = 0;
297 1.17 dholland #else
298 1.1 mrg Daemon.sun_family = SOCK_FAMILY;
299 1.1 mrg (void) strcpy(Daemon.sun_path, Stat_name);
300 1.17 dholland #endif
301 1.1 mrg
302 1.1 mrg Status = socket(SOCK_FAMILY, SOCK_STREAM, 0);
303 1.1 mrg if (bind(Status, (struct sockaddr *) &Daemon, DAEMON_SIZE) < 0) {
304 1.1 mrg if (errno == EADDRINUSE)
305 1.1 mrg exit(0);
306 1.1 mrg else {
307 1.17 dholland #ifdef LOG
308 1.1 mrg syslog(LOG_ERR, "bind: %m");
309 1.17 dholland #else
310 1.3 lukem warn("bind");
311 1.17 dholland #endif
312 1.1 mrg cleanup(1);
313 1.1 mrg }
314 1.1 mrg }
315 1.1 mrg (void) listen(Status, 5);
316 1.1 mrg
317 1.17 dholland #ifdef INTERNET
318 1.1 mrg len = sizeof (SOCKET);
319 1.1 mrg if (getsockname(Status, (struct sockaddr *) &Daemon, &len) < 0) {
320 1.17 dholland #ifdef LOG
321 1.1 mrg syslog(LOG_ERR, "getsockname: %m");
322 1.17 dholland #else
323 1.3 lukem warn("getsockname");
324 1.17 dholland #endif
325 1.1 mrg exit(1);
326 1.1 mrg }
327 1.1 mrg stat_port = ntohs(Daemon.sin_port);
328 1.17 dholland #endif
329 1.1 mrg
330 1.1 mrg /*
331 1.1 mrg * Initialize main socket
332 1.1 mrg */
333 1.17 dholland #ifdef INTERNET
334 1.1 mrg Daemon.sin_family = SOCK_FAMILY;
335 1.1 mrg Daemon.sin_addr.s_addr = INADDR_ANY;
336 1.1 mrg Daemon.sin_port = 0;
337 1.17 dholland #else
338 1.1 mrg Daemon.sun_family = SOCK_FAMILY;
339 1.1 mrg (void) strcpy(Daemon.sun_path, Sock_name);
340 1.17 dholland #endif
341 1.1 mrg
342 1.1 mrg Socket = socket(SOCK_FAMILY, SOCK_STREAM, 0);
343 1.17 dholland #if defined(INTERNET)
344 1.1 mrg msg = 1;
345 1.1 mrg if (setsockopt(Socket, SOL_SOCKET, SO_USELOOPBACK, &msg, sizeof msg)<0)
346 1.17 dholland #ifdef LOG
347 1.1 mrg syslog(LOG_WARNING, "setsockopt loopback %m");
348 1.17 dholland #else
349 1.3 lukem warn("setsockopt loopback");
350 1.17 dholland #endif
351 1.17 dholland #endif
352 1.1 mrg if (bind(Socket, (struct sockaddr *) &Daemon, DAEMON_SIZE) < 0) {
353 1.1 mrg if (errno == EADDRINUSE)
354 1.1 mrg exit(0);
355 1.1 mrg else {
356 1.17 dholland #ifdef LOG
357 1.1 mrg syslog(LOG_ERR, "bind: %m");
358 1.17 dholland #else
359 1.3 lukem warn("bind");
360 1.17 dholland #endif
361 1.1 mrg cleanup(1);
362 1.1 mrg }
363 1.1 mrg }
364 1.1 mrg (void) listen(Socket, 5);
365 1.1 mrg
366 1.17 dholland #ifdef INTERNET
367 1.1 mrg len = sizeof (SOCKET);
368 1.1 mrg if (getsockname(Socket, (struct sockaddr *) &Daemon, &len) < 0) {
369 1.17 dholland #ifdef LOG
370 1.1 mrg syslog(LOG_ERR, "getsockname: %m");
371 1.17 dholland #else
372 1.3 lukem warn("getsockname");
373 1.17 dholland #endif
374 1.1 mrg exit(1);
375 1.1 mrg }
376 1.1 mrg sock_port = ntohs(Daemon.sin_port);
377 1.17 dholland #endif
378 1.1 mrg
379 1.1 mrg /*
380 1.12 elad * Initialize minimal poll mask
381 1.1 mrg */
382 1.8 mycroft fdset[0].fd = Socket;
383 1.8 mycroft fdset[0].events = POLLIN;
384 1.8 mycroft fdset[1].fd = Status;
385 1.8 mycroft fdset[1].events = POLLIN;
386 1.1 mrg
387 1.17 dholland #ifdef INTERNET
388 1.1 mrg len = sizeof (SOCKET);
389 1.1 mrg if (getsockname(0, (struct sockaddr *) &test_port, &len) >= 0
390 1.1 mrg && test_port.sin_family == AF_INET) {
391 1.1 mrg inetd_spawned = TRUE;
392 1.1 mrg Test_socket = 0;
393 1.1 mrg if (test_port.sin_port != htons((u_short) Test_port)) {
394 1.1 mrg standard_port = FALSE;
395 1.1 mrg Test_port = ntohs(test_port.sin_port);
396 1.1 mrg }
397 1.1 mrg } else {
398 1.1 mrg test_port = Daemon;
399 1.1 mrg test_port.sin_port = htons((u_short) Test_port);
400 1.1 mrg
401 1.1 mrg Test_socket = socket(SOCK_FAMILY, SOCK_DGRAM, 0);
402 1.1 mrg if (bind(Test_socket, (struct sockaddr *) &test_port,
403 1.1 mrg DAEMON_SIZE) < 0) {
404 1.17 dholland #ifdef LOG
405 1.1 mrg syslog(LOG_ERR, "bind: %m");
406 1.17 dholland #else
407 1.3 lukem warn("bind");
408 1.17 dholland #endif
409 1.1 mrg exit(1);
410 1.1 mrg }
411 1.1 mrg (void) listen(Test_socket, 5);
412 1.1 mrg }
413 1.1 mrg
414 1.8 mycroft fdset[2].fd = Test_socket;
415 1.8 mycroft fdset[2].events = POLLIN;
416 1.17 dholland #else
417 1.8 mycroft fdset[2].fd = -1;
418 1.17 dholland #endif
419 1.1 mrg
420 1.1 mrg Seed = getpid() + time((time_t *) NULL);
421 1.1 mrg makemaze();
422 1.17 dholland #ifdef BOOTS
423 1.1 mrg makeboots();
424 1.17 dholland #endif
425 1.1 mrg
426 1.1 mrg for (i = 0; i < NASCII; i++)
427 1.1 mrg See_over[i] = TRUE;
428 1.1 mrg See_over[DOOR] = FALSE;
429 1.1 mrg See_over[WALL1] = FALSE;
430 1.1 mrg See_over[WALL2] = FALSE;
431 1.1 mrg See_over[WALL3] = FALSE;
432 1.17 dholland #ifdef REFLECT
433 1.1 mrg See_over[WALL4] = FALSE;
434 1.1 mrg See_over[WALL5] = FALSE;
435 1.17 dholland #endif
436 1.1 mrg
437 1.1 mrg }
438 1.1 mrg
439 1.17 dholland #ifdef BOOTS
440 1.1 mrg /*
441 1.1 mrg * makeboots:
442 1.1 mrg * Put the boots in the maze
443 1.1 mrg */
444 1.2 lukem static void
445 1.16 dholland makeboots(void)
446 1.1 mrg {
447 1.17 dholland int x, y;
448 1.17 dholland PLAYER *pp;
449 1.1 mrg
450 1.1 mrg do {
451 1.1 mrg x = rand_num(WIDTH - 1) + 1;
452 1.1 mrg y = rand_num(HEIGHT - 1) + 1;
453 1.1 mrg } while (Maze[y][x] != SPACE);
454 1.1 mrg Maze[y][x] = BOOT_PAIR;
455 1.1 mrg for (pp = Boot; pp < &Boot[NBOOTS]; pp++)
456 1.1 mrg pp->p_flying = -1;
457 1.1 mrg }
458 1.17 dholland #endif
459 1.1 mrg
460 1.1 mrg
461 1.1 mrg /*
462 1.1 mrg * checkdam:
463 1.1 mrg * Check the damage to the given player, and see if s/he is killed
464 1.1 mrg */
465 1.2 lukem void
466 1.16 dholland checkdam(PLAYER *ouch, PLAYER *gotcha, IDENT *credit, int amt,
467 1.16 dholland char this_shot_type)
468 1.1 mrg {
469 1.17 dholland const char *cp;
470 1.1 mrg
471 1.1 mrg if (ouch->p_death[0] != '\0')
472 1.1 mrg return;
473 1.17 dholland #ifdef BOOTS
474 1.13 dholland if (this_shot_type == SLIME)
475 1.1 mrg switch (ouch->p_nboots) {
476 1.1 mrg default:
477 1.1 mrg break;
478 1.1 mrg case 1:
479 1.1 mrg amt = (amt + 1) / 2;
480 1.1 mrg break;
481 1.1 mrg case 2:
482 1.1 mrg if (gotcha != NULL)
483 1.1 mrg message(gotcha, "He has boots on!");
484 1.1 mrg return;
485 1.1 mrg }
486 1.17 dholland #endif
487 1.1 mrg ouch->p_damage += amt;
488 1.1 mrg if (ouch->p_damage <= ouch->p_damcap) {
489 1.14 dholland (void) snprintf(Buf, sizeof(Buf), "%2d", ouch->p_damage);
490 1.1 mrg cgoto(ouch, STAT_DAM_ROW, STAT_VALUE_COL);
491 1.1 mrg outstr(ouch, Buf, 2);
492 1.1 mrg return;
493 1.1 mrg }
494 1.1 mrg
495 1.1 mrg /* Someone DIED */
496 1.13 dholland switch (this_shot_type) {
497 1.1 mrg default:
498 1.1 mrg cp = "Killed";
499 1.1 mrg break;
500 1.17 dholland #ifdef FLY
501 1.1 mrg case FALL:
502 1.1 mrg cp = "Killed on impact";
503 1.1 mrg break;
504 1.17 dholland #endif
505 1.1 mrg case KNIFE:
506 1.1 mrg cp = "Stabbed to death";
507 1.1 mrg ouch->p_ammo = 0; /* No exploding */
508 1.1 mrg break;
509 1.1 mrg case SHOT:
510 1.1 mrg cp = "Shot to death";
511 1.1 mrg break;
512 1.1 mrg case GRENADE:
513 1.1 mrg case SATCHEL:
514 1.1 mrg case BOMB:
515 1.1 mrg cp = "Bombed";
516 1.1 mrg break;
517 1.1 mrg case MINE:
518 1.1 mrg case GMINE:
519 1.1 mrg cp = "Blown apart";
520 1.1 mrg break;
521 1.17 dholland #ifdef OOZE
522 1.1 mrg case SLIME:
523 1.1 mrg cp = "Slimed";
524 1.1 mrg if (credit != NULL)
525 1.1 mrg credit->i_slime++;
526 1.1 mrg break;
527 1.17 dholland #endif
528 1.17 dholland #ifdef VOLCANO
529 1.1 mrg case LAVA:
530 1.1 mrg cp = "Baked";
531 1.1 mrg break;
532 1.17 dholland #endif
533 1.17 dholland #ifdef DRONE
534 1.1 mrg case DSHOT:
535 1.1 mrg cp = "Eliminated";
536 1.1 mrg break;
537 1.17 dholland #endif
538 1.1 mrg }
539 1.1 mrg if (credit == NULL) {
540 1.14 dholland (void) snprintf(ouch->p_death, sizeof(ouch->p_death),
541 1.14 dholland "| %s by %s |", cp,
542 1.13 dholland (this_shot_type == MINE || this_shot_type == GMINE) ?
543 1.1 mrg "a mine" : "act of God");
544 1.1 mrg return;
545 1.1 mrg }
546 1.1 mrg
547 1.14 dholland (void) snprintf(ouch->p_death, sizeof(ouch->p_death),
548 1.14 dholland "| %s by %s |", cp, credit->i_name);
549 1.1 mrg
550 1.1 mrg if (ouch == gotcha) { /* No use killing yourself */
551 1.1 mrg credit->i_kills--;
552 1.1 mrg credit->i_bkills++;
553 1.1 mrg }
554 1.1 mrg else if (ouch->p_ident->i_team == ' '
555 1.1 mrg || ouch->p_ident->i_team != credit->i_team) {
556 1.1 mrg credit->i_kills++;
557 1.1 mrg credit->i_gkills++;
558 1.1 mrg }
559 1.1 mrg else {
560 1.1 mrg credit->i_kills--;
561 1.1 mrg credit->i_bkills++;
562 1.1 mrg }
563 1.1 mrg credit->i_score = credit->i_kills / (double) credit->i_entries;
564 1.1 mrg ouch->p_ident->i_deaths++;
565 1.1 mrg if (ouch->p_nchar == 0)
566 1.1 mrg ouch->p_ident->i_stillb++;
567 1.1 mrg if (gotcha == NULL)
568 1.1 mrg return;
569 1.1 mrg gotcha->p_damcap += STABDAM;
570 1.1 mrg gotcha->p_damage -= STABDAM;
571 1.1 mrg if (gotcha->p_damage < 0)
572 1.1 mrg gotcha->p_damage = 0;
573 1.14 dholland (void) snprintf(Buf, sizeof(Buf), "%2d/%2d", gotcha->p_damage,
574 1.14 dholland gotcha->p_damcap);
575 1.1 mrg cgoto(gotcha, STAT_DAM_ROW, STAT_VALUE_COL);
576 1.1 mrg outstr(gotcha, Buf, 5);
577 1.14 dholland (void) snprintf(Buf, sizeof(Buf), "%3d",
578 1.14 dholland (gotcha->p_damcap - MAXDAM) / 2);
579 1.1 mrg cgoto(gotcha, STAT_KILL_ROW, STAT_VALUE_COL);
580 1.1 mrg outstr(gotcha, Buf, 3);
581 1.14 dholland (void) snprintf(Buf, sizeof(Buf), "%5.2f", gotcha->p_ident->i_score);
582 1.1 mrg for (ouch = Player; ouch < End_player; ouch++) {
583 1.1 mrg cgoto(ouch, STAT_PLAY_ROW + 1 + (gotcha - Player),
584 1.1 mrg STAT_NAME_COL);
585 1.1 mrg outstr(ouch, Buf, 5);
586 1.1 mrg }
587 1.17 dholland #ifdef MONITOR
588 1.1 mrg for (ouch = Monitor; ouch < End_monitor; ouch++) {
589 1.1 mrg cgoto(ouch, STAT_PLAY_ROW + 1 + (gotcha - Player),
590 1.1 mrg STAT_NAME_COL);
591 1.1 mrg outstr(ouch, Buf, 5);
592 1.1 mrg }
593 1.17 dholland #endif
594 1.1 mrg }
595 1.1 mrg
596 1.1 mrg /*
597 1.1 mrg * zap:
598 1.1 mrg * Kill off a player and take him out of the game.
599 1.1 mrg */
600 1.2 lukem static void
601 1.16 dholland zap(PLAYER *pp, FLAG was_player, int i)
602 1.1 mrg {
603 1.17 dholland int n, len;
604 1.17 dholland BULLET *bp;
605 1.17 dholland PLAYER *np;
606 1.17 dholland int x, y;
607 1.17 dholland int savefd;
608 1.1 mrg
609 1.1 mrg if (was_player) {
610 1.1 mrg if (pp->p_undershot)
611 1.1 mrg fixshots(pp->p_y, pp->p_x, pp->p_over);
612 1.1 mrg drawplayer(pp, FALSE);
613 1.1 mrg Nplayer--;
614 1.1 mrg }
615 1.1 mrg
616 1.1 mrg len = strlen(pp->p_death); /* Display the cause of death */
617 1.1 mrg x = (WIDTH - len) / 2;
618 1.1 mrg cgoto(pp, HEIGHT / 2, x);
619 1.1 mrg outstr(pp, pp->p_death, len);
620 1.8 mycroft for (n = 1; n < len; n++)
621 1.8 mycroft pp->p_death[n] = '-';
622 1.1 mrg pp->p_death[0] = '+';
623 1.1 mrg pp->p_death[len - 1] = '+';
624 1.1 mrg cgoto(pp, HEIGHT / 2 - 1, x);
625 1.1 mrg outstr(pp, pp->p_death, len);
626 1.1 mrg cgoto(pp, HEIGHT / 2 + 1, x);
627 1.1 mrg outstr(pp, pp->p_death, len);
628 1.1 mrg cgoto(pp, HEIGHT, 0);
629 1.1 mrg
630 1.1 mrg savefd = pp->p_fd;
631 1.1 mrg
632 1.17 dholland #ifdef MONITOR
633 1.1 mrg if (was_player) {
634 1.17 dholland #endif
635 1.1 mrg for (bp = Bullets; bp != NULL; bp = bp->b_next) {
636 1.1 mrg if (bp->b_owner == pp)
637 1.1 mrg bp->b_owner = NULL;
638 1.1 mrg if (bp->b_x == pp->p_x && bp->b_y == pp->p_y)
639 1.1 mrg bp->b_over = SPACE;
640 1.1 mrg }
641 1.1 mrg
642 1.8 mycroft n = rand_num(pp->p_ammo);
643 1.1 mrg x = rand_num(pp->p_ammo);
644 1.8 mycroft if (x > n)
645 1.8 mycroft n = x;
646 1.1 mrg if (pp->p_ammo == 0)
647 1.1 mrg x = 0;
648 1.8 mycroft else if (n == pp->p_ammo - 1) {
649 1.1 mrg x = pp->p_ammo;
650 1.1 mrg len = SLIME;
651 1.1 mrg }
652 1.1 mrg else {
653 1.1 mrg for (x = MAXBOMB - 1; x > 0; x--)
654 1.8 mycroft if (n >= shot_req[x])
655 1.1 mrg break;
656 1.1 mrg for (y = MAXSLIME - 1; y > 0; y--)
657 1.8 mycroft if (n >= slime_req[y])
658 1.1 mrg break;
659 1.1 mrg if (y >= 0 && slime_req[y] > shot_req[x]) {
660 1.1 mrg x = slime_req[y];
661 1.1 mrg len = SLIME;
662 1.1 mrg }
663 1.1 mrg else if (x != 0) {
664 1.1 mrg len = shot_type[x];
665 1.1 mrg x = shot_req[x];
666 1.1 mrg }
667 1.1 mrg }
668 1.1 mrg if (x > 0) {
669 1.1 mrg (void) add_shot(len, pp->p_y, pp->p_x, pp->p_face, x,
670 1.1 mrg (PLAYER *) NULL, TRUE, SPACE);
671 1.14 dholland (void) snprintf(Buf, sizeof(Buf), "%s detonated.",
672 1.1 mrg pp->p_ident->i_name);
673 1.1 mrg for (np = Player; np < End_player; np++)
674 1.1 mrg message(np, Buf);
675 1.17 dholland #ifdef MONITOR
676 1.1 mrg for (np = Monitor; np < End_monitor; np++)
677 1.1 mrg message(np, Buf);
678 1.17 dholland #endif
679 1.17 dholland #ifdef BOOTS
680 1.1 mrg while (pp->p_nboots-- > 0) {
681 1.1 mrg for (np = Boot; np < &Boot[NBOOTS]; np++)
682 1.1 mrg if (np->p_flying < 0)
683 1.1 mrg break;
684 1.1 mrg if (np >= &Boot[NBOOTS])
685 1.2 lukem err(1, "Too many boots");
686 1.1 mrg np->p_undershot = FALSE;
687 1.1 mrg np->p_x = pp->p_x;
688 1.1 mrg np->p_y = pp->p_y;
689 1.1 mrg np->p_flying = rand_num(20);
690 1.1 mrg np->p_flyx = 2 * rand_num(6) - 5;
691 1.1 mrg np->p_flyy = 2 * rand_num(6) - 5;
692 1.1 mrg np->p_over = SPACE;
693 1.1 mrg np->p_face = BOOT;
694 1.1 mrg showexpl(np->p_y, np->p_x, BOOT);
695 1.1 mrg }
696 1.17 dholland #endif
697 1.1 mrg }
698 1.17 dholland #ifdef BOOTS
699 1.1 mrg else if (pp->p_nboots > 0) {
700 1.1 mrg if (pp->p_nboots == 2)
701 1.1 mrg Maze[pp->p_y][pp->p_x] = BOOT_PAIR;
702 1.1 mrg else
703 1.1 mrg Maze[pp->p_y][pp->p_x] = BOOT;
704 1.1 mrg if (pp->p_undershot)
705 1.1 mrg fixshots(pp->p_y, pp->p_x,
706 1.1 mrg Maze[pp->p_y][pp->p_x]);
707 1.1 mrg }
708 1.17 dholland #endif
709 1.1 mrg
710 1.17 dholland #ifdef VOLCANO
711 1.1 mrg volcano += pp->p_ammo - x;
712 1.1 mrg if (rand_num(100) < volcano / 50) {
713 1.1 mrg do {
714 1.1 mrg x = rand_num(WIDTH / 2) + WIDTH / 4;
715 1.1 mrg y = rand_num(HEIGHT / 2) + HEIGHT / 4;
716 1.1 mrg } while (Maze[y][x] != SPACE);
717 1.1 mrg (void) add_shot(LAVA, y, x, LEFTS, volcano,
718 1.1 mrg (PLAYER *) NULL, TRUE, SPACE);
719 1.1 mrg for (np = Player; np < End_player; np++)
720 1.1 mrg message(np, "Volcano eruption.");
721 1.1 mrg volcano = 0;
722 1.1 mrg }
723 1.17 dholland #endif
724 1.1 mrg
725 1.17 dholland #ifdef DRONE
726 1.1 mrg if (rand_num(100) < 2) {
727 1.1 mrg do {
728 1.1 mrg x = rand_num(WIDTH / 2) + WIDTH / 4;
729 1.1 mrg y = rand_num(HEIGHT / 2) + HEIGHT / 4;
730 1.1 mrg } while (Maze[y][x] != SPACE);
731 1.1 mrg add_shot(DSHOT, y, x, rand_dir(),
732 1.1 mrg shot_req[MINDSHOT +
733 1.1 mrg rand_num(MAXBOMB - MINDSHOT)],
734 1.1 mrg (PLAYER *) NULL, FALSE, SPACE);
735 1.1 mrg }
736 1.17 dholland #endif
737 1.1 mrg
738 1.1 mrg sendcom(pp, ENDWIN);
739 1.1 mrg (void) putc(' ', pp->p_output);
740 1.1 mrg (void) fclose(pp->p_output);
741 1.1 mrg
742 1.1 mrg End_player--;
743 1.1 mrg if (pp != End_player) {
744 1.1 mrg memcpy(pp, End_player, sizeof (PLAYER));
745 1.8 mycroft fdset[i] = fdset[End_player - Player + 3];
746 1.8 mycroft fdset[End_player - Player + 3].fd = -1;
747 1.14 dholland (void) snprintf(Buf, sizeof(Buf), "%5.2f%c%-10.10s %c",
748 1.1 mrg pp->p_ident->i_score, stat_char(pp),
749 1.1 mrg pp->p_ident->i_name, pp->p_ident->i_team);
750 1.8 mycroft n = STAT_PLAY_ROW + 1 + (pp - Player);
751 1.1 mrg for (np = Player; np < End_player; np++) {
752 1.8 mycroft cgoto(np, n, STAT_NAME_COL);
753 1.1 mrg outstr(np, Buf, STAT_NAME_LEN);
754 1.1 mrg }
755 1.17 dholland #ifdef MONITOR
756 1.1 mrg for (np = Monitor; np < End_monitor; np++) {
757 1.8 mycroft cgoto(np, n, STAT_NAME_COL);
758 1.1 mrg outstr(np, Buf, STAT_NAME_LEN);
759 1.1 mrg }
760 1.17 dholland #endif
761 1.8 mycroft } else
762 1.8 mycroft fdset[i].fd = -1;
763 1.1 mrg
764 1.1 mrg /* Erase the last player */
765 1.8 mycroft n = STAT_PLAY_ROW + 1 + Nplayer;
766 1.1 mrg for (np = Player; np < End_player; np++) {
767 1.8 mycroft cgoto(np, n, STAT_NAME_COL);
768 1.1 mrg ce(np);
769 1.1 mrg }
770 1.17 dholland #ifdef MONITOR
771 1.1 mrg for (np = Monitor; np < End_monitor; np++) {
772 1.8 mycroft cgoto(np, n, STAT_NAME_COL);
773 1.1 mrg ce(np);
774 1.1 mrg }
775 1.1 mrg }
776 1.1 mrg else {
777 1.1 mrg sendcom(pp, ENDWIN);
778 1.1 mrg (void) putc(LAST_PLAYER, pp->p_output);
779 1.1 mrg (void) fclose(pp->p_output);
780 1.1 mrg
781 1.1 mrg End_monitor--;
782 1.1 mrg if (pp != End_monitor) {
783 1.1 mrg memcpy(pp, End_monitor, sizeof (PLAYER));
784 1.8 mycroft fdset[i] = fdset[End_monitor - Monitor + MAXPL + 3];
785 1.8 mycroft fdset[End_monitor - Monitor + MAXPL + 3].fd = -1;
786 1.14 dholland (void) snprintf(Buf, sizeof(Buf), "%5.5s %-10.10s %c",
787 1.14 dholland " ",
788 1.1 mrg pp->p_ident->i_name, pp->p_ident->i_team);
789 1.8 mycroft n = STAT_MON_ROW + 1 + (pp - Player);
790 1.1 mrg for (np = Player; np < End_player; np++) {
791 1.8 mycroft cgoto(np, n, STAT_NAME_COL);
792 1.1 mrg outstr(np, Buf, STAT_NAME_LEN);
793 1.1 mrg }
794 1.1 mrg for (np = Monitor; np < End_monitor; np++) {
795 1.8 mycroft cgoto(np, n, STAT_NAME_COL);
796 1.1 mrg outstr(np, Buf, STAT_NAME_LEN);
797 1.1 mrg }
798 1.8 mycroft } else
799 1.8 mycroft fdset[i].fd = -1;
800 1.1 mrg
801 1.1 mrg /* Erase the last monitor */
802 1.8 mycroft n = STAT_MON_ROW + 1 + (End_monitor - Monitor);
803 1.1 mrg for (np = Player; np < End_player; np++) {
804 1.8 mycroft cgoto(np, n, STAT_NAME_COL);
805 1.1 mrg ce(np);
806 1.1 mrg }
807 1.1 mrg for (np = Monitor; np < End_monitor; np++) {
808 1.8 mycroft cgoto(np, n, STAT_NAME_COL);
809 1.1 mrg ce(np);
810 1.1 mrg }
811 1.1 mrg }
812 1.17 dholland #endif
813 1.1 mrg }
814 1.1 mrg
815 1.1 mrg /*
816 1.1 mrg * rand_num:
817 1.1 mrg * Return a random number in a given range.
818 1.1 mrg */
819 1.2 lukem int
820 1.16 dholland rand_num(int range)
821 1.1 mrg {
822 1.1 mrg return (range == 0 ? 0 : RN % range);
823 1.1 mrg }
824 1.1 mrg
825 1.1 mrg /*
826 1.1 mrg * havechar:
827 1.1 mrg * Check to see if we have any characters in the input queue; if
828 1.1 mrg * we do, read them, stash them away, and return TRUE; else return
829 1.1 mrg * FALSE.
830 1.1 mrg */
831 1.2 lukem static int
832 1.16 dholland havechar(PLAYER *pp, int i)
833 1.1 mrg {
834 1.1 mrg
835 1.1 mrg if (pp->p_ncount < pp->p_nchar)
836 1.1 mrg return TRUE;
837 1.8 mycroft if (!(fdset[i].revents & POLLIN))
838 1.1 mrg return FALSE;
839 1.1 mrg check_again:
840 1.1 mrg errno = 0;
841 1.1 mrg if ((pp->p_nchar = read(pp->p_fd, pp->p_cbuf, sizeof pp->p_cbuf)) <= 0)
842 1.1 mrg {
843 1.1 mrg if (errno == EINTR)
844 1.1 mrg goto check_again;
845 1.1 mrg pp->p_cbuf[0] = 'q';
846 1.1 mrg }
847 1.1 mrg pp->p_ncount = 0;
848 1.1 mrg return TRUE;
849 1.1 mrg }
850 1.1 mrg
851 1.1 mrg /*
852 1.1 mrg * cleanup:
853 1.1 mrg * Exit with the given value, cleaning up any droppings lying around
854 1.1 mrg */
855 1.1 mrg SIGNAL_TYPE
856 1.16 dholland cleanup(int eval)
857 1.1 mrg {
858 1.17 dholland PLAYER *pp;
859 1.1 mrg
860 1.1 mrg for (pp = Player; pp < End_player; pp++) {
861 1.1 mrg cgoto(pp, HEIGHT, 0);
862 1.1 mrg sendcom(pp, ENDWIN);
863 1.1 mrg (void) putc(LAST_PLAYER, pp->p_output);
864 1.1 mrg (void) fclose(pp->p_output);
865 1.1 mrg }
866 1.17 dholland #ifdef MONITOR
867 1.1 mrg for (pp = Monitor; pp < End_monitor; pp++) {
868 1.1 mrg cgoto(pp, HEIGHT, 0);
869 1.1 mrg sendcom(pp, ENDWIN);
870 1.1 mrg (void) putc(LAST_PLAYER, pp->p_output);
871 1.1 mrg (void) fclose(pp->p_output);
872 1.1 mrg }
873 1.17 dholland #endif
874 1.1 mrg (void) close(Socket);
875 1.17 dholland #ifdef AF_UNIX_HACK
876 1.1 mrg (void) unlink(Sock_name);
877 1.17 dholland #endif
878 1.1 mrg
879 1.1 mrg exit(eval);
880 1.1 mrg }
881 1.1 mrg
882 1.1 mrg /*
883 1.1 mrg * send_stats:
884 1.1 mrg * Print stats to requestor
885 1.1 mrg */
886 1.2 lukem static void
887 1.16 dholland send_stats(void)
888 1.1 mrg {
889 1.17 dholland IDENT *ip;
890 1.17 dholland FILE *fp;
891 1.17 dholland int s;
892 1.17 dholland SOCKET sockstruct;
893 1.17 dholland socklen_t socklen;
894 1.1 mrg
895 1.1 mrg /*
896 1.1 mrg * Get the output stream ready
897 1.1 mrg */
898 1.17 dholland #ifdef INTERNET
899 1.1 mrg socklen = sizeof sockstruct;
900 1.17 dholland #else
901 1.1 mrg socklen = sizeof sockstruct - 1;
902 1.17 dholland #endif
903 1.1 mrg s = accept(Status, (struct sockaddr *) &sockstruct, &socklen);
904 1.1 mrg if (s < 0) {
905 1.1 mrg if (errno == EINTR)
906 1.1 mrg return;
907 1.17 dholland #ifdef LOG
908 1.7 lukem syslog(LOG_WARNING, "accept: %m");
909 1.17 dholland #else
910 1.3 lukem warn("accept");
911 1.17 dholland #endif
912 1.1 mrg return;
913 1.1 mrg }
914 1.1 mrg fp = fdopen(s, "w");
915 1.1 mrg if (fp == NULL) {
916 1.17 dholland #ifdef LOG
917 1.7 lukem syslog(LOG_WARNING, "fdopen: %m");
918 1.17 dholland #else
919 1.3 lukem warn("fdopen");
920 1.17 dholland #endif
921 1.1 mrg (void) close(s);
922 1.1 mrg return;
923 1.1 mrg }
924 1.1 mrg
925 1.1 mrg /*
926 1.1 mrg * Send output to requestor
927 1.1 mrg */
928 1.1 mrg fputs("Name\t\tScore\tDucked\tAbsorb\tFaced\tShot\tRobbed\tMissed\tSlimeK\n", fp);
929 1.1 mrg for (ip = Scores; ip != NULL; ip = ip->i_next) {
930 1.1 mrg fprintf(fp, "%s\t", ip->i_name);
931 1.1 mrg if (strlen(ip->i_name) < 8)
932 1.1 mrg putc('\t', fp);
933 1.1 mrg fprintf(fp, "%.2f\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
934 1.1 mrg ip->i_score, ip->i_ducked, ip->i_absorbed,
935 1.1 mrg ip->i_faced, ip->i_shot, ip->i_robbed,
936 1.1 mrg ip->i_missed, ip->i_slime);
937 1.1 mrg }
938 1.1 mrg fputs("\n\nName\t\tEnemy\tFriend\tDeaths\tStill\tSaved\n", fp);
939 1.1 mrg for (ip = Scores; ip != NULL; ip = ip->i_next) {
940 1.1 mrg if (ip->i_team == ' ') {
941 1.1 mrg fprintf(fp, "%s\t", ip->i_name);
942 1.1 mrg if (strlen(ip->i_name) < 8)
943 1.1 mrg putc('\t', fp);
944 1.1 mrg }
945 1.1 mrg else {
946 1.1 mrg fprintf(fp, "%s[%c]\t", ip->i_name, ip->i_team);
947 1.1 mrg if (strlen(ip->i_name) + 3 < 8)
948 1.1 mrg putc('\t', fp);
949 1.1 mrg }
950 1.1 mrg fprintf(fp, "%d\t%d\t%d\t%d\t%d\n",
951 1.1 mrg ip->i_gkills, ip->i_bkills, ip->i_deaths,
952 1.1 mrg ip->i_stillb, ip->i_saved);
953 1.1 mrg }
954 1.1 mrg
955 1.1 mrg (void) fclose(fp);
956 1.1 mrg }
957 1.1 mrg
958 1.1 mrg /*
959 1.1 mrg * clear_scores:
960 1.1 mrg * Clear out the scores so the next session start clean
961 1.1 mrg */
962 1.2 lukem static void
963 1.16 dholland clear_scores(void)
964 1.1 mrg {
965 1.17 dholland IDENT *ip, *nextip;
966 1.1 mrg
967 1.1 mrg for (ip = Scores; ip != NULL; ip = nextip) {
968 1.1 mrg nextip = ip->i_next;
969 1.15 dholland (void) free(ip);
970 1.1 mrg }
971 1.1 mrg Scores = NULL;
972 1.1 mrg }
973