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