comparison redraw.c @ 3:5a977ccbc7a9 default tip

Empty changelog
author darius
date Sat, 06 Dec 1997 05:41:29 +0000
parents
children
comparison
equal deleted inserted replaced
2:fba0b6e6cdc7 3:5a977ccbc7a9
1 /*
2 * redraw.c
3 */
4 #include "copyright.h"
5
6 #include <stdio.h>
7 #include <signal.h>
8 #include <math.h>
9 #include <ctype.h>
10 #include "Wlib.h"
11 #include "defs.h"
12 #include "struct.h"
13 #include "data.h"
14 #include "packets.h"
15 #include "proto.h"
16 #include "gameconf.h"
17 #ifdef SOUND
18 #include "Slib.h"
19 #endif
20 #include "sound.h"
21
22 typedef struct tractor Tractor;
23 struct tractor {
24 int sx, sy, d1x, d1y, d2x, d2y; /* source (x,y) dest (x1,y1) (x2,y2) */
25 Tractor *next;
26 } *tracthead = NULL, *tractcurrent = NULL, *tractrunner;
27
28 struct _clearzone *
29 new_czone()
30 {
31 if (clearzone == 0) {
32 czsize = 10;
33 clearzone = (struct _clearzone *) malloc(sizeof(*clearzone) * czsize);
34 clearcount = 0;
35 } else if (clearcount >= czsize) {
36 clearzone = (struct _clearzone *) realloc(clearzone,
37 sizeof(*clearzone) * (czsize *= 2));
38 }
39 return &clearzone[clearcount++];
40 }
41
42 /* Prototypes */
43 static void local P((void));
44 #ifndef COW_HAS_IT_WHY_SHOULDNT_WE
45 static
46 #endif
47 void map P((void));
48 static void redraw P((void));
49 /* static void stline P((int flag));*/
50 static W_Icon planetBitmap P((struct planet * p));
51 static W_Icon planetmBitmap P((struct planet * p));
52
53 void
54 intrupt()
55 {
56 static long lastread;
57 static struct timeval lastredraw = {0, 0};
58 struct timeval t;
59 static int needredraw=0;
60
61 #ifndef __osf__
62 long time();
63 #endif
64
65 udcounter++;
66
67 needredraw += readFromServer();
68
69 gettimeofday(&t, NULL);
70 if (needredraw && ((unsigned int) redrawDelay * 100000 <
71 (unsigned int) ((t.tv_sec - lastredraw.tv_sec) * 1000000
72 + (t.tv_usec - lastredraw.tv_usec)))) {
73 needredraw = 0;
74 lastredraw=t;
75 #if 0
76 lastread = time(NULL);
77 #endif
78 #ifdef RECORDER
79 if (!playback || (pb_update &&
80 ((!pb_scan) || !(udcounter % pb_advance))))
81 #endif
82 {
83 redraw();
84 playerlist2();
85 }
86 #ifdef RECORDER
87 if (playback) {
88 if(!pb_scan) {
89 if (pb_advance > 0) {
90 if ((pb_advance -= pb_update) <= 0) {
91 pb_advance = 0;
92 paused = 1;
93 }
94 } else if (pb_advance < 0) {
95 switch (pb_advance) {
96 case PB_REDALERT:
97 if (me->p_flags & PFRED) {
98 pb_advance = 0;
99 paused = 1;
100 }
101 break;
102 case PB_YELLOWALERT:
103 if (me->p_flags & PFYELLOW) {
104 pb_advance = 0;
105 paused = 1;
106 }
107 break;
108 case PB_DEATH:
109 default:
110 if (me->p_status != PALIVE) {
111 pb_advance = 0;
112 paused = 1;
113 }
114 break;
115 }
116 }
117 }
118 pb_update = 0;
119 }
120 if (recordGame)
121 writeUpdateMarker();
122 #endif
123 }
124 #if 0
125 if (lastread + 3 < time(NULL)) {
126 /*
127 We haven't heard from server for awhile... Strategy: send a
128 useless packet to "ping" server.
129 */
130 sendWarReq(me->p_hostile);
131 }
132 #endif
133 if (me->p_status == POUTFIT) {
134 death();
135 }
136 }
137
138 static void
139 redraw()
140 {
141
142 /* erase warning line if necessary */
143 if ((warntimer <= udcounter) && (warncount > 0)) {
144 #ifndef AMIGA
145 /* XFIX */
146 W_ClearArea(warnw, 5, 5, W_Textwidth * warncount, W_Textheight);
147 #else
148 W_ClearWindow(warnw);
149 #endif
150 warncount = 0;
151 }
152 if (W_FastClear) {
153 W_ClearWindow(w);
154 clearcount = 0;
155 clearlcount = 0;
156 tractcurrent = tracthead;
157 } else {
158 #if 0
159 /* just to save a little time on all the function calls */
160 /* all the normal clear functions are implemented as well. */
161 W_FlushClearZones(w, clearzone, clearcount);
162 clearcount = 0;
163 #else
164 while (clearcount) {
165 clearcount--;
166 /* XFIX */
167 W_CacheClearArea(w, clearzone[clearcount].x,
168 clearzone[clearcount].y, clearzone[clearcount].width,
169 clearzone[clearcount].height);
170
171 /*
172 W_ClearArea(w, clearzone[clearcount].x,
173 clearzone[clearcount].y, clearzone[clearcount].width,
174 clearzone[clearcount].height);
175 */
176 }
177 #endif
178 while (clearlcount) {
179 clearlcount--;
180 /* XFIX */
181 W_CacheLine(w, clearline[0][clearlcount],
182 clearline[1][clearlcount], clearline[2][clearlcount],
183 clearline[3][clearlcount], backColor);
184 /*
185 W_MakeLine(w, clearline[0][clearlcount],
186 clearline[1][clearlcount], clearline[2][clearlcount],
187 clearline[3][clearlcount], backColor);
188 */
189 }
190 /* XFIX */
191 #ifndef AMIGA
192 W_FlushClearAreaCache(w);
193 W_FlushLineCaches(w);
194 #endif
195 /* erase the tractor lines [BDyess] */
196 for (tractrunner = tracthead; tractrunner != tractcurrent;
197 tractrunner = tractrunner->next) {
198 W_MakeTractLine(w, tractrunner->sx, tractrunner->sy,
199 tractrunner->d1x, tractrunner->d1y,
200 backColor);
201 W_MakeTractLine(w, tractrunner->sx, tractrunner->sy,
202 tractrunner->d2x, tractrunner->d2y,
203 backColor);
204 }
205 tractcurrent = tracthead;
206 }
207
208 local(); /* redraw local window */
209
210 #ifdef AMIGA /* would do it in W_EventsPending, just have
211 it here so the display is updated sooner. */
212 W_Flush();
213 #endif
214
215 /* XFIX */
216 W_FlushLineCaches(w);
217
218 stline(0);
219
220 if (W_IsMapped(statwin))
221 updateStats();
222
223 updateInform(); /* check and update info window [BDyess] */
224
225 /* XFIX: last since its least accurate information */
226 if (mapmode)
227 map();
228
229 }
230
231 static W_Icon terrainBitmap(int x, int y)
232 {
233 int aster_bm = 0;
234 int aster_fluff = 0;
235
236 /* is no asteroids, then return fluff if adjacent 'roids */
237 if (!(terrainInfo[x*250 + y].types & T_ASTEROIDS)) aster_fluff = 1;
238
239 /* check surrounding terrain */
240 if (x > 0)
241 if (terrainInfo[(x-1)*250 + y].types & T_ASTEROIDS)
242 aster_bm |= (1<<0);
243 if (x < 249)
244 if (terrainInfo[(x+1)*250 + y].types & T_ASTEROIDS)
245 aster_bm |= (1<<2);
246 if (y > 0)
247 if (terrainInfo[x*250 + y-1].types & T_ASTEROIDS)
248 aster_bm |= (1<<3);
249 if (y < 249)
250 if (terrainInfo[x*250 + y+1].types & T_ASTEROIDS)
251 aster_bm |= (1<<1);
252
253 if (aster_fluff && aster_bm) return asteroidfluff[(x*250 + y)%3];
254 else return asteroidBM[aster_bm];
255 }
256
257 static W_Icon
258 planetBitmap(p)
259 register struct planet *p;
260 {
261 int i;
262 if (paradise) {
263 switch (PL_TYPE(*p)) {
264 case PLWHOLE:
265 return wormBM[udcounter % WORMFRAMES];
266 break;
267 case PLSTAR:
268 return starBM[udcounter % STARFRAMES];
269 break;
270 case PLAST:
271 return basteroid[0];
272 }
273 }
274 if (showlocal == 2) {
275 return (bplanets[0]);
276 } else if (p->pl_info & idx_to_mask(me->p_teami)) {
277 if (showlocal == 1 || showlocal == 4) {
278 i = 0;
279 if ((paradise) && (p->pl_flags & PLSHIPYARD))
280 i += 8;
281 if (p->pl_armies > 4)
282 i += 4;
283 if (p->pl_flags & PLREPAIR)
284 i += 2;
285 if (p->pl_flags & PLFUEL)
286 i += 1;
287 return ((showlocal == 1 ? bplanets2 : bplanetsMOO)[i]);
288 } else if (showlocal == 0) {
289 int team = mask_to_idx(p->pl_owner);
290 if (team < -1)
291 team = -1;
292 else if (team >= number_of_teams)
293 team = number_of_teams - 1;
294 return (bplanets[1 + team]);
295 } else {
296 int mask;
297 if (paradise)
298 mask = (p->pl_flags & PLSURMASK) >> PLSURSHIFT;
299 else {
300 mask = ((p->pl_flags & PLFUEL) ? 1 : 0)
301 | ((p->pl_flags & PLREPAIR) ? 2 : 0)
302 | ((p->pl_flags & PLAGRI) ? 4 : 0);
303 }
304 return bplanetsr[mask];
305 }
306 } else {
307 return (bplanets[5]);
308 }
309 }
310
311
312 static W_Icon
313 planetmBitmap(p)
314 register struct planet *p;
315 {
316 int i;
317 if (paradise) {
318 switch (p->pl_flags & PLTYPEMASK) {
319 case PLSTAR:
320 return mstarBM;
321 case PLAST:
322 return mbasteroid[0];
323 #ifdef VISIBLE_WORMHOLES
324 case PLWHOLE:
325 return mholeBM;
326 #endif /*VISIBLE_WORMHOLES*/
327 }
328 }
329 if (showgalactic == 2) {
330 return (mbplanets[0]);
331 } else if (showgalactic == 4) {
332 int infoage = 4;
333 if (!(p->pl_info & idx_to_mask(me->p_teami)))
334 return mbplanetsA[NSCOUTAGES - 1];
335 if (p->pl_owner == idx_to_mask(me->p_teami))
336 return mbplanetsA[0];
337
338 for (i = 0;
339 i < NSCOUTAGES - 1 && infoage < status2->clock - p->pl_timestamp;
340 i++, infoage = infoage * 5 / 3) {
341 }
342 return mbplanetsA[i];
343 } else if (p->pl_info & idx_to_mask(me->p_teami)) {
344 if (showgalactic == 1 || showgalactic == 5) {
345 i = 0;
346 if ((paradise) && (p->pl_flags & PLSHIPYARD))
347 i += 8;
348 if (p->pl_armies > 4)
349 i += 4;
350 if (p->pl_flags & PLREPAIR)
351 i += 2;
352 if (p->pl_flags & PLFUEL)
353 i += 1;
354 return ((showgalactic == 1 ? mbplanets2 : mbplanetsMOO)[i]);
355 } else if (showgalactic == 0) {
356 int team = mask_to_idx(p->pl_owner);
357 if (team < -1)
358 team = -1;
359 else if (team >= number_of_teams)
360 team = number_of_teams - 1;
361 return (mbplanets[1 + team]);
362 } else {
363 int mask;
364 if (paradise)
365 mask = (p->pl_flags & PLSURMASK) >> PLSURSHIFT;
366 else {
367 mask = ((p->pl_flags & PLFUEL) ? 1 : 0)
368 | ((p->pl_flags & PLREPAIR) ? 2 : 0)
369 | ((p->pl_flags & PLAGRI) ? 4 : 0);
370 }
371 return mbplanetsr[mask];
372 }
373 } else {
374 return (mbplanets[5]);
375 }
376 }
377
378 /* call this from local for each player, instead of having an extra loop! */
379 static void
380 redraw_photon_torps(j)
381 struct player *j;
382 {
383 int i, h;
384 struct torp *k;
385 int dx, dy;
386 int view;
387 struct _clearzone *cz;
388
389 view = SCALE * WINSIDE / 2;
390 i = j->p_no;
391 if (!j->p_ntorp)
392 return;
393 for (h = 0, k = &torps[ntorps * i + h]; h < ntorps; h++, k++) {
394 if (!k->t_status)
395 continue;
396 dx = k->t_x - me->p_x;
397 dy = k->t_y - me->p_y;
398 if (ABS(dx) > view || ABS(dy) > view) {
399 /* Call any torps off screen "free" (if owned by other) */
400 if (k->t_status == TEXPLODE && j != me) {
401 k->t_status = TFREE;
402 j->p_ntorp--;
403 }
404 continue;
405 }
406 dx = dx / SCALE + WINSIDE / 2;
407 dy = dy / SCALE + WINSIDE / 2;
408 #ifdef UNIX_SOUND
409 if ((k->t_status == TEXPLODE) && (k->t_fuse == 5)) play_sound (SND_TORPHIT);
410 #endif
411 if (k->t_status == TEXPLODE) {
412
413 k->t_fuse--;
414 if (k->t_fuse <= 0) {
415 k->t_status = TFREE;
416 j->p_ntorp--;
417 continue;
418 }
419 if (k->t_fuse >= NUMDETFRAMES) {
420 k->t_fuse = NUMDETFRAMES - 1;
421 }
422 W_WriteBitmap(dx - (cloud_width / 2), dy - (cloud_height / 2),
423 cloud[k->t_fuse], torpColor(k));
424 cz = new_czone();
425 cz->x = dx - (cloud_width / 2);
426 cz->y = dy - (cloud_height / 2);
427 cz->width = cloud_width;
428 cz->height = cloud_height;
429 } else if (k->t_owner != me->p_no && ((k->t_war & idx_to_mask(me->p_teami)) ||
430 (idx_to_mask(players[k->t_owner].p_teami) & (me->p_hostile | me->p_swar)))) {
431 /*
432 solid. Looks strange. W_FillArea(w, dx - (etorp_width/2), dy
433 - (etorp_height/2), etorp_width, etorp_height, torpColor(k));
434 */
435
436 #ifdef BORGTEST
437 W_CacheLine(w, dx - (etorp_width / 2), dy - (etorp_height / 2),
438 dx + (etorp_width / 2), dy + (etorp_height / 2),
439 (k->t_turns == 32767) ? notColor(k) : torpColor(k));
440 W_CacheLine(w, dx + (etorp_width / 2), dy - (etorp_height / 2),
441 dx - (etorp_width / 2), dy + (etorp_height / 2),
442 (k->t_turns == 32767) ? notColor(k) : torpColor(k));
443 #else
444 #ifdef TORPBITS
445 /*
446 went back to this for Amiga, one bitmap is faster than 2
447 lines.
448 */
449 W_WriteBitmap(dx - (etorp_width / 2), dy - (etorp_height / 2),
450 etorp, torpColor(k));
451 #else
452 /* XFIX */
453 if (0 && k->frame) {
454 W_CacheLine(w, dx - 2, dy,
455 dx + 2, dy, torpColor(k));
456 W_CacheLine(w, dx, dy - 2,
457 dx, dy + 2, torpColor(k));
458 } else {
459 W_CacheLine(w, dx - 1, dy - 1,
460 dx + 1, dy + 1, torpColor(k));
461 W_CacheLine(w, dx + 1, dy - 1,
462 dx - 1, dy + 1, torpColor(k));
463 }
464 k->frame = !k->frame;
465 #endif /* TORPBITS */
466 #endif
467
468 cz = new_czone();
469 cz->x = dx - (etorp_width / 2);
470 cz->y = dy - (etorp_height / 2);
471 cz->width = etorp_width;
472 cz->height = etorp_height;
473 } else {
474 /* XFIX */
475
476 if (0 /* animateTorps */ ) {
477 switch (k->frame) {
478 case 0:
479 W_CacheLine(w, dx - (mtorp_width / 2), dy, dx,
480 dy, torpColor(k));
481 break;
482 case 1:
483 W_CacheLine(w, dx - (mtorp_width / 2), dy - (mtorp_width / 2),
484 dx, dy, torpColor(k));
485 break;
486 case 2:
487 W_CacheLine(w, dx, dy, dx,
488 dy + (mtorp_width / 2), torpColor(k));
489 break;
490 case 3:
491 W_CacheLine(w, dx, dy,
492 dx + (mtorp_width / 2), dy - (mtorp_width / 2), torpColor(k));
493 break;
494 case 4:
495 W_CacheLine(w, dx, dy, dx + (mtorp_width / 2),
496 dy, torpColor(k));
497 break;
498 case 5:
499 W_CacheLine(w, dx - (mtorp_width / 2), dy - (mtorp_width / 2),
500 dx, dy, torpColor(k));
501 break;
502 case 6:
503 W_CacheLine(w, dx, dy - (mtorp_width / 2), dx,
504 dy, torpColor(k));
505 break;
506 case 7:
507 W_CacheLine(w, dx - (mtorp_width / 2), dy - (mtorp_width / 2),
508 dx, dy, torpColor(k));
509 break;
510 }
511 k->frame++;
512 if (k->frame > 7)
513 k->frame = 0;
514 } else {
515 #ifdef TORPBITS
516 W_WriteBitmap(dx - (mtorp_width / 2), dy - (mtorp_height / 2),
517 mtorp, torpColor(k));
518 #else
519 W_CacheLine(w, dx - (mtorp_width / 2), dy,
520 dx + (mtorp_width / 2), dy, torpColor(k));
521 W_CacheLine(w, dx, dy - (mtorp_width / 2),
522 dx, dy + (mtorp_width / 2), torpColor(k));
523 #endif
524 }
525
526 cz = new_czone();
527 cz->x = dx - (mtorp_width / 2);
528 cz->y = dy - (mtorp_height / 2);
529 cz->width = mtorp_width;
530 cz->height = mtorp_height;
531 }
532 }
533 }
534
535 static void
536 draw_one_thingy(k)
537 struct thingy *k;
538 {
539 int dx, dy;
540 int view;
541 struct _clearzone *cz;
542 view = SCALE * WINSIDE / 2;
543
544 if (k->t_shape == SHP_BLANK)
545 return;
546 /* printf("%d,%d - %d,%d\n", me->p_x, me->p_y, k->t_x, k->t_y); */
547 dx = k->t_x - me->p_x;
548 dy = k->t_y - me->p_y;
549 if (ABS(dx) > view || ABS(dy) > view) {
550 return;
551 }
552 dx = dx / SCALE + WINSIDE / 2;
553 dy = dy / SCALE + WINSIDE / 2;
554 switch (k->t_shape) {
555 case SHP_BOOM:
556 k->t_fuse--;
557 if (k->t_fuse <= 0) {
558 k->t_shape = SHP_BLANK;
559 return;
560 }
561 if (k->t_fuse >= NUMDETFRAMES) {
562 k->t_fuse = NUMDETFRAMES - 1;
563 }
564 W_WriteBitmap(dx - (cloud_width / 2), dy - (cloud_height / 2),
565 cloud[k->t_fuse], droneColor(k));
566 cz = new_czone();
567 cz->x = dx - (cloud_width / 2);
568 cz->y = dy - (cloud_height / 2);
569 cz->width = cloud_width;
570 cz->height = cloud_height;
571 break;
572 case SHP_MISSILE:
573 {
574 int dview = (int) (k->t_dir * NDRONEVIEWS + 128) / 256;
575 if (dview >= NDRONEVIEWS)
576 dview -= NDRONEVIEWS;
577 W_WriteBitmap
578 (dx - (drone_width / 2), dy - (drone_height / 2),
579 drone_bm[dview],
580 droneColor(k));
581 }
582 cz = new_czone();
583 cz->x = dx - (drone_width / 2);
584 cz->y = dy - (drone_height / 2);
585 cz->width = drone_width;
586 cz->height = drone_height;
587 break;
588 case SHP_TORP:
589 if (k->t_owner != me->p_no &&
590 ((k->t_war & idx_to_mask(me->p_teami)) ||
591 (idx_to_mask(players[k->t_owner].p_teami) & (me->p_hostile | me->p_swar)))) {
592 W_CacheLine(w, dx - (etorp_width / 2), dy - (etorp_height / 2),
593 dx + (etorp_width / 2), dy + (etorp_height / 2), torpColor(k));
594 W_CacheLine(w, dx + (etorp_width / 2), dy - (etorp_height / 2),
595 dx - (etorp_width / 2), dy + (etorp_height / 2), torpColor(k));
596 cz = new_czone();
597 cz->x = dx - (etorp_width / 2);
598 cz->y = dy - (etorp_height / 2);
599 cz->width = etorp_width;
600 cz->height = etorp_height;
601 } else {
602 W_CacheLine(w, dx - (mtorp_width / 2), dy, dx + (mtorp_width / 2), dy,
603 torpColor(k));
604 W_CacheLine(w, dx, dy - (mtorp_width / 2), dx, dy + (mtorp_width / 2),
605 torpColor(k));
606 cz = new_czone();
607 cz->x = dx - (mtorp_width / 2);
608 cz->y = dy - (mtorp_height / 2);
609 cz->width = mtorp_width;
610 cz->height = mtorp_height;
611 }
612 break;
613 case SHP_PLASMA:
614 case SHP_MINE: /* use plasma until I get a nifty bitmap */
615 if (k->t_owner != me->p_no &&
616 ((k->t_war & idx_to_mask(me->p_teami)) ||
617 (idx_to_mask(players[k->t_owner].p_teami) & (me->p_hostile | me->p_swar)))) {
618 W_WriteBitmap(dx - (eplasmatorp_width / 2),
619 dy - (eplasmatorp_height / 2),
620 eplasmatorp, torpColor(k));
621 cz = new_czone();
622 cz->x = dx - (eplasmatorp_width / 2);
623 cz->y = dy - (eplasmatorp_height / 2);
624 cz->width = eplasmatorp_width;
625 cz->height = eplasmatorp_height;
626 } else {
627 W_WriteBitmap(dx - (mplasmatorp_width / 2),
628 dy - (mplasmatorp_height / 2),
629 mplasmatorp, torpColor(k));
630 cz = new_czone();
631 cz->x = dx - (mplasmatorp_width / 2);
632 cz->y = dy - (mplasmatorp_height / 2);
633 cz->width = mplasmatorp_width;
634 cz->height = mplasmatorp_height;
635 }
636 break;
637 case SHP_PBOOM:
638 k->t_fuse--;
639 if (k->t_fuse <= 0) {
640 k->t_shape = SHP_BLANK;
641 return;
642 }
643 if (k->t_fuse >= NUMDETFRAMES) {
644 k->t_fuse = NUMDETFRAMES - 1;
645 }
646 W_WriteBitmap(dx - (plasmacloud_width / 2),
647 dy - (plasmacloud_height / 2),
648 plasmacloud[k->t_fuse], torpColor(k));
649 cz = new_czone();
650 cz->x = dx - (plasmacloud_width / 2);
651 cz->y = dy - (plasmacloud_height / 2);
652 cz->width = plasmacloud_width;
653 cz->height = plasmacloud_height;
654 break;
655 case SHP_FIGHTER:
656 {
657 int fview = (int) (k->t_dir * VIEWS + 128) / 256;
658 if (fview >= VIEWS)
659 fview -= VIEWS;
660 W_WriteBitmap(dx - (fighter_width / 2),
661 dy - (fighter_height / 2),
662 fighter[fview], torpColor(k));
663 cz = new_czone();
664 cz->x = dx - (fighter_width / 2);
665 cz->y = dy - (fighter_height / 2);
666 cz->width = fighter_width;
667 cz->height = fighter_height;
668 }
669 break;
670 case SHP_WARP_BEACON:
671 {
672 cz = new_czone();
673 cz->x = dx - (warpbeacon_width / 2);
674 cz->y = dy - (warpbeacon_height / 2);
675 cz->width = warpbeacon_width;
676 cz->height = warpbeacon_height;
677 W_WriteBitmap(cz->x, cz->y,
678 warpbeacon, W_White);
679 if (k->t_fuse > 4) {
680 W_WriteBitmap(cz->x, cz->y,
681 wbflash, shipCol[1 + mask_to_idx(k->t_owner)]);
682 }
683 if (++(k->t_fuse) > 6)
684 k->t_fuse = 0;
685 }
686 }
687 }
688
689 static void
690 redraw_drones(j)
691 struct player *j;
692 {
693 int i, h;
694 int count;
695
696 i = j->p_no;
697
698 if (!j->p_ndrone)
699 return;
700 count = 0;
701
702 for (h = i * npthingies; h < npthingies * (i + 1); h++) {
703 draw_one_thingy(&thingies[h]);
704 if (thingies[h].t_shape != SHP_BLANK)
705 count++;
706 }
707 j->p_ndrone = count;
708 }
709
710 static void
711 redraw_other_drones()
712 {
713 int h;
714
715 for (h = 0; h < ngthingies; h++)
716 draw_one_thingy(&thingies[nplayers * npthingies + h]);
717 }
718
719 static void
720 redraw_plasma_torps(j)
721 struct player *j;
722 {
723 int h, i;
724 register struct plasmatorp *pt;
725 struct _clearzone *cz;
726
727 int dx, dy;
728 int view;
729
730 view = SCALE * WINSIDE / 2;
731 i = j->p_no;
732
733 if (!j->p_nplasmatorp)
734 return;
735 for (h = 0, pt = &plasmatorps[nplasmas * i + h]; h < nplasmas; h++, pt++) {
736 if (!pt->pt_status)
737 continue;
738 dx = pt->pt_x - me->p_x;
739 dy = pt->pt_y - me->p_y;
740 if (ABS(dx) > view || ABS(dy) > view)
741 continue;
742 dx = dx / SCALE + WINSIDE / 2;
743 dy = dy / SCALE + WINSIDE / 2;
744 #ifdef UNIX_SOUND
745 if ((pt->pt_status == TEXPLODE) && (pt->pt_fuse == 5))
746 play_sound (SND_TORPHIT); /* Torp Hit used for Plasma Hit */
747 #endif
748 if (pt->pt_status == PTEXPLODE) {
749 pt->pt_fuse--;
750 if (pt->pt_fuse <= 0) {
751 pt->pt_status = PTFREE;
752 j->p_nplasmatorp--;
753 continue;
754 }
755 if (pt->pt_fuse >= NUMDETFRAMES) {
756 pt->pt_fuse = NUMDETFRAMES - 1;
757 }
758 W_WriteBitmap(dx - (plasmacloud_width / 2),
759 dy - (plasmacloud_height / 2),
760 plasmacloud[pt->pt_fuse], plasmatorpColor(pt));
761 cz = new_czone();
762 cz->x = dx - (plasmacloud_width / 2);
763 cz->y = dy - (plasmacloud_height / 2);
764 cz->width = plasmacloud_width;
765 cz->height = plasmacloud_height;
766 }
767 /* needmore: if(pt->pt_war & idx_to_mask(me->p_teami)) */
768 else if (pt->pt_owner != me->p_no && ((pt->pt_war & idx_to_mask(me->p_teami)) ||
769 (idx_to_mask(players[pt->pt_owner].p_teami) & (me->p_hostile | me->p_swar)))) {
770 W_WriteBitmap(dx - (eplasmatorp_width / 2),
771 dy - (eplasmatorp_height / 2),
772 eplasmatorp, plasmatorpColor(pt));
773 cz = new_czone();
774 cz->x = dx - (eplasmatorp_width / 2);
775 cz->y = dy - (eplasmatorp_height / 2);
776 cz->width = eplasmatorp_width;
777 cz->height = eplasmatorp_height;
778 } else {
779 W_WriteBitmap(dx - (mplasmatorp_width / 2),
780 dy - (mplasmatorp_height / 2),
781 mplasmatorp, plasmatorpColor(pt));
782 cz = new_czone();
783 cz->x = dx - (mplasmatorp_width / 2);
784 cz->y = dy - (mplasmatorp_height / 2);
785 cz->width = mplasmatorp_width;
786 cz->height = mplasmatorp_height;
787 }
788 }
789 }
790
791 #ifdef HOCKEY
792 void tactical_hockey P((void));
793 #endif
794
795 void
796 redraw_terrain()
797 {
798 int i,j;
799 int view;
800 int nx, ny; /* for adjusted coords, based on ship position */
801 int tx, ty, x; /* terrain grid x and y for 0,0 on the local */
802 struct _clearzone *cz;
803
804 view = SCALE * WINSIDE / 2;
805
806 nx = (int) ((me->p_x - view) / SCALE)%terrain_width;
807 ny = (int) ((me->p_y - view) / SCALE)%terrain_height;
808
809 ty = (int) ((me->p_y - view)/(GWIDTH/250));
810 x = tx = (int) ((me->p_x - view)/(GWIDTH/250));
811 if (ty < 0) ty = 0;
812 if (tx < 0) {
813 tx = 0;
814 x = 0;
815 }
816
817 if(received_terrain_info) {
818 for (i=0; i < WINSIDE; i += terrain_height) {
819 for (j=0; j < WINSIDE; j += terrain_width) {
820 if ((terrainInfo[tx*250+ty].types & T_ASTEROIDS) ||
821 ((tx > 0) && (terrainInfo[(tx-1)*250+ty].types & T_ASTEROIDS)) ||
822 ((tx < 249) && (terrainInfo[(tx+1)*250+ty].types & T_ASTEROIDS)) ||
823 ((ty > 0) && (terrainInfo[tx*250+(ty-1)].types & T_ASTEROIDS)) ||
824 ((tx < 249) && (terrainInfo[tx*250+(ty+1)].types & T_ASTEROIDS))) {
825 W_WriteBitmap(j-nx, i-ny, terrainBitmap(tx,ty), W_Grey);
826 cz = new_czone();
827 cz->x = j-nx;
828 cz->y = i-ny;
829 cz->width = terrain_width;
830 cz->height = terrain_height;
831 }
832 tx++;
833 if (tx >= 250) {
834 tx = x;
835 break;
836 }
837 }
838 ty++;
839 if (ty >= 250) break;
840 tx = x;
841 }
842 }
843 }
844
845 void
846 redraw_all_planets()
847 {
848 int view;
849 int i;
850 int dx, dy;
851 struct _clearzone *cz;
852 struct planet *l;
853 int nplan;
854
855 view = SCALE * WINSIDE / 2;
856 nplan = paradise ? nplanets : 40;
857
858 #ifdef HOCKEY
859 if(hockey) {
860 tactical_hockey();
861 }
862 #endif /*HOCKEY*/
863 for (i = 0, l = &planets[i]; i < nplan; i++, l++) {
864 dx = l->pl_x - me->p_x;
865 dy = l->pl_y - me->p_y;
866 if (ABS(dx) > view || ABS(dy) > view)
867 continue;
868 dx = dx / SCALE + WINSIDE / 2;
869 dy = dy / SCALE + WINSIDE / 2;
870 if (PL_TYPE(*l) == PLWHOLE)
871 W_WriteBitmap(dx - (wormhole_width / 2), dy - (wormhole_height / 2),
872 planetBitmap(l),
873 ((paradise) && (PL_TYPE(*l) == PLWHOLE))
874 ? textColor
875 : planetColor(l));
876 else
877 W_WriteBitmap(dx - (planet_width / 2), dy - (planet_height / 2),
878 planetBitmap(l),
879 ((paradise) && (PL_TYPE(*l) == PLSTAR))
880 ? textColor
881 : planetColor(l));
882 #ifdef SHOW_IND
883 if (showIND && (l->pl_info & idx_to_mask(me->p_teami)) && (l->pl_owner == NOBODY) && l->pl_flags & PLPLANET)
884 {
885 W_CacheLine (w, dx - (planet_width / 2), dy - (planet_height / 2),
886 dx + (planet_width / 2 - 1), dy + (planet_height / 2 - 1),
887 W_White);
888 W_CacheLine (w, dx + (planet_width / 2 - 1), dy - (planet_height / 2),
889 dx - (planet_width / 2), dy + (planet_height / 2 - 1),
890 W_White);
891 }
892 #endif
893 if (namemode) {
894 if (PL_TYPE(*l) != PLWHOLE) {
895 W_MaskText(w, dx - l->pl_namelen * W_Textwidth / 2, dy + (planet_height / 2),
896 ((paradise) && (PL_TYPE(*l) == PLSTAR))
897 ? textColor
898 : planetColor(l),
899 l->pl_name, l->pl_namelen, planetFont(l));
900 cz = new_czone();
901 cz->x = dx - l->pl_namelen * W_Textwidth / 2;
902 cz->y = dy + (planet_height / 2);
903 cz->width = W_Textwidth * l->pl_namelen;
904 cz->height = W_Textheight;
905 }
906 }
907 /* put letters and number next to */
908 /* planet bitmaps for resources and */
909 /* armies */
910 if (paradise && tacPlanetInfo) {
911 if (PL_TYPE(*l) == PLPLANET) {
912 char dspstr[8];
913 if (tacPlanetInfo & 1)
914 sprintf(dspstr, "%d", l->pl_armies);
915 if ((tacPlanetInfo & 2) && (l->pl_flags & PLREPAIR))
916 strcat(dspstr, "R");
917 if ((tacPlanetInfo & 4) && (l->pl_flags & PLFUEL))
918 strcat(dspstr, "F");
919 if ((tacPlanetInfo & 8) && (l->pl_flags & PLAGRI))
920 strcat(dspstr, "A");
921 if ((tacPlanetInfo & 16) && (l->pl_flags & PLSHIPYARD))
922 strcat(dspstr, "S");
923 cz = new_czone();
924 cz->x = dx + planet_width/2 + 2;
925 cz->y = dy;
926 cz->width = W_Textwidth * strlen(dspstr);
927 cz->height = W_Textheight;
928 W_MaskText(w, cz->x, cz->y,
929 planetColor(l), dspstr, strlen(dspstr),
930 planetFont(l));
931 }
932 }
933
934 /*--------draw tactical lock*/
935 if ((showLock & 2) && (me->p_flags & PFPLLOCK) && (me->p_planet == l->pl_no)) {
936 W_WriteTriangle(w, dx, dy - (planet_height) / 2 - 6, 5, 0, foreColor);
937 cz=new_czone();
938 cz->x=dx-5;
939 cz->y=dy - (planet_height) / 2 - 12;
940 cz->width=11;
941 cz->height=7;
942 }
943 cz = new_czone();
944 if (PL_TYPE(*l) == PLWHOLE) {
945 cz->x = dx - (wormhole_width / 2);
946 cz->y = dy - (wormhole_height / 2);
947 cz->width = wormhole_width;
948 cz->height = wormhole_height;
949 } else {
950 cz->x = dx - (planet_width / 2);
951 /*cz->y = dy - (planet_height / 2) - 13;*/
952 cz->y = dy - (planet_height / 2);
953 cz->width = planet_width;
954 /*cz->height = planet_height + 26;*/
955 cz->height = planet_height;
956 }
957 }
958 }
959
960 void
961 doShowMySpeed(dx, dy, ship_bits, j)
962 int dx, dy;
963 struct ship_shape *ship_bits;
964 struct player *j;
965 {
966 struct _clearzone *cz;
967 char idbuf[5];
968 int len;
969 int color;
970
971 sprintf(idbuf, "%c,%d", *(shipnos + j->p_no), me->p_speed);
972 len = strlen(idbuf);
973 /*
974 color the playernum,speed based on warp/afterburn/warpprep state
975 [BDyess]
976 */
977 switch (me->p_flags & (PFWARP | PFAFTER | PFWARPPREP)) {
978 case PFWARP:
979 color = W_Cyan;
980 me->p_flags &= ~PFWARPPREP;
981 break;
982 case PFAFTER:
983 color = rColor;
984 break;
985 case PFWARPPREP:
986 color = yColor;
987 break;
988 default: /* impulse */
989 if (me->p_speed > 0) {
990 color = gColor;
991 } else { /* stopped */
992 color = textColor;
993 }
994 break;
995 }
996 dx += ship_bits->width / 2;
997 dy -= ship_bits->height / 2;
998 /* underline number,speed if warp is suspended [BDyess] */
999 W_MaskText(w, dx, dy, color, idbuf, len, (me->p_flags & PFWPSUSPENDED) ?
1000 W_UnderlineFont : shipFont(j));
1001
1002 cz = new_czone();
1003 cz->x = dx;
1004 cz->y = dy;
1005 cz->width = len * W_Textwidth;
1006 cz->height = W_Textheight;
1007 }
1008
1009 #ifdef LOCAL_SHIPSTATS
1010 /* show just about anything next to ship on local display
1011 DSFAPWE - for each letter in statString, show a line for:
1012 Damage, Shields, Fuel, Armies, sPeed, Wtemp, Etemp
1013
1014 lower case = reverse length
1015 */
1016 static void
1017 doLocalShipstats()
1018 {
1019 char *sptr;
1020 int num=0, len, x=localStatsX, i;
1021 struct _clearzone *cz;
1022 W_Color color;
1023
1024 for(sptr=statString;*sptr;sptr++) {
1025 switch(toupper(*sptr)) {
1026 case 'W':
1027 len=(statHeight*me->p_wtemp) / me->p_ship->s_maxwpntemp;
1028 break;
1029 case 'E':
1030 len=(statHeight*me->p_etemp) / me->p_ship->s_maxegntemp;
1031 break;
1032 case 'P':
1033 len=(statHeight*me->p_speed)/me->p_ship->s_maxspeed;
1034 break;
1035 case 'D':
1036 len=(statHeight*me->p_damage)/me->p_ship->s_maxdamage;
1037 break;
1038 case 'S':
1039 len=statHeight - ((statHeight*me->p_shield)/me->p_ship->s_maxshield);
1040 break;
1041 case 'F':
1042 len=statHeight - ((statHeight*me->p_fuel)/me->p_ship->s_maxfuel);
1043 break;
1044 case 'A':
1045 len= me->p_ship->s_maxarmies ?
1046 (statHeight*me->p_armies)/me->p_ship->s_maxarmies : 0;
1047 break;
1048 default:
1049 continue;
1050 }
1051 if(islower(*sptr))
1052 len=statHeight - len;
1053 if(len>statHeight)
1054 len=statHeight;
1055
1056 if(len>2*(statHeight/3) || toupper(*sptr) == 'A')
1057 color=W_Red;
1058 else if(len<(statHeight/3))
1059 color=W_Green;
1060 else
1061 color=W_Yellow;
1062 if(len>0)
1063 W_CacheLine(w,x+W_Textwidth/2,localStatsY-len,x+W_Textwidth/2,localStatsY,color);
1064 W_MaskText(w,x,localStatsY+1,W_White,sptr,1,W_RegularFont);
1065 x+=W_Textwidth;
1066 }
1067 if(x>localStatsX) {
1068 W_CacheLine(w,localStatsX,localStatsY-statHeight,x,localStatsY-statHeight,W_White);
1069 W_CacheLine(w,localStatsX,localStatsY,x,localStatsY,W_White);
1070 cz=new_czone();
1071 cz->x=localStatsX;
1072 cz->y=localStatsY-statHeight+1;
1073 cz->width=x-localStatsX;
1074 cz->height=statHeight-2;
1075 }
1076 }
1077 #endif
1078
1079 static void
1080 local()
1081 {
1082 register int i;
1083 register struct player *j;
1084 register struct phaser *php;
1085 struct _clearzone *cz;
1086
1087 int dx, dy;
1088 int view;
1089 char idbuf[10];
1090 struct ship_shape *ship_bits;
1091 if (showKitchenSink) {
1092 cz = new_czone();
1093 cz->width = 76;
1094 cz->height = 60;
1095 cz->x = 500 - cz->width;
1096 cz->y = 0;
1097 W_WriteBitmap(cz->x, cz->y, kitchenSink, W_Grey);
1098 }
1099 /*
1100 Kludge to try to fix missing ID chars on tactical (short range)
1101 display.
1102 */
1103 idbuf[0] = '0';
1104 idbuf[1] = '\0';
1105 /* Draw Terrain */
1106 redraw_terrain();
1107 /* Draw Planets */
1108 redraw_all_planets();
1109 /* Draw ships */
1110 view = SCALE * WINSIDE / 2;
1111 for (i = 0, j = &players[i]; i < nplayers; i++, j++) {
1112 int tx, ty;
1113 if (me->p_x < 0)
1114 continue;
1115
1116 /* more efficient than using a separate loop for this */
1117 redraw_photon_torps(j);
1118 redraw_drones(j);
1119 redraw_plasma_torps(j);
1120
1121 if ((j->p_status != PALIVE) && (j->p_status != PEXPLODE))
1122 continue;
1123
1124 #ifdef UNIX_SOUND
1125 if (myPlayer(j) && (j->p_flags & PFCLOAK) &&
1126 (j->p_cloakphase == 0)) play_sound (SND_CLOAK);
1127 if (myPlayer(j) && (!(j->p_flags & PFCLOAK)) &&
1128 (j->p_cloakphase == 6)) play_sound (SND_CLOAK);
1129 #endif
1130
1131 if (j->p_flags & PFCLOAK) {
1132 if (j->p_cloakphase < (CLOAK_PHASES - 1)) {
1133 j->p_cloakphase++;
1134 }
1135 } else {
1136 if (j->p_cloakphase) {
1137 j->p_cloakphase--;
1138 }
1139 }
1140 dx = j->p_x - me->p_x;
1141 dy = j->p_y - me->p_y;
1142 if (ABS(dx) > view || ABS(dy) > view) {
1143 if(j->p_status == PEXPLODE)
1144 j->p_explode++;
1145 continue;
1146 }
1147 dx = dx / SCALE + WINSIDE / 2;
1148 dy = dy / SCALE + WINSIDE / 2;
1149 if (j->p_status == PALIVE) {
1150
1151 ship_bits = shape_of_ship(j->p_teami, j->p_ship->s_bitmap);
1152
1153 if (j->p_flags & PFCLOAK && (j->p_cloakphase == (CLOAK_PHASES - 1))) {
1154 if (myPlayer(j)) {
1155 W_WriteBitmap(dx - (cloak_width / 2), dy - (cloak_height / 2),
1156 cloakicon, myColor);
1157 cz = new_czone();
1158 cz->x = dx - (ship_bits->width / 2 + 1);
1159 cz->y = dy - (ship_bits->height / 2 + 1);
1160 cz->width = ship_bits->width + 2;
1161 cz->height = ship_bits->height + 2;
1162 doShields(dx, dy, ship_bits, j);
1163 #ifdef VARY_HULL
1164 doHull(dx, dy, ship_bits, j);
1165 #endif /* VARY_HULL */
1166 if (showMySpeed)
1167 doShowMySpeed(dx, dy, ship_bits, j);
1168 }
1169 continue;
1170 }
1171 cz = new_czone();
1172 #ifdef BEEPLITE
1173 if (emph_player_seq_n[j->p_no] > 0 &&
1174 ((F_beeplite_flags & LITE_PLAYERS_LOCAL) ||
1175 ((j == me) && (F_beeplite_flags & LITE_SELF)))) {
1176 int seq_n = emph_player_seq_n[j->p_no] % emph_player_seql_frames;
1177
1178 cz->x = dx - (emph_player_seql_width / 2);
1179 cz->y = dy - (emph_player_seql_height / 2);
1180 cz->width = emph_player_seql_width;
1181 cz->height = emph_player_seql_height;
1182
1183 W_WriteBitmap(dx - (emph_player_seql_width / 2),
1184 dy - (emph_player_seql_height / 2),
1185 emph_player_seql[seq_n],
1186 emph_player_color[j->p_no]);
1187 } else
1188 #endif
1189 {
1190 cz->x = dx - (ship_bits->width / 2);
1191 cz->y = dy - (ship_bits->height / 2);
1192 cz->width = ship_bits->width;
1193 cz->height = ship_bits->height;
1194 }
1195 W_WriteBitmap(dx - (ship_bits->width / 2),
1196 dy - (ship_bits->height / 2),
1197 ship_bits->bmap[rosette((int) j->p_dir,
1198 (int) ship_bits->nviews)], playerColor(j));
1199 if (j->p_cloakphase > 0) {
1200 W_WriteBitmap(dx - (cloak_width / 2),
1201 dy - (cloak_height / 2), cloakicon, playerColor(j));
1202 doShields(dx, dy, ship_bits, j);
1203 if (j == me) {
1204 #ifdef VARY_HULL
1205 doHull(dx, dy, ship_bits, j);
1206 #endif /* VARY_HULL */
1207 if (showMySpeed)
1208 doShowMySpeed(dx, dy, ship_bits, j);
1209 }
1210 continue;
1211 }
1212 if (showLock & 2) {
1213 if ((me->p_flags & PFPLOCK) && (me->p_playerl == j->p_no)) {
1214 W_WriteTriangle(w, dx, dy + (ship_bits->width / 2),
1215 4, 1, foreColor);
1216 cz = new_czone();
1217 cz->x = dx - 4;
1218 cz->y = dy + (ship_bits->height / 2);
1219 cz->width = 9;
1220 cz->height = 5;
1221 }
1222 }
1223 doShields(dx, dy, ship_bits, j);
1224 #ifdef VARY_HULL
1225 doHull(dx, dy, ship_bits, j);
1226 #endif /* VARY_HULL */
1227 if (showMySpeed && j == me)
1228 doShowMySpeed(dx, dy, ship_bits, j);
1229 else {
1230 int color = playerColor(j);
1231 idbuf[0] = *(shipnos + j->p_no);
1232
1233 W_MaskText(w, dx + (ship_bits->width / 2),
1234 dy - (ship_bits->height / 2), color,
1235 idbuf, 1, shipFont(j));
1236
1237 cz = new_czone();
1238 cz->x = dx + (ship_bits->width / 2);
1239 cz->y = dy - (ship_bits->height / 2);
1240 cz->width = W_Textwidth;
1241 cz->height = W_Textheight;
1242 }
1243 } else if (j->p_status == PEXPLODE) {
1244 int i;
1245 i = j->p_explode;
1246 if (i < EX_FRAMES || (i < SBEXPVIEWS && j->p_ship->s_type == STARBASE)) {
1247
1248 #ifdef SOUND
1249 if(i==0)
1250 S_PlaySound(S_EXPLOSION);
1251 #endif
1252 #ifdef UNIX_SOUND
1253 if (i==0)
1254 {
1255 if (j->p_ship->s_type == STARBASE)
1256 play_sound(SND_EXP_SB); /* Starbase Explode */
1257 else play_sound(SND_EXPLOSION); /* Ship Explosion */
1258 }
1259 #endif
1260
1261 cz = new_czone();
1262 if (j->p_ship->s_type == STARBASE) {
1263 W_WriteBitmap(dx - (sbexp_width / 2),
1264 dy - (sbexp_height / 2), sbexpview[i],
1265 playerColor(j));
1266 cz->x = dx - (sbexp_width / 2);
1267 cz->y = dy - (sbexp_height / 2);
1268 cz->width = sbexp_width;
1269 cz->height = sbexp_height;
1270 } else {
1271 W_WriteBitmap(dx - (ex_width / 2), dy - (ex_height / 2),
1272 expview[i], playerColor(j));
1273 cz->x = dx - (ex_width / 2);
1274 cz->y = dy - (ex_height / 2);
1275 cz->width = ex_width;
1276 cz->height = ex_height;
1277 }
1278 j->p_explode++;
1279 }
1280 }
1281 /* Now draw his phaser (if it exists) */
1282 php = &phasers[j->p_no];
1283 if (php->ph_status != PHFREE) {
1284 if (php->ph_status == PHMISS) {
1285 /* Here I will have to compute end coordinate */
1286 tx = j->p_x + j->p_ship->s_phaserrange * Cos[php->ph_dir];
1287 ty = j->p_y + j->p_ship->s_phaserrange * Sin[php->ph_dir];
1288 tx = (tx - me->p_x) / SCALE + WINSIDE / 2;
1289 ty = (ty - me->p_y) / SCALE + WINSIDE / 2;
1290 } else if (php->ph_status == PHHIT2) {
1291 tx = (php->ph_x - me->p_x) / SCALE + WINSIDE / 2;
1292 ty = (php->ph_y - me->p_y) / SCALE + WINSIDE / 2;
1293 } else { /* Start point is dx, dy */
1294 tx = (players[php->ph_target].p_x - me->p_x) /
1295 SCALE + WINSIDE / 2;
1296 ty = (players[php->ph_target].p_y - me->p_y) /
1297 SCALE + WINSIDE / 2;
1298 }
1299
1300
1301 php->ph_fuse++;
1302
1303 #ifdef CHECK_DROPPED
1304 if (php->ph_fuse > longest_ph_fuse + 1 && php->ph_status != PHGHOST) {
1305 if (reportDroppedPackets)
1306 printf("Dropped phaser free, player %d (fuse)\n", j->p_no);
1307 php->ph_status = PHGHOST;
1308 }
1309 if (php->ph_status != PHGHOST) {
1310 #endif
1311 #ifdef W_PHASERLINE
1312 /*
1313 * an old redraw.c I used for the Amiga port(not this port) had this.
1314 * Draws a dashed line instead of solid..different pattern from tractor
1315 * lines. At least that's what I guessed for amigawindow.c :-) -JR
1316 */
1317
1318 if (j->p_teami != me->p_teami)
1319 W_MakePhaserLine(w, dx, dy, tx, ty,
1320 (php->ph_fuse % 2 && php->ph_status != PHMISS) ?
1321 foreColor :
1322 shipCol[1 + j->p_teami],
1323 php->ph_fuse);
1324 else
1325 #endif
1326 {
1327 W_Color ph_col;
1328 if (jubileePhasers) {
1329
1330 switch (php->ph_fuse % 4) {
1331 case 0:
1332 ph_col = W_Red;
1333 break;
1334 case 1:
1335 ph_col = W_Yellow;
1336 break;
1337 case 2:
1338 ph_col = W_Green;
1339 break;
1340 case 3:
1341 ph_col = W_Cyan;
1342 break;
1343 }
1344 if (php->ph_status == PHMISS)
1345 ph_col = W_White;
1346 } else {
1347 ph_col = (php->ph_fuse % 2 && php->ph_status != PHMISS) ?
1348 foreColor :
1349 shipCol[1 + j->p_teami];
1350 }
1351 W_CacheLine(w, dx, dy, tx, ty, ph_col);
1352 }
1353 clearline[0][clearlcount] = dx;
1354 clearline[1][clearlcount] = dy;
1355 clearline[2][clearlcount] = tx;
1356 clearline[3][clearlcount] = ty;
1357 clearlcount++;
1358 #ifdef CHECK_DROPPED
1359 } /* PHGHOST */
1360 #endif
1361 }
1362 }
1363
1364 /* ATM - show tractor/pressor beams (modified by James Collins) */
1365 /* showTractorPressor is a variable set by xtrekrc. */
1366 /* modified to show all T/P's 1/28/94 [BDyess] */
1367 /* fixed display bug 1/29/94 [BDyess] */
1368 dx = WINSIDE / 2;
1369 dy = WINSIDE / 2;
1370 if (showTractorPressor) {
1371 double theta;
1372 unsigned char dir;
1373 int lx[2], ly[2], px, py, target_width;
1374 struct player *victim = &players[me->p_tractor];
1375 int last;
1376 if (paradise && showAllTractorPressor && allowShowAllTractorPressor) {
1377 /* check everybody */
1378 last = nplayers;
1379 j = &players[0];
1380 i = 0;
1381 } else {
1382 /* only check self */
1383 last = me->p_no + 1;
1384 j = me;
1385 i = me->p_no;
1386 }
1387 for (; i < last; i++, j++) {
1388 if (!(j->p_flags & (PFTRACT | PFPRESS) && isAlive(j)))
1389 continue;
1390 if (!paradise && RSA_Client > 0 && j != me)
1391 continue;
1392 victim = &players[j->p_tractor];
1393 if (victim->p_flags & PFCLOAK)
1394 break; /* can't see tractors on cloaked opponents */
1395 if (j == me) {
1396 dx = dy = WINSIDE / 2;
1397 } else {
1398 dx = (j->p_x - me->p_x) / SCALE + WINSIDE / 2;
1399 dy = (j->p_y - me->p_y) / SCALE + WINSIDE / 2;
1400 }
1401 if (PtOutsideWin(dx, dy))
1402 continue; /* he's off the screen */
1403 px = (victim->p_x - me->p_x) / SCALE + WINSIDE / 2;
1404 py = (victim->p_y - me->p_y) / SCALE + WINSIDE / 2;
1405 if (px == dx && py == dy)
1406 break;
1407 #define XPI 3.1415926
1408 theta = atan2((double) (px - dx), (double) (dy - py)) + XPI / 2.0;
1409 dir = (unsigned char) (theta / XPI * 128.0);
1410 target_width = shape_of_ship(victim->p_teami,
1411 victim->p_ship->s_bitmap)->width;
1412 if (!(victim->p_flags & PFSHIELD))
1413 target_width /= 2;
1414 lx[0] = px + (Cos[dir] * (target_width / 2));
1415 ly[0] = py + (Sin[dir] * (target_width / 2));
1416 lx[1] = px - (Cos[dir] * (target_width / 2));
1417 ly[1] = py - (Sin[dir] * (target_width / 2));
1418 #undef XPI
1419 if (j->p_flags & PFPRESS) {
1420 W_MakeTractLine(w, dx, dy, lx[0], ly[0], W_Yellow);
1421 W_MakeTractLine(w, dx, dy, lx[1], ly[1], W_Yellow);
1422 } else {
1423 W_MakeTractLine(w, dx, dy, lx[0], ly[0], W_Green);
1424 W_MakeTractLine(w, dx, dy, lx[1], ly[1], W_Green);
1425 }
1426 /*
1427 keeping track of tractors seperately from other lines allows
1428 clearing them diffently. Clearing them the same as other
1429 solid lines caused occasional bits to be left on the screen.
1430 This is the fix. [BDyess]
1431 */
1432 if (tractcurrent == NULL) { /* just starting */
1433 tractcurrent = tracthead = (Tractor *) malloc(sizeof(Tractor));
1434 tracthead->next = NULL;
1435 }
1436 tractcurrent->sx = dx;
1437 tractcurrent->sy = dy;
1438 tractcurrent->d1x = lx[0];
1439 tractcurrent->d1y = ly[0];
1440 tractcurrent->d2x = lx[1];
1441 tractcurrent->d2y = ly[1];
1442 /* get ready for the next run through */
1443 if (tractcurrent->next) { /* already malloc'd before */
1444 tractcurrent = tractcurrent->next;
1445 } else { /* new maximum, create a new struct */
1446 tractcurrent->next = (Tractor *) malloc(sizeof(Tractor));
1447 tractcurrent = tractcurrent->next;
1448 tractcurrent->next = NULL;
1449 }
1450 }
1451 }
1452 /* changed torps/drones/plasmas to one call per player, in the above loop */
1453 /* still have leftover drones to draw: */
1454 redraw_other_drones();
1455
1456 /* Draw Edges */
1457 if (me->p_x < (WINSIDE / 2) * SCALE) {
1458 int sy, ey;
1459 dx = (WINSIDE / 2) - (me->p_x) / SCALE;
1460 sy = (WINSIDE / 2) + (0 - me->p_y) / SCALE;
1461 ey = (WINSIDE / 2) + (blk_gwidth - me->p_y) / SCALE;
1462 if (sy < 0)
1463 sy = 0;
1464 if (ey > WINSIDE - 1)
1465 ey = WINSIDE - 1;
1466 /* XFIX */
1467 W_CacheLine(w, dx, sy, dx, ey, warningColor);
1468 /*
1469 W_MakeLine(w, dx, sy, dx, ey, warningColor);
1470 */
1471 clearline[0][clearlcount] = dx;
1472 clearline[1][clearlcount] = sy;
1473 clearline[2][clearlcount] = dx;
1474 clearline[3][clearlcount] = ey;
1475 clearlcount++;
1476 }
1477 if ((blk_gwidth - me->p_x) < (WINSIDE / 2) * SCALE) {
1478 int sy, ey;
1479 dx = (WINSIDE / 2) + (blk_gwidth - me->p_x) / SCALE;
1480 sy = (WINSIDE / 2) + (0 - me->p_y) / SCALE;
1481 ey = (WINSIDE / 2) + (blk_gwidth - me->p_y) / SCALE;
1482 if (sy < 0)
1483 sy = 0;
1484 if (ey > WINSIDE - 1)
1485 ey = WINSIDE - 1;
1486 /* XFIX */
1487 W_CacheLine(w, dx, sy, dx, ey, warningColor);
1488 /*
1489 W_MakeLine(w, dx, sy, dx, ey, warningColor);
1490 */
1491 clearline[0][clearlcount] = dx;
1492 clearline[1][clearlcount] = sy;
1493 clearline[2][clearlcount] = dx;
1494 clearline[3][clearlcount] = ey;
1495 clearlcount++;
1496 }
1497 if (me->p_y < (WINSIDE / 2) * SCALE) {
1498 int sx, ex;
1499 dy = (WINSIDE / 2) - (me->p_y) / SCALE;
1500 sx = (WINSIDE / 2) + (0 - me->p_x) / SCALE;
1501 ex = (WINSIDE / 2) + (blk_gwidth - me->p_x) / SCALE;
1502 if (sx < 0)
1503 sx = 0;
1504 if (ex > WINSIDE - 1)
1505 ex = WINSIDE - 1;
1506 /* XFIX */
1507 W_CacheLine(w, sx, dy, ex, dy, warningColor);
1508 /*
1509 W_MakeLine(w, sx, dy, ex, dy, warningColor);
1510 */
1511 clearline[0][clearlcount] = sx;
1512 clearline[1][clearlcount] = dy;
1513 clearline[2][clearlcount] = ex;
1514 clearline[3][clearlcount] = dy;
1515 clearlcount++;
1516 }
1517 if ((blk_gwidth - me->p_y) < (WINSIDE / 2) * SCALE) {
1518 int sx, ex;
1519 dy = (WINSIDE / 2) + (blk_gwidth - me->p_y) / SCALE;
1520 sx = (WINSIDE / 2) + (0 - me->p_x) / SCALE;
1521 ex = (WINSIDE / 2) + (blk_gwidth - me->p_x) / SCALE;
1522 if (sx < 0)
1523 sx = 0;
1524 if (ex > WINSIDE - 1)
1525 ex = WINSIDE - 1;
1526 /* XFIX */
1527 W_CacheLine(w, sx, dy, ex, dy, warningColor);
1528 /*
1529 W_MakeLine(w, sx, dy, ex, dy, warningColor);
1530 */
1531 clearline[0][clearlcount] = sx;
1532 clearline[1][clearlcount] = dy;
1533 clearline[2][clearlcount] = ex;
1534 clearline[3][clearlcount] = dy;
1535 clearlcount++;
1536 }
1537 /* Change border color to signify alert status */
1538
1539 #ifdef UNIX_SOUND
1540 if (oldalert != (me->p_flags & (PFGREEN | PFYELLOW | PFRED)))
1541 {
1542 if (me->p_flags & PFRED)
1543 maybe_play_sound (SND_REDALERT); /* Red Alert, play ONLY once */
1544 else sound_completed (SND_REDALERT); /* Done with Red Alert */
1545 }
1546 #endif
1547
1548 if (oldalert != (me->p_flags & (PFGREEN | PFYELLOW | PFRED))) {
1549 if(paradise && auto_zoom_timer<udcounter && (autoZoom || autoUnZoom)) {
1550 int old_zoom=blk_zoom;
1551 switch(autoZoom) {
1552 case 1:
1553 if(me->p_flags & (PFYELLOW | PFRED))
1554 blk_zoom = 1;
1555 break;
1556 case 2:
1557 if(me->p_flags & (PFRED))
1558 blk_zoom = 1;
1559 break;
1560 }
1561 switch(autoUnZoom) {
1562 case 1:
1563 if(me->p_flags & (PFGREEN))
1564 blk_zoom = 0;
1565 break;
1566 case 2:
1567 if(me->p_flags & (PFYELLOW | PFGREEN))
1568 blk_zoom = 0;
1569 break;
1570 }
1571 if(old_zoom != blk_zoom)
1572 redrawall=1;
1573 }
1574 oldalert = (me->p_flags & (PFGREEN | PFYELLOW | PFRED));
1575 if (infoIcon && iconified)
1576 drawIcon();
1577 switch (oldalert) {
1578 case PFGREEN:
1579 if (extraBorder)
1580 W_ChangeBorder(w, gColor);
1581 W_ChangeBorder(baseWin, gColor);
1582 W_ChangeBorder(iconWin, gColor);
1583 break;
1584 case PFYELLOW:
1585 if (extraBorder)
1586 W_ChangeBorder(w, yColor);
1587 W_ChangeBorder(baseWin, yColor);
1588 W_ChangeBorder(iconWin, yColor);
1589 break;
1590 case PFRED:
1591 if (extraBorder)
1592 W_ChangeBorder(w, rColor);
1593 W_ChangeBorder(baseWin, rColor);
1594 W_ChangeBorder(iconWin, rColor);
1595 break;
1596 }
1597 }
1598 /* draw stars */
1599
1600 if (blk_showStars)
1601 drawStars();
1602
1603 #ifdef LOCAL_SHIPSTATS
1604 if(localShipStats)
1605 doLocalShipstats();
1606 #endif
1607
1608
1609 }
1610 #define DRAWGRID 4
1611
1612 int
1613 zoom_offset(v)
1614 int v;
1615 {
1616 if (blk_zoom) {
1617 register gwidth, ov;
1618 /* dimension of zoom area */
1619 gwidth = blk_gwidth / 2;
1620 /* offset to bring us into new zoom area */
1621 ov = (v / (int) gwidth) * gwidth;
1622 if (blk_zoom > 1)
1623 return ov;
1624 else
1625 /* sector offset into new zoom area */
1626 return ov + (((v - ov) / GRIDSIZE) * GRIDSIZE) - GRIDSIZE;
1627 } else
1628 return v;
1629 }
1630
1631 #ifdef HOCKEY
1632 void galactic_hockey P((void));
1633 #endif
1634
1635 #ifndef COW_HAS_IT_WHY_SHOULDNT_WE
1636 static
1637 #endif
1638 void
1639 map()
1640 {
1641 int nplan;
1642 register int i, k, tmp = blk_gwidth/250;
1643 register struct player *j;
1644 register struct planet *l;
1645 register int dx, dy, odx, ody;
1646 static osx = 0, osy = 0; /* old square */
1647 static last_offsetx, last_offsety;
1648 static int grid_fuse; /* TSH */
1649 register int gwidth, offsetx, offsety;
1650 int color, pl = 0;
1651 /*
1652 last_lock is used to hold the begin/end point for lock line; [0] holds
1653 me->; [1] holds target lock; lockx[2] holds status of line so we can
1654 erase if line is there but lock if off
1655 */
1656 static last_lockx[3] = {0, 0, 0}, last_locky[2];
1657 int me_galx, me_galy;
1658
1659 grid_fuse++; /* we only draw the grids every DRAWGRID
1660 interval */
1661
1662 /* set number of planets for later */
1663 nplan = (paradise) ? nplanets : 40;
1664
1665 if (reinitPlanets) {
1666 initPlanets();
1667 reinitPlanets = 0;
1668 #ifdef HOCKEY
1669 /* planets moved so the lines need updating [BDyess] */
1670 if(hockey) hockeyInit();
1671 #endif /*HOCKEY*/
1672 }
1673
1674 #ifdef HOCKEY
1675 galactic_hockey();
1676 #endif /*HOCKEY*/
1677
1678 if (blk_zoom) {
1679 gwidth = blk_gwidth / 2;
1680 offsetx = zoom_offset(me->p_x);
1681 offsety = zoom_offset(me->p_y);
1682
1683 if (offsetx != last_offsetx || offsety != last_offsety)
1684 redrawall = 1;
1685
1686 last_offsetx = offsetx;
1687 last_offsety = offsety;
1688 } else {
1689 gwidth = blk_gwidth;
1690 offsetx = 0;
1691 offsety = 0;
1692 }
1693
1694 me_galx = (me->p_x - offsetx) * WINSIDE / gwidth;
1695 me_galy = (me->p_y - offsety) * WINSIDE / gwidth;
1696
1697 /* draw asteroid dots -- this is a test only. MDM */
1698 if( received_terrain_info && paradise ){
1699 /* but avoid that SEGV! */
1700 for( i = 0; i < 250; i++ ){
1701 for( k = udcounter%10; k < 250; k += 10){
1702 if(terrainInfo[i*250+k].types & T_ASTEROIDS) {
1703 W_DrawPoint( mapw,
1704 (i*tmp - offsetx) * WINSIDE / gwidth,
1705 (k*tmp - offsety) * WINSIDE / gwidth,
1706 W_White);
1707 }
1708 if (terrainInfo[i*250+k].types & T_NEBULA) {
1709 W_DrawPoint( mapw,
1710 ((i*tmp - offsetx) * WINSIDE / gwidth) + 1,
1711 ((k*tmp - offsety) * WINSIDE / gwidth) + 1,
1712 W_Red);
1713 }
1714 }
1715 }
1716 }
1717
1718 if (redrawall)
1719 W_ClearWindow(mapw);
1720
1721 /* draw grid on galactic */
1722 if ((redrawall || (grid_fuse % DRAWGRID) == 0) && (paradise) && (drawgrid)) {
1723 int x, y, w, h, grid;
1724 char numbuf[1];
1725 grid = GRIDSIZE * WINSIDE / gwidth;
1726 for (i = 1; i <= 6 / (blk_zoom ? 2 : 1); i++) {
1727 /* looks nasty but we only have to do it 3 times if blk_zoom */
1728
1729 /* horizontal line */
1730 x = 0;
1731 y = i * grid;
1732 w = WINSIDE;
1733 numbuf[0] = '0' + (char) i;
1734 if (blk_zoom) {
1735 /* we might have to clip */
1736 dy = i * GRIDSIZE + offsety;
1737 if (dy >= 0 && dy <= blk_gwidth + 2 * GRIDSIZE) {
1738 if (offsetx < 0) {
1739 x = grid;
1740 w = 2 * x;
1741 } else if (offsetx + 3 * GRIDSIZE > blk_gwidth) {
1742 w = 2 * grid;
1743 }
1744 W_MakeTractLine(mapw, x, y, x + w, y, W_Grey);
1745 }
1746 if (sectorNums) {
1747 numbuf[0] = '0' + (char) (i + offsety / 33333);
1748 if ((numbuf[0] == '0') || (numbuf[0] == '7'))
1749 numbuf[0] = ' ';
1750 if (i == 1) /* so numbers dont overwrite in 1st box */
1751 W_WriteText(mapw, x + 2, y - grid + 11, W_Grey, numbuf, 1,
1752 W_RegularFont);
1753 else
1754 W_WriteText(mapw, x + 2, y - grid + 2, W_Grey, numbuf, 1,
1755 W_RegularFont);
1756 }
1757 } else {
1758 W_MakeTractLine(mapw, x, y, x + w, y, W_Grey);
1759 if (sectorNums) {
1760 W_WriteText(mapw, x + 2, y - grid + 2, W_Grey, numbuf, 1, W_RegularFont);
1761 }
1762 }
1763 /* vertical line */
1764 x = i * grid;
1765 y = 0;
1766 h = WINSIDE;
1767
1768 if (blk_zoom) {
1769 /* we might have to clip */
1770 dx = i * GRIDSIZE + offsetx;
1771 if (dx >= 0 && dx <= blk_gwidth + 2 * GRIDSIZE) {
1772 if (offsety < 0) {
1773 y = grid;
1774 h = 2 * y;
1775 } else if (offsety + 3 * GRIDSIZE > blk_gwidth) {
1776 h = 2 * grid;
1777 }
1778 W_MakeTractLine(mapw, x, y, x, y + h, W_Grey);
1779 }
1780 if (sectorNums) {
1781 numbuf[0] = '0' + (char) (i + offsetx / 33333);
1782 if ((numbuf[0] == '0') || (numbuf[0] == '7'))
1783 numbuf[0] = ' ';
1784 if (i == 1)
1785 W_WriteText(mapw, x - grid + 11, y + 2, W_Grey, numbuf, 1,
1786 W_RegularFont);
1787 else
1788 W_WriteText(mapw, x - grid + 2, y + 2, W_Grey, numbuf, 1,
1789 W_RegularFont);
1790 }
1791 } else {
1792 W_MakeTractLine(mapw, x, y, x, y + h, W_Grey);
1793 if (sectorNums) {
1794 W_WriteText(mapw, x - grid + 2, y + 2, W_Grey, numbuf, 1,
1795 W_RegularFont);
1796 }
1797 }
1798 }
1799
1800 dx = ((me->p_x - offsetx) / GRIDSIZE) * GRIDSIZE;
1801 dy = ((me->p_y - offsety) / GRIDSIZE) * GRIDSIZE;
1802 if (!redrawall && ((osx != dx) || (osy != dy))) {
1803
1804 /* clear old sector */
1805 x = osx * WINSIDE / gwidth;
1806 y = osy * WINSIDE / gwidth;
1807 w = h = grid;
1808
1809 W_DrawSectorHighlight(mapw, x, y, w, h, backColor);
1810
1811 osx = dx;
1812 osy = dy;
1813 }
1814 /* draw our current sector */
1815 x = dx * WINSIDE / gwidth;
1816 w = h = grid;
1817 y = dy * WINSIDE / gwidth;
1818
1819 W_DrawSectorHighlight(mapw, x, y, w, h, yColor);
1820 }
1821 /* Erase ships */
1822 for (i = 0, j = &players[i]; i < nplayers; i++, j++) {
1823 lastUpdate[i]++;
1824 /*
1825 Erase the guy if: redrawPlayer[i] is set and the mapmode setting
1826 allows it.
1827 */
1828 if (!redrawPlayer[i] || (mapmode == GMAP_INFREQUENT && lastUpdate[i] < 5))
1829 continue;
1830 lastUpdate[i] = 0;
1831 /* Clear his old image... */
1832 if (mclearzone[2][i]) {
1833 /* XFIX */
1834 if (!redrawall) {
1835 W_ClearArea(mapw, mclearzone[0][i], mclearzone[1][i],
1836 mclearzone[2][i], mclearzone[3][i]);
1837 /* Redraw the hole just left next update */
1838 checkRedraw(mclearzone[4][i], mclearzone[5][i]);
1839 }
1840 mclearzone[2][i] = 0;
1841 }
1842 }
1843 /* Draw Planets */
1844 #ifdef HOCKEY
1845 if(! (hockey && cleanHockeyGalactic)) {
1846 #endif
1847 for (i = 0, l = &planets[i]; i < nplan; i++, l++) {
1848 char buf[4];
1849 int color;
1850 if (!(l->pl_flags & PLREDRAW) && (!redrawall))
1851 continue;
1852 l->pl_flags &= ~PLREDRAW; /* Turn redraw flag off! */
1853
1854 dx = (l->pl_x - offsetx) * WINSIDE / gwidth;
1855 dy = (l->pl_y - offsety) * WINSIDE / gwidth;
1856
1857 if (PtOutsideWin(dx, dy))
1858 continue;
1859
1860 if (0 == strncmp(l->pl_name, "New ", 4)) {
1861 strncpy(buf, l->pl_name + 4, 3);
1862 } else if (0 == strncmp(l->pl_name, "Planet ", 7)) {
1863 strncpy(buf, l->pl_name + 7, 3);
1864 } else
1865 strncpy(buf, l->pl_name, 3);
1866
1867 /* moving planets */
1868 if (pl_update[l->pl_no].plu_update == 1) {
1869 odx = (pl_update[l->pl_no].plu_x - offsetx) * WINSIDE / gwidth;
1870 ody = (pl_update[l->pl_no].plu_y - offsety) * WINSIDE / gwidth;
1871
1872 /* XFIX */
1873 W_ClearArea(mapw, odx - (mplanet_width / 2), ody - (mplanet_height / 2),
1874 mplanet_width, mplanet_height);
1875
1876 W_WriteText(mapw, odx - (mplanet_width / 2), ody + (mplanet_height / 2),
1877 backColor, buf, 3, planetFont(l));
1878
1879 pl_update[l->pl_no].plu_update = 0;
1880 }
1881 #if 0
1882 /* not necessary, pl_update is now set whenever a planet needs to be
1883 * erased. -JR
1884 */
1885 else {
1886
1887 /* XFIX */
1888 W_ClearArea(mapw, dx - (mplanet_width / 2), dy - (mplanet_height / 2),
1889 mplanet_width, mplanet_height);
1890 }
1891 #endif
1892 color = ((paradise) && (l->pl_flags & (PLSTAR | PLWHOLE))) ?
1893 textColor : planetColor(l);
1894 #ifdef BEEPLITE
1895 if (UseLite && emph_planet_seq_n[l->pl_no] > 0 &&
1896 (F_beeplite_flags & LITE_PLANETS)) {
1897 int seq_n = emph_planet_seq_n[l->pl_no] % emph_planet_seq_frames;
1898
1899 if ((emph_planet_seq_n[l->pl_no] -= 1) > 0)
1900 W_OverlayBitmap(dx - (emph_planet_seq_width / 2),
1901 dy - (emph_planet_seq_height / 2),
1902 emph_planet_seq[seq_n],
1903 emph_planet_color[l->pl_no]);
1904 else
1905 W_ClearArea(mapw, dx - (emph_planet_seq_width / 2),
1906 dy - (emph_planet_seq_height / 2),
1907 emph_planet_seq_width, emph_planet_seq_height);
1908 W_WriteBitmap(dx - (mplanet_width / 2), dy - (mplanet_height / 2),
1909 planetmBitmap(l), color);
1910 l->pl_flags |= PLREDRAW; /* Leave redraw on until done
1911 highlighting */
1912 pl_update[l->pl_no].plu_update = 1;
1913 } else
1914 #endif
1915 if (!(PL_TYPE(*l) == PLWHOLE)) { /* non wormholes */
1916 W_WriteBitmap(dx - (mplanet_width / 2), dy - (mplanet_height / 2),
1917 planetmBitmap(l), color);
1918 W_WriteText(mapw, dx - (mplanet_width / 2), dy + (mplanet_height / 2),
1919 color, buf, ((strlen(buf) >= 3) ? 3 : strlen(buf)),
1920 planetFont(l));
1921 #ifdef SHOW_IND
1922 if (showIND && (l->pl_info & idx_to_mask(me->p_teami)) && (l->pl_owner == NOBODY) && l->pl_flags & PLPLANET)
1923 {
1924 W_MakeLine (mapw, dx + (mplanet_width / 2 - 1), dy + (mplanet_height / 2 - 1),
1925 dx - (mplanet_width / 2), dy - (mplanet_height / 2),
1926 W_White);
1927 W_MakeLine (mapw, dx - (mplanet_width / 2), dy + (mplanet_height / 2 - 1),
1928 dx + (mplanet_width / 2 - 1), dy - (mplanet_height / 2),
1929 W_White);
1930 }
1931 #endif
1932 }
1933 #ifdef VISIBLE_WORMHOLES
1934 else { /* wormholes show when scouted [BDyess] */
1935 if(l->pl_info & idx_to_mask(me->p_teami)) { /* have info [BDyess]*/
1936 printf("l->pl_info == %d\n",l->pl_info);
1937 W_WriteBitmap(dx - (mplanet_width / 2),
1938 dy - (mplanet_height / 2),
1939 planetmBitmap(l),
1940 color);
1941 }
1942 }
1943 #endif /*VISIBLE_WORMHOLES*/
1944 #ifdef HOCKEY
1945 }
1946 #endif
1947 /* Draw ships */
1948 for (i = 0, j = &players[i]; i < nplayers; i++, j++) {
1949 /*
1950 We draw the guy if redrawall, or we just erased him. Also, we
1951 redraw if we haven't drawn for 30 frames. (in case he was erased
1952 by other ships).
1953 */
1954 if (lastUpdate[i] != 0 && (!redrawall) && lastUpdate[i] < 30)
1955 continue;
1956 if (j->p_status != PALIVE)
1957 continue;
1958 lastUpdate[i] = 0;
1959 dx = (j->p_x - offsetx) * WINSIDE / gwidth;
1960 dy = (j->p_y - offsety) * WINSIDE / gwidth;
1961
1962 if ((showLock & 1) && !(j->p_flags & PFCLOAK)) {
1963 if ((me->p_flags & PFPLOCK) && (me->p_playerl == j->p_no)) {
1964 if (lockLine) {
1965 if ((last_lockx[0] != me_galx) || (last_locky[0] != me_galx) ||
1966 (last_lockx[1] != dx) || (last_locky[1] != dy)) {
1967 W_MakeTractLine(mapw, last_lockx[0], last_locky[0],
1968 last_lockx[1], last_locky[1], backColor);
1969 last_lockx[0] = me_galx;
1970 last_locky[0] = me_galy;
1971 last_lockx[1] = dx;
1972 last_locky[1] = dy;
1973 last_lockx[2] = 1;
1974 W_MakeTractLine(mapw, last_lockx[0], last_locky[0],
1975 last_lockx[1], last_locky[1], W_Green);
1976
1977 }
1978 }
1979 W_WriteTriangle(mapw, dx, dy + 6, 4, 1, foreColor);
1980 pl = 1;
1981 }
1982 }
1983 if (PtOutsideWin(dx, dy))
1984 continue;
1985
1986 if (blk_friendlycloak == 1) {
1987 if (j->p_flags & PFCLOAK) {
1988 if (myPlayer(j))
1989 color = myColor;
1990 else if (friendlyPlayer(j))
1991 color = playerColor(j);
1992 else
1993 color = unColor;
1994 } else
1995 color = playerColor(j);
1996
1997 pl = 0;
1998 if (j->p_flags & PFCLOAK)
1999 W_WriteText(mapw, dx - W_Textwidth * cloakcharslen / 2,
2000 dy - W_Textheight / 2, color, cloakchars, cloakcharslen,
2001 W_RegularFont);
2002 else
2003 W_WriteText(mapw, dx - W_Textwidth,
2004 dy - W_Textheight / 2, color, j->p_mapchars, 2,
2005 shipFont(j));
2006 } else {
2007 if (j->p_flags & PFCLOAK) {
2008 W_WriteText(mapw, dx - W_Textwidth * cloakcharslen / 2,
2009 dy - W_Textheight / 2, unColor, cloakchars, cloakcharslen,
2010 W_RegularFont);
2011 } else {
2012 W_WriteText(mapw, dx - W_Textwidth,
2013 dy - W_Textheight / 2, playerColor(j), j->p_mapchars, 2,
2014 shipFont(j));
2015 }
2016 }
2017
2018 #ifdef BEEPLITE
2019 if (UseLite && emph_player_seq_n[i] > 0 &&
2020 (F_beeplite_flags & LITE_PLAYERS_MAP)) {
2021 int seq_n = emph_player_seq_n[i] % emph_player_seq_frames;
2022
2023 W_WriteBitmap(dx - (emph_player_seq_width / 2 - 1),
2024 dy - (emph_player_seq_height / 2 + 1),
2025 emph_player_seq[seq_n],
2026 emph_player_color[i]);
2027 emph_player_seq_n[i] -= 1;
2028 mclearzone[0][i] = dx - (emph_player_seq_width / 2 - 1);
2029 mclearzone[1][i] = dy - (emph_player_seq_height / 2 + 1);
2030 mclearzone[2][i] = emph_player_seq_width;
2031 mclearzone[3][i] = emph_player_seq_height;
2032 mclearzone[4][i] = j->p_x;
2033 mclearzone[5][i] = j->p_y;
2034 /*
2035 Force redraw for this guy no matter what. Even if stationary.
2036 */
2037 lastUpdate[i] = 30;
2038 /* Leave redraw on until done highlighting */
2039 redrawPlayer[i] = 1;
2040 } else
2041 #endif
2042 {
2043 if (j->p_flags & PFCLOAK) {
2044 mclearzone[0][i] = dx - W_Textwidth * cloakcharslen / 2;
2045 mclearzone[1][i] = dy - W_Textheight / 2;
2046 mclearzone[2][i] = W_Textwidth * cloakcharslen;
2047 } else {
2048 mclearzone[0][i] = dx - W_Textwidth;
2049 mclearzone[1][i] = dy - W_Textheight / 2;
2050 mclearzone[2][i] = W_Textwidth * 2;
2051 }
2052 if (pl)
2053 mclearzone[3][i] = W_Textheight + 8;
2054 else
2055 mclearzone[3][i] = W_Textheight;
2056 /* Set these so we can checkRedraw() next time */
2057 mclearzone[4][i] = j->p_x;
2058 mclearzone[5][i] = j->p_y;
2059 redrawPlayer[i] = 0;
2060 }
2061 }
2062 /* draw viewBox if wanted [BDyess] */
2063 #define VIEWDIST SCALE * WINSIDE * WINSIDE / (gwidth * 2)
2064 #define REDRAWDIST SCALE * WINSIDE / 2
2065 if (viewBox && allowViewBox) {
2066 static int viewx = 0, viewy = 0;
2067
2068 dx = (me->p_x - offsetx) * WINSIDE / gwidth;
2069 dy = (me->p_y - offsety) * WINSIDE / gwidth;
2070 if (viewx != dx || viewy != dy || redrawall) {
2071 /* clear old dots - placed here for less flicker */
2072 W_DrawPoint(mapw, viewx + VIEWDIST, viewy + VIEWDIST, backColor);
2073 W_DrawPoint(mapw, viewx + VIEWDIST, viewy - VIEWDIST, backColor);
2074 W_DrawPoint(mapw, viewx - VIEWDIST, viewy + VIEWDIST, backColor);
2075 W_DrawPoint(mapw, viewx - VIEWDIST, viewy - VIEWDIST, backColor);
2076 /* redraw any planets they overwrote */
2077 viewx *= gwidth / WINSIDE + offsetx; /* correct from view
2078 scale */
2079 viewy *= gwidth / WINSIDE + offsety;
2080 checkRedraw(viewx + REDRAWDIST, viewy + REDRAWDIST);
2081 checkRedraw(viewx + REDRAWDIST, viewy - REDRAWDIST);
2082 checkRedraw(viewx - REDRAWDIST, viewy + REDRAWDIST);
2083 checkRedraw(viewx - REDRAWDIST, viewy - REDRAWDIST);
2084 /* draw the new points */
2085 W_DrawPoint(mapw, dx + VIEWDIST, dy + VIEWDIST, W_White);
2086 W_DrawPoint(mapw, dx + VIEWDIST, dy - VIEWDIST, W_White);
2087 W_DrawPoint(mapw, dx - VIEWDIST, dy + VIEWDIST, W_White);
2088 W_DrawPoint(mapw, dx - VIEWDIST, dy - VIEWDIST, W_White);
2089 viewx = dx; /* store the points for later */
2090 viewy = dy; /* clearing */
2091 }
2092 }
2093 #undef VIEWDIST
2094 #undef REDRAWDIST
2095
2096 if (clearlmcount) {
2097 W_WriteTriangle(mapw, clearlmark[0], clearlmark[1], 4, 0, backColor);
2098 clearlmcount--;
2099 }
2100 if (showLock & 1) {
2101 /* for now draw this everytime */
2102 if ((me->p_flags & PFPLLOCK) && (me->p_status != POBSERVE)) {
2103 struct planet *l = &planets[me->p_planet];
2104 dx = (l->pl_x - offsetx) * WINSIDE / gwidth;
2105 dy = (l->pl_y - offsety) * WINSIDE / gwidth;
2106
2107 if (lockLine) {
2108 if ((last_lockx[0] != me_galx) || (last_locky[0] != me_galx) ||
2109 (last_lockx[1] != dx) || (last_locky[1] != dy)) {
2110 W_MakeTractLine(mapw, last_lockx[0], last_locky[0],
2111 last_lockx[1], last_locky[1], backColor);
2112 last_lockx[0] = me_galx;
2113 last_locky[0] = me_galy;
2114 last_lockx[1] = dx;
2115 last_locky[1] = dy;
2116 last_lockx[2] = 1;
2117 W_MakeTractLine(mapw, last_lockx[0], last_locky[0],
2118 last_lockx[1], last_locky[1], W_Green);
2119 }
2120 }
2121 if (!PtOutsideWin(dx, dy)) {
2122 W_WriteTriangle(mapw, dx, dy - (mplanet_height) / 2 - 4, 4, 0,
2123 foreColor);
2124 clearlmark[0] = dx;
2125 clearlmark[1] = dy - (mplanet_height) / 2 - 4;
2126 clearlmcount++;
2127 }
2128 }
2129 }
2130 /* if lock line is drawn but no lock; erase lock line */
2131 if (lockLine && ((me->p_flags & (PFPLLOCK | PFPLOCK)) == 0) && last_lockx[2]) {
2132 W_MakeTractLine(mapw, last_lockx[0], last_locky[0], last_lockx[1],
2133 last_locky[1], backColor);
2134 last_lockx[2] = 0;
2135 }
2136 /* redraw warp beacon routes */
2137
2138 for (i = 0; i < ngthingies; i += 2) {
2139 struct thingy *k = &thingies[i + nplayers * npthingies];
2140 if (k[0].t_shape == SHP_WARP_BEACON &&
2141 k[1].t_shape == SHP_WARP_BEACON) {
2142 W_MakeLine(mapw, (k[0].t_x - offsetx) * WINSIDE / gwidth,
2143 (k[0].t_y - offsety) * WINSIDE / gwidth,
2144 (k[1].t_x - offsetx) * WINSIDE / gwidth,
2145 (k[1].t_y - offsety) * WINSIDE / gwidth,
2146 W_Grey);
2147 }
2148 }
2149 }
2150 redrawall = 0;
2151 }
2152
2153 #define TWODIGIT_L(p, val) \
2154 { \
2155 if ((val)<10) { \
2156 (p)[0] = (val)+'0'; \
2157 (p)[1] = ' '; \
2158 } else { \
2159 (p)[0] = (val)/10 + '0'; \
2160 (p)[1] = (val)%10 + '0'; \
2161 } \
2162 }
2163
2164 #define TWODIGIT_R(p, val) \
2165 { \
2166 if ((val)<10) { \
2167 (p)[0] = ' '; \
2168 (p)[1] = (val)+'0'; \
2169 } else { \
2170 (p)[0] = (val)/10 + '0'; \
2171 (p)[1] = (val)%10 + '0'; \
2172 } \
2173 }
2174
2175 #define THREEDIGIT_C(p, val) \
2176 { \
2177 if ((val)<10) { \
2178 (p)[0] = ' '; (p)[1] = (val)+'0'; (p)[2] = ' '; \
2179 } else if ((val)<100) { \
2180 (p)[0] = (val)/10 + '0'; \
2181 (p)[1] = (val)%10 + '0'; \
2182 (p)[2] = ' '; \
2183 } else { \
2184 (p)[0] = (val)/100 + '0'; \
2185 (p)[1] = ((val)/10 %10) + '0'; \
2186 (p)[2] = (val)%10 + '0'; \
2187 } \
2188 }
2189
2190 #define THREEDIGIT_R(p, val) \
2191 { \
2192 if ((val)<10) { \
2193 (p)[0] = ' '; (p)[1] = ' '; (p)[2] = (val)+'0'; \
2194 } else if ((val)<100) { \
2195 (p)[0] = ' '; \
2196 (p)[1] = (val)/10 + '0'; \
2197 (p)[2] = (val)%10 + '0'; \
2198 } else { \
2199 (p)[0] = (val)/100 + '0'; \
2200 (p)[1] = ((val)/10 %10) + '0'; \
2201 (p)[2] = (val)%10 + '0'; \
2202 } \
2203 }
2204
2205 #define FOURDIGIT_R(p, val) \
2206 { \
2207 if ((val)<10) { \
2208 (p)[0] = ' '; \
2209 (p)[1] = ' '; \
2210 (p)[2] = ' '; \
2211 (p)[3] = (val)+'0'; \
2212 } else if ((val)<100) { \
2213 (p)[0] = ' '; \
2214 (p)[1] = ' '; \
2215 (p)[2] = (val)/10 + '0'; \
2216 (p)[3] = (val)%10 + '0'; \
2217 } else if ((val)<1000) { \
2218 (p)[0] = ' '; \
2219 (p)[1] = (val)/100 + '0'; \
2220 (p)[2] = ((val)/10 %10) + '0'; \
2221 (p)[3] = (val)%10 + '0'; \
2222 } else { \
2223 (p)[0] = (val)/1000 + '0'; \
2224 (p)[1] = ((val)/100 %10) + '0'; \
2225 (p)[2] = ((val)/10 %10) + '0'; \
2226 (p)[3] = (val)%10 + '0'; \
2227 } \
2228 }
2229
2230 #define SIXDIGIT_R(p, val) \
2231 { \
2232 if ((val)<10) { \
2233 (p)[0] = ' '; \
2234 (p)[1] = ' '; \
2235 (p)[2] = ' '; \
2236 (p)[3] = ' '; \
2237 (p)[4] = ' '; \
2238 (p)[5] = (val)+'0'; \
2239 } else if ((val)<100) { \
2240 (p)[0] = ' '; \
2241 (p)[1] = ' '; \
2242 (p)[2] = ' '; \
2243 (p)[3] = ' '; \
2244 (p)[4] = (val)/10 + '0'; \
2245 (p)[5] = (val)%10 + '0'; \
2246 } else if ((val)<1000) { \
2247 (p)[0] = ' '; \
2248 (p)[1] = ' '; \
2249 (p)[2] = ' '; \
2250 (p)[3] = (val)/100 + '0'; \
2251 (p)[4] = ((val)/10 %10) + '0'; \
2252 (p)[5] = (val)%10 + '0'; \
2253 } else if ((val)<10000) { \
2254 (p)[0] = ' '; \
2255 (p)[1] = ' '; \
2256 (p)[2] = ((val)/1000 %10) + '0'; \
2257 (p)[3] = ((val)/100 %10) + '0'; \
2258 (p)[4] = ((val)/10 %10) + '0'; \
2259 (p)[5] = (val)%10 + '0'; \
2260 } else if ((val)<100000) { \
2261 (p)[0] = ' '; \
2262 (p)[1] = ((val)/10000 %10) + '0'; \
2263 (p)[2] = ((val)/1000 %10) + '0'; \
2264 (p)[3] = ((val)/100 %10) + '0'; \
2265 (p)[4] = ((val)/10 %10) + '0'; \
2266 (p)[5] = (val)%10 + '0'; \
2267 } else { \
2268 (p)[0] = (val)/100000 + '0'; \
2269 (p)[1] = ((val)/10000 %10) + '0'; \
2270 (p)[2] = ((val)/1000 %10) + '0'; \
2271 (p)[3] = ((val)/100 %10) + '0'; \
2272 (p)[4] = ((val)/10 %10) + '0'; \
2273 (p)[5] = (val)%10 + '0'; \
2274 } \
2275 }
2276
2277 #define SIXnTWOf_R(p, val) \
2278 { \
2279 (p)[3] = '.'; \
2280 (p)[4] = ((int) (10*(val))) %10 + '0'; \
2281 (p)[5] = ((int) (100*(val))) %10 + '0'; \
2282 if ((val)<10) { \
2283 (p)[0] = ' '; \
2284 (p)[1] = ' '; \
2285 (p)[2] = ((int)(val))+'0'; \
2286 } else if ((val)<100) { \
2287 (p)[0] = ' '; \
2288 (p)[1] = ((int)(val))/10 + '0'; \
2289 (p)[2] = ((int)(val))%10 + '0'; \
2290 } else { \
2291 (p)[0] = ((int)(val))/100 + '0'; \
2292 (p)[1] = (((int)(val))/10 %10) + '0'; \
2293 (p)[2] = ((int)(val))%10 + '0'; \
2294 } \
2295 }
2296
2297 #if 0
2298
2299 static void
2300 stline(flag)
2301 int flag;
2302 {
2303 static char buf1[80];
2304 static char buf2[80];
2305 static char whichbuf = 0;
2306 static int lastnewDashboard;
2307 register char *buf, *oldbuf;
2308 register char *s;
2309 register int i, j;
2310 int k;
2311 /* if you don't do something like this, then switching in the options menu
2312 is 'entertaining' */
2313 if (newDashboard != lastnewDashboard) {
2314 lastnewDashboard = newDashboard;
2315 redrawTstats();
2316 return;
2317 }
2318 /* use the new dashboard if we can */
2319
2320
2321
2322
2323
2324
2325 if (newDashboard) {
2326 db_redraw(flag);
2327 return;
2328 }
2329 /* Instead of one sprintf, we do all this by hand for optimization */
2330
2331 if (flag)
2332 whichbuf = 0; /* We must completely refresh */
2333
2334 if (whichbuf != 2) {
2335 buf = buf1;
2336 oldbuf = buf2;
2337 } else {
2338 buf = buf2;
2339 oldbuf = buf1;
2340 }
2341 buf[0] = (me->p_flags & PFSHIELD ? 'S' : ' ');
2342 if (me->p_flags & PFGREEN)
2343 buf[1] = 'G';
2344 else if (me->p_flags & PFYELLOW)
2345 buf[1] = 'Y';
2346 else if (me->p_flags & PFRED)
2347 buf[1] = 'R';
2348 buf[2] = (me->p_flags & (PFPLLOCK | PFPLOCK) ? 'L' : ' ');
2349 buf[3] = (me->p_flags & PFREPAIR ? 'R' : ' ');
2350 buf[4] = (me->p_flags & PFBOMB ? 'B' : ' ');
2351 buf[5] = (me->p_flags & PFORBIT ? 'O' : ' ');
2352 buf[6] = (me->p_flags & PFDOCKOK ? 'D' : ' ');
2353 /* buf[6] = (me->p_flags & PFDOCK ? 'D' : ' ');*/
2354 buf[7] = (me->p_flags & PFCLOAK ? 'C' : ' ');
2355 buf[8] = (me->p_flags & PFWEP ? 'W' : ' ');
2356 buf[9] = (me->p_flags & PFENG ? 'E' : ' ');
2357 if (me->p_flags & PFPRESS)
2358 buf[10] = 'P';
2359 else if (me->p_flags & PFTRACT)
2360 buf[10] = 'T';
2361 else
2362 buf[10] = ' ';
2363 if (me->p_flags & PFBEAMUP)
2364 buf[11] = 'u';
2365 else if (me->p_flags & PFBEAMDOWN)
2366 buf[11] = 'd';
2367 else
2368 buf[11] = ' ';
2369 if (!paradise)
2370 buf[12] = (status->tourn) ? 't' : ' ';
2371 else
2372 buf[12] = (status2->tourn) ? 't' : ' ';
2373
2374 buf[13] = ' ';
2375
2376 #if 1
2377 /* w/i indicator is a kludge - it just guesses based on the speed of
2378 the ship */
2379 sprintf(buf + 14, "%2d%c %3d %3d %1d %6.2f %3d %6d %4d %4d ",
2380 me->p_speed, (me->p_speed > me->p_ship->s_maxspeed + 2) ? 'w' : 'i',
2381 me->p_damage, me->p_shield, me->p_ntorp, me->p_kills,
2382 me->p_armies, me->p_fuel, me->p_wtemp, me->p_etemp);
2383 #else
2384 #if 0
2385 TWODIGIT_L(&buf[14], me->p_speed);
2386 buf[16] = 'i';
2387 buf[17] = ' ';
2388 buf[18] = ' ';
2389 buf[19] = ' ';
2390 THREEDIGIT_R(&buf[20], me->p_damage);
2391 buf[23] = ' ';
2392 THREEDIGIT_R(&buf[24], me->p_shield);
2393 buf[27] = ' ';
2394 TWODIGIT_R(&buf[28], me->p_ntorp);
2395 buf[30] = ' ';
2396 buf[31] = ' ';
2397 SIXnTWOf_R(&buf[32], me->p_kills);
2398 buf[38] = ' ';
2399 THREEDIGIT_C(&buf[39], me->p_armies);
2400 buf[42] = ' ';
2401 SIXDIGIT_R(&buf[43], me->p_fuel);
2402 buf[49] = ' ';
2403 buf[50] = ' ';
2404 FOURDIGIT_R(&buf[51], me->p_wtemp / 10);
2405 buf[55] = ' ';
2406 FOURDIGIT_R(&buf[56], me->p_etemp / 10);
2407 buf[60] = ' ';
2408 buf[61] = ' ';
2409 #else
2410 buf[14] = '0' + ((me->p_speed % 100) / 10);
2411 if (buf[14] == '0')
2412 buf[14] = ' ';
2413 buf[15] = '0' + (me->p_speed % 10); /* speed */
2414 buf[16] = ' ';
2415 buf[17] = ' ';
2416 buf[18] = '0' + (me->p_damage / 100);
2417 if (buf[18] == '0')
2418 buf[18] = ' ';
2419 buf[19] = '0' + ((me->p_damage % 100) / 10);
2420 if ((buf[19] == '0') && (me->p_damage < 100))
2421 buf[19] = ' ';
2422 buf[20] = '0' + (me->p_damage % 10);
2423 buf[21] = ' ';
2424 buf[22] = '0' + (me->p_shield / 100);
2425 if (buf[22] == '0')
2426 buf[22] = ' ';
2427 buf[23] = '0' + ((me->p_shield % 100) / 10);
2428 if ((buf[23] == '0') && (me->p_shield < 100))
2429 buf[23] = ' ';
2430 buf[24] = '0' + (me->p_shield % 10);
2431 buf[25] = ' ';
2432 buf[26] = ' ';
2433 buf[27] = '0' + ((me->p_ntorp % 100) / 10);
2434 if (buf[27] == '0')
2435 buf[27] = ' ';
2436 buf[28] = '0' + (me->p_ntorp % 10);
2437 buf[29] = ' ';
2438 buf[30] = ' ';
2439 buf[31] = ' ';
2440 buf[32] = ' ';
2441 buf[33] = '0' + ((int) (me->p_kills / 10));
2442 if (buf[33] == '0')
2443 buf[33] = ' ';
2444 buf[34] = '0' + (((int) me->p_kills) % 10);
2445 buf[35] = '.';
2446 buf[36] = '0' + (((int) (me->p_kills * 10)) % 10);
2447 buf[37] = '0' + (((int) (me->p_kills * 100)) % 10);
2448 buf[38] = ' ';
2449 buf[39] = ' ';
2450 buf[40] = ' ';
2451 buf[41] = '0' + ((me->p_armies % 100) / 10);
2452 if (buf[41] == '0')
2453 buf[41] = ' ';
2454 buf[42] = '0' + (me->p_armies % 10);
2455 buf[43] = ' ';
2456 buf[44] = ' ';
2457 buf[45] = ' ';
2458
2459 buf[46] = '0' + (me->p_fuel / 100000);
2460 if (buf[46] == '0')
2461 buf[46] = ' ';
2462 buf[47] = '0' + ((me->p_fuel % 100000) / 10000);
2463 if ((buf[47] == '0') && (me->p_fuel < 100000))
2464 buf[47] = ' ';
2465 buf[48] = '0' + ((me->p_fuel % 10000) / 1000);
2466 if ((buf[48] == '0') && (me->p_fuel < 10000))
2467 buf[48] = ' ';
2468 buf[49] = '0' + ((me->p_fuel % 1000) / 100);
2469 if ((buf[49] == '0') && (me->p_fuel < 1000))
2470 buf[49] = ' ';
2471 buf[50] = '0' + ((me->p_fuel % 100) / 10);
2472 if ((buf[50] == '0') && (me->p_fuel < 100))
2473 buf[50] = ' ';
2474 buf[51] = '0' + (me->p_fuel % 10);
2475 buf[52] = ' ';
2476 buf[53] = ' ';
2477 buf[54] = ' ';
2478
2479 buf[55] = '0' + ((me->p_wtemp / 10) / 100);
2480 if (buf[55] == '0')
2481 buf[55] = ' ';
2482 buf[56] = '0' + (((me->p_wtemp / 10) % 100) / 10);
2483 if ((buf[56] == '0') && (me->p_wtemp < 1000))
2484 buf[56] = ' ';
2485 buf[57] = '0' + ((me->p_wtemp / 10) % 10);
2486
2487 buf[58] = ' ';
2488 buf[59] = ' ';
2489 buf[60] = ' ';
2490 buf[61] = '0' + ((me->p_etemp / 10) / 1000);
2491 if (buf[61] == '0')
2492 buf[61] = ' ';
2493 buf[62] = '0' + (((me->p_etemp / 10) % 1000) / 100);
2494 if (buf[62] == '0' && me->p_etemp < 1000)
2495 buf[62] = ' ';
2496 buf[63] = '0' + (((me->p_etemp / 10) % 100) / 10);
2497 if ((buf[63] == '0') && (me->p_etemp < 1000))
2498 buf[63] = ' ';
2499 buf[64] = '0' + ((me->p_etemp / 10) % 10);
2500 buf[65] = ' ';
2501 #endif
2502 #endif
2503
2504 if (whichbuf == 0) {
2505 /* Draw status line */
2506 W_WriteText(tstatw, TSTATW_BASEX, 16, textColor, buf, 66, W_RegularFont);
2507 whichbuf = 1;
2508 } else { /* Hacks to make it print only what is
2509 necessary */
2510 whichbuf = 3 - whichbuf;
2511 j = -1;
2512 for (i = 0; i < 66; i++) {
2513 if (*(buf++) != *(oldbuf++)) {
2514 /* Different string */
2515 if (j == -1) {
2516 k = i;
2517 s = buf - 1;
2518 }
2519 j = 0;
2520 } else {
2521 /* Same string */
2522 if (j == -1)
2523 continue;
2524 j++;
2525 if (j == 20) { /* Random number */
2526 W_WriteText(tstatw, TSTATW_BASEX + W_Textwidth * k, 16, textColor,
2527 s, i - k - 19, W_RegularFont);
2528 j = -1;
2529 }
2530 }
2531 }
2532 if (j != -1) {
2533 W_WriteText(tstatw, TSTATW_BASEX + W_Textwidth * k, 16, textColor, s, i - k - j,
2534 W_RegularFont);
2535 }
2536 }
2537 }
2538
2539 void
2540 redrawTstats()
2541 {
2542 char buf[100];
2543 W_ClearWindow(tstatw);
2544 /* use new dashboard if possible */
2545 if (newDashboard) {
2546 db_redraw(1);
2547 return;
2548 }
2549 stline(1); /* This is for refresh. We redraw player
2550 stats too */
2551 strcpy(buf, "Flags Speed Dam Shd Trp Kills Ams Fuel Wtmp Etmp Special" /* "Flags Warp
2552 Dam Shd Torps Kills
2553 Armies Fuel Wtemp
2554 Etemp" */ );
2555 W_WriteText(tstatw, TSTATW_BASEX, 5, textColor, buf, strlen(buf), W_RegularFont);
2556 sprintf(buf,
2557 "Maximum: %2d %3d %3d 8 %3d %6d %4d %4d ",
2558 me->p_ship->s_maxspeed, me->p_ship->s_maxdamage,
2559 me->p_ship->s_maxshield, me->p_ship->s_maxarmies,
2560 me->p_ship->s_maxfuel, me->p_ship->s_maxwpntemp / 10,
2561 me->p_ship->s_maxegntemp / 10);
2562 W_WriteText(tstatw, TSTATW_BASEX, 27, textColor, buf, strlen(buf), W_RegularFont);
2563 }
2564 #endif