forked from hyperyoda/netrek-client-brmh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.c
1431 lines (1296 loc) · 31.6 KB
/
input.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* input.c
*
* Modified to work as client in socket based protocol
*/
#include "copyright.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <sys/types.h>
#ifdef hpux
#include <time.h>
#else /* hpux */
#include <sys/time.h>
#endif /* hpux */
#include <signal.h>
#include <errno.h>
#include "netrek.h"
#ifdef RECORD
#include "recorder.h"
#endif
#if __STDC__ || defined(__cplusplus)
#define P_(s) s
#else
#define P_(s) ()
#endif
/* input.c */
static unsigned char *AddStringToKeymap P_((unsigned char *str, unsigned char *keymap, char *keymapName, int isCtrlKeymap));
static void AddStrToButtonMap P_((unsigned char *str, char *buttonmap));
int torprepeat = 0;
int last_torp = 0;
#undef P_
/*
* Create a keymap with the default bindings.
*
* If keyMap has not been allocated yet (keyMap is NULL) this will involve
* reallocating the keymap. Otherwise, the procedure will reset the
* given keymap.
*
* RETURN: The updated keymap.
*/
unsigned char *
InitKeyMap(keyMap)
unsigned char *keyMap;
{
register i;
unsigned char *defaultMap;
if (!keyMap) {
keyMap = (unsigned char *) calloc(1, MAXKEY);
if (!keyMap) {
fprintf(stderr, "netrek: Out of memory\n");
exit(1);
}
}
defaultMap = keymaps[KEYMAP_DEFAULT];
if ((!defaultMap) || (keyMap == defaultMap)) {
/* The default keyMap starts out as a null keymap. */
for (i = MAXKEY - 2; i >= 0; --i)
keyMap[i] = i + 32;
keyMap[MAXKEY - 1] = 0;
} else {
/* Other keymaps start out as the current default keymap. */
for (i = MAXKEY - 1; i >= 0; --i)
keyMap[i] = defaultMap[i];
}
return keyMap;
}
/*
* Add the given string of keybindings to the keymap.
*
* The keymap will be re-initialised if it is not already defined. If
* isCtrlKeymap is set then `^' notation is allowed. The variable
* "keymapName" contains the name of the keymap (eg "ckeymap-sc") so that
* errors can be reported nicely.
*
* RETURN The updated keymap.
*/
static unsigned char *
AddStringToKeymap(str, keymap, keymapName, isCtrlKeymap)
unsigned char *str, *keymap;
char *keymapName;
int isCtrlKeymap;
{
int ch = 0, left = 0, offset = 0, error = 0;
unsigned char *point;
if (!keymap)
keymap = InitKeyMap(keymap);
/*
* Use a character by character parser so that we can examine each
* character properly and so we don't parse passed the end of the string
* if it ends too early.
*/
point = str;
for (; *str != '\0'; ++str) {
/* Read the next key */
if (*str == '^' && isCtrlKeymap) {
if (!offset) {
offset = 96; /* A single ^ means control */
continue; /* No new character */
} else {
ch = '^'; /* A double ^ means ^ */
}
} else if (*str >= 32 && *str < MAXASCII) {
ch = *(str) + offset;
} else {
error = 1;
ch = 1;
}
/* Have we read two keys yet? */
if (!left) {
left = ch;
} else if (error) {
fprintf(stderr, "%s: Ignoring the %s entry `", defaults_file,
keymapName);
while (point <= str) {
putc(*point, stderr);
++point;
}
fputs("'.\n\tUse 'ckeymap' to map control characters.\n", stderr);
left = 0;
point = str + 1;
} else {
keymap[left - 32] = ch;
left = 0;
point = str + 1;
}
offset = 0; /* Forget about ^ flag after each key is read */
}
if (left || offset) {
fprintf(stderr,
"%s: %s ends halfway through a key definition\n",
defaults_file, keymapName);
}
return keymap;
}
/*
* Add a string of definitions to a buttonmap.
*/
static void
AddStrToButtonMap(str, buttonmap)
unsigned char *str;
char *buttonmap;
{
int ind, offset, error;
char *errString =
"%s: buttonmap ends in the middle of a definition.\n";
while (*str != '\0') {
/*
* Set the flags.
*/
offset = 0;
error = 0;
/*
* Get a number.
*/
ind = (*str) - '0';
if (ind > 9)
ind = (*str) - 'a' + 10;
if (ind < 1 || ind > 12) {
fprintf(stderr, "%s: %c ignored in buttonmap\n", defaults_file, *str);
error = 1; /* Allow error recovery */
}
if(ind > 3) extended_mouse = 1;
/*
* Get a key to map to.
*/
offset = 0;
if (*(++str) == '\0') {
fprintf(stderr, errString, defaults_file);
break;
}
if (*str == '^') {
if (*(++str) == '\0') {
fprintf(stderr, errString, defaults_file);
break;
}
if (*str != '^')
offset = 96; /* ^a is ctrl-a but ^^ is ^ */
}
/*
* Do the mapping if an error has not occured.
*/
if (!error)
buttonmap[ind] = *str + offset;
++str;
}
}
void
initkeymaps()
/*
* Load a new set of keymaps.
*
* NOTE: The function will install a new set of keymaps, rather than
* extending the old keymaps, if the defaults file is reloaded halfway
* through a game.
*/
{
unsigned char *str;
register i;
char buf[80];
/*
* Create the default keymap first because the default keymap should be
* the basis for ship specific keymaps.
*
* Don't call InitKeyMap(keymaps[KEYMAP_DEFAULT]) here because it should have
* been called already in initDefaults so that the macro defintions could
* be assigned. This is very nasty but what can you do.
*/
if ((str = (unsigned char *) getdefault("keymap")) != NULL) {
keymaps[KEYMAP_DEFAULT] =
AddStringToKeymap(str, keymaps[KEYMAP_DEFAULT],
"keymap", 0);
}
#ifdef CONTROL_KEY
if ((str = (unsigned char *) getdefault("ckeymap")) != NULL) {
keymaps[KEYMAP_DEFAULT] =
AddStringToKeymap(str, keymaps[KEYMAP_DEFAULT],
"ckeymap", 1);
}
#endif
/*
* Now create a keymap for each ship type that requires it.
*/
for (i = NUM_TYPES - 1; i >= 0; --i) {
if (keymaps[i])
keymaps[i] = InitKeyMap(keymaps[i]);
sprintf(buf, "keymap-%s", classes[i]);
if ((str = (unsigned char *) getdefault(buf)) != NULL) {
keymaps[i] = AddStringToKeymap(str, keymaps[i], buf, 0);
}
#ifdef CONTROL_KEY
sprintf(buf, "ckeymap-%s", classes[i]);
if ((str = (unsigned char *) getdefault(buf)) != NULL) {
keymaps[i] = AddStringToKeymap(str, keymaps[i], buf, 1);
}
#endif
}
/*
* Now extend keymap with keymap-default and ckeymap-default.
*/
if ((str = (unsigned char *) getdefault("keymap-default")) != NULL) {
keymaps[KEYMAP_DEFAULT] =
AddStringToKeymap(str, keymaps[KEYMAP_DEFAULT],
"keymap-default", 0);
}
#ifdef CONTROL_KEY
if ((str = (unsigned char *) getdefault("ckeymap-default")) != NULL) {
keymaps[KEYMAP_DEFAULT] =
AddStringToKeymap(str, keymaps[KEYMAP_DEFAULT],
"ckeymap-default", 1);
}
#endif
#ifdef SHOW_DEFAULTS
show_defaults("input-keymap", "keymap", "aabbcc",
"Maps new keys to old keys. Format: <new key><old key><new key><old key>...");
show_defaults("input-keymap", "keymap-[sc,dd,ca,bb,sb]", "",
"Ship-specific keymap extensions (default is keymap).");
show_defaults("input-keymap", "keymap-default", "",
"keymap extension used if keymap-<ship_type> is not defined");
#endif
#ifdef CONTROL_KEY /* COWlite */
#ifdef SHOW_DEFAULTS
show_defaults("input-keymap", "ckeymap", "^a^a^b^b^c^c",
"Control keys keymap. Format <new key><old key> ...\n\
Any combination of normal keys and control keys can be mapped to one\n\
another. In other words, you can map from control key to control key\n\
control key to normal key, normal key to normal key, and normal key\n\
to control key.\n\
\n\
New format for ckeymap is:\n\
c = any printable ascii character.\n\
^ = introduce control mapping (the key '^' not control + key.)\n\
\n\
Each entry is a pair, like:\n\
cc # regular format\n\
c^c # regular->control\n\
^cc # control->regular\n\
^c^c # control->control");
show_defaults("input-keymap", "ckeymap-[sc,dd,ca,bb,sb]", "",
"Ship-specific control-key map extensions (default is ckeymap)");
show_defaults("input-keymap", "ckeymap-default", "",
"ckeymap extension used if ckeymap-<ship_type> is not defined");
#endif
#endif
/* note: not stored on server */
for (i = 11; i >= 0; --i) /* Clear the current button map */
buttonmap[i] = '\0';
if ((str = (unsigned char *) getdefault("buttonmap")) != NULL)
AddStrToButtonMap(str, buttonmap);
#ifdef SHOW_DEFAULTS
show_defaults("input", "buttonmap", "1t2p3k4%5q6#7u8c9iaTbyc;",
"Maps buttons to key functions. Format: <button><key>... \n\
See the help window for key descriptions.\n\
<button> is in the range 1-3 if shiftedMouse is off. Otherwise the\n\
values are\n\
4 - shift+m1, 5 - shift+m2, 6 - shift+m3\n\
7 - ctrl+m1, 8 - ctrl+m2, 9 - ctrl+m3\n\
a - shift+ctrl+m1, b - shift+ctrl+m2, c - shift+ctrl+m3");
#endif
}
void
initinput()
{
/* Nothing doing... */
}
void
input()
{
fd_set readfds;
register
int xsock = W_Socket(); /* put it in a register */
register
int doflush = 0;
#ifdef RECORD_DEBUG
fprintf(RECORDFD, "input() called\n"); /* DBP */
#endif
while (1) {
FD_ZERO(&readfds);
FD_SET(xsock, &readfds);
FD_SET(sock, &readfds);
if (udpSock >= 0)
FD_SET(udpSock, &readfds);
select(max_fd, &readfds, 0, 0, 0);
if (FD_ISSET(xsock, &readfds) || W_EventsQueued()) {
process_event();
/* NOTE: we're no longer calling XPending(), need this */
doflush = 1;
}
if (FD_ISSET(sock, &readfds) ||
(udpSock >= 0 && FD_ISSET(udpSock, &readfds))) {
intrupt(&readfds);
/* NOTE: we're no longer calling XPending(), need this */
doflush = 1;
if (isServerDead()) {
printf("Whoops! We've been ghostbusted!\n");
printf("Pray for a miracle!\n");
/* UDP fail-safe */
commMode = commModeReq = COMM_TCP;
commSwitchTimeout = 0;
if (udpSock >= 0)
closeUdpConn();
if (udpWin) {
udprefresh(UDP_CURRENT);
udprefresh(UDP_STATUS);
}
connectToServer(nextSocket);
printf("Yea! We've been resurrected!\n");
}
}
/* NOTE: we're no longer calling XPending(), need this */
if (doflush) {
W_Flush();
doflush = 0;
}
}
}
int
process_event()
{
W_Event data;
register W_Window win;
do {
/* we don't need a loop here technically but it won't hurt */
if (!W_SpNextEvent(&data))
continue; /* continues at loop bottom */
win = data.Window;
switch ((int) data.type) {
case W_EV_KEY:
if (messageon) {
smessage(data.key);
}
/* move checks to top instead of inside keyaction() */
else if (win == w || win == mapw) {
keyaction(&data);
} else if (win == optionWin) {
optionaction(&data);
} else if (win == messagew || win == warnw) {
smessage(data.key);
} else if (motdWin && win == motdWin) {
motdWinEvent(data.key);
} else if ((infow && win == infow)
#ifdef SCAN
|| win == scanwin
#endif
) {
keyaction(&data);
}
break;
case W_EV_BUTTON:
/* move checks to top instead of inside buttonaction() */
if (win == w || win == mapw) {
buttonaction(&data);
} else if (win == war) {
waraction(&data);
} else if (win == optionWin) {
optionaction(&data);
} else if (win == udpWin) {
udpaction(&data); /* UDP */
} else if (win == messagew || win == warnw) {
if ((data.key == W_MBUTTON) && messpend)
smess_paste();
} else if ((infow && win == infow)
#ifdef SCAN
|| win == scanwin
#endif
) {
buttonaction(&data);
}
break;
case W_EV_EXPOSE:
/* most common first */
if (win == mapw) {
setup_redraw_map(data.x, data.y,
data.x + data.width, data.y + data.height);
#ifdef nodef
if (!redrawall)
redrawall = 2; /* no need to clear */
#endif
} else if (win == w) /* nothing special to do here */
;
else if (win == statwin)
redrawStats();
#ifdef NETSTAT
else if (win == lMeter)
redrawLMeter();
#endif
#ifdef PING
else if (win == pStats)
redrawPStats();
#endif
else if (win == tstatw)
redrawTstats();
else if (win == iconWin)
drawIcon();
else if (win == helpWin)
fillhelp();
#ifdef XTREKRC_HELP
else if (defWin && (win == defWin))
showdef();
#endif
else if (win == playerw)
playerlist();
else if (win == planetw)
planetlist();
else if (win == rankw)
ranklist();
else if (win == warnw)
W_ClearWindow(warnw);
else if (win == messagew)
smess_refresh();
else if (motdWin && win == motdWin)
motdWinEvent('r'); /* 'r' is refresh */
#ifdef FEATURE
else if (macroWin && win == macroWin)
fillmacro();
#endif
break;
default:
break;
}
}
while (W_EventsQueued());
return 1;
}
#ifdef XTRA
void
xinput()
{
static
struct timeval timeout =
{0, 0};
fd_set readfds;
int xsock = W_Socket();
FD_ZERO(&readfds);
FD_SET(xsock, &readfds);
if (select(max_fd, &readfds, 0, 0, &timeout) == 1) {
process_event();
}
}
#endif
void
keyaction(data)
W_Event *data;
{
unsigned char course;
struct obtype *gettarget(), *target;
register W_Window win = data->Window;
register unsigned char key = data->key;
static int last_det;
register now;
if ((infow && win == infow)
#ifdef SCAN
|| win == scanwin
#endif
) {
int x, y;
if (W_FindMouseInWin(&x, &y, w)) { /* local window */
win = w;
data->x = x;
data->y = y;
} else if (W_FindMouseInWin(&x, &y, mapw)) { /* galactic window */
win = mapw;
data->x = x;
data->y = y;
}
}
#ifdef RECORD
if(playback)
if(playback_keyaction(data)) /* was a playback command */
return;
#endif
#ifdef FEATURE
if (key == macrokey)
key = 'X';
#endif
if (!strchr("sbogadc", key) || !(localflags & PFREFIT)) {
if (key >= 32 && key < MAXKEY) {
key = mykeymap[key - 32];
}
}
#ifdef FEATURE
if (!MacroMode && singleMacro) {
if (strchr(singleMacro, data->key)) {
MacroMode = 1;
if (F_UseNewMacro)
MacroNum = -1;
}
}
if (MacroMode) {
doMacro(data->key, data);
return;
}
#endif
switch (key) {
#ifdef FEATURE
case 'X':
#if 0 /* assume server mechanism is sufficient */
gettimeofday(&curtp, NULL);
if (0 /* curtp.tv_sec < lasttp.tv_sec + 6 */ ) {
warning("Chill out with the messages!!");
break;
}
lasttp = curtp;
#endif
warning("In Macro Mode");
if (F_UseNewMacro)
MacroNum = -1;
MacroMode = 1;
break;
#endif
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
set_speed(key - '0');
localflags &= ~(PFREFIT);
break;
case 'e': /* Turn off docking permission, eject docked
* vessels. */
if (me->p_flags & PFDOCKOK)
sendDockingReq(0);
else
sendDockingReq(1);
break;
case 'r':
localflags |= PFREFIT;
#ifdef GALAXY
warning("s=scout, d=destroyer, c=cruiser, b=battleship, a=assault, g=galaxy, o=starbase/outpost");
#else
warning("s=scout, d=destroyer, c=cruiser, b=battleship, a=assault, o=starbase/outpost");
#endif /* GALAXY */
break;
case ')':
set_speed(10);
localflags &= ~(PFREFIT);
break;
case '!':
set_speed(11);
localflags &= ~(PFREFIT);
break;
case '@':
set_speed(12);
localflags &= ~(PFREFIT);
break;
case '#':
set_speed(me->p_ship.s_maxspeed / 2);
localflags &= ~(PFREFIT);
break;
case '%':
set_speed(99); /* Max speed... */
localflags &= ~(PFREFIT);
break;
case '&':
ReReadDefaults();
break;
#ifdef EM
case '>':
set_speed(me->p_speed + 1);
break;
case '<':
set_speed(me->p_speed - 1);
break;
case '{':
cloak_on();
break;
case '}':
cloak_off();
break;
#endif /* EM */
case 'a':
if (localflags & PFREFIT) {
do_refit(ASSAULT);
}
#ifdef SCAN
else {
if (!W_IsMapped(scanwin)) {
scan(win, data->x, data->y);
} else {
if (scanmapped)
W_UnmapWindow(scanwin);
scanmapped = 0;
}
}
#endif /* ATM */
break;
#ifdef GALAXY
case 'g':
if (localflags & PFREFIT) {
do_refit(SGALAXY);
}
break;
#endif /* GALAXY */
case 'm': /* new from galaxy -- works here too */
message_on();
break;
case 'k': /* k = set course */
course = getcourse(win, data->x, data->y);
set_course(course);
me->p_flags &= ~(PFPLOCK | PFPLLOCK);
localflags &= ~(PFREFIT);
break;
case 'K': /* K = reset clock to zero */
time(&basetime);
break;
case 'p': /* p = fire phasers */
course = getcourse(win, data->x, data->y);
sendPhaserReq(course);
break;
case 't': /* t = launch torps */
course = getcourse(win, data->x, data->y);
if ((now = mstime()) - last_torp >= 50) {
sendTorpReq(course);
last_torp = now;
}
break;
case 'f':
/* f = launch plasma torpedos */
course = getcourse(win, data->x, data->y);
sendPlasmaReq(course);
break;
case 'd': /* d = detonate other torps */
if (localflags & PFREFIT)
do_refit(DESTROYER);
else if ((now = mstime()) - last_det >= 100) {
sendDetonateReq();
last_det = now;
}
break;
case 'D': /* D = detonate my torps */
detmine();
break;
case '[':
shield_down();
break;
case ']':
shield_up();
break;
case 'u': /* u = toggle shields */
shield_tog();
break;
case 's': /* For Serge */
if (localflags & PFREFIT)
do_refit(SCOUT);
else
shield_tog();
break;
case 'b': /* b = bomb planet */
if (localflags & PFREFIT)
do_refit(BATTLESHIP);
else
bomb_planet();
break;
case 'z': /* z = beam up */
beam_up();
break;
case 'x': /* x = beam down */
beam_down();
break;
case 'R': /* R = Go into repair mode */
sendRepairReq(1);
break;
case 'y':
case 'T':
if (me->p_flags & (PFTRACT | PFPRESS)) {
sendTractorReq(0, me->p_no);
break;
}
target = gettarget(win, data->x, data->y, TARG_PLAYER);
me->p_tractor = target->o_num;
if (key == 'T') {
sendTractorReq(1, target->o_num);
} else {
sendRepressReq(1, target->o_num);
}
break;
/*
* Alternative tractor/pressor. These keys will nearly always be
* remapped.
*/
case '_':
if (me->p_flags & (PFTRACT | PFPRESS))
sendTractorReq(0, me->p_no);
target = gettarget(win, data->x, data->y, TARG_PLAYER);
me->p_tractor = target->o_num;
sendTractorReq(1, target->o_num);
break;
case '^':
if (me->p_flags & (PFTRACT | PFPRESS))
sendRepressReq(0, me->p_no);
target = gettarget(win, data->x, data->y, TARG_PLAYER);
me->p_tractor = target->o_num;
sendRepressReq(1, target->o_num);
break;
case '$':
sendTractorReq(0, me->p_no);
break;
case 'o': /* o = dock at nearby starbase or orbit
* nearest planet */
if (localflags & PFREFIT) {
do_refit(STARBASE);
} else {
sendOrbitReq(1);
}
break;
case 'O': /* O = options Window */
if (optionWin != NULL && W_IsMapped(optionWin))
optiondone();
else
optionwindow();
break;
case 'q':
if (fastQuitOk)
fastQuit = 1;
case 'Q':
sendQuitReq();
break;
case 'V':
showlocal++;
if (showlocal == 4)
showlocal = 0;
if (optionWin)
optionredrawoption(&showlocal);
break;
case 'B':
showgalactic++;
if (showgalactic == 3)
showgalactic = 0;
if (!redrawall)
redrawall = 2;
if (optionWin)
optionredrawoption(&showlocal);
break;
case '?': /* ? = Redisplay all message windows */
if(!W_IsMapped(reviewWin))
W_MapWindow(reviewWin);
else
W_UnmapWindow(reviewWin);
if(!W_IsMapped(phaserwin))
W_MapWindow(phaserwin);
else
W_UnmapWindow(phaserwin);
if(!W_IsMapped(messwa))
W_MapWindow(messwa);
else
W_UnmapWindow(messwa);
if(!W_IsMapped(messwt))
W_MapWindow(messwt);
else
W_UnmapWindow(messwt);
if(!W_IsMapped(messwi))
W_MapWindow(messwi);
else
W_UnmapWindow(messwi);
if(!W_IsMapped(messwk))
W_MapWindow(messwk);
else
W_UnmapWindow(messwk);
#if 0
/* the logic below is badly contorted */
if (W_IsMapped(phaserwin))
phaserWindow = 1;
if (!W_IsMapped(reviewWin)) {
if (W_IsMapped(messwa)) {
W_UnmapWindow(messwa);
W_UnmapWindow(phaserwin);
W_UnmapWindow(messwt);
W_UnmapWindow(messwi);
W_UnmapWindow(messwk);
} else {
W_MapWindow(reviewWin);
}
} else {
W_UnmapWindow(reviewWin);
W_MapWindow(messwa);
W_MapWindow(messwt);
W_MapWindow(messwi);
W_MapWindow(messwk);
if (phaserWindow)
W_MapWindow(phaserwin);
}
#endif
if (optionWin) {
optionredrawtarget(reviewWin);
optionredrawtarget(messwa);
optionredrawtarget(phaserwin);
optionredrawtarget(messwt);
optionredrawtarget(messwi);
optionredrawtarget(messwk);
}
break;
case 'c': /* c = cloak */
if (localflags & PFREFIT)
do_refit(CRUISER);
else
cloak();
break;
case 'C': /* C = coups */
sendCoupReq();
break;
case 'l': /* l = lock onto */
target = gettarget(win, data->x, data->y,
TARG_PLAYER | TARG_PLANET);
if (target->o_type == PLAYERTYPE) {
sendPlaylockReq(target->o_num);
me->p_playerl = target->o_num;
redrawPlayer[me->p_playerl] = 1;
} else { /* It's a planet */
sendPlanlockReq(target->o_num);
me->p_planet = target->o_num;
planets[me->p_planet].pl_flags |= PLREDRAW;
}
break;
case '*':
sendPractrReq();
break;
/* Start of display functions */
case ' ': /* ' ' = clear special windows */
W_UnmapWindow(planetw);
W_UnmapWindow(rankw);
if (infomapped)
destroyInfo();
W_UnmapWindow(helpWin);
#ifdef XTREKRC_HELP
if (defWin)
W_UnmapWindow(defWin);
#endif
W_UnmapWindow(war);
if (optionWin)
optiondone();
#ifdef SCAN
if (scanmapped) {
W_UnmapWindow(scanwin);
scanmapped = 0;
}
#endif
if (udpWin)
udpdone();
break;
case 'E': /* E = send emergency call */
#ifdef FEATURE
rcd(generic, data);
#else
emergency();
#endif
break;
#ifdef FEATURE
case 'F': /* F = send armies carried report */
rcd(carrying, data);