return some value from dr_main() (mostly for lint)
[unix-history] / usr / src / games / sail / dr_2.c
index 5b8c186..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.1 83/10/31";
+static char *sccsid = "@(#)dr_2.c      2.7 85/04/23";
 #endif
 
 #include "driver.h"
 #endif
 
 #include "driver.h"
@@ -38,37 +44,23 @@ thinkofgrapples()
 
 checkup()
 {
 
 checkup()
 {
-       register int k;
        register struct ship *sp, *sq;
        register char explode, sink;
 
        register struct ship *sp, *sq;
        register char explode, sink;
 
-       /*
-       readpos();
-       */
        foreachship(sp) {
        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);
-               sp->file->dir = 0;      /* hopefully enough to kill ship */
-               /* Write(n, 0, 10, 0); XXX */
-               Write(W_CLASS, 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) {
@@ -83,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);
                }
        }
 }
                }
        }
 }
@@ -160,31 +148,6 @@ char onlytemp;
        return total;
 }
 
        return total;
 }
 
-moveship(ship, movement)
-struct ship *ship;
-char *movement;
-{
-       register struct File *fp = ship->file;
-       char drift = fp->drift;
-       int row = fp->row;
-       int col = fp->col;
-       int dir = fp->dir;
-
-       if (fp->dir == 0)
-               return;
-       move(movement, ship, &fp->dir, &fp->row, &fp->col, &drift);
-       if (drift > 2 || *movement == 0)
-               (void) strcat(movement, "d");
-       if (fp->drift != drift)
-               Write(W_DRIFT, ship, 0, drift, 0, 0, 0);
-       if (fp->row != row)
-               Write(W_SHIPROW, ship, 0, fp->row, 0, 0, 0);
-       if (fp->col != col)
-               Write(W_SHIPCOL, ship, 0, fp->col, 0, 0, 0);
-       if (fp->dir != dir)
-               Write(W_SHIPDIR, ship, 0, fp->dir, 0, 0, 0);
-}
-
 move(p, ship, dir, row, col, drift)
 register char *p;
 register struct ship *ship;
 move(p, ship, dir, row, col, drift)
 register char *p;
 register struct ship *ship;
@@ -217,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];