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[] = "@(#)dock.c	5.1 (Berkeley) 5/30/85";
   9: #endif not lint
  10: 
  11: # include   "trek.h"
  12: 
  13: /*
  14: **  DOCK TO STARBASE
  15: **
  16: **	The starship is docked to a starbase.  For this to work you
  17: **	must be adjacent to a starbase.
  18: **
  19: **	You get your supplies replenished and your captives are
  20: **	disembarked.  Note that your score is updated now, not when
  21: **	you actually take the captives.
  22: **
  23: **	Any repairs that need to be done are rescheduled to take
  24: **	place sooner.  This provides for the faster repairs when you
  25: **	are docked.
  26: */
  27: 
  28: dock()
  29: {
  30:     register int        i, j;
  31:     int         ok;
  32:     register struct event   *e;
  33: 
  34:     if (Ship.cond == DOCKED)
  35:         return (printf("Chekov: But captain, we are already docked\n"));
  36:     /* check for ok to dock, i.e., adjacent to a starbase */
  37:     ok = 0;
  38:     for (i = Ship.sectx - 1; i <= Ship.sectx + 1 && !ok; i++)
  39:     {
  40:         if (i < 0 || i >= NSECTS)
  41:             continue;
  42:         for (j = Ship.secty - 1; j <= Ship.secty + 1; j++)
  43:         {
  44:             if (j  < 0 || j >= NSECTS)
  45:                 continue;
  46:             if (Sect[i][j] == BASE)
  47:             {
  48:                 ok++;
  49:                 break;
  50:             }
  51:         }
  52:     }
  53:     if (!ok)
  54:         return (printf("Chekov: But captain, we are not adjacent to a starbase.\n"));
  55: 
  56:     /* restore resources */
  57:     Ship.energy = Param.energy;
  58:     Ship.torped = Param.torped;
  59:     Ship.shield = Param.shield;
  60:     Ship.crew = Param.crew;
  61:     Game.captives += Param.brigfree - Ship.brigfree;
  62:     Ship.brigfree = Param.brigfree;
  63: 
  64:     /* reset ship's defenses */
  65:     Ship.shldup = 0;
  66:     Ship.cloaked = 0;
  67:     Ship.cond = DOCKED;
  68:     Ship.reserves = Param.reserves;
  69: 
  70:     /* recalibrate space inertial navigation system */
  71:     Ship.sinsbad = 0;
  72: 
  73:     /* output any saved radio messages */
  74:     dumpssradio();
  75: 
  76:     /* reschedule any device repairs */
  77:     for (i = 0; i < MAXEVENTS; i++)
  78:     {
  79:         e = &Event[i];
  80:         if (e->evcode != E_FIXDV)
  81:             continue;
  82:         reschedule(e, (e->date - Now.date) * Param.dockfac);
  83:     }
  84:     return;
  85: }
  86: 
  87: 
  88: /*
  89: **  LEAVE A STARBASE
  90: **
  91: **	This is the inverse of dock().  The main function it performs
  92: **	is to reschedule any damages so that they will take longer.
  93: */
  94: 
  95: undock()
  96: {
  97:     register struct event   *e;
  98:     register int        i;
  99: 
 100:     if (Ship.cond != DOCKED)
 101:     {
 102:         printf("Sulu: Pardon me captain, but we are not docked.\n");
 103:         return;
 104:     }
 105:     Ship.cond = GREEN;
 106:     Move.free = 0;
 107: 
 108:     /* reschedule device repair times (again) */
 109:     for (i = 0; i < MAXEVENTS; i++)
 110:     {
 111:         e = &Event[i];
 112:         if (e->evcode != E_FIXDV)
 113:             continue;
 114:         reschedule(e, (e->date - Now.date) / Param.dockfac);
 115:     }
 116:     return;
 117: }

Defined functions

undock defined in line 95; used 3 times

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: 2239
Valid CSS Valid XHTML 1.0 Strict