xref: /original-bsd/games/trek/dumpme.c (revision 5d3a6356)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of California at Berkeley. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  */
12 
13 #ifndef lint
14 static char sccsid[] = "@(#)dumpme.c	5.2 (Berkeley) 05/05/88";
15 #endif /* not lint */
16 
17 # include	"trek.h"
18 
19 /*
20 **  Dump the starship somewhere in the galaxy
21 **
22 **	Parameter is zero if bounce off of negative energy barrier,
23 **	one if through a black hole
24 **
25 **	Note that the quadrant is NOT initialized here.  This must
26 **	be done from the calling routine.
27 **
28 **	Repair of devices must be deferred.
29 */
30 
31 dumpme(flag)
32 int	flag;
33 {
34 	register int		f;
35 	double			x;
36 	register struct event	*e;
37 	register int		i;
38 
39 	f = flag;
40 	Ship.quadx = ranf(NQUADS);
41 	Ship.quady = ranf(NQUADS);
42 	Ship.sectx = ranf(NSECTS);
43 	Ship.secty = ranf(NSECTS);
44 	x += 1.5 * franf();
45 	Move.time += x;
46 	if (f)
47 	{
48 		printf("%s falls into a black hole.\n", Ship.shipname);
49 	}
50 	else
51 	{
52 		printf("Computer applies full reverse power to avoid hitting the\n");
53 		printf("   negative energy barrier.  A space warp was entered.\n");
54 	}
55 	/* bump repair dates forward */
56 	for (i = 0; i < MAXEVENTS; i++)
57 	{
58 		e = &Event[i];
59 		if (e->evcode != E_FIXDV)
60 			continue;
61 		reschedule(e, (e->date - Now.date) + x);
62 	}
63 	events(1);
64 	printf("You are now in quadrant %d,%d.  It is stardate %.2f\n",
65 		Ship.quadx, Ship.quady, Now.date);
66 	Move.time = 0;
67 }
68