Mercurial > ~darius > hgwebdir.cgi > paradise_server
comparison src/gameconf.c @ 4:aa38447a4b21
First entry of Paradise Server 2.9 patch 10 Beta
author | darius |
---|---|
date | Sat, 06 Dec 1997 04:37:03 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:cafa94d86546 | 4:aa38447a4b21 |
---|---|
1 /*-------------------------------------------------------------------------- | |
2 NETREK II -- Paradise | |
3 | |
4 Permission to use, copy, modify, and distribute this software and its | |
5 documentation, or any derivative works thereof, for any NON-COMMERCIAL | |
6 purpose and without fee is hereby granted, provided that this copyright | |
7 notice appear in all copies. No representations are made about the | |
8 suitability of this software for any purpose. This software is provided | |
9 "as is" without express or implied warranty. | |
10 | |
11 Xtrek Copyright 1986 Chris Guthrie | |
12 Netrek (Xtrek II) Copyright 1989 Kevin P. Smith | |
13 Scott Silvey | |
14 Paradise II (Netrek II) Copyright 1993 Larry Denys | |
15 Kurt Olsen | |
16 Brandon Gillespie | |
17 --------------------------------------------------------------------------*/ | |
18 | |
19 #include "config.h" | |
20 #include <sys/types.h> | |
21 #include <stdio.h> | |
22 #include <netinet/in.h> | |
23 #include "defs.h" | |
24 #include "gppackets.h" | |
25 #include "shmem.h" | |
26 #include "data.h" | |
27 | |
28 /* some game params packet stuff */ | |
29 /* status experimental */ | |
30 | |
31 void | |
32 updateGPrank() | |
33 { | |
34 int i; | |
35 struct gp_rank_spacket pkt; | |
36 | |
37 pkt.type = SP_GPARAM; | |
38 pkt.subtype = 5; | |
39 | |
40 for (i = 0; i < NUMRANKS; i++) | |
41 { | |
42 pkt.rankn = i; | |
43 pkt.genocides = htonl(ranks[i].genocides); | |
44 #ifndef BAD_SVR4_HACKS | |
45 pkt.milliDI = htonl(1000 * ranks[i].di); | |
46 pkt.millibattle = htonl(1000 * ranks[i].battle); | |
47 pkt.millistrat = htonl(1000 * ranks[i].strategy); | |
48 pkt.millispec = htonl(1000 * ranks[i].specship); | |
49 #else /* Unixware/IRIX requires explicit casts */ | |
50 /* this next define will make the next more readable */ | |
51 #define BAD_SVR4_HACKS_CAST(a,b) (unsigned long)( (long double)a * (long double)b ) | |
52 pkt.milliDI = htonl(BAD_SVR4_HACKS_CAST(1000, ranks[i].di)); | |
53 pkt.millibattle = htonl(BAD_SVR4_HACKS_CAST(1000, ranks[i].battle)); | |
54 pkt.millistrat = htonl(BAD_SVR4_HACKS_CAST(1000, ranks[i].strategy)); | |
55 pkt.millispec = htonl(BAD_SVR4_HACKS_CAST(1000, ranks[i].specship)); | |
56 #endif /* BAD_SVR4_HACKS */ | |
57 strcpy(pkt.name, ranks[i].name); | |
58 | |
59 sendClientPacket((struct player_spacket *) & pkt); | |
60 } | |
61 } | |
62 | |
63 void | |
64 updateGProyal() | |
65 { | |
66 int i; | |
67 struct gp_royal_spacket pkt; | |
68 | |
69 pkt.type = SP_GPARAM; | |
70 pkt.subtype = 6; | |
71 | |
72 for (i = 0; i < NUMROYALRANKS; i++) | |
73 { | |
74 pkt.rankn = i; | |
75 strcpy(pkt.name, royal[i].name); | |
76 sendClientPacket((struct player_spacket *) & pkt); | |
77 } | |
78 } | |
79 | |
80 void | |
81 updateGPteams() | |
82 { | |
83 struct gp_team_spacket pkt; | |
84 int i; | |
85 | |
86 for (i = 0; i < NUMTEAM; i++) | |
87 { | |
88 pkt.type = SP_GPARAM; | |
89 pkt.subtype = 1; | |
90 | |
91 pkt.index = i; | |
92 pkt.letter = teams[idx_to_mask(i)].letter; | |
93 strncpy(pkt.shortname, teams[idx_to_mask(i)].shortname, | |
94 sizeof(pkt.shortname)); | |
95 strncpy(pkt.teamname, teams[idx_to_mask(i)].name, sizeof(pkt.teamname)); | |
96 | |
97 sendClientPacket((struct player_spacket *) & pkt); | |
98 } | |
99 } | |
100 | |
101 static void | |
102 send_one_teamlogo(teamidx, data, width, height) | |
103 int teamidx; | |
104 unsigned char *data; | |
105 int width, height; | |
106 { | |
107 struct gp_teamlogo_spacket pkt; | |
108 int pwidth; | |
109 | |
110 if (width > 99 || height > 99) | |
111 { | |
112 printf("logo too big: %dx%d\n", width, height); | |
113 return; | |
114 } | |
115 | |
116 pkt.type = SP_GPARAM; | |
117 pkt.subtype = 2; | |
118 | |
119 pkt.logowidth = width; | |
120 pkt.logoheight = height; | |
121 pkt.teamindex = teamidx; | |
122 | |
123 pwidth = (width - 1) / 8 + 1; | |
124 pkt.thisheight = sizeof(pkt.data) / pwidth; | |
125 | |
126 for (pkt.y = 0; pkt.y < height; pkt.y += pkt.thisheight) | |
127 { | |
128 | |
129 if (pkt.y + pkt.thisheight > height) | |
130 pkt.thisheight = height - pkt.y; | |
131 | |
132 memcpy(pkt.data, data + pkt.y * pwidth, pkt.thisheight * pwidth); | |
133 sendClientPacket((struct player_spacket *) & pkt); | |
134 } | |
135 } | |
136 | |
137 void | |
138 updateGPteamlogos() | |
139 { | |
140 char buf[40]; | |
141 char *data; | |
142 int width, height; | |
143 int i; | |
144 | |
145 for (i = 0; i < NUMTEAM; i++) | |
146 { | |
147 sprintf(buf, "artwork/%d/logo", i); | |
148 #ifdef LEAGUE_SUPPORT | |
149 if (status2->league == 1) | |
150 { | |
151 if (i == 0) | |
152 sprintf(buf, "artwork/%s/logo", status2->home.name); | |
153 else if (i == 1) | |
154 sprintf(buf, "artwork/%s/logo", status2->away.name); | |
155 } | |
156 else if (status2->league) | |
157 { | |
158 if (i == status2->home.index) | |
159 sprintf(buf, "artwork/%s/logo", status2->home.name); | |
160 else if (i == status2->away.index) | |
161 sprintf(buf, "artwork/%s/logo", status2->away.name); | |
162 } | |
163 #endif | |
164 { | |
165 FILE *fp; | |
166 fp = fopen(build_path(buf), "r"); | |
167 if (!fp) | |
168 continue; /* no image to transmit */ | |
169 ParseXbmFile(fp, &width, &height, &data); | |
170 fclose(fp); | |
171 } | |
172 if (!data) | |
173 { | |
174 continue; | |
175 } | |
176 send_one_teamlogo(i, data, width, height); | |
177 free(data); | |
178 } | |
179 } | |
180 | |
181 /* #include "borgcube.bm" */ | |
182 | |
183 void | |
184 updateGPshipshapes() | |
185 { | |
186 #if 0 | |
187 { | |
188 struct gp_shipshape_spacket pkt; | |
189 | |
190 pkt.type = SP_GPARAM; | |
191 pkt.subtype = 3; | |
192 | |
193 pkt.shipno = ATT; | |
194 pkt.race = -1; | |
195 pkt.nviews = 1; | |
196 pkt.width = borgcube_width; | |
197 pkt.height = borgcube_height; | |
198 | |
199 sendClientPacket((struct player_spacket *) & pkt); | |
200 } | |
201 | |
202 { | |
203 struct gp_shipbitmap_spacket pkt; | |
204 | |
205 pkt.type = SP_GPARAM; | |
206 pkt.subtype = 4; | |
207 | |
208 pkt.shipno = ATT; | |
209 pkt.race = -1; | |
210 pkt.thisview = 0; | |
211 | |
212 memcpy(pkt.bitmapdata, borgcube_bits, sizeof(borgcube_bits)); | |
213 | |
214 sendClientPacket((struct player_spacket *) & pkt); | |
215 } | |
216 #endif | |
217 } | |
218 | |
219 void | |
220 updateGPplanetbitmaps() | |
221 { | |
222 struct gp_teamplanet_spacket pkt; | |
223 char buf[40]; | |
224 char *data; | |
225 int width, height; | |
226 int i; | |
227 | |
228 for (i = 0; i < NUMTEAM; i++) | |
229 { | |
230 | |
231 pkt.type = SP_GPARAM; | |
232 pkt.subtype = 7; | |
233 | |
234 pkt.teamn = i; | |
235 | |
236 sprintf(buf, "artwork/%d/tplanet", i); | |
237 #ifdef LEAGUE_SUPPORT | |
238 if (status2->league == 1) | |
239 { | |
240 if (i == 0) | |
241 sprintf(buf, "artwork/%s/tplanet", status2->home.name); | |
242 else if (i == 1) | |
243 sprintf(buf, "artwork/%s/tplanet", status2->away.name); | |
244 } | |
245 else if (status2->league) | |
246 { | |
247 if (i == status2->home.index) | |
248 sprintf(buf, "artwork/%s/tplanet", status2->home.name); | |
249 else if (i == status2->away.index) | |
250 sprintf(buf, "artwork/%s/tplanet", status2->away.name); | |
251 } | |
252 #endif | |
253 { | |
254 FILE *fp; | |
255 fp = fopen(build_path(buf), "r"); | |
256 if (!fp) | |
257 continue; /* no image to transmit */ | |
258 ParseXbmFile(fp, &width, &height, &data); | |
259 fclose(fp); | |
260 } | |
261 if (!data) | |
262 { | |
263 continue; | |
264 } | |
265 memcpy(pkt.tactical, data, 120); | |
266 memcpy(pkt.tacticalM, data, 120); | |
267 free(data); | |
268 | |
269 sprintf(buf, "artwork/%d/gplanet", i); | |
270 #ifdef LEAGUE_SUPPORT | |
271 if (status2->league == 1) | |
272 { | |
273 if (i == 0) | |
274 sprintf(buf, "artwork/%s/gplanet", status2->home.name); | |
275 else if (i == 1) | |
276 sprintf(buf, "artwork/%s/gplanet", status2->away.name); | |
277 } | |
278 else if (status2->league) | |
279 { | |
280 if (i == status2->home.index) | |
281 sprintf(buf, "artwork/%s/gplanet", status2->home.name); | |
282 else if (i == status2->away.index) | |
283 sprintf(buf, "artwork/%s/gplanet", status2->away.name); | |
284 } | |
285 #endif | |
286 { | |
287 FILE *fp; | |
288 fp = fopen(build_path(buf), "r"); | |
289 if (!fp) | |
290 continue; /* no image to transmit */ | |
291 ParseXbmFile(fp, &width, &height, &data); | |
292 fclose(fp); | |
293 } | |
294 if (!data) | |
295 { | |
296 continue; | |
297 } | |
298 memcpy(pkt.galactic, data, 32); | |
299 memcpy(pkt.galacticM, data, 32); | |
300 free(data); | |
301 | |
302 sendClientPacket((struct player_spacket *) & pkt); | |
303 } | |
304 | |
305 } | |
306 | |
307 void | |
308 updateGameparams() | |
309 { | |
310 struct gp_sizes_spacket pkt; | |
311 | |
312 memset((char *) &pkt, 0, sizeof(pkt)); | |
313 | |
314 pkt.type = SP_GPARAM; | |
315 pkt.subtype = 0; | |
316 | |
317 pkt.nplayers = MAXPLAYER; | |
318 pkt.nteams = 4; | |
319 pkt.nshiptypes = NUM_TYPES; | |
320 pkt.nranks = NUMRANKS; | |
321 pkt.nroyal = NUMROYALRANKS; | |
322 pkt.nphasers = 1; | |
323 pkt.ntorps = MAXTORP; | |
324 pkt.nplasmas = MAXPLASMA; | |
325 pkt.nthingies = NPTHINGIES; | |
326 pkt.gthingies = NGTHINGIES; | |
327 pkt.gwidth = GWIDTH; | |
328 pkt.flags = 0; | |
329 pkt.nplanets = configvals->numplanets; | |
330 sendClientPacket((struct player_spacket *) & pkt); | |
331 | |
332 updateGPteams(); | |
333 if (me == 0 || !(me->p_stats.st_flags & ST_NOBITMAPS)) | |
334 { | |
335 updateGPteamlogos(); | |
336 updateGPshipshapes(); | |
337 updateGPplanetbitmaps(); | |
338 } | |
339 updateGPrank(); | |
340 updateGProyal(); | |
341 } | |
342 | |
343 /* end game params stuff */ |