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