return some value from dr_main() (mostly for lint)
[unix-history] / usr / src / games / sail / dr_2.c
index f95ccba..16284a8 100644 (file)
@@ -1,5 +1,11 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California,
+ * All rights reserved.  Redistribution permitted subject to
+ * the terms of the Berkeley Software License Agreement.
+ */
+
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)dr_2.c      2.2 83/12/12";
+static char *sccsid = "@(#)dr_2.c      2.7 85/04/23";
 #endif
 
 #include "driver.h"
 #endif
 
 #include "driver.h"
@@ -38,32 +44,23 @@ thinkofgrapples()
 
 checkup()
 {
 
 checkup()
 {
-       register int k;
        register struct ship *sp, *sq;
        register char explode, sink;
 
        foreachship(sp) {
        register struct ship *sp, *sq;
        register char explode, sink;
 
        foreachship(sp) {
+               if (sp->file->dir == 0)
+                       continue;
                explode = sp->file->explode;
                sink = sp->file->sink;
                explode = sp->file->explode;
                sink = sp->file->sink;
-               if (die() < 5)
-                       continue;
                if (explode != 1 && sink != 1)
                        continue;
                if (explode != 1 && sink != 1)
                        continue;
-               Write(sink ? W_SINK : W_EXPLODE, sp, 0, 2, 0, 0, 0);
-               Write(W_SHIPDIR, sp, 0, 0, 0, 0, 0);
-               if (fouled(sp) || grappled(sp)) {
-                       for (k = 0; k < NSHIP; k++) {
-                               if (sp->file->fouls[k].turnfoul)
-                                       cleanfoul(sp,
-                                               sp->file->fouls[k].toship, k);
-                       }
-                       for (k = 0; k < NSHIP; k++) {
-                               if (sp->file->grapples[k].turnfoul)
-                                       cleangrapple(sp,
-                                               sp->file->grapples[k].toship,
-                                               k);
-                       }
-               }
+               if (die() < 5)
+                       continue;
+               Write(sink == 1 ? W_SINK : W_EXPLODE, sp, 0, 2, 0, 0, 0);
+               Write(W_DIR, sp, 0, 0, 0, 0, 0);
+               if (snagged(sp))
+                       foreachship(sq)
+                               cleansnag(sp, sq, 1);
                if (sink != 1) {
                        makesignal(sp, "exploding!", (struct ship *)0);
                        foreachship(sq) {
                if (sink != 1) {
                        makesignal(sp, "exploding!", (struct ship *)0);
                        foreachship(sq) {
@@ -78,21 +75,17 @@ checkup()
 prizecheck()
 {
        register struct ship *sp;
 prizecheck()
 {
        register struct ship *sp;
-       register int prisoners, points;
 
        foreachship(sp) {
                if (sp->file->captured == 0)
                        continue;
                if (sp->file->struck || sp->file->dir == 0)
                        continue;
 
        foreachship(sp) {
                if (sp->file->captured == 0)
                        continue;
                if (sp->file->struck || sp->file->dir == 0)
                        continue;
-               prisoners = sp->specs->crew1 + sp->specs->crew2 + sp->specs->crew3;
-               if (prisoners > sp->file->pcrew * 6) {
-                       Write(W_CAPTURED, sp, 0, -1, 0, 0, 0);
+               if (sp->specs->crew1 + sp->specs->crew2 + sp->specs->crew3 > sp->file->pcrew * 6) {
                        Write(W_SIGNAL, sp, 1,
                                (int)"prize crew overthrown", 0, 0, 0);
                        Write(W_SIGNAL, sp, 1,
                                (int)"prize crew overthrown", 0, 0, 0);
-                       points = sp->file->captured->file->points
-                               - 2 * sp->specs->pts;
-                       Write(W_POINTS, sp->file->captured, 0, points, 0, 0, 0);
+                       Write(W_POINTS, sp->file->captured, 0, sp->file->captured->file->points - 2 * sp->specs->pts, 0, 0, 0);
+                       Write(W_CAPTURED, sp, 0, -1, 0, 0, 0);
                }
        }
 }
                }
        }
 }
@@ -187,10 +180,8 @@ register char *drift;
                        break;
                }
        }
                        break;
                }
        }
-       if (!windspeed)
-               *drift = 1;
        if (!moved) {
        if (!moved) {
-               if (++*drift > 2) {
+               if (windspeed != 0 && ++*drift > 2) {
                        if (ship->specs->class >= 3 && !snagged(ship)
                            || (turn & 1) == 0) {
                                *row -= dr[winddir];
                        if (ship->specs->class >= 3 && !snagged(ship)
                            || (turn & 1) == 0) {
                                *row -= dr[winddir];