Mercurial > ~darius > hgwebdir.cgi > paradise_client
comparison dashboard.c @ 1:ff5e05767bd3 ALPHA
Empty changelog
author | darius |
---|---|
date | Sat, 06 Dec 1997 05:41:28 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:d17661b1e221 | 1:ff5e05767bd3 |
---|---|
1 /* $Id: dashboard.c,v 1.1.1.1 1997/12/06 05:41:28 darius Exp $ */ | |
2 | |
3 /* | |
4 * dashboard.c - graphic tstatw - 6/2/93 | |
5 * | |
6 * copyright 1993 Lars Bernhardsson (lab@mtek.chalmers.se) | |
7 * Free to use as long as this notice is left here. | |
8 * | |
9 * Color by Nick Trown. | |
10 * Paradise shoehorning by Bill Dyess. | |
11 * Rainbow dashboard by Bill Dyess | |
12 */ | |
13 | |
14 #include "copyright.h" | |
15 | |
16 #include <stdio.h> | |
17 #include <time.h> | |
18 #include "Wlib.h" | |
19 #include "defs.h" | |
20 #include "struct.h" | |
21 #include "data.h" | |
22 #include "proto.h" | |
23 #include "sound.h" | |
24 | |
25 #define DB_NOFILL 0 | |
26 #define DB_LINE 1 | |
27 #define DB_FILL 2 | |
28 | |
29 #define DB_3DIGITS 0 | |
30 #define DB_5DIGITS 1 | |
31 | |
32 /* | |
33 #define BAR_LENGTH 56 | |
34 #define BAR_LENGTH_THIRD 18 | |
35 */ | |
36 #define TSTATW_BASEX 32 | |
37 | |
38 #define SPACING 4 | |
39 | |
40 int BAR_LENGTH = 56; | |
41 int BAR_LENGTH_THIRD = 18; | |
42 | |
43 int column[4]; | |
44 | |
45 #ifdef PACKET_LIGHTS | |
46 /* code to draw and erase packet lights 2/5/94 [BDyess] */ | |
47 | |
48 #define SENDX 7 | |
49 #define SENDY 1 | |
50 #define RECEIVEX 3 | |
51 #define RECEIVEY 1 | |
52 | |
53 int send_lit = 0, receive_lit = 0; | |
54 | |
55 void | |
56 light_send() | |
57 { | |
58 if (packetLights == 0 || send_lit) | |
59 return; | |
60 send_lit = 1; | |
61 W_DrawPoint(tstatw, SENDX, SENDY, W_Green); | |
62 W_DrawPoint(tstatw, SENDX + 1, SENDY, W_Green); | |
63 W_DrawPoint(tstatw, SENDX, SENDY + 1, W_Green); | |
64 W_DrawPoint(tstatw, SENDX + 1, SENDY + 1, W_Green); | |
65 } | |
66 | |
67 void | |
68 light_receive() | |
69 { | |
70 if (packetLights == 0 || receive_lit) | |
71 return; | |
72 receive_lit = 2; | |
73 W_DrawPoint(tstatw, RECEIVEX, RECEIVEY, W_Yellow); | |
74 W_DrawPoint(tstatw, RECEIVEX + 1, RECEIVEY, W_Yellow); | |
75 W_DrawPoint(tstatw, RECEIVEX, RECEIVEY + 1, W_Yellow); | |
76 W_DrawPoint(tstatw, RECEIVEX + 1, RECEIVEY + 1, W_Yellow); | |
77 } | |
78 | |
79 void | |
80 light_erase() | |
81 { | |
82 if (receive_lit == 1) { | |
83 W_DrawPoint(tstatw, RECEIVEX, RECEIVEY, backColor); | |
84 W_DrawPoint(tstatw, RECEIVEX + 1, RECEIVEY, backColor); | |
85 W_DrawPoint(tstatw, RECEIVEX, RECEIVEY + 1, backColor); | |
86 W_DrawPoint(tstatw, RECEIVEX + 1, RECEIVEY + 1, backColor); | |
87 } | |
88 if (receive_lit) | |
89 receive_lit--; | |
90 if (send_lit == 1) { | |
91 W_DrawPoint(tstatw, SENDX, SENDY, backColor); | |
92 W_DrawPoint(tstatw, SENDX + 1, SENDY, backColor); | |
93 W_DrawPoint(tstatw, SENDX, SENDY + 1, backColor); | |
94 W_DrawPoint(tstatw, SENDX + 1, SENDY + 1, backColor); | |
95 } | |
96 if (send_lit) | |
97 send_lit--; | |
98 } | |
99 #endif /* PACKET_LIGHTS */ | |
100 | |
101 void | |
102 db_box(x, y, w, h, f, color) | |
103 int x, y, w, h, f, color; | |
104 { | |
105 int border = W_White; | |
106 | |
107 if (color == W_Red) | |
108 border = color; | |
109 | |
110 if (w == 0 || h == 0) | |
111 return; | |
112 | |
113 switch (f) { | |
114 case DB_FILL: | |
115 W_FillArea(tstatw, x, y, w + 1, h + 1, color); | |
116 break; | |
117 case DB_LINE: | |
118 W_MakeLine(tstatw, x + w, y, x + w, y + h, border); | |
119 W_MakeLine(tstatw, x + w, y + 4, x + BAR_LENGTH, y + 4, border); | |
120 break; | |
121 case DB_NOFILL: | |
122 W_MakeLine(tstatw, x, y, x + w, y, border); | |
123 W_MakeLine(tstatw, x + w, y, x + w, y + h, border); | |
124 W_MakeLine(tstatw, x + w, y + h, x, y + h, border); | |
125 W_MakeLine(tstatw, x, y + h, x, y, border); | |
126 break; | |
127 } | |
128 } | |
129 | |
130 void | |
131 db_bar(lab, x, y, value, tmpmax, max, digits, color) | |
132 char *lab; | |
133 int x, y, value, tmpmax, max, digits, color; | |
134 { | |
135 register int wt, wv, tw, tc; | |
136 char valstr[32]; | |
137 | |
138 switch (digits) { | |
139 case DB_3DIGITS: | |
140 tc = 11; | |
141 tw = W_Textwidth * tc; | |
142 sprintf(valstr, "%2.2s[%3d/%3d]", lab, value, tmpmax); | |
143 W_ClearArea(tstatw, x, y, tw + BAR_LENGTH, W_Textheight); | |
144 break; | |
145 case DB_5DIGITS: | |
146 default: | |
147 tc = 15; | |
148 tw = W_Textwidth * tc; | |
149 sprintf(valstr, "%2.2s[%5d/%5d]", lab, value, tmpmax); | |
150 W_ClearArea(tstatw, x, y, tw + BAR_LENGTH, W_Textheight); | |
151 break; | |
152 } | |
153 | |
154 if (max) { | |
155 wt = (BAR_LENGTH * tmpmax) / max; | |
156 wv = (BAR_LENGTH * value) / max; | |
157 } else { | |
158 wt = 0; | |
159 wv = 0; | |
160 } | |
161 if (wt > BAR_LENGTH) | |
162 wt = BAR_LENGTH; | |
163 if (wv > BAR_LENGTH) | |
164 wv = BAR_LENGTH; | |
165 | |
166 W_WriteText(tstatw, x, y, textColor, valstr, tc, W_RegularFont); | |
167 | |
168 db_box(x + tw, y, BAR_LENGTH, W_Textheight - 1, DB_NOFILL, color); | |
169 if (wt >= wv && wt > 0) | |
170 db_box(x + tw, y, wt, W_Textheight - 1, DB_LINE, color); | |
171 | |
172 if (wv > 0) | |
173 db_box(x + tw, y, wv, W_Textheight - 1, DB_FILL, color); | |
174 } | |
175 | |
176 void | |
177 db_color_bar(lab, x, y, barvalue, numvalue, tmpmax, max, digits) | |
178 char *lab; | |
179 int x, y, barvalue, numvalue, tmpmax, max, digits; | |
180 { | |
181 register int wt, wv, tw, tc; | |
182 char valstr[32]; | |
183 int color = W_White; | |
184 | |
185 switch (digits) { | |
186 case DB_3DIGITS: | |
187 tc = 11; | |
188 tw = W_Textwidth * tc; | |
189 sprintf(valstr, "%2.2s[%3d/%3d]", lab, numvalue, tmpmax); | |
190 W_ClearArea(tstatw, x, y, tw + BAR_LENGTH, W_Textheight); | |
191 break; | |
192 case DB_5DIGITS: | |
193 default: | |
194 tc = 15; | |
195 tw = W_Textwidth * tc; | |
196 sprintf(valstr, "%2.2s[%5d/%5d]", lab, numvalue, tmpmax); | |
197 W_ClearArea(tstatw, x, y, tw + BAR_LENGTH, W_Textheight); | |
198 break; | |
199 } | |
200 | |
201 if (max) { | |
202 wt = (int) ((float) BAR_LENGTH * ((float) tmpmax / (float) max)); | |
203 wv = (int) ((float) BAR_LENGTH * ((float) barvalue / (float) max)); | |
204 } else { | |
205 wt = 0; | |
206 wv = 0; | |
207 } | |
208 #if 0 /* this code turns the color to red when it | |
209 exceeds the bar length */ | |
210 if (wv > wt) | |
211 color = W_Red; | |
212 #endif /* 0 */ | |
213 if (wt > BAR_LENGTH) | |
214 wt = BAR_LENGTH; | |
215 if (wv > BAR_LENGTH) | |
216 wv = BAR_LENGTH; | |
217 | |
218 W_WriteText(tstatw, x, y, color, valstr, tc, W_RegularFont); | |
219 | |
220 db_box(x + tw, y, BAR_LENGTH, W_Textheight - 1, DB_NOFILL, color); | |
221 if (wt >= wv && wt > 0) | |
222 db_box(x + tw, y, wt, W_Textheight - 1, DB_LINE, color); | |
223 | |
224 /* draw rainbow bars */ | |
225 if (wv > 0) | |
226 db_box(x + tw, y, wv > BAR_LENGTH_THIRD ? BAR_LENGTH_THIRD : wv, W_Textheight - 1, DB_FILL, W_Green); | |
227 if (wv > BAR_LENGTH_THIRD) | |
228 db_box(x + tw + BAR_LENGTH_THIRD, y, wv > 2 * BAR_LENGTH_THIRD ? BAR_LENGTH_THIRD | |
229 : wv - BAR_LENGTH_THIRD, W_Textheight - 1, DB_FILL, W_Yellow); | |
230 if (wv > 2 * BAR_LENGTH_THIRD) | |
231 db_box(x + tw + 2 * BAR_LENGTH_THIRD, y, (wv > BAR_LENGTH ? BAR_LENGTH : wv) - | |
232 2 * BAR_LENGTH_THIRD, W_Textheight - 1, DB_FILL, W_Red); | |
233 | |
234 #if 0 | |
235 /* draw rainbow bars */ | |
236 if (wv > 0) | |
237 db_box((x += 1) + tw, y += 1, wv > BAR_LENGTH_THIRD ? BAR_LENGTH_THIRD : wv, 7, DB_FILL, W_Green); | |
238 if (wv > BAR_LENGTH_THIRD) | |
239 db_box(x + tw + BAR_LENGTH_THIRD, y, wv > 2 * BAR_LENGTH_THIRD ? BAR_LENGTH_THIRD | |
240 : wv - BAR_LENGTH_THIRD, 7, DB_FILL, W_Yellow); | |
241 if (wv > 2 * BAR_LENGTH_THIRD) | |
242 db_box(x + tw + 2 * BAR_LENGTH_THIRD, y, (wv > BAR_LENGTH ? BAR_LENGTH : wv) - | |
243 2 * BAR_LENGTH_THIRD - 2, 7, DB_FILL, W_Red); | |
244 #endif /* 0 */ | |
245 } | |
246 | |
247 #ifdef TIMER | |
248 void | |
249 db_timer(fr, xloc, yloc) | |
250 int fr, xloc, yloc; | |
251 /* handles the dashboard timer [BDyess] 10/29/93 */ | |
252 { | |
253 static time_t oldtime = -1; | |
254 static int lastTimerType = -1; | |
255 time_t now = 0; | |
256 static char lasttimer[TIMESTRLEN], *timer; | |
257 int left, right, x, pos; | |
258 | |
259 #ifdef RECORDER | |
260 if(playback) { | |
261 pb_framectr(xloc, yloc); | |
262 return; | |
263 } | |
264 #endif | |
265 if (timerType != lastTimerType || fr) { | |
266 fr = 1; | |
267 lastTimerType = timerType; | |
268 switch (timerType) { | |
269 case T_NONE: | |
270 W_ClearArea(tstatw, xloc, yloc, (TIMESTRLEN+3) * W_Textwidth, | |
271 W_Textheight); | |
272 memset(lasttimer, ' ', TIMESTRLEN); | |
273 strcpy(lasttimer, " "); | |
274 oldtime = now; | |
275 break; | |
276 case T_DAY: | |
277 W_WriteText(tstatw, xloc, yloc, textColor, "NOW", 3, W_RegularFont); | |
278 break; | |
279 case T_SERVER: | |
280 W_WriteText(tstatw, xloc, yloc, textColor, "SRV", 3, W_RegularFont); | |
281 break; | |
282 case T_SHIP: | |
283 W_WriteText(tstatw, xloc, yloc, textColor, "SHP", 3, W_RegularFont); | |
284 break; | |
285 case T_USR: | |
286 W_WriteText(tstatw, xloc, yloc, textColor, "TMR", 3, W_RegularFont); | |
287 break; | |
288 } | |
289 } | |
290 if (!timerType) | |
291 return; | |
292 now = time(NULL); | |
293 if (now != oldtime || fr) { | |
294 /* | |
295 get the timer string and start comparing it with the old one. Only | |
296 print the differences | |
297 */ | |
298 timer = timeString(now - timeBank[timerType]); | |
299 x = xloc + 4 * W_Textwidth; | |
300 left = 0; | |
301 right = -1; | |
302 pos = 0; | |
303 | |
304 /* | |
305 run through the string to find any differences. Print any | |
306 continuous differences with one W_WriteText call. | |
307 */ | |
308 if (fr) { | |
309 W_WriteText(tstatw, x, yloc, textColor, timer, | |
310 TIMESTRLEN, W_RegularFont); | |
311 } else { | |
312 while (pos < TIMESTRLEN) { | |
313 if (timer[pos] == lasttimer[pos]) { | |
314 if (left <= right) | |
315 W_WriteText(tstatw, x + left * W_Textwidth, | |
316 yloc, textColor, timer + left, | |
317 right - left + 1, W_RegularFont); | |
318 left = pos + 1; | |
319 right = pos; | |
320 } else | |
321 right++; | |
322 pos++; | |
323 } | |
324 if (left <= right) | |
325 W_WriteText(tstatw, x + left * W_Textwidth, yloc, textColor, | |
326 timer + left, right - left + 1, W_RegularFont); | |
327 } | |
328 oldtime = now; | |
329 strcpy(lasttimer, timer); | |
330 } | |
331 return; | |
332 } | |
333 #endif /* TIMER */ | |
334 | |
335 void | |
336 db_flags(fr) | |
337 int fr; | |
338 { | |
339 static float old_kills = -1.0; | |
340 static int old_torp = -1; | |
341 static int old_drone = 0; | |
342 static int old_totmissiles = 0; | |
343 static unsigned int old_flags = ~(unsigned int) 0; | |
344 static int old_tourn = -1; | |
345 static int old_spd = -1; | |
346 unsigned char current_tourn; | |
347 int i; | |
348 char buf[26]; | |
349 | |
350 #ifdef UNIX_SOUND | |
351 if ((me->p_etemp > me->p_ship->s_maxegntemp) && (me->p_flags & PFENG)) | |
352 maybe_play_sound (SND_THERMAL); /* Engines Over Thermal Limit, play ONLY once */ | |
353 else sound_completed (SND_THERMAL); /* Done with Etmp, Replay Sound if we Etmp Again */ | |
354 #endif | |
355 | |
356 if (fr || me->p_flags != old_flags) { | |
357 buf[0] = (me->p_flags & PFSHIELD ? 'S' : ' '); | |
358 | |
359 if (me->p_flags & PFGREEN) | |
360 buf[1] = 'G'; | |
361 else if (me->p_flags & PFYELLOW) | |
362 buf[1] = 'Y'; | |
363 else | |
364 buf[1] = 'R'; | |
365 buf[2] = (me->p_flags & (PFPLLOCK | PFPLOCK) ? 'L' : ' '); | |
366 buf[3] = (me->p_flags & PFREPAIR ? 'R' : ' '); | |
367 buf[4] = (me->p_flags & PFBOMB ? 'B' : ' '); | |
368 buf[5] = (me->p_flags & PFORBIT ? 'O' : ' '); | |
369 buf[6] = (me->p_flags & (PFDOCK | PFDOCKOK)) ? 'D' : ' '; | |
370 buf[7] = (me->p_flags & PFCLOAK ? 'C' : ' '); | |
371 buf[8] = (me->p_flags & PFWEP ? 'W' : ' '); | |
372 buf[9] = (me->p_flags & PFENG ? 'E' : ' '); | |
373 if (me->p_flags & PFPRESS) | |
374 buf[10] = 'P'; | |
375 else if (me->p_flags & PFTRACT) | |
376 buf[10] = 'T'; | |
377 else | |
378 buf[10] = ' '; | |
379 if (me->p_flags & PFBEAMUP) | |
380 buf[11] = 'u'; | |
381 else if (me->p_flags & PFBEAMDOWN) | |
382 buf[11] = 'd'; | |
383 else | |
384 buf[11] = ' '; | |
385 | |
386 /* Flags turn red with etemped/wtemped [BDyess] */ | |
387 if (me->p_flags & (PFWEP | PFENG)) | |
388 W_WriteText(tstatw, 2, 3, W_Red, "Flags", 5, W_RegularFont); | |
389 else | |
390 W_WriteText(tstatw, 2, 3, textColor, "Flags", 5, W_RegularFont); | |
391 /* blue 'Warp' text [BDyess] */ | |
392 if (me->p_flags & PFWARP) | |
393 W_WriteText(tstatw, 2 + 6 * W_Textwidth, 3, W_Cyan, " Warp", 8, | |
394 W_BoldFont); | |
395 /* red 'Afterbrn' text [BDyess] */ | |
396 else if (me->p_flags & PFAFTER) | |
397 W_WriteText(tstatw, 2 + 6 * W_Textwidth, 3, W_Red, "Afterbrn", 8, | |
398 W_RegularFont); | |
399 /* yellow 'WarpPrep' or 'WrpPause' text [BDyess] */ | |
400 else if (me->p_flags & PFWARPPREP) | |
401 if (me->p_flags & PFWPSUSPENDED) | |
402 W_WriteText(tstatw, 2 + 6 * W_Textwidth, 3, W_Yellow, "WrpPause", | |
403 8, W_RegularFont); | |
404 else | |
405 W_WriteText(tstatw, 2 + 6 * W_Textwidth, 3, W_Yellow, "WarpPrep", | |
406 8, W_RegularFont); | |
407 /* green 'Impulse' text [BDyess] */ | |
408 else if (me->p_speed > 0) | |
409 W_WriteText(tstatw, 2 + 6 * W_Textwidth, 3, W_Green, " Impulse", 8, | |
410 W_RegularFont); | |
411 /* white 'Stopped' text [BDyess] */ | |
412 else | |
413 W_WriteText(tstatw, 2 + 6 * W_Textwidth, 3, textColor, " Stopped", 8, | |
414 W_RegularFont); | |
415 W_WriteText(tstatw, 2, 3 + (W_Textheight + SPACING), textColor, buf, 12, W_RegularFont); | |
416 #if 0 /* colored G/Y/R status flags. Looked stupid */ | |
417 if (me->p_flags & PFGREEN) | |
418 W_WriteText(tstatw, 2 + W_Textwidth, 3 + W_Textheight + SPACING, W_Green, "G", 1, W_RegularFont); | |
419 else if (me->p_flags & PFYELLOW) | |
420 W_WriteText(tstatw, 2 + W_Textwidth, 3 + W_Textheight + SPACING, W_Yellow, "Y", 1, W_RegularFont); | |
421 else | |
422 W_WriteText(tstatw, 2 + W_Textwidth, 3 + W_Textheight + SPACING, W_Red, "R", 1, W_RegularFont); | |
423 #endif /* 0 */ | |
424 old_flags = me->p_flags; | |
425 old_spd = me->p_speed; | |
426 } else if ( (me->p_speed == 0 && old_spd) || | |
427 (me->p_speed && old_spd == 0) ) { | |
428 if (me->p_speed > 0) | |
429 W_WriteText(tstatw, 2 + 6 * W_Textwidth, 3, W_Yellow, " Impulse", 8, | |
430 W_RegularFont); | |
431 else | |
432 W_WriteText(tstatw, 2 + 6 * W_Textwidth, 3, textColor, " Stopped", 8, | |
433 W_RegularFont); | |
434 old_spd = me->p_speed; | |
435 } | |
436 current_tourn = paradise ? status2->tourn : status->tourn; | |
437 | |
438 if (fr || current_tourn != old_tourn) { | |
439 if (current_tourn) | |
440 W_WriteText(tstatw, 74, 3 + W_Textheight + SPACING, textColor, "T", 1, W_BoldFont); | |
441 else | |
442 W_WriteText(tstatw, 74, 3 + W_Textheight + SPACING, textColor, " ", 1, W_BoldFont); | |
443 | |
444 old_tourn = current_tourn; | |
445 } | |
446 if (fr || me->p_kills != old_kills) { | |
447 if (me->p_kills > 0.0) { | |
448 /* W_WriteText (tstatw, column[3], 3+W_Textheight + SPACING, textColor, "Kills:", 6, W_RegularFont);*/ | |
449 sprintf(buf, "Kills: %5.2f", me->p_kills); | |
450 W_WriteText(tstatw, column[3], 3 + W_Textheight + SPACING, textColor, buf, strlen(buf), W_RegularFont); | |
451 } else { | |
452 W_ClearArea(tstatw, column[3], 3 + W_Textheight + SPACING, 12 * W_Textwidth, W_Textheight); | |
453 } | |
454 old_kills = me->p_kills; | |
455 } | |
456 if (fr || me->p_ntorp != old_torp) { | |
457 if (me->p_ntorp > 0) { | |
458 /* W_WriteText (tstatw, column[3]+17*W_Textwidth, 3+W_Textheight + SPACING, textColor, "Torps:", | |
459 6, W_RegularFont); | |
460 */ | |
461 sprintf(buf, "Torps: %d", me->p_ntorp); | |
462 W_WriteText(tstatw, column[3] + 17 * W_Textwidth, 3 + W_Textheight + SPACING, textColor, buf, | |
463 strlen(buf), W_RegularFont); | |
464 } else { | |
465 W_ClearArea(tstatw, column[3] + 17 * W_Textwidth, 3 + W_Textheight + SPACING, 8 * W_Textwidth, 10); | |
466 } | |
467 old_torp = me->p_ntorp; | |
468 } | |
469 /* code to show the number of drones out */ | |
470 strcpy(buf, "Missiles "); | |
471 if (fr || me->p_totmissiles != old_totmissiles || me->p_ndrone != old_drone) { | |
472 if (me->p_totmissiles > 0) | |
473 sprintf(buf + strlen(buf), "Left: %d ", me->p_totmissiles); | |
474 old_totmissiles = me->p_totmissiles; | |
475 if (me->p_ndrone > 0) | |
476 sprintf(buf + strlen(buf), "Out: %d ", me->p_ndrone); | |
477 old_drone = me->p_ndrone; | |
478 if (!me->p_totmissiles && !me->p_ndrone) { /* clear missile text */ | |
479 W_ClearArea(tstatw, column[3], 3 + 2 * (W_Textheight + SPACING), 24 * W_Textwidth, W_Textheight); | |
480 } else { | |
481 for (i = strlen(buf); i < 24; i++) | |
482 buf[i] = ' '; | |
483 buf[24] = 0; | |
484 W_WriteText(tstatw, column[3], 3 + 2 * (W_Textheight + SPACING), textColor, buf, 24, W_RegularFont); | |
485 } | |
486 } | |
487 #if 0 | |
488 if (fr || me->p_ndrone != old_drone) { | |
489 if (me->p_ndrone > 0) { | |
490 if (!missile_text) { | |
491 W_WriteText(tstatw, column[3], 30, textColor, | |
492 "Missiles", 8, W_RegularFont); | |
493 } | |
494 sprintf(buf, "Out: %d", me->p_ndrone); | |
495 W_WriteText(tstatw, column[3] + W_Textwidth * 18, 30, textColor, buf, strlen(buf), W_RegularFont); | |
496 } else { | |
497 W_ClearArea(tstatw, column[3] + W_Textwidth * 18, 30, 7 * W_Textwidth, W_Textheight); | |
498 } | |
499 old_drone = me->p_ndrone; | |
500 } | |
501 if (fr || me->p_totmissiles != old_totmissiles) { | |
502 if (me->p_totmissiles > 0) { | |
503 if (!missile_text) { | |
504 W_WriteText(tstatw, column[3], 30, textColor, | |
505 "Missiles", 8, W_RegularFont); | |
506 } | |
507 sprintf(buf, "Left: %d", me->p_totmissiles); | |
508 W_WriteText(tstatw, column[3] + W_Textwidth * 9, 3 + 2 * (W_Textheight + SPACING), | |
509 textColor, buf, strlen(buf), W_RegularFont); | |
510 } else { | |
511 W_ClearArea(tstatw, column[3], 3 + 2 * (W_Textheight + SPACING), 8 * W_Textwidth, W_Textheight); | |
512 } | |
513 old_totmissiles = me->p_totmissiles; | |
514 } | |
515 if (missile_text && !me->p_totmissiles && !me->p_ndrone) /* clear missile text */ | |
516 W_ClearArea(tstatw, column[3], 30, 9 * W_Textwidth, 10); | |
517 #endif /* 0 */ | |
518 } | |
519 | |
520 void | |
521 db_redraw_krp(fr) | |
522 int fr; | |
523 { | |
524 static int old_spd = -1, old_cur_spd = -1; | |
525 static int old_shl = -1, old_dam = -1; | |
526 static int old_arm = -1, old_cur_arm = -1; | |
527 static int old_wpn = -1, old_egn = -1; | |
528 static int old_ful = -1; | |
529 register int cur_max; | |
530 register int value; | |
531 int color; | |
532 int index = 0; | |
533 register int mid; | |
534 | |
535 if (me->p_ship->s_type == STARBASE) /* SB */ | |
536 index = 1; | |
537 | |
538 if (fr) | |
539 W_ClearWindow(tstatw); | |
540 | |
541 db_flags(fr); | |
542 | |
543 #ifdef TIMER | |
544 db_timer(fr, 1, 3 + 2 * (W_Textheight + SPACING)); | |
545 #endif /* TIMER */ | |
546 | |
547 #ifdef PACKET_LIGHTS | |
548 light_erase(); | |
549 #endif /* PACKET_LIGHTS */ | |
550 | |
551 if (paradise) | |
552 cur_max = me->p_ship->s_maxspeed - (int) ((float) me->p_ship->s_maxspeed | |
553 * (float) me->p_damage / (float) me->p_ship->s_maxdamage); | |
554 else | |
555 cur_max = (me->p_ship->s_maxspeed + 1) - ((me->p_ship->s_maxspeed + 1) * me->p_damage) | |
556 / me->p_ship->s_maxdamage; | |
557 if (cur_max > me->p_ship->s_maxspeed) | |
558 cur_max = me->p_ship->s_maxspeed; | |
559 if (cur_max < 0) | |
560 cur_max = 0; | |
561 | |
562 if (fr || me->p_speed != old_spd || cur_max != old_cur_spd) { | |
563 if (me->p_speed >= me->p_ship->s_maxspeed - 2) | |
564 color = W_Red; | |
565 else | |
566 color = W_Green; | |
567 db_bar("Sp", column[1], 3, | |
568 me->p_speed, cur_max, me->p_ship->s_maxspeed, DB_3DIGITS, color); | |
569 old_spd = me->p_speed; | |
570 old_cur_spd = cur_max; | |
571 } | |
572 if (fr || me->p_shield != old_shl) { | |
573 value = (100 * me->p_shield) / me->p_ship->s_maxshield; | |
574 if (value <= 16) | |
575 color = W_Red; | |
576 else if (value <= 66) | |
577 color = W_Yellow; | |
578 else | |
579 color = W_Green; | |
580 db_bar("Sh", column[1], 3 + W_Textheight + SPACING, | |
581 me->p_shield, me->p_ship->s_maxshield, me->p_ship->s_maxshield, | |
582 DB_3DIGITS, color); | |
583 old_shl = me->p_shield; | |
584 } | |
585 if (fr || me->p_damage != old_dam) { | |
586 value = (100 * (me->p_ship->s_maxdamage - me->p_damage)) / me->p_ship->s_maxdamage; | |
587 if (value <= 16) | |
588 color = W_Red; | |
589 else if (value <= 66) | |
590 color = W_Yellow; | |
591 else | |
592 color = W_Green; | |
593 db_bar("Hu", column[1], 3 + 2 * (W_Textheight + SPACING), | |
594 (me->p_ship->s_maxdamage - me->p_damage), | |
595 me->p_ship->s_maxdamage, me->p_ship->s_maxdamage, | |
596 DB_3DIGITS, color); | |
597 old_dam = me->p_damage; | |
598 } | |
599 if (me->p_ship->s_type == ASSAULT) | |
600 cur_max = (((me->p_kills * 3) > me->p_ship->s_maxarmies) ? | |
601 me->p_ship->s_maxarmies : (int) (me->p_kills * 3)); | |
602 else if (me->p_ship->s_type == STARBASE) | |
603 cur_max = me->p_ship->s_maxarmies; | |
604 else | |
605 cur_max = (((me->p_kills * 2) > me->p_ship->s_maxarmies) ? | |
606 me->p_ship->s_maxarmies : (int) (me->p_kills * 2)); | |
607 | |
608 if (fr || me->p_armies != old_arm || cur_max != old_cur_arm) { | |
609 value = me->p_armies; | |
610 mid = me->p_ship->s_maxarmies / 3; | |
611 if (value <= mid) | |
612 color = W_Green; | |
613 else if (value > mid * 2) | |
614 color = W_Red; | |
615 else | |
616 color = W_Yellow; | |
617 db_bar("Ar", column[2], 3, | |
618 me->p_armies, cur_max, me->p_ship->s_maxarmies, DB_3DIGITS, color); | |
619 old_arm = me->p_armies; | |
620 old_cur_arm = cur_max; | |
621 } | |
622 if (fr || me->p_wtemp != old_wpn) { | |
623 value = (100 * me->p_wtemp) / me->p_ship->s_maxwpntemp; | |
624 if (value <= 16) | |
625 color = W_Green; | |
626 else if (value <= 66) | |
627 color = W_Yellow; | |
628 else | |
629 color = W_Red; | |
630 db_bar("Wt", column[2], 3 + W_Textheight + SPACING, | |
631 me->p_wtemp / 10, me->p_ship->s_maxwpntemp / 10, me->p_ship->s_maxwpntemp / 10, DB_3DIGITS | |
632 ,color); | |
633 old_wpn = me->p_wtemp; | |
634 } | |
635 if (fr || me->p_etemp != old_egn) { | |
636 value = (100 * me->p_etemp) / me->p_ship->s_maxegntemp; | |
637 if (value <= 16) | |
638 color = W_Green; | |
639 else if (value <= 66) | |
640 color = W_Yellow; | |
641 else | |
642 color = W_Red; | |
643 db_bar("Et", column[2], 3 + 2 * (W_Textheight + SPACING), | |
644 me->p_etemp / 10, me->p_ship->s_maxegntemp / 10, me->p_ship->s_maxegntemp / 10, DB_3DIGITS | |
645 ,color); | |
646 old_egn = me->p_etemp; | |
647 } | |
648 if (fr || me->p_fuel != old_ful) { | |
649 value = ((100 * me->p_fuel) / me->p_ship->s_maxfuel); | |
650 if (value <= 16) | |
651 color = W_Red; | |
652 else if (value <= 66) | |
653 color = W_Yellow; | |
654 else | |
655 color = W_Green; | |
656 db_bar("Fu", column[3], 3, | |
657 me->p_fuel, me->p_ship->s_maxfuel, me->p_ship->s_maxfuel, DB_5DIGITS, color); | |
658 old_ful = me->p_fuel; | |
659 } | |
660 } | |
661 | |
662 | |
663 void | |
664 db_redraw_BRM(fr) | |
665 int fr; | |
666 { | |
667 static int old_spd = -1, old_cur_spd = -1; | |
668 static int old_shl = -1, old_dam = -1; | |
669 static int old_arm = -1, old_cur_arm = -1; | |
670 static int old_wpn = -1, old_egn = -1; | |
671 static int old_ful = -1; | |
672 register int cur_max; | |
673 register int value; | |
674 int color; | |
675 int index = 0; | |
676 register int mid; | |
677 register int tmp; | |
678 | |
679 if (me->p_ship->s_type == STARBASE) /* SB */ | |
680 index = 1; | |
681 | |
682 if (fr) | |
683 W_ClearWindow(tstatw); | |
684 | |
685 db_flags(fr); | |
686 | |
687 #ifdef TIMER | |
688 db_timer(fr, 1, 3 + 2 * (W_Textheight + SPACING)); | |
689 #endif /* TIMER */ | |
690 #ifdef PACKET_LIGHTS | |
691 light_erase(); | |
692 #endif /* PACKET_LIGHTS */ | |
693 | |
694 cur_max = (me->p_ship->s_maxspeed + 1) - ((me->p_ship->s_maxspeed + 1) * me->p_damage) | |
695 / me->p_ship->s_maxdamage; | |
696 if (cur_max > me->p_ship->s_maxspeed) | |
697 cur_max = me->p_ship->s_maxspeed; | |
698 if (cur_max < 0) | |
699 cur_max = 0; | |
700 | |
701 if (fr || me->p_speed != old_spd || cur_max != old_cur_spd) { | |
702 if (Dashboard == 3) { | |
703 db_color_bar("Sp", column[1], 3, me->p_speed, me->p_speed, cur_max, | |
704 me->p_ship->s_maxspeed, DB_3DIGITS); | |
705 } else { | |
706 if (me->p_speed >= me->p_ship->s_maxspeed - 2) | |
707 color = W_Yellow; | |
708 else | |
709 color = W_White; | |
710 db_bar("Sp", column[1], 3, | |
711 me->p_speed, cur_max, me->p_ship->s_maxspeed, DB_3DIGITS, color); | |
712 } | |
713 old_spd = me->p_speed; | |
714 old_cur_spd = cur_max; | |
715 } | |
716 if (fr || me->p_shield != old_shl) { | |
717 if (Dashboard == 3) { | |
718 tmp = me->p_ship->s_maxshield - me->p_shield; | |
719 db_color_bar("Sh", column[1], 3 + W_Textheight + SPACING, tmp, tmp, | |
720 me->p_ship->s_maxshield, me->p_ship->s_maxshield, | |
721 DB_3DIGITS); | |
722 } else { | |
723 value = (100 * me->p_shield) / me->p_ship->s_maxshield; | |
724 /* | |
725 mid = (distress[index].max_shld - distress[index].min_shld) / | |
726 2; | |
727 */ | |
728 mid = 33; | |
729 if (value <= mid) | |
730 color = W_Red; | |
731 /* else if (value < distress[index].max_shld) */ | |
732 else if (value < mid * 2) | |
733 color = W_Yellow; | |
734 else | |
735 color = W_White; | |
736 db_bar("Sh", column[1], 3 + W_Textheight + SPACING, me->p_ship->s_maxshield - me->p_shield, | |
737 me->p_ship->s_maxshield, me->p_ship->s_maxshield, DB_3DIGITS, color); | |
738 } | |
739 old_shl = me->p_shield; | |
740 } | |
741 if (fr || me->p_damage != old_dam) { | |
742 if (Dashboard == 3) { | |
743 db_color_bar("Hu", column[1], 3 + 2 * (W_Textheight + SPACING), | |
744 me->p_damage, me->p_damage, me->p_ship->s_maxdamage, | |
745 me->p_ship->s_maxdamage, DB_3DIGITS); | |
746 } else { | |
747 value = (100 * me->p_damage) / me->p_ship->s_maxdamage; | |
748 /* mid = (distress[index].max_dam - distress[index].min_dam) / 2; */ | |
749 mid = 33; | |
750 /* if (value <= distress[index].min_dam) */ | |
751 if (value <= mid) | |
752 color = W_White; | |
753 else if (value > mid * 2) | |
754 color = W_Red; | |
755 else | |
756 color = W_Yellow; | |
757 db_bar("Hu", column[1], 3 + 2 * (W_Textheight + SPACING), | |
758 me->p_damage, me->p_ship->s_maxdamage, me->p_ship->s_maxdamage, DB_3DIGITS, color); | |
759 } | |
760 old_dam = me->p_damage; | |
761 } | |
762 if (me->p_ship->s_type == ASSAULT) | |
763 cur_max = (((me->p_kills * 3) > me->p_ship->s_maxarmies) ? | |
764 me->p_ship->s_maxarmies : (int) (me->p_kills * 3)); | |
765 else if (me->p_ship->s_type == STARBASE) | |
766 cur_max = me->p_ship->s_maxarmies; | |
767 else | |
768 cur_max = (((me->p_kills * 2) > me->p_ship->s_maxarmies) ? | |
769 me->p_ship->s_maxarmies : (int) (me->p_kills * 2)); | |
770 | |
771 /* doing rainbow colors for armies makes little since, so I don't */ | |
772 if (fr || me->p_armies != old_arm || cur_max != old_cur_arm) { | |
773 if (Dashboard == 3) { | |
774 db_bar("Ar", column[2], 3, | |
775 me->p_armies, cur_max, me->p_ship->s_maxarmies, DB_3DIGITS, W_White); | |
776 } else { | |
777 value = me->p_armies; | |
778 /* | |
779 mid = (distress[index].max_arms - distress[index].min_arms) / | |
780 2; | |
781 */ | |
782 mid = me->p_ship->s_maxarmies / 3; | |
783 /* if (value <= distress[index].min_arms) */ | |
784 if (value <= mid) | |
785 color = W_White; | |
786 else if (value > mid * 2) | |
787 color = W_Red; | |
788 else | |
789 color = W_Yellow; | |
790 db_bar("Ar", column[2], 3, | |
791 me->p_armies, cur_max, me->p_ship->s_maxarmies, DB_3DIGITS, color); | |
792 } | |
793 old_arm = me->p_armies; | |
794 old_cur_arm = cur_max; | |
795 } | |
796 if (fr || me->p_wtemp != old_wpn) { | |
797 if (Dashboard == 3) { | |
798 tmp = me->p_wtemp / 10; | |
799 db_color_bar("Wt", column[2], 3 + W_Textheight + SPACING, tmp, tmp, | |
800 me->p_ship->s_maxwpntemp / 10, | |
801 me->p_ship->s_maxwpntemp / 10, DB_3DIGITS); | |
802 } else { | |
803 value = (100 * me->p_wtemp) / me->p_ship->s_maxwpntemp; | |
804 /* | |
805 mid = (distress[index].max_wtmp - distress[index].min_wtmp) / | |
806 2; | |
807 */ | |
808 mid = 67; | |
809 if (value > mid) | |
810 color = W_Red; | |
811 /* else if (value <= distress[index].min_wtmp) */ | |
812 else if (value <= mid / 2) | |
813 color = W_White; | |
814 else | |
815 color = W_Yellow; | |
816 db_bar("Wt", column[2], 3 + W_Textheight + SPACING, me->p_wtemp / 10, me->p_ship->s_maxwpntemp / 10, | |
817 me->p_ship->s_maxwpntemp / 10, DB_3DIGITS, color); | |
818 } | |
819 old_wpn = me->p_wtemp; | |
820 } | |
821 if (fr || me->p_etemp != old_egn) { | |
822 if (Dashboard == 3) { | |
823 tmp = me->p_etemp / 10; | |
824 db_color_bar("Et", column[2], 3 + 2 * (W_Textheight + SPACING), tmp, tmp, | |
825 me->p_ship->s_maxegntemp / 10, | |
826 me->p_ship->s_maxegntemp / 10, DB_3DIGITS); | |
827 } else { | |
828 value = (100 * me->p_etemp) / me->p_ship->s_maxegntemp; | |
829 /* | |
830 mid = (distress[index].max_etmp - distress[index].min_etmp) / | |
831 2; | |
832 */ | |
833 mid = 67; | |
834 if (value <= mid / 2) | |
835 color = W_White; | |
836 /* else if (value < mid / 2 + mid) */ | |
837 else if (value < mid) | |
838 color = W_Yellow; | |
839 else | |
840 color = W_Red; | |
841 db_bar("Et", column[2], 3 + 2 * (W_Textheight + SPACING), me->p_etemp / 10, me->p_ship->s_maxegntemp / 10, | |
842 me->p_ship->s_maxegntemp / 10, DB_3DIGITS, color); | |
843 } | |
844 old_egn = me->p_etemp; | |
845 } | |
846 if (fr || me->p_fuel != old_ful) { | |
847 if (Dashboard == 3) { | |
848 db_color_bar("Fu", column[3], 3, me->p_ship->s_maxfuel - me->p_fuel, | |
849 me->p_fuel, me->p_ship->s_maxfuel, me->p_ship->s_maxfuel, | |
850 DB_5DIGITS); | |
851 } else { | |
852 value = ((100 * me->p_fuel) / me->p_ship->s_maxfuel); | |
853 /* | |
854 mid = (distress[index].max_fuel - distress[index].min_fuel) / | |
855 2; | |
856 */ | |
857 mid = 33; | |
858 if (value <= mid) | |
859 color = W_Red; | |
860 /* else if (value > distress[index].max_fuel) */ | |
861 else if (value > mid * 2) | |
862 color = W_White; | |
863 else | |
864 color = W_Yellow; | |
865 db_bar("Fu", column[3], 3, | |
866 me->p_fuel, me->p_ship->s_maxfuel, me->p_ship->s_maxfuel, DB_5DIGITS, color); | |
867 } | |
868 old_ful = me->p_fuel; | |
869 } | |
870 } | |
871 | |
872 void | |
873 db_redraw(fr) | |
874 int fr; | |
875 { | |
876 static int oldDashboard = -1; | |
877 | |
878 if (oldDashboard < 0) { /* 1st time only? */ | |
879 BAR_LENGTH = ((W_WindowWidth(tstatw) - 90 - 4 * W_Textwidth) / 3) - W_Textwidth * 12; | |
880 BAR_LENGTH_THIRD = BAR_LENGTH / 3; | |
881 column[0] = 2; /* not used */ | |
882 column[1] = 90; | |
883 column[2] = 90 + 11 * W_Textwidth + BAR_LENGTH + 6; | |
884 column[3] = column[2] + 11 * W_Textwidth + BAR_LENGTH + 6; | |
885 } | |
886 if (Dashboard != oldDashboard) { | |
887 oldDashboard = Dashboard; | |
888 fr = 1; | |
889 } | |
890 if (Dashboard == 2) | |
891 db_redraw_krp(fr); | |
892 else | |
893 db_redraw_BRM(fr); | |
894 } | |
895 | |
896 void | |
897 stline(flag) | |
898 int flag; | |
899 { | |
900 static char buf1[80]; | |
901 static char buf2[80]; | |
902 static char whichbuf = 0; | |
903 static int lastDashboard; | |
904 | |
905 register char *buf, *oldbuf; | |
906 register char *s; | |
907 register int i, j; | |
908 int k; | |
909 | |
910 /* if you don't do something like this, then switching in the options menu | |
911 is 'entertaining' */ | |
912 if (Dashboard != lastDashboard) { | |
913 lastDashboard = Dashboard; | |
914 redrawTstats(); | |
915 return; | |
916 } | |
917 /* use the new dashboard if we can */ | |
918 if (Dashboard) { | |
919 db_redraw(flag); | |
920 return; | |
921 } | |
922 #ifdef TIMER | |
923 /* Do da clock */ | |
924 db_timer(flag, W_WindowWidth(tstatw) - (12 * W_Textwidth + 5), 27); | |
925 #endif /* TIMER */ | |
926 #ifdef PACKET_LIGHTS | |
927 light_erase(); | |
928 #endif /* PACKET_LIGHTS */ | |
929 | |
930 | |
931 /* Instead of one sprintf, we do all this by hand for optimization */ | |
932 | |
933 if (flag) | |
934 whichbuf = 0; /* We must completely refresh */ | |
935 | |
936 if (whichbuf != 2) { | |
937 buf = buf1; | |
938 oldbuf = buf2; | |
939 } else { | |
940 buf = buf2; | |
941 oldbuf = buf1; | |
942 } | |
943 buf[0] = (me->p_flags & PFSHIELD ? 'S' : ' '); | |
944 if (me->p_flags & PFGREEN) | |
945 buf[1] = 'G'; | |
946 else if (me->p_flags & PFYELLOW) | |
947 buf[1] = 'Y'; | |
948 else if (me->p_flags & PFRED) | |
949 buf[1] = 'R'; | |
950 buf[2] = (me->p_flags & (PFPLLOCK | PFPLOCK) ? 'L' : ' '); | |
951 buf[3] = (me->p_flags & PFREPAIR ? 'R' : ' '); | |
952 buf[4] = (me->p_flags & PFBOMB ? 'B' : ' '); | |
953 buf[5] = (me->p_flags & PFORBIT ? 'O' : ' '); | |
954 buf[6] = (me->p_flags & PFDOCKOK ? 'D' : ' '); | |
955 /* buf[6] = (me->p_flags & PFDOCK ? 'D' : ' ');*/ | |
956 buf[7] = (me->p_flags & PFCLOAK ? 'C' : ' '); | |
957 buf[8] = (me->p_flags & PFWEP ? 'W' : ' '); | |
958 buf[9] = (me->p_flags & PFENG ? 'E' : ' '); | |
959 if (me->p_flags & PFPRESS) | |
960 buf[10] = 'P'; | |
961 else if (me->p_flags & PFTRACT) | |
962 buf[10] = 'T'; | |
963 else | |
964 buf[10] = ' '; | |
965 if (me->p_flags & PFBEAMUP) | |
966 buf[11] = 'u'; | |
967 else if (me->p_flags & PFBEAMDOWN) | |
968 buf[11] = 'd'; | |
969 else | |
970 buf[11] = ' '; | |
971 if (!paradise) | |
972 buf[12] = (status->tourn) ? 't' : ' '; | |
973 else | |
974 buf[12] = (status2->tourn) ? 't' : ' '; | |
975 | |
976 buf[13] = ' '; | |
977 | |
978 #if 1 | |
979 /* w/i indicator is a kludge - it just guesses based on the speed of | |
980 the ship */ | |
981 sprintf(buf + 14, "%2d%c %3d %3d %1d %6.2f %3d %6d %4d %4d ", | |
982 me->p_speed, /* (me->p_speed > me->p_ship->s_maxspeed+2) */ | |
983 me->p_flags & PFWARP ? 'w' : me->p_flags & PFAFTER ? 'a' : 'i', | |
984 me->p_damage, me->p_shield, me->p_ntorp, me->p_kills, | |
985 me->p_armies, me->p_fuel, me->p_wtemp / 10, me->p_etemp / 10); | |
986 #else | |
987 #if 0 | |
988 TWODIGIT_L(&buf[14], me->p_speed); | |
989 buf[16] = 'i'; | |
990 buf[17] = ' '; | |
991 buf[18] = ' '; | |
992 buf[19] = ' '; | |
993 THREEDIGIT_R(&buf[20], me->p_damage); | |
994 buf[23] = ' '; | |
995 THREEDIGIT_R(&buf[24], me->p_shield); | |
996 buf[27] = ' '; | |
997 TWODIGIT_R(&buf[28], me->p_ntorp); | |
998 buf[30] = ' '; | |
999 buf[31] = ' '; | |
1000 SIXnTWOf_R(&buf[32], me->p_kills); | |
1001 buf[38] = ' '; | |
1002 THREEDIGIT_C(&buf[39], me->p_armies); | |
1003 buf[42] = ' '; | |
1004 SIXDIGIT_R(&buf[43], me->p_fuel); | |
1005 buf[49] = ' '; | |
1006 buf[50] = ' '; | |
1007 FOURDIGIT_R(&buf[51], me->p_wtemp); | |
1008 buf[55] = ' '; | |
1009 FOURDIGIT_R(&buf[56], me->p_wtemp); | |
1010 buf[60] = ' '; | |
1011 buf[61] = ' '; | |
1012 #else /* 0 */ | |
1013 buf[14] = '0' + ((me->p_speed % 100) / 10); | |
1014 if (buf[14] == '0') | |
1015 buf[14] = ' '; | |
1016 buf[15] = '0' + (me->p_speed % 10); /* speed */ | |
1017 buf[16] = ' '; | |
1018 buf[17] = ' '; | |
1019 buf[18] = '0' + (me->p_damage / 100); | |
1020 if (buf[18] == '0') | |
1021 buf[18] = ' '; | |
1022 buf[19] = '0' + ((me->p_damage % 100) / 10); | |
1023 if ((buf[19] == '0') && (me->p_damage < 100)) | |
1024 buf[19] = ' '; | |
1025 buf[20] = '0' + (me->p_damage % 10); | |
1026 buf[21] = ' '; | |
1027 buf[22] = '0' + (me->p_shield / 100); | |
1028 if (buf[22] == '0') | |
1029 buf[22] = ' '; | |
1030 buf[23] = '0' + ((me->p_shield % 100) / 10); | |
1031 if ((buf[23] == '0') && (me->p_shield < 100)) | |
1032 buf[23] = ' '; | |
1033 buf[24] = '0' + (me->p_shield % 10); | |
1034 buf[25] = ' '; | |
1035 buf[26] = ' '; | |
1036 buf[27] = '0' + ((me->p_ntorp % 100) / 10); | |
1037 if (buf[27] == '0') | |
1038 buf[27] = ' '; | |
1039 buf[28] = '0' + (me->p_ntorp % 10); | |
1040 buf[29] = ' '; | |
1041 buf[30] = ' '; | |
1042 buf[31] = ' '; | |
1043 buf[32] = ' '; | |
1044 buf[33] = '0' + ((int) (me->p_kills / 10)); | |
1045 if (buf[33] == '0') | |
1046 buf[33] = ' '; | |
1047 buf[34] = '0' + (((int) me->p_kills) % 10); | |
1048 buf[35] = '.'; | |
1049 buf[36] = '0' + (((int) (me->p_kills * 10)) % 10); | |
1050 buf[37] = '0' + (((int) (me->p_kills * 100)) % 10); | |
1051 buf[38] = ' '; | |
1052 buf[39] = ' '; | |
1053 buf[40] = ' '; | |
1054 buf[41] = '0' + ((me->p_armies % 100) / 10); | |
1055 if (buf[41] == '0') | |
1056 buf[41] = ' '; | |
1057 buf[42] = '0' + (me->p_armies % 10); | |
1058 buf[43] = ' '; | |
1059 buf[44] = ' '; | |
1060 buf[45] = ' '; | |
1061 | |
1062 buf[46] = '0' + (me->p_fuel / 100000); | |
1063 if (buf[46] == '0') | |
1064 buf[46] = ' '; | |
1065 buf[47] = '0' + ((me->p_fuel % 100000) / 10000); | |
1066 if ((buf[47] == '0') && (me->p_fuel < 100000)) | |
1067 buf[47] = ' '; | |
1068 buf[48] = '0' + ((me->p_fuel % 10000) / 1000); | |
1069 if ((buf[48] == '0') && (me->p_fuel < 10000)) | |
1070 buf[48] = ' '; | |
1071 buf[49] = '0' + ((me->p_fuel % 1000) / 100); | |
1072 if ((buf[49] == '0') && (me->p_fuel < 1000)) | |
1073 buf[49] = ' '; | |
1074 buf[50] = '0' + ((me->p_fuel % 100) / 10); | |
1075 if ((buf[50] == '0') && (me->p_fuel < 100)) | |
1076 buf[50] = ' '; | |
1077 buf[51] = '0' + (me->p_fuel % 10); | |
1078 buf[52] = ' '; | |
1079 buf[53] = ' '; | |
1080 buf[54] = ' '; | |
1081 | |
1082 buf[55] = '0' + ((me->p_wtemp / 10) / 100); | |
1083 if (buf[55] == '0') | |
1084 buf[55] = ' '; | |
1085 buf[56] = '0' + (((me->p_wtemp / 10) % 100) / 10); | |
1086 if ((buf[56] == '0') && (me->p_wtemp < 1000)) | |
1087 buf[56] = ' '; | |
1088 buf[57] = '0' + ((me->p_wtemp / 10) % 10); | |
1089 | |
1090 buf[58] = ' '; | |
1091 buf[59] = ' '; | |
1092 buf[60] = ' '; | |
1093 buf[61] = '0' + ((me->p_etemp / 10) / 1000); | |
1094 if (buf[61] == '0') | |
1095 buf[61] = ' '; | |
1096 buf[62] = '0' + (((me->p_etemp / 10) % 1000) / 100); | |
1097 if (buf[62] == '0' && me->p_etemp < 1000) | |
1098 buf[62] = ' '; | |
1099 buf[63] = '0' + (((me->p_etemp / 10) % 100) / 10); | |
1100 if ((buf[63] == '0') && (me->p_etemp < 1000)) | |
1101 buf[63] = ' '; | |
1102 buf[64] = '0' + ((me->p_etemp / 10) % 10); | |
1103 buf[65] = ' '; | |
1104 #endif /* 0 */ | |
1105 #endif | |
1106 | |
1107 if (whichbuf == 0) { | |
1108 /* Draw status line */ | |
1109 W_WriteText(tstatw, TSTATW_BASEX, 16, textColor, buf, 66, W_RegularFont); | |
1110 whichbuf = 1; | |
1111 } else { /* Hacks to make it print only what is | |
1112 necessary */ | |
1113 whichbuf = 3 - whichbuf; | |
1114 j = -1; | |
1115 for (i = 0; i < 66; i++) { | |
1116 if (*(buf++) != *(oldbuf++)) { | |
1117 /* Different string */ | |
1118 if (j == -1) { | |
1119 k = i; | |
1120 s = buf - 1; | |
1121 } | |
1122 j = 0; | |
1123 } else { | |
1124 /* Same string */ | |
1125 if (j == -1) | |
1126 continue; | |
1127 j++; | |
1128 if (j == 20) { /* Random number */ | |
1129 W_WriteText(tstatw, TSTATW_BASEX + W_Textwidth * k, 16, textColor, | |
1130 s, i - k - 19, W_RegularFont); | |
1131 j = -1; | |
1132 } | |
1133 } | |
1134 } | |
1135 if (j != -1) { | |
1136 W_WriteText(tstatw, TSTATW_BASEX + W_Textwidth * k, 16, textColor, s, i - k - j, | |
1137 W_RegularFont); | |
1138 } | |
1139 } | |
1140 } | |
1141 | |
1142 void | |
1143 redrawTstats() | |
1144 { | |
1145 char buf[100]; | |
1146 | |
1147 W_ClearWindow(tstatw); | |
1148 /* use new dashboard if possible */ | |
1149 if (Dashboard) { | |
1150 db_redraw(1); | |
1151 return; | |
1152 } | |
1153 stline(1); /* This is for refresh. We redraw player | |
1154 stats too */ | |
1155 strcpy(buf, "Flags Speed Dam Shd Trp Kills Ams Fuel Wtmp Etmp Special" /* "Flags Warp | |
1156 Dam Shd Torps Kills | |
1157 Armies Fuel Wtemp | |
1158 Etemp" */ ); | |
1159 W_WriteText(tstatw, TSTATW_BASEX, 5, textColor, buf, strlen(buf), W_RegularFont); | |
1160 sprintf(buf, | |
1161 "Maximum: %2d %3d %3d 8 %3d %6d %4d %4d ", | |
1162 me->p_ship->s_maxspeed, me->p_ship->s_maxdamage, | |
1163 me->p_ship->s_maxshield, me->p_ship->s_maxarmies, | |
1164 me->p_ship->s_maxfuel, me->p_ship->s_maxwpntemp / 10, | |
1165 me->p_ship->s_maxegntemp / 10); | |
1166 W_WriteText(tstatw, TSTATW_BASEX, 27, textColor, buf, strlen(buf), W_RegularFont); | |
1167 } |