annotate input.c @ 3:5a977ccbc7a9 default tip

Empty changelog
author darius
date Sat, 06 Dec 1997 05:41:29 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1 /* $Id: input.c,v 1.1.1.1 1997/12/06 05:41:29 darius Exp $ */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
3 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
4 * input.c
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
5 *
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
6 * Modified to work as client in socket based protocol
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
7 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
8 #include "copyright.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
9
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
10 #include <stdio.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
11 #include <math.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
12 #include <sys/types.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
13 #ifdef RS6K
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
14 #include <sys/select.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
15 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
16 #ifdef hpux
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
17 #include <time.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
18 #else /* hpux */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
19 #include <sys/time.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
20 #endif /* hpux */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
21 #include <signal.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
22 #include <errno.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
23 #include "Wlib.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
24 #include "defs.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
25 #include "struct.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
26 #include "data.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
27 #include "packets.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
28 #include "proto.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
29 #ifdef SOUND
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
30 #include "Slib.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
31 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
32
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
33 #define control(x) (x)+128
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
34
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
35 /* Prototypes */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
36 static void buttonaction P((W_Event * data));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
37 static void keyaction P((W_Event * data));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
38 static void scan P((W_Window w, int x, int y));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
39 /*static void selectblkbozo P((W_Event *data));*/
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
40
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
41 static int tmodeChange = 0; /* handles first change of tmode; including */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
42 /* when a play first joins a tmode game */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
43
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
44 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
45 initinput()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
46 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
47 /* Nothing doing... */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
48 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
49
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
50 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
51 dispatch_W_key_event(evt)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
52 W_Event *evt;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
53 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
54 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
55
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
56 /* try to speed up response -JR */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
57 if (!messageon && (evt->Window == w || evt->Window == mapw)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
58 keyaction(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
59 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
60 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
61 for (i = 0; i < WNUM; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
62 if (evt->Window == messWin[i].window) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
63 messageWinEvent(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
64 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
65 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
66 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
67 if (evt->Window == optionWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
68 optionaction(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
69 else if (
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
70 #ifdef NOWARP
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
71 messageon ||
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
72 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
73 evt->Window == messagew ||
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
74 evt->Window == tstatw ||
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
75 evt->Window == warnw) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
76 smessage(evt->key);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
77 #ifdef SHORT_PACKETS
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
78 } else if (evt->Window == spWin) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
79 spaction(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
80 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
81 } else if (evt->Window == motdWin) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
82 motdWinEvent(evt->key);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
83 } else if (evt->Window == playerw) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
84 playerwEvent(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
85 } else if (evt->Window == defWin && evt->key == ' ') {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
86 W_UnmapWindow(defWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
87 #ifdef SOUND
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
88 } else if (evt->Window == soundWin) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
89 soundaction(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
90 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
91 #ifdef TOOLS
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
92 } else if (evt->Window == toolsWin) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
93 smessage_ahead('!', evt->key);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
94 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
95 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
96 keyaction(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
97 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
98 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
99
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
100 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
101 dispatch_W_button_event(evt)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
102 W_Event *evt;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
103 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
104 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
105
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
106 if (evt->Window == w || evt->Window == mapw) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
107 buttonaction(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
108 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
109 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
110 for (i = 0; i < WNUM; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
111 if (evt->Window == messWin[i].window) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
112 messageWinEvent(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
113 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
114 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
115 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
116 if (evt->Window == war)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
117 waraction(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
118 else if (evt->Window == optionWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
119 optionaction(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
120 #ifdef ATM
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
121 else if (evt->Window == udpWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
122 udpaction(evt); /* UDP */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
123 #endif /* ATM */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
124 #ifdef SHORT_PACKETS
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
125 else if (evt->Window == spWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
126 spaction(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
127 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
128 #ifdef SOUND
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
129 else if (evt->Window == soundWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
130 soundaction(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
131 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
132 else if (evt->Window == playerw)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
133 selectblkbozo(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
134 #ifdef MACROS
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
135 else if (evt->Window == macroWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
136 switchmacros();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
137 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
138 #ifdef XTREKRC_HELP
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
139 else if (evt->Window == defWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
140 def_action(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
141 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
142 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
143 buttonaction(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
144 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
145
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
146 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
147 dispatch_W_expose_event(evt)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
148 W_Event *evt;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
149 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
150 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
151 if anything but the iconWin is refreshed, turn off the iconified flag.
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
152 [BDyess]
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
153 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
154 if (evt->Window != iconWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
155 iconified = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
156 if (evt->Window == statwin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
157 redrawStats();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
158 else if (evt->Window == tstatw)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
159 redrawTstats();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
160 else if (evt->Window == mapw)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
161 redrawall = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
162 else if (evt->Window == iconWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
163 drawIcon();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
164 else if (evt->Window == helpWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
165 fillhelp();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
166 else if (evt->Window == macroWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
167 fillmacro();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
168 else if (evt->Window == playerw)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
169 playerlist();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
170 else if (evt->Window == planetw)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
171 planetlist();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
172 else if (evt->Window == planetw2)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
173 planetlist();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
174 else if (evt->Window == rankw)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
175 ranklist();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
176 else if (evt->Window == warnw)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
177 W_ClearWindow(warnw);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
178 else if (evt->Window == messagew)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
179 message_expose();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
180 else if (evt->Window == motdWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
181 motdWinEvent('r'); /* 'r' is refresh */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
182 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
183 lag meter? maybe later - RF else if (evt->Window == lMeter)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
184 redrawLMeter();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
185 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
186 else if (evt->Window == pStats)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
187 redrawPStats();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
188 #ifdef XTREKRC_HELP
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
189 else if (defWin && (evt->Window == defWin))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
190 showdef();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
191 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
192 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
193
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
194 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
195 dispatch_W_event(evt)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
196 W_Event *evt;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
197 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
198 switch ((int) evt->type) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
199 case W_EV_KEY:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
200 dispatch_W_key_event(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
201 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
202 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
203 case W_EV_KEY_OFF:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
204 if (autoKey)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
205 autoKeyOff(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
206 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
207 #endif /* AUTOKEY */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
208 case W_EV_BUTTON:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
209 dispatch_W_button_event(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
210 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
211 case W_EV_EXPOSE:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
212 dispatch_W_expose_event(evt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
213 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
214 default:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
215 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
216 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
217 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
218
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
219 /* this figures out what to set war dec's */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
220 void autoWarDecl(scheme)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
221 int scheme;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
222 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
223 extern int number_of_teams;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
224 int i, j, k, *team, enemymask = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
225 struct player *pptr;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
226
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
227 if((team = (int *)malloc(number_of_teams * sizeof(int))) == NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
228 perror("autoWarDecl: malloc error\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
229 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
230 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
231 memset(team, 0, sizeof(int)*number_of_teams);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
232 for(i=0, pptr=&players[i]; i < nplayers; i++, pptr++)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
233 if(pptr->p_status != PFREE && !(pptr->p_status == POUTFIT &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
234 pptr->p_teami < 0)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
235 team[pptr->p_teami]++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
236 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
237 switch(scheme) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
238 case 1:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
239 /* war with all non-zero member team */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
240 /* peace with teams with 0 players */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
241 for(i=0; i < number_of_teams; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
242 if(i != me->p_teami)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
243 enemymask ^= team[i] ? (1<<i) : 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
244 /*printf("team: %i, #: %i\n", i, team[i]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
245 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
246 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
247 /*printf("mask: %i\n", enemymask);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
248 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
249 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
250 case 2:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
251 /* war with only the largest enemy */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
252 /* team; peace with everyone else*/
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
253 for(i=0; i < number_of_teams; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
254 if ((i != me->p_teami) && (j < team[i])) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
255 j = team[i];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
256 k = i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
257 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
258 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
259 enemymask = 0 | (1 << k);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
260 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
261 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
262 sendWarReq(enemymask);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
263 free(team);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
264 } /* end of autoWarDecl */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
265
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
266
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
267 /* this new event loop allows more flexibility in state transitions */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
268 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
269 input()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
270 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
271 W_Event data;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
272 fd_set readfds;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
273 int wsock = W_Socket();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
274 int old_tourn = paradise ? status2->tourn : status->tourn, new_tourn;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
275
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
276 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
277 struct timeval timeout;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
278
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
279 timeout.tv_sec = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
280 timeout.tv_usec = 100000;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
281 #endif /* AUTOKEY */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
282
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
283 #ifdef RECORDER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
284 if (playback) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
285 pb_input(); /* recorder.c */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
286 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
287 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
288 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
289 while (me->p_status == PALIVE ||
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
290 me->p_status == PEXPLODE ||
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
291 me->p_status == PDEAD ||
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
292 me->p_status == POBSERVE) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
293
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
294 #ifdef TIMELORD
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
295 /* we're playing. Count the seconds */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
296 update_timelord(0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
297 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
298
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
299 if (keepInfo > 0) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
300 if (infowin_up >= 0 &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
301 --infowin_up == -1 &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
302 infomapped) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
303 destroyInfo();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
304 infowin_up = -2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
305 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
306 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
307 exitInputLoop = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
308 while (W_EventsPending() && !exitInputLoop) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
309 fastQuit = 0; /* any event cancel fastquit */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
310 W_NextEvent(&data);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
311 dispatch_W_event(&data);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
312 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
313
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
314 #if 0
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
315 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
316 Do some enforcement of non-paradise feature disabling. The options
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
317 menu doesn't deal with this too well.
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
318 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
319 if (!paradise) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
320 blk_zoom = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
321 blk_showStars = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
322 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
323 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
324 #ifndef AMIGA
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
325 FD_ZERO(&readfds);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
326 FD_SET(wsock, &readfds);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
327 FD_SET(sock, &readfds);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
328 if (udpSock >= 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
329 FD_SET(udpSock, &readfds);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
330 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
331 if (autoKey) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
332 doAutoKey();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
333 if (select(32, &readfds, (fd_set *) 0, (fd_set *) 0, &timeout) == 0) /* timeout */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
334 continue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
335 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
336 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
337 select(32, &readfds, (fd_set *) 0, (fd_set *) 0, 0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
338 #else /* AMIGA */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
339 #ifdef DNET
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
340 sigsPending = Wait(wsock | sockMask | udpSockMask | SIGBREAKF_CTRL_C);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
341 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
342 /* insert code here for Amiga with TCP/IP... */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
343 #endif /* DNET */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
344 if (sigsPending & SIGBREAKF_CTRL_C) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
345 printf("User break, Ctrl-C, exiting!\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
346 exit(0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
347 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
348 /* note: for DNET, FD_ISSET is faked, see amigadefs.h -JR */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
349 #endif /* AMIGA */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
350 if (FD_ISSET(sock, &readfds) ||
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
351 (udpSock >= 0 && FD_ISSET(udpSock, &readfds))) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
352
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
353 #ifdef HANDLER_TIMES
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
354 start_log();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
355 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
356 intrupt();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
357 #ifdef HANDLER_TIMES
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
358 stop_log(64);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
359 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
360 if (isServerDead()) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
361 printf("Whoops! We've been ghostbusted!\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
362 printf("Pray for a miracle!\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
363
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
364 /* UDP fail-safe */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
365 commMode = commModeReq = COMM_TCP;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
366 commSwitchTimeout = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
367 if (udpSock >= 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
368 closeUdpConn();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
369 if (udpWin) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
370 udprefresh(UDP_CURRENT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
371 udprefresh(UDP_STATUS);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
372 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
373 connectToServer(nextSocket);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
374 printf("Yea! We've been resurrected!\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
375 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
376 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
377 beep if tmode status changes. Idea from Roger Books. [BDyess]
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
378 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
379 new_tourn = paradise ? status2->tourn : status->tourn;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
380
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
381 /* change war dec's at transitions to */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
382 /* positive tmode */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
383 if (!tmodeChange && new_tourn) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
384 autoWarDecl(autoSetWar);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
385 tmodeChange = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
386 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
387
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
388 if (old_tourn != new_tourn) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
389 #ifndef SOUND
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
390 W_Beep();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
391 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
392 S_PlaySound(S_TMODE);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
393 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
394 old_tourn = new_tourn;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
395 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
396 continue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
397 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
398 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
399 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
400
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
401
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
402 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
403 keyaction(data)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
404 W_Event *data;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
405 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
406 unsigned char course;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
407 struct obtype *target;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
408 int key = data->key;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
409 struct shiplist *temp;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
410
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
411 if (data->Window != mapw && data->Window != w
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
412 && data->Window != planetw && data->Window != planetw2
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
413 && data->Window != rankw
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
414 #ifdef ATM
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
415 && data->Window != scanw
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
416 #endif /* ATM */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
417 )
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
418 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
419
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
420 #ifdef RECORDER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
421 if (playback)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
422 pb_dokey(data);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
423 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
424 if (localflags & PFREFIT) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
425 temp = shiptypes;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
426 while (temp) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
427 if (temp->ship->s_letter == key) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
428 do_refit(temp->ship->s_type);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
429 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
430 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
431 temp = temp->next;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
432 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
433 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
434 key = doKeymap(data);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
435 if (key == -1)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
436 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
437 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
438
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
439 switch (key) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
440 case '0':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
441 case '1':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
442 case '2':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
443 case '3':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
444 case '4':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
445 case '5':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
446 case '6':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
447 case '7':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
448 case '8':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
449 case '9':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
450 set_speed(key - '0');
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
451 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
452 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
453 case 'e': /* Turn off docking permission, eject docked
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
454 vessels. */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
455 sendDockingReq(!(me->p_flags & PFDOCKOK));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
456 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
457 case 'r':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
458 localflags |= PFREFIT;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
459 warning(blk_refitstring);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
460 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
461 case control('0'): /* ctrl 0-9, speed 10-19 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
462 case control('1'):
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
463 case control('2'):
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
464 case control('3'):
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
465 case control('4'):
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
466 case control('5'):
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
467 case control('6'):
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
468 case control('7'):
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
469 case control('8'):
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
470 case control('9'):
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
471 set_speed(10 + key - control('0'));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
472 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
473 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
474 case control(')'): /* ctrl-shift 0-9, speed 20-29 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
475 set_speed(20);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
476 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
477 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
478 case control('!'): /* ctrl-shift-1, speed 21 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
479 set_speed(21);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
480 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
481 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
482 case control('@'): /* ctrl-shift-2, speed 22 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
483 set_speed(22);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
484 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
485 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
486 case control('#'): /* ctrl-shift-3, speed 23 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
487 set_speed(23);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
488 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
489 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
490 case control('$'): /* ctrl-shift-4, speed 24 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
491 set_speed(24);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
492 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
493 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
494 case control('%'): /* ctrl-shift-5, speed 25 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
495 set_speed(25);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
496 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
497 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
498 case control('^'): /* ctrl-shift-6, speed 26 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
499 set_speed(26);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
500 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
501 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
502 case control('&'): /* ctrl-shift-7, speed 27 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
503 set_speed(27);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
504 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
505 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
506 case control('*'): /* ctrl-shift-8, speed 28 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
507 set_speed(28);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
508 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
509 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
510 case control('('): /* ctrl-shift-9, speed 29 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
511 set_speed(29);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
512 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
513 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
514 case '`': /* afterburners */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
515 set_speed(98);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
516 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
517 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
518 case '-':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
519 set_speed(99); /* warp! */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
520 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
521 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
522 case control('-'): /* suspend warp toggle [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
523 if (me->p_flags & PFWPSUSPENDED)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
524 set_speed(96); /* unsuspend */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
525 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
526 set_speed(97); /* suspend */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
527 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
528 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
529 case '%': /* max impulse */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
530 set_speed(me->p_ship->s_maxspeed);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
531 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
532 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
533 case '<': /* speed -= 1 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
534 set_speed(me->p_speed - 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
535 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
536 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
537 case '>': /* speed += 1 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
538 set_speed(me->p_speed + 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
539 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
540 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
541 case '#': /* halfimpulse */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
542 set_speed((me->p_ship->s_maxspeed + 1) / 2);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
543 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
544 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
545 case ':': /* toggle message logging */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
546 if (logmess)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
547 warning("Message logging disabled");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
548 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
549 warning("Message logging enabled");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
550 logmess = !logmess;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
551 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
552 case '!':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
553 #if 1
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
554 showKitchenSink = !showKitchenSink;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
555 warning(showKitchenSink ?
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
556 "Kitchen Sink activated. Bad guys beware!" :
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
557 "Kitchen Sink deactivated.");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
558 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
559 if (blk_altbits) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
560 blk_altbits = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
561 warning("Switching to old bitmaps.");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
562 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
563 blk_altbits = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
564 warning("Switching to new bitmaps.");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
565 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
566 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
567 if (optionWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
568 optionredrawoption(&blk_altbits);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
569 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
570 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
571 #ifdef TIMER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
572 case '@':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
573 timeBank[T_USR] = time(NULL);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
574 timerType = T_USR;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
575 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
576 case control('t'):
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
577 timerType++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
578 if (timerType >= T_TOTAL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
579 timerType = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
580 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
581 #endif /* TIMER */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
582 #ifdef WIDE_PLIST
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
583 case 'K': /* cycle playerlist [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
584 while (*playerList && *playerList != ',')
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
585 playerList++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
586 if (*playerList == ',')
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
587 playerList++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
588 else if (*playerList == 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
589 playerList = playerListStart;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
590 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
591 #endif /* WIDE_PLIST */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
592 case 'a':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
593 #ifdef ATM
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
594 if (!W_IsMapped(scanwin)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
595 scan(data->Window, data->x, data->y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
596 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
597 if (scanmapped)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
598 W_UnmapWindow(scanwin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
599 scanmapped = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
600 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
601 #endif /* ATM */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
602 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
603 case 'm': /* new from galaxy -- works here too */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
604 case '\'': /* ' starts message to 'T'eam */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
605 #ifdef NOWARP
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
606 message_on();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
607 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
608 W_WarpPointer(messagew);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
609 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
610 if((key == '\'') && (messpend==0)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
611 smessage(lowercaset ? 't' : 'T');
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
612 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
613 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
614 case 'k': /* k = set course */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
615 course = getcourse(data->Window, data->x, data->y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
616 set_course(course);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
617 me->p_flags &= ~(PFPLOCK | PFPLLOCK);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
618 localflags &= ~(PFREFIT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
619 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
620 case 'p': /* p = fire phasers */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
621 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
622 if (autoKey)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
623 autoKeyPhaserReqOn();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
624 else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
625 course = getcourse(data->Window, data->x, data->y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
626 sendPhaserReq(course);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
627 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
628 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
629 course = getcourse(data->Window, data->x, data->y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
630 sendPhaserReq(course);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
631 #endif /* AUTOKEY */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
632 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
633 case 't': /* t = launch torps */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
634 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
635 if (autoKey)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
636 autoKeyTorpReqOn();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
637 else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
638 course = getcourse(data->Window, data->x, data->y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
639 sendTorpReq(course);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
640 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
641 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
642 course = getcourse(data->Window, data->x, data->y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
643 sendTorpReq(course);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
644 #endif /* AUTOKEY */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
645 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
646 case 'f':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
647 /* f = launch plasma torpedos */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
648 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
649 if (autoKey)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
650 autoKeyPlasmaReqOn();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
651 else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
652 course = getcourse(data->Window, data->x, data->y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
653 sendPlasmaReq(course);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
654 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
655 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
656 course = getcourse(data->Window, data->x, data->y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
657 sendPlasmaReq(course);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
658 #endif /* AUTOKEY */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
659 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
660 case 'd': /* d = detonate other torps */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
661 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
662 if (autoKey)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
663 autoKeyDetReqOn();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
664 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
665 sendDetonateReq();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
666 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
667 sendDetonateReq();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
668 #endif /* AUTOKEY */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
669 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
670 case 'D': /* D = detonate my torps */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
671 detmine();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
672 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
673 if (autoKey)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
674 autoKeyAllOff(); /* xx */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
675 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
676 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
677 case '[':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
678 shield_down();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
679 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
680 case ']':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
681 shield_up();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
682 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
683 case 'u': /* u = toggle shields */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
684 shield_tog();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
685 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
686 case 's': /* For Serge */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
687 shield_tog();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
688 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
689 case 'b': /* b = bomb planet */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
690 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
691 if (autoKey && !(localflags & PFREFIT))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
692 autoKeyBombReqOn();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
693 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
694 bomb_planet();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
695 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
696 bomb_planet();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
697 #endif /* AUTOKEY */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
698 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
699 case 'z': /* z = beam up */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
700 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
701 if (autoKey)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
702 autoKeyBeamUpReqOn();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
703 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
704 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
705 beam_up();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
706 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
707 case 'x': /* x = beam down */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
708 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
709 if (autoKey)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
710 autoKeyBeamDownReqOn();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
711 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
712 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
713 beam_down();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
714 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
715 case 'X': /* X = enter macro mode */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
716 macroState = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
717 warning("Macro mode");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
718 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
719 case 'R': /* R = Go into repair mode */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
720 sendRepairReq(1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
721 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
722 case 'y':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
723 case 'T':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
724 case '_': /* _ = turn on tractor beam */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
725 case '^': /* ^ = turn on pressor beam */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
726 if (me->p_flags & (PFTRACT | PFPRESS)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
727 sendTractorReq(0, me->p_no);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
728 if (key == 'T' || key == 'y')
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
729 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
730 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
731 target = gettarget(data->Window, data->x, data->y, TARG_PLAYER);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
732 me->p_tractor = target->o_num;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
733 if (key == 'T' || key == '_') {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
734 sendTractorReq(1, target->o_num);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
735 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
736 sendRepressReq(1, target->o_num);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
737 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
738 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
739 case '$': /* turn off tractor/pressor beam */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
740 sendTractorReq(0, me->p_no);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
741 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
742 case 'o': /* o = dock at nearby starbase or orbit
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
743 nearest planet */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
744 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
745 if (autoKey && !(localflags & PFREFIT))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
746 autoKeyOrbitReqOn();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
747 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
748 sendOrbitReq(1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
749 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
750 sendOrbitReq(1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
751 #endif /* AUTOKEY */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
752 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
753 case 'O': /* O = options Window */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
754 if (optionWin != NULL && W_IsMapped(optionWin))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
755 optiondone();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
756 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
757 optionwindow();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
758 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
759 case 'Q':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
760 sendQuitReq();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
761 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
762 case 'q': /* fastquit */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
763 fastQuit = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
764 sendQuitReq();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
765 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
766 case 'V':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
767 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
768 /* configurable showlocal rotation sequence [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
769 int i, len = strlen(showLocalSequence);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
770 for (i = 0; i < len; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
771 if (showLocalSequence[i] - '0' == showlocal) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
772 showlocal = showLocalSequence[(i + 1) % len] - '0';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
773 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
774 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
775 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
776 if (i == len)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
777 showlocal = (*showLocalSequence) - '0';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
778 if (showlocal > 4)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
779 showlocal = 4;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
780 else if (showlocal < 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
781 showlocal = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
782 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
783 if (optionWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
784 optionredrawoption(&showlocal);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
785 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
786 case 'B':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
787 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
788 /* configurable showgalactic rotation sequence [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
789 int i, len = strlen(showGalacticSequence);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
790 for (i = 0; i < len; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
791 if (showGalacticSequence[i] - '0' == showgalactic) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
792 showgalactic = showGalacticSequence[(i + 1) % len] - '0';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
793 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
794 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
795 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
796 if (i == len)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
797 showgalactic = (*showGalacticSequence) - '0';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
798 if (!paradise && showgalactic == 3)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
799 showgalactic = 5; /* force scout ages -> MOO */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
800 if (showgalactic > 5)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
801 showgalactic = 5;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
802 else if (showgalactic < 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
803 showgalactic = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
804 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
805 redrawall = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
806 if (optionWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
807 optionredrawoption(&showgalactic);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
808 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
809 case '?': /* ? = Redisplay all message windows */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
810 if (!W_IsMapped(messWin[WREVIEW].window)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
811 if (W_IsMapped(messWin[WALL].window)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
812 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
813 for (i = 0; i < WNUM; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
814 if (W_IsMapped(messWin[i].window))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
815 W_UnmapWindow(messWin[i].window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
816 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
817 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
818 W_MapWindow(messWin[WREVIEW].window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
819 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
820 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
821 W_UnmapWindow(messWin[WREVIEW].window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
822 W_MapWindow(messWin[WALL].window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
823 W_MapWindow(messWin[WTEAM].window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
824 W_MapWindow(messWin[WINDIV].window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
825 W_MapWindow(messWin[WKILL].window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
826 W_MapWindow(messWin[WPHASER].window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
827 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
828 if (optionWin) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
829 optionredrawtarget(messWin[WREVIEW].window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
830 optionredrawtarget(messWin[WALL].window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
831 optionredrawtarget(messWin[WKILL].window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
832 optionredrawtarget(messWin[WTEAM].window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
833 optionredrawtarget(messWin[WINDIV].window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
834 optionredrawtarget(messWin[WPHASER].window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
835 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
836 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
837 case 'c': /* c = cloak */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
838 cloak();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
839 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
840 case '{': /* { = cloak, no toggle */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
841 sendCloakReq(1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
842 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
843 case '}': /* } = uncloak, no toggle */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
844 sendCloakReq(0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
845 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
846 case 'C': /* C = coups */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
847 sendCoupReq();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
848 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
849 case ';': /* ; = lock onto planet/base */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
850 target = gettarget(data->Window, data->x, data->y,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
851 TARG_BASE | TARG_PLANET);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
852 if (target->o_type == PLAYERTYPE) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
853 sendPlaylockReq(target->o_num); /* a base */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
854 me->p_playerl = target->o_num;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
855 } else { /* It's a planet */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
856 sendPlanlockReq(target->o_num);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
857 me->p_planet = target->o_num;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
858 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
859 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
860 case 'l': /* l = lock onto */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
861 target = gettarget(data->Window, data->x, data->y,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
862 TARG_PLAYER | TARG_ASTRAL);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
863 if (target->o_type == PLAYERTYPE) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
864 sendPlaylockReq(target->o_num);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
865 me->p_playerl = target->o_num;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
866 } else { /* It's a planet */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
867 sendPlanlockReq(target->o_num);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
868 me->p_planet = target->o_num;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
869 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
870 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
871 case '/': /* toggle sorted player list */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
872 sortPlayers = !sortPlayers;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
873 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
874 case '*': /* send in practice robot */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
875 sendPractrReq();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
876 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
877 /* Start of display functions */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
878 case ' ': /* ' ' = clear special windows */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
879 W_UnmapWindow(planetw);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
880 W_UnmapWindow(planetw2);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
881 W_UnmapWindow(rankw);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
882 if (infomapped)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
883 destroyInfo();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
884 W_UnmapWindow(helpWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
885 W_UnmapWindow(war);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
886 if (optionWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
887 optiondone();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
888 #ifdef ATM
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
889 if (scanmapped) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
890 W_UnmapWindow(scanwin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
891 scanmapped = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
892 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
893 if (udpWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
894 udpdone();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
895 #endif /* ATM */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
896 #ifdef XTREKRC_HELP
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
897 if (defWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
898 W_UnmapWindow(defWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
899 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
900 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
901 case 'E': /* E = send emergency call */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
902 if (F_gen_distress)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
903 rcd(generic, data);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
904 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
905 emergency();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
906 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
907 case 'F': /* F = send carry report */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
908 if (F_gen_distress)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
909 rcd(carrying, data);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
910 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
911 carry_report();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
912 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
913 case 'L': /* L = Player list */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
914 if (W_IsMapped(playerw)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
915 W_UnmapWindow(playerw);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
916 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
917 W_MapWindow(playerw);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
918 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
919 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
920 case 'P': /* P = Planet list */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
921 if (W_IsMapped(planetw)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
922 W_UnmapWindow(planetw);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
923 W_UnmapWindow(planetw2);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
924 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
925 W_MapWindow(planetw);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
926 W_MapWindow(planetw2);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
927 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
928 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
929 case 'U': /* U = Rank list */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
930 if (W_IsMapped(rankw)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
931 W_UnmapWindow(rankw);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
932 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
933 W_MapWindow(rankw);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
934 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
935 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
936 case 'S': /* S = toggle stat mode */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
937 if (W_IsMapped(statwin)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
938 W_UnmapWindow(statwin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
939 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
940 W_MapWindow(statwin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
941 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
942 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
943 #ifdef nodef /* people hit this by accident and think the
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
944 client crashed */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
945 case 'M': /* M = Toggle Map mode */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
946 mapmode = !mapmode;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
947 if (optionWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
948 optionredrawoption(&mapmode);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
949 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
950 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
951 case 'M': /* map the motd window */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
952 showMotdWin();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
953 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
954 case 'N': /* N = Toggle Name mode */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
955 namemode = !namemode;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
956 if (optionWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
957 optionredrawoption(&namemode);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
958 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
959 case 'i': /* i = get information */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
960 case 'I': /* I = get extended information */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
961 case control('i'): /* ^i = info on a planet [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
962 if (!infomapped)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
963 inform(data->Window, data->x, data->y, key);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
964 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
965 destroyInfo();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
966 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
967 case 'h': /* h = Map help window */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
968 if (W_IsMapped(helpWin)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
969 W_UnmapWindow(helpWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
970 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
971 W_MapWindow(helpWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
972 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
973 if (optionWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
974 optionredrawtarget(helpWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
975 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
976 case 'w': /* w = map war stuff */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
977 if (W_IsMapped(war))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
978 W_UnmapWindow(war);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
979 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
980 warwindow();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
981 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
982 #ifdef ATM
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
983 case '+': /* UDP: pop up UDP control window */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
984 if (udpWin != NULL && W_IsMapped(udpWin))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
985 udpdone();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
986 else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
987 char buf[80];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
988 udpwindow();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
989 sprintf(buf, "UDP client version %.1f",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
990 (float) UDPVERSION / 10.0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
991 warning(buf);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
992 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
993 if (optionWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
994 optionredrawtarget(udpWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
995 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
996 case '=': /* UDP: request for full update */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
997 sendUdpReq(COMM_UPDATE);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
998 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
999 #endif /* ATM */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1000
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1001 case 9: /* tab */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1002 case control('m'): /* because you can't remap to tab */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1003 /* actually, you can, put a literal
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1004 TAB in a ckeymap entry and it works.
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1005 So should we keep this? -JR */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1006 if(paradise) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1007 blk_zoom = !blk_zoom;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1008 redrawall = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1009 auto_zoom_timer = udcounter+autoZoomOverride;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1010 if (optionWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1011 optionredrawoption(&blk_zoom);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1012 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1013 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1014 #ifdef SHORT_PACKETS
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1015 case '~':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1016 if (spWin != NULL && W_IsMapped(spWin))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1017 spdone();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1018 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1019 spwindow();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1020 if (optionWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1021 optionredrawtarget(spWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1022 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1023 case '\\':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1024 sendShortReq(SPK_SALL);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1025 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1026 case '|':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1027 sendShortReq(SPK_ALL);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1028 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1029 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1030 case ',':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1031 if (W_IsMapped(pStats)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1032 W_UnmapWindow(pStats);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1033 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1034 W_MapWindow(pStats);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1035 redrawPStats();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1036 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1037 if (optionWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1038 optionredrawtarget(pStats);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1039 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1040 case '&': /* reread defaults file */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1041 if (defaultsFile) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1042 char buf[150];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1043 sprintf(buf, "Reading defaults from %s", defaultsFile);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1044 warning(buf);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1045 freeDefaults();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1046 defaultsFile = initDefaults(defaultsFile);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1047 resetDefaults();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1048 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1049 warning("No defaults file to read from!");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1050 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1051 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1052 #ifdef ROTATERACE
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1053 case '(':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1054 rotate--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1055 if (rotate < 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1056 rotate = 3;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1057 if (optionWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1058 optionredrawoption(&rotate);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1059 rotate_all();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1060 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1061 case ')':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1062 rotate++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1063 if (rotate > 3)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1064 rotate = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1065 if (optionWin)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1066 optionredrawoption(&rotate);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1067 rotate_all();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1068 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1069 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1070
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1071 #ifdef RECORDER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1072 case control('r'):
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1073 stopRecorder();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1074 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1075 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1076
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1077 #ifdef SOUND
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1078 case control('s'):
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1079 S_SoundWindow();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1080 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1081 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1082 #ifdef TOOLS
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1083 case '\"':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1084 showToolsWin();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1085 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1086 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1087 #ifdef AMIGA
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1088 case 'A':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1089 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1090 extern int flush_speech;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1091 flush_speech = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1092 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1093 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1094 #endif /* AMIGA */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1095 default:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1096 W_Beep();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1097 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1098 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1099 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1100
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1101 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1102 buttonaction(data)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1103 W_Event *data;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1104 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1105 unsigned char course;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1106
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1107 #ifdef NOWARP
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1108 if (messageon)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1109 message_off(); /* ATM */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1110 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1111
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1112 if (data->Window != w && data->Window != mapw
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1113 #ifdef ATM
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1114 && data->Window != scanwin
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1115 #endif /* ATM */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1116 )
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1117 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1118
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1119 data->key--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1120 if (data->key >= 0 && data->key < 12) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1121 if (myship->s_buttonmap[data->key] != '\0') {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1122 data->key = myship->s_buttonmap[data->key];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1123 #if 0 /* do NOT bypass keymap */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1124 data->key += 256; /* simulate alt key so keymap is bypassed
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1125 [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1126 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1127 keyaction(data);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1128 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1129 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1130 data->key = data->key % 3;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1131 /* if alt key is pressed, do default */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1132 } if (data->key > 11)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1133 data->key -= 12;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1134 data->key++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1135 if (data->key == W_RBUTTON) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1136 course = getcourse(data->Window, data->x, data->y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1137 set_course(course);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1138 } else if (data->key == W_LBUTTON) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1139 course = getcourse(data->Window, data->x, data->y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1140 sendTorpReq(course);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1141 } else if (data->key == W_MBUTTON) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1142 course = getcourse(data->Window, data->x, data->y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1143 sendPhaserReq(course);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1144 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1145 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1146
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1147 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1148 * changed from unsigned char to irint() for precise rounding (from Leonard
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1149 * Dickens)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1150 *
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1151 * changed from irint (which ULTRIX doesn't have in its math.h header) to
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1152 * floor(x+0.5) for portability.
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1153 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1154
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1155
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1156
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1157 int
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1158 getcourse(ww, x, y)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1159 W_Window ww;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1160 int x, y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1161 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1162 if (ww == mapw) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1163 int me_x, me_y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1164 register gwidth, offsetx, offsety;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1165
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1166 if (blk_zoom) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1167 gwidth = blk_gwidth / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1168 offsetx = zoom_offset(me->p_x);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1169 offsety = zoom_offset(me->p_y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1170 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1171 gwidth = blk_gwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1172 offsetx = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1173 offsety = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1174 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1175 me_x = (me->p_x - offsetx) * WINSIDE / gwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1176 me_y = (me->p_y - offsety) * WINSIDE / gwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1177
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1178 return (unsigned char)(int)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1179 floor(0.5 + atan2((double) (x - me_x),
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1180 (double) (me_y - y))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1181 / 3.14159 * 128.);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1182
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1183
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1184 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1185
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1186 double result = atan2((double) (x - WINSIDE / 2),
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1187 (double) (WINSIDE / 2 - y)) / 3.14159 * 128.;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1188
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1189 return (unsigned char) (int) floor (result + 0.5);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1190 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1191 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1192 #ifdef ATM
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1193 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1194 scan(w, x, y)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1195 W_Window w;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1196 int x, y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1197 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1198 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1199 #endif /* ATM */