-
Notifications
You must be signed in to change notification settings - Fork 1
/
redraw.c
1920 lines (1744 loc) · 51.3 KB
/
redraw.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
/*
* redraw.c
*/
#include "copyright.h"
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include <math.h>
#include <time.h>
#include <sys/types.h>
#include <sys/time.h>
#include "netrek.h"
#ifdef RECORD
#include "recorder.h"
#endif
#if __STDC__ || defined(__cplusplus)
#define P_(s) s
#else
#define P_(s) ()
#endif
/* redraw.c */
static void get_shrink_phaser_coords P_((int *rx, int *ry, register dx, register dy, register tx, register ty, register curr_fuse, register max_fuse));
#undef P_
#define XPI 3.1415926
static int clearzone[4][(MAXTORP + 1) * MAXPLAYER +
(MAXPLASMA + 1) * MAXPLAYER + MAXPLANETS];
static int clearcount;
/* galactic edges, phasers (2 lines at most) */
static int clearline[4][4 + 2 * MAXPLAYER];
static int clearlcount;
/* tractors */
static int cleartpline[4][2];
static int cleartplcount;
static int clearlmark[4];
static int clearlmcount;
#ifndef FOR_MORONS
static int mclearzone[6][MAXPLAYER]; /* For map window */
#else /* FOR_MORONS */
static int mclearzone[6][MAXPLAYER + MAXPLANETS]; /* For map window */
int For_Morons = 0; /* set this to 1 for defaulting to MORON mode */
short FlashChange = 1;
static time_t lastflash;
#define BOLD_ON ( lastread % 2) /* whether to show flash this update */
#endif /* FOR_MORONS */
static short nplayers;
#ifdef FOR_MORONS
static time_t lastread;
#endif
void
intrupt(readfds)
fd_set *readfds;
{
time_t time();
udcounter++;
if (readFromServer(readfds)) {
#ifdef XTRA
xinput();
#endif
#ifdef FOR_MORONS
lastread = time(NULL);
#endif
#ifndef NO_TRAP
errcount = 0; /* reset the signal handler error counters */
#endif
#ifdef FOR_MORONS
if (For_Morons) {
if (lastread != lastflash) {
FlashChange = 1;
lastflash = lastread;
} else {
FlashChange = 0;
}
}
/* cache RealNumShips */
(void) RealNumShips(-1);
#endif
#ifdef EM
if (sortPlayers) {
if(!teamOrder) /* DBP */
Sorted_playerlist2();
else Sorted_playerlist3(); /* DBP */
}
#endif
#ifdef RECORD
if(!playback || playback_update)
#endif
redraw();
#ifdef RECORD
if(playback) {
if(playback_update) {
playback_update = 0;
/* fprintf(stderr, "reset playback_update to 0\n"); */
}
if(pb_mode == SCAN) {
/* Record our current alert status */
switch(pb_alert_scan) {
case PB_RED:
if(pb_alert == PB_RED && me->p_flags & PFRED) {
/* We started scan in red-alert, keep looking for next one */
;
}
else {
if(me->p_flags & PFRED) {
pb_alert = PB_RED; /* Found our status, pause */
pb_paused = 1;
db_redraw(1);
}
else {
pb_alert = PB_NONE;
}
}
break;
case PB_YELLOW:
if(pb_alert == PB_YELLOW && me->p_flags & PFYELLOW) {
/* We started scan in yellow-alert, keep looking for next one */
;
}
else {
if(me->p_flags & PFYELLOW) {
pb_alert = PB_YELLOW; /* Found our status, pause */
pb_paused = 1;
db_redraw(1);
}
else pb_alert = PB_NONE;
}
break;
case PB_GREEN:
if(pb_alert == PB_GREEN && me->p_flags & PFGREEN) {
/* We started scan in green-alert, keep looking for next one */
;
}
else {
if(me->p_flags & PFGREEN) {
pb_alert = PB_GREEN; /* Found our status, pause */
pb_paused = 1;
db_redraw(1);
}
else pb_alert = PB_NONE;
}
break;
case PB_DEATH:
if(pb_alert == PB_DEATH && me->p_status != PALIVE) {
/* We started scan dead, keep looking for next one */
;
}
else {
if(me->p_status != PALIVE) {
pb_alert = PB_DEATH; /* Found our status, pause */
pb_paused = 1;
db_redraw(1);
}
else pb_alert = PB_NONE;
}
break;
case PB_NONE:
default:
break;
} /* switch(pb_alert_scan) */
} /* if(pb_mode == SCAN) */
} /* if(playback) */
#endif
/* regular player list called from redraw */
#ifdef RECORD
if(recordGame)
recordUpdate();
#endif
}
if (reinitPlanets) {
initPlanets();
reinitPlanets = 0;
}
#ifdef FOR_MORONS /* my thinking is is you haven't heard from
* the server, no amount of pinging is going
* to help */
if (lastread + 3 < time(NULL)) {
/*
* We haven't heard from server for awhile... Strategy: send a useless
* packet to "ping" server.
*/
printf("Server might be dead, pinging with a war req!\n");
sendWarReq(me->p_hostile);
}
#endif
/*
* New: scrolling windows updated every other update instead of for every
* message packet
*/
if ((udcounter % 2) == 0) {
W_FlushScrollingWindow(messwa);
W_FlushScrollingWindow(messwt);
W_FlushScrollingWindow(messwi);
W_FlushScrollingWindow(messwk);
W_FlushScrollingWindow(reviewWin);
}
if (me->p_status == POUTFIT) {
death();
}
}
void
redraw()
{
/* erase warning line if necessary */
if (warncount && (warntimer <= udcounter)) {
W_ClearArea(warnw, 5, 5, W_Textwidth * warncount, W_Textheight);
warncount = 0;
}
if (W_FastClear) {
W_ClearWindow(w);
clearcount = 0;
clearlcount = 0;
cleartplcount = 0;
} else {
while (clearcount) {
clearcount--;
W_CacheClearArea(w, clearzone[0][clearcount],
clearzone[1][clearcount], clearzone[2][clearcount],
clearzone[3][clearcount]);
}
while (clearlcount) {
clearlcount--;
W_CacheLine(w, clearline[0][clearlcount], clearline[1][clearlcount],
clearline[2][clearlcount], clearline[3][clearlcount],
backColor);
}
W_FlushClearAreaCache(w);
W_FlushLineCaches(w);
while (cleartplcount) {
cleartplcount--;
W_MakeTractLine(w, cleartpline[0][cleartplcount],
cleartpline[1][cleartplcount],
cleartpline[2][cleartplcount],
cleartpline[3][cleartplcount],
backColor);
}
}
#ifdef TTS
if (tts && tts_timer) {
static int last_width;
tts_timer--;
if (!tts_timer) {
/* timed out */
if (!W_FastClear)
W_EraseTTSText(w, WINSIDE, tts_loc, last_width);
last_width = 0;
} else if (tts_timer == tts_time - 1 && last_width) {
/* first draw -- erase previous */
if (!W_FastClear)
W_EraseTTSText(w, WINSIDE, tts_loc, last_width);
/* draw new */
W_WriteTTSText(w, WINSIDE, tts_loc, tts_width, lastIn,
tts_len);
last_width = tts_width;
} else {
/* regular draw */
W_WriteTTSText(w, WINSIDE, tts_loc, tts_width, lastIn, tts_len);
last_width = tts_width;
}
}
#endif
local(); /* redraw local window */
#ifdef XTRA
xinput();
#endif
W_FlushLineCaches(w);
#ifdef RECORD
if(playback && update_dashboard) {
db_redraw(1);
update_dashboard = 0;
}
else
#endif
db_redraw(0);
if (W_IsMapped(statwin))
updateStats();
if (mapmode)
map();
if (tclock)
run_clock(0); /* I want it where I'm looking dammit */
}
#ifndef FONT_BITMAPS
W_Icon
planetmBitmap(p)
register struct planet *p;
{
int i;
if (showgalactic == 2) {
return (mbplanets[0]);
} else if (p->pl_info & me->p_team) {
if (showgalactic == 1) {
i = 0;
if (p->pl_armies > 4)
i += 4;
if (p->pl_flags & PLREPAIR)
i += 2;
if (p->pl_flags & PLFUEL)
i += 1;
#ifdef MOOBITMAPS
if (myPlanetBitmap)
return (mbplanets3[i]); /* <isae> new bitmaps */
else
#endif /* MOOBITMAPS */
return (mbplanets2[i]);
} else {
return (mbplanets[remap[p->pl_owner]]);
}
} else {
return (mbplanets[5]);
}
}
#endif
void
DrawLocalPlanets()
/*
* Draw the local planets on the tacktical map.
*
* This procedure has been created to keep all the planet stuff together and
* so that separate procedures do not have to be used to select which
* bitmap should be used for each planet.
*/
{
register int my_x = me->p_x, my_y = me->p_y;
register struct planet *l;
int dx, dy;
int view;
#ifndef FONT_BITMAPS
int iconNum;
W_Icon icon;
#endif
view = SCALE * WINSIDE / 2;
l = planets + MAXPLANETS;
while (l != planets) {
--l;
dx = l->pl_x - my_x;
if (dx > view || dx < -view)
continue;
dy = l->pl_y - my_y;
if (dy > view || dy < -view)
continue;
dx = dx / SCALE + WINSIDE / 2;
dy = dy / SCALE + WINSIDE / 2;
#ifdef FONT_BITMAPS
W_MaskText(w, dx - (planet_width / 2), dy - (planet_height / 2),
planetColor(l), F_planetChar(l), 1, F_planetFont());
#else /* no FONT_BITMAPS */
if (l->pl_info & me->p_team) {
if (showlocal == 0) /* show owner */
icon = bplanets[remap[l->pl_owner]];
else if (showlocal == 2) /* show nothing */
icon = bplanets[0];
else {
iconNum = (l->pl_armies > 4) ? 4 : 0;
if (l->pl_flags & PLREPAIR)
iconNum += 2;
if (l->pl_flags & PLFUEL)
iconNum += 1;
if (showlocal == 1) /* show resources */
icon = bplanets2[iconNum];
else /* showlocal == 3 */
/* show rabbit ears */
icon = bplanets3[iconNum];
}
} else { /* No info */
icon = bplanets[5];
}
W_WriteBitmap(dx - (planet_width / 2), dy - (planet_height / 2),
icon, planetColor(l));
#endif /* no FONT_BITMAPS */
if (showInd && (l->pl_info & me->p_team) && (l->pl_owner == NOBODY)) {
W_CacheLine(w, dx - (planet_width / 2), dy - (planet_height / 2),
dx + (planet_width / 2 - 1), dy + (planet_height / 2 - 1),
W_White);
W_CacheLine(w, dx + (planet_width / 2 - 1), dy - (planet_height / 2),
dx - (planet_width / 2), dy + (planet_height / 2 - 1),
W_White);
}
clearzone[0][clearcount] = dx - (planet_width / 2);
clearzone[1][clearcount] = dy - (planet_height / 2);
clearzone[2][clearcount] = planet_width;
clearzone[3][clearcount] = planet_height;
clearcount++;
if (namemode) {
int pl_name_width;
int pl_namelen;
if (namemode == 1)
/* draw a maximum of 5 characters */
pl_namelen = l->pl_namelen < 5 ? l->pl_namelen : 5;
else
pl_namelen = l->pl_namelen;
pl_name_width = W_Textwidth * pl_namelen;
W_MaskText(w, dx - (planet_width / 2), dy + (planet_height / 2),
planetColor(l), l->pl_name, pl_namelen,
planetFont(l));
if (pl_name_width <= planet_width) {
clearzone[3][clearcount - 1] += W_Textheight;
} else {
clearzone[0][clearcount] = dx - (planet_width / 2);
clearzone[1][clearcount] = dy + (planet_height / 2);
clearzone[2][clearcount] = pl_name_width;
clearzone[3][clearcount] = W_Textheight;
clearcount++;
}
}
}
}
/* draw out the 'tactical' map */
void
local()
{
register int h, i, my_x = me->p_x, my_y = me->p_y;
register struct player *j;
register struct torp *k;
register struct phaser *php;
register struct plasmatorp *pt;
static int tcounter = 2;
register int color;
int dx, dy;
int view;
char idbuf[10];
#if !defined(DYNAMIC_BITMAPS) && !defined(FONT_BITMAPS)
W_Icon(*ship_bits)[VIEWS];
#endif
if (my_x < 0)
return;
/*
* Kludge to try to fix missing ID chars on tactical (short range)
* display.
*/
idbuf[0] = '0';
idbuf[1] = '\0';
DrawLocalPlanets();
/* Draw ships */
nplayers = 0;
view = SCALE * WINSIDE / 2;
for (i = 0, j = &players[i]; i < MAXPLAYER; i++, j++) {
if (updatePlayer[i]) { /* NEW */
#ifdef EM
if (!sortPlayers)
#endif
playerlist3(i);
}
if ((j->p_status != PALIVE) && (j->p_status != PEXPLODE))
continue;
/***
if(j->p_flags & PFOBSERV)
continue; * INL *
***/
/* DBP */
/* Only draw observer's ship if it's me, I'm locked onto a player,
and the player is cloaked. For non-cloaked ship, we pick it up
seperately when the observed player's ship is drawn. */
if(j->p_flags & PFOBSERV) { /* j is an observer */
if(j != me || !(me->p_flags & PFPLOCK)) /* I am j and player locked */
continue;
else if(!((&players[me->p_playerl])->p_flags & PFCLOAK)) /* cloaked */
continue;
}
nplayers++;
if (j->p_flags & PFCLOAK) {
if (j->p_cloakphase < (CLOAK_PHASES - 1)) {
j->p_cloakphase++;
}
} else {
if (j->p_cloakphase) {
j->p_cloakphase--;
}
}
dx = j->p_x - my_x;
if (dx > view || dx < -view) {
/* if he's off screen we don't draw phasers anyway */
phasers[j->p_no].ph_status = PHFREE;
continue;
}
dy = j->p_y - my_y;
if (dy > view || dy < -view) {
/* if he's off screen we don't draw phasers anyway */
phasers[j->p_no].ph_status = PHFREE;
continue;
}
dx = dx / SCALE + WINSIDE / 2;
dy = dy / SCALE + WINSIDE / 2;
if (j->p_flags & PFCLOAK && (j->p_cloakphase == (CLOAK_PHASES - 1))) {
if (myPlayer(j)) {
#ifdef FONT_BITMAPS
W_MaskText(w, dx - (cloak_width / 2), dy - (cloak_height / 2),
myColor, F_cloakChar(), 1, F_cloakFont());
#else
W_WriteBitmap(dx - (cloak_width / 2), dy - (cloak_height / 2),
cloakicon, myColor);
#endif
clearzone[0][clearcount] = dx - (shield_width / 2);
clearzone[1][clearcount] = dy - (shield_height / 2);
clearzone[2][clearcount] = shield_width;
clearzone[3][clearcount] = shield_height;
clearcount++;
/* hmm... I guess this is ok now */
if (showShields && (me->p_flags & PFSHIELD)) {
int shieldnum;
if (VShieldBitmaps) {
shieldnum = SHIELD_FRAMES * me->p_shield / me->p_ship.s_maxshield
;
if (shieldnum >= SHIELD_FRAMES)
shieldnum = SHIELD_FRAMES - 1;
color = gColor;
if (shieldnum < SHIELD_FRAMES * 2 / 3) {
color = yColor;
if (shieldnum < SHIELD_FRAMES * 2 / 3) {
color = rColor;
}
}
} else {
color = playerColor(me);
shieldnum = 2;
}
#ifdef FONT_BITMAPS
W_MaskText(w, dx - (shield_width / 2), dy - (shield_height / 2),
color, F_shieldChar(shieldnum), 1, F_shieldFont());
#else
W_WriteBitmap(dx - (shield_width / 2),
dy - (shield_height / 2), shield[shieldnum], color);
#endif
}
}
continue;
}
if (j->p_status == PALIVE) {
#if !defined(DYNAMIC_BITMAPS) && !defined(FONT_BITMAPS)
switch (j->p_team) {
case FED:
ship_bits = fed_bitmaps;
break;
case ROM:
ship_bits = rom_bitmaps;
break;
case KLI:
ship_bits = kli_bitmaps;
break;
case ORI:
ship_bits = ori_bitmaps;
break;
default:
ship_bits = ind_bitmaps;
break;
}
#endif
clearzone[0][clearcount] = dx - (shield_width / 2);
clearzone[1][clearcount] = dy - (shield_height / 2);
clearzone[2][clearcount] = shield_width;
clearzone[3][clearcount] = shield_height;
/* we wait til after drawing text number to increment clearcount */
#ifdef FONT_BITMAPS
#ifdef HOCKEY
if (j->p_ispuck)
W_MaskText(w, dx - (shield_width / 2), dy - (shield_width / 2),
playerColor(j), F_puckChar(j->p_dir), 1, F_puckFont());
else
#endif
W_MaskText(w, dx - (shield_width / 2), dy - (shield_width / 2),
playerColor(j),
F_shipChar(j->p_team, j->p_ship.s_type, j->p_dir),
1, F_playerFont(j->p_team));
#else
#ifdef HOCKEY
if (j->p_ispuck)
W_WriteBitmap(dx - (j->p_ship.s_width / 2),
dy - (j->p_ship.s_height / 2),
puck_bitmaps[rosette(j->p_dir)], playerColor(j));
else
#endif
W_WriteBitmap(dx - (j->p_ship.s_width / 2),
dy - (j->p_ship.s_height / 2),
#ifndef DYNAMIC_BITMAPS
ship_bits[j->p_ship.s_type][rosette(j->p_dir)],
#else
ship_bitmaps[PlayerBitmap(j)][rosette(j->p_dir)],
#endif
playerColor(j));
#endif /* FONT_BITMAPS */
if (j->p_cloakphase > 0) {
#ifdef FONT_BITMAPS
W_MaskText(w, dx - (cloak_height / 2), dy - (cloak_width / 2),
playerColor(j), F_cloakChar(), 1, F_cloakFont());
#else
W_WriteBitmap(dx - (cloak_width / 2),
dy - (cloak_height / 2), cloakicon, playerColor(j));
#endif
clearcount++;
continue;
}
if (showShields && (j->p_flags & PFSHIELD)) {
int shieldnum;
if (j == me && VShieldBitmaps) {
shieldnum = SHIELD_FRAMES * me->p_shield / me->p_ship.s_maxshield;
if (shieldnum >= SHIELD_FRAMES)
shieldnum = SHIELD_FRAMES - 1;
color = gColor;
if (shieldnum < SHIELD_FRAMES * 2 / 3) {
color = yColor;
if (shieldnum < SHIELD_FRAMES * 2 / 3) {
color = rColor;
}
}
} else {
color = playerColor(j);
shieldnum = 2;
}
#ifdef FONT_BITMAPS
W_MaskText(w, dx - (shield_width / 2), dy - (shield_height / 2),
color, F_shieldChar(shieldnum), 1, F_shieldFont());
#else
W_WriteBitmap(dx - (shield_width / 2),
dy - (shield_height / 2), shield[shieldnum], color);
#endif /* FONT_BITMAPS */
} {
idbuf[0] = *(shipnos + j->p_no);
color = playerColor(j);
if (j == me) {
switch (me->p_flags & (PFGREEN | PFYELLOW | PFRED)) {
case PFGREEN:
color = gColor;
break;
case PFYELLOW:
color = yColor;
break;
case PFRED:
color = rColor;
break;
}
}
#ifdef HOCKEY
if (!j->p_ispuck)
#endif
W_MaskText(w, dx + (j->p_ship.s_width / 2),
dy - (j->p_ship.s_height / 2), color,
idbuf, 1, shipFont(j));
/* save a clearzone */
clearzone[2][clearcount] += W_Textwidth;
clearcount++;
}
} else if (j->p_status == PEXPLODE) {
int i;
i = j->p_explode;
if (i < EX_FRAMES || (i < SBEXPVIEWS && j->p_ship.s_type == STARBASE)) {
if (j->p_ship.s_type == STARBASE) {
#ifdef FONT_BITMAPS
W_MaskText(w, dx - (sbexp_width / 2), dy - (sbexp_height / 2),
playerColor(j), F_expSbChar(i), 1, F_explodeFont());
#else
W_WriteBitmap(dx - (sbexp_width / 2),
dy - (sbexp_height / 2), sbexpview[i],
playerColor(j));
#endif
clearzone[0][clearcount] = dx - (sbexp_width / 2);
clearzone[1][clearcount] = dy - (sbexp_height / 2);
clearzone[2][clearcount] = sbexp_width;
clearzone[3][clearcount] = sbexp_height;
} else {
#ifdef FONT_BITMAPS
W_MaskText(w, dx - (ex_width / 2), dy - (ex_height / 2),
playerColor(j), F_expChar(i), 1, F_explodeFont());
#else
W_WriteBitmap(dx - (ex_width / 2), dy - (ex_height / 2),
expview[i], playerColor(j));
#endif
clearzone[0][clearcount] = dx - (ex_width / 2);
clearzone[1][clearcount] = dy - (ex_height / 2);
clearzone[2][clearcount] = ex_width;
clearzone[3][clearcount] = ex_height;
}
clearcount++;
j->p_explode++;
}
#ifdef DROP_FIX
/* done exploding. Must be off screen */
else if (drop_fix && j != me
/* special cse for critters */
&& j->p_ship.s_type != ATT) {
j->p_x = -100000;
j->p_y = -100000;
}
#endif
}
/* Now draw his phaser (if it exists) */
php = &phasers[j->p_no];
if (php->ph_status != PHFREE) {
register int tx, ty;
int draw_ph = 1;
switch (php->ph_status) {
case PHMISS:
/* Here I will have to compute end coordinate */
tx = j->p_x + PHASEDIST * j->p_ship.s_phaserdamage / 100 * Cos[(unsigned char)php->ph_dir];
ty = j->p_y + PHASEDIST * j->p_ship.s_phaserdamage / 100 * Sin[(unsigned char)php->ph_dir];
tx = (tx - my_x) / SCALE + WINSIDE / 2;
ty = (ty - my_y) / SCALE + WINSIDE / 2;
#ifdef DROP_FIX
if (
#ifdef FEATURE
!F_phaser_multi_send &&
#endif
drop_fix) {
if (udcounter - php->ph_lastupdate > 2 * updates_per_second) {
/*
* dmessage("missed phaser freed", MTEAM+MVALID, me->p_no,
* 0);
*/
php->ph_status = PHFREE;
draw_ph = 0;
}
}
#endif
break;
case PHHIT2:
tx = (php->ph_x - my_x) / SCALE + WINSIDE / 2;
ty = (php->ph_y - my_y) / SCALE + WINSIDE / 2;
#ifdef DROP_FIX
if (
#ifdef FEATURE
!F_phaser_multi_send &&
#endif
drop_fix) {
if (udcounter - php->ph_lastupdate > 2 * updates_per_second) {
/*
* dmessage("phhit2 phaser freed", MTEAM+MVALID, me->p_no,
* 0);
*/
php->ph_status = PHFREE;
draw_ph = 0;
}
}
#endif
break;
default:
/* Start point is dx, dy */
{
struct player *targ = &players[php->ph_target];
tx = (targ->p_x - my_x) / SCALE + WINSIDE / 2;
ty = (targ->p_y - my_y) / SCALE + WINSIDE / 2;
#ifdef DROP_FIX
if (tx < 0 || ty < 0) {
php->ph_status = PHFREE;
draw_ph = 0;
} else if (
#ifdef FEATURE
!F_phaser_multi_send &&
#endif
drop_fix) {
/*
* here's the heuristic -- is the phaser too long to be
* real? Don't draw it (we rely on phaserdamage here)
*/
if (ihypot((j->p_x - targ->p_x), (j->p_y - targ->p_y)) >
PHASEDIST * j->p_ship.s_phaserdamage / 100 &&
udcounter - php->ph_lastupdate > 2 * updates_per_second) {
/*
* dmessage("too long phaser freed", MTEAM+MVALID,
* me->p_no, 0);
*/
php->ph_status = PHFREE;
draw_ph = 0;
}
}
#endif
#ifdef nodef
/* if this player is also phasering j, draw differently */
if (phasers[targ->p_no].ph_status == PHHIT &&
phasers[targ->p_no].ph_target == j->p_no)
duel = 1;
#endif
}
break;
}
if (tx == dx && ty == dy)
draw_ph = 0;
if (draw_ph) {
int new_dx = dx, new_dy = dy;
if (php->ph_status == PHMISS || ((php->ph_fuse % 2) == 0) ||
!friendlyPhaser(php))
color = shipCol[remap[j->p_team]];
else
color = foreColor;
/* BRM */
if (enemyPhasers && !friendlyPhaser(php)) {
register int wx, wy, lx, ly;
#ifdef PHASER_SHRINK
if (shrink_phasers && php->ph_status != PHMISS) {
get_shrink_phaser_coords(&new_dx, &new_dy,
dx, dy, tx, ty, php->ph_fuse, php->ph_maxfuse);
}
#endif
wx = new_dx + enemyPhasers * Cos[(unsigned char) (php->ph_dir + 64)];
wy = new_dy + enemyPhasers * Sin[(unsigned char) (php->ph_dir + 64)];
lx = new_dx + enemyPhasers * Cos[(unsigned char) (php->ph_dir - 64)];
ly = new_dy + enemyPhasers * Sin[(unsigned char) (php->ph_dir - 64)];
W_CacheLine(w, wx, wy, tx, ty, color);
clearline[0][clearlcount] = wx;
clearline[1][clearlcount] = wy;
clearline[2][clearlcount] = tx;
clearline[3][clearlcount] = ty;
clearlcount++;
W_CacheLine(w, lx, ly, tx, ty, color);
clearline[0][clearlcount] = lx;
clearline[1][clearlcount] = ly;
clearline[2][clearlcount] = tx;
clearline[3][clearlcount] = ty;
clearlcount++;
} else {
#ifdef PHASER_SHRINK
if (shrink_phasers && php->ph_status != PHMISS) {
get_shrink_phaser_coords(&new_dx, &new_dy,
dx, dy, tx, ty, php->ph_fuse, php->ph_maxfuse);
/*
* if(php->ph_status == PHHIT) printf("%d, %d, %d, %d,
* ph_fuse %d\n", new_dx, new_dy, tx, ty, php->ph_fuse);
*/
}
#endif
W_CacheLine(w, new_dx, new_dy, tx, ty, color);
clearline[0][clearlcount] = new_dx;
clearline[1][clearlcount] = new_dy;
clearline[2][clearlcount] = tx;
clearline[3][clearlcount] = ty;
clearlcount++;
}
php->ph_fuse++;
#if 0
/* TMP */
printf("fuse now at %d.\n", php->ph_fuse);
#endif
if (php->ph_fuse > php->ph_maxfuse + 1) {
#ifdef FEATURE
if (F_phaser_multi_send){
php->ph_status = PHFREE;
/* TMP */
#if 0
printf("freeing phaser.\n");
#endif
}
#endif
#ifdef PHASER_SHRINK
php->ph_fuse = 0;
#endif
}
}
}
/* ATM - show tractor/pressor beams (modified by James Collins) */
/* showTractorPressor is a variable set by xtrekrc. */
if (showTractorPressor) {
if (j == me && (j->p_flags & (PFTRACT | PFPRESS)) && j->p_status == PALIVE) {
double theta;
unsigned char dir;
int lx[2], ly[2], px, py, target_width;
struct player *tractee;
if (me->p_tractor < 0 || me->p_tractor >= MAXPLAYER)
continue;
tractee = &players[me->p_tractor];
if (tractee->p_status != PALIVE ||
((tractee->p_flags & PFCLOAK) && (tractee->p_cloakphase == (CLOAK_PHASES - 1))))
continue;
if (tcounter >= 2) {/* continue tractor stuff */
if (!continueTractor)
tcounter--;
px = (players[me->p_tractor].p_x - my_x) / SCALE + WINSIDE / 2;
py = (players[me->p_tractor].p_y - my_y) / SCALE + WINSIDE / 2;
if (px == dx && py == dy)
continue; /* this had better be last in for(..) */
theta = atan2((double) (px - dx), (double) (dy - py)) + XPI / 2.0;
dir = (unsigned char) (theta / XPI * 128.0);
if (tractee->p_flags & PFSHIELD)
target_width = shield_width;
else {
target_width = tractee->p_ship.s_width / 2;
}
lx[0] = px + (Cos[dir] * (target_width / 2));
ly[0] = py + (Sin[dir] * (target_width / 2));
lx[1] = px - (Cos[dir] * (target_width / 2));
ly[1] = py - (Sin[dir] * (target_width / 2));
if (j->p_flags & PFPRESS) {
W_MakeTractLine(w, dx, dy, lx[0], ly[0], W_Yellow);
W_MakeTractLine(w, dx, dy, lx[1], ly[1], W_Yellow);
} else {
W_MakeTractLine(w, dx, dy, lx[0], ly[0], W_Green);
W_MakeTractLine(w, dx, dy, lx[1], ly[1], W_Green);
}
cleartpline[0][cleartplcount] = dx;
cleartpline[1][cleartplcount] = dy;
cleartpline[2][cleartplcount] = lx[1];
cleartpline[3][cleartplcount] = ly[1];
cleartplcount++;
cleartpline[0][cleartplcount] = dx;
cleartpline[1][cleartplcount] = dy;
cleartpline[2][cleartplcount] = lx[0];
cleartpline[3][cleartplcount] = ly[0];
cleartplcount++;
} else
tcounter = 2;
}
}