1 /*
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8 #ifndef lint
9 static char sccsid[] = "@(#)srscan.c 8.1 (Berkeley) 05/31/93";
10 #endif /* not lint */
11
12 # include "trek.h"
13 # include "getpar.h"
14
15 /*
16 ** SHORT RANGE SENSOR SCAN
17 **
18 ** A short range scan is taken of the current quadrant. If the
19 ** flag 'f' is one, it is an "auto srscan", which is not done
20 ** unless in 'fast' mode. It does a status report and a srscan.
21 ** If 'f' is -1, you get a status report only. If it is zero,
22 ** you get a srscan and an optional status report. The status
23 ** report is taken if you enter "srscan yes"; for all srscans
24 ** thereafter you get a status report with your srscan until
25 ** you type "srscan no". It defaults to on.
26 **
27 ** The current quadrant is filled in on the computer chart.
28 */
29
30 char *Color[4] =
31 {
32 "GREEN",
33 "DOCKED",
34 "YELLOW",
35 "RED"
36 };
37
srscan(f)38 srscan(f)
39 int f;
40 {
41 register int i, j;
42 register int statinfo;
43 char *s;
44 int percent;
45 struct quad *q;
46 extern struct cvntab Skitab[];
47 extern struct cvntab Lentab[];
48 struct cvntab *p;
49
50 if (f >= 0 && check_out(SRSCAN))
51 {
52 return;
53 }
54 if (f)
55 statinfo = 1;
56 else
57 {
58 if (!testnl())
59 Etc.statreport = getynpar("status report");
60 statinfo = Etc.statreport;
61 }
62 if (f > 0)
63 {
64 Etc.statreport = 1;
65 if (!Etc.fast)
66 return;
67 }
68 if (f >= 0)
69 {
70 printf("\nShort range sensor scan\n");
71 q = &Quad[Ship.quadx][Ship.quady];
72 q->scanned = q->klings * 100 + q->bases * 10 + q->stars;
73 printf(" ");
74 for (i = 0; i < NSECTS; i++)
75 {
76 printf("%d ", i);
77 }
78 printf("\n");
79 }
80
81 for (i = 0; i < NSECTS; i++)
82 {
83 if (f >= 0)
84 {
85 printf("%d ", i);
86 for (j = 0; j < NSECTS; j++)
87 printf("%c ", Sect[i][j]);
88 printf("%d", i);
89 if (statinfo)
90 printf(" ");
91 }
92 if (statinfo)
93 switch (i)
94 {
95 case 0:
96 printf("stardate %.2f", Now.date);
97 break;
98 case 1:
99 printf("condition %s", Color[Ship.cond]);
100 if (Ship.cloaked)
101 printf(", CLOAKED");
102 break;
103 case 2:
104 printf("position %d,%d/%d,%d",Ship.quadx, Ship.quady, Ship.sectx, Ship.secty);
105 break;
106 case 3:
107 printf("warp factor %.1f", Ship.warp);
108 break;
109 case 4:
110 printf("total energy %d", Ship.energy);
111 break;
112 case 5:
113 printf("torpedoes %d", Ship.torped);
114 break;
115 case 6:
116 s = "down";
117 if (Ship.shldup)
118 s = "up";
119 if (damaged(SHIELD))
120 s = "damaged";
121 percent = 100.0 * Ship.shield / Param.shield;
122 printf("shields %s, %d%%", s, percent);
123 break;
124 case 7:
125 printf("Klingons left %d", Now.klings);
126 break;
127 case 8:
128 printf("time left %.2f", Now.time);
129 break;
130 case 9:
131 printf("life support ");
132 if (damaged(LIFESUP))
133 {
134 printf("damaged, reserves = %.2f", Ship.reserves);
135 break;
136 }
137 printf("active");
138 break;
139 }
140 printf("\n");
141 }
142 if (f < 0)
143 {
144 printf("current crew %d\n", Ship.crew);
145 printf("brig space %d\n", Ship.brigfree);
146 printf("Klingon power %d\n", Param.klingpwr);
147 p = &Lentab[Game.length - 1];
148 if (Game.length > 2)
149 p--;
150 printf("Length, Skill %s%s, ", p->abrev, p->full);
151 p = &Skitab[Game.skill - 1];
152 printf("%s%s\n", p->abrev, p->full);
153 return;
154 }
155 printf(" ");
156 for (i = 0; i < NSECTS; i++)
157 printf("%d ", i);
158 printf("\n");
159
160 if (q->qsystemname & Q_DISTRESSED)
161 printf("Distressed ");
162 if (q->qsystemname)
163 printf("Starsystem %s\n", systemname(q));
164 }
165