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