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