BSD 4_3_Tahoe release
[unix-history] / usr / src / games / sail / dr_4.c
index ff0343a..8e73d1f 100644 (file)
@@ -1,46 +1,49 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)dr_4.c      1.1 83/03/17";
-#endif
+static char sccsid[] = "@(#)dr_4.c     5.3 (Berkeley) 6/18/88";
+#endif /* not lint */
+
 #include "externs.h"
 
 #include "externs.h"
 
-ungrap(from,to)
-int from, to;
+ungrap(from, to)
+register struct ship *from, *to;
 {
 {
-       int k;
+       register k;
+       char friend;
 
 
-       if(grapple(from, to)){
-               for (k = 0; k < 10; k++){
-                       if (scene[game].ship[from].file -> grapples[k].turnfoul && to == scene[game].ship[from].file -> grapples[k].toship && (die() < 3 || scene[game].ship[from].nationality == scene[game].ship[to].nationality)){
-                               cleangrapple(from, to, k);
-                               makesignal("ungrappling %s (%c%c)", to, from);
-                       }
+       if ((k = grappled2(from, to)) == 0)
+               return;
+       friend = capship(from)->nationality == capship(to)->nationality;
+       while (--k >= 0) {
+               if (friend || die() < 3) {
+                       cleangrapple(from, to, 0);
+                       makesignal(from, "ungrappling %s (%c%c)", to);
                }
        }
 }
 
 grap(from, to)
                }
        }
 }
 
 grap(from, to)
-int from,to;
+register struct ship *from, *to;
 {
 {
-       int number, captured, l;
-
-       if ((captured = scene[game].ship[to].file -> captured) < 0)
-               captured = to;
-       number = die() < 3;
-       if (!number && scene[game].ship[from].nationality == scene[game].ship[captured].nationality)
-               number = 1;
-       if (number){
-               for (l=0; l < 10 && scene[game].ship[from].file -> grapples[l].turnfoul; l++);
-               if (l < 10){
-                       Write(FILES + from, 0, 124 + l*4, turn);
-                       Write(FILES + from, 0, 124 + l*4 + 2, to);
-               }
-               for (l=0; l < 10 && scene[game].ship[to].file -> grapples[l].turnfoul; l++);
-               if (l < 10){
-                       Write(FILES + to, 0, 124 + l*4, turn);
-                       Write(FILES + to, 0, 124 + l*4 + 2, from);
-               }
-               makesignal("grappled with %s (%c%c)", to, from);
-       }
+       if (capship(from)->nationality != capship(to)->nationality && die() > 2)
+               return;
+       Write(W_GRAP, from, 0, to->file->index, 0, 0, 0);
+       Write(W_GRAP, to, 0, from->file->index, 0, 0, 0);
+       makesignal(from, "grappled with %s (%c%c)", to);
 }
 }
-
-