]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - trek/klmove.c
Pass -Wstrict-overflow.
[bsdgames-darwin.git] / trek / klmove.c
index 9419d3bdec25aaf03c8ca87009a4d59e91423f9e..4963f6be265c93fc572259a610c7092fe420053d 100644 (file)
@@ -1,6 +1,8 @@
+/*     $NetBSD: klmove.c,v 1.9 2009/05/24 22:55:03 dholland Exp $      */
+
 /*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 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
  * 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.
  *
  * SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
 #ifndef lint
-/*static char sccsid[] = "from: @(#)klmove.c   5.4 (Berkeley) 6/1/90";*/
-static char rcsid[] = "$Id: klmove.c,v 1.2 1993/08/01 18:50:23 mycroft Exp $";
+#if 0
+static char sccsid[] = "@(#)klmove.c   8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: klmove.c,v 1.9 2009/05/24 22:55:03 dholland Exp $");
+#endif
 #endif /* not lint */
 
-# include      "trek.h"
+#include <stdio.h>
+#include "trek.h"
 
 /*
 **  Move Klingons Around
@@ -61,26 +64,25 @@ static char rcsid[] = "$Id: klmove.c,v 1.2 1993/08/01 18:50:23 mycroft Exp $";
 **     course around stars.
 */
 
-klmove(fl)
-int    fl;
+void
+klmove(int fl)
 {
        int                     n;
-       register struct kling   *k;
+       struct kling    *k;
        double                  dx, dy;
        int                     nextx, nexty;
-       register int            lookx, looky;
+       int             lookx, looky;
        int                     motion;
        int                     fudgex, fudgey;
        int                     qx, qy;
        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; k && n++)
-       {
+#endif
+       for (n = 0; n < Etc.nkling; n++) {
                k = &Etc.klingon[n];
                i = 100;
                if (fl)
@@ -100,8 +102,7 @@ int 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;
@@ -110,12 +111,11 @@ int       fl;
                /* 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;
@@ -129,39 +129,41 @@ int       fl;
                                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;
                                Etc.nkling -= 1;
-                               bmove(&Etc.klingon[Etc.nkling], k, sizeof *k);
+                               *k = Etc.klingon[Etc.nkling];
                                Quad[Ship.quadx][Ship.quady].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;
                                        }
@@ -170,8 +172,7 @@ int fl;
                        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);