Str_New -> strdup
[unix-history] / usr / src / games / trek / warp.c
index dc90dab..3632895 100644 (file)
@@ -1,6 +1,23 @@
+/*
+ * Copyright (c) 1980 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[] = "@(#)warp.c     4.1     (Berkeley)      %G%";
-#endif not lint
+static char sccsid[] = "@(#)warp.c     5.3 (Berkeley) %G%";
+#endif /* not lint */
 
 # include      "trek.h"
 
 
 # include      "trek.h"
 
@@ -25,14 +42,14 @@ int fl, c;
 double d;
 {
        int                     course;
 double d;
 {
        int                     course;
-       float                   power;
-       float                   dist;
-       float                   time;
-       float                   speed;
+       double                  power;
+       double                  dist;
+       double                  time;
+       double                  speed;
        double                  frac;
        register int            percent;
        register int            i;
        double                  frac;
        register int            percent;
        register int            i;
-       extern float            move();
+       extern double           move();
 
        if (Ship.cond == DOCKED)
                return (printf("%s is docked\n", Ship.shipname));
 
        if (Ship.cond == DOCKED)
                return (printf("%s is docked\n", Ship.shipname));
@@ -78,8 +95,8 @@ double        d;
        if (Ship.warp > 6.0 && ranf(100) < 20 + 15 * (Ship.warp - 6.0))
        {
                frac = franf();
        if (Ship.warp > 6.0 && ranf(100) < 20 + 15 * (Ship.warp - 6.0))
        {
                frac = franf();
-               dist =* frac;
-               time =* frac;
+               dist *= frac;
+               time *= frac;
                damage(WARP, (frac + 1.0) * Ship.warp * (franf() + 0.25) * 0.20);
        }
 
                damage(WARP, (frac + 1.0) * Ship.warp * (franf() + 0.25) * 0.20);
        }
 
@@ -88,7 +105,7 @@ double       d;
 
        /* see how far we actually went, and decrement energy appropriately */
        dist = Move.time * speed;
 
        /* see how far we actually went, and decrement energy appropriately */
        dist = Move.time * speed;
-       Ship.energy =- dist * Ship.warp3 * (Ship.shldup + 1);
+       Ship.energy -= dist * Ship.warp3 * (Ship.shldup + 1);
 
        /* test for bizarre events */
        if (Ship.warp <= 9.0)
 
        /* test for bizarre events */
        if (Ship.warp <= 9.0)
@@ -113,24 +130,24 @@ double    d;
                {
                        /* positive time warp */
                        time = (Ship.warp - 8.0) * dist * (franf() + 1.0);
                {
                        /* positive time warp */
                        time = (Ship.warp - 8.0) * dist * (franf() + 1.0);
-                       Now.date =+ time;
+                       Now.date += time;
                        printf("Positive time portal entered -- it is now Stardate %.2f\n",
                                Now.date);
                        for (i = 0; i < MAXEVENTS; i++)
                        {
                                percent = Event[i].evcode;
                                if (percent == E_FIXDV || percent == E_LRTB)
                        printf("Positive time portal entered -- it is now Stardate %.2f\n",
                                Now.date);
                        for (i = 0; i < MAXEVENTS; i++)
                        {
                                percent = Event[i].evcode;
                                if (percent == E_FIXDV || percent == E_LRTB)
-                                       Event[i].date =+ time;
+                                       Event[i].date += time;
                        }
                        return;
                }
 
                /* s/he got lucky: a negative time portal */
                time = Now.date;
                        }
                        return;
                }
 
                /* s/he got lucky: a negative time portal */
                time = Now.date;
-               i = Etc.snapshot;
-               bmove(i, &Quad, sizeof Quad);
-               bmove(i =+ sizeof Quad, &Event, sizeof Event);
-               bmove(i =+ sizeof Event, &Now, sizeof Now);
+               i = (int) Etc.snapshot;
+               bmove(i, Quad, sizeof Quad);
+               bmove(i += sizeof Quad, Event, sizeof Event);
+               bmove(i += sizeof Event, &Now, sizeof Now);
                printf("Negative time portal entered -- it is now Stardate %.2f\n",
                        Now.date);
                for (i = 0; i < MAXEVENTS; i++)
                printf("Negative time portal entered -- it is now Stardate %.2f\n",
                        Now.date);
                for (i = 0; i < MAXEVENTS; i++)