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