-/* $NetBSD: klmove.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */
+/* $NetBSD: klmove.c,v 1.9 2009/05/24 22:55:03 dholland Exp $ */
/*
* Copyright (c) 1980, 1993
#if 0
static char sccsid[] = "@(#)klmove.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: klmove.c,v 1.6 2009/05/24 19:18:44 dholland Exp $");
+__RCSID("$NetBSD: klmove.c,v 1.9 2009/05/24 22:55:03 dholland Exp $");
#endif
#endif /* not lint */
double bigger;
int i;
-# ifdef xTRACE
+#ifdef xTRACE
if (Trace)
printf("klmove: fl = %d, Etc.nkling = %d\n", fl, Etc.nkling);
-# endif
- for (n = 0; n < Etc.nkling; n++)
- {
+#endif
+ for (n = 0; n < Etc.nkling; n++) {
k = &Etc.klingon[n];
i = 100;
if (fl)
bigger = 1.0;
dx = dx / bigger + 0.5;
dy = dy / bigger + 0.5;
- if (motion < 0)
- {
+ if (motion < 0) {
motion = -motion;
dx = -dx;
dy = -dy;
/* try to move the klingon */
nextx = k->x;
nexty = k->y;
- for (; motion > 0; motion--)
- {
+ for (; motion > 0; motion--) {
lookx = nextx + dx;
looky = nexty + dy;
- if (lookx < 0 || lookx >= NSECTS || looky < 0 || looky >= NSECTS)
- {
+ if (lookx < 0 || lookx >= NSECTS ||
+ looky < 0 || looky >= NSECTS) {
/* new quadrant */
qx = Ship.quadx;
qy = Ship.quady;
else
if (looky >= NSECTS)
qy += 1;
- if (qx < 0 || qx >= NQUADS || qy < 0 || qy >= NQUADS ||
- Quad[qx][qy].stars < 0 || Quad[qx][qy].klings > MAXKLQUAD - 1)
+ if (qx < 0 || qx >= NQUADS ||
+ qy < 0 || qy >= NQUADS ||
+ Quad[qx][qy].stars < 0 ||
+ Quad[qx][qy].klings > MAXKLQUAD - 1)
break;
- if (!damaged(SRSCAN))
- {
- printf("Klingon at %d,%d escapes to quadrant %d,%d\n",
+ if (!damaged(SRSCAN)) {
+ printf("Klingon at %d,%d escapes to "
+ "quadrant %d,%d\n",
k->x, k->y, qx, qy);
motion = Quad[qx][qy].scanned;
if (motion >= 0 && motion < 1000)
Quad[qx][qy].scanned += 100;
- motion = Quad[Ship.quadx][Ship.quady].scanned;
+ motion = Quad[Ship.quadx][Ship.quady]
+ .scanned;
if (motion >= 0 && motion < 1000)
- Quad[Ship.quadx][Ship.quady].scanned -= 100;
+ Quad[Ship.quadx][Ship.quady]
+ .scanned -= 100;
}
Sect[k->x][k->y] = EMPTY;
Quad[qx][qy].klings += 1;
k = 0;
break;
}
- if (Sect[lookx][looky] != EMPTY)
- {
+ if (Sect[lookx][looky] != EMPTY) {
lookx = nextx + fudgex;
if (lookx < 0 || lookx >= NSECTS)
lookx = nextx + dx;
- if (Sect[lookx][looky] != EMPTY)
- {
+ if (Sect[lookx][looky] != EMPTY) {
fudgex = -fudgex;
looky = nexty + fudgey;
- if (looky < 0 || looky >= NSECTS || Sect[lookx][looky] != EMPTY)
- {
+ if (looky < 0 || looky >= NSECTS ||
+ Sect[lookx][looky] != EMPTY) {
fudgey = -fudgey;
break;
}
nextx = lookx;
nexty = looky;
}
- if (k && (k->x != nextx || k->y != nexty))
- {
+ if (k && (k->x != nextx || k->y != nexty)) {
if (!damaged(SRSCAN))
printf("Klingon at %d,%d moves to %d,%d\n",
k->x, k->y, nextx, nexty);