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