srscan.c 5.0 KB

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