-/* $NetBSD: pl_5.c,v 1.16 2003/08/07 09:37:44 agc Exp $ */
+/* $NetBSD: pl_5.c,v 1.21 2009/03/14 19:35:13 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
#if 0
static char sccsid[] = "@(#)pl_5.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: pl_5.c,v 1.16 2003/08/07 09:37:44 agc Exp $");
+__RCSID("$NetBSD: pl_5.c,v 1.21 2009/03/14 19:35:13 dholland Exp $");
#endif
#endif /* not lint */
#define turnfirst(x) (*x == 'r' || *x == 'l')
-static void parties(struct ship *, int *, int, int);
+static void parties(struct ship *, int *, int, int);
void
acceptmove(void)
char af;
int moved = 0;
int vma, dir;
- char prompt[60];
+ char promptstr[60];
char buf[60], last = '\0';
char *p;
ta = maxturns(ms, &af);
ma = maxmove(ms, mf->dir, 0);
- sprintf(prompt, "move (%d,%c%d): ", ma, af ? '\'' : ' ', ta);
- sgetstr(prompt, buf, sizeof buf);
+ snprintf(promptstr, sizeof(promptstr),
+ "move (%d,%c%d): ", ma, af ? '\'' : ' ', ta);
+ sgetstr(promptstr, buf, sizeof buf);
dir = mf->dir;
vma = ma;
for (p = buf; *p; p++)
*p-- = '\0';
break;
default:
- if (!isspace(*p)) {
+ if (!isspace((unsigned char)*p)) {
Msg("Input error.");
*p-- = '\0';
}
}
}
if (*buf)
- strcpy(movebuf, buf);
+ strlcpy(movebuf, buf, sizeof(movebuf));
else
- strcpy(movebuf, "d");
+ strlcpy(movebuf, "d", sizeof(movebuf));
Writestr(W_MOVE, ms, movebuf);
Msg("Helm: %s.", movebuf);
}
sp, 1);
parties(sp, crew, 0, c);
} else if ((fouled2(ms, sp) || grappled2(ms, sp)) && crew[2]) {
- c = sgetch("Crew sections to board the $$ (3 max) ?", sp, 1);
+ c = sgetch("Crew sections to board the $$ (3 max) ?",
+ sp, 1);
parties(sp, crew, 0, c);
}
}
static void
parties(struct ship *to, int *crew, int isdefense, int buf)
{
- int k, j, men;
+ int k, j, men;
struct BP *ptr;
int temp[3];
for (k = 0; k < 3; k++)
temp[k] = crew[k];
if (isdigit(buf)) {
- ptr = isdefense ? to->file->DBP : to->file->OBP;
+ ptr = isdefense ? to->file->DBP : to->file->OBP;
for (j = 0; j < NBP && ptr[j].turnsent; j++)
;
- if (!ptr[j].turnsent && buf > '0') {
+ if (j < NBP && !ptr[j].turnsent && buf > '0') {
men = 0;
for (k = 0; k < 3 && buf > '0'; k++) {
men += crew[k]