Sun Jun 28 21:12:35 2009 UTC ()
sprintf -> snprintf


(dholland)
diff -r1.10 -r1.11 src/games/hunt/huntd/answer.c
diff -r1.4 -r1.5 src/games/hunt/huntd/draw.c
diff -r1.13 -r1.14 src/games/hunt/huntd/driver.c
diff -r1.5 -r1.6 src/games/hunt/huntd/execute.c
diff -r1.11 -r1.12 src/games/hunt/huntd/faketalk.c
diff -r1.6 -r1.7 src/games/hunt/huntd/shots.c

cvs diff -r1.10 -r1.11 src/games/hunt/huntd/answer.c (expand / switch to unified diff)

--- src/games/hunt/huntd/answer.c 2009/06/28 18:59:37 1.10
+++ src/games/hunt/huntd/answer.c 2009/06/28 21:12:35 1.11
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: answer.c,v 1.10 2009/06/28 18:59:37 dholland Exp $ */ 1/* $NetBSD: answer.c,v 1.11 2009/06/28 21:12:35 dholland Exp $ */
2/* 2/*
3 * Copyright (c) 1983-2003, Regents of the University of California. 3 * Copyright (c) 1983-2003, Regents of the University of California.
4 * All rights reserved. 4 * All rights reserved.
5 *  5 *
6 * Redistribution and use in source and binary forms, with or without  6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are  7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 *  9 *
10 * + Redistributions of source code must retain the above copyright  10 * + Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * + Redistributions in binary form must reproduce the above copyright  12 * + Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the  13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A  22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT  25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,  26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY  27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE  29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34#ifndef lint 34#ifndef lint
35__RCSID("$NetBSD: answer.c,v 1.10 2009/06/28 18:59:37 dholland Exp $"); 35__RCSID("$NetBSD: answer.c,v 1.11 2009/06/28 21:12:35 dholland Exp $");
36#endif /* not lint */ 36#endif /* not lint */
37 37
38# include <ctype.h> 38# include <ctype.h>
39# include <errno.h> 39# include <errno.h>
40# include <fcntl.h> 40# include <fcntl.h>
41# include <stdlib.h> 41# include <stdlib.h>
42# include <unistd.h> 42# include <unistd.h>
43# include "hunt.h" 43# include "hunt.h"
44 44
45# define SCOREDECAY 15 45# define SCOREDECAY 15
46 46
47static char Ttyname[NAMELEN]; 47static char Ttyname[NAMELEN];
48 48
@@ -121,29 +121,30 @@ answer() @@ -121,29 +121,30 @@ answer()
121 * between driver and player processes 121 * between driver and player processes
122 */ 122 */
123 for (cp1 = cp2 = name; *cp1 != '\0'; cp1++) 123 for (cp1 = cp2 = name; *cp1 != '\0'; cp1++)
124 if (isprint((unsigned char)*cp1) || *cp1 == ' ') 124 if (isprint((unsigned char)*cp1) || *cp1 == ' ')
125 *cp2++ = *cp1; 125 *cp2++ = *cp1;
126 *cp2 = '\0'; 126 *cp2 = '\0';
127 127
128# ifdef INTERNET 128# ifdef INTERNET
129 if (mode == C_MESSAGE) { 129 if (mode == C_MESSAGE) {
130 char buf[BUFSIZ + 1]; 130 char buf[BUFSIZ + 1];
131 int n; 131 int n;
132 132
133 if (team == ' ') 133 if (team == ' ')
134 (void) sprintf(buf, "%s: ", name); 134 (void) snprintf(buf, sizeof(buf), "%s: ", name);
135 else 135 else
136 (void) sprintf(buf, "%s[%c]: ", name, team); 136 (void) snprintf(buf, sizeof(buf), "%s[%c]: ", name,
 137 team);
137 n = strlen(buf); 138 n = strlen(buf);
138 for (pp = Player; pp < End_player; pp++) { 139 for (pp = Player; pp < End_player; pp++) {
139 cgoto(pp, HEIGHT, 0); 140 cgoto(pp, HEIGHT, 0);
140 outstr(pp, buf, n); 141 outstr(pp, buf, n);
141 } 142 }
142 while ((n = read(newsock, buf, BUFSIZ)) > 0) 143 while ((n = read(newsock, buf, BUFSIZ)) > 0)
143 for (pp = Player; pp < End_player; pp++) 144 for (pp = Player; pp < End_player; pp++)
144 outstr(pp, buf, n); 145 outstr(pp, buf, n);
145 for (pp = Player; pp < End_player; pp++) { 146 for (pp = Player; pp < End_player; pp++) {
146 ce(pp); 147 ce(pp);
147 sendcom(pp, REFRESH); 148 sendcom(pp, REFRESH);
148 sendcom(pp, READY, 0); 149 sendcom(pp, READY, 0);
149 (void) fflush(pp->p_output); 150 (void) fflush(pp->p_output);
@@ -203,27 +204,28 @@ answer() @@ -203,27 +204,28 @@ answer()
203 204
204# ifdef MONITOR 205# ifdef MONITOR
205void 206void
206stmonitor(pp) 207stmonitor(pp)
207 PLAYER *pp; 208 PLAYER *pp;
208{ 209{
209 int line; 210 int line;
210 PLAYER *npp; 211 PLAYER *npp;
211 212
212 memcpy(pp->p_maze, Maze, sizeof Maze); 213 memcpy(pp->p_maze, Maze, sizeof Maze);
213 214
214 drawmaze(pp); 215 drawmaze(pp);
215 216
216 (void) sprintf(Buf, "%5.5s%c%-10.10s %c", " ", stat_char(pp), 217 (void) snprintf(Buf, sizeof(Buf), "%5.5s%c%-10.10s %c", " ",
 218 stat_char(pp),
217 pp->p_ident->i_name, pp->p_ident->i_team); 219 pp->p_ident->i_name, pp->p_ident->i_team);
218 line = STAT_MON_ROW + 1 + (pp - Monitor); 220 line = STAT_MON_ROW + 1 + (pp - Monitor);
219 for (npp = Player; npp < End_player; npp++) { 221 for (npp = Player; npp < End_player; npp++) {
220 cgoto(npp, line, STAT_NAME_COL); 222 cgoto(npp, line, STAT_NAME_COL);
221 outstr(npp, Buf, STAT_NAME_LEN); 223 outstr(npp, Buf, STAT_NAME_LEN);
222 } 224 }
223 for (npp = Monitor; npp < End_monitor; npp++) { 225 for (npp = Monitor; npp < End_monitor; npp++) {
224 cgoto(npp, line, STAT_NAME_COL); 226 cgoto(npp, line, STAT_NAME_COL);
225 outstr(npp, Buf, STAT_NAME_LEN); 227 outstr(npp, Buf, STAT_NAME_LEN);
226 } 228 }
227 229
228 sendcom(pp, REFRESH); 230 sendcom(pp, REFRESH);
229 sendcom(pp, READY, 0); 231 sendcom(pp, READY, 0);
@@ -307,39 +309,41 @@ stplayer(newpp, enter_status) @@ -307,39 +309,41 @@ stplayer(newpp, enter_status)
307 check(pp, y, x); 309 check(pp, y, x);
308# endif 310# endif
309 311
310 do { 312 do {
311 x = rand_num(WIDTH - 1) + 1; 313 x = rand_num(WIDTH - 1) + 1;
312 y = rand_num(HEIGHT - 1) + 1; 314 y = rand_num(HEIGHT - 1) + 1;
313 } while (Maze[y][x] != SPACE); 315 } while (Maze[y][x] != SPACE);
314 Maze[y][x] = MINE; 316 Maze[y][x] = MINE;
315# ifdef MONITOR 317# ifdef MONITOR
316 for (pp = Monitor; pp < End_monitor; pp++) 318 for (pp = Monitor; pp < End_monitor; pp++)
317 check(pp, y, x); 319 check(pp, y, x);
318# endif 320# endif
319 321
320 (void) sprintf(Buf, "%5.2f%c%-10.10s %c", newpp->p_ident->i_score, 322 (void) snprintf(Buf, sizeof(Buf), "%5.2f%c%-10.10s %c",
 323 newpp->p_ident->i_score,
321 stat_char(newpp), newpp->p_ident->i_name, 324 stat_char(newpp), newpp->p_ident->i_name,
322 newpp->p_ident->i_team); 325 newpp->p_ident->i_team);
323 y = STAT_PLAY_ROW + 1 + (newpp - Player); 326 y = STAT_PLAY_ROW + 1 + (newpp - Player);
324 for (pp = Player; pp < End_player; pp++) { 327 for (pp = Player; pp < End_player; pp++) {
325 if (pp != newpp) { 328 if (pp != newpp) {
326 char smallbuf[16]; 329 char smallbuf[16];
327 330
328 pp->p_ammo += NSHOTS; 331 pp->p_ammo += NSHOTS;
329 newpp->p_ammo += NSHOTS; 332 newpp->p_ammo += NSHOTS;
330 cgoto(pp, y, STAT_NAME_COL); 333 cgoto(pp, y, STAT_NAME_COL);
331 outstr(pp, Buf, STAT_NAME_LEN); 334 outstr(pp, Buf, STAT_NAME_LEN);
332 (void) sprintf(smallbuf, "%3d", pp->p_ammo); 335 (void) snprintf(smallbuf, sizeof(smallbuf),
 336 "%3d", pp->p_ammo);
333 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); 337 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
334 outstr(pp, smallbuf, 3); 338 outstr(pp, smallbuf, 3);
335 } 339 }
336 } 340 }
337# ifdef MONITOR 341# ifdef MONITOR
338 for (pp = Monitor; pp < End_monitor; pp++) { 342 for (pp = Monitor; pp < End_monitor; pp++) {
339 cgoto(pp, y, STAT_NAME_COL); 343 cgoto(pp, y, STAT_NAME_COL);
340 outstr(pp, Buf, STAT_NAME_LEN); 344 outstr(pp, Buf, STAT_NAME_LEN);
341 } 345 }
342# endif 346# endif
343 347
344 drawmaze(newpp); 348 drawmaze(newpp);
345 drawplayer(newpp, TRUE); 349 drawplayer(newpp, TRUE);

cvs diff -r1.4 -r1.5 src/games/hunt/huntd/draw.c (expand / switch to unified diff)

--- src/games/hunt/huntd/draw.c 2008/01/28 03:23:29 1.4
+++ src/games/hunt/huntd/draw.c 2009/06/28 21:12:35 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: draw.c,v 1.4 2008/01/28 03:23:29 dholland Exp $ */ 1/* $NetBSD: draw.c,v 1.5 2009/06/28 21:12:35 dholland Exp $ */
2/* 2/*
3 * Copyright (c) 1983-2003, Regents of the University of California. 3 * Copyright (c) 1983-2003, Regents of the University of California.
4 * All rights reserved. 4 * All rights reserved.
5 *  5 *
6 * Redistribution and use in source and binary forms, with or without  6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are  7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 *  9 *
10 * + Redistributions of source code must retain the above copyright  10 * + Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * + Redistributions in binary form must reproduce the above copyright  12 * + Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the  13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A  22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT  25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,  26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY  27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE  29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34#ifndef lint 34#ifndef lint
35__RCSID("$NetBSD: draw.c,v 1.4 2008/01/28 03:23:29 dholland Exp $"); 35__RCSID("$NetBSD: draw.c,v 1.5 2009/06/28 21:12:35 dholland Exp $");
36#endif /* not lint */ 36#endif /* not lint */
37 37
38# include "hunt.h" 38# include "hunt.h"
39 39
40void 40void
41drawmaze(pp) 41drawmaze(pp)
42 PLAYER *pp; 42 PLAYER *pp;
43{ 43{
44 int x; 44 int x;
45 char *sp; 45 char *sp;
46 int y; 46 int y;
47 char *endp; 47 char *endp;
48 48
@@ -69,62 +69,64 @@ drawmaze(pp) @@ -69,62 +69,64 @@ drawmaze(pp)
69/* 69/*
70 * drawstatus - put up the status lines (this assumes the screen 70 * drawstatus - put up the status lines (this assumes the screen
71 * size is 80x24 with the maze being 64x24) 71 * size is 80x24 with the maze being 64x24)
72 */ 72 */
73void 73void
74drawstatus(pp) 74drawstatus(pp)
75 PLAYER *pp; 75 PLAYER *pp;
76{ 76{
77 int i; 77 int i;
78 PLAYER *np; 78 PLAYER *np;
79 79
80 cgoto(pp, STAT_AMMO_ROW, STAT_LABEL_COL); 80 cgoto(pp, STAT_AMMO_ROW, STAT_LABEL_COL);
81 outstr(pp, "Ammo:", 5); 81 outstr(pp, "Ammo:", 5);
82 (void) sprintf(Buf, "%3d", pp->p_ammo); 82 (void) snprintf(Buf, sizeof(Buf), "%3d", pp->p_ammo);
83 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); 83 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
84 outstr(pp, Buf, 3); 84 outstr(pp, Buf, 3);
85 85
86 cgoto(pp, STAT_GUN_ROW, STAT_LABEL_COL); 86 cgoto(pp, STAT_GUN_ROW, STAT_LABEL_COL);
87 outstr(pp, "Gun:", 4); 87 outstr(pp, "Gun:", 4);
88 cgoto(pp, STAT_GUN_ROW, STAT_VALUE_COL); 88 cgoto(pp, STAT_GUN_ROW, STAT_VALUE_COL);
89 outstr(pp, (pp->p_ncshot < MAXNCSHOT) ? " ok" : " ", 3); 89 outstr(pp, (pp->p_ncshot < MAXNCSHOT) ? " ok" : " ", 3);
90 90
91 cgoto(pp, STAT_DAM_ROW, STAT_LABEL_COL); 91 cgoto(pp, STAT_DAM_ROW, STAT_LABEL_COL);
92 outstr(pp, "Damage:", 7); 92 outstr(pp, "Damage:", 7);
93 (void) sprintf(Buf, "%2d/%2d", pp->p_damage, pp->p_damcap); 93 (void) snprintf(Buf, sizeof(Buf), "%2d/%2d", pp->p_damage,
 94 pp->p_damcap);
94 cgoto(pp, STAT_DAM_ROW, STAT_VALUE_COL); 95 cgoto(pp, STAT_DAM_ROW, STAT_VALUE_COL);
95 outstr(pp, Buf, 5); 96 outstr(pp, Buf, 5);
96 97
97 cgoto(pp, STAT_KILL_ROW, STAT_LABEL_COL); 98 cgoto(pp, STAT_KILL_ROW, STAT_LABEL_COL);
98 outstr(pp, "Kills:", 6); 99 outstr(pp, "Kills:", 6);
99 (void) sprintf(Buf, "%3d", (pp->p_damcap - MAXDAM) / 2); 100 (void) snprintf(Buf, sizeof(Buf), "%3d", (pp->p_damcap - MAXDAM) / 2);
100 cgoto(pp, STAT_KILL_ROW, STAT_VALUE_COL); 101 cgoto(pp, STAT_KILL_ROW, STAT_VALUE_COL);
101 outstr(pp, Buf, 3); 102 outstr(pp, Buf, 3);
102 103
103 cgoto(pp, STAT_PLAY_ROW, STAT_LABEL_COL); 104 cgoto(pp, STAT_PLAY_ROW, STAT_LABEL_COL);
104 outstr(pp, "Player:", 7); 105 outstr(pp, "Player:", 7);
105 for (i = STAT_PLAY_ROW + 1, np = Player; np < End_player; np++) { 106 for (i = STAT_PLAY_ROW + 1, np = Player; np < End_player; np++) {
106 (void) sprintf(Buf, "%5.2f%c%-10.10s %c", np->p_ident->i_score, 107 (void) snprintf(Buf, sizeof(Buf), "%5.2f%c%-10.10s %c",
 108 np->p_ident->i_score,
107 stat_char(np), np->p_ident->i_name, 109 stat_char(np), np->p_ident->i_name,
108 np->p_ident->i_team); 110 np->p_ident->i_team);
109 cgoto(pp, i++, STAT_NAME_COL); 111 cgoto(pp, i++, STAT_NAME_COL);
110 outstr(pp, Buf, STAT_NAME_LEN); 112 outstr(pp, Buf, STAT_NAME_LEN);
111 } 113 }
112 114
113# ifdef MONITOR 115# ifdef MONITOR
114 cgoto(pp, STAT_MON_ROW, STAT_LABEL_COL); 116 cgoto(pp, STAT_MON_ROW, STAT_LABEL_COL);
115 outstr(pp, "Monitor:", 8); 117 outstr(pp, "Monitor:", 8);
116 for (i = STAT_MON_ROW + 1, np = Monitor; np < End_monitor; np++) { 118 for (i = STAT_MON_ROW + 1, np = Monitor; np < End_monitor; np++) {
117 (void) sprintf(Buf, "%5.5s %-10.10s %c", " ", 119 (void) snprintf(Buf, sizeof(Buf), "%5.5s %-10.10s %c", " ",
118 np->p_ident->i_name, np->p_ident->i_team); 120 np->p_ident->i_name, np->p_ident->i_team);
119 cgoto(pp, i++, STAT_NAME_COL); 121 cgoto(pp, i++, STAT_NAME_COL);
120 outstr(pp, Buf, STAT_NAME_LEN); 122 outstr(pp, Buf, STAT_NAME_LEN);
121 } 123 }
122# endif 124# endif
123} 125}
124 126
125void 127void
126look(pp) 128look(pp)
127 PLAYER *pp; 129 PLAYER *pp;
128{ 130{
129 int x, y; 131 int x, y;
130 132

cvs diff -r1.13 -r1.14 src/games/hunt/huntd/driver.c (expand / switch to unified diff)

--- src/games/hunt/huntd/driver.c 2008/01/28 03:23:29 1.13
+++ src/games/hunt/huntd/driver.c 2009/06/28 21:12:35 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: driver.c,v 1.13 2008/01/28 03:23:29 dholland Exp $ */ 1/* $NetBSD: driver.c,v 1.14 2009/06/28 21:12:35 dholland Exp $ */
2/* 2/*
3 * Copyright (c) 1983-2003, Regents of the University of California. 3 * Copyright (c) 1983-2003, Regents of the University of California.
4 * All rights reserved. 4 * All rights reserved.
5 *  5 *
6 * Redistribution and use in source and binary forms, with or without  6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are  7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 *  9 *
10 * + Redistributions of source code must retain the above copyright  10 * + Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * + Redistributions in binary form must reproduce the above copyright  12 * + Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the  13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A  22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT  25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,  26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY  27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE  29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34#ifndef lint 34#ifndef lint
35__RCSID("$NetBSD: driver.c,v 1.13 2008/01/28 03:23:29 dholland Exp $"); 35__RCSID("$NetBSD: driver.c,v 1.14 2009/06/28 21:12:35 dholland Exp $");
36#endif /* not lint */ 36#endif /* not lint */
37 37
38# include <sys/ioctl.h> 38# include <sys/ioctl.h>
39# include <sys/stat.h> 39# include <sys/stat.h>
40# include <sys/time.h> 40# include <sys/time.h>
41# include <err.h> 41# include <err.h>
42# include <errno.h> 42# include <errno.h>
43# include <signal.h> 43# include <signal.h>
44# include <stdlib.h> 44# include <stdlib.h>
45# include <unistd.h> 45# include <unistd.h>
46# include "hunt.h" 46# include "hunt.h"
47 47
48# ifndef pdp11 48# ifndef pdp11
@@ -480,27 +480,27 @@ checkdam(ouch, gotcha, credit, amt, this @@ -480,27 +480,27 @@ checkdam(ouch, gotcha, credit, amt, this
480 default: 480 default:
481 break; 481 break;
482 case 1: 482 case 1:
483 amt = (amt + 1) / 2; 483 amt = (amt + 1) / 2;
484 break; 484 break;
485 case 2: 485 case 2:
486 if (gotcha != NULL) 486 if (gotcha != NULL)
487 message(gotcha, "He has boots on!"); 487 message(gotcha, "He has boots on!");
488 return; 488 return;
489 } 489 }
490# endif 490# endif
491 ouch->p_damage += amt; 491 ouch->p_damage += amt;
492 if (ouch->p_damage <= ouch->p_damcap) { 492 if (ouch->p_damage <= ouch->p_damcap) {
493 (void) sprintf(Buf, "%2d", ouch->p_damage); 493 (void) snprintf(Buf, sizeof(Buf), "%2d", ouch->p_damage);
494 cgoto(ouch, STAT_DAM_ROW, STAT_VALUE_COL); 494 cgoto(ouch, STAT_DAM_ROW, STAT_VALUE_COL);
495 outstr(ouch, Buf, 2); 495 outstr(ouch, Buf, 2);
496 return; 496 return;
497 } 497 }
498 498
499 /* Someone DIED */ 499 /* Someone DIED */
500 switch (this_shot_type) { 500 switch (this_shot_type) {
501 default: 501 default:
502 cp = "Killed"; 502 cp = "Killed";
503 break; 503 break;
504# ifdef FLY 504# ifdef FLY
505 case FALL: 505 case FALL:
506 cp = "Killed on impact"; 506 cp = "Killed on impact";
@@ -531,64 +531,68 @@ checkdam(ouch, gotcha, credit, amt, this @@ -531,64 +531,68 @@ checkdam(ouch, gotcha, credit, amt, this
531# endif 531# endif
532# ifdef VOLCANO 532# ifdef VOLCANO
533 case LAVA: 533 case LAVA:
534 cp = "Baked"; 534 cp = "Baked";
535 break; 535 break;
536# endif 536# endif
537# ifdef DRONE 537# ifdef DRONE
538 case DSHOT: 538 case DSHOT:
539 cp = "Eliminated"; 539 cp = "Eliminated";
540 break; 540 break;
541# endif 541# endif
542 } 542 }
543 if (credit == NULL) { 543 if (credit == NULL) {
544 (void) sprintf(ouch->p_death, "| %s by %s |", cp, 544 (void) snprintf(ouch->p_death, sizeof(ouch->p_death),
 545 "| %s by %s |", cp,
545 (this_shot_type == MINE || this_shot_type == GMINE) ? 546 (this_shot_type == MINE || this_shot_type == GMINE) ?
546 "a mine" : "act of God"); 547 "a mine" : "act of God");
547 return; 548 return;
548 } 549 }
549 550
550 (void) sprintf(ouch->p_death, "| %s by %s |", cp, credit->i_name); 551 (void) snprintf(ouch->p_death, sizeof(ouch->p_death),
 552 "| %s by %s |", cp, credit->i_name);
551 553
552 if (ouch == gotcha) { /* No use killing yourself */ 554 if (ouch == gotcha) { /* No use killing yourself */
553 credit->i_kills--; 555 credit->i_kills--;
554 credit->i_bkills++; 556 credit->i_bkills++;
555 } 557 }
556 else if (ouch->p_ident->i_team == ' ' 558 else if (ouch->p_ident->i_team == ' '
557 || ouch->p_ident->i_team != credit->i_team) { 559 || ouch->p_ident->i_team != credit->i_team) {
558 credit->i_kills++; 560 credit->i_kills++;
559 credit->i_gkills++; 561 credit->i_gkills++;
560 } 562 }
561 else { 563 else {
562 credit->i_kills--; 564 credit->i_kills--;
563 credit->i_bkills++; 565 credit->i_bkills++;
564 } 566 }
565 credit->i_score = credit->i_kills / (double) credit->i_entries; 567 credit->i_score = credit->i_kills / (double) credit->i_entries;
566 ouch->p_ident->i_deaths++; 568 ouch->p_ident->i_deaths++;
567 if (ouch->p_nchar == 0) 569 if (ouch->p_nchar == 0)
568 ouch->p_ident->i_stillb++; 570 ouch->p_ident->i_stillb++;
569 if (gotcha == NULL) 571 if (gotcha == NULL)
570 return; 572 return;
571 gotcha->p_damcap += STABDAM; 573 gotcha->p_damcap += STABDAM;
572 gotcha->p_damage -= STABDAM; 574 gotcha->p_damage -= STABDAM;
573 if (gotcha->p_damage < 0) 575 if (gotcha->p_damage < 0)
574 gotcha->p_damage = 0; 576 gotcha->p_damage = 0;
575 (void) sprintf(Buf, "%2d/%2d", gotcha->p_damage, gotcha->p_damcap); 577 (void) snprintf(Buf, sizeof(Buf), "%2d/%2d", gotcha->p_damage,
 578 gotcha->p_damcap);
576 cgoto(gotcha, STAT_DAM_ROW, STAT_VALUE_COL); 579 cgoto(gotcha, STAT_DAM_ROW, STAT_VALUE_COL);
577 outstr(gotcha, Buf, 5); 580 outstr(gotcha, Buf, 5);
578 (void) sprintf(Buf, "%3d", (gotcha->p_damcap - MAXDAM) / 2); 581 (void) snprintf(Buf, sizeof(Buf), "%3d",
 582 (gotcha->p_damcap - MAXDAM) / 2);
579 cgoto(gotcha, STAT_KILL_ROW, STAT_VALUE_COL); 583 cgoto(gotcha, STAT_KILL_ROW, STAT_VALUE_COL);
580 outstr(gotcha, Buf, 3); 584 outstr(gotcha, Buf, 3);
581 (void) sprintf(Buf, "%5.2f", gotcha->p_ident->i_score); 585 (void) snprintf(Buf, sizeof(Buf), "%5.2f", gotcha->p_ident->i_score);
582 for (ouch = Player; ouch < End_player; ouch++) { 586 for (ouch = Player; ouch < End_player; ouch++) {
583 cgoto(ouch, STAT_PLAY_ROW + 1 + (gotcha - Player), 587 cgoto(ouch, STAT_PLAY_ROW + 1 + (gotcha - Player),
584 STAT_NAME_COL); 588 STAT_NAME_COL);
585 outstr(ouch, Buf, 5); 589 outstr(ouch, Buf, 5);
586 } 590 }
587# ifdef MONITOR 591# ifdef MONITOR
588 for (ouch = Monitor; ouch < End_monitor; ouch++) { 592 for (ouch = Monitor; ouch < End_monitor; ouch++) {
589 cgoto(ouch, STAT_PLAY_ROW + 1 + (gotcha - Player), 593 cgoto(ouch, STAT_PLAY_ROW + 1 + (gotcha - Player),
590 STAT_NAME_COL); 594 STAT_NAME_COL);
591 outstr(ouch, Buf, 5); 595 outstr(ouch, Buf, 5);
592 } 596 }
593# endif 597# endif
594} 598}
@@ -661,27 +665,27 @@ zap(pp, was_player, i) @@ -661,27 +665,27 @@ zap(pp, was_player, i)
661 break; 665 break;
662 if (y >= 0 && slime_req[y] > shot_req[x]) { 666 if (y >= 0 && slime_req[y] > shot_req[x]) {
663 x = slime_req[y]; 667 x = slime_req[y];
664 len = SLIME; 668 len = SLIME;
665 } 669 }
666 else if (x != 0) { 670 else if (x != 0) {
667 len = shot_type[x]; 671 len = shot_type[x];
668 x = shot_req[x]; 672 x = shot_req[x];
669 } 673 }
670 } 674 }
671 if (x > 0) { 675 if (x > 0) {
672 (void) add_shot(len, pp->p_y, pp->p_x, pp->p_face, x, 676 (void) add_shot(len, pp->p_y, pp->p_x, pp->p_face, x,
673 (PLAYER *) NULL, TRUE, SPACE); 677 (PLAYER *) NULL, TRUE, SPACE);
674 (void) sprintf(Buf, "%s detonated.", 678 (void) snprintf(Buf, sizeof(Buf), "%s detonated.",
675 pp->p_ident->i_name); 679 pp->p_ident->i_name);
676 for (np = Player; np < End_player; np++) 680 for (np = Player; np < End_player; np++)
677 message(np, Buf); 681 message(np, Buf);
678# ifdef MONITOR 682# ifdef MONITOR
679 for (np = Monitor; np < End_monitor; np++) 683 for (np = Monitor; np < End_monitor; np++)
680 message(np, Buf); 684 message(np, Buf);
681# endif 685# endif
682# ifdef BOOTS 686# ifdef BOOTS
683 while (pp->p_nboots-- > 0) { 687 while (pp->p_nboots-- > 0) {
684 for (np = Boot; np < &Boot[NBOOTS]; np++) 688 for (np = Boot; np < &Boot[NBOOTS]; np++)
685 if (np->p_flying < 0) 689 if (np->p_flying < 0)
686 break; 690 break;
687 if (np >= &Boot[NBOOTS]) 691 if (np >= &Boot[NBOOTS])
@@ -737,27 +741,27 @@ zap(pp, was_player, i) @@ -737,27 +741,27 @@ zap(pp, was_player, i)
737 (PLAYER *) NULL, FALSE, SPACE); 741 (PLAYER *) NULL, FALSE, SPACE);
738 } 742 }
739# endif 743# endif
740 744
741 sendcom(pp, ENDWIN); 745 sendcom(pp, ENDWIN);
742 (void) putc(' ', pp->p_output); 746 (void) putc(' ', pp->p_output);
743 (void) fclose(pp->p_output); 747 (void) fclose(pp->p_output);
744 748
745 End_player--; 749 End_player--;
746 if (pp != End_player) { 750 if (pp != End_player) {
747 memcpy(pp, End_player, sizeof (PLAYER)); 751 memcpy(pp, End_player, sizeof (PLAYER));
748 fdset[i] = fdset[End_player - Player + 3]; 752 fdset[i] = fdset[End_player - Player + 3];
749 fdset[End_player - Player + 3].fd = -1; 753 fdset[End_player - Player + 3].fd = -1;
750 (void) sprintf(Buf, "%5.2f%c%-10.10s %c", 754 (void) snprintf(Buf, sizeof(Buf), "%5.2f%c%-10.10s %c",
751 pp->p_ident->i_score, stat_char(pp), 755 pp->p_ident->i_score, stat_char(pp),
752 pp->p_ident->i_name, pp->p_ident->i_team); 756 pp->p_ident->i_name, pp->p_ident->i_team);
753 n = STAT_PLAY_ROW + 1 + (pp - Player); 757 n = STAT_PLAY_ROW + 1 + (pp - Player);
754 for (np = Player; np < End_player; np++) { 758 for (np = Player; np < End_player; np++) {
755 cgoto(np, n, STAT_NAME_COL); 759 cgoto(np, n, STAT_NAME_COL);
756 outstr(np, Buf, STAT_NAME_LEN); 760 outstr(np, Buf, STAT_NAME_LEN);
757 } 761 }
758# ifdef MONITOR 762# ifdef MONITOR
759 for (np = Monitor; np < End_monitor; np++) { 763 for (np = Monitor; np < End_monitor; np++) {
760 cgoto(np, n, STAT_NAME_COL); 764 cgoto(np, n, STAT_NAME_COL);
761 outstr(np, Buf, STAT_NAME_LEN); 765 outstr(np, Buf, STAT_NAME_LEN);
762 } 766 }
763# endif 767# endif
@@ -776,27 +780,28 @@ zap(pp, was_player, i) @@ -776,27 +780,28 @@ zap(pp, was_player, i)
776 ce(np); 780 ce(np);
777 } 781 }
778 } 782 }
779 else { 783 else {
780 sendcom(pp, ENDWIN); 784 sendcom(pp, ENDWIN);
781 (void) putc(LAST_PLAYER, pp->p_output); 785 (void) putc(LAST_PLAYER, pp->p_output);
782 (void) fclose(pp->p_output); 786 (void) fclose(pp->p_output);
783 787
784 End_monitor--; 788 End_monitor--;
785 if (pp != End_monitor) { 789 if (pp != End_monitor) {
786 memcpy(pp, End_monitor, sizeof (PLAYER)); 790 memcpy(pp, End_monitor, sizeof (PLAYER));
787 fdset[i] = fdset[End_monitor - Monitor + MAXPL + 3]; 791 fdset[i] = fdset[End_monitor - Monitor + MAXPL + 3];
788 fdset[End_monitor - Monitor + MAXPL + 3].fd = -1; 792 fdset[End_monitor - Monitor + MAXPL + 3].fd = -1;
789 (void) sprintf(Buf, "%5.5s %-10.10s %c", " ", 793 (void) snprintf(Buf, sizeof(Buf), "%5.5s %-10.10s %c",
 794 " ",
790 pp->p_ident->i_name, pp->p_ident->i_team); 795 pp->p_ident->i_name, pp->p_ident->i_team);
791 n = STAT_MON_ROW + 1 + (pp - Player); 796 n = STAT_MON_ROW + 1 + (pp - Player);
792 for (np = Player; np < End_player; np++) { 797 for (np = Player; np < End_player; np++) {
793 cgoto(np, n, STAT_NAME_COL); 798 cgoto(np, n, STAT_NAME_COL);
794 outstr(np, Buf, STAT_NAME_LEN); 799 outstr(np, Buf, STAT_NAME_LEN);
795 } 800 }
796 for (np = Monitor; np < End_monitor; np++) { 801 for (np = Monitor; np < End_monitor; np++) {
797 cgoto(np, n, STAT_NAME_COL); 802 cgoto(np, n, STAT_NAME_COL);
798 outstr(np, Buf, STAT_NAME_LEN); 803 outstr(np, Buf, STAT_NAME_LEN);
799 } 804 }
800 } else 805 } else
801 fdset[i].fd = -1; 806 fdset[i].fd = -1;
802 807

cvs diff -r1.5 -r1.6 src/games/hunt/huntd/execute.c (expand / switch to unified diff)

--- src/games/hunt/huntd/execute.c 2008/01/28 03:23:29 1.5
+++ src/games/hunt/huntd/execute.c 2009/06/28 21:12:35 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: execute.c,v 1.5 2008/01/28 03:23:29 dholland Exp $ */ 1/* $NetBSD: execute.c,v 1.6 2009/06/28 21:12:35 dholland Exp $ */
2/* 2/*
3 * Copyright (c) 1983-2003, Regents of the University of California. 3 * Copyright (c) 1983-2003, Regents of the University of California.
4 * All rights reserved. 4 * All rights reserved.
5 *  5 *
6 * Redistribution and use in source and binary forms, with or without  6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are  7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 *  9 *
10 * + Redistributions of source code must retain the above copyright  10 * + Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * + Redistributions in binary form must reproduce the above copyright  12 * + Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the  13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A  22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT  25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,  26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY  27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE  29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34#ifndef lint 34#ifndef lint
35__RCSID("$NetBSD: execute.c,v 1.5 2008/01/28 03:23:29 dholland Exp $"); 35__RCSID("$NetBSD: execute.c,v 1.6 2009/06/28 21:12:35 dholland Exp $");
36#endif /* not lint */ 36#endif /* not lint */
37 37
38# include <stdlib.h> 38# include <stdlib.h>
39# include "hunt.h" 39# include "hunt.h"
40 40
41static void cloak(PLAYER *); 41static void cloak(PLAYER *);
42static void turn_player(PLAYER *, int); 42static void turn_player(PLAYER *, int);
43static void fire(PLAYER *, int); 43static void fire(PLAYER *, int);
44static void fire_slime(PLAYER *, int); 44static void fire_slime(PLAYER *, int);
45static void move_player(PLAYER *, int); 45static void move_player(PLAYER *, int);
46static void pickup(PLAYER *, int, int, int, int); 46static void pickup(PLAYER *, int, int, int, int);
47static void scan(PLAYER *); 47static void scan(PLAYER *);
48 48
@@ -356,27 +356,27 @@ fire(pp, req_index) @@ -356,27 +356,27 @@ fire(pp, req_index)
356 while (req_index >= 0 && pp->p_ammo < shot_req[req_index]) 356 while (req_index >= 0 && pp->p_ammo < shot_req[req_index])
357 req_index--; 357 req_index--;
358 if (req_index < 0) { 358 if (req_index < 0) {
359 message(pp, "Not enough charges."); 359 message(pp, "Not enough charges.");
360 return; 360 return;
361 } 361 }
362 if (pp->p_ncshot > MAXNCSHOT) 362 if (pp->p_ncshot > MAXNCSHOT)
363 return; 363 return;
364 if (pp->p_ncshot++ == MAXNCSHOT) { 364 if (pp->p_ncshot++ == MAXNCSHOT) {
365 cgoto(pp, STAT_GUN_ROW, STAT_VALUE_COL); 365 cgoto(pp, STAT_GUN_ROW, STAT_VALUE_COL);
366 outstr(pp, " ", 3); 366 outstr(pp, " ", 3);
367 } 367 }
368 pp->p_ammo -= shot_req[req_index]; 368 pp->p_ammo -= shot_req[req_index];
369 (void) sprintf(Buf, "%3d", pp->p_ammo); 369 (void) snprintf(Buf, sizeof(Buf), "%3d", pp->p_ammo);
370 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); 370 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
371 outstr(pp, Buf, 3); 371 outstr(pp, Buf, 3);
372 372
373 add_shot(shot_type[req_index], pp->p_y, pp->p_x, pp->p_face, 373 add_shot(shot_type[req_index], pp->p_y, pp->p_x, pp->p_face,
374 shot_req[req_index], pp, FALSE, pp->p_face); 374 shot_req[req_index], pp, FALSE, pp->p_face);
375 pp->p_undershot = TRUE; 375 pp->p_undershot = TRUE;
376 376
377 /* 377 /*
378 * Show the object to everyone 378 * Show the object to everyone
379 */ 379 */
380 showexpl(pp->p_y, pp->p_x, shot_type[req_index]); 380 showexpl(pp->p_y, pp->p_x, shot_type[req_index]);
381 for (pp = Player; pp < End_player; pp++) 381 for (pp = Player; pp < End_player; pp++)
382 sendcom(pp, REFRESH); 382 sendcom(pp, REFRESH);
@@ -405,27 +405,27 @@ fire_slime(pp, req_index) @@ -405,27 +405,27 @@ fire_slime(pp, req_index)
405 while (req_index >= 0 && pp->p_ammo < slime_req[req_index]) 405 while (req_index >= 0 && pp->p_ammo < slime_req[req_index])
406 req_index--; 406 req_index--;
407 if (req_index < 0) { 407 if (req_index < 0) {
408 message(pp, "Not enough charges."); 408 message(pp, "Not enough charges.");
409 return; 409 return;
410 } 410 }
411 if (pp->p_ncshot > MAXNCSHOT) 411 if (pp->p_ncshot > MAXNCSHOT)
412 return; 412 return;
413 if (pp->p_ncshot++ == MAXNCSHOT) { 413 if (pp->p_ncshot++ == MAXNCSHOT) {
414 cgoto(pp, STAT_GUN_ROW, STAT_VALUE_COL); 414 cgoto(pp, STAT_GUN_ROW, STAT_VALUE_COL);
415 outstr(pp, " ", 3); 415 outstr(pp, " ", 3);
416 } 416 }
417 pp->p_ammo -= slime_req[req_index]; 417 pp->p_ammo -= slime_req[req_index];
418 (void) sprintf(Buf, "%3d", pp->p_ammo); 418 (void) snprintf(Buf, sizeof(Buf), "%3d", pp->p_ammo);
419 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); 419 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
420 outstr(pp, Buf, 3); 420 outstr(pp, Buf, 3);
421 421
422 add_shot(SLIME, pp->p_y, pp->p_x, pp->p_face, 422 add_shot(SLIME, pp->p_y, pp->p_x, pp->p_face,
423 slime_req[req_index] * SLIME_FACTOR, pp, FALSE, pp->p_face); 423 slime_req[req_index] * SLIME_FACTOR, pp, FALSE, pp->p_face);
424 pp->p_undershot = TRUE; 424 pp->p_undershot = TRUE;
425 425
426 /* 426 /*
427 * Show the object to everyone 427 * Show the object to everyone
428 */ 428 */
429 showexpl(pp->p_y, pp->p_x, SLIME); 429 showexpl(pp->p_y, pp->p_x, SLIME);
430 for (pp = Player; pp < End_player; pp++) 430 for (pp = Player; pp < End_player; pp++)
431 sendcom(pp, REFRESH); 431 sendcom(pp, REFRESH);
@@ -526,51 +526,51 @@ static void @@ -526,51 +526,51 @@ static void
526cloak(pp) 526cloak(pp)
527 PLAYER *pp; 527 PLAYER *pp;
528{ 528{
529 if (pp->p_ammo <= 0) { 529 if (pp->p_ammo <= 0) {
530 message(pp, "No more charges"); 530 message(pp, "No more charges");
531 return; 531 return;
532 } 532 }
533# ifdef BOOTS 533# ifdef BOOTS
534 if (pp->p_nboots > 0) { 534 if (pp->p_nboots > 0) {
535 message(pp, "Boots are too noisy to cloak!"); 535 message(pp, "Boots are too noisy to cloak!");
536 return; 536 return;
537 } 537 }
538# endif 538# endif
539 (void) sprintf(Buf, "%3d", --pp->p_ammo); 539 (void) snprintf(Buf, sizeof(Buf), "%3d", --pp->p_ammo);
540 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); 540 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
541 outstr(pp, Buf, 3); 541 outstr(pp, Buf, 3);
542 542
543 pp->p_cloak += CLOAKLEN; 543 pp->p_cloak += CLOAKLEN;
544 544
545 if (pp->p_scan >= 0) 545 if (pp->p_scan >= 0)
546 pp->p_scan = -1; 546 pp->p_scan = -1;
547 547
548 showstat(pp); 548 showstat(pp);
549} 549}
550 550
551/* 551/*
552 * scan: 552 * scan:
553 * Turn on or increase length of a scan 553 * Turn on or increase length of a scan
554 */ 554 */
555static void 555static void
556scan(pp) 556scan(pp)
557 PLAYER *pp; 557 PLAYER *pp;
558{ 558{
559 if (pp->p_ammo <= 0) { 559 if (pp->p_ammo <= 0) {
560 message(pp, "No more charges"); 560 message(pp, "No more charges");
561 return; 561 return;
562 } 562 }
563 (void) sprintf(Buf, "%3d", --pp->p_ammo); 563 (void) snprintf(Buf, sizeof(Buf), "%3d", --pp->p_ammo);
564 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); 564 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
565 outstr(pp, Buf, 3); 565 outstr(pp, Buf, 3);
566 566
567 pp->p_scan += SCANLEN; 567 pp->p_scan += SCANLEN;
568 568
569 if (pp->p_cloak >= 0) 569 if (pp->p_cloak >= 0)
570 pp->p_cloak = -1; 570 pp->p_cloak = -1;
571 571
572 showstat(pp); 572 showstat(pp);
573} 573}
574 574
575/* 575/*
576 * pickup: 576 * pickup:
@@ -590,18 +590,18 @@ pickup(pp, y, x, prob, obj) @@ -590,18 +590,18 @@ pickup(pp, y, x, prob, obj)
590 req = BULREQ; 590 req = BULREQ;
591 break; 591 break;
592 case GMINE: 592 case GMINE:
593 req = GRENREQ; 593 req = GRENREQ;
594 break; 594 break;
595 default: 595 default:
596 abort(); 596 abort();
597 } 597 }
598 if (rand_num(100) < prob) 598 if (rand_num(100) < prob)
599 add_shot(obj, y, x, LEFTS, req, (PLAYER *) NULL, 599 add_shot(obj, y, x, LEFTS, req, (PLAYER *) NULL,
600 TRUE, pp->p_face); 600 TRUE, pp->p_face);
601 else { 601 else {
602 pp->p_ammo += req; 602 pp->p_ammo += req;
603 (void) sprintf(Buf, "%3d", pp->p_ammo); 603 (void) snprintf(Buf, sizeof(Buf), "%3d", pp->p_ammo);
604 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); 604 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
605 outstr(pp, Buf, 3); 605 outstr(pp, Buf, 3);
606 } 606 }
607} 607}

cvs diff -r1.11 -r1.12 src/games/hunt/huntd/Attic/faketalk.c (expand / switch to unified diff)

--- src/games/hunt/huntd/Attic/faketalk.c 2007/12/15 19:44:41 1.11
+++ src/games/hunt/huntd/Attic/faketalk.c 2009/06/28 21:12:35 1.12
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: faketalk.c,v 1.11 2007/12/15 19:44:41 perry Exp $ */ 1/* $NetBSD: faketalk.c,v 1.12 2009/06/28 21:12:35 dholland Exp $ */
2/* 2/*
3 * Copyright (c) 1983-2003, Regents of the University of California. 3 * Copyright (c) 1983-2003, Regents of the University of California.
4 * All rights reserved. 4 * All rights reserved.
5 *  5 *
6 * Redistribution and use in source and binary forms, with or without  6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are  7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 *  9 *
10 * + Redistributions of source code must retain the above copyright  10 * + Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * + Redistributions in binary form must reproduce the above copyright  12 * + Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the  13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A  22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT  25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,  26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY  27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE  29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34#ifndef lint 34#ifndef lint
35__RCSID("$NetBSD: faketalk.c,v 1.11 2007/12/15 19:44:41 perry Exp $"); 35__RCSID("$NetBSD: faketalk.c,v 1.12 2009/06/28 21:12:35 dholland Exp $");
36#endif /* not lint */ 36#endif /* not lint */
37 37
38#include "bsd.h" 38#include "bsd.h"
39#include "hunt.h" 39#include "hunt.h"
40 40
41#if defined(TALK_43) || defined(TALK_42) 41#if defined(TALK_43) || defined(TALK_42)
42 42
43# include <sys/time.h> 43# include <sys/time.h>
44# include <sys/wait.h> 44# include <sys/wait.h>
45# include <ctype.h> 45# include <ctype.h>
46# include <netdb.h> 46# include <netdb.h>
47# include <signal.h> 47# include <signal.h>
48# include <stdio.h> 48# include <stdio.h>
@@ -154,30 +154,32 @@ faketalk() @@ -154,30 +154,32 @@ faketalk()
154# endif 154# endif
155 _exit(1); 155 _exit(1);
156 } 156 }
157 if ((f = fdopen(service, "r")) == NULL) { 157 if ((f = fdopen(service, "r")) == NULL) {
158# ifdef LOG 158# ifdef LOG
159 syslog(LOG_ERR, "fdopen failed\n"); 159 syslog(LOG_ERR, "fdopen failed\n");
160# else 160# else
161 warn("faketalk: fdopen"); 161 warn("faketalk: fdopen");
162# endif 162# endif
163 _exit(2); 163 _exit(2);
164 } 164 }
165 165
166 (void) fgets(buf, BUFSIZ, f); 166 (void) fgets(buf, BUFSIZ, f);
167 (void) sprintf(buf, "HELO HuntGame@%s\r\n", my_machine_name); 167 (void) snprintf(buf, sizeof(buf),
 168 "HELO HuntGame@%s\r\n", my_machine_name);
168 (void) write(service, buf, strlen(buf)); 169 (void) write(service, buf, strlen(buf));
169 (void) fgets(buf, BUFSIZ, f); 170 (void) fgets(buf, BUFSIZ, f);
170 (void) sprintf(buf, "EXPN %s@%s\r\n", RENDEZVOUS, my_machine_name); 171 (void) snprintf(buf, sizeof(buf),
 172 "EXPN %s@%s\r\n", RENDEZVOUS, my_machine_name);
171 (void) write(service, buf, strlen(buf)); 173 (void) write(service, buf, strlen(buf));
172 while (fgets(buf, BUFSIZ, f) != NULL) { 174 while (fgets(buf, BUFSIZ, f) != NULL) {
173 char *s, *t; 175 char *s, *t;
174 176
175 if (buf[0] != '2' || buf[1] != '5' || buf[2] != '0') 177 if (buf[0] != '2' || buf[1] != '5' || buf[2] != '0')
176 break; 178 break;
177 if ((s = strchr(buf + 4, '<')) == NULL) 179 if ((s = strchr(buf + 4, '<')) == NULL)
178 s = buf + 4, t = buf + strlen(buf) - 1; 180 s = buf + 4, t = buf + strlen(buf) - 1;
179 else { 181 else {
180 s += 1; 182 s += 1;
181 if ((t = strrchr(s, '>')) == NULL) 183 if ((t = strrchr(s, '>')) == NULL)
182 t = s + strlen(s) - 1; 184 t = s + strlen(s) - 1;
183 else 185 else

cvs diff -r1.6 -r1.7 src/games/hunt/huntd/shots.c (expand / switch to unified diff)

--- src/games/hunt/huntd/shots.c 2006/03/17 23:34:37 1.6
+++ src/games/hunt/huntd/shots.c 2009/06/28 21:12:35 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: shots.c,v 1.6 2006/03/17 23:34:37 abs Exp $ */ 1/* $NetBSD: shots.c,v 1.7 2009/06/28 21:12:35 dholland Exp $ */
2/* 2/*
3 * Copyright (c) 1983-2003, Regents of the University of California. 3 * Copyright (c) 1983-2003, Regents of the University of California.
4 * All rights reserved. 4 * All rights reserved.
5 *  5 *
6 * Redistribution and use in source and binary forms, with or without  6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are  7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 *  9 *
10 * + Redistributions of source code must retain the above copyright  10 * + Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * + Redistributions in binary form must reproduce the above copyright  12 * + Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the  13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A  22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT  25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,  26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY  27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE  29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34#ifndef lint 34#ifndef lint
35__RCSID("$NetBSD: shots.c,v 1.6 2006/03/17 23:34:37 abs Exp $"); 35__RCSID("$NetBSD: shots.c,v 1.7 2009/06/28 21:12:35 dholland Exp $");
36#endif /* not lint */ 36#endif /* not lint */
37 37
38# include <err.h> 38# include <err.h>
39# include <signal.h> 39# include <signal.h>
40# include <stdlib.h> 40# include <stdlib.h>
41# include "hunt.h" 41# include "hunt.h"
42 42
43# define PLUS_DELTA(x, max) if (x < max) x++; else x-- 43# define PLUS_DELTA(x, max) if (x < max) x++; else x--
44# define MINUS_DELTA(x, min) if (x > min) x--; else x++ 44# define MINUS_DELTA(x, min) if (x > min) x--; else x++
45 45
46static void chkshot(BULLET *, BULLET *); 46static void chkshot(BULLET *, BULLET *);
47static void chkslime(BULLET *, BULLET *); 47static void chkslime(BULLET *, BULLET *);
48static void explshot(BULLET *, int, int); 48static void explshot(BULLET *, int, int);
@@ -306,27 +306,28 @@ move_normal_shot(bp) @@ -306,27 +306,28 @@ move_normal_shot(bp)
306 if (rand_num(100) < 10) { 306 if (rand_num(100) < 10) {
307 if (bp->b_owner != NULL) 307 if (bp->b_owner != NULL)
308 message(bp->b_owner, 308 message(bp->b_owner,
309 "Your charge was absorbed!"); 309 "Your charge was absorbed!");
310 if (bp->b_score != NULL) 310 if (bp->b_score != NULL)
311 bp->b_score->i_robbed += bp->b_charge; 311 bp->b_score->i_robbed += bp->b_charge;
312 pp->p_ammo += bp->b_charge; 312 pp->p_ammo += bp->b_charge;
313 if (pp->p_damage + bp->b_size * MINDAM 313 if (pp->p_damage + bp->b_size * MINDAM
314 > pp->p_damcap) 314 > pp->p_damcap)
315 pp->p_ident->i_saved++; 315 pp->p_ident->i_saved++;
316 message(pp, "Absorbed charge (good shield!)"); 316 message(pp, "Absorbed charge (good shield!)");
317 pp->p_ident->i_absorbed += bp->b_charge; 317 pp->p_ident->i_absorbed += bp->b_charge;
318 free((char *) bp); 318 free((char *) bp);
319 (void) sprintf(Buf, "%3d", pp->p_ammo); 319 (void) snprintf(Buf, sizeof(Buf),
 320 "%3d", pp->p_ammo);
320 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); 321 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
321 outstr(pp, Buf, 3); 322 outstr(pp, Buf, 3);
322 return FALSE; 323 return FALSE;
323 } 324 }
324 pp->p_ident->i_faced += bp->b_charge; 325 pp->p_ident->i_faced += bp->b_charge;
325 } 326 }
326 /* 327 /*
327 * Small chance that the bullet just misses the 328 * Small chance that the bullet just misses the
328 * person. If so, the bullet just goes on its 329 * person. If so, the bullet just goes on its
329 * merry way without exploding. 330 * merry way without exploding.
330 */ 331 */
331 if (rand_num(100) < 5) { 332 if (rand_num(100) < 5) {
332 pp->p_ident->i_ducked += bp->b_charge; 333 pp->p_ident->i_ducked += bp->b_charge;
@@ -487,27 +488,27 @@ drone_move: @@ -487,27 +488,27 @@ drone_move:
487 case RIGHT: 488 case RIGHT:
488 case BELOW: 489 case BELOW:
489 case ABOVE: 490 case ABOVE:
490 /* 491 /*
491 * give the person a chance to catch a 492 * give the person a chance to catch a
492 * drone if s/he is facing it 493 * drone if s/he is facing it
493 */ 494 */
494 if (rand_num(100) < 1 && 495 if (rand_num(100) < 1 &&
495 opposite(bp->b_face, Maze[bp->b_y][bp->b_x])) { 496 opposite(bp->b_face, Maze[bp->b_y][bp->b_x])) {
496 pp = play_at(bp->b_y, bp->b_x); 497 pp = play_at(bp->b_y, bp->b_x);
497 pp->p_ammo += bp->b_charge; 498 pp->p_ammo += bp->b_charge;
498 message(pp, "**** Absorbed drone ****"); 499 message(pp, "**** Absorbed drone ****");
499 free((char *) bp); 500 free((char *) bp);
500 (void) sprintf(Buf, "%3d", pp->p_ammo); 501 (void) snprintf(Buf, sizeof(buf), "%3d", pp->p_ammo);
501 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL); 502 cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
502 outstr(pp, Buf, 3); 503 outstr(pp, Buf, 3);
503 return FALSE; 504 return FALSE;
504 } 505 }
505 bp->b_expl = TRUE; 506 bp->b_expl = TRUE;
506 break; 507 break;
507 } 508 }
508 return TRUE; 509 return TRUE;
509} 510}
510# endif 511# endif
511 512
512/* 513/*
513 * save_bullet: 514 * save_bullet: