1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)damage.c	5.1 (Berkeley) 5/30/85";
   9: #endif not lint
  10: 
  11: # include   "trek.h"
  12: 
  13: /*
  14: **  Schedule Ship.damages to a Device
  15: **
  16: **	Device `dev1' is damaged in an amount `dam'.  Dam is measured
  17: **	in stardates, and is an additional amount of damage.  It should
  18: **	be the amount to occur in non-docked mode.  The adjustment
  19: **	to docked mode occurs automatically if we are docked.
  20: **
  21: **	Note that the repair of the device occurs on a DATE, meaning
  22: **	that the dock() and undock() have to reschedule the event.
  23: */
  24: 
  25: damage(dev1, dam)
  26: int dev1;       /*  device index */
  27: double  dam;        /* time to repair */
  28: {
  29:     register int        i;
  30:     register struct event   *e;
  31:     int         f;
  32:     register int        dev;
  33: 
  34:     /* ignore zero damages */
  35:     if (dam <= 0.0)
  36:         return;
  37:     dev = dev1;
  38: 
  39:     printf("\t%s damaged\n", Device[dev].name);
  40: 
  41:     /* find actual length till it will be fixed */
  42:     if (Ship.cond == DOCKED)
  43:         dam *= Param.dockfac;
  44:     /* set the damage flag */
  45:     f = damaged(dev);
  46:     if (!f)
  47:     {
  48:         /* new damages -- schedule a fix */
  49:         schedule(E_FIXDV, dam, 0, 0, dev);
  50:         return;
  51:     }
  52:     /* device already damaged -- add to existing damages */
  53:     /* scan for old damages */
  54:     for (i = 0; i < MAXEVENTS; i++)
  55:     {
  56:         e = &Event[i];
  57:         if (e->evcode != E_FIXDV || e->systemname != dev)
  58:             continue;
  59:         /* got the right one; add on the new damages */
  60:         reschedule(e, e->date - Now.date + dam);
  61:         return;
  62:     }
  63:     syserr("Cannot find old damages %d\n", dev);
  64: }

Defined functions

Defined variables

sccsid defined in line 8; never used
Last modified: 1985-05-30
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2045
Valid CSS Valid XHTML 1.0 Strict