+/* $NetBSD: dr_3.c,v 1.5 1997/10/13 21:03:27 christos Exp $ */
+
/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1983, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-/*static char sccsid[] = "from: @(#)dr_3.c 5.4 (Berkeley) 6/1/90";*/
-static char rcsid[] = "$Id: dr_3.c,v 1.2 1993/08/01 18:51:50 mycroft Exp $";
+#if 0
+static char sccsid[] = "@(#)dr_3.c 8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: dr_3.c,v 1.5 1997/10/13 21:03:27 christos Exp $");
+#endif
#endif /* not lint */
#include "driver.h"
+#include <stdlib.h>
+void
moveall() /* move all comp ships */
{
- register struct ship *sp, *sq; /* r11, r10 */
- register int n; /* r9 */
- register int k, l; /* r8, r7 */
+ struct ship *sp, *sq;
+ int n;
+ int k, l;
int row[NSHIP], col[NSHIP], dir[NSHIP], drift[NSHIP];
char moved[NSHIP];
if (snagged2(sp, sq) && range(sp, sq) > 1)
snap++;
if (!range(sp, sq) && !fouled2(sp, sq)) {
- makesignal(sp,
- "collision with %s (%c%c)", sq);
+ makesignal(sp, "collision with $$", sq);
if (die() < 4) {
- makesignal(sp,
- "fouled with %s (%c%c)",
- sq);
+ makesignal(sp, "fouled with $$",
+ sq);
Write(W_FOUL, sp, 0, l, 0, 0, 0);
Write(W_FOUL, sq, 0, n, 0, 0, 0);
}
}
}
+int
stillmoving(k)
-register int k;
+int k;
{
- register struct ship *sp;
+ struct ship *sp;
foreachship(sp)
if (sp->file->movebuf[k])
return 0;
}
+int
isolated(ship)
-register struct ship *ship;
+struct ship *ship;
{
- register struct ship *sp;
+ struct ship *sp;
foreachship(sp) {
if (ship != sp && range(ship, sp) <= 10)
return 1;
}
+int
push(from, to)
-register struct ship *from, *to;
+struct ship *from, *to;
{
- register int bs, sb;
+ int bs, sb;
sb = to->specs->guns;
bs = from->specs->guns;
return from < to;
}
+void
step(com, sp, moved)
char com;
-register struct ship *sp;
+struct ship *sp;
char *moved;
{
- register int dist;
+ int dist;
switch (com) {
case 'r':
case 'd':
if (!*moved) {
if (windspeed != 0 && ++sp->file->drift > 2 &&
- (sp->specs->class >= 3 && !snagged(sp)
+ ((sp->specs->class >= 3 && !snagged(sp))
|| (turn & 1) == 0)) {
sp->file->row -= dr[winddir];
sp->file->col -= dc[winddir];
}
}
+void
sendbp(from, to, sections, isdefense)
-register struct ship *from, *to;
+struct ship *from, *to;
int sections;
char isdefense;
{
int n;
- register struct BP *bp;
+ struct BP *bp;
bp = isdefense ? from->file->DBP : from->file->OBP;
for (n = 0; n < NBP && bp[n].turnsent; n++)
Write(isdefense ? W_DBP : W_OBP, from, 0,
n, turn, to->file->index, sections);
if (isdefense)
- makesignal(from, "repelling boarders",
- (struct ship *)0);
+ makemsg(from, "repelling boarders");
else
- makesignal(from, "boarding the %s (%c%c)", to);
+ makesignal(from, "boarding the $$", to);
}
}
+int
toughmelee(ship, to, isdefense, count)
-register struct ship *ship, *to;
+struct ship *ship, *to;
int isdefense, count;
{
- register struct BP *bp;
- register obp = 0;
+ struct BP *bp;
+ int obp = 0;
int n, OBP = 0, DBP = 0, dbp = 0;
int qual;
return 0;
}
+void
reload()
{
- register struct ship *sp;
+ struct ship *sp;
foreachship(sp) {
sp->file->loadwith = 0;
}
}
+void
checksails()
{
- register struct ship *sp;
- register int rig, full;
+ struct ship *sp;
+ int rig, full;
struct ship *close;
foreachship(sp) {
if (sp->file->captain[0] != 0)
continue;
rig = sp->specs->rig1;
- if (windspeed == 6 || windspeed == 5 && sp->specs->class > 4)
+ if (windspeed == 6 || (windspeed == 5 && sp->specs->class > 4))
rig = 0;
if (rig && sp->specs->crew3) {
close = closestenemy(sp, 0, 0);