prints stats wrong way round
[unix-history] / usr / src / games / sail / dr_2.c
index 9d1c518..97c9583 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)dr_2.c      1.2 83/07/20";
+static char *sccsid = "@(#)dr_2.c      2.5 84/01/19";
 #endif
 
 #include "driver.h"
 #endif
 
 #include "driver.h"
@@ -38,35 +38,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) {
@@ -81,21 +69,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);
                }
        }
 }
                }
        }
 }
@@ -130,7 +114,8 @@ char movement[];
 register struct ship *ship, *to;
 char onlytemp;
 {
 register struct ship *ship, *to;
 char onlytemp;
 {
-       int drift, row, col, dir, total, ran;
+       char drift;
+       int row, col, dir, total, ran;
        register struct File *fp = ship->file;
 
        if ((dir = fp->dir) == 0)
        register struct File *fp = ship->file;
 
        if ((dir = fp->dir) == 0)
@@ -157,33 +142,12 @@ char onlytemp;
        return total;
 }
 
        return total;
 }
 
-moveship(ship, movement)
-struct ship *ship;
-char *movement;
-{
-       int drift;
-       register struct File *fp = ship->file;
-
-       if (fp->dir == 0)
-               return;
-       drift = fp->drift;
-       move(movement, ship, &fp->dir, &fp->row, &fp->col, &drift);
-       if (drift > 2 || *movement == 0)
-               (void) strcat(movement, "d");
-       if (drift != fp->drift)
-               Write(W_DRIFT, ship, 0, drift, 0, 0, 0);
-       if (fp->row != ship->shiprow)
-               Write(W_SHIPROW, ship, 0, fp->row, 0, 0, 0);
-       if (fp->col != ship->shipcol)
-               Write(W_SHIPCOL, ship, 0, fp->col, 0, 0, 0);
-       if (fp->dir != ship->shipdir)
-               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;
-register int *dir, *row, *col, *drift;
+register char *dir;
+register short *row, *col;
+register char *drift;
 {
        int dist;
        char moved = 0;
 {
        int dist;
        char moved = 0;
@@ -215,13 +179,13 @@ register int *dir, *row, *col, *drift;
        if (!moved) {
                if (++*drift > 2) {
                        if (ship->specs->class >= 3 && !snagged(ship)
        if (!moved) {
                if (++*drift > 2) {
                        if (ship->specs->class >= 3 && !snagged(ship)
-                           || turn % 2 == 0) {
+                           || (turn & 1) == 0) {
                                *row -= dr[winddir];
                                *col -= dc[winddir];
                        }
                }
        } else
                                *row -= dr[winddir];
                                *col -= dc[winddir];
                        }
                }
        } else
-               drift = 0;
+               *drift = 0;
 }
 
 try(command, temp, ma, ta, af, vma, dir, f, t, high, rakeme)
 }
 
 try(command, temp, ma, ta, af, vma, dir, f, t, high, rakeme)
@@ -267,3 +231,14 @@ char command[], temp[];
                rmend(temp);
        }
 }
                rmend(temp);
        }
 }
+
+rmend(str)
+char *str;
+{
+       register char *p;
+
+       for (p = str; *p; p++)
+               ;
+       if (p != str)
+               *--p = 0;
+}