]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - sail/dr_3.c
Fix merge conflicts
[bsdgames-darwin.git] / sail / dr_3.c
index 27bf04729e31d39a3a3d69973453c200d1d78319..eb0280eaa3a0d250b9550d6c6cccdd16f00fc186 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: dr_3.c,v 1.11 2001/01/04 03:21:17 jwise Exp $  */
+/*     $NetBSD: dr_3.c,v 1.19 2009/03/14 22:52:52 dholland Exp $       */
 
 /*
  * Copyright (c) 1983, 1993
 
 /*
  * 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.
  * 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.
  *
  *    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
 #if 0
 static char sccsid[] = "@(#)dr_3.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: dr_3.c,v 1.11 2001/01/04 03:21:17 jwise Exp $");
+__RCSID("$NetBSD: dr_3.c,v 1.19 2009/03/14 22:52:52 dholland Exp $");
 #endif
 #endif /* not lint */
 
 #include <stdlib.h>
 #endif
 #endif /* not lint */
 
 #include <stdlib.h>
+#include <string.h>
 #include "extern.h"
 #include "driver.h"
 
 #include "extern.h"
 #include "driver.h"
 
-void   moveall(void);
-static int     stillmoving(int);
-static int     is_isolated(struct ship *);
-static int     push(struct ship *, struct ship *);
-static void    step(int, struct ship *, char *);
-void   sendbp(struct ship *, struct ship *, int, int);
-int    is_toughmelee(struct ship *, struct ship *, int, int);
-void   reload(void);
-void   checksails(void);
+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
 
 /* move all comp ships */
 void
@@ -72,7 +64,7 @@ moveall(void)
        foreachship(sp) {
                struct ship *closest;
                int ma, ta;
        foreachship(sp) {
                struct ship *closest;
                int ma, ta;
-               char af;
+               bool af;
 
                if (sp->file->captain[0] || sp->file->dir == 0)
                        continue;
 
                if (sp->file->captain[0] || sp->file->dir == 0)
                        continue;
@@ -85,6 +77,7 @@ moveall(void)
                                *sp->file->movebuf = '\0';
                        else
                                closeon(sp, closest, sp->file->movebuf,
                                *sp->file->movebuf = '\0';
                        else
                                closeon(sp, closest, sp->file->movebuf,
+                                       sizeof(sp->file->movebuf),
                                        ta, ma, af);
                } else
                        *sp->file->movebuf = '\0';
                                        ta, ma, af);
                } else
                        *sp->file->movebuf = '\0';
@@ -123,7 +116,7 @@ moveall(void)
                        if (!sp->file->movebuf[k])
                                sp->file->movebuf[k+1] = '\0';
                        else if (sp->file->dir)
                        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++;
                }
                /*
                        n++;
                }
                /*
@@ -150,8 +143,8 @@ moveall(void)
                                        if (dieroll() < 4) {
                                                makesignal(sp, "fouled with $$",
                                                    sq);
                                        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++;
                                }
                                        }
                                        snap++;
                                }
@@ -182,13 +175,13 @@ moveall(void)
                if (sp->file->dir != 0) {
                        *sp->file->movebuf = 0;
                        if (row[n] != sp->file->row)
                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)
                        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)
                        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)
                        if (drift[n] != sp->file->drift)
-                               Write(W_DRIFT, sp, sp->file->drift, 0, 0, 0);
+                               send_drift(sp, sp->file->drift);
                }
                n++;
        }
                }
                n++;
        }
@@ -232,7 +225,7 @@ push(struct ship *from, struct ship *to)
 }
 
 static void
 }
 
 static void
-step(int com, struct ship *sp, char *moved)
+step(struct ship *sp, int com, char *moved)
 {
        int dist;
 
 {
        int dist;
 
@@ -265,8 +258,9 @@ step(int com, struct ship *sp, char *moved)
                                sp->file->row -= dr[winddir];
                                sp->file->col -= dc[winddir];
                        }
                                sp->file->row -= dr[winddir];
                                sp->file->col -= dc[winddir];
                        }
-               } else
+               } else {
                        sp->file->drift = 0;
                        sp->file->drift = 0;
+               }
                break;
        }
 }
                break;
        }
 }
@@ -281,8 +275,11 @@ sendbp(struct ship *from, struct ship *to, int sections, int isdefense)
        for (n = 0; n < NBP && bp[n].turnsent; n++)
                ;
        if (n < NBP && sections) {
        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
                if (isdefense)
                        makemsg(from, "repelling boarders");
                else
@@ -335,7 +332,7 @@ void
 checksails(void)
 {
        struct ship *sp;
 checksails(void)
 {
        struct ship *sp;
-       int rig, full; 
+       int rig, full;
        struct ship *close;
 
        foreachship(sp) {
        struct ship *close;
 
        foreachship(sp) {
@@ -351,11 +348,13 @@ checksails(void)
                                        full = 1;
                                else
                                        full = 0;
                                        full = 1;
                                else
                                        full = 0;
-                       } else 
+                       } else {
                                full = 0;
                                full = 0;
-               } else
+                       }
+               } else {
                        full = 0;
                        full = 0;
+               }
                if ((sp->file->FS != 0) != full)
                if ((sp->file->FS != 0) != full)
-                       Write(W_FS, sp, full, 0, 0, 0);
+                       send_fs(sp, full);
        }
 }
        }
 }