pl_4.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* $NetBSD: pl_4.c,v 1.15 2004/11/05 21:30:32 dsl Exp $ */
  2. /*
  3. * Copyright (c) 1983, 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[] = "@(#)pl_4.c 8.1 (Berkeley) 5/31/93";
  34. #else
  35. __RCSID("$NetBSD: pl_4.c,v 1.15 2004/11/05 21:30:32 dsl Exp $");
  36. #endif
  37. #endif /* not lint */
  38. #include <sys/types.h>
  39. #include <ctype.h>
  40. #include "extern.h"
  41. #include "player.h"
  42. void
  43. changesail(void)
  44. {
  45. int rig, full;
  46. rig = mc->rig1;
  47. full = mf->FS;
  48. if (windspeed == 6 || (windspeed == 5 && mc->class > 4))
  49. rig = 0;
  50. if (mc->crew3 && rig) {
  51. if (!full) {
  52. if (sgetch("Increase to Full sails? ",
  53. (struct ship *)0, 1) == 'y') {
  54. changed = 1;
  55. Write(W_FS, ms, 1, 0, 0, 0);
  56. }
  57. } else {
  58. if (sgetch("Reduce to Battle sails? ",
  59. (struct ship *)0, 1) == 'y') {
  60. Write(W_FS, ms, 0, 0, 0, 0);
  61. changed = 1;
  62. }
  63. }
  64. } else if (!rig)
  65. Msg("Sails rent to pieces");
  66. }
  67. void
  68. acceptsignal(void)
  69. {
  70. char buf[60];
  71. char *p = buf;
  72. *p++ = '"';
  73. sgetstr("Message? ", p, sizeof buf - 2);
  74. while (*p++)
  75. ;
  76. p[-1] = '"';
  77. *p = 0;
  78. Writestr(W_SIGNAL, ms, buf);
  79. }
  80. void
  81. lookout(void)
  82. {
  83. struct ship *sp;
  84. char buf[3];
  85. char c;
  86. sgetstr("What ship? ", buf, sizeof buf);
  87. foreachship(sp) {
  88. c = *countryname[sp->nationality];
  89. if ((tolower((unsigned char)c) == *buf || colours(sp) == *buf)
  90. && (sp->file->stern == buf[1] || sterncolour(sp) == buf[1]
  91. || buf[1] == '?')) {
  92. eyeball(sp);
  93. }
  94. }
  95. }
  96. const char *
  97. saywhat(struct ship *sp, int flag)
  98. {
  99. if (sp->file->captain[0])
  100. return sp->file->captain;
  101. else if (sp->file->struck)
  102. return "(struck)";
  103. else if (sp->file->captured != 0)
  104. return "(captured)";
  105. else if (flag)
  106. return "(available)";
  107. else
  108. return "(computer)";
  109. }
  110. void
  111. eyeball(struct ship *ship)
  112. {
  113. int i;
  114. if (ship->file->dir != 0) {
  115. Msg("Sail ho! (range %d, %s)",
  116. range(ms, ship), saywhat(ship, 0));
  117. i = portside(ms, ship, 1) - mf->dir;
  118. if (i <= 0)
  119. i += 8;
  120. Signal("$$ %s %s %s.",
  121. ship, countryname[ship->nationality],
  122. classname[ship->specs->class], directionname[i]);
  123. }
  124. }