]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - sail/dr_3.c
avoid duplicating symbols in libterminfo.
[bsdgames-darwin.git] / sail / dr_3.c
index 6c935269e779e11fc03baaa91b774a4cd0d6e6f4..eb0280eaa3a0d250b9550d6c6cccdd16f00fc186 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: dr_3.c,v 1.6 1999/02/10 00:45:45 hubertf Exp $ */
+/*     $NetBSD: dr_3.c,v 1.19 2009/03/14 22:52:52 dholland 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_3.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: dr_3.c,v 1.6 1999/02/10 00:45:45 hubertf Exp $");
+__RCSID("$NetBSD: dr_3.c,v 1.19 2009/03/14 22:52:52 dholland Exp $");
 #endif
 #endif /* not lint */
 
-#include "driver.h"
 #include <stdlib.h>
+#include <string.h>
+#include "extern.h"
+#include "driver.h"
 
+static int stillmoving(int);
+static int is_isolated(struct ship *);
+static int push(struct ship *, struct ship *);
+static void step(struct ship *, int, char *);
+
+/* move all comp ships */
 void
-moveall()              /* move all comp ships */
+moveall(void)
 {
        struct ship *sp, *sq;
        int n;
@@ -60,7 +64,7 @@ moveall()             /* move all comp ships */
        foreachship(sp) {
                struct ship *closest;
                int ma, ta;
-               char af;
+               bool af;
 
                if (sp->file->captain[0] || sp->file->dir == 0)
                        continue;
@@ -73,6 +77,7 @@ moveall()             /* move all comp ships */
                                *sp->file->movebuf = '\0';
                        else
                                closeon(sp, closest, sp->file->movebuf,
+                                       sizeof(sp->file->movebuf),
                                        ta, ma, af);
                } else
                        *sp->file->movebuf = '\0';
@@ -86,10 +91,10 @@ moveall()           /* move all comp ships */
        n = 0;
        foreachship(sp) {
                if (snagged(sp))
-                       (void) strcpy(sp->file->movebuf, "d");
+                       strcpy(sp->file->movebuf, "d");
                else
                        if (*sp->file->movebuf != 'd')
-                               (void) strcat(sp->file->movebuf, "d");
+                               strcat(sp->file->movebuf, "d");
                row[n] = sp->file->row;
                col[n] = sp->file->col;
                dir[n] = sp->file->dir;
@@ -111,7 +116,7 @@ moveall()           /* move all comp ships */
                        if (!sp->file->movebuf[k])
                                sp->file->movebuf[k+1] = '\0';
                        else if (sp->file->dir)
-                               step(sp->file->movebuf[k], sp, &moved[n]);
+                               step(sp, sp->file->movebuf[k], &moved[n]);
                        n++;
                }
                /*
@@ -119,7 +124,7 @@ moveall()           /* move all comp ships */
                 */
                n = 0;
                foreachship(sp) {
-                       if (sp->file->dir == 0 || isolated(sp))
+                       if (sp->file->dir == 0 || is_isolated(sp))
                                goto cont1;
                        l = 0;
                        foreachship(sq) {
@@ -135,11 +140,11 @@ moveall()         /* move all comp ships */
                                        snap++;
                                if (!range(sp, sq) && !fouled2(sp, sq)) {
                                        makesignal(sp, "collision with $$", sq);
-                                       if (die() < 4) {
+                                       if (dieroll() < 4) {
                                                makesignal(sp, "fouled with $$",
                                                    sq);
-                                               Write(W_FOUL, sp, l, 0, 0, 0);
-                                               Write(W_FOUL, sq, n, 0, 0, 0);
+                                               send_foul(sp, l);
+                                               send_foul(sq, n);
                                        }
                                        snap++;
                                }
@@ -170,21 +175,20 @@ moveall()         /* move all comp ships */
                if (sp->file->dir != 0) {
                        *sp->file->movebuf = 0;
                        if (row[n] != sp->file->row)
-                               Write(W_ROW, sp, sp->file->row, 0, 0, 0);
+                               send_row(sp, sp->file->row);
                        if (col[n] != sp->file->col)
-                               Write(W_COL, sp, sp->file->col, 0, 0, 0);
+                               send_col(sp, sp->file->col);
                        if (dir[n] != sp->file->dir)
-                               Write(W_DIR, sp, sp->file->dir, 0, 0, 0);
+                               send_dir(sp, sp->file->dir);
                        if (drift[n] != sp->file->drift)
-                               Write(W_DRIFT, sp, sp->file->drift, 0, 0, 0);
+                               send_drift(sp, sp->file->drift);
                }
                n++;
        }
 }
 
-int
-stillmoving(k)
-int k;
+static int
+stillmoving(int k)
 {
        struct ship *sp;
 
@@ -194,9 +198,8 @@ int k;
        return 0;
 }
 
-int
-isolated(ship)
-struct ship *ship;
+static int
+is_isolated(struct ship *ship)
 {
        struct ship *sp;
 
@@ -207,9 +210,8 @@ struct ship *ship;
        return 1;
 }
 
-int
-push(from, to)
-struct ship *from, *to;
+static int
+push(struct ship *from, struct ship *to)
 {
        int bs, sb;
 
@@ -222,11 +224,8 @@ struct ship *from, *to;
        return from < to;
 }
 
-void
-step(com, sp, moved)
-char com;
-struct ship *sp;
-char *moved;
+static void
+step(struct ship *sp, int com, char *moved)
 {
        int dist;
 
@@ -259,17 +258,15 @@ char *moved;
                                sp->file->row -= dr[winddir];
                                sp->file->col -= dc[winddir];
                        }
-               } else
+               } else {
                        sp->file->drift = 0;
+               }
                break;
        }
 }
 
 void
-sendbp(from, to, sections, isdefense)
-struct ship *from, *to;
-int sections;
-char isdefense;
+sendbp(struct ship *from, struct ship *to, int sections, int isdefense)
 {
        int n;
        struct BP *bp;
@@ -278,8 +275,11 @@ char isdefense;
        for (n = 0; n < NBP && bp[n].turnsent; n++)
                ;
        if (n < NBP && sections) {
-               Write(isdefense ? W_DBP : W_OBP, from,
-                       n, turn, to->file->index, sections);
+               if (isdefense) {
+                       send_dbp(from, n, turn, to->file->index, sections);
+               } else {
+                       send_obp(from, n, turn, to->file->index, sections);
+               }
                if (isdefense)
                        makemsg(from, "repelling boarders");
                else
@@ -288,9 +288,7 @@ char isdefense;
 }
 
 int
-toughmelee(ship, to, isdefense, count)
-struct ship *ship, *to;
-int isdefense, count;
+is_toughmelee(struct ship *ship, struct ship *to, int isdefense, int count)
 {
        struct BP *bp;
        int obp = 0;
@@ -311,9 +309,9 @@ int isdefense, count;
        }
        if (count || isdefense)
                return obp;
-       OBP = toughmelee(to, ship, 0, count + 1);
-       dbp = toughmelee(ship, to, 1, count + 1);
-       DBP = toughmelee(to, ship, 1, count + 1);
+       OBP = is_toughmelee(to, ship, 0, count + 1);
+       dbp = is_toughmelee(ship, to, 1, count + 1);
+       DBP = is_toughmelee(to, ship, 1, count + 1);
        if (OBP > obp + 10 || OBP + DBP >= obp + dbp + 10)
                return 1;
        else
@@ -321,7 +319,7 @@ int isdefense, count;
 }
 
 void
-reload()
+reload(void)
 {
        struct ship *sp;
 
@@ -331,10 +329,10 @@ reload()
 }
 
 void
-checksails()
+checksails(void)
 {
        struct ship *sp;
-       int rig, full; 
+       int rig, full;
        struct ship *close;
 
        foreachship(sp) {
@@ -350,11 +348,13 @@ checksails()
                                        full = 1;
                                else
                                        full = 0;
-                       } else 
+                       } else {
                                full = 0;
-               } else
+                       }
+               } else {
                        full = 0;
+               }
                if ((sp->file->FS != 0) != full)
-                       Write(W_FS, sp, full, 0, 0, 0);
+                       send_fs(sp, full);
        }
 }