1 /* @(#)dock.c 8.1 (Berkeley) 5/31/93 */
2 /* $NetBSD: dock.c,v 1.10 2009/05/24 22:55:03 dholland Exp $ */
5 * Copyright (c) 1980, 1993
6 * The Regents of the University of California. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 ** The starship is docked to a starbase. For this to work you
40 ** must be adjacent to a starbase.
42 ** You get your supplies replenished and your captives are
43 ** disembarked. Note that your score is updated now, not when
44 ** you actually take the captives.
46 ** Any repairs that need to be done are rescheduled to take
47 ** place sooner. This provides for the faster repairs when you
59 if (Ship.cond == DOCKED) {
60 printf("Chekov: But captain, we are already docked\n");
63 /* check for ok to dock, i.e., adjacent to a starbase */
65 for (i = Ship.sectx - 1; i <= Ship.sectx + 1 && !ok; i++) {
66 if (i < 0 || i >= NSECTS)
68 for (j = Ship.secty - 1; j <= Ship.secty + 1; j++) {
69 if (j < 0 || j >= NSECTS)
71 if (Sect[i][j] == BASE) {
78 printf("Chekov: But captain, we are not adjacent to a "
83 /* restore resources */
84 Ship.energy = Param.energy;
85 Ship.torped = Param.torped;
86 Ship.shield = Param.shield;
87 Ship.crew = Param.crew;
88 Game.captives += Param.brigfree - Ship.brigfree;
89 Ship.brigfree = Param.brigfree;
91 /* reset ship's defenses */
95 Ship.reserves = Param.reserves;
97 /* recalibrate space inertial navigation system */
100 /* output any saved radio messages */
103 /* reschedule any device repairs */
104 for (i = 0; i < MAXEVENTS; i++) {
106 if (e->evcode != E_FIXDV)
108 reschedule(e, (e->date - Now.date) * Param.dockfac);
117 ** This is the inverse of dock(). The main function it performs
118 ** is to reschedule any damages so that they will take longer.
123 undock(int v __unused)
128 if (Ship.cond != DOCKED) {
129 printf("Sulu: Pardon me captain, but we are not docked.\n");
135 /* reschedule device repair times (again) */
136 for (i = 0; i < MAXEVENTS; i++) {
138 if (e->evcode != E_FIXDV)
140 reschedule(e, (e->date - Now.date) / Param.dockfac);