Mercurial > ~darius > hgwebdir.cgi > paradise_client
comparison newwin.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 /* $Id: newwin.c,v 1.1.1.1 1997/12/06 05:41:29 darius Exp $ */ | |
2 | |
3 /* | |
4 * newwin.c | |
5 */ | |
6 #include "copyright.h" | |
7 | |
8 #include <stdio.h> | |
9 #ifdef __STDC__ | |
10 #include <stdlib.h> | |
11 #endif | |
12 #include <math.h> | |
13 #include <signal.h> | |
14 #include <sys/types.h> | |
15 #include <string.h> | |
16 #ifdef hpux | |
17 #include <time.h> | |
18 #else /* hpux */ | |
19 #include <sys/time.h> | |
20 #endif /* hpux */ | |
21 #ifdef RS6K | |
22 #include <sys/select.h> | |
23 #endif | |
24 #include "Wlib.h" | |
25 #include "defs.h" | |
26 #include "struct.h" | |
27 #include "data.h" | |
28 #include "gameconf.h" | |
29 | |
30 | |
31 | |
32 #include "oldbitmaps.h" | |
33 #include "bitmaps_pr.h" | |
34 #include "bitmaps3.h" | |
35 #include "hullbitmaps.h" | |
36 #include "planetbitmaps.h" | |
37 #include "rabbitbitmaps.h" | |
38 #include "starbitmaps.h" | |
39 | |
40 #ifdef BEEPLITE | |
41 #include "emph_planet_seq.h" | |
42 #include "emph_player_seq.h" | |
43 #include "emph_player_seql.h" | |
44 #endif | |
45 | |
46 #include "packets.h" | |
47 #include "proto.h" | |
48 | |
49 #define NRHEADERS 4 | |
50 W_Icon headerA, headerB, headerchanges[NRHEADERS]; | |
51 W_Icon safepic; | |
52 /* elapsed time in outfit window [BDyess] */ | |
53 int elapsed; | |
54 | |
55 int newMotdStuff = 0; /* set to 1 when new motd packets arrive */ | |
56 static struct piclist *motdPics = NULL; | |
57 /*static struct page *currpage = NULL; | |
58 static struct page *motddata = NULL;*/ | |
59 | |
60 #define LINESPERPAGE 38 | |
61 | |
62 #define BOXSIDE (WINSIDE / 5) | |
63 #define TILESIDE 16 | |
64 #define MESSAGESIZE 20 | |
65 #define STATSIZE (MESSAGESIZE * 2 + BORDER) | |
66 #define YOFF 0 | |
67 | |
68 #define stipple_width 16 | |
69 #define stipple_height 16 | |
70 static unsigned char stipple_bits[] = { | |
71 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, | |
72 0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, | |
73 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, | |
74 0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80}; | |
75 | |
76 /* ATM: extra stuff for those who don't like my visible tractors */ | |
77 #define tract_width 5 | |
78 #define tract_height 5 | |
79 static char tract_bits[] = { | |
80 0x1f, 0x04, 0x04, 0x04, 0x04}; | |
81 #define press_width 5 | |
82 #define press_height 5 | |
83 static char press_bits[] = { | |
84 0x0f, 0x11, 0x0f, 0x01, 0x01}; | |
85 | |
86 /* Prototypes */ | |
87 static void savebitmaps P((void)); | |
88 static int teamRequest P((int team, int ship)); | |
89 static int numShips P((int owner)); | |
90 static int checkBold P((char *line)); | |
91 void showMotd P((W_Window win)); | |
92 static void showPics P((W_Window win)); | |
93 void showValues P((W_Window win)); | |
94 static void getResources P((char *prog)); | |
95 static void getTiles P((void)); | |
96 static void redrawTeam P((W_Window win, int teamNo, int *lastnum)); | |
97 static void redrawQuit P((void)); | |
98 static void showTimeLeft P((int time, int max)); | |
99 | |
100 /* from dashboard.c: */ | |
101 void light_erase P((void)); | |
102 | |
103 extern int helpmessages; | |
104 | |
105 void | |
106 newwin(hostmon, progname) | |
107 char *hostmon, *progname; | |
108 { | |
109 int i; | |
110 | |
111 /* W_Initialize(hostmon); */ | |
112 | |
113 baseWin = W_MakeWindow("netrek", 0, YOFF, WINSIDE * 2 + 1 * BORDER, | |
114 WINSIDE + 2 * BORDER + 2 * MESSAGESIZE, NULL, "bomb here", BORDER, gColor); | |
115 iconWin = W_MakeWindow("netrek_icon", 0, 0, icon_width, icon_height, NULL, | |
116 (char *) 0, BORDER, gColor); | |
117 W_SetIconWindow(baseWin, iconWin); | |
118 w = W_MakeWindow("local", -BORDER, -BORDER, WINSIDE, WINSIDE, baseWin, | |
119 (char *) 0, BORDER, foreColor); | |
120 mapw = W_MakeWindow("map", WINSIDE, -BORDER, WINSIDE, WINSIDE, baseWin, | |
121 (char *) 0, BORDER, foreColor); | |
122 tstatw = W_MakeWindow("tstat", -BORDER, WINSIDE, WINSIDE, STATSIZE, baseWin, | |
123 "xterm", BORDER, foreColor); | |
124 warnw = W_MakeWindow("warn", WINSIDE, WINSIDE, WINSIDE, MESSAGESIZE, | |
125 baseWin, "xterm", BORDER, foreColor); | |
126 messagew = W_MakeWindow("message", WINSIDE, WINSIDE + BORDER + MESSAGESIZE, | |
127 WINSIDE, MESSAGESIZE, baseWin, "xterm", BORDER, foreColor); | |
128 planetw = W_MakeTextWindow("planet", 10, 10, 75, (nplanets + 13) / 2, w, (char *) 0, 2); | |
129 planetw2 = W_MakeTextWindow("planet2", 10, 10, 75, (nplanets + 13) / 2, mapw, (char *) 0, 2); | |
130 rankw = W_MakeTextWindow("rank", 50, 100, 65, nranks2 + 8, w, (char *) 0, 2); | |
131 playerw = W_MakeTextWindow("player", 0, YOFF + WINSIDE + 2 * BORDER + 2 * MESSAGESIZE, | |
132 83, (nplayers + 14) / 2, NULL, (char *) 0, 2); | |
133 helpWin = W_MakeTextWindow("help", 0, YOFF + WINSIDE + 2 * BORDER + 2 * MESSAGESIZE, | |
134 160, helpmessages / 4 + 1, NULL, (char *) 0, BORDER); | |
135 #ifdef METASERVER | |
136 /* | |
137 metaWin = W_MakeMenu ("MetaServer List", WINSIDE+10, -BORDER+10, 69, | |
138 num_servers + 2, NULL, 2); | |
139 */ | |
140 #endif /* METASERVER */ | |
141 #if 0 | |
142 W_SetWindowKeyDownHandler(metaWin, metaaction); | |
143 W_SetWindowButtonHandler(metaWin, metaaction); | |
144 #endif /* 0 */ | |
145 | |
146 initMessageWindows(); | |
147 | |
148 pStats = W_MakeWindow("Network Statistics", 500, 4, pStatsWidth(), pStatsHeight(), | |
149 NULL, (char *) 0, 1, foreColor); | |
150 udpWin = W_MakeMenu("UDP", WINSIDE + 10, -BORDER + 10, 40, UDP_NUMOPTS, | |
151 NULL, 2); | |
152 | |
153 #ifdef SHORT_PACKETS | |
154 spWin = W_MakeMenu("network", WINSIDE + 10, -BORDER + 10, 40, SPK_NUMFIELDS, | |
155 NULL, 2); | |
156 #endif | |
157 | |
158 #ifdef TOOLS | |
159 toolsWin = W_MakeScrollingWindow("tools", WINSIDE + BORDER, BORDER, | |
160 80, TOOLSWINLEN, NULL, "xterm", BORDER); | |
161 #endif | |
162 | |
163 motdWin = W_MakeWindow("Motd" | |
164 ,-BORDER, -BORDER, WINSIDE, WINSIDE, NULL, | |
165 (char *) 0, BORDER, foreColor); | |
166 | |
167 for (i = 0; i < 4; i++) { | |
168 teamWin[i] = W_MakeWindow(teaminfo[i].shortname, i * BOXSIDE, 0, | |
169 BOXSIDE, BOXSIDE, mapw, (char *) 0, 1, foreColor); | |
170 } | |
171 qwin = W_MakeWindow("quit", 4 * BOXSIDE, 0, BOXSIDE, BOXSIDE, mapw, | |
172 "pirate", 1, foreColor); | |
173 | |
174 /* statwin = W_MakeWindow("stats", 422, 13, 160, 95, NULL, (char*)0, | |
175 5, foreColor);*/ | |
176 statwin = W_MakeWindow("stats", 422, 13, 160, 80, NULL, | |
177 (char *) 0, 5, foreColor); | |
178 | |
179 #define WARHEIGHT 2 | |
180 #define WARWIDTH 20 | |
181 #define WARBORDER 2 | |
182 | |
183 war = W_MakeMenu("war", WINSIDE + 10, -BORDER + 10, WARWIDTH, 6, baseWin, | |
184 WARBORDER); | |
185 | |
186 | |
187 getResources(progname); | |
188 savebitmaps(); | |
189 } | |
190 | |
191 void | |
192 mapAll() | |
193 { | |
194 initinput(); | |
195 W_MapWindow(mapw); | |
196 W_MapWindow(tstatw); | |
197 W_MapWindow(warnw); | |
198 W_MapWindow(messagew); | |
199 W_MapWindow(w); | |
200 W_MapWindow(baseWin); | |
201 | |
202 /* | |
203 since we aren't mapping windows that have root as parent in | |
204 x11window.c (since that messes up the TransientFor feature) we have to | |
205 map them here. (If already mapped, W_MapWindow returns) | |
206 */ | |
207 | |
208 if (checkMapped("planet")) | |
209 W_MapWindow(planetw); | |
210 if (checkMapped("planet2")) | |
211 W_MapWindow(planetw2); | |
212 if (checkMapped("rank")) | |
213 W_MapWindow(rankw); | |
214 if (checkMapped("help")) | |
215 W_MapWindow(helpWin); | |
216 if (checkMapped("Motd")) | |
217 W_MapWindow(motdWin); | |
218 if (checkMapped("review_all")) | |
219 W_MapWindow(messWin[WALL].window); | |
220 if (checkMapped("review_team")) | |
221 W_MapWindow(messWin[WTEAM].window); | |
222 if (checkMapped("review_your")) | |
223 W_MapWindow(messWin[WINDIV].window); | |
224 if (checkMapped("review_kill")) | |
225 W_MapWindow(messWin[WKILL].window); | |
226 if (checkMapped("review_phaser")) | |
227 W_MapWindow(messWin[WPHASER].window); | |
228 if (booleanDefault("player.mapped", 1)) | |
229 W_MapWindow(playerw); | |
230 if (booleanDefault("review.mapped", 1)) | |
231 W_MapWindow(messWin[WREVIEW].window); | |
232 if (checkMapped("UDP")) | |
233 udpwindow(); | |
234 | |
235 } | |
236 | |
237 static void | |
238 savebitmaps() | |
239 { | |
240 register int i; | |
241 int tw, th, mw, mh; | |
242 | |
243 /* slurp_ship_bitmaps(); */ | |
244 | |
245 clockpic = W_StoreBitmap(clock_width, clock_height, clock_bits, | |
246 qwin); | |
247 safepic = W_StoreBitmap(safe_width, safe_height, safe_bits, | |
248 qwin); | |
249 | |
250 #ifdef BEEPLITE | |
251 for (i = 0; i < emph_player_seq_frames; i++) { | |
252 emph_player_seq[emph_player_seq_frames - (i + 1)] = | |
253 W_StoreBitmap(emph_player_seq_width, emph_player_seq_height, | |
254 emph_player_seq_bits[i], mapw); | |
255 } | |
256 | |
257 for (i = 0; i < emph_player_seql_frames; i++) { | |
258 emph_player_seql[emph_player_seql_frames - (i + 1)] = | |
259 W_StoreBitmap(emph_player_seql_width, emph_player_seql_height, | |
260 emph_player_seql_bits[i], w); | |
261 } | |
262 | |
263 for (i = 0; i < emph_planet_seq_frames; i++) { | |
264 emph_planet_seq[emph_planet_seq_frames - (i + 1)] = | |
265 W_StoreBitmap(emph_planet_seq_width, emph_planet_seq_height, | |
266 emph_planet_seq_bits[i], mapw); | |
267 } | |
268 #endif | |
269 | |
270 load_default_teamlogos(); | |
271 | |
272 headerA = W_StoreBitmap(headerA_width, headerA_height, | |
273 headerA_bits, motdWin); | |
274 headerB = W_StoreBitmap(headerB_width, headerB_height, | |
275 headerB_bits, motdWin); | |
276 headerchanges[0] = W_StoreBitmap(header1_width, header1_height, | |
277 header1_bits, motdWin); | |
278 headerchanges[1] = W_StoreBitmap(header2_width, header2_height, | |
279 header2_bits, motdWin); | |
280 headerchanges[2] = W_StoreBitmap(header3_width, header3_height, | |
281 header3_bits, motdWin); | |
282 headerchanges[3] = W_StoreBitmap(header4_width, header4_height, | |
283 header4_bits, motdWin); | |
284 for (i = 0; i < HULL_FRAMES; i++) | |
285 hull[i] = W_StoreBitmap(hull_width, hull_height, hull_bits[i], w); | |
286 | |
287 for (i = 0; i < 5; i++) { | |
288 cloud[i] = W_StoreBitmap(cloud_width, cloud_height, cloud_bits[4 - i], w); | |
289 plasmacloud[i] = W_StoreBitmap(plasmacloud_width, | |
290 plasmacloud_height, plasmacloud_bits[4 - i], w); | |
291 } | |
292 etorp = W_StoreBitmap(etorp_width, etorp_height, etorp_bits, w); | |
293 mtorp = W_StoreBitmap(mtorp_width, mtorp_height, mtorp_bits, w); | |
294 for (i = 0; i < NDRONEVIEWS; i++) { | |
295 drone_bm[i] = W_StoreBitmap(drone_width, drone_height, drone_bits[i], w); | |
296 } | |
297 eplasmatorp = | |
298 W_StoreBitmap(eplasmatorp_width, eplasmatorp_height, eplasmatorp_bits, w); | |
299 mplasmatorp = | |
300 W_StoreBitmap(mplasmatorp_width, mplasmatorp_height, mplasmatorp_bits, w); | |
301 for (i = 0; i < VIEWS; i++) { | |
302 fighter[i] = | |
303 W_StoreBitmap(fighter_width, fighter_height, fighter_bits[i], w); | |
304 }; | |
305 warpbeacon = W_StoreBitmap(warpbeacon_width, warpbeacon_height, warpbeacon_bits, w); | |
306 wbflash = W_StoreBitmap(warpbeacon_width, warpbeacon_height, warpflash_bits, w); | |
307 | |
308 tw = planet_width; | |
309 th = planet_height; | |
310 mw = mplanet_width; | |
311 mh = mplanet_height; | |
312 | |
313 /* tactical screen planet bitmaps for team */ | |
314 | |
315 bplanets[0] = W_StoreBitmap(tw, th, indplanet_bits, w); | |
316 bplanets[1] = W_StoreBitmap(tw, th, fedplanet_bits, w); | |
317 bplanets[2] = W_StoreBitmap(tw, th, romplanet_bits, w); | |
318 bplanets[3] = W_StoreBitmap(tw, th, kliplanet_bits, w); | |
319 bplanets[4] = W_StoreBitmap(tw, th, oriplanet_bits, w); | |
320 bplanets[5] = W_StoreBitmap(tw, th, planet_bits, w); | |
321 | |
322 /* galactic screen planet bitmaps for team */ | |
323 | |
324 mbplanets[0] = W_StoreBitmap(mw, mh, indmplanet_bits, mapw); | |
325 mbplanets[1] = W_StoreBitmap(mw, mh, fedmplanet_bits, mapw); | |
326 mbplanets[2] = W_StoreBitmap(mw, mh, rommplanet_bits, mapw); | |
327 mbplanets[3] = W_StoreBitmap(mw, mh, klimplanet_bits, mapw); | |
328 mbplanets[4] = W_StoreBitmap(mw, mh, orimplanet_bits, mapw); | |
329 mbplanets[5] = W_StoreBitmap(mw, mh, mplanet_bits, mapw); | |
330 | |
331 | |
332 | |
333 /* tactical screen planet bitmaps for facilities */ | |
334 | |
335 bplanets2[0] = bplanets[0]; | |
336 bplanets2[1] = W_StoreBitmap(tw, th, planet001_bits, w); | |
337 bplanets2[2] = W_StoreBitmap(tw, th, planet010_bits, w); | |
338 bplanets2[3] = W_StoreBitmap(tw, th, planet011_bits, w); | |
339 bplanets2[4] = W_StoreBitmap(tw, th, planet100_bits, w); | |
340 bplanets2[5] = W_StoreBitmap(tw, th, planet101_bits, w); | |
341 bplanets2[6] = W_StoreBitmap(tw, th, planet110_bits, w); | |
342 bplanets2[7] = W_StoreBitmap(tw, th, planet111_bits, w); | |
343 bplanets2[8] = W_StoreBitmap(tw, th, planet1010_bits, w); | |
344 bplanets2[9] = W_StoreBitmap(tw, th, planet1011_bits, w); | |
345 bplanets2[10] = bplanets2[8]; | |
346 bplanets2[11] = bplanets2[9]; | |
347 bplanets2[12] = W_StoreBitmap(tw, th, planet1110_bits, w); | |
348 bplanets2[13] = W_StoreBitmap(tw, th, planet1111_bits, w); | |
349 bplanets2[14] = bplanets2[12]; | |
350 bplanets2[15] = bplanets2[13]; | |
351 | |
352 /* galactic screen planet bitmaps for facilities */ | |
353 | |
354 mbplanets2[0] = mbplanets[0]; | |
355 mbplanets2[1] = W_StoreBitmap(mw, mh, mplanet001_bits, mapw); | |
356 mbplanets2[2] = W_StoreBitmap(mw, mh, mplanet010_bits, mapw); | |
357 mbplanets2[3] = W_StoreBitmap(mw, mh, mplanet011_bits, mapw); | |
358 mbplanets2[4] = W_StoreBitmap(mw, mh, mplanet100_bits, mapw); | |
359 mbplanets2[5] = W_StoreBitmap(mw, mh, mplanet101_bits, mapw); | |
360 mbplanets2[6] = W_StoreBitmap(mw, mh, mplanet110_bits, mapw); | |
361 mbplanets2[7] = W_StoreBitmap(mw, mh, mplanet111_bits, mapw); | |
362 mbplanets2[8] = W_StoreBitmap(mw, mh, mplanet1010_bits, mapw); | |
363 mbplanets2[9] = W_StoreBitmap(mw, mh, mplanet1011_bits, mapw); | |
364 mbplanets2[10] = mbplanets2[8]; | |
365 mbplanets2[11] = mbplanets2[9]; | |
366 mbplanets2[12] = W_StoreBitmap(mw, mh, mplanet1110_bits, mapw); | |
367 mbplanets2[13] = W_StoreBitmap(mw, mh, mplanet1111_bits, mapw); | |
368 mbplanets2[14] = mbplanets2[12]; | |
369 mbplanets2[15] = mbplanets2[13]; | |
370 | |
371 /* tactical screen planet bitmaps for surface properties */ | |
372 | |
373 bplanetsr[0] = bplanets[0]; | |
374 bplanetsr[1] = W_StoreBitmap(tw, th, planetr001_bits, w); | |
375 bplanetsr[2] = W_StoreBitmap(tw, th, planetr010_bits, w); | |
376 bplanetsr[3] = W_StoreBitmap(tw, th, planetr011_bits, w); | |
377 bplanetsr[4] = W_StoreBitmap(tw, th, planetr100_bits, w); | |
378 bplanetsr[5] = W_StoreBitmap(tw, th, planetr101_bits, w); | |
379 bplanetsr[6] = W_StoreBitmap(tw, th, planetr110_bits, w); | |
380 bplanetsr[7] = W_StoreBitmap(tw, th, planetr111_bits, w); | |
381 | |
382 /* galactic screen planet bitmaps for surface properties */ | |
383 | |
384 mbplanetsr[0] = mbplanets[0]; | |
385 mbplanetsr[1] = W_StoreBitmap(mw, mh, mplanetr001_bits, mapw); | |
386 mbplanetsr[2] = W_StoreBitmap(mw, mh, mplanetr010_bits, mapw); | |
387 mbplanetsr[3] = W_StoreBitmap(mw, mh, mplanetr011_bits, mapw); | |
388 mbplanetsr[4] = W_StoreBitmap(mw, mh, mplanetr100_bits, mapw); | |
389 mbplanetsr[5] = W_StoreBitmap(mw, mh, mplanetr101_bits, mapw); | |
390 mbplanetsr[6] = W_StoreBitmap(mw, mh, mplanetr110_bits, mapw); | |
391 mbplanetsr[7] = W_StoreBitmap(mw, mh, mplanetr111_bits, mapw); | |
392 | |
393 /* tactical screen bitmaps for facilities, MOO-style */ | |
394 | |
395 bplanetsMOO[0] = W_StoreBitmap(tw, th, rmyplanet000_bits, w); | |
396 bplanetsMOO[1] = W_StoreBitmap(tw, th, rmyplanet001_bits, w); | |
397 bplanetsMOO[2] = W_StoreBitmap(tw, th, rmyplanet010_bits, w); | |
398 bplanetsMOO[3] = W_StoreBitmap(tw, th, rmyplanet011_bits, w); | |
399 bplanetsMOO[4] = W_StoreBitmap(tw, th, rmyplanet100_bits, w); | |
400 bplanetsMOO[5] = W_StoreBitmap(tw, th, rmyplanet101_bits, w); | |
401 bplanetsMOO[6] = W_StoreBitmap(tw, th, rmyplanet110_bits, w); | |
402 bplanetsMOO[7] = W_StoreBitmap(tw, th, rmyplanet111_bits, w); | |
403 bplanetsMOO[8] = W_StoreBitmap(tw, th, rmyplanet1010_bits, w); | |
404 bplanetsMOO[9] = W_StoreBitmap(tw, th, rmyplanet1011_bits, w); | |
405 bplanetsMOO[10] = bplanetsMOO[8]; | |
406 bplanetsMOO[11] = bplanetsMOO[9]; | |
407 bplanetsMOO[12] = W_StoreBitmap(tw, th, rmyplanet1110_bits, w); | |
408 bplanetsMOO[13] = W_StoreBitmap(tw, th, rmyplanet1111_bits, w); | |
409 bplanetsMOO[14] = bplanetsMOO[12]; | |
410 bplanetsMOO[15] = bplanetsMOO[13]; | |
411 | |
412 /* galactic screen bitmaps for facilities, MOO-style */ | |
413 | |
414 mbplanetsMOO[0] = W_StoreBitmap(mw, mh, rmymplanet000_bits, mapw); | |
415 mbplanetsMOO[1] = W_StoreBitmap(mw, mh, rmymplanet001_bits, mapw); | |
416 mbplanetsMOO[2] = W_StoreBitmap(mw, mh, rmymplanet010_bits, mapw); | |
417 mbplanetsMOO[3] = W_StoreBitmap(mw, mh, rmymplanet011_bits, mapw); | |
418 mbplanetsMOO[4] = W_StoreBitmap(mw, mh, mplanet100_bits, mapw); | |
419 mbplanetsMOO[5] = W_StoreBitmap(mw, mh, mplanet101_bits, mapw); | |
420 mbplanetsMOO[6] = W_StoreBitmap(mw, mh, mplanet110_bits, mapw); | |
421 mbplanetsMOO[7] = W_StoreBitmap(mw, mh, mplanet111_bits, mapw); | |
422 mbplanetsMOO[8] = W_StoreBitmap(mw, mh, rmymplanet1010_bits, mapw); | |
423 mbplanetsMOO[9] = W_StoreBitmap(mw, mh, rmymplanet1011_bits, mapw); | |
424 mbplanetsMOO[10] = mbplanetsMOO[8]; | |
425 mbplanetsMOO[11] = mbplanetsMOO[9]; | |
426 mbplanetsMOO[12] = W_StoreBitmap(mw, mh, mplanet1110_bits, mapw); | |
427 mbplanetsMOO[13] = W_StoreBitmap(mw, mh, mplanet1111_bits, mapw); | |
428 mbplanetsMOO[14] = mbplanetsMOO[12]; | |
429 mbplanetsMOO[15] = mbplanetsMOO[13]; | |
430 | |
431 for (i = 0; i < NSCOUTAGES; i++) | |
432 mbplanetsA[i] = W_StoreBitmap(mw, mh, age_bits[i], mapw); | |
433 | |
434 /* star bitmaps */ | |
435 | |
436 for (i = 0; i < STARFRAMES; i++) { | |
437 starBM[i] = W_StoreBitmap(star_width, star_height, star_bitarray[i], w); | |
438 } | |
439 mstarBM = W_StoreBitmap(starm_width, starm_height, starm_bits, mapw); | |
440 #ifdef VISIBLE_WORMHOLES | |
441 mholeBM = W_StoreBitmap(holem_width, holem_height, holem_bits, mapw); | |
442 #endif /*VISIBLE_WORMHOLES*/ | |
443 for (i = 0; i < WORMFRAMES; i++) { | |
444 wormBM[i] = W_StoreBitmap(wormhole_width, wormhole_height, | |
445 wormhole_bitarray[i], w); | |
446 } | |
447 | |
448 /* set of 16 asteroid pics, and 3 asteroid fluff filler pics */ | |
449 asteroidBM[0] = W_StoreBitmap(terrain_width, terrain_height, | |
450 a0000_bits, w); | |
451 asteroidBM[1] = W_StoreBitmap(terrain_width, terrain_height, | |
452 a0001_bits, w); | |
453 asteroidBM[2] = W_StoreBitmap(terrain_width, terrain_height, | |
454 a0010_bits, w); | |
455 asteroidBM[3] = W_StoreBitmap(terrain_width, terrain_height, | |
456 a0011_bits, w); | |
457 asteroidBM[4] = W_StoreBitmap(terrain_width, terrain_height, | |
458 a0100_bits, w); | |
459 asteroidBM[5] = W_StoreBitmap(terrain_width, terrain_height, | |
460 a0101_bits, w); | |
461 asteroidBM[6] = W_StoreBitmap(terrain_width, terrain_height, | |
462 a0110_bits, w); | |
463 asteroidBM[7] = W_StoreBitmap(terrain_width, terrain_height, | |
464 a0111_bits, w); | |
465 asteroidBM[8] = W_StoreBitmap(terrain_width, terrain_height, | |
466 a1000_bits, w); | |
467 asteroidBM[9] = W_StoreBitmap(terrain_width, terrain_height, | |
468 a1001_bits, w); | |
469 asteroidBM[10] = W_StoreBitmap(terrain_width, terrain_height, | |
470 a1010_bits, w); | |
471 asteroidBM[11] = W_StoreBitmap(terrain_width, terrain_height, | |
472 a1011_bits, w); | |
473 asteroidBM[12] = W_StoreBitmap(terrain_width, terrain_height, | |
474 a1100_bits, w); | |
475 asteroidBM[13] = W_StoreBitmap(terrain_width, terrain_height, | |
476 a1101_bits, w); | |
477 asteroidBM[14] = W_StoreBitmap(terrain_width, terrain_height, | |
478 a1110_bits, w); | |
479 asteroidBM[15] = W_StoreBitmap(terrain_width, terrain_height, | |
480 a1111_bits, w); | |
481 asteroidfluff[0] = W_StoreBitmap(terrain_width, terrain_height, | |
482 a0_bits, w); | |
483 asteroidfluff[1] = W_StoreBitmap(terrain_width, terrain_height, | |
484 a1_bits, w); | |
485 asteroidfluff[2] = W_StoreBitmap(terrain_width, terrain_height, | |
486 a2_bits, w); | |
487 for (i = 0; i < 2; i++) { | |
488 basteroid2[i] = W_StoreBitmap(asteroid_width, asteroid_height, asteroid_bits, w); | |
489 mbasteroid2[i] = W_StoreBitmap(masteroid_width, masteroid_height, masteroid_bits, mapw); | |
490 } | |
491 for (i = 0; i < 6; i++) { | |
492 basteroid[i] = W_StoreBitmap(asteroid_width, asteroid_height, asteroid_bits, w); | |
493 mbasteroid[i] = W_StoreBitmap(masteroid_width, masteroid_height, masteroid_bits, mapw); | |
494 } | |
495 | |
496 kitchenSink = W_StoreBitmap(sink_width, sink_height, sink_bits, w); | |
497 | |
498 for (i = 0; i < EX_FRAMES; i++) { | |
499 expview[i] = W_StoreBitmap(ex_width, ex_height, ex_bits[i], w); | |
500 } | |
501 for (i = 0; i < SBEXPVIEWS; i++) { | |
502 sbexpview[i] = W_StoreBitmap(sbexp_width, sbexp_height, sbexp_bits[i], w); | |
503 } | |
504 | |
505 cloakicon = W_StoreBitmap(cloak_width, cloak_height, cloak_bits, w); | |
506 icon = W_StoreBitmap(icon_width, icon_height, icon_bits, iconWin); | |
507 tractbits = W_StoreBitmap(tract_width, tract_height, tract_bits, w); | |
508 pressbits = W_StoreBitmap(press_width, press_height, press_bits, w); | |
509 } | |
510 | |
511 void | |
512 get_N_dispatch_outfit_event(team, s_type, lastplayercount) | |
513 int *team; | |
514 int *s_type; | |
515 int *lastplayercount; | |
516 { | |
517 W_Event event; | |
518 int validshipletter = 0; | |
519 static int resetting = 0; | |
520 int oldresetting; | |
521 int i; | |
522 | |
523 oldresetting = resetting; | |
524 | |
525 W_NextEvent(&event); | |
526 switch ((int) event.type) { | |
527 case W_EV_KEY: | |
528 { | |
529 struct shiplist *shipscan; | |
530 validshipletter = 0; | |
531 shipscan = shiptypes; | |
532 while (shipscan) { | |
533 if (shipscan->ship->s_letter == event.key) { | |
534 *s_type = shipscan->ship->s_type; | |
535 validshipletter = 1; | |
536 break; | |
537 } | |
538 shipscan = shipscan->next; | |
539 } | |
540 } | |
541 | |
542 if (me->p_status == PTQUEUE) { | |
543 int i; | |
544 for (i = 0; i < WNUM; i++) { | |
545 if (event.Window == messWin[i].window) { | |
546 messageWinEvent(&event); | |
547 break; | |
548 } | |
549 } | |
550 if (i != WNUM) | |
551 break; | |
552 if (event.Window == messagew || | |
553 event.Window == tstatw || | |
554 event.Window == warnw) | |
555 smessage(event.key); | |
556 } | |
557 if (event.Window == motdWin) { | |
558 motdWinEvent(event.key); | |
559 break; | |
560 } else if (event.Window == playerw || event.Window == infow) { | |
561 /* allow 'i' 'I' and '^i' in playerw [BDyess] */ | |
562 playerwEvent(&event); | |
563 break; | |
564 } else if (event.Window == w || event.Window == mapw) { | |
565 switch (event.key) { | |
566 #ifdef Q_OUTFITTING | |
567 case 'q': | |
568 *team = number_of_teams; | |
569 me->p_status = PFREE; | |
570 break; | |
571 #endif /* Q_OUTFITTING */ | |
572 case 'R': | |
573 warning("Are you sure you want to reset your stats?"); | |
574 resetting = 1; | |
575 break; | |
576 case 'y': | |
577 if (resetting) { | |
578 sendResetStatsReq('Y'); | |
579 warning("OK, your stats have been reset."); | |
580 resetting = 0; | |
581 } | |
582 break; | |
583 case 'n': | |
584 if (resetting) { | |
585 warning("I didn't think so."); | |
586 resetting = 0; | |
587 } | |
588 break; | |
589 | |
590 case 'f': /* Scroll motd forward */ | |
591 if (currpage == NULL) | |
592 currpage = motddata; | |
593 if (currpage == NULL || currpage->next == NULL) | |
594 break; | |
595 currpage->next->prev = currpage; | |
596 currpage = currpage->next; | |
597 showMotd(w); | |
598 resetting = 0; | |
599 break; | |
600 case 'b': /* Scroll motd backward */ | |
601 if (currpage == NULL || currpage->prev == NULL) | |
602 break; | |
603 currpage = currpage->prev; | |
604 showMotd(w); | |
605 resetting = 0; | |
606 break; | |
607 /* ok, let's have some info windows available on the TQ */ | |
608 | |
609 default: /* hmm, something that doesn't have to do | |
610 with the MOTD, maybe it's an info window | |
611 request */ | |
612 switch (doKeymap(&event)) { | |
613 case 'U': /* U = Rank list */ | |
614 if (W_IsMapped(rankw)) { | |
615 W_UnmapWindow(rankw); | |
616 } else { | |
617 W_MapWindow(rankw); | |
618 } | |
619 break; | |
620 case 'P': /* P = Planet list */ | |
621 if (W_IsMapped(planetw)) { | |
622 W_UnmapWindow(planetw); | |
623 W_UnmapWindow(planetw2); | |
624 } else { | |
625 W_MapWindow(planetw); | |
626 W_MapWindow(planetw2); | |
627 } | |
628 break; | |
629 case 'h': /* h = Map help window */ | |
630 if (W_IsMapped(helpWin)) { | |
631 W_UnmapWindow(helpWin); | |
632 } else { | |
633 W_MapWindow(helpWin); | |
634 } | |
635 if (optionWin) | |
636 optionredrawtarget(helpWin); | |
637 break; | |
638 case 'O': /* O = options Window */ | |
639 if (optionWin != NULL && W_IsMapped(optionWin)) | |
640 optiondone(); | |
641 else | |
642 optionwindow(); | |
643 break; | |
644 case 'w': /* w = map war stuff */ | |
645 if (W_IsMapped(war)) | |
646 W_UnmapWindow(war); | |
647 else | |
648 warwindow(); | |
649 break; | |
650 case '&': | |
651 if (defaultsFile) { | |
652 char buf[150]; | |
653 sprintf(buf, "Reading defaults from %s", defaultsFile); | |
654 warning(buf); | |
655 freeDefaults(); | |
656 defaultsFile = initDefaults(defaultsFile); | |
657 resetDefaults(); | |
658 } else { | |
659 warning("No defaults file to read from!"); | |
660 } | |
661 } | |
662 break; | |
663 } | |
664 | |
665 break; /* switch event type */ | |
666 } | |
667 if (event.Window == qwin) | |
668 return; /* normal keypresses can't make you quit */ | |
669 | |
670 if (event.Window == optionWin) { | |
671 optionaction(&event); | |
672 return; | |
673 } | |
674 if (!validshipletter) | |
675 break; | |
676 /* | |
677 it wasn't the main window, see if they hit the key in a team | |
678 window to choose their ship... falling through | |
679 */ | |
680 case W_EV_BUTTON: | |
681 | |
682 for (i = 0; i < number_of_teams; i++) | |
683 if (event.Window == teamWin[i]) { | |
684 *team = i; | |
685 break; | |
686 } | |
687 if (event.Window == qwin) { | |
688 *team = number_of_teams; | |
689 me->p_status = PFREE; | |
690 break; | |
691 } | |
692 /* allow message scrollback [BDyess] */ | |
693 for (i = 0; i < WNUM; i++) { | |
694 if (event.Window == messWin[i].window) { | |
695 messageWinEvent(&event); | |
696 break; | |
697 } | |
698 } | |
699 /* allow bozo selection in playerw [BDyess] */ | |
700 if (event.Window == playerw) { | |
701 playerwEvent(&event); | |
702 break; | |
703 } else if (event.Window == war) | |
704 waraction(&event); | |
705 else if (event.Window == optionWin) | |
706 optionaction(&event); | |
707 if (*team != -1 && !teamRequest(*team, *s_type)) { | |
708 *team = -1; | |
709 } | |
710 break; | |
711 case W_EV_EXPOSE: | |
712 for (i = 0; i < number_of_teams; i++) | |
713 if (event.Window == teamWin[i]) { | |
714 lastplayercount[i] = -1; /* force update */ | |
715 redrawTeam(teamWin[i], i, &lastplayercount[i]); | |
716 break; | |
717 } | |
718 if (event.Window == qwin) | |
719 redrawQuit(); | |
720 else if (event.Window == w) | |
721 showMotd(w); | |
722 else if (event.Window == mapw) { | |
723 #ifdef COW_HAS_IT_WHY_SHOULDNT_WE | |
724 if(showMapAtMotd) { | |
725 map(); | |
726 redraw_death_messages(); | |
727 } else | |
728 #endif | |
729 showValues(mapw); | |
730 } else | |
731 /* let the normal expose handler figure out who to redraw */ | |
732 dispatch_W_expose_event(&event); | |
733 break; | |
734 } | |
735 | |
736 if (oldresetting && resetting) { | |
737 resetting = 0; | |
738 warning("Resetting of stats cancelled"); | |
739 } | |
740 } | |
741 | |
742 void | |
743 new_entrywindow(team, s_type) | |
744 int *team, *s_type; | |
745 { | |
746 int i; | |
747 int lastplayercount[4]; /* number of players on each team */ | |
748 int okayMask, lastOkayMask; /* teams you're allowed to choose */ | |
749 char buf[100]; | |
750 | |
751 /* OUTFIT timeout stuff */ | |
752 long startTime = -1; | |
753 long lasttime = -1; | |
754 int spareTime = 0; | |
755 | |
756 if (fastQuit) { | |
757 *team = -1; | |
758 return; | |
759 } | |
760 lastOkayMask = okayMask = tournMask; | |
761 | |
762 #ifdef PACKET_LIGHTS | |
763 /* erase packet lights to make Bob happy [BDyess] */ | |
764 light_erase(); | |
765 #endif /* PACKET_LIGHTS */ | |
766 | |
767 /* | |
768 map all team selection windows, and stripe out those that are | |
769 unchoosable | |
770 */ | |
771 for (i = 0; i < number_of_teams; i++) { | |
772 if (okayMask & (1 << i)) | |
773 W_UnTileWindow(teamWin[i]); | |
774 else | |
775 W_TileWindow(teamWin[i], stipple); | |
776 | |
777 W_MapWindow(teamWin[i]); | |
778 lastplayercount[i] = -1; | |
779 } | |
780 W_MapWindow(qwin); | |
781 | |
782 /* no team selected yet */ | |
783 *team = -1; | |
784 /* | |
785 set to team index (0..n-1) to choose a team. set to n if you want to | |
786 quit | |
787 */ | |
788 | |
789 /* I don't know why this restriction is in place - RF */ | |
790 if (me->p_whydead != KWINNER && me->p_whydead != KGENOCIDE) { | |
791 showMotd(w); | |
792 #ifdef COW_HAS_IT_WHY_SHOULDNT_WE | |
793 if(showMapAtMotd) { | |
794 map(); | |
795 redraw_death_messages(); | |
796 } else | |
797 #endif | |
798 showValues(mapw); | |
799 } | |
800 do { | |
801 | |
802 /* set team to n if you want to quit */ | |
803 while (!W_EventsPending() && (me->p_status == POUTFIT || | |
804 me->p_status == PTQUEUE)) { | |
805 /* no window events, just process socket stuff */ | |
806 fd_set mask; | |
807 | |
808 #ifdef PACKET_LIGHTS | |
809 light_erase(); | |
810 #endif /* PACKET_LIGHTS */ | |
811 | |
812 readFromServer(); | |
813 | |
814 if (me->p_status == POUTFIT || me->p_status == PTQUEUE) { | |
815 /* wait up to a half-second for input from the window system */ | |
816 struct timeval tv; | |
817 | |
818 #ifndef AMIGA | |
819 tv.tv_sec = 0; | |
820 tv.tv_usec = 500000; | |
821 | |
822 FD_ZERO(&mask); | |
823 FD_SET(W_Socket(), &mask); | |
824 select(W_Socket() + 1, &mask, 0, 0, &tv); | |
825 #else | |
826 StartTimer(0, 500000); | |
827 while (1) { | |
828 #ifdef DNET | |
829 sigsPending = Wait(W_Socket() | portmask | sockMask | udpSockMask | SIGBREAKF_CTRL_C); | |
830 #else | |
831 /* something else.... */ | |
832 #endif | |
833 if (sigsPending & SIGBREAKF_CTRL_C) { | |
834 printf("Ctrl-c break from entrywindow!\n"); | |
835 StopTimer(); | |
836 exit(0); | |
837 } | |
838 if ((sigsPending & (W_Socket() | sockMask | udpSockMask)) || | |
839 (CheckIO(&(ior->tr_node)))) | |
840 break; | |
841 } /* timer returns false signals, wish I knew | |
842 why. :-( */ | |
843 StopTimer(); | |
844 #endif /* AMIGA */ | |
845 } | |
846 | |
847 #ifdef COW_HAS_IT_WHY_SHOULDNT_WE | |
848 if(showMapAtMotd) { | |
849 map(); | |
850 redraw_death_messages(); | |
851 } | |
852 #endif | |
853 | |
854 if (me->p_status == PTQUEUE) | |
855 startTime = -1; | |
856 | |
857 if (me->p_status == POUTFIT) { | |
858 /* time only elapses in OUTFIT mode */ | |
859 | |
860 if (startTime == -1) { /* we were on the tqueue */ | |
861 /* I hate this [BDyess] */ | |
862 #if 1 | |
863 W_Deiconify(baseWin); /* we changed status. alert | |
864 the user */ | |
865 #endif | |
866 startTime = time(0); | |
867 spareTime = 480; /* Allow them extra time, as long */ | |
868 /* as they are active */ | |
869 } | |
870 elapsed = time(0) - startTime; | |
871 | |
872 if (elapsed > autoQuit) { | |
873 printf("Auto-Quit.\n"); | |
874 *team = number_of_teams; | |
875 break; | |
876 } | |
877 } | |
878 if (lasttime != time(0)) { | |
879 if (W_IsMapped(playerw)) | |
880 playerlist2(); | |
881 | |
882 if (newMotdStuff) { | |
883 showMotd(w); | |
884 #ifdef COW_HAS_IT_WHY_SHOULDNT_WE | |
885 if(showMapAtMotd) { | |
886 map(); | |
887 redraw_death_messages(); | |
888 } else | |
889 #endif | |
890 showValues(mapw); | |
891 } | |
892 if (me->p_status == POUTFIT) { | |
893 showTimeLeft(elapsed, autoQuit); | |
894 } | |
895 lasttime = time(0); | |
896 } | |
897 okayMask = tournMask; | |
898 | |
899 /* redraw those windows whose choosable status has changed */ | |
900 for (i = 0; i < number_of_teams; i++) { | |
901 if ((okayMask ^ lastOkayMask) & (1 << i)) { | |
902 if (okayMask & (1 << i)) { | |
903 W_UnTileWindow(teamWin[i]); | |
904 } else { | |
905 W_TileWindow(teamWin[i], stipple); | |
906 } | |
907 lastplayercount[i] = -1; /* force update */ | |
908 } | |
909 redrawTeam(teamWin[i], i, &lastplayercount[i]); | |
910 } | |
911 lastOkayMask = okayMask; | |
912 } | |
913 | |
914 #ifdef RECORDER | |
915 if (playback) /* silly. Shouldn't even be mapping team windows. */ | |
916 break; | |
917 #endif | |
918 /* they quit or ran out of time */ | |
919 if (*team == number_of_teams) { | |
920 me->p_status = PFREE; /* exit outer while loop */ | |
921 break; | |
922 } | |
923 /* | |
924 this makes them eventually run out of time no matter how awake | |
925 they are. Only affects the OUTFIT screen. | |
926 */ | |
927 if (me->p_status == POUTFIT && startTime != -1) { | |
928 if (time(0) - startTime <= spareTime) { | |
929 spareTime -= time(0) - startTime; | |
930 startTime = time(0); | |
931 } else { | |
932 startTime += spareTime; | |
933 spareTime = 0; | |
934 } | |
935 } | |
936 if (!W_EventsPending()) | |
937 continue; | |
938 | |
939 /* ok, there's a window event pending */ | |
940 | |
941 /* thiswill set p_status to PFREE if they decide to quit */ | |
942 get_N_dispatch_outfit_event(team, s_type, lastplayercount); | |
943 | |
944 } while ((me->p_status == POUTFIT || | |
945 me->p_status == PTQUEUE) | |
946 #ifdef RECORDER | |
947 && (!pb_update) | |
948 #endif | |
949 ); | |
950 | |
951 if (*team >= 0) { | |
952 strcpy(buf, "Welcome aboard "); | |
953 if (paradise) | |
954 strcat(buf, ranks2[me->p_stats2.st_rank].name); | |
955 else | |
956 strcat(buf, ranks[me->p_stats.st_rank].name); | |
957 sprintf(buf, "Welcome aboard %s!", get_players_rank_name(me)); | |
958 warning(buf); | |
959 } | |
960 #ifdef RECORDER | |
961 if (playback) { | |
962 extern int lastTeamReq; | |
963 *team = me->p_teami = lastTeamReq; | |
964 } else | |
965 #endif | |
966 /* if they quit or ran out of time */ | |
967 if (me->p_status == PFREE) | |
968 *team = -1; | |
969 else if (me->p_status == PALIVE || | |
970 me->p_status == POBSERVE) | |
971 if (*team == -1) | |
972 *team = me->p_teami; | |
973 else | |
974 me->p_teami = *team; | |
975 | |
976 | |
977 for (i = 0; i < number_of_teams; i++) | |
978 W_UnmapWindow(teamWin[i]); | |
979 W_UnmapWindow(qwin); | |
980 } | |
981 | |
982 /* Attempt to pick specified team & ship */ | |
983 static int | |
984 teamRequest(team, ship) | |
985 int team, ship; | |
986 { | |
987 int lastTime; | |
988 | |
989 #ifdef RECORDER | |
990 extern int lastTeamReq; | |
991 | |
992 if (!playback) | |
993 lastTeamReq = team; | |
994 #endif | |
995 #ifdef TIMELORD | |
996 if (!allowed_to_keep_playing()) { | |
997 warning("You've played enough for today. Get back to work!"); | |
998 return 0; | |
999 } | |
1000 #endif | |
1001 pickOk = -1; | |
1002 sendTeamReq(team, ship); | |
1003 lastTime = time(NULL); | |
1004 while (pickOk == -1) { | |
1005 if (lastTime + 3 < time(NULL)) { | |
1006 sendTeamReq(team, ship); | |
1007 lastTime = time(NULL); | |
1008 } | |
1009 socketPause(0, 20000); | |
1010 readFromServer(); | |
1011 if (isServerDead()) { | |
1012 printf("Whoops! We've been ghostbusted!\n"); | |
1013 printf("Pray for a miracle!\n"); | |
1014 | |
1015 /* UDP fail-safe */ | |
1016 commMode = commModeReq = COMM_TCP; | |
1017 commSwitchTimeout = 0; | |
1018 if (udpSock >= 0) | |
1019 closeUdpConn(); | |
1020 if (udpWin) { | |
1021 udprefresh(UDP_CURRENT); | |
1022 udprefresh(UDP_STATUS); | |
1023 } | |
1024 connectToServer(nextSocket); | |
1025 printf("Yea! We've been resurrected!\n"); | |
1026 pickOk = 0; | |
1027 break; | |
1028 } | |
1029 #if 0 /* >this< is redundant ;-) */ | |
1030 if (me->p_status == PALIVE) { /* well, something happened and we've | |
1031 got a ship! */ | |
1032 pickOk = 1; | |
1033 break; | |
1034 } | |
1035 #endif | |
1036 } | |
1037 | |
1038 #if 1 /* this is not redundant? */ | |
1039 if (pickOk) { | |
1040 me->p_status = PALIVE; /* we got a ship. We must be alive */ | |
1041 #ifdef TIMER | |
1042 timeBank[T_SHIP] = time(NULL); | |
1043 #endif /* TIMER */ | |
1044 } | |
1045 #endif | |
1046 return (pickOk); | |
1047 } | |
1048 | |
1049 static int | |
1050 numShips(owner) | |
1051 int owner; | |
1052 { | |
1053 int i, num = 0; | |
1054 struct player *p; | |
1055 | |
1056 for (i = 0, p = players; i < nplayers; i++, p++) | |
1057 if ((p->p_status == PALIVE || p->p_status == PTQUEUE) | |
1058 && p->p_teami == owner) | |
1059 num++; | |
1060 return (num); | |
1061 } | |
1062 | |
1063 #if 0 | |
1064 int | |
1065 realNumShips(owner) | |
1066 int owner; | |
1067 { | |
1068 int i, num = 0; | |
1069 struct player *p; | |
1070 | |
1071 for (i = 0, p = players; i < MAXPLAYER; i++, p++) | |
1072 if (p->p_status != PFREE && | |
1073 p->p_team == owner) | |
1074 num++; | |
1075 return (num); | |
1076 } | |
1077 #endif | |
1078 | |
1079 #if 0 | |
1080 int | |
1081 deadTeam(owner) | |
1082 int owner; | |
1083 /* The team is dead if it has no planets and cannot coup it's home planet */ | |
1084 { | |
1085 int i, num = 0; | |
1086 struct planet *p; | |
1087 | |
1088 if (planets[remap[owner] * 10 - 10].pl_couptime == 0) | |
1089 return (0); | |
1090 for (i = 0, p = planets; i < MAXPLANETS; i++, p++) { | |
1091 if (p->pl_owner & owner) { | |
1092 num++; | |
1093 } | |
1094 } | |
1095 if (num != 0) | |
1096 return (0); | |
1097 return (1); | |
1098 } | |
1099 #endif | |
1100 | |
1101 static int | |
1102 checkBold(line) | |
1103 /* Determine if that line should be highlighted on sign-on screen */ | |
1104 /* Which is done when it is the players own score being displayed */ | |
1105 char *line; | |
1106 { | |
1107 char *s, *t; | |
1108 int i; | |
1109 int end = 0; | |
1110 | |
1111 if ((int) strlen(line) < 60) | |
1112 return (0); | |
1113 s = line + 4; | |
1114 if (!me) | |
1115 return (0); | |
1116 t = me->p_name; | |
1117 | |
1118 for (i = 0; i < 16; i++) { | |
1119 if (!end) { | |
1120 if (*t == '\0') | |
1121 end = 1; | |
1122 else if (*t != *s) | |
1123 return (0); | |
1124 } | |
1125 if (end) { | |
1126 if (*s != ' ') | |
1127 return (0); | |
1128 } | |
1129 s++; | |
1130 t++; | |
1131 } | |
1132 return (1); | |
1133 } | |
1134 | |
1135 struct list { | |
1136 char bold; | |
1137 struct list *next; | |
1138 char *data; | |
1139 }; | |
1140 static struct list *sysdefptr = NULL; | |
1141 | |
1142 void | |
1143 showMotd(win) | |
1144 W_Window win; | |
1145 { | |
1146 FILE *fopen(); | |
1147 int i; | |
1148 struct list *data; | |
1149 int count; | |
1150 int headernum; | |
1151 | |
1152 newMotdStuff = 0; /* clear the flag */ | |
1153 | |
1154 if (currpage == NULL) | |
1155 currpage = motddata; | |
1156 if (currpage == NULL) | |
1157 return; | |
1158 if (!W_IsMapped(win)) | |
1159 return; | |
1160 | |
1161 headernum = currpage->page % NRHEADERS; | |
1162 W_ClearWindow(win); | |
1163 W_WriteWinBitmap(win, 0, 0, headerA, foreColor); | |
1164 W_WriteWinBitmap(win, headerA_width, 0, headerB, foreColor); | |
1165 W_WriteWinBitmap(win, headerA_width, headerB_height, headerchanges[headernum], foreColor); | |
1166 if (headernum == 2) { /* fill in client: */ | |
1167 /* note: font dependant */ | |
1168 W_WriteText(win, headerA_width + header3_x_hot, headerB_height + header3_y_hot | |
1169 - 7, textColor, CLIENTVERS, strlen(CLIENTVERS), W_BoldFont); | |
1170 } else if (headernum == 3) {/* fill in server: */ | |
1171 ; | |
1172 } | |
1173 if (currpage->first) { | |
1174 currpage->first = 0; | |
1175 data = currpage->text; | |
1176 while (data != NULL) { | |
1177 data->bold = checkBold(data->data); | |
1178 data = data->next; | |
1179 } | |
1180 } | |
1181 data = currpage->text; | |
1182 count = LINESPERPAGE; /* Magical # of lines to display */ | |
1183 i = headerA_height / (paradise ? 10 : W_Textheight) + 1; | |
1184 while (count > 0) { | |
1185 if (data == NULL) | |
1186 break; | |
1187 | |
1188 if (data->bold) { | |
1189 W_WriteText(win, 20, i * (paradise ? 10 : W_Textheight), textColor, data->data, | |
1190 strlen(data->data), W_BoldFont); | |
1191 } else { | |
1192 W_WriteText(win, 20, i * (paradise ? 10 : W_Textheight), textColor, data->data, | |
1193 strlen(data->data), W_RegularFont); | |
1194 } | |
1195 data = data->next; | |
1196 count--; | |
1197 i++; | |
1198 } | |
1199 if (win == w) { | |
1200 count = W_StringWidth(blk_refitstring, W_RegularFont) / 2; | |
1201 W_WriteText(mapw, 250 - count, 480, textColor, blk_refitstring, | |
1202 strlen(blk_refitstring), W_RegularFont); | |
1203 } | |
1204 showPics(win); | |
1205 /* showValues(mapw); Should be handled in event loop now RF */ | |
1206 } | |
1207 | |
1208 static void | |
1209 showPics(win) | |
1210 W_Window win; | |
1211 { | |
1212 struct piclist *temp; | |
1213 int page; | |
1214 | |
1215 page = currpage->page; | |
1216 temp = motdPics; | |
1217 | |
1218 while (temp != NULL) { | |
1219 if (page == temp->page) { | |
1220 if (temp->thepic) | |
1221 W_WriteWinBitmap(win, temp->x, temp->y, temp->thepic, foreColor); | |
1222 else { | |
1223 W_MakeLine(win, temp->x, temp->y, | |
1224 temp->x + temp->width - 1, temp->y + temp->height - 1, W_Grey); | |
1225 W_MakeLine(win, temp->x, temp->y + temp->height - 1, | |
1226 temp->x + temp->width - 1, temp->y, W_Grey); | |
1227 W_MakeLine(win, temp->x, temp->y, | |
1228 temp->x + temp->width - 1, temp->y, W_Grey); | |
1229 W_MakeLine(win, temp->x, temp->y, | |
1230 temp->x, temp->y + temp->height - 1, W_Grey); | |
1231 W_MakeLine(win, temp->x, temp->y + temp->height - 1, | |
1232 temp->x + temp->width - 1, temp->y + temp->height - 1, W_Grey); | |
1233 W_MakeLine(win, temp->x + temp->width - 1, temp->y + temp->height - 1, | |
1234 temp->x + temp->width - 1, temp->y, W_Grey); | |
1235 } | |
1236 } | |
1237 temp = temp->next; | |
1238 } | |
1239 } | |
1240 | |
1241 /* | |
1242 * ATM: show the current values of the .sysdef parameters. | |
1243 */ | |
1244 void | |
1245 showValues(win) | |
1246 W_Window win; | |
1247 { | |
1248 int i; | |
1249 struct list *data; | |
1250 | |
1251 /* try to find the start of the info */ | |
1252 data = sysdefptr; | |
1253 | |
1254 for (i = 12; i < 50; i++) { | |
1255 if (data == NULL) | |
1256 break; | |
1257 if (data->data[0] == '+') /* quick boldface hack */ | |
1258 W_WriteText(win, 20, i * W_Textheight, textColor, data->data + 1, | |
1259 strlen(data->data) - 1, W_BoldFont); | |
1260 else | |
1261 W_WriteText(win, 20, i * W_Textheight, textColor, data->data, | |
1262 strlen(data->data), W_RegularFont); | |
1263 data = data->next; | |
1264 } | |
1265 } | |
1266 | |
1267 #define BETWEEN_PAGES 0 | |
1268 #define IN_PAGE 1 | |
1269 #define IN_SYSDEF 3 | |
1270 | |
1271 static int motdlinestate = BETWEEN_PAGES; | |
1272 static int pagecount = 0; | |
1273 static struct list **temp = NULL; | |
1274 static struct page **ptemp = NULL; | |
1275 static int linecount = 0; | |
1276 static struct piclist **motd_buftail = &motdPics; | |
1277 | |
1278 void | |
1279 erase_motd() | |
1280 { | |
1281 struct piclist *temppic; | |
1282 struct page *temppage; | |
1283 struct list *templist; | |
1284 | |
1285 while (motdPics) { | |
1286 temppic = motdPics; | |
1287 motdPics = temppic->next; | |
1288 if (temppic->thepic) | |
1289 W_FreeBitmap(temppic->thepic); | |
1290 free(temppic); | |
1291 } | |
1292 motd_buftail = &motdPics; | |
1293 | |
1294 while (motddata) { | |
1295 temppage = motddata; | |
1296 motddata = temppage->next; | |
1297 while (temppage->text) { | |
1298 templist = temppage->text; | |
1299 temppage->text = templist->next; | |
1300 free(templist->data); | |
1301 free(templist); | |
1302 } | |
1303 free(temppage); | |
1304 } | |
1305 motdlinestate = BETWEEN_PAGES; | |
1306 currpage = 0; | |
1307 pagecount = 0; | |
1308 temp = 0; | |
1309 ptemp = 0; | |
1310 linecount = 0; | |
1311 | |
1312 while (sysdefptr) { | |
1313 templist = sysdefptr; | |
1314 sysdefptr = templist->next; | |
1315 free(templist->data); | |
1316 free(templist); | |
1317 } | |
1318 } | |
1319 | |
1320 void | |
1321 newMotdPic(x, y, width, height, bits, page) | |
1322 int x, y, page, width, height; | |
1323 char *bits; | |
1324 { | |
1325 struct piclist *temp; | |
1326 | |
1327 { | |
1328 struct motd_pic_spacket dummy; | |
1329 if ((width + 7) / 8 * height > sizeof(dummy.bits) && bits) { | |
1330 fprintf(stderr, "MOTD picture from server is too big! %dx%d couldn't possibly fit in the %d data bytes of the packet\n", | |
1331 width, height, (int) sizeof(dummy.bits)); | |
1332 return; | |
1333 } | |
1334 } | |
1335 if ((currpage && page == currpage->page) || page == 0) | |
1336 newMotdStuff = 1; /* set flag for event loop */ | |
1337 | |
1338 temp = (*motd_buftail) = (struct piclist *) malloc(sizeof(struct piclist)); | |
1339 temp->next = NULL; | |
1340 temp->x = x; | |
1341 temp->y = y; | |
1342 temp->width = width; | |
1343 temp->height = height; | |
1344 temp->thepic = bits ? W_StoreBitmap(width, height, bits, motdWin) : 0; | |
1345 temp->page = page; | |
1346 motd_buftail = &(temp->next); | |
1347 } | |
1348 | |
1349 void | |
1350 newMotdLine(line) | |
1351 char *line; | |
1352 { | |
1353 | |
1354 /* | |
1355 Do this first. That way we don't even have to worry about it at all. | |
1356 */ | |
1357 | |
1358 if (strncmp("BLK: ", line, 5) == 0) { | |
1359 blk_parsemotd(line); | |
1360 return; | |
1361 } | |
1362 if (strncmp("\t@@@", line, 4) == 0 && motdlinestate != IN_SYSDEF) { | |
1363 motdlinestate = IN_SYSDEF; | |
1364 temp = &sysdefptr; | |
1365 } | |
1366 if (strncmp("\t@@b", line, 4) == 0 && motdlinestate == IN_PAGE) | |
1367 motdlinestate = BETWEEN_PAGES; | |
1368 | |
1369 if (motdlinestate == BETWEEN_PAGES || | |
1370 (motdlinestate == IN_PAGE && linecount >= LINESPERPAGE)) { | |
1371 if (motddata == NULL) | |
1372 ptemp = &motddata; | |
1373 (*ptemp) = (struct page *) malloc(sizeof(struct page)); | |
1374 (*ptemp)->next = NULL; | |
1375 (*ptemp)->first = 1; | |
1376 (*ptemp)->prev = NULL; | |
1377 (*ptemp)->page = pagecount++; | |
1378 temp = &((*ptemp)->text); | |
1379 (*ptemp)->text = NULL; | |
1380 ptemp = &((*ptemp)->next); | |
1381 motdlinestate = IN_PAGE; | |
1382 linecount = 0; | |
1383 } | |
1384 if (strncmp("\t@@", line, 3) == 0) | |
1385 return; | |
1386 | |
1387 if (!currpage || | |
1388 (pagecount - 1) == currpage->page || | |
1389 motdlinestate == IN_SYSDEF) | |
1390 newMotdStuff = 1; /* set flag for event loop */ | |
1391 | |
1392 (*temp) = (struct list *) malloc(sizeof(struct list)); | |
1393 (*temp)->next = NULL; | |
1394 (*temp)->data = (char *) malloc(strlen(line) + 1); | |
1395 strcpy((*temp)->data, line); | |
1396 temp = &((*temp)->next); | |
1397 | |
1398 if (motdlinestate == IN_PAGE) | |
1399 linecount++; | |
1400 } | |
1401 | |
1402 /*ARGSUSED*/ | |
1403 static void | |
1404 getResources(prog) | |
1405 char *prog; | |
1406 { | |
1407 getColorDefs(); | |
1408 getTiles(); | |
1409 } | |
1410 | |
1411 static void | |
1412 getTiles() | |
1413 { | |
1414 stipple = W_StoreBitmap(stipple_width, stipple_height, stipple_bits, w); | |
1415 } | |
1416 | |
1417 static void | |
1418 redrawTeam(win, teamNo, lastnum) | |
1419 W_Window win; | |
1420 int teamNo; | |
1421 int *lastnum; | |
1422 { | |
1423 char buf[BUFSIZ]; | |
1424 int num = numShips(teamNo); | |
1425 | |
1426 /* Only redraw if number of players has changed */ | |
1427 if (*lastnum == num) | |
1428 return; | |
1429 | |
1430 drawIcon(); | |
1431 | |
1432 W_ClearWindow(win); | |
1433 W_WriteBitmap(0, 0, teaminfo[teamNo].shield_logo, shipCol[teamNo + 1]); | |
1434 | |
1435 (void) sprintf(buf, "%d", num); | |
1436 W_MaskText(win, 5, 46, shipCol[teamNo + 1], buf, strlen(buf), | |
1437 W_BigFont); | |
1438 *lastnum = num; | |
1439 } | |
1440 | |
1441 static void | |
1442 redrawQuit() | |
1443 { | |
1444 /* W_WriteText(qwin, 5, 5, textColor, "Quit xtrek", 10, W_RegularFont); */ | |
1445 if (me->p_status == PTQUEUE) { | |
1446 W_ClearArea(qwin, 0, 0, BOXSIDE, BOXSIDE); | |
1447 W_WriteBitmap(0, 0, safepic, foreColor); | |
1448 } | |
1449 } | |
1450 | |
1451 void | |
1452 drawIcon() | |
1453 { | |
1454 if (!iconified) { | |
1455 me_messages = 0; | |
1456 team_messages = 0; | |
1457 all_messages = 0; | |
1458 } | |
1459 #ifdef AMIGA | |
1460 /* | |
1461 not sure this isn't appropriate for X as well. This is called from | |
1462 redrawTeam(), so iconified is set, and then all my personal messages | |
1463 beep...iconified or not. | |
1464 */ | |
1465 if (W_IsMapped(iconWin)) | |
1466 #endif | |
1467 iconified = 1; | |
1468 if (!infoIcon) { | |
1469 W_WriteBitmap(0, 0, icon, W_White); | |
1470 } else { /* code for information icon 1/15 [BDyess] */ | |
1471 int side, bottom, top, digits, x, i; | |
1472 char buf[50]; | |
1473 | |
1474 W_ClearWindow(iconWin); | |
1475 side = icon_width / number_of_teams; | |
1476 bottom = 0 + side; | |
1477 top = 0; | |
1478 W_MakeLine(iconWin, 0, bottom, icon_width, bottom, W_White); | |
1479 for (i = 0; i <= number_of_teams; i++) { /* draw the vertical | |
1480 lines */ | |
1481 x = i * side; | |
1482 x = (x > icon_width) ? icon_width : x; | |
1483 W_MakeLine(iconWin, x, bottom, x, top, W_White); | |
1484 } | |
1485 for (i = 0; i < number_of_teams; i++) { | |
1486 sprintf(buf, "%d", numShips(i)); | |
1487 digits = strlen(buf); | |
1488 W_WriteText(iconWin, i * side + side / 2 - digits * W_Textwidth / 2, | |
1489 bottom - side / 2 - W_Textheight / 2, | |
1490 shipCol[i + 1], buf, digits, W_RegularFont); | |
1491 } | |
1492 if (me->p_status == PALIVE) { | |
1493 #define TOP icon_height-10 | |
1494 if (me->p_flags & PFGREEN) | |
1495 W_FillArea(iconWin, 0, TOP, icon_width, | |
1496 icon_height, W_Green); | |
1497 else if (me->p_flags & PFYELLOW) | |
1498 W_FillArea(iconWin, 0, TOP, | |
1499 icon_width, icon_height, W_Yellow); | |
1500 else if (me->p_flags & PFRED) | |
1501 W_FillArea(iconWin, 0, TOP, | |
1502 icon_width, icon_height, W_Red); | |
1503 } | |
1504 if (me_messages) { | |
1505 sprintf(buf, "Personal: %d", me_messages); | |
1506 W_WriteText(iconWin, 1, bottom + 2, W_White, buf, strlen(buf), | |
1507 W_RegularFont); | |
1508 } | |
1509 if (team_messages) { | |
1510 sprintf(buf, "Team: %d", team_messages); | |
1511 W_WriteText(iconWin, 1, bottom + 2 + W_Textheight, W_White, buf, | |
1512 strlen(buf), W_RegularFont); | |
1513 } | |
1514 if (all_messages) { | |
1515 sprintf(buf, "All: %d", all_messages); | |
1516 W_WriteText(iconWin, 1, bottom + 2 + 2 * W_Textheight, W_White, buf, | |
1517 strlen(buf), W_RegularFont); | |
1518 } | |
1519 if (me->p_status == POUTFIT) { | |
1520 sprintf(buf, "Time left: %d", autoQuit - elapsed); | |
1521 W_WriteText(iconWin, 1, bottom + 2 + W_Textheight, W_White, buf, | |
1522 strlen(buf), W_RegularFont); | |
1523 } | |
1524 } | |
1525 } | |
1526 | |
1527 #define CLOCK_WID BOXSIDE | |
1528 #define CLOCK_HEI BOXSIDE | |
1529 #define CLOCK_BDR 0 | |
1530 | |
1531 #ifndef PI | |
1532 #define PI 3.141592654 | |
1533 #endif /* PI */ | |
1534 | |
1535 static void | |
1536 showTimeLeft(time, max) | |
1537 int time, max; | |
1538 { | |
1539 char buf[BUFSIZ]; | |
1540 int cx, cy, ex, ey, tx, ty; | |
1541 | |
1542 if ((max - time) < 10 && time & 1) { | |
1543 W_Beep(); | |
1544 W_Deiconify(baseWin); | |
1545 } | |
1546 if (iconified) | |
1547 drawIcon(); | |
1548 /* XFIX */ | |
1549 W_ClearArea(qwin, 0, 0, BOXSIDE, BOXSIDE); | |
1550 | |
1551 W_WriteBitmap(0, 0, clockpic, foreColor); | |
1552 | |
1553 cx = BOXSIDE / 2; | |
1554 cy = BOXSIDE / 2 - 6; | |
1555 ex = cx - 35 * Sin[((255 * time) / max + 64) % 256]; | |
1556 ey = cy - 35 * Cos[((255 * time) / max + 64) % 256]; | |
1557 W_MakeLine(qwin, cx, cy, ex, ey, foreColor); | |
1558 | |
1559 sprintf(buf, "%d", max - time); | |
1560 cy = BOXSIDE / 2 - 1; | |
1561 tx = cx - W_StringWidth(buf, W_RegularFont) / 2.0; | |
1562 ty = cy - W_Textheight; | |
1563 W_WriteText(qwin, tx, ty, textColor, buf, strlen(buf), W_RegularFont); | |
1564 } | |
1565 | |
1566 | |
1567 void | |
1568 do_refit(type) | |
1569 int type; | |
1570 { | |
1571 sendRefitReq(type); | |
1572 localflags &= ~PFREFIT; | |
1573 } |