srscan.c revision 1.2 1 1.1 cgd /*
2 1.1 cgd * Copyright (c) 1980 Regents of the University of California.
3 1.1 cgd * All rights reserved.
4 1.1 cgd *
5 1.1 cgd * Redistribution and use in source and binary forms, with or without
6 1.1 cgd * modification, are permitted provided that the following conditions
7 1.1 cgd * are met:
8 1.1 cgd * 1. Redistributions of source code must retain the above copyright
9 1.1 cgd * notice, this list of conditions and the following disclaimer.
10 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer in the
12 1.1 cgd * documentation and/or other materials provided with the distribution.
13 1.1 cgd * 3. All advertising materials mentioning features or use of this software
14 1.1 cgd * must display the following acknowledgement:
15 1.1 cgd * This product includes software developed by the University of
16 1.1 cgd * California, Berkeley and its contributors.
17 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
18 1.1 cgd * may be used to endorse or promote products derived from this software
19 1.1 cgd * without specific prior written permission.
20 1.1 cgd *
21 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 1.1 cgd * SUCH DAMAGE.
32 1.1 cgd */
33 1.1 cgd
34 1.1 cgd #ifndef lint
35 1.2 mycroft /*static char sccsid[] = "from: @(#)srscan.c 5.4 (Berkeley) 6/1/90";*/
36 1.2 mycroft static char rcsid[] = "$Id: srscan.c,v 1.2 1993/08/01 18:49:56 mycroft Exp $";
37 1.1 cgd #endif /* not lint */
38 1.1 cgd
39 1.1 cgd # include "trek.h"
40 1.1 cgd # include "getpar.h"
41 1.1 cgd
42 1.1 cgd /*
43 1.1 cgd ** SHORT RANGE SENSOR SCAN
44 1.1 cgd **
45 1.1 cgd ** A short range scan is taken of the current quadrant. If the
46 1.1 cgd ** flag 'f' is one, it is an "auto srscan", which is not done
47 1.1 cgd ** unless in 'fast' mode. It does a status report and a srscan.
48 1.1 cgd ** If 'f' is -1, you get a status report only. If it is zero,
49 1.1 cgd ** you get a srscan and an optional status report. The status
50 1.1 cgd ** report is taken if you enter "srscan yes"; for all srscans
51 1.1 cgd ** thereafter you get a status report with your srscan until
52 1.1 cgd ** you type "srscan no". It defaults to on.
53 1.1 cgd **
54 1.1 cgd ** The current quadrant is filled in on the computer chart.
55 1.1 cgd */
56 1.1 cgd
57 1.1 cgd char *Color[4] =
58 1.1 cgd {
59 1.1 cgd "GREEN",
60 1.1 cgd "DOCKED",
61 1.1 cgd "YELLOW",
62 1.1 cgd "RED"
63 1.1 cgd };
64 1.1 cgd
65 1.1 cgd srscan(f)
66 1.1 cgd int f;
67 1.1 cgd {
68 1.1 cgd register int i, j;
69 1.1 cgd register int statinfo;
70 1.1 cgd char *s;
71 1.1 cgd int percent;
72 1.1 cgd struct quad *q;
73 1.1 cgd extern struct cvntab Skitab[];
74 1.1 cgd extern struct cvntab Lentab[];
75 1.1 cgd struct cvntab *p;
76 1.1 cgd
77 1.1 cgd if (f >= 0 && check_out(SRSCAN))
78 1.1 cgd {
79 1.1 cgd return;
80 1.1 cgd }
81 1.1 cgd if (f)
82 1.1 cgd statinfo = 1;
83 1.1 cgd else
84 1.1 cgd {
85 1.1 cgd if (!testnl())
86 1.1 cgd Etc.statreport = getynpar("status report");
87 1.1 cgd statinfo = Etc.statreport;
88 1.1 cgd }
89 1.1 cgd if (f > 0)
90 1.1 cgd {
91 1.1 cgd Etc.statreport = 1;
92 1.1 cgd if (!Etc.fast)
93 1.1 cgd return;
94 1.1 cgd }
95 1.1 cgd if (f >= 0)
96 1.1 cgd {
97 1.1 cgd printf("\nShort range sensor scan\n");
98 1.1 cgd q = &Quad[Ship.quadx][Ship.quady];
99 1.1 cgd q->scanned = q->klings * 100 + q->bases * 10 + q->stars;
100 1.1 cgd printf(" ");
101 1.1 cgd for (i = 0; i < NSECTS; i++)
102 1.1 cgd {
103 1.1 cgd printf("%d ", i);
104 1.1 cgd }
105 1.1 cgd printf("\n");
106 1.1 cgd }
107 1.1 cgd
108 1.1 cgd for (i = 0; i < NSECTS; i++)
109 1.1 cgd {
110 1.1 cgd if (f >= 0)
111 1.1 cgd {
112 1.1 cgd printf("%d ", i);
113 1.1 cgd for (j = 0; j < NSECTS; j++)
114 1.1 cgd printf("%c ", Sect[i][j]);
115 1.1 cgd printf("%d", i);
116 1.1 cgd if (statinfo)
117 1.1 cgd printf(" ");
118 1.1 cgd }
119 1.1 cgd if (statinfo)
120 1.1 cgd switch (i)
121 1.1 cgd {
122 1.1 cgd case 0:
123 1.1 cgd printf("stardate %.2f", Now.date);
124 1.1 cgd break;
125 1.1 cgd case 1:
126 1.1 cgd printf("condition %s", Color[Ship.cond]);
127 1.1 cgd if (Ship.cloaked)
128 1.1 cgd printf(", CLOAKED");
129 1.1 cgd break;
130 1.1 cgd case 2:
131 1.1 cgd printf("position %d,%d/%d,%d",Ship.quadx, Ship.quady, Ship.sectx, Ship.secty);
132 1.1 cgd break;
133 1.1 cgd case 3:
134 1.1 cgd printf("warp factor %.1f", Ship.warp);
135 1.1 cgd break;
136 1.1 cgd case 4:
137 1.1 cgd printf("total energy %d", Ship.energy);
138 1.1 cgd break;
139 1.1 cgd case 5:
140 1.1 cgd printf("torpedoes %d", Ship.torped);
141 1.1 cgd break;
142 1.1 cgd case 6:
143 1.1 cgd s = "down";
144 1.1 cgd if (Ship.shldup)
145 1.1 cgd s = "up";
146 1.1 cgd if (damaged(SHIELD))
147 1.1 cgd s = "damaged";
148 1.1 cgd percent = 100.0 * Ship.shield / Param.shield;
149 1.1 cgd printf("shields %s, %d%%", s, percent);
150 1.1 cgd break;
151 1.1 cgd case 7:
152 1.1 cgd printf("Klingons left %d", Now.klings);
153 1.1 cgd break;
154 1.1 cgd case 8:
155 1.1 cgd printf("time left %.2f", Now.time);
156 1.1 cgd break;
157 1.1 cgd case 9:
158 1.1 cgd printf("life support ");
159 1.1 cgd if (damaged(LIFESUP))
160 1.1 cgd {
161 1.1 cgd printf("damaged, reserves = %.2f", Ship.reserves);
162 1.1 cgd break;
163 1.1 cgd }
164 1.1 cgd printf("active");
165 1.1 cgd break;
166 1.1 cgd }
167 1.1 cgd printf("\n");
168 1.1 cgd }
169 1.1 cgd if (f < 0)
170 1.1 cgd {
171 1.1 cgd printf("current crew %d\n", Ship.crew);
172 1.1 cgd printf("brig space %d\n", Ship.brigfree);
173 1.1 cgd printf("Klingon power %d\n", Param.klingpwr);
174 1.1 cgd p = &Lentab[Game.length - 1];
175 1.1 cgd if (Game.length > 2)
176 1.1 cgd p--;
177 1.1 cgd printf("Length, Skill %s%s, ", p->abrev, p->full);
178 1.1 cgd p = &Skitab[Game.skill - 1];
179 1.1 cgd printf("%s%s\n", p->abrev, p->full);
180 1.1 cgd return;
181 1.1 cgd }
182 1.1 cgd printf(" ");
183 1.1 cgd for (i = 0; i < NSECTS; i++)
184 1.1 cgd printf("%d ", i);
185 1.1 cgd printf("\n");
186 1.1 cgd
187 1.1 cgd if (q->qsystemname & Q_DISTRESSED)
188 1.1 cgd printf("Distressed ");
189 1.1 cgd if (q->qsystemname)
190 1.1 cgd printf("Starsystem %s\n", systemname(q));
191 1.1 cgd }
192