+/* $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
** 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;
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 */
/* 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++)