]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - trek/warp.c
Curses works - define USE_CURSES for BSD44 and don't try to do our own
[bsdgames-darwin.git] / trek / warp.c
index 0b78b5e2490131574504ecf021ba994b63d980f1..d221d965646e7ca1d89e8cbd44715a43064e09a6 100644 (file)
@@ -1,6 +1,8 @@
+/*     $NetBSD: warp.c,v 1.6 1998/09/11 14:28:28 hubertf Exp $ */
+
 /*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
 #ifndef lint
-/*static char sccsid[] = "from: @(#)warp.c     5.4 (Berkeley) 6/1/90";*/
-static char rcsid[] = "$Id: warp.c,v 1.2 1993/08/01 18:49:52 mycroft Exp $";
+#if 0
+static char sccsid[] = "@(#)warp.c     8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: warp.c,v 1.6 1998/09/11 14:28:28 hubertf Exp $");
+#endif
 #endif /* not lint */
 
-# include      "trek.h"
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+#include <unistd.h>
+#include "trek.h"
+#include "getpar.h"
 
 /*
 **  MOVE UNDER WARP POWER
@@ -54,34 +65,45 @@ static char rcsid[] = "$Id: warp.c,v 1.2 1993/08/01 18:49:52 mycroft Exp $";
 **     case, there is code to handle time warps, etc.
 */
 
+void
+dowarp(fl)
+       int fl;
+{
+       int c;
+       double d;
+
+       if (getcodi(&c, &d))
+               return;
+       warp(fl, c, d);
+}
+
+void
 warp(fl, c, d)
 int    fl, c;
 double d;
 {
-       int                     course;
-       double                  power;
-       double                  dist;
-       double                  time;
-       double                  speed;
-       double                  frac;
-       register int            percent;
-       register int            i;
-       extern double           move();
-
-       if (Ship.cond == DOCKED)
-               return (printf("%s is docked\n", Ship.shipname));
-       if (damaged(WARP))
-       {
-               return (out(WARP));
+       char           *p;
+       int             course;
+       double          power;
+       double          dist;
+       double          time;
+       double          speed;
+       double          frac;
+       int             percent;
+       int             i;
+
+       if (Ship.cond == DOCKED) {
+               printf("%s is docked\n", Ship.shipname);
+               return;
        }
-       if (fl < 0)
+       if (damaged(WARP))
        {
-               course = c;
-               dist = d;
+               out(WARP);
+               return;
        }
-       else
-               if (getcodi(&course, &dist))
-                       return;
+
+       course = c;
+       dist = d;
 
        /* check to see that we are not using an absurd amount of power */
        power = (dist + 0.05) * Ship.warp3;
@@ -135,7 +157,8 @@ double      d;
        sleep(4);
        if (ranf(100) >= 100 * dist)
        {
-               return (printf("Equilibrium restored -- all systems normal\n"));
+               printf("Equilibrium restored -- all systems normal\n");
+               return;
        }
 
        /* select a bizzare thing to happen to us */
@@ -161,10 +184,12 @@ double    d;
 
                /* s/he got lucky: a negative time portal */
                time = Now.date;
-               i = (int) Etc.snapshot;
-               bmove(i, Quad, sizeof Quad);
-               bmove(i += sizeof Quad, Event, sizeof Event);
-               bmove(i += sizeof Event, &Now, sizeof Now);
+               p = (char *) Etc.snapshot;
+               memcpy(p, Quad, sizeof Quad);
+               p += sizeof Quad;
+               memcpy(p, Event, sizeof Event);
+               p += sizeof Event;
+               memcpy(p, &Now, sizeof Now);
                printf("Negative time portal entered -- it is now Stardate %.2f\n",
                        Now.date);
                for (i = 0; i < MAXEVENTS; i++)