pl_2.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /* $NetBSD: pl_2.c,v 1.11 2003/08/07 09:37:43 agc 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_2.c 8.1 (Berkeley) 5/31/93";
  34. #else
  35. __RCSID("$NetBSD: pl_2.c,v 1.11 2003/08/07 09:37:43 agc Exp $");
  36. #endif
  37. #endif /* not lint */
  38. #include <signal.h>
  39. #include "extern.h"
  40. #include "player.h"
  41. void
  42. play(void)
  43. {
  44. struct ship *sp;
  45. for (;;) {
  46. switch (sgetch("~\b", (struct ship *)0, 0)) {
  47. case 'm':
  48. acceptmove();
  49. break;
  50. case 's':
  51. acceptsignal();
  52. break;
  53. case 'g':
  54. grapungrap();
  55. break;
  56. case 'u':
  57. unfoulplayer();
  58. break;
  59. case 'v':
  60. Msg("%s", version);
  61. break;
  62. case 'b':
  63. acceptboard();
  64. break;
  65. case 'f':
  66. acceptcombat();
  67. break;
  68. case 'l':
  69. loadplayer();
  70. break;
  71. case 'c':
  72. changesail();
  73. break;
  74. case 'r':
  75. repair();
  76. break;
  77. case 'B':
  78. Msg("'Hands to stations!'");
  79. unboard(ms, ms, 1); /* cancel DBP's */
  80. unboard(ms, ms, 0); /* cancel offense */
  81. break;
  82. case '\f':
  83. centerview();
  84. blockalarm();
  85. draw_board();
  86. draw_screen();
  87. unblockalarm();
  88. break;
  89. case 'L':
  90. mf->loadL = L_EMPTY;
  91. mf->loadR = L_EMPTY;
  92. mf->readyL = R_EMPTY;
  93. mf->readyR = R_EMPTY;
  94. Msg("Broadsides unloaded");
  95. break;
  96. case 'q':
  97. Msg("Type 'Q' to quit");
  98. break;
  99. case 'Q':
  100. leave(LEAVE_QUIT);
  101. break;
  102. case 'I':
  103. foreachship(sp)
  104. if (sp != ms)
  105. eyeball(sp);
  106. break;
  107. case 'i':
  108. if ((sp = closestenemy(ms, 0, 1)) == 0)
  109. Msg("No more ships left.");
  110. else
  111. eyeball(sp);
  112. break;
  113. case 'C':
  114. centerview();
  115. blockalarm();
  116. draw_view();
  117. unblockalarm();
  118. break;
  119. case 'U':
  120. upview();
  121. blockalarm();
  122. draw_view();
  123. unblockalarm();
  124. break;
  125. case 'D':
  126. case 'N':
  127. downview();
  128. blockalarm();
  129. draw_view();
  130. unblockalarm();
  131. break;
  132. case 'H':
  133. leftview();
  134. blockalarm();
  135. draw_view();
  136. unblockalarm();
  137. break;
  138. case 'J':
  139. rightview();
  140. blockalarm();
  141. draw_view();
  142. unblockalarm();
  143. break;
  144. case 'F':
  145. lookout();
  146. break;
  147. case 'S':
  148. dont_adjust = !dont_adjust;
  149. blockalarm();
  150. draw_turn();
  151. unblockalarm();
  152. break;
  153. }
  154. }
  155. }