1 | /* |
1 | /* |
2 | * static char *rcsid_init_c = |
2 | * static char *rcsid_init_c = |
3 | * "$Id: init.C,v 1.3 2006/09/03 00:18:39 root Exp $"; |
3 | * "$Id: init.C,v 1.6 2006/09/07 09:37:11 pippijn 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 | |
… | |
… | |
256 | ring_arch = NULL; |
256 | ring_arch = NULL; |
257 | amulet_arch = NULL; |
257 | amulet_arch = NULL; |
258 | staff_arch = NULL; |
258 | staff_arch = NULL; |
259 | trying_emergency_save = 0; |
259 | trying_emergency_save = 0; |
260 | num_animations=0; |
260 | num_animations=0; |
261 | animations=NULL; |
|
|
262 | animations_allocated=0; |
261 | animations_allocated=0; |
263 | init_defaults(); |
262 | init_defaults(); |
264 | } |
263 | } |
265 | |
264 | |
266 | /* |
265 | /* |
267 | * Sets up and initialises the linked list of free and used objects. |
266 | * Sets up and initialises the linked list of free and used objects. |
268 | * Allocates a certain chunk of objects and puts them on the free list. |
267 | * Allocates a certain chunk of objects and puts them on the free list. |
269 | * Called by init_library(); |
268 | * Called by init_library(); |
270 | */ |
269 | */ |
271 | |
270 | |
|
|
271 | void |
272 | void init_objects(void) { |
272 | init_objects(void) |
273 | int i; |
273 | { |
274 | /* Initialize all objects: */ |
274 | /* Initialize all objects: */ |
275 | objects=NULL; |
275 | objects = NULL; |
276 | active_objects = NULL; |
276 | active_objects = NULL; |
277 | |
|
|
278 | #ifdef MEMORY_DEBUG |
|
|
279 | free_objects=NULL; |
|
|
280 | #else |
|
|
281 | free_objects=objarray; |
|
|
282 | objarray[0].prev=NULL, |
|
|
283 | objarray[0].next= &objarray[1], |
|
|
284 | SET_FLAG(&objarray[0], FLAG_REMOVED); |
|
|
285 | SET_FLAG(&objarray[0], FLAG_FREED); |
|
|
286 | for(i=1;i<STARTMAX-1;i++) { |
|
|
287 | objarray[i].next= &objarray[i+1]; |
|
|
288 | objarray[i].prev= &objarray[i-1]; |
|
|
289 | SET_FLAG(&objarray[i], FLAG_REMOVED); |
|
|
290 | SET_FLAG(&objarray[i], FLAG_FREED); |
|
|
291 | } |
|
|
292 | objarray[STARTMAX-1].next=NULL; |
|
|
293 | objarray[STARTMAX-1].prev= &objarray[STARTMAX-2]; |
|
|
294 | SET_FLAG(&objarray[STARTMAX-1], FLAG_REMOVED); |
|
|
295 | SET_FLAG(&objarray[STARTMAX-1], FLAG_FREED); |
|
|
296 | #endif |
|
|
297 | } |
277 | } |
298 | |
278 | |
299 | /* |
279 | /* |
300 | * Initialises global variables which can be changed by options. |
280 | * Initialises global variables which can be changed by options. |
301 | * Called by init_library(). |
281 | * Called by init_library(). |