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