Sync with FreeBSD (adds reload).
[dragonfly.git] / games / sail / pl_2.c
blob0c8b5c10bb201eac54d06fa8cf7e4f13ce253b85
1 /*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
33 * @(#)pl_2.c 8.1 (Berkeley) 5/31/93
34 * $FreeBSD: src/games/sail/pl_2.c,v 1.4 1999/11/30 03:49:36 billf Exp $
35 * $DragonFly: src/games/sail/pl_2.c,v 1.3 2006/09/03 17:33:13 pavalos Exp $
38 #include "player.h"
40 void
41 play(void)
43 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 Signal("%s", (struct ship *)0, 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 Signal("'Hands to stations!'", (struct ship *)0);
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 Signal("Broadsides unloaded", (struct ship *)0);
95 break;
96 case 'q':
97 Signal("Type 'Q' to quit", (struct ship *)0);
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 Signal("No more ships left.", (struct ship *)0);
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;