1 | /* |
1 | /* |
2 | * static char *rcsid_init_c = |
2 | * static char *rcsid_init_c = |
3 | * "$Id: init.C,v 1.2 2006/08/29 08:01:35 root Exp $"; |
3 | * "$Id: init.C,v 1.9 2006/09/09 23:49:06 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | |
25 | |
26 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
26 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
27 | */ |
27 | */ |
28 | |
28 | |
29 | #define EXTERN |
29 | #define EXTERN // horrible hack |
30 | #define INIT_C |
30 | |
31 | #include <global.h> |
31 | #include <global.h> |
32 | #include <object.h> |
32 | #include <object.h> |
|
|
33 | |
|
|
34 | extern const char* const attacktype_desc[NROFATTACKS] = { |
|
|
35 | # define def(uc, lc, name, plus, change) # name, |
|
|
36 | # include "attackinc.h" |
|
|
37 | # undef def |
|
|
38 | }; |
|
|
39 | |
|
|
40 | extern const keyword resist_save[NROFATTACKS] = { |
|
|
41 | # define def(uc, lc, name, plus, change) KW_resist_ ## lc, |
|
|
42 | # include "attackinc.h" |
|
|
43 | # undef def |
|
|
44 | }; |
|
|
45 | |
|
|
46 | extern const char* const resist_plus[NROFATTACKS] = { |
|
|
47 | # define def(uc, lc, name, plus, change) # plus, |
|
|
48 | # include "attackinc.h" |
|
|
49 | # undef def |
|
|
50 | }; |
|
|
51 | |
|
|
52 | extern const char* const change_resist_msg[NROFATTACKS] = { |
|
|
53 | # define def(uc, lc, name, plus, change) # change, |
|
|
54 | # include "attackinc.h" |
|
|
55 | # undef def |
|
|
56 | }; |
|
|
57 | |
|
|
58 | int resist_table[NROFATTACKS] = { |
|
|
59 | # define def(uc, lc, name, plus, change) ATNR_ ## uc, |
|
|
60 | # include "attackinc.h" |
|
|
61 | # undef def |
|
|
62 | }; |
33 | |
63 | |
34 | /* You unforunately need to looking in include/global.h to see what these |
64 | /* You unforunately need to looking in include/global.h to see what these |
35 | * correspond to. |
65 | * correspond to. |
36 | */ |
66 | */ |
37 | struct Settings settings = { |
67 | struct Settings settings = { |
… | |
… | |
179 | */ |
209 | */ |
180 | |
210 | |
181 | void init_library(void) { |
211 | void init_library(void) { |
182 | init_environ(); |
212 | init_environ(); |
183 | init_globals(); |
213 | init_globals(); |
184 | init_hash_table(); |
|
|
185 | init_objects(); |
214 | init_objects(); |
186 | init_vars(); |
215 | init_vars(); |
187 | init_block(); |
216 | init_block(); |
188 | ReadBmapNames (); |
217 | ReadBmapNames (); |
189 | ReadSmooth(); |
218 | ReadSmooth(); |
… | |
… | |
255 | nrofartifacts = 0; |
284 | nrofartifacts = 0; |
256 | nrofallowedstr=0; |
285 | nrofallowedstr=0; |
257 | ring_arch = NULL; |
286 | ring_arch = NULL; |
258 | amulet_arch = NULL; |
287 | amulet_arch = NULL; |
259 | staff_arch = NULL; |
288 | staff_arch = NULL; |
260 | undead_name = add_string("undead"); |
|
|
261 | trying_emergency_save = 0; |
289 | trying_emergency_save = 0; |
262 | num_animations=0; |
290 | num_animations=0; |
263 | animations=NULL; |
|
|
264 | animations_allocated=0; |
291 | animations_allocated=0; |
265 | init_defaults(); |
292 | init_defaults(); |
266 | } |
293 | } |
267 | |
294 | |
268 | /* |
295 | /* |
269 | * Sets up and initialises the linked list of free and used objects. |
296 | * Sets up and initialises the linked list of free and used objects. |
270 | * Allocates a certain chunk of objects and puts them on the free list. |
297 | * Allocates a certain chunk of objects and puts them on the free list. |
271 | * Called by init_library(); |
298 | * Called by init_library(); |
272 | */ |
299 | */ |
273 | |
300 | |
|
|
301 | void |
274 | void init_objects(void) { |
302 | init_objects(void) |
275 | int i; |
303 | { |
276 | /* Initialize all objects: */ |
304 | /* Initialize all objects: */ |
277 | objects=NULL; |
305 | objects = NULL; |
278 | active_objects = NULL; |
306 | active_objects = NULL; |
279 | |
|
|
280 | #ifdef MEMORY_DEBUG |
|
|
281 | free_objects=NULL; |
|
|
282 | #else |
|
|
283 | free_objects=objarray; |
|
|
284 | objarray[0].prev=NULL, |
|
|
285 | objarray[0].next= &objarray[1], |
|
|
286 | SET_FLAG(&objarray[0], FLAG_REMOVED); |
|
|
287 | SET_FLAG(&objarray[0], FLAG_FREED); |
|
|
288 | for(i=1;i<STARTMAX-1;i++) { |
|
|
289 | objarray[i].next= &objarray[i+1]; |
|
|
290 | objarray[i].prev= &objarray[i-1]; |
|
|
291 | SET_FLAG(&objarray[i], FLAG_REMOVED); |
|
|
292 | SET_FLAG(&objarray[i], FLAG_FREED); |
|
|
293 | } |
|
|
294 | objarray[STARTMAX-1].next=NULL; |
|
|
295 | objarray[STARTMAX-1].prev= &objarray[STARTMAX-2]; |
|
|
296 | SET_FLAG(&objarray[STARTMAX-1], FLAG_REMOVED); |
|
|
297 | SET_FLAG(&objarray[STARTMAX-1], FLAG_FREED); |
|
|
298 | #endif |
|
|
299 | } |
307 | } |
300 | |
308 | |
301 | /* |
309 | /* |
302 | * Initialises global variables which can be changed by options. |
310 | * Initialises global variables which can be changed by options. |
303 | * Called by init_library(). |
311 | * Called by init_library(). |