-/* $NetBSD: dr_1.c,v 1.11 2000/11/30 22:02:20 jwise Exp $ */
+/* $NetBSD: dr_1.c,v 1.21 2004/11/05 21:30:32 dsl Exp $ */
/*
* Copyright (c) 1983, 1993
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
#if 0
static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: dr_1.c,v 1.11 2000/11/30 22:02:20 jwise Exp $");
+__RCSID("$NetBSD: dr_1.c,v 1.21 2004/11/05 21:30:32 dsl Exp $");
#endif
#endif /* not lint */
-#include "driver.h"
+#include <ctype.h>
+#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include "extern.h"
+#include "driver.h"
+
+static int fightitout(struct ship *, struct ship *, int);
void
-unfoul()
+unfoul(void)
{
struct ship *sp;
struct ship *to;
}
void
-boardcomp()
+boardcomp(void)
{
int crew[3];
struct ship *sp, *sq;
}
}
-int
-fightitout(from, to, key)
-struct ship *from, *to;
-int key;
+static int
+fightitout(struct ship *from, struct ship *to, int key)
{
struct ship *fromcap, *tocap;
int crewfrom[3], crewto[3], menfrom, mento;
}
if (fromstrength >= strengthto * 3 || count == 4) {
unboard(to, from, 0);
- subtract(from, totalfrom, crewfrom, fromcap, pcfrom);
- subtract(to, totalto, crewto, tocap, pcto);
+ subtract(from, fromcap, totalfrom, crewfrom, pcfrom);
+ subtract(to, tocap, totalto, crewto, pcto);
makemsg(from, "boarders from %s repelled", to->shipname);
- (void) sprintf(message, "killed in melee: %d. %s: %d",
+ sprintf(message, "killed in melee: %d. %s: %d",
totalto, from->shipname, totalfrom);
Writestr(W_SIGNAL, to, message);
if (key)
return 1;
} else if (strengthto >= fromstrength * 3) {
unboard(from, to, 0);
- subtract(from, totalfrom, crewfrom, fromcap, pcfrom);
- subtract(to, totalto, crewto, tocap, pcto);
+ subtract(from, fromcap, totalfrom, crewfrom, pcfrom);
+ subtract(to, tocap, totalto, crewto, pcto);
if (key) {
if (fromcap != from)
Write(W_POINTS, fromcap,
Write(W_POINTS, to, topoints, 0, 0, 0);
mento = crewto[0] ? crewto[0] : crewto[1];
if (mento) {
- subtract(to, mento, crewto, tocap, pcto);
- subtract(from, - mento, crewfrom, to, 0);
+ subtract(to, tocap, mento, crewto, pcto);
+ subtract(from, to, - mento, crewfrom, 0);
}
- (void) sprintf(message, "captured by the %s!",
- to->shipname);
+ sprintf(message, "captured by the %s!", to->shipname);
Writestr(W_SIGNAL, from, message);
- (void) sprintf(message, "killed in melee: %d. %s: %d",
+ sprintf(message, "killed in melee: %d. %s: %d",
totalto, from->shipname, totalfrom);
Writestr(W_SIGNAL, to, message);
mento = 0;
}
void
-resolve()
+resolve(void)
{
int thwart;
struct ship *sp, *sq;
continue;
for (sq = sp + 1; sq < ls; sq++)
if (sq->file->dir && meleeing(sp, sq) && meleeing(sq, sp))
- (void) fightitout(sp, sq, 0);
+ fightitout(sp, sq, 0);
thwart = 2;
foreachship(sq) {
if (sq->file->dir && meleeing(sq, sp))
}
void
-compcombat()
+compcombat(void)
{
int n;
struct ship *sp;
if (hit >= 0) {
if (load != L_GRAPE)
hit = hit > 10 ? 10 : hit;
- table(shootat, load, hit, closest, sp, dieroll());
+ table(sp, closest, shootat, load, hit, dieroll());
}
}
}
}
int
-next()
+next(void)
{
if (++turn % 55 == 0) {
if (alive)
if (tp == 0)
p = "Driver";
else {
- if (islower(*tp))
- *tp = toupper(*tp);
+ *tp = toupper((unsigned char)*tp);
p = tp;
}
- (void) strncpy(bestship->file->captain, p,
+ strlcpy(bestship->file->captain, p,
sizeof bestship->file->captain);
- bestship->file->captain
- [sizeof bestship->file->captain - 1] = 0;
logger(bestship);
}
return -1;