Home | History | Annotate | Line # | Download | only in trek
dcrept.c revision 1.4
      1 /*	$NetBSD: dcrept.c,v 1.4 1997/10/12 21:24:38 christos Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1980, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *	This product includes software developed by the University of
     18  *	California, Berkeley and its contributors.
     19  * 4. Neither the name of the University nor the names of its contributors
     20  *    may be used to endorse or promote products derived from this software
     21  *    without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  * SUCH DAMAGE.
     34  */
     35 
     36 #include <sys/cdefs.h>
     37 #ifndef lint
     38 #if 0
     39 static char sccsid[] = "@(#)dcrept.c	8.1 (Berkeley) 5/31/93";
     40 #else
     41 __RCSID("$NetBSD: dcrept.c,v 1.4 1997/10/12 21:24:38 christos Exp $");
     42 #endif
     43 #endif /* not lint */
     44 
     45 #include <stdio.h>
     46 #include "trek.h"
     47 
     48 /*
     49 **  damage control report
     50 **
     51 **	Print damages and time to fix.  This is taken from the event
     52 **	list.  A couple of factors are set up, based on whether or not
     53 **	we are docked.  (One of these factors will always be 1.0.)
     54 **	The event list is then scanned for damage fix events, the
     55 **	time until they occur is determined, and printed out.  The
     56 **	magic number DAMFAC is used to tell how much faster you can
     57 **	fix things if you are docked.
     58 */
     59 
     60 /*ARGSUSED*/
     61 void
     62 dcrept(v)
     63 	int v;
     64 {
     65 	int		i, f;
     66 	double		x;
     67 	double		m1, m2;
     68 	struct event	*e;
     69 
     70 	/* set up the magic factors to output the time till fixed */
     71 	if (Ship.cond == DOCKED)
     72 	{
     73 		m1 = 1.0 / Param.dockfac;
     74 		m2 = 1.0;
     75 	}
     76 	else
     77 	{
     78 		m1 = 1.0;
     79 		m2 = Param.dockfac;
     80 	}
     81 	printf("Damage control report:\n");
     82 	f = 1;
     83 
     84 	/* scan for damages */
     85 	for (i = 0; i < MAXEVENTS; i++)
     86 	{
     87 		e = &Event[i];
     88 		if (e->evcode != E_FIXDV)
     89 			continue;
     90 
     91 		/* output the title first time */
     92 		if (f)
     93 		{
     94 			printf("\t\t\t  repair times\n");
     95 			printf("device\t\t\tin flight  docked\n");
     96 			f = 0;
     97 		}
     98 
     99 		/* compute time till fixed, then adjust by the magic factors */
    100 		x = e->date - Now.date;
    101 		printf("%-24s%7.2f  %7.2f\n",
    102 			Device[e->systemname].name, x * m1 + 0.005, x * m2 + 0.005);
    103 
    104 		/* do a little consistancy checking */
    105 	}
    106 
    107 	/* if everything was ok, reassure the nervous captain */
    108 	if (f)
    109 		printf("All devices functional\n");
    110 }
    111