Annotation of 43BSDTahoe/games/trek/dock.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
                      6:  * provided that the above copyright notice and this paragraph are
                      7:  * duplicated in all such forms and that any documentation,
                      8:  * advertising materials, and other materials related to such
                      9:  * distribution and use acknowledge that the software was developed
                     10:  * by the University of California, Berkeley.  The name of the
                     11:  * University may not be used to endorse or promote products derived
                     12:  * from this software without specific prior written permission.
                     13:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     14:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     15:  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     16:  */
                     17: 
                     18: #ifndef lint
                     19: static char sccsid[] = "@(#)dock.c     5.3 (Berkeley) 6/18/88";
                     20: #endif /* not lint */
                     21: 
                     22: # include      "trek.h"
                     23: 
                     24: /*
                     25: **  DOCK TO STARBASE
                     26: **
                     27: **     The starship is docked to a starbase.  For this to work you
                     28: **     must be adjacent to a starbase.
                     29: **
                     30: **     You get your supplies replenished and your captives are
                     31: **     disembarked.  Note that your score is updated now, not when
                     32: **     you actually take the captives.
                     33: **
                     34: **     Any repairs that need to be done are rescheduled to take
                     35: **     place sooner.  This provides for the faster repairs when you
                     36: **     are docked.
                     37: */
                     38: 
                     39: dock()
                     40: {
                     41:        register int            i, j;
                     42:        int                     ok;
                     43:        register struct event   *e;
                     44: 
                     45:        if (Ship.cond == DOCKED)
                     46:                return (printf("Chekov: But captain, we are already docked\n"));
                     47:        /* check for ok to dock, i.e., adjacent to a starbase */
                     48:        ok = 0;
                     49:        for (i = Ship.sectx - 1; i <= Ship.sectx + 1 && !ok; i++)
                     50:        {
                     51:                if (i < 0 || i >= NSECTS)
                     52:                        continue;
                     53:                for (j = Ship.secty - 1; j <= Ship.secty + 1; j++)
                     54:                {
                     55:                        if (j  < 0 || j >= NSECTS)
                     56:                                continue;
                     57:                        if (Sect[i][j] == BASE)
                     58:                        {
                     59:                                ok++;
                     60:                                break;
                     61:                        }
                     62:                }
                     63:        }
                     64:        if (!ok)
                     65:                return (printf("Chekov: But captain, we are not adjacent to a starbase.\n"));
                     66: 
                     67:        /* restore resources */
                     68:        Ship.energy = Param.energy;
                     69:        Ship.torped = Param.torped;
                     70:        Ship.shield = Param.shield;
                     71:        Ship.crew = Param.crew;
                     72:        Game.captives += Param.brigfree - Ship.brigfree;
                     73:        Ship.brigfree = Param.brigfree;
                     74: 
                     75:        /* reset ship's defenses */
                     76:        Ship.shldup = 0;
                     77:        Ship.cloaked = 0;
                     78:        Ship.cond = DOCKED;
                     79:        Ship.reserves = Param.reserves;
                     80: 
                     81:        /* recalibrate space inertial navigation system */
                     82:        Ship.sinsbad = 0;
                     83: 
                     84:        /* output any saved radio messages */
                     85:        dumpssradio();
                     86: 
                     87:        /* reschedule any device repairs */
                     88:        for (i = 0; i < MAXEVENTS; i++)
                     89:        {
                     90:                e = &Event[i];
                     91:                if (e->evcode != E_FIXDV)
                     92:                        continue;
                     93:                reschedule(e, (e->date - Now.date) * Param.dockfac);
                     94:        }
                     95:        return;
                     96: }
                     97: 
                     98: 
                     99: /*
                    100: **  LEAVE A STARBASE
                    101: **
                    102: **     This is the inverse of dock().  The main function it performs
                    103: **     is to reschedule any damages so that they will take longer.
                    104: */
                    105: 
                    106: undock()
                    107: {
                    108:        register struct event   *e;
                    109:        register int            i;
                    110: 
                    111:        if (Ship.cond != DOCKED)
                    112:        {
                    113:                printf("Sulu: Pardon me captain, but we are not docked.\n");
                    114:                return;
                    115:        }
                    116:        Ship.cond = GREEN;
                    117:        Move.free = 0;
                    118: 
                    119:        /* reschedule device repair times (again) */
                    120:        for (i = 0; i < MAXEVENTS; i++)
                    121:        {
                    122:                e = &Event[i];
                    123:                if (e->evcode != E_FIXDV)
                    124:                        continue;
                    125:                reschedule(e, (e->date - Now.date) / Param.dockfac);
                    126:        }
                    127:        return;
                    128: }

unix.superglobalmegacorp.com

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