1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_init_c = |
|
|
4 | * "$Id: init.C,v 1.10 2006/09/10 16:00:23 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* |
1 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
9 | |
3 | |
10 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
11 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
31 | |
25 | |
32 | #include <global.h> |
26 | #include <global.h> |
33 | #include <object.h> |
27 | #include <object.h> |
34 | |
28 | |
35 | extern const char *const attacktype_desc[NROFATTACKS] = { |
29 | extern const char *const attacktype_desc[NROFATTACKS] = { |
36 | #define def(uc, lc, name, plus, change) # name, |
30 | # define def(uc, lc, name, plus, change) # name, |
37 | #include "attackinc.h" |
31 | # include "attackinc.h" |
38 | #undef def |
32 | # undef def |
39 | }; |
33 | }; |
40 | |
34 | |
41 | extern const keyword resist_save[NROFATTACKS] = { |
35 | extern const keyword resist_save[NROFATTACKS] = { |
42 | #define def(uc, lc, name, plus, change) KW_resist_ ## lc, |
36 | # define def(uc, lc, name, plus, change) KW_resist_ ## lc, |
43 | #include "attackinc.h" |
37 | # include "attackinc.h" |
44 | #undef def |
38 | # undef def |
45 | }; |
39 | }; |
46 | |
40 | |
47 | extern const char *const resist_plus[NROFATTACKS] = { |
41 | extern const char *const resist_plus[NROFATTACKS] = { |
48 | #define def(uc, lc, name, plus, change) # plus, |
42 | # define def(uc, lc, name, plus, change) # plus, |
49 | #include "attackinc.h" |
43 | # include "attackinc.h" |
50 | #undef def |
44 | # undef def |
51 | }; |
45 | }; |
52 | |
46 | |
53 | extern const char *const change_resist_msg[NROFATTACKS] = { |
47 | extern const char *const change_resist_msg[NROFATTACKS] = { |
54 | #define def(uc, lc, name, plus, change) # change, |
48 | # define def(uc, lc, name, plus, change) # change, |
55 | #include "attackinc.h" |
49 | # include "attackinc.h" |
56 | #undef def |
50 | # undef def |
57 | }; |
51 | }; |
58 | |
52 | |
59 | int resist_table[NROFATTACKS] = { |
53 | int resist_table[NROFATTACKS] = { |
60 | #define def(uc, lc, name, plus, change) ATNR_ ## uc, |
54 | # define def(uc, lc, name, plus, change) ATNR_ ## uc, |
61 | #include "attackinc.h" |
55 | # include "attackinc.h" |
62 | #undef def |
56 | # undef def |
63 | }; |
57 | }; |
64 | |
58 | |
65 | /* You unforunately need to looking in include/global.h to see what these |
59 | /* You unforunately need to looking in include/global.h to see what these |
66 | * correspond to. |
60 | * correspond to. |
67 | */ |
61 | */ |
… | |
… | |
220 | void |
214 | void |
221 | init_library (void) |
215 | init_library (void) |
222 | { |
216 | { |
223 | init_environ (); |
217 | init_environ (); |
224 | init_globals (); |
218 | init_globals (); |
225 | init_objects (); |
|
|
226 | init_vars (); |
219 | init_vars (); |
227 | init_block (); |
220 | init_block (); |
228 | ReadBmapNames (); |
221 | ReadBmapNames (); |
229 | ReadSmooth (); |
222 | ReadSmooth (); |
230 | init_anim (); /* Must be after we read in the bitmaps */ |
223 | init_anim (); /* Must be after we read in the bitmaps */ |
… | |
… | |
283 | |
276 | |
284 | void |
277 | void |
285 | init_globals (void) |
278 | init_globals (void) |
286 | { |
279 | { |
287 | if (settings.logfilename[0] == 0) |
280 | if (settings.logfilename[0] == 0) |
288 | { |
|
|
289 | logfile = stderr; |
281 | logfile = stderr; |
290 | } |
|
|
291 | else if ((logfile = fopen (settings.logfilename, "a")) == NULL) |
282 | else if ((logfile = fopen (settings.logfilename, "a")) == NULL) |
292 | { |
283 | { |
293 | fprintf (stderr, "Unable to open %s as the logfile - will use stderr instead\n", settings.logfilename); |
284 | fprintf (stderr, "Unable to open %s as the logfile - will use stderr instead\n", settings.logfilename); |
294 | logfile = stderr; |
285 | logfile = stderr; |
295 | } |
286 | } |
296 | else |
287 | else |
297 | { |
|
|
298 | setvbuf (logfile, NULL, _IOLBF, 0); |
288 | setvbuf (logfile, NULL, _IOLBF, 0); |
299 | } |
|
|
300 | exiting = 0; |
|
|
301 | first_player = NULL; |
|
|
302 | first_friendly_object = NULL; |
|
|
303 | first_map = NULL; |
|
|
304 | first_treasurelist = NULL; |
|
|
305 | first_artifactlist = NULL; |
|
|
306 | first_archetype = NULL; |
|
|
307 | *first_map_ext_path = 0; |
|
|
308 | warn_archetypes = 0; |
|
|
309 | nroftreasures = 0; |
|
|
310 | nrofartifacts = 0; |
|
|
311 | nrofallowedstr = 0; |
|
|
312 | ring_arch = NULL; |
|
|
313 | amulet_arch = NULL; |
|
|
314 | staff_arch = NULL; |
|
|
315 | trying_emergency_save = 0; |
|
|
316 | num_animations = 0; |
|
|
317 | animations_allocated = 0; |
|
|
318 | init_defaults (); |
|
|
319 | } |
289 | } |
320 | |
|
|
321 | /* |
|
|
322 | * Sets up and initialises the linked list of free and used objects. |
|
|
323 | * Allocates a certain chunk of objects and puts them on the free list. |
|
|
324 | * Called by init_library(); |
|
|
325 | */ |
|
|
326 | |
|
|
327 | void |
|
|
328 | init_objects (void) |
|
|
329 | { |
|
|
330 | /* Initialize all objects: */ |
|
|
331 | objects = NULL; |
|
|
332 | active_objects = NULL; |
|
|
333 | } |
|
|
334 | |
|
|
335 | /* |
|
|
336 | * Initialises global variables which can be changed by options. |
|
|
337 | * Called by init_library(). |
|
|
338 | */ |
|
|
339 | |
|
|
340 | void |
|
|
341 | init_defaults (void) |
|
|
342 | { |
|
|
343 | editor = 0; |
|
|
344 | nroferrors = 0; |
|
|
345 | } |
|
|
346 | |
|
|
347 | |
290 | |
348 | void |
291 | void |
349 | init_dynamic (void) |
292 | init_dynamic (void) |
350 | { |
293 | { |
351 | archetype *at = first_archetype; |
294 | archetype *at = first_archetype; |
… | |
… | |
353 | while (at) |
296 | while (at) |
354 | { |
297 | { |
355 | if (at->clone.type == MAP) |
298 | if (at->clone.type == MAP) |
356 | { |
299 | { |
357 | if (at->clone.race) |
300 | if (at->clone.race) |
358 | { |
|
|
359 | strcpy (first_map_ext_path, at->clone.race); |
301 | strcpy (first_map_ext_path, at->clone.race); |
360 | } |
302 | |
361 | if (EXIT_PATH (&at->clone)) |
303 | if (EXIT_PATH (&at->clone)) |
362 | { |
304 | { |
363 | strcpy (first_map_path, EXIT_PATH (&at->clone)); |
305 | strcpy (first_map_path, EXIT_PATH (&at->clone)); |
364 | return; |
306 | return; |
365 | } |
307 | } |
366 | } |
308 | } |
|
|
309 | |
367 | at = at->next; |
310 | at = at->next; |
368 | } |
311 | } |
|
|
312 | |
369 | LOG (llevDebug, "You Need a archetype called 'map' and it have to contain start map\n"); |
313 | LOG (llevDebug, "You Need a archetype called 'map' and it have to contain start map\n"); |
370 | exit (-1); |
314 | exit (-1); |
371 | } |
315 | } |
372 | |
316 | |
373 | unsigned long todtick; |
317 | unsigned long todtick; |