/usr/games often isn't in root's path
[unix-history] / usr / src / games / trek / dcrept.c
CommitLineData
b6f0a7e4
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
e9fb6bea
KB
3 * All rights reserved.
4 *
b2e7427f 5 * %sccs.include.redist.c%
b6f0a7e4
DF
6 */
7
7f24e2d8 8#ifndef lint
b2e7427f 9static char sccsid[] = "@(#)dcrept.c 5.4 (Berkeley) %G%";
e9fb6bea 10#endif /* not lint */
7f24e2d8
KM
11
12# include "trek.h"
13
14/*
15** damage control report
16**
17** Print damages and time to fix. This is taken from the event
18** list. A couple of factors are set up, based on whether or not
19** we are docked. (One of these factors will always be 1.0.)
20** The event list is then scanned for damage fix events, the
21** time until they occur is determined, and printed out. The
22** magic number DAMFAC is used to tell how much faster you can
23** fix things if you are docked.
24*/
25
26dcrept()
27{
28 register int i, f;
06d69904
KL
29 double x;
30 double m1, m2;
7f24e2d8
KM
31 register struct event *e;
32
33 /* set up the magic factors to output the time till fixed */
34 if (Ship.cond == DOCKED)
35 {
36 m1 = 1.0 / Param.dockfac;
37 m2 = 1.0;
38 }
39 else
40 {
41 m1 = 1.0;
42 m2 = Param.dockfac;
43 }
44 printf("Damage control report:\n");
45 f = 1;
46
47 /* scan for damages */
48 for (i = 0; i < MAXEVENTS; i++)
49 {
50 e = &Event[i];
51 if (e->evcode != E_FIXDV)
52 continue;
53
54 /* output the title first time */
55 if (f)
56 {
57 printf("\t\t\t repair times\n");
58 printf("device\t\t\tin flight docked\n");
59 f = 0;
60 }
61
62 /* compute time till fixed, then adjust by the magic factors */
63 x = e->date - Now.date;
64 printf("%-24s%7.2f %7.2f\n",
65 Device[e->systemname].name, x * m1 + 0.005, x * m2 + 0.005);
66
67 /* do a little consistancy checking */
68 }
69
70 /* if everything was ok, reassure the nervous captain */
71 if (f)
72 printf("All devices functional\n");
73}