3
|
1 /* $Id: getship.c,v 1.1.1.1 1997/12/06 05:41:29 darius Exp $ */
|
|
2
|
|
3 /*
|
|
4 * getship.c for client of socket protocol.
|
|
5 *
|
|
6 * This file has been mangled so it only sets the ship characteristics needed.
|
|
7 */
|
|
8 #include "copyright.h"
|
|
9
|
|
10 #include <stdio.h>
|
|
11 #ifdef __STDC__
|
|
12 #include <stdlib.h>
|
|
13 #endif
|
|
14 #include <sys/types.h>
|
|
15 #include "Wlib.h"
|
|
16 #include "defs.h"
|
|
17 #include "struct.h"
|
|
18 #include "data.h"
|
|
19 #include "proto.h"
|
|
20
|
|
21 /* Prototypes */
|
|
22 static void getship_default P((struct ship * shipp, int s_type));
|
|
23
|
|
24 void
|
|
25 init_shiptypes()
|
|
26 {
|
|
27 int i;
|
|
28 struct shiplist *temp;
|
|
29
|
|
30 /* start at -1, the default shiptype */
|
|
31 for (i = -1; i < nshiptypes; i++) {
|
|
32 temp = (struct shiplist *) malloc(sizeof(struct shiplist));
|
|
33 temp->ship = (struct ship *) malloc(sizeof(struct ship));
|
|
34 getship_default(temp->ship, i);
|
|
35 temp->next = shiptypes;
|
|
36 if (temp->next)
|
|
37 temp->next->prev = temp;
|
|
38 temp->prev = NULL;
|
|
39 shiptypes = temp;
|
|
40 }
|
|
41 }
|
|
42
|
|
43 void
|
|
44 init_galaxy_class()
|
|
45 {
|
|
46 /*
|
|
47 hack to allow galaxy class ships. By the time the client knows it's
|
|
48 connected to a paradise server, the defaults must already have been
|
|
49 run. [BDyess]
|
|
50 */
|
|
51 struct shiplist *temp;
|
|
52
|
|
53 for (temp = shiptypes; temp->ship->s_type != GALAXY; temp = temp->next)
|
|
54 /* null body */ ;
|
|
55 getship_default(temp->ship, GALAXY);
|
|
56
|
|
57 /* slurp_ship_bitmaps(); */ /* don't destroy downloaded bitmaps */
|
|
58
|
|
59 return;
|
|
60 }
|
|
61
|
|
62 #if 0
|
|
63 void
|
|
64 init_puck()
|
|
65 {
|
|
66 /* ditto above init_galaxy_class(), but this time for hockey and puck.
|
|
67 [BDyess] */
|
|
68 struct shiplist *temp;
|
|
69
|
|
70 temp = shiptypes;
|
|
71 while(temp->next) temp = temp->next;
|
|
72 temp->next = (struct shiplist*)malloc(sizeof(struct shiplist));
|
|
73 temp = temp->next;
|
|
74 temp->ship = (struct ship*)malloc(sizeof(struct ship));
|
|
75 getship_default(temp->ship, PUCK);
|
|
76 temp->next = NULL;
|
|
77
|
|
78 slurp_ship_bitmaps();
|
|
79
|
|
80 return;
|
|
81 }
|
|
82 #endif /*0*/
|
|
83
|
|
84 /* now returns a pointer to where the ship data is located. This way
|
|
85 if the data is later changed by the server everybody gets updated.
|
|
86 Plus as a bonus it's more efficient :) [Bill Dyess] */
|
|
87 struct ship *
|
|
88 getship(s_type)
|
|
89 int s_type;
|
|
90 {
|
|
91 struct shiplist *temp, *new;
|
|
92
|
|
93 temp = shiptypes;
|
|
94 while (temp) {
|
|
95 if (temp->ship->s_type == s_type) {
|
|
96 /* bcopy(temp->ship, shipp, sizeof(struct ship)); */
|
|
97 return temp->ship;
|
|
98 }
|
|
99 temp = temp->next;
|
|
100 }
|
|
101 /*
|
|
102 ok, that shiptype is unheard of. Assume a new shiptype, and get the
|
|
103 values for CA. Also add the ship to the list so if it gets updated by
|
|
104 the server later everyone stays happy. [Bill Dyess]
|
|
105 */
|
|
106 printf("Error: getship of unknown ship type %d, using CA defaults\n", s_type);
|
|
107 temp = shiptypes;
|
|
108 while (temp) {
|
|
109 if (temp->ship->s_type == DEFAULT) {
|
|
110 printf("Adding ship type %d\n", s_type);
|
|
111 /* bcopy(temp->ship, shipp, sizeof(struct ship)); */
|
|
112 /* now add the new ship to the list */
|
|
113 new = (struct shiplist *) malloc(sizeof(struct shiplist));
|
|
114 new->ship = (struct ship *) malloc(sizeof(struct ship));
|
|
115 new->next = shiptypes;
|
|
116 new->prev = NULL;
|
|
117 if (shiptypes)
|
|
118 shiptypes->prev = new;
|
|
119 shiptypes = new;
|
|
120 bcopy(temp->ship, new->ship, sizeof(struct ship));
|
|
121 new->ship->s_type = s_type;
|
|
122 return new->ship;
|
|
123 }
|
|
124 temp = temp->next;
|
|
125 }
|
|
126 return temp->ship;
|
|
127
|
|
128 }
|
|
129
|
|
130 /* fill in ship characteristics */
|
|
131
|
|
132 static void
|
|
133 getship_default(shipp, s_type)
|
|
134 struct ship *shipp;
|
|
135 int s_type;
|
|
136 {
|
|
137 switch (s_type) {
|
|
138 case SCOUT:
|
|
139 case PUCK:
|
|
140 shipp->s_torpspeed = 16;
|
|
141 shipp->s_phaserrange = 4500;
|
|
142 shipp->s_maxspeed = 12;
|
|
143 shipp->s_maxfuel = 5000;
|
|
144 shipp->s_maxarmies = 2;
|
|
145 shipp->s_maxshield = 75;
|
|
146 shipp->s_maxdamage = 75;
|
|
147 shipp->s_maxwpntemp = 1000;
|
|
148 shipp->s_maxegntemp = 1000;
|
|
149 if(s_type == PUCK) {
|
|
150 shipp->s_type = PUCK;
|
|
151 shipp->s_letter = 'k';
|
|
152 shipp->s_desig[0] = 'P';
|
|
153 shipp->s_desig[1] = 'U';
|
|
154 shipp->s_bitmap = PUCK;
|
|
155 } else {
|
|
156 shipp->s_type = SCOUT;
|
|
157 shipp->s_letter = 's';
|
|
158 shipp->s_desig[0] = 'S';
|
|
159 shipp->s_desig[1] = 'C';
|
|
160 shipp->s_bitmap = SCOUT;
|
|
161 }
|
|
162 break;
|
|
163 case DESTROYER:
|
|
164 shipp->s_type = DESTROYER;
|
|
165 shipp->s_torpspeed = 14;
|
|
166 shipp->s_phaserrange = 5100;
|
|
167 shipp->s_maxspeed = 10;
|
|
168 shipp->s_maxfuel = 7000;
|
|
169 shipp->s_maxarmies = 5;
|
|
170 shipp->s_maxshield = 85;
|
|
171 shipp->s_maxdamage = 85;
|
|
172 shipp->s_maxwpntemp = 1000;
|
|
173 shipp->s_maxegntemp = 1000;
|
|
174 shipp->s_letter = 'd';
|
|
175 shipp->s_desig[0] = 'D';
|
|
176 shipp->s_desig[1] = 'D';
|
|
177 shipp->s_bitmap = DESTROYER;
|
|
178 break;
|
|
179 default:
|
|
180 case DEFAULT:
|
|
181 case CRUISER:
|
|
182 shipp->s_type = s_type;
|
|
183 shipp->s_torpspeed = 12;
|
|
184 shipp->s_phaserrange = 6000;
|
|
185 shipp->s_maxspeed = 9;
|
|
186 shipp->s_maxfuel = 10000;
|
|
187 shipp->s_maxarmies = 10;
|
|
188 shipp->s_maxshield = 100;
|
|
189 shipp->s_maxdamage = 100;
|
|
190 shipp->s_maxwpntemp = 1000;
|
|
191 shipp->s_maxegntemp = 1000;
|
|
192 shipp->s_letter = 'c';
|
|
193 shipp->s_desig[0] = 'C';
|
|
194 shipp->s_desig[1] = 'A';
|
|
195 shipp->s_bitmap = CRUISER;
|
|
196 break;
|
|
197 case BATTLESHIP:
|
|
198 shipp->s_type = BATTLESHIP;
|
|
199 shipp->s_torpspeed = 12;
|
|
200 shipp->s_phaserrange = 6300;
|
|
201 shipp->s_maxspeed = 8;
|
|
202 shipp->s_maxfuel = 14000;
|
|
203 shipp->s_maxarmies = 6;
|
|
204 shipp->s_maxshield = 130;
|
|
205 shipp->s_maxdamage = 130;
|
|
206 shipp->s_maxwpntemp = 1000;
|
|
207 shipp->s_maxegntemp = 1000;
|
|
208 shipp->s_letter = 'b';
|
|
209 shipp->s_desig[0] = 'B';
|
|
210 shipp->s_desig[1] = 'B';
|
|
211 shipp->s_bitmap = BATTLESHIP;
|
|
212 break;
|
|
213 case ASSAULT:
|
|
214 shipp->s_type = ASSAULT;
|
|
215 shipp->s_torpspeed = 16;
|
|
216 shipp->s_phaserrange = 4800;
|
|
217 shipp->s_maxspeed = 8;
|
|
218 shipp->s_maxfuel = 6000;
|
|
219 shipp->s_maxarmies = 20;
|
|
220 shipp->s_maxshield = 80;
|
|
221 shipp->s_maxdamage = 200;
|
|
222 shipp->s_maxwpntemp = 1000;
|
|
223 shipp->s_maxegntemp = 1200;
|
|
224 shipp->s_letter = 'a';
|
|
225 shipp->s_desig[0] = 'A';
|
|
226 shipp->s_desig[1] = 'S';
|
|
227 shipp->s_bitmap = ASSAULT;
|
|
228 break;
|
|
229 case STARBASE:
|
|
230 shipp->s_type = STARBASE;
|
|
231 shipp->s_torpspeed = 14;
|
|
232 shipp->s_phaserrange = 7200;
|
|
233 shipp->s_maxspeed = 2;
|
|
234 shipp->s_maxfuel = 60000;
|
|
235 shipp->s_maxarmies = 25;
|
|
236 shipp->s_maxshield = 500;
|
|
237 shipp->s_maxdamage = 600;
|
|
238 shipp->s_maxwpntemp = 1300;
|
|
239 shipp->s_maxegntemp = 1000;
|
|
240 shipp->s_letter = 'o';
|
|
241 shipp->s_desig[0] = 'S';
|
|
242 shipp->s_desig[1] = 'B';
|
|
243 shipp->s_bitmap = STARBASE;
|
|
244 break;
|
|
245 case ATT: /* or GALAXY */
|
|
246 if (paradise) {
|
|
247 shipp->s_type = ATT;
|
|
248 shipp->s_torpspeed = 20;
|
|
249 shipp->s_phaserrange = 6000;
|
|
250 shipp->s_maxspeed = 90;
|
|
251 shipp->s_maxfuel = 60000;
|
|
252 shipp->s_maxarmies = 1000;
|
|
253 shipp->s_maxshield = 30000;
|
|
254 shipp->s_maxdamage = 30000;
|
|
255 shipp->s_maxwpntemp = 10000;
|
|
256 shipp->s_maxegntemp = 10000;
|
|
257 shipp->s_letter = 'X';
|
|
258 shipp->s_desig[0] = 'A';
|
|
259 shipp->s_desig[1] = 'T';
|
|
260 shipp->s_bitmap = ATT;
|
|
261 } else {
|
|
262 shipp->s_type = GALAXY;
|
|
263 shipp->s_torpspeed = 13;
|
|
264 shipp->s_phaserrange = 6000; /* this is a guess */
|
|
265 shipp->s_maxspeed = 9;
|
|
266 shipp->s_maxfuel = 12000;
|
|
267 shipp->s_maxarmies = 12;
|
|
268 shipp->s_maxshield = 140;
|
|
269 shipp->s_maxdamage = 120;
|
|
270 shipp->s_maxwpntemp = 1000;
|
|
271 shipp->s_maxegntemp = 1000;
|
|
272 shipp->s_letter = 'g';
|
|
273 shipp->s_desig[0] = 'G';
|
|
274 shipp->s_desig[1] = 'A';
|
|
275 shipp->s_bitmap = FLAGSHIP;
|
|
276 }
|
|
277 break;
|
|
278 case FLAGSHIP:
|
|
279 shipp->s_type = FLAGSHIP;
|
|
280 shipp->s_torpspeed = 14;
|
|
281 shipp->s_phaserrange = 5750;
|
|
282 shipp->s_maxspeed = 9;
|
|
283 shipp->s_maxfuel = 14500;
|
|
284 shipp->s_maxarmies = 8;
|
|
285 shipp->s_maxshield = 115;
|
|
286 shipp->s_maxdamage = 115;
|
|
287 shipp->s_maxwpntemp = 1000;
|
|
288 shipp->s_maxegntemp = 1500;
|
|
289 shipp->s_letter = 'f';
|
|
290 shipp->s_desig[0] = 'F';
|
|
291 shipp->s_desig[1] = 'L';
|
|
292 shipp->s_bitmap = FLAGSHIP;
|
|
293 break;
|
|
294 case JUMPSHIP:
|
|
295 shipp->s_type = JUMPSHIP;
|
|
296 shipp->s_torpspeed = 18;
|
|
297 shipp->s_phaserrange = 3000;
|
|
298 shipp->s_maxspeed = 20;
|
|
299 shipp->s_maxfuel = 50000;
|
|
300 shipp->s_maxarmies = 0;
|
|
301 shipp->s_maxshield = 5;
|
|
302 shipp->s_maxdamage = 60;
|
|
303 shipp->s_maxwpntemp = 1300;
|
|
304 shipp->s_maxegntemp = 5000;
|
|
305 shipp->s_letter = 'j';
|
|
306 shipp->s_desig[0] = 'J';
|
|
307 shipp->s_desig[1] = 'S';
|
|
308 shipp->s_bitmap = JUMPSHIP;
|
|
309 break;
|
|
310 case WARBASE:
|
|
311 shipp->s_type = WARBASE;
|
|
312 shipp->s_torpspeed = 15;
|
|
313 shipp->s_phaserrange = 6000;
|
|
314 shipp->s_maxspeed = 3;
|
|
315 shipp->s_maxfuel = 50000;
|
|
316 shipp->s_maxarmies = 0;
|
|
317 shipp->s_maxshield = 150;
|
|
318 shipp->s_maxdamage = 500;
|
|
319 shipp->s_maxwpntemp = 1500;
|
|
320 shipp->s_maxegntemp = 1000;
|
|
321 shipp->s_letter = 'w';
|
|
322 shipp->s_desig[0] = 'W';
|
|
323 shipp->s_desig[1] = 'B';
|
|
324 shipp->s_bitmap = WARBASE;
|
|
325 break;
|
|
326
|
|
327 case LIGHTCRUISER:
|
|
328 shipp->s_type = LIGHTCRUISER;
|
|
329 shipp->s_torpspeed = 13;
|
|
330 shipp->s_phaserrange = 6000;
|
|
331 shipp->s_maxspeed = 10;
|
|
332 shipp->s_maxfuel = 9000;
|
|
333 shipp->s_maxarmies = 4;
|
|
334 shipp->s_maxshield = 95;
|
|
335 shipp->s_maxdamage = 90;
|
|
336 shipp->s_maxwpntemp = 1000;
|
|
337 shipp->s_maxegntemp = 1500;
|
|
338 shipp->s_letter = 'l';
|
|
339 shipp->s_desig[0] = 'C';
|
|
340 shipp->s_desig[1] = 'L';
|
|
341 shipp->s_bitmap = LIGHTCRUISER;
|
|
342 break;
|
|
343
|
|
344 case CARRIER:
|
|
345 shipp->s_type = CARRIER;
|
|
346 shipp->s_torpspeed = 10;
|
|
347 shipp->s_phaserrange = 4500;
|
|
348 shipp->s_maxspeed = 10;
|
|
349 shipp->s_maxfuel = 15000;
|
|
350 shipp->s_maxarmies = 3;
|
|
351 shipp->s_maxshield = 100;
|
|
352 shipp->s_maxdamage = 150;
|
|
353 shipp->s_maxwpntemp = 1000;
|
|
354 shipp->s_maxegntemp = 1000;
|
|
355 shipp->s_letter = 'v';
|
|
356 shipp->s_desig[0] = 'C';
|
|
357 shipp->s_desig[1] = 'V';
|
|
358 shipp->s_bitmap = CARRIER;
|
|
359 break;
|
|
360 case UTILITY:
|
|
361 shipp->s_type = UTILITY;
|
|
362 shipp->s_torpspeed = 16;
|
|
363 shipp->s_phaserrange = 5000;
|
|
364 shipp->s_maxspeed = 7;
|
|
365 shipp->s_maxfuel = 12000;
|
|
366 shipp->s_maxarmies = 12;
|
|
367 shipp->s_maxshield = 110;
|
|
368 shipp->s_maxdamage = 180;
|
|
369 shipp->s_maxwpntemp = 1000;
|
|
370 shipp->s_maxegntemp = 1800;
|
|
371 shipp->s_letter = 'u';
|
|
372 shipp->s_desig[0] = 'U';
|
|
373 shipp->s_desig[1] = 'T';
|
|
374 shipp->s_bitmap = UTILITY;
|
|
375 break;
|
|
376
|
|
377 case PATROL:
|
|
378 shipp->s_type = PATROL;
|
|
379 shipp->s_torpspeed = 15;
|
|
380 shipp->s_phaserrange = 5000;
|
|
381 shipp->s_maxspeed = 11;
|
|
382 shipp->s_maxfuel = 4000;
|
|
383 shipp->s_maxarmies = 1;
|
|
384 shipp->s_maxshield = 50;
|
|
385 shipp->s_maxdamage = 40;
|
|
386 shipp->s_maxwpntemp = 1000;
|
|
387 shipp->s_maxegntemp = 1500;
|
|
388 shipp->s_letter = 'p';
|
|
389 shipp->s_desig[0] = 'P';
|
|
390 shipp->s_desig[1] = 'T';
|
|
391 shipp->s_bitmap = PATROL;
|
|
392 break;
|
|
393 }
|
|
394 buildShipKeymap(shipp);
|
|
395 }
|