Annotation of 43BSDReno/games/trek/damage.c, revision 1.1.1.1

1.1       root        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 provided
                      6:  * that: (1) source distributions retain this entire copyright notice and
                      7:  * comment, and (2) distributions including binaries display the following
                      8:  * acknowledgement:  ``This product includes software developed by the
                      9:  * University of California, Berkeley and its contributors'' in the
                     10:  * documentation or other materials provided with the distribution and in
                     11:  * all advertising materials mentioning features or use of this software.
                     12:  * Neither the name of the University nor the names of its contributors may
                     13:  * be used to endorse or promote products derived from this software without
                     14:  * specific prior written permission.
                     15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     16:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     17:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     18:  */
                     19: 
                     20: #ifndef lint
                     21: static char sccsid[] = "@(#)damage.c   5.4 (Berkeley) 6/1/90";
                     22: #endif /* not lint */
                     23: 
                     24: # include      "trek.h"
                     25: 
                     26: /*
                     27: **  Schedule Ship.damages to a Device
                     28: **
                     29: **     Device `dev1' is damaged in an amount `dam'.  Dam is measured
                     30: **     in stardates, and is an additional amount of damage.  It should
                     31: **     be the amount to occur in non-docked mode.  The adjustment
                     32: **     to docked mode occurs automatically if we are docked.
                     33: **
                     34: **     Note that the repair of the device occurs on a DATE, meaning
                     35: **     that the dock() and undock() have to reschedule the event.
                     36: */
                     37: 
                     38: damage(dev1, dam)
                     39: int    dev1;           /*  device index */
                     40: double dam;            /* time to repair */
                     41: {
                     42:        register int            i;
                     43:        register struct event   *e;
                     44:        int                     f;
                     45:        register int            dev;
                     46: 
                     47:        /* ignore zero damages */
                     48:        if (dam <= 0.0)
                     49:                return;
                     50:        dev = dev1;
                     51: 
                     52:        printf("\t%s damaged\n", Device[dev].name);
                     53: 
                     54:        /* find actual length till it will be fixed */
                     55:        if (Ship.cond == DOCKED)
                     56:                dam *= Param.dockfac;
                     57:        /* set the damage flag */
                     58:        f = damaged(dev);
                     59:        if (!f)
                     60:        {
                     61:                /* new damages -- schedule a fix */
                     62:                schedule(E_FIXDV, dam, 0, 0, dev);
                     63:                return;
                     64:        }
                     65:        /* device already damaged -- add to existing damages */
                     66:        /* scan for old damages */
                     67:        for (i = 0; i < MAXEVENTS; i++)
                     68:        {
                     69:                e = &Event[i];
                     70:                if (e->evcode != E_FIXDV || e->systemname != dev)
                     71:                        continue;
                     72:                /* got the right one; add on the new damages */
                     73:                reschedule(e, e->date - Now.date + dam);
                     74:                return;
                     75:        }
                     76:        syserr("Cannot find old damages %d\n", dev);
                     77: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.