1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2002 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
14 #include "libgame/libgame.h"
29 #include "conf_e2g.c" /* include auto-generated data structure definitions */
30 #include "conf_esg.c" /* include auto-generated data structure definitions */
31 #include "conf_e2s.c" /* include auto-generated data structure definitions */
32 #include "conf_fnt.c" /* include auto-generated data structure definitions */
33 #include "conf_g2s.c" /* include auto-generated data structure definitions */
34 #include "conf_g2m.c" /* include auto-generated data structure definitions */
37 #define CONFIG_TOKEN_FONT_INITIAL "font.initial"
40 static struct FontBitmapInfo font_initial[NUM_INITIAL_FONTS];
42 static int copy_properties[][5] =
46 EL_BUG_LEFT, EL_BUG_RIGHT,
47 EL_BUG_UP, EL_BUG_DOWN
51 EL_SPACESHIP_LEFT, EL_SPACESHIP_RIGHT,
52 EL_SPACESHIP_UP, EL_SPACESHIP_DOWN
56 EL_BD_BUTTERFLY_LEFT, EL_BD_BUTTERFLY_RIGHT,
57 EL_BD_BUTTERFLY_UP, EL_BD_BUTTERFLY_DOWN
61 EL_BD_FIREFLY_LEFT, EL_BD_FIREFLY_RIGHT,
62 EL_BD_FIREFLY_UP, EL_BD_FIREFLY_DOWN
66 EL_PACMAN_LEFT, EL_PACMAN_RIGHT,
67 EL_PACMAN_UP, EL_PACMAN_DOWN
71 EL_MOLE_LEFT, EL_MOLE_RIGHT,
72 EL_MOLE_UP, EL_MOLE_DOWN
82 FreeLevelEditorGadgets();
91 static boolean gadgets_initialized = FALSE;
93 if (gadgets_initialized)
96 CreateLevelEditorGadgets();
100 CreateScreenGadgets();
102 gadgets_initialized = TRUE;
105 inline void InitElementSmallImagesScaledUp(int graphic)
107 CreateImageWithSmallImages(graphic, graphic_info[graphic].scale_up_factor);
110 void InitElementSmallImages()
112 static int special_graphics[] =
114 IMG_EDITOR_ELEMENT_BORDER,
115 IMG_EDITOR_ELEMENT_BORDER_INPUT,
116 IMG_EDITOR_CASCADE_LIST,
117 IMG_EDITOR_CASCADE_LIST_ACTIVE,
120 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
121 int num_property_mappings = getImageListPropertyMappingSize();
124 /* initialize normal images from static configuration */
125 for (i = 0; element_to_graphic[i].element > -1; i++)
126 InitElementSmallImagesScaledUp(element_to_graphic[i].graphic);
128 /* initialize special images from static configuration */
129 for (i = 0; element_to_special_graphic[i].element > -1; i++)
130 InitElementSmallImagesScaledUp(element_to_special_graphic[i].graphic);
132 /* initialize images from dynamic configuration (may be elements or other) */
133 for (i = 0; i < num_property_mappings; i++)
134 InitElementSmallImagesScaledUp(property_mapping[i].artwork_index);
136 /* initialize special images from above list (non-element images) */
137 for (i = 0; special_graphics[i] > -1; i++)
138 InitElementSmallImagesScaledUp(special_graphics[i]);
142 /* !!! FIX THIS (CHANGE TO USING NORMAL ELEMENT GRAPHIC DEFINITIONS) !!! */
143 void SetBitmaps_EM(Bitmap **em_bitmap)
145 em_bitmap[0] = graphic_info[IMG_EMC_OBJECT].bitmap;
146 em_bitmap[1] = graphic_info[IMG_EMC_SPRITE].bitmap;
150 static int getFontBitmapID(int font_nr)
154 if (game_status >= GAME_MODE_MAIN && game_status <= GAME_MODE_PSEUDO_PREVIEW)
155 special = game_status;
156 else if (game_status == GAME_MODE_PSEUDO_TYPENAME)
157 special = GFX_SPECIAL_ARG_MAIN;
158 else if (game_status == GAME_MODE_PLAYING)
159 special = GFX_SPECIAL_ARG_DOOR;
162 return font_info[font_nr].special_bitmap_id[special];
167 void InitFontGraphicInfo()
169 static struct FontBitmapInfo *font_bitmap_info = NULL;
170 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
171 int num_property_mappings = getImageListPropertyMappingSize();
172 int num_font_bitmaps = NUM_FONTS;
175 if (graphic_info == NULL) /* still at startup phase */
177 InitFontInfo(font_initial, NUM_INITIAL_FONTS, getFontBitmapID);
182 /* ---------- initialize font graphic definitions ---------- */
184 /* always start with reliable default values (normal font graphics) */
185 for (i = 0; i < NUM_FONTS; i++)
186 font_info[i].graphic = IMG_FONT_INITIAL_1;
188 /* initialize normal font/graphic mapping from static configuration */
189 for (i = 0; font_to_graphic[i].font_nr > -1; i++)
191 int font_nr = font_to_graphic[i].font_nr;
192 int special = font_to_graphic[i].special;
193 int graphic = font_to_graphic[i].graphic;
198 font_info[font_nr].graphic = graphic;
201 /* always start with reliable default values (special font graphics) */
202 for (i = 0; i < NUM_FONTS; i++)
204 for (j = 0; j < NUM_SPECIAL_GFX_ARGS; j++)
206 font_info[i].special_graphic[j] = font_info[i].graphic;
207 font_info[i].special_bitmap_id[j] = i;
211 /* initialize special font/graphic mapping from static configuration */
212 for (i = 0; font_to_graphic[i].font_nr > -1; i++)
214 int font_nr = font_to_graphic[i].font_nr;
215 int special = font_to_graphic[i].special;
216 int graphic = font_to_graphic[i].graphic;
217 int base_graphic = font2baseimg(font_nr);
219 if (special >= 0 && special < NUM_SPECIAL_GFX_ARGS)
221 boolean base_redefined =
222 getImageListEntryFromImageID(base_graphic)->redefined;
223 boolean special_redefined =
224 getImageListEntryFromImageID(graphic)->redefined;
226 /* if the base font ("font.title_1", for example) has been redefined,
227 but not the special font ("font.title_1.LEVELS", for example), do not
228 use an existing (in this case considered obsolete) special font
229 anymore, but use the automatically determined default font */
230 if (base_redefined && !special_redefined)
233 font_info[font_nr].special_graphic[special] = graphic;
234 font_info[font_nr].special_bitmap_id[special] = num_font_bitmaps;
239 /* initialize special element/graphic mapping from dynamic configuration */
240 for (i = 0; i < num_property_mappings; i++)
242 int font_nr = property_mapping[i].base_index - MAX_NUM_ELEMENTS;
243 int special = property_mapping[i].ext3_index;
244 int graphic = property_mapping[i].artwork_index;
249 if (special >= 0 && special < NUM_SPECIAL_GFX_ARGS)
251 font_info[font_nr].special_graphic[special] = graphic;
252 font_info[font_nr].special_bitmap_id[special] = num_font_bitmaps;
257 /* ---------- initialize font bitmap array ---------- */
259 if (font_bitmap_info != NULL)
260 FreeFontInfo(font_bitmap_info);
263 checked_calloc(num_font_bitmaps * sizeof(struct FontBitmapInfo));
265 /* ---------- initialize font bitmap definitions ---------- */
267 for (i = 0; i < NUM_FONTS; i++)
269 if (i < NUM_INITIAL_FONTS)
271 font_bitmap_info[i] = font_initial[i];
275 for (j = 0; j < NUM_SPECIAL_GFX_ARGS; j++)
277 int font_bitmap_id = font_info[i].special_bitmap_id[j];
278 int graphic = font_info[i].special_graphic[j];
280 /* set 'graphic_info' for font entries, if uninitialized (guessed) */
281 if (graphic_info[graphic].anim_frames < MIN_NUM_CHARS_PER_FONT)
283 graphic_info[graphic].anim_frames = DEFAULT_NUM_CHARS_PER_FONT;
284 graphic_info[graphic].anim_frames_per_line= DEFAULT_NUM_CHARS_PER_LINE;
287 /* copy font relevant information from graphics information */
288 font_bitmap_info[font_bitmap_id].bitmap = graphic_info[graphic].bitmap;
289 font_bitmap_info[font_bitmap_id].src_x = graphic_info[graphic].src_x;
290 font_bitmap_info[font_bitmap_id].src_y = graphic_info[graphic].src_y;
291 font_bitmap_info[font_bitmap_id].width = graphic_info[graphic].width;
292 font_bitmap_info[font_bitmap_id].height = graphic_info[graphic].height;
293 font_bitmap_info[font_bitmap_id].draw_x = graphic_info[graphic].draw_x;
294 font_bitmap_info[font_bitmap_id].draw_y = graphic_info[graphic].draw_y;
296 font_bitmap_info[font_bitmap_id].num_chars =
297 graphic_info[graphic].anim_frames;
298 font_bitmap_info[font_bitmap_id].num_chars_per_line =
299 graphic_info[graphic].anim_frames_per_line;
303 InitFontInfo(font_bitmap_info, num_font_bitmaps, getFontBitmapID);
306 void InitElementGraphicInfo()
308 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
309 int num_property_mappings = getImageListPropertyMappingSize();
312 if (graphic_info == NULL) /* still at startup phase */
315 /* set values to -1 to identify later as "uninitialized" values */
316 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
318 for (act = 0; act < NUM_ACTIONS; act++)
320 element_info[i].graphic[act] = -1;
321 element_info[i].crumbled[act] = -1;
323 for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
325 element_info[i].direction_graphic[act][dir] = -1;
326 element_info[i].direction_crumbled[act][dir] = -1;
331 /* initialize normal element/graphic mapping from static configuration */
332 for (i = 0; element_to_graphic[i].element > -1; i++)
334 int element = element_to_graphic[i].element;
335 int action = element_to_graphic[i].action;
336 int direction = element_to_graphic[i].direction;
337 boolean crumbled = element_to_graphic[i].crumbled;
338 int graphic = element_to_graphic[i].graphic;
339 int base_graphic = el2baseimg(element);
341 if (graphic_info[graphic].bitmap == NULL)
344 if ((action > -1 || direction > -1 || crumbled == TRUE) &&
347 boolean base_redefined =
348 getImageListEntryFromImageID(base_graphic)->redefined;
349 boolean act_dir_redefined =
350 getImageListEntryFromImageID(graphic)->redefined;
352 /* if the base graphic ("emerald", for example) has been redefined,
353 but not the action graphic ("emerald.falling", for example), do not
354 use an existing (in this case considered obsolete) action graphic
355 anymore, but use the automatically determined default graphic */
356 if (base_redefined && !act_dir_redefined)
361 action = ACTION_DEFAULT;
366 element_info[element].direction_crumbled[action][direction] = graphic;
368 element_info[element].crumbled[action] = graphic;
373 element_info[element].direction_graphic[action][direction] = graphic;
375 element_info[element].graphic[action] = graphic;
379 /* initialize normal element/graphic mapping from dynamic configuration */
380 for (i = 0; i < num_property_mappings; i++)
382 int element = property_mapping[i].base_index;
383 int action = property_mapping[i].ext1_index;
384 int direction = property_mapping[i].ext2_index;
385 int special = property_mapping[i].ext3_index;
386 int graphic = property_mapping[i].artwork_index;
387 boolean crumbled = FALSE;
389 if (special == GFX_SPECIAL_ARG_CRUMBLED)
395 if (graphic_info[graphic].bitmap == NULL)
398 if (element >= MAX_NUM_ELEMENTS || special != -1)
402 action = ACTION_DEFAULT;
407 for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
408 element_info[element].direction_crumbled[action][dir] = -1;
411 element_info[element].direction_crumbled[action][direction] = graphic;
413 element_info[element].crumbled[action] = graphic;
418 for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
419 element_info[element].direction_graphic[action][dir] = -1;
422 element_info[element].direction_graphic[action][direction] = graphic;
424 element_info[element].graphic[action] = graphic;
428 /* now copy all graphics that are defined to be cloned from other graphics */
429 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
431 int graphic = element_info[i].graphic[ACTION_DEFAULT];
432 int crumbled_like, diggable_like;
437 crumbled_like = graphic_info[graphic].crumbled_like;
438 diggable_like = graphic_info[graphic].diggable_like;
440 if (crumbled_like != -1 && element_info[i].crumbled[ACTION_DEFAULT] == -1)
442 for (act = 0; act < NUM_ACTIONS; act++)
443 element_info[i].crumbled[act] =
444 element_info[crumbled_like].crumbled[act];
445 for (act = 0; act < NUM_ACTIONS; act++)
446 for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
447 element_info[i].direction_crumbled[act][dir] =
448 element_info[crumbled_like].direction_crumbled[act][dir];
451 if (diggable_like != -1 && element_info[i].graphic[ACTION_DIGGING] == -1)
453 element_info[i].graphic[ACTION_DIGGING] =
454 element_info[diggable_like].graphic[ACTION_DIGGING];
455 for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
456 element_info[i].direction_graphic[ACTION_DIGGING][dir] =
457 element_info[diggable_like].direction_graphic[ACTION_DIGGING][dir];
462 /* set hardcoded definitions for some runtime elements without graphic */
463 element_info[EL_AMOEBA_TO_DIAMOND].graphic[ACTION_DEFAULT] = IMG_AMOEBA_DEAD;
467 /* set hardcoded definitions for some internal elements without graphic */
468 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
470 if (IS_EDITOR_CASCADE_INACTIVE(i))
471 element_info[i].graphic[ACTION_DEFAULT] = IMG_EDITOR_CASCADE_LIST;
472 else if (IS_EDITOR_CASCADE_ACTIVE(i))
473 element_info[i].graphic[ACTION_DEFAULT] = IMG_EDITOR_CASCADE_LIST_ACTIVE;
477 /* now set all undefined/invalid graphics to -1 to set to default after it */
478 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
480 for (act = 0; act < NUM_ACTIONS; act++)
484 graphic = element_info[i].graphic[act];
485 if (graphic > 0 && graphic_info[graphic].bitmap == NULL)
486 element_info[i].graphic[act] = -1;
488 graphic = element_info[i].crumbled[act];
489 if (graphic > 0 && graphic_info[graphic].bitmap == NULL)
490 element_info[i].crumbled[act] = -1;
492 for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
494 graphic = element_info[i].direction_graphic[act][dir];
495 if (graphic > 0 && graphic_info[graphic].bitmap == NULL)
496 element_info[i].direction_graphic[act][dir] = -1;
498 graphic = element_info[i].direction_crumbled[act][dir];
499 if (graphic > 0 && graphic_info[graphic].bitmap == NULL)
500 element_info[i].direction_crumbled[act][dir] = -1;
505 /* adjust graphics with 2nd tile for movement according to direction
506 (do this before correcting '-1' values to minimize calculations) */
507 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
509 for (act = 0; act < NUM_ACTIONS; act++)
511 for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
513 int graphic = element_info[i].direction_graphic[act][dir];
514 int move_dir = (act == ACTION_FALLING ? MV_BIT_DOWN : dir);
516 if (act == ACTION_FALLING) /* special case */
517 graphic = element_info[i].graphic[act];
520 graphic_info[graphic].double_movement &&
521 graphic_info[graphic].swap_double_tiles != 0)
523 struct GraphicInfo *g = &graphic_info[graphic];
524 int src_x_front = g->src_x;
525 int src_y_front = g->src_y;
526 int src_x_back = g->src_x + g->offset2_x;
527 int src_y_back = g->src_y + g->offset2_y;
528 boolean frames_are_ordered_diagonally = (g->offset_x != 0 &&
530 boolean front_is_left_or_upper = (src_x_front < src_x_back ||
531 src_y_front < src_y_back);
532 boolean swap_movement_tiles_always = (g->swap_double_tiles == 1);
533 boolean swap_movement_tiles_autodetected =
534 (!frames_are_ordered_diagonally &&
535 ((move_dir == MV_BIT_LEFT && !front_is_left_or_upper) ||
536 (move_dir == MV_BIT_UP && !front_is_left_or_upper) ||
537 (move_dir == MV_BIT_RIGHT && front_is_left_or_upper) ||
538 (move_dir == MV_BIT_DOWN && front_is_left_or_upper)));
541 /* swap frontside and backside graphic tile coordinates, if needed */
542 if (swap_movement_tiles_always || swap_movement_tiles_autodetected)
544 /* get current (wrong) backside tile coordinates */
545 getGraphicSourceExt(graphic, 0, &dummy, &src_x_back, &src_y_back,
548 /* set frontside tile coordinates to backside tile coordinates */
549 g->src_x = src_x_back;
550 g->src_y = src_y_back;
552 /* invert tile offset to point to new backside tile coordinates */
556 /* do not swap front and backside tiles again after correction */
557 g->swap_double_tiles = 0;
564 /* now set all '-1' values to element specific default values */
565 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
567 int default_graphic = element_info[i].graphic[ACTION_DEFAULT];
568 int default_crumbled = element_info[i].crumbled[ACTION_DEFAULT];
569 int default_direction_graphic[NUM_DIRECTIONS_FULL];
570 int default_direction_crumbled[NUM_DIRECTIONS_FULL];
572 if (default_graphic == -1)
573 default_graphic = IMG_UNKNOWN;
575 if (default_crumbled == -1)
576 default_crumbled = default_graphic;
578 /* !!! THIS LOOKS CRAPPY FOR SAND ETC. WITHOUT CRUMBLED GRAPHICS !!! */
579 if (default_crumbled == -1)
580 default_crumbled = IMG_EMPTY;
583 for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
585 default_direction_graphic[dir] =
586 element_info[i].direction_graphic[ACTION_DEFAULT][dir];
587 default_direction_crumbled[dir] =
588 element_info[i].direction_crumbled[ACTION_DEFAULT][dir];
590 if (default_direction_graphic[dir] == -1)
591 default_direction_graphic[dir] = default_graphic;
593 if (default_direction_crumbled[dir] == -1)
594 default_direction_crumbled[dir] = default_direction_graphic[dir];
596 /* !!! THIS LOOKS CRAPPY FOR SAND ETC. WITHOUT CRUMBLED GRAPHICS !!! */
597 if (default_direction_crumbled[dir] == -1)
598 default_direction_crumbled[dir] = default_crumbled;
602 for (act = 0; act < NUM_ACTIONS; act++)
604 boolean act_remove = ((IS_DIGGABLE(i) && act == ACTION_DIGGING) ||
605 (IS_SNAPPABLE(i) && act == ACTION_SNAPPING) ||
606 (IS_COLLECTIBLE(i) && act == ACTION_COLLECTING));
607 boolean act_turning = (act == ACTION_TURNING_FROM_LEFT ||
608 act == ACTION_TURNING_FROM_RIGHT ||
609 act == ACTION_TURNING_FROM_UP ||
610 act == ACTION_TURNING_FROM_DOWN);
612 /* generic default action graphic (defined by "[default]" directive) */
613 int default_action_graphic = element_info[EL_DEFAULT].graphic[act];
614 int default_action_crumbled = element_info[EL_DEFAULT].crumbled[act];
615 int default_remove_graphic = IMG_EMPTY;
617 if (act_remove && default_action_graphic != -1)
618 default_remove_graphic = default_action_graphic;
620 /* look for special default action graphic (classic game specific) */
621 if (IS_BD_ELEMENT(i) && element_info[EL_BD_DEFAULT].graphic[act] != -1)
622 default_action_graphic = element_info[EL_BD_DEFAULT].graphic[act];
623 if (IS_SP_ELEMENT(i) && element_info[EL_SP_DEFAULT].graphic[act] != -1)
624 default_action_graphic = element_info[EL_SP_DEFAULT].graphic[act];
625 if (IS_SB_ELEMENT(i) && element_info[EL_SB_DEFAULT].graphic[act] != -1)
626 default_action_graphic = element_info[EL_SB_DEFAULT].graphic[act];
628 if (IS_BD_ELEMENT(i) && element_info[EL_BD_DEFAULT].crumbled[act] != -1)
629 default_action_crumbled = element_info[EL_BD_DEFAULT].crumbled[act];
630 if (IS_SP_ELEMENT(i) && element_info[EL_SP_DEFAULT].crumbled[act] != -1)
631 default_action_crumbled = element_info[EL_SP_DEFAULT].crumbled[act];
632 if (IS_SB_ELEMENT(i) && element_info[EL_SB_DEFAULT].crumbled[act] != -1)
633 default_action_crumbled = element_info[EL_SB_DEFAULT].crumbled[act];
636 /* !!! needed because EL_EMPTY_SPACE treated as IS_SP_ELEMENT !!! */
637 /* !!! make this better !!! */
638 if (i == EL_EMPTY_SPACE)
640 default_action_graphic = element_info[EL_DEFAULT].graphic[act];
641 default_action_crumbled = element_info[EL_DEFAULT].crumbled[act];
645 if (default_action_graphic == -1)
646 default_action_graphic = default_graphic;
648 if (default_action_crumbled == -1)
649 default_action_crumbled = default_action_graphic;
651 /* !!! THIS LOOKS CRAPPY FOR SAND ETC. WITHOUT CRUMBLED GRAPHICS !!! */
652 if (default_action_crumbled == -1)
653 default_action_crumbled = default_crumbled;
656 for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
658 /* use action graphic as the default direction graphic, if undefined */
659 int default_action_direction_graphic = element_info[i].graphic[act];
660 int default_action_direction_crumbled = element_info[i].crumbled[act];
662 /* no graphic for current action -- use default direction graphic */
663 if (default_action_direction_graphic == -1)
664 default_action_direction_graphic =
665 (act_remove ? default_remove_graphic :
667 element_info[i].direction_graphic[ACTION_TURNING][dir] :
668 default_action_graphic != default_graphic ?
669 default_action_graphic :
670 default_direction_graphic[dir]);
672 if (element_info[i].direction_graphic[act][dir] == -1)
673 element_info[i].direction_graphic[act][dir] =
674 default_action_direction_graphic;
677 if (default_action_direction_crumbled == -1)
678 default_action_direction_crumbled =
679 element_info[i].direction_graphic[act][dir];
681 if (default_action_direction_crumbled == -1)
682 default_action_direction_crumbled =
683 (act_remove ? default_remove_graphic :
685 element_info[i].direction_crumbled[ACTION_TURNING][dir] :
686 default_action_crumbled != default_crumbled ?
687 default_action_crumbled :
688 default_direction_crumbled[dir]);
691 if (element_info[i].direction_crumbled[act][dir] == -1)
692 element_info[i].direction_crumbled[act][dir] =
693 default_action_direction_crumbled;
696 /* no graphic for this specific action -- use default action graphic */
697 if (element_info[i].graphic[act] == -1)
698 element_info[i].graphic[act] =
699 (act_remove ? default_remove_graphic :
700 act_turning ? element_info[i].graphic[ACTION_TURNING] :
701 default_action_graphic);
703 if (element_info[i].crumbled[act] == -1)
704 element_info[i].crumbled[act] = element_info[i].graphic[act];
706 if (element_info[i].crumbled[act] == -1)
707 element_info[i].crumbled[act] =
708 (act_remove ? default_remove_graphic :
709 act_turning ? element_info[i].crumbled[ACTION_TURNING] :
710 default_action_crumbled);
715 /* set animation mode to "none" for each graphic with only 1 frame */
716 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
718 for (act = 0; act < NUM_ACTIONS; act++)
720 int graphic = element_info[i].graphic[act];
721 int crumbled = element_info[i].crumbled[act];
723 if (graphic_info[graphic].anim_frames == 1)
724 graphic_info[graphic].anim_mode = ANIM_NONE;
725 if (graphic_info[crumbled].anim_frames == 1)
726 graphic_info[crumbled].anim_mode = ANIM_NONE;
728 for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
730 graphic = element_info[i].direction_graphic[act][dir];
731 crumbled = element_info[i].direction_crumbled[act][dir];
733 if (graphic_info[graphic].anim_frames == 1)
734 graphic_info[graphic].anim_mode = ANIM_NONE;
735 if (graphic_info[crumbled].anim_frames == 1)
736 graphic_info[crumbled].anim_mode = ANIM_NONE;
745 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
746 if (element_info[i].graphic[ACTION_DEFAULT] == IMG_UNKNOWN &&
748 Error(ERR_RETURN, "warning: no graphic for element '%s' (%d)",
749 element_info[i].token_name, i);
755 void InitElementSpecialGraphicInfo()
757 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
758 int num_property_mappings = getImageListPropertyMappingSize();
761 /* always start with reliable default values */
762 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
763 for (j = 0; j < NUM_SPECIAL_GFX_ARGS; j++)
764 element_info[i].special_graphic[j] =
765 element_info[i].graphic[ACTION_DEFAULT];
767 /* initialize special element/graphic mapping from static configuration */
768 for (i = 0; element_to_special_graphic[i].element > -1; i++)
770 int element = element_to_special_graphic[i].element;
771 int special = element_to_special_graphic[i].special;
772 int graphic = element_to_special_graphic[i].graphic;
773 int base_graphic = el2baseimg(element);
774 boolean base_redefined =
775 getImageListEntryFromImageID(base_graphic)->redefined;
776 boolean special_redefined =
777 getImageListEntryFromImageID(graphic)->redefined;
779 /* if the base graphic ("emerald", for example) has been redefined,
780 but not the special graphic ("emerald.EDITOR", for example), do not
781 use an existing (in this case considered obsolete) special graphic
782 anymore, but use the automatically created (down-scaled) graphic */
783 if (base_redefined && !special_redefined)
786 element_info[element].special_graphic[special] = graphic;
789 /* initialize special element/graphic mapping from dynamic configuration */
790 for (i = 0; i < num_property_mappings; i++)
792 int element = property_mapping[i].base_index;
793 int special = property_mapping[i].ext3_index;
794 int graphic = property_mapping[i].artwork_index;
796 if (element >= MAX_NUM_ELEMENTS)
799 if (special >= 0 && special < NUM_SPECIAL_GFX_ARGS)
800 element_info[element].special_graphic[special] = graphic;
803 /* now set all undefined/invalid graphics to default */
804 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
805 for (j = 0; j < NUM_SPECIAL_GFX_ARGS; j++)
806 if (graphic_info[element_info[i].special_graphic[j]].bitmap == NULL)
807 element_info[i].special_graphic[j] =
808 element_info[i].graphic[ACTION_DEFAULT];
811 static int get_graphic_parameter_value(char *value_raw, char *suffix, int type)
816 if (type != TYPE_TOKEN)
817 return get_parameter_value(value_raw, suffix, type);
819 if (strcmp(value_raw, ARG_UNDEFINED) == 0)
820 return ARG_UNDEFINED_VALUE;
822 /* !!! OPTIMIZE THIS BY USING HASH !!! */
823 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
824 if (strcmp(element_info[i].token_name, value_raw) == 0)
827 /* !!! OPTIMIZE THIS BY USING HASH !!! */
828 for (i = 0; image_config[i].token != NULL; i++)
830 int len_config_value = strlen(image_config[i].value);
832 if (strcmp(&image_config[i].value[len_config_value - 4], ".pcx") != 0 &&
833 strcmp(&image_config[i].value[len_config_value - 4], ".wav") != 0 &&
834 strcmp(image_config[i].value, UNDEFINED_FILENAME) != 0)
837 if (strcmp(image_config[i].token, value_raw) == 0)
846 static int get_scaled_graphic_width(int graphic)
848 int original_width = getOriginalImageWidthFromImageID(graphic);
849 int scale_up_factor = graphic_info[graphic].scale_up_factor;
851 return original_width * scale_up_factor;
854 static int get_scaled_graphic_height(int graphic)
856 int original_height = getOriginalImageHeightFromImageID(graphic);
857 int scale_up_factor = graphic_info[graphic].scale_up_factor;
859 return original_height * scale_up_factor;
862 static void set_graphic_parameters(int graphic)
864 struct FileInfo *image = getImageListEntryFromImageID(graphic);
865 char **parameter_raw = image->parameter;
866 Bitmap *src_bitmap = getBitmapFromImageID(graphic);
867 int parameter[NUM_GFX_ARGS];
868 int anim_frames_per_row = 1, anim_frames_per_col = 1;
869 int anim_frames_per_line = 1;
872 /* if fallback to default artwork is done, also use the default parameters */
873 if (image->fallback_to_default)
874 parameter_raw = image->default_parameter;
876 /* get integer values from string parameters */
877 for (i = 0; i < NUM_GFX_ARGS; i++)
878 parameter[i] = get_graphic_parameter_value(parameter_raw[i],
879 image_config_suffix[i].token,
880 image_config_suffix[i].type);
882 graphic_info[graphic].bitmap = src_bitmap;
884 /* start with reliable default values */
885 graphic_info[graphic].src_image_width = 0;
886 graphic_info[graphic].src_image_height = 0;
887 graphic_info[graphic].src_x = 0;
888 graphic_info[graphic].src_y = 0;
889 graphic_info[graphic].width = TILEX;
890 graphic_info[graphic].height = TILEY;
891 graphic_info[graphic].offset_x = 0; /* one or both of these values ... */
892 graphic_info[graphic].offset_y = 0; /* ... will be corrected later */
893 graphic_info[graphic].offset2_x = 0; /* one or both of these values ... */
894 graphic_info[graphic].offset2_y = 0; /* ... will be corrected later */
895 graphic_info[graphic].swap_double_tiles = -1; /* auto-detect tile swapping */
896 graphic_info[graphic].crumbled_like = -1; /* do not use clone element */
897 graphic_info[graphic].diggable_like = -1; /* do not use clone element */
898 graphic_info[graphic].border_size = TILEX / 8; /* "CRUMBLED" border size */
899 graphic_info[graphic].scale_up_factor = 1; /* default: no scaling up */
900 graphic_info[graphic].clone_from = -1; /* do not use clone graphic */
901 graphic_info[graphic].anim_delay_fixed = 0;
902 graphic_info[graphic].anim_delay_random = 0;
903 graphic_info[graphic].post_delay_fixed = 0;
904 graphic_info[graphic].post_delay_random = 0;
906 /* optional x and y tile position of animation frame sequence */
907 if (parameter[GFX_ARG_XPOS] != ARG_UNDEFINED_VALUE)
908 graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
909 if (parameter[GFX_ARG_YPOS] != ARG_UNDEFINED_VALUE)
910 graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
912 /* optional x and y pixel position of animation frame sequence */
913 if (parameter[GFX_ARG_X] != ARG_UNDEFINED_VALUE)
914 graphic_info[graphic].src_x = parameter[GFX_ARG_X];
915 if (parameter[GFX_ARG_Y] != ARG_UNDEFINED_VALUE)
916 graphic_info[graphic].src_y = parameter[GFX_ARG_Y];
918 /* optional width and height of each animation frame */
919 if (parameter[GFX_ARG_WIDTH] != ARG_UNDEFINED_VALUE)
920 graphic_info[graphic].width = parameter[GFX_ARG_WIDTH];
921 if (parameter[GFX_ARG_HEIGHT] != ARG_UNDEFINED_VALUE)
922 graphic_info[graphic].height = parameter[GFX_ARG_HEIGHT];
924 /* optional zoom factor for scaling up the image to a larger size */
925 if (parameter[GFX_ARG_SCALE_UP_FACTOR] != ARG_UNDEFINED_VALUE)
926 graphic_info[graphic].scale_up_factor = parameter[GFX_ARG_SCALE_UP_FACTOR];
927 if (graphic_info[graphic].scale_up_factor < 1)
928 graphic_info[graphic].scale_up_factor = 1; /* no scaling */
932 /* get final bitmap size (with scaling, but without small images) */
933 int src_image_width = get_scaled_graphic_width(graphic);
934 int src_image_height = get_scaled_graphic_height(graphic);
936 anim_frames_per_row = src_image_width / graphic_info[graphic].width;
937 anim_frames_per_col = src_image_height / graphic_info[graphic].height;
939 graphic_info[graphic].src_image_width = src_image_width;
940 graphic_info[graphic].src_image_height = src_image_height;
943 /* correct x or y offset dependent of vertical or horizontal frame order */
944 if (parameter[GFX_ARG_VERTICAL]) /* frames are ordered vertically */
946 graphic_info[graphic].offset_y =
947 (parameter[GFX_ARG_OFFSET] != ARG_UNDEFINED_VALUE ?
948 parameter[GFX_ARG_OFFSET] : graphic_info[graphic].height);
949 anim_frames_per_line = anim_frames_per_col;
951 else /* frames are ordered horizontally */
953 graphic_info[graphic].offset_x =
954 (parameter[GFX_ARG_OFFSET] != ARG_UNDEFINED_VALUE ?
955 parameter[GFX_ARG_OFFSET] : graphic_info[graphic].width);
956 anim_frames_per_line = anim_frames_per_row;
959 /* optionally, the x and y offset of frames can be specified directly */
960 if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
961 graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
962 if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
963 graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
965 /* optionally, moving animations may have separate start and end graphics */
966 graphic_info[graphic].double_movement = parameter[GFX_ARG_2ND_MOVEMENT_TILE];
968 if (parameter[GFX_ARG_2ND_VERTICAL] == ARG_UNDEFINED_VALUE)
969 parameter[GFX_ARG_2ND_VERTICAL] = !parameter[GFX_ARG_VERTICAL];
971 /* correct x or y offset2 dependent of vertical or horizontal frame order */
972 if (parameter[GFX_ARG_2ND_VERTICAL]) /* frames are ordered vertically */
973 graphic_info[graphic].offset2_y =
974 (parameter[GFX_ARG_2ND_OFFSET] != ARG_UNDEFINED_VALUE ?
975 parameter[GFX_ARG_2ND_OFFSET] : graphic_info[graphic].height);
976 else /* frames are ordered horizontally */
977 graphic_info[graphic].offset2_x =
978 (parameter[GFX_ARG_2ND_OFFSET] != ARG_UNDEFINED_VALUE ?
979 parameter[GFX_ARG_2ND_OFFSET] : graphic_info[graphic].width);
981 /* optionally, the x and y offset of 2nd graphic can be specified directly */
982 if (parameter[GFX_ARG_2ND_XOFFSET] != ARG_UNDEFINED_VALUE)
983 graphic_info[graphic].offset2_x = parameter[GFX_ARG_2ND_XOFFSET];
984 if (parameter[GFX_ARG_2ND_YOFFSET] != ARG_UNDEFINED_VALUE)
985 graphic_info[graphic].offset2_y = parameter[GFX_ARG_2ND_YOFFSET];
987 /* optionally, the second movement tile can be specified as start tile */
988 if (parameter[GFX_ARG_2ND_SWAP_TILES] != ARG_UNDEFINED_VALUE)
989 graphic_info[graphic].swap_double_tiles= parameter[GFX_ARG_2ND_SWAP_TILES];
991 /* automatically determine correct number of frames, if not defined */
992 if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
993 graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
994 else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
995 graphic_info[graphic].anim_frames = anim_frames_per_row;
996 else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
997 graphic_info[graphic].anim_frames = anim_frames_per_col;
999 graphic_info[graphic].anim_frames = 1;
1001 graphic_info[graphic].anim_frames_per_line =
1002 (parameter[GFX_ARG_FRAMES_PER_LINE] != ARG_UNDEFINED_VALUE ?
1003 parameter[GFX_ARG_FRAMES_PER_LINE] : anim_frames_per_line);
1005 graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
1006 if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
1007 graphic_info[graphic].anim_delay = 1;
1009 graphic_info[graphic].anim_mode = parameter[GFX_ARG_ANIM_MODE];
1011 if (graphic_info[graphic].anim_frames == 1)
1012 graphic_info[graphic].anim_mode = ANIM_NONE;
1015 /* automatically determine correct start frame, if not defined */
1016 if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
1017 graphic_info[graphic].anim_start_frame = 0;
1018 else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
1019 graphic_info[graphic].anim_start_frame =
1020 graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
1022 graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];
1024 /* animation synchronized with global frame counter, not move position */
1025 graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
1027 /* optional element for cloning crumble graphics */
1028 if (parameter[GFX_ARG_CRUMBLED_LIKE] != ARG_UNDEFINED_VALUE)
1029 graphic_info[graphic].crumbled_like = parameter[GFX_ARG_CRUMBLED_LIKE];
1031 /* optional element for cloning digging graphics */
1032 if (parameter[GFX_ARG_DIGGABLE_LIKE] != ARG_UNDEFINED_VALUE)
1033 graphic_info[graphic].diggable_like = parameter[GFX_ARG_DIGGABLE_LIKE];
1035 /* optional border size for "crumbling" diggable graphics */
1036 if (parameter[GFX_ARG_BORDER_SIZE] != ARG_UNDEFINED_VALUE)
1037 graphic_info[graphic].border_size = parameter[GFX_ARG_BORDER_SIZE];
1039 /* this is only used for player "boring" and "sleeping" actions */
1040 if (parameter[GFX_ARG_ANIM_DELAY_FIXED] != ARG_UNDEFINED_VALUE)
1041 graphic_info[graphic].anim_delay_fixed =
1042 parameter[GFX_ARG_ANIM_DELAY_FIXED];
1043 if (parameter[GFX_ARG_ANIM_DELAY_RANDOM] != ARG_UNDEFINED_VALUE)
1044 graphic_info[graphic].anim_delay_random =
1045 parameter[GFX_ARG_ANIM_DELAY_RANDOM];
1046 if (parameter[GFX_ARG_POST_DELAY_FIXED] != ARG_UNDEFINED_VALUE)
1047 graphic_info[graphic].post_delay_fixed =
1048 parameter[GFX_ARG_POST_DELAY_FIXED];
1049 if (parameter[GFX_ARG_POST_DELAY_RANDOM] != ARG_UNDEFINED_VALUE)
1050 graphic_info[graphic].post_delay_random =
1051 parameter[GFX_ARG_POST_DELAY_RANDOM];
1053 /* this is only used for toon animations */
1054 graphic_info[graphic].step_offset = parameter[GFX_ARG_STEP_OFFSET];
1055 graphic_info[graphic].step_delay = parameter[GFX_ARG_STEP_DELAY];
1057 /* this is only used for drawing font characters */
1058 graphic_info[graphic].draw_x = parameter[GFX_ARG_DRAW_XOFFSET];
1059 graphic_info[graphic].draw_y = parameter[GFX_ARG_DRAW_YOFFSET];
1061 /* this is only used for drawing envelope graphics */
1062 graphic_info[graphic].draw_masked = parameter[GFX_ARG_DRAW_MASKED];
1064 /* optional graphic for cloning all graphics settings */
1065 if (parameter[GFX_ARG_CLONE_FROM] != ARG_UNDEFINED_VALUE)
1066 graphic_info[graphic].clone_from = parameter[GFX_ARG_CLONE_FROM];
1069 static void set_cloned_graphic_parameters(int graphic)
1071 int fallback_graphic = IMG_CHAR_EXCLAM;
1072 int max_num_images = getImageListSize();
1073 int clone_graphic = graphic_info[graphic].clone_from;
1074 int num_references_followed = 1;
1076 while (graphic_info[clone_graphic].clone_from != -1 &&
1077 num_references_followed < max_num_images)
1079 clone_graphic = graphic_info[clone_graphic].clone_from;
1081 num_references_followed++;
1084 if (num_references_followed >= max_num_images)
1086 Error(ERR_RETURN_LINE, "-");
1087 Error(ERR_RETURN, "warning: error found in config file:");
1088 Error(ERR_RETURN, "- config file: '%s'", getImageConfigFilename());
1089 Error(ERR_RETURN, "- config token: '%s'", getTokenFromImageID(graphic));
1090 Error(ERR_RETURN, "error: loop discovered when resolving cloned graphics");
1091 Error(ERR_RETURN, "custom graphic rejected for this element/action");
1093 if (graphic == fallback_graphic)
1094 Error(ERR_EXIT, "fatal error: no fallback graphic available");
1096 Error(ERR_RETURN, "fallback done to 'char_exclam' for this graphic");
1097 Error(ERR_RETURN_LINE, "-");
1099 graphic_info[graphic] = graphic_info[fallback_graphic];
1103 graphic_info[graphic] = graphic_info[clone_graphic];
1104 graphic_info[graphic].clone_from = clone_graphic;
1108 static void InitGraphicInfo()
1110 int fallback_graphic = IMG_CHAR_EXCLAM;
1111 int num_images = getImageListSize();
1114 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1115 static boolean clipmasks_initialized = FALSE;
1117 XGCValues clip_gc_values;
1118 unsigned long clip_gc_valuemask;
1119 GC copy_clipmask_gc = None;
1122 checked_free(graphic_info);
1124 graphic_info = checked_calloc(num_images * sizeof(struct GraphicInfo));
1126 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1127 if (clipmasks_initialized)
1129 for (i = 0; i < num_images; i++)
1131 if (graphic_info[i].clip_mask)
1132 XFreePixmap(display, graphic_info[i].clip_mask);
1133 if (graphic_info[i].clip_gc)
1134 XFreeGC(display, graphic_info[i].clip_gc);
1136 graphic_info[i].clip_mask = None;
1137 graphic_info[i].clip_gc = None;
1142 /* first set all graphic paramaters ... */
1143 for (i = 0; i < num_images; i++)
1144 set_graphic_parameters(i);
1146 /* ... then copy these parameters for cloned graphics */
1147 for (i = 0; i < num_images; i++)
1148 if (graphic_info[i].clone_from != -1)
1149 set_cloned_graphic_parameters(i);
1151 for (i = 0; i < num_images; i++)
1155 int first_frame, last_frame;
1156 int src_bitmap_width, src_bitmap_height;
1158 /* now check if no animation frames are outside of the loaded image */
1160 if (graphic_info[i].bitmap == NULL)
1161 continue; /* skip check for optional images that are undefined */
1163 /* get final bitmap size (with scaling, but without small images) */
1164 src_bitmap_width = graphic_info[i].src_image_width;
1165 src_bitmap_height = graphic_info[i].src_image_height;
1167 /* check if first animation frame is inside specified bitmap */
1170 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
1172 if (src_x < 0 || src_y < 0 ||
1173 src_x + TILEX > src_bitmap_width ||
1174 src_y + TILEY > src_bitmap_height)
1176 Error(ERR_RETURN_LINE, "-");
1177 Error(ERR_RETURN, "warning: error found in config file:");
1178 Error(ERR_RETURN, "- config file: '%s'", getImageConfigFilename());
1179 Error(ERR_RETURN, "- config token: '%s'", getTokenFromImageID(i));
1180 Error(ERR_RETURN, "- image file: '%s'", src_bitmap->source_filename);
1182 "error: first animation frame out of bounds (%d, %d) [%d, %d]",
1183 src_x, src_y, src_bitmap_width, src_bitmap_height);
1184 Error(ERR_RETURN, "custom graphic rejected for this element/action");
1186 if (i == fallback_graphic)
1187 Error(ERR_EXIT, "fatal error: no fallback graphic available");
1189 Error(ERR_RETURN, "fallback done to 'char_exclam' for this graphic");
1190 Error(ERR_RETURN_LINE, "-");
1192 graphic_info[i] = graphic_info[fallback_graphic];
1195 /* check if last animation frame is inside specified bitmap */
1197 last_frame = graphic_info[i].anim_frames - 1;
1198 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
1200 if (src_x < 0 || src_y < 0 ||
1201 src_x + TILEX > src_bitmap_width ||
1202 src_y + TILEY > src_bitmap_height)
1204 Error(ERR_RETURN_LINE, "-");
1205 Error(ERR_RETURN, "warning: error found in config file:");
1206 Error(ERR_RETURN, "- config file: '%s'", getImageConfigFilename());
1207 Error(ERR_RETURN, "- config token: '%s'", getTokenFromImageID(i));
1208 Error(ERR_RETURN, "- image file: '%s'", src_bitmap->source_filename);
1210 "error: last animation frame (%d) out of bounds (%d, %d) [%d, %d]",
1211 last_frame, src_x, src_y, src_bitmap_width, src_bitmap_height);
1212 Error(ERR_RETURN, "custom graphic rejected for this element/action");
1214 if (i == fallback_graphic)
1215 Error(ERR_EXIT, "fatal error: no fallback graphic available");
1217 Error(ERR_RETURN, "fallback done to 'char_exclam' for this graphic");
1218 Error(ERR_RETURN_LINE, "-");
1220 graphic_info[i] = graphic_info[fallback_graphic];
1223 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1224 /* currently we only need a tile clip mask from the first frame */
1225 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
1227 if (copy_clipmask_gc == None)
1229 clip_gc_values.graphics_exposures = False;
1230 clip_gc_valuemask = GCGraphicsExposures;
1231 copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
1232 clip_gc_valuemask, &clip_gc_values);
1235 graphic_info[i].clip_mask =
1236 XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
1238 src_pixmap = src_bitmap->clip_mask;
1239 XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
1240 copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
1242 clip_gc_values.graphics_exposures = False;
1243 clip_gc_values.clip_mask = graphic_info[i].clip_mask;
1244 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
1246 graphic_info[i].clip_gc =
1247 XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
1251 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1252 if (copy_clipmask_gc)
1253 XFreeGC(display, copy_clipmask_gc);
1255 clipmasks_initialized = TRUE;
1259 static void InitElementSoundInfo()
1261 struct PropertyMapping *property_mapping = getSoundListPropertyMapping();
1262 int num_property_mappings = getSoundListPropertyMappingSize();
1265 /* set values to -1 to identify later as "uninitialized" values */
1266 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
1267 for (act = 0; act < NUM_ACTIONS; act++)
1268 element_info[i].sound[act] = -1;
1270 /* initialize element/sound mapping from static configuration */
1271 for (i = 0; element_to_sound[i].element > -1; i++)
1273 int element = element_to_sound[i].element;
1274 int action = element_to_sound[i].action;
1275 int sound = element_to_sound[i].sound;
1276 boolean is_class = element_to_sound[i].is_class;
1279 action = ACTION_DEFAULT;
1282 element_info[element].sound[action] = sound;
1284 for (j = 0; j < MAX_NUM_ELEMENTS; j++)
1285 if (strcmp(element_info[j].class_name,
1286 element_info[element].class_name) == 0)
1287 element_info[j].sound[action] = sound;
1290 /* initialize element class/sound mapping from dynamic configuration */
1291 for (i = 0; i < num_property_mappings; i++)
1293 int element_class = property_mapping[i].base_index - MAX_NUM_ELEMENTS;
1294 int action = property_mapping[i].ext1_index;
1295 int sound = property_mapping[i].artwork_index;
1297 if (element_class < 0 || element_class >= MAX_NUM_ELEMENTS)
1301 action = ACTION_DEFAULT;
1303 for (j = 0; j < MAX_NUM_ELEMENTS; j++)
1304 if (strcmp(element_info[j].class_name,
1305 element_info[element_class].class_name) == 0)
1306 element_info[j].sound[action] = sound;
1309 /* initialize element/sound mapping from dynamic configuration */
1310 for (i = 0; i < num_property_mappings; i++)
1312 int element = property_mapping[i].base_index;
1313 int action = property_mapping[i].ext1_index;
1314 int sound = property_mapping[i].artwork_index;
1316 if (element >= MAX_NUM_ELEMENTS)
1320 action = ACTION_DEFAULT;
1322 element_info[element].sound[action] = sound;
1325 /* now set all '-1' values to element specific default values */
1326 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
1328 for (act = 0; act < NUM_ACTIONS; act++)
1330 /* generic default action sound (defined by "[default]" directive) */
1331 int default_action_sound = element_info[EL_DEFAULT].sound[act];
1333 /* look for special default action sound (classic game specific) */
1334 if (IS_BD_ELEMENT(i) && element_info[EL_BD_DEFAULT].sound[act] != -1)
1335 default_action_sound = element_info[EL_BD_DEFAULT].sound[act];
1336 if (IS_SP_ELEMENT(i) && element_info[EL_SP_DEFAULT].sound[act] != -1)
1337 default_action_sound = element_info[EL_SP_DEFAULT].sound[act];
1338 if (IS_SB_ELEMENT(i) && element_info[EL_SB_DEFAULT].sound[act] != -1)
1339 default_action_sound = element_info[EL_SB_DEFAULT].sound[act];
1341 /* !!! there's no such thing as a "default action sound" !!! */
1343 /* look for element specific default sound (independent from action) */
1344 if (element_info[i].sound[ACTION_DEFAULT] != -1)
1345 default_action_sound = element_info[i].sound[ACTION_DEFAULT];
1349 /* !!! needed because EL_EMPTY_SPACE treated as IS_SP_ELEMENT !!! */
1350 /* !!! make this better !!! */
1351 if (i == EL_EMPTY_SPACE)
1352 default_action_sound = element_info[EL_DEFAULT].sound[act];
1355 /* no sound for this specific action -- use default action sound */
1356 if (element_info[i].sound[act] == -1)
1357 element_info[i].sound[act] = default_action_sound;
1361 /* copy sound settings to some elements that are only stored in level file
1362 in native R'n'D levels, but are used by game engine in native EM levels */
1363 for (i = 0; copy_properties[i][0] != -1; i++)
1364 for (j = 1; j <= 4; j++)
1365 for (act = 0; act < NUM_ACTIONS; act++)
1366 element_info[copy_properties[i][j]].sound[act] =
1367 element_info[copy_properties[i][0]].sound[act];
1370 static void InitGameModeSoundInfo()
1374 /* set values to -1 to identify later as "uninitialized" values */
1375 for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++)
1378 /* initialize gamemode/sound mapping from static configuration */
1379 for (i = 0; gamemode_to_sound[i].sound > -1; i++)
1381 int gamemode = gamemode_to_sound[i].gamemode;
1382 int sound = gamemode_to_sound[i].sound;
1385 gamemode = GAME_MODE_DEFAULT;
1387 menu.sound[gamemode] = sound;
1390 /* now set all '-1' values to levelset specific default values */
1391 for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++)
1392 if (menu.sound[i] == -1)
1393 menu.sound[i] = menu.sound[GAME_MODE_DEFAULT];
1396 for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++)
1397 if (menu.sound[i] != -1)
1398 printf("::: menu.sound[%d] == %d\n", i, menu.sound[i]);
1402 static void set_sound_parameters(int sound, char **parameter_raw)
1404 int parameter[NUM_SND_ARGS];
1407 /* get integer values from string parameters */
1408 for (i = 0; i < NUM_SND_ARGS; i++)
1410 get_parameter_value(parameter_raw[i],
1411 sound_config_suffix[i].token,
1412 sound_config_suffix[i].type);
1414 /* explicit loop mode setting in configuration overrides default value */
1415 if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
1416 sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP];
1418 /* sound volume to change the original volume when loading the sound file */
1419 sound_info[sound].volume = parameter[SND_ARG_VOLUME];
1421 /* sound priority to give certain sounds a higher or lower priority */
1422 sound_info[sound].volume = parameter[SND_ARG_VOLUME];
1425 static void InitSoundInfo()
1427 int *sound_effect_properties;
1428 int num_sounds = getSoundListSize();
1431 checked_free(sound_info);
1433 sound_effect_properties = checked_calloc(num_sounds * sizeof(int));
1434 sound_info = checked_calloc(num_sounds * sizeof(struct SoundInfo));
1436 /* initialize sound effect for all elements to "no sound" */
1437 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
1438 for (j = 0; j < NUM_ACTIONS; j++)
1439 element_info[i].sound[j] = SND_UNDEFINED;
1441 for (i = 0; i < num_sounds; i++)
1443 struct FileInfo *sound = getSoundListEntry(i);
1444 int len_effect_text = strlen(sound->token);
1446 sound_effect_properties[i] = ACTION_OTHER;
1447 sound_info[i].loop = FALSE; /* default: play sound only once */
1450 printf("::: sound %d: '%s'\n", i, sound->token);
1453 /* determine all loop sounds and identify certain sound classes */
1455 for (j = 0; element_action_info[j].suffix; j++)
1457 int len_action_text = strlen(element_action_info[j].suffix);
1459 if (len_action_text < len_effect_text &&
1460 strcmp(&sound->token[len_effect_text - len_action_text],
1461 element_action_info[j].suffix) == 0)
1463 sound_effect_properties[i] = element_action_info[j].value;
1464 sound_info[i].loop = element_action_info[j].is_loop_sound;
1470 /* associate elements and some selected sound actions */
1472 for (j = 0; j < MAX_NUM_ELEMENTS; j++)
1474 if (element_info[j].class_name)
1476 int len_class_text = strlen(element_info[j].class_name);
1478 if (len_class_text + 1 < len_effect_text &&
1479 strncmp(sound->token,
1480 element_info[j].class_name, len_class_text) == 0 &&
1481 sound->token[len_class_text] == '.')
1483 int sound_action_value = sound_effect_properties[i];
1485 element_info[j].sound[sound_action_value] = i;
1490 set_sound_parameters(i, sound->parameter);
1493 free(sound_effect_properties);
1496 static void InitGameModeMusicInfo()
1498 struct PropertyMapping *property_mapping = getMusicListPropertyMapping();
1499 int num_property_mappings = getMusicListPropertyMappingSize();
1500 int default_levelset_music = -1;
1503 /* set values to -1 to identify later as "uninitialized" values */
1504 for (i = 0; i < MAX_LEVELS; i++)
1505 levelset.music[i] = -1;
1506 for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++)
1509 /* initialize gamemode/music mapping from static configuration */
1510 for (i = 0; gamemode_to_music[i].music > -1; i++)
1512 int gamemode = gamemode_to_music[i].gamemode;
1513 int music = gamemode_to_music[i].music;
1516 printf("::: gamemode == %d, music == %d\n", gamemode, music);
1520 gamemode = GAME_MODE_DEFAULT;
1522 menu.music[gamemode] = music;
1525 /* initialize gamemode/music mapping from dynamic configuration */
1526 for (i = 0; i < num_property_mappings; i++)
1528 int prefix = property_mapping[i].base_index;
1529 int gamemode = property_mapping[i].ext1_index;
1530 int level = property_mapping[i].ext2_index;
1531 int music = property_mapping[i].artwork_index;
1534 printf("::: prefix == %d, gamemode == %d, level == %d, music == %d\n",
1535 prefix, gamemode, level, music);
1538 if (prefix < 0 || prefix >= NUM_MUSIC_PREFIXES)
1542 gamemode = GAME_MODE_DEFAULT;
1544 /* level specific music only allowed for in-game music */
1545 if (level != -1 && gamemode == GAME_MODE_DEFAULT)
1546 gamemode = GAME_MODE_PLAYING;
1551 default_levelset_music = music;
1554 if (gamemode == GAME_MODE_PLAYING || gamemode == GAME_MODE_DEFAULT)
1555 levelset.music[level] = music;
1556 if (gamemode != GAME_MODE_PLAYING)
1557 menu.music[gamemode] = music;
1560 /* now set all '-1' values to menu specific default values */
1561 /* (undefined values of "levelset.music[]" might stay at "-1" to
1562 allow dynamic selection of music files from music directory!) */
1563 for (i = 0; i < MAX_LEVELS; i++)
1564 if (levelset.music[i] == -1)
1565 levelset.music[i] = default_levelset_music;
1566 for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++)
1567 if (menu.music[i] == -1)
1568 menu.music[i] = menu.music[GAME_MODE_DEFAULT];
1571 for (i = 0; i < MAX_LEVELS; i++)
1572 if (levelset.music[i] != -1)
1573 printf("::: levelset.music[%d] == %d\n", i, levelset.music[i]);
1574 for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++)
1575 if (menu.music[i] != -1)
1576 printf("::: menu.music[%d] == %d\n", i, menu.music[i]);
1580 static void set_music_parameters(int music, char **parameter_raw)
1582 int parameter[NUM_MUS_ARGS];
1585 /* get integer values from string parameters */
1586 for (i = 0; i < NUM_MUS_ARGS; i++)
1588 get_parameter_value(parameter_raw[i],
1589 music_config_suffix[i].token,
1590 music_config_suffix[i].type);
1592 /* explicit loop mode setting in configuration overrides default value */
1593 if (parameter[MUS_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
1594 music_info[music].loop = parameter[MUS_ARG_MODE_LOOP];
1597 static void InitMusicInfo()
1599 int num_music = getMusicListSize();
1602 checked_free(music_info);
1604 music_info = checked_calloc(num_music * sizeof(struct MusicInfo));
1606 for (i = 0; i < num_music; i++)
1608 struct FileInfo *music = getMusicListEntry(i);
1609 int len_music_text = strlen(music->token);
1611 music_info[i].loop = TRUE; /* default: play music in loop mode */
1613 /* determine all loop music */
1615 for (j = 0; music_prefix_info[j].prefix; j++)
1617 int len_prefix_text = strlen(music_prefix_info[j].prefix);
1619 if (len_prefix_text < len_music_text &&
1620 strncmp(music->token,
1621 music_prefix_info[j].prefix, len_prefix_text) == 0)
1623 music_info[i].loop = music_prefix_info[j].is_loop_music;
1629 set_music_parameters(i, music->parameter);
1633 static void ReinitializeGraphics()
1635 InitGraphicInfo(); /* graphic properties mapping */
1636 InitElementGraphicInfo(); /* element game graphic mapping */
1637 InitElementSpecialGraphicInfo(); /* element special graphic mapping */
1639 InitElementSmallImages(); /* scale images to all needed sizes */
1640 InitFontGraphicInfo(); /* initialize text drawing functions */
1642 InitGraphicInfo_EM(); /* graphic mapping for EM engine */
1644 SetMainBackgroundImage(IMG_BACKGROUND);
1645 SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
1651 static void ReinitializeSounds()
1653 InitSoundInfo(); /* sound properties mapping */
1654 InitElementSoundInfo(); /* element game sound mapping */
1655 InitGameModeSoundInfo(); /* game mode sound mapping */
1657 InitPlayLevelSound(); /* internal game sound settings */
1660 static void ReinitializeMusic()
1662 InitMusicInfo(); /* music properties mapping */
1663 InitGameModeMusicInfo(); /* game mode music mapping */
1666 static int get_special_property_bit(int element, int property_bit_nr)
1668 struct PropertyBitInfo
1674 static struct PropertyBitInfo pb_can_move_into_acid[] =
1676 /* the player may be able fall into acid when gravity is activated */
1681 { EL_SP_MURPHY, 0 },
1682 { EL_SOKOBAN_FIELD_PLAYER, 0 },
1684 /* all elements that can move may be able to also move into acid */
1687 { EL_BUG_RIGHT, 1 },
1690 { EL_SPACESHIP, 2 },
1691 { EL_SPACESHIP_LEFT, 2 },
1692 { EL_SPACESHIP_RIGHT, 2 },
1693 { EL_SPACESHIP_UP, 2 },
1694 { EL_SPACESHIP_DOWN, 2 },
1695 { EL_BD_BUTTERFLY, 3 },
1696 { EL_BD_BUTTERFLY_LEFT, 3 },
1697 { EL_BD_BUTTERFLY_RIGHT, 3 },
1698 { EL_BD_BUTTERFLY_UP, 3 },
1699 { EL_BD_BUTTERFLY_DOWN, 3 },
1700 { EL_BD_FIREFLY, 4 },
1701 { EL_BD_FIREFLY_LEFT, 4 },
1702 { EL_BD_FIREFLY_RIGHT, 4 },
1703 { EL_BD_FIREFLY_UP, 4 },
1704 { EL_BD_FIREFLY_DOWN, 4 },
1706 { EL_DARK_YAMYAM, 6 },
1709 { EL_PACMAN_LEFT, 8 },
1710 { EL_PACMAN_RIGHT, 8 },
1711 { EL_PACMAN_UP, 8 },
1712 { EL_PACMAN_DOWN, 8 },
1714 { EL_MOLE_LEFT, 9 },
1715 { EL_MOLE_RIGHT, 9 },
1717 { EL_MOLE_DOWN, 9 },
1721 { EL_SATELLITE, 13 },
1722 { EL_SP_SNIKSNAK, 14 },
1723 { EL_SP_ELECTRON, 15 },
1726 { EL_EMC_ANDROID, 18 },
1731 static struct PropertyBitInfo pb_dont_collide_with[] =
1733 { EL_SP_SNIKSNAK, 0 },
1734 { EL_SP_ELECTRON, 1 },
1742 struct PropertyBitInfo *pb_info;
1745 { EP_CAN_MOVE_INTO_ACID, pb_can_move_into_acid },
1746 { EP_DONT_COLLIDE_WITH, pb_dont_collide_with },
1751 struct PropertyBitInfo *pb_info = NULL;
1754 for (i = 0; pb_definition[i].bit_nr != -1; i++)
1755 if (pb_definition[i].bit_nr == property_bit_nr)
1756 pb_info = pb_definition[i].pb_info;
1758 if (pb_info == NULL)
1761 for (i = 0; pb_info[i].element != -1; i++)
1762 if (pb_info[i].element == element)
1763 return pb_info[i].bit_nr;
1768 void setBitfieldProperty(int *bitfield, int property_bit_nr, int element,
1769 boolean property_value)
1771 int bit_nr = get_special_property_bit(element, property_bit_nr);
1776 *bitfield |= (1 << bit_nr);
1778 *bitfield &= ~(1 << bit_nr);
1782 boolean getBitfieldProperty(int *bitfield, int property_bit_nr, int element)
1784 int bit_nr = get_special_property_bit(element, property_bit_nr);
1787 return ((*bitfield & (1 << bit_nr)) != 0);
1793 static void resolve_group_element(int group_element, int recursion_depth)
1795 static int group_nr;
1796 static struct ElementGroupInfo *group;
1797 struct ElementGroupInfo *actual_group = element_info[group_element].group;
1800 if (actual_group == NULL) /* not yet initialized */
1803 if (recursion_depth > NUM_GROUP_ELEMENTS) /* recursion too deep */
1805 Error(ERR_WARN, "recursion too deep when resolving group element %d",
1806 group_element - EL_GROUP_START + 1);
1808 /* replace element which caused too deep recursion by question mark */
1809 group->element_resolved[group->num_elements_resolved++] = EL_UNKNOWN;
1814 if (recursion_depth == 0) /* initialization */
1816 group = actual_group;
1817 group_nr = group_element - EL_GROUP_START;
1819 group->num_elements_resolved = 0;
1820 group->choice_pos = 0;
1823 for (i = 0; i < actual_group->num_elements; i++)
1825 int element = actual_group->element[i];
1827 if (group->num_elements_resolved == NUM_FILE_ELEMENTS)
1830 if (IS_GROUP_ELEMENT(element))
1831 resolve_group_element(element, recursion_depth + 1);
1834 group->element_resolved[group->num_elements_resolved++] = element;
1835 element_info[element].in_group[group_nr] = TRUE;
1841 void InitElementPropertiesStatic()
1843 static int ep_diggable[] =
1848 EL_SP_BUGGY_BASE_ACTIVATING,
1851 EL_INVISIBLE_SAND_ACTIVE,
1854 /* !!! currently not diggable, but handled by 'ep_dont_run_into' !!! */
1855 /* (if amoeba can grow into anything diggable, maybe keep these out) */
1859 EL_SP_BUGGY_BASE_ACTIVE,
1866 static int ep_collectible_only[] =
1887 EL_DYNABOMB_INCREASE_NUMBER,
1888 EL_DYNABOMB_INCREASE_SIZE,
1889 EL_DYNABOMB_INCREASE_POWER,
1909 static int ep_dont_run_into[] =
1911 /* same elements as in 'ep_dont_touch' */
1917 /* same elements as in 'ep_dont_collide_with' */
1929 /* !!! maybe this should better be handled by 'ep_diggable' !!! */
1933 EL_SP_BUGGY_BASE_ACTIVE,
1940 static int ep_dont_collide_with[] =
1942 /* same elements as in 'ep_dont_touch' */
1959 static int ep_dont_touch[] =
1969 static int ep_indestructible[] =
1973 EL_ACID_POOL_TOPLEFT,
1974 EL_ACID_POOL_TOPRIGHT,
1975 EL_ACID_POOL_BOTTOMLEFT,
1976 EL_ACID_POOL_BOTTOM,
1977 EL_ACID_POOL_BOTTOMRIGHT,
1978 EL_SP_HARDWARE_GRAY,
1979 EL_SP_HARDWARE_GREEN,
1980 EL_SP_HARDWARE_BLUE,
1982 EL_SP_HARDWARE_YELLOW,
1983 EL_SP_HARDWARE_BASE_1,
1984 EL_SP_HARDWARE_BASE_2,
1985 EL_SP_HARDWARE_BASE_3,
1986 EL_SP_HARDWARE_BASE_4,
1987 EL_SP_HARDWARE_BASE_5,
1988 EL_SP_HARDWARE_BASE_6,
1989 EL_INVISIBLE_STEELWALL,
1990 EL_INVISIBLE_STEELWALL_ACTIVE,
1991 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
1992 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
1993 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
1994 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
1995 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
1996 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
1997 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
1998 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
1999 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
2000 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
2001 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
2002 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
2004 EL_LIGHT_SWITCH_ACTIVE,
2005 EL_SIGN_EXCLAMATION,
2006 EL_SIGN_RADIOACTIVITY,
2017 EL_STEELWALL_SLIPPERY,
2031 EL_GATE_1_GRAY_ACTIVE,
2032 EL_GATE_2_GRAY_ACTIVE,
2033 EL_GATE_3_GRAY_ACTIVE,
2034 EL_GATE_4_GRAY_ACTIVE,
2043 EL_EM_GATE_1_GRAY_ACTIVE,
2044 EL_EM_GATE_2_GRAY_ACTIVE,
2045 EL_EM_GATE_3_GRAY_ACTIVE,
2046 EL_EM_GATE_4_GRAY_ACTIVE,
2055 EL_EMC_GATE_5_GRAY_ACTIVE,
2056 EL_EMC_GATE_6_GRAY_ACTIVE,
2057 EL_EMC_GATE_7_GRAY_ACTIVE,
2058 EL_EMC_GATE_8_GRAY_ACTIVE,
2060 EL_SWITCHGATE_OPENING,
2061 EL_SWITCHGATE_CLOSED,
2062 EL_SWITCHGATE_CLOSING,
2064 EL_SWITCHGATE_SWITCH_UP,
2065 EL_SWITCHGATE_SWITCH_DOWN,
2068 EL_TIMEGATE_OPENING,
2070 EL_TIMEGATE_CLOSING,
2073 EL_TIMEGATE_SWITCH_ACTIVE,
2078 EL_TUBE_VERTICAL_LEFT,
2079 EL_TUBE_VERTICAL_RIGHT,
2080 EL_TUBE_HORIZONTAL_UP,
2081 EL_TUBE_HORIZONTAL_DOWN,
2090 static int ep_slippery[] =
2104 EL_ROBOT_WHEEL_ACTIVE,
2110 EL_ACID_POOL_TOPLEFT,
2111 EL_ACID_POOL_TOPRIGHT,
2121 EL_STEELWALL_SLIPPERY,
2124 EL_EMC_WALL_SLIPPERY_1,
2125 EL_EMC_WALL_SLIPPERY_2,
2126 EL_EMC_WALL_SLIPPERY_3,
2127 EL_EMC_WALL_SLIPPERY_4,
2129 EL_EMC_MAGIC_BALL_ACTIVE,
2134 static int ep_can_change[] =
2139 static int ep_can_move[] =
2141 /* same elements as in 'pb_can_move_into_acid' */
2164 static int ep_can_fall[] =
2179 EL_BD_MAGIC_WALL_FULL,
2193 static int ep_can_smash_player[] =
2219 static int ep_can_smash_enemies[] =
2228 static int ep_can_smash_everything[] =
2237 static int ep_explodes_by_fire[] =
2239 /* same elements as in 'ep_explodes_impact' */
2244 /* same elements as in 'ep_explodes_smashed' */
2253 EL_DYNABOMB_PLAYER_1_ACTIVE,
2254 EL_DYNABOMB_PLAYER_2_ACTIVE,
2255 EL_DYNABOMB_PLAYER_3_ACTIVE,
2256 EL_DYNABOMB_PLAYER_4_ACTIVE,
2257 EL_DYNABOMB_INCREASE_NUMBER,
2258 EL_DYNABOMB_INCREASE_SIZE,
2259 EL_DYNABOMB_INCREASE_POWER,
2260 EL_SP_DISK_RED_ACTIVE,
2274 static int ep_explodes_smashed[] =
2276 /* same elements as in 'ep_explodes_impact' */
2290 static int ep_explodes_impact[] =
2299 static int ep_walkable_over[] =
2303 EL_SOKOBAN_FIELD_EMPTY,
2315 EL_GATE_1_GRAY_ACTIVE,
2316 EL_GATE_2_GRAY_ACTIVE,
2317 EL_GATE_3_GRAY_ACTIVE,
2318 EL_GATE_4_GRAY_ACTIVE,
2326 static int ep_walkable_inside[] =
2331 EL_TUBE_VERTICAL_LEFT,
2332 EL_TUBE_VERTICAL_RIGHT,
2333 EL_TUBE_HORIZONTAL_UP,
2334 EL_TUBE_HORIZONTAL_DOWN,
2343 static int ep_walkable_under[] =
2348 static int ep_passable_over[] =
2358 EL_EM_GATE_1_GRAY_ACTIVE,
2359 EL_EM_GATE_2_GRAY_ACTIVE,
2360 EL_EM_GATE_3_GRAY_ACTIVE,
2361 EL_EM_GATE_4_GRAY_ACTIVE,
2370 EL_EMC_GATE_5_GRAY_ACTIVE,
2371 EL_EMC_GATE_6_GRAY_ACTIVE,
2372 EL_EMC_GATE_7_GRAY_ACTIVE,
2373 EL_EMC_GATE_8_GRAY_ACTIVE,
2380 static int ep_passable_inside[] =
2386 EL_SP_PORT_HORIZONTAL,
2387 EL_SP_PORT_VERTICAL,
2389 EL_SP_GRAVITY_PORT_LEFT,
2390 EL_SP_GRAVITY_PORT_RIGHT,
2391 EL_SP_GRAVITY_PORT_UP,
2392 EL_SP_GRAVITY_PORT_DOWN,
2393 EL_SP_GRAVITY_ON_PORT_LEFT,
2394 EL_SP_GRAVITY_ON_PORT_RIGHT,
2395 EL_SP_GRAVITY_ON_PORT_UP,
2396 EL_SP_GRAVITY_ON_PORT_DOWN,
2397 EL_SP_GRAVITY_OFF_PORT_LEFT,
2398 EL_SP_GRAVITY_OFF_PORT_RIGHT,
2399 EL_SP_GRAVITY_OFF_PORT_UP,
2400 EL_SP_GRAVITY_OFF_PORT_DOWN,
2405 static int ep_passable_under[] =
2410 static int ep_droppable[] =
2415 static int ep_explodes_1x1_old[] =
2420 static int ep_pushable[] =
2432 EL_SOKOBAN_FIELD_FULL,
2441 static int ep_explodes_cross_old[] =
2446 static int ep_protected[] =
2448 /* same elements as in 'ep_walkable_inside' */
2452 EL_TUBE_VERTICAL_LEFT,
2453 EL_TUBE_VERTICAL_RIGHT,
2454 EL_TUBE_HORIZONTAL_UP,
2455 EL_TUBE_HORIZONTAL_DOWN,
2461 /* same elements as in 'ep_passable_over' */
2470 EL_EM_GATE_1_GRAY_ACTIVE,
2471 EL_EM_GATE_2_GRAY_ACTIVE,
2472 EL_EM_GATE_3_GRAY_ACTIVE,
2473 EL_EM_GATE_4_GRAY_ACTIVE,
2482 EL_EMC_GATE_5_GRAY_ACTIVE,
2483 EL_EMC_GATE_6_GRAY_ACTIVE,
2484 EL_EMC_GATE_7_GRAY_ACTIVE,
2485 EL_EMC_GATE_8_GRAY_ACTIVE,
2489 /* same elements as in 'ep_passable_inside' */
2494 EL_SP_PORT_HORIZONTAL,
2495 EL_SP_PORT_VERTICAL,
2497 EL_SP_GRAVITY_PORT_LEFT,
2498 EL_SP_GRAVITY_PORT_RIGHT,
2499 EL_SP_GRAVITY_PORT_UP,
2500 EL_SP_GRAVITY_PORT_DOWN,
2501 EL_SP_GRAVITY_ON_PORT_LEFT,
2502 EL_SP_GRAVITY_ON_PORT_RIGHT,
2503 EL_SP_GRAVITY_ON_PORT_UP,
2504 EL_SP_GRAVITY_ON_PORT_DOWN,
2505 EL_SP_GRAVITY_OFF_PORT_LEFT,
2506 EL_SP_GRAVITY_OFF_PORT_RIGHT,
2507 EL_SP_GRAVITY_OFF_PORT_UP,
2508 EL_SP_GRAVITY_OFF_PORT_DOWN,
2513 static int ep_throwable[] =
2518 static int ep_can_explode[] =
2520 /* same elements as in 'ep_explodes_impact' */
2525 /* same elements as in 'ep_explodes_smashed' */
2531 /* elements that can explode by explosion or by dragonfire */
2534 EL_DYNABOMB_PLAYER_1_ACTIVE,
2535 EL_DYNABOMB_PLAYER_2_ACTIVE,
2536 EL_DYNABOMB_PLAYER_3_ACTIVE,
2537 EL_DYNABOMB_PLAYER_4_ACTIVE,
2538 EL_DYNABOMB_INCREASE_NUMBER,
2539 EL_DYNABOMB_INCREASE_SIZE,
2540 EL_DYNABOMB_INCREASE_POWER,
2541 EL_SP_DISK_RED_ACTIVE,
2549 /* elements that can explode only by explosion */
2555 static int ep_gravity_reachable[] =
2561 EL_INVISIBLE_SAND_ACTIVE,
2566 EL_SP_PORT_HORIZONTAL,
2567 EL_SP_PORT_VERTICAL,
2569 EL_SP_GRAVITY_PORT_LEFT,
2570 EL_SP_GRAVITY_PORT_RIGHT,
2571 EL_SP_GRAVITY_PORT_UP,
2572 EL_SP_GRAVITY_PORT_DOWN,
2573 EL_SP_GRAVITY_ON_PORT_LEFT,
2574 EL_SP_GRAVITY_ON_PORT_RIGHT,
2575 EL_SP_GRAVITY_ON_PORT_UP,
2576 EL_SP_GRAVITY_ON_PORT_DOWN,
2577 EL_SP_GRAVITY_OFF_PORT_LEFT,
2578 EL_SP_GRAVITY_OFF_PORT_RIGHT,
2579 EL_SP_GRAVITY_OFF_PORT_UP,
2580 EL_SP_GRAVITY_OFF_PORT_DOWN,
2586 static int ep_player[] =
2593 EL_SOKOBAN_FIELD_PLAYER,
2599 static int ep_can_pass_magic_wall[] =
2613 static int ep_switchable[] =
2617 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
2618 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
2619 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
2620 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
2621 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
2622 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
2623 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
2624 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
2625 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
2626 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
2627 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
2628 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
2629 EL_SWITCHGATE_SWITCH_UP,
2630 EL_SWITCHGATE_SWITCH_DOWN,
2632 EL_LIGHT_SWITCH_ACTIVE,
2634 EL_BALLOON_SWITCH_LEFT,
2635 EL_BALLOON_SWITCH_RIGHT,
2636 EL_BALLOON_SWITCH_UP,
2637 EL_BALLOON_SWITCH_DOWN,
2638 EL_BALLOON_SWITCH_ANY,
2639 EL_BALLOON_SWITCH_NONE,
2642 EL_EMC_MAGIC_BALL_SWITCH,
2643 EL_EMC_MAGIC_BALL_SWITCH_ACTIVE,
2648 static int ep_bd_element[] =
2682 static int ep_sp_element[] =
2684 /* should always be valid */
2687 /* standard classic Supaplex elements */
2694 EL_SP_HARDWARE_GRAY,
2702 EL_SP_GRAVITY_PORT_RIGHT,
2703 EL_SP_GRAVITY_PORT_DOWN,
2704 EL_SP_GRAVITY_PORT_LEFT,
2705 EL_SP_GRAVITY_PORT_UP,
2710 EL_SP_PORT_VERTICAL,
2711 EL_SP_PORT_HORIZONTAL,
2717 EL_SP_HARDWARE_BASE_1,
2718 EL_SP_HARDWARE_GREEN,
2719 EL_SP_HARDWARE_BLUE,
2721 EL_SP_HARDWARE_YELLOW,
2722 EL_SP_HARDWARE_BASE_2,
2723 EL_SP_HARDWARE_BASE_3,
2724 EL_SP_HARDWARE_BASE_4,
2725 EL_SP_HARDWARE_BASE_5,
2726 EL_SP_HARDWARE_BASE_6,
2730 /* additional elements that appeared in newer Supaplex levels */
2733 /* additional gravity port elements (not switching, but setting gravity) */
2734 EL_SP_GRAVITY_ON_PORT_LEFT,
2735 EL_SP_GRAVITY_ON_PORT_RIGHT,
2736 EL_SP_GRAVITY_ON_PORT_UP,
2737 EL_SP_GRAVITY_ON_PORT_DOWN,
2738 EL_SP_GRAVITY_OFF_PORT_LEFT,
2739 EL_SP_GRAVITY_OFF_PORT_RIGHT,
2740 EL_SP_GRAVITY_OFF_PORT_UP,
2741 EL_SP_GRAVITY_OFF_PORT_DOWN,
2743 /* more than one Murphy in a level results in an inactive clone */
2746 /* runtime Supaplex elements */
2747 EL_SP_DISK_RED_ACTIVE,
2748 EL_SP_TERMINAL_ACTIVE,
2749 EL_SP_BUGGY_BASE_ACTIVATING,
2750 EL_SP_BUGGY_BASE_ACTIVE,
2757 static int ep_sb_element[] =
2762 EL_SOKOBAN_FIELD_EMPTY,
2763 EL_SOKOBAN_FIELD_FULL,
2764 EL_SOKOBAN_FIELD_PLAYER,
2769 EL_INVISIBLE_STEELWALL,
2774 static int ep_gem[] =
2786 static int ep_food_dark_yamyam[] =
2814 static int ep_food_penguin[] =
2828 static int ep_food_pig[] =
2840 static int ep_historic_wall[] =
2851 EL_GATE_1_GRAY_ACTIVE,
2852 EL_GATE_2_GRAY_ACTIVE,
2853 EL_GATE_3_GRAY_ACTIVE,
2854 EL_GATE_4_GRAY_ACTIVE,
2863 EL_EM_GATE_1_GRAY_ACTIVE,
2864 EL_EM_GATE_2_GRAY_ACTIVE,
2865 EL_EM_GATE_3_GRAY_ACTIVE,
2866 EL_EM_GATE_4_GRAY_ACTIVE,
2873 EL_EXPANDABLE_WALL_HORIZONTAL,
2874 EL_EXPANDABLE_WALL_VERTICAL,
2875 EL_EXPANDABLE_WALL_ANY,
2876 EL_EXPANDABLE_WALL_GROWING,
2883 EL_SP_HARDWARE_GRAY,
2884 EL_SP_HARDWARE_GREEN,
2885 EL_SP_HARDWARE_BLUE,
2887 EL_SP_HARDWARE_YELLOW,
2888 EL_SP_HARDWARE_BASE_1,
2889 EL_SP_HARDWARE_BASE_2,
2890 EL_SP_HARDWARE_BASE_3,
2891 EL_SP_HARDWARE_BASE_4,
2892 EL_SP_HARDWARE_BASE_5,
2893 EL_SP_HARDWARE_BASE_6,
2895 EL_SP_TERMINAL_ACTIVE,
2898 EL_INVISIBLE_STEELWALL,
2899 EL_INVISIBLE_STEELWALL_ACTIVE,
2901 EL_INVISIBLE_WALL_ACTIVE,
2902 EL_STEELWALL_SLIPPERY,
2919 static int ep_historic_solid[] =
2923 EL_EXPANDABLE_WALL_HORIZONTAL,
2924 EL_EXPANDABLE_WALL_VERTICAL,
2925 EL_EXPANDABLE_WALL_ANY,
2938 EL_QUICKSAND_FILLING,
2939 EL_QUICKSAND_EMPTYING,
2941 EL_MAGIC_WALL_ACTIVE,
2942 EL_MAGIC_WALL_EMPTYING,
2943 EL_MAGIC_WALL_FILLING,
2947 EL_BD_MAGIC_WALL_ACTIVE,
2948 EL_BD_MAGIC_WALL_EMPTYING,
2949 EL_BD_MAGIC_WALL_FULL,
2950 EL_BD_MAGIC_WALL_FILLING,
2951 EL_BD_MAGIC_WALL_DEAD,
2960 EL_SP_TERMINAL_ACTIVE,
2964 EL_INVISIBLE_WALL_ACTIVE,
2965 EL_SWITCHGATE_SWITCH_UP,
2966 EL_SWITCHGATE_SWITCH_DOWN,
2968 EL_TIMEGATE_SWITCH_ACTIVE,
2980 /* the following elements are a direct copy of "indestructible" elements,
2981 except "EL_ACID", which is "indestructible", but not "solid"! */
2986 EL_ACID_POOL_TOPLEFT,
2987 EL_ACID_POOL_TOPRIGHT,
2988 EL_ACID_POOL_BOTTOMLEFT,
2989 EL_ACID_POOL_BOTTOM,
2990 EL_ACID_POOL_BOTTOMRIGHT,
2991 EL_SP_HARDWARE_GRAY,
2992 EL_SP_HARDWARE_GREEN,
2993 EL_SP_HARDWARE_BLUE,
2995 EL_SP_HARDWARE_YELLOW,
2996 EL_SP_HARDWARE_BASE_1,
2997 EL_SP_HARDWARE_BASE_2,
2998 EL_SP_HARDWARE_BASE_3,
2999 EL_SP_HARDWARE_BASE_4,
3000 EL_SP_HARDWARE_BASE_5,
3001 EL_SP_HARDWARE_BASE_6,
3002 EL_INVISIBLE_STEELWALL,
3003 EL_INVISIBLE_STEELWALL_ACTIVE,
3004 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
3005 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
3006 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
3007 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
3008 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
3009 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
3010 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
3011 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
3012 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
3013 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
3014 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
3015 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
3017 EL_LIGHT_SWITCH_ACTIVE,
3018 EL_SIGN_EXCLAMATION,
3019 EL_SIGN_RADIOACTIVITY,
3030 EL_STEELWALL_SLIPPERY,
3044 EL_GATE_1_GRAY_ACTIVE,
3045 EL_GATE_2_GRAY_ACTIVE,
3046 EL_GATE_3_GRAY_ACTIVE,
3047 EL_GATE_4_GRAY_ACTIVE,
3056 EL_EM_GATE_1_GRAY_ACTIVE,
3057 EL_EM_GATE_2_GRAY_ACTIVE,
3058 EL_EM_GATE_3_GRAY_ACTIVE,
3059 EL_EM_GATE_4_GRAY_ACTIVE,
3061 EL_SWITCHGATE_OPENING,
3062 EL_SWITCHGATE_CLOSED,
3063 EL_SWITCHGATE_CLOSING,
3065 EL_TIMEGATE_OPENING,
3067 EL_TIMEGATE_CLOSING,
3071 EL_TUBE_VERTICAL_LEFT,
3072 EL_TUBE_VERTICAL_RIGHT,
3073 EL_TUBE_HORIZONTAL_UP,
3074 EL_TUBE_HORIZONTAL_DOWN,
3083 static int ep_classic_enemy[] =
3100 static int ep_belt[] =
3102 EL_CONVEYOR_BELT_1_LEFT,
3103 EL_CONVEYOR_BELT_1_MIDDLE,
3104 EL_CONVEYOR_BELT_1_RIGHT,
3105 EL_CONVEYOR_BELT_2_LEFT,
3106 EL_CONVEYOR_BELT_2_MIDDLE,
3107 EL_CONVEYOR_BELT_2_RIGHT,
3108 EL_CONVEYOR_BELT_3_LEFT,
3109 EL_CONVEYOR_BELT_3_MIDDLE,
3110 EL_CONVEYOR_BELT_3_RIGHT,
3111 EL_CONVEYOR_BELT_4_LEFT,
3112 EL_CONVEYOR_BELT_4_MIDDLE,
3113 EL_CONVEYOR_BELT_4_RIGHT,
3118 static int ep_belt_active[] =
3120 EL_CONVEYOR_BELT_1_LEFT_ACTIVE,
3121 EL_CONVEYOR_BELT_1_MIDDLE_ACTIVE,
3122 EL_CONVEYOR_BELT_1_RIGHT_ACTIVE,
3123 EL_CONVEYOR_BELT_2_LEFT_ACTIVE,
3124 EL_CONVEYOR_BELT_2_MIDDLE_ACTIVE,
3125 EL_CONVEYOR_BELT_2_RIGHT_ACTIVE,
3126 EL_CONVEYOR_BELT_3_LEFT_ACTIVE,
3127 EL_CONVEYOR_BELT_3_MIDDLE_ACTIVE,
3128 EL_CONVEYOR_BELT_3_RIGHT_ACTIVE,
3129 EL_CONVEYOR_BELT_4_LEFT_ACTIVE,
3130 EL_CONVEYOR_BELT_4_MIDDLE_ACTIVE,
3131 EL_CONVEYOR_BELT_4_RIGHT_ACTIVE,
3136 static int ep_belt_switch[] =
3138 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
3139 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
3140 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
3141 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
3142 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
3143 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
3144 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
3145 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
3146 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
3147 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
3148 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
3149 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
3154 static int ep_tube[] =
3161 EL_TUBE_HORIZONTAL_UP,
3162 EL_TUBE_HORIZONTAL_DOWN,
3164 EL_TUBE_VERTICAL_LEFT,
3165 EL_TUBE_VERTICAL_RIGHT,
3171 static int ep_keygate[] =
3181 EL_GATE_1_GRAY_ACTIVE,
3182 EL_GATE_2_GRAY_ACTIVE,
3183 EL_GATE_3_GRAY_ACTIVE,
3184 EL_GATE_4_GRAY_ACTIVE,
3193 EL_EM_GATE_1_GRAY_ACTIVE,
3194 EL_EM_GATE_2_GRAY_ACTIVE,
3195 EL_EM_GATE_3_GRAY_ACTIVE,
3196 EL_EM_GATE_4_GRAY_ACTIVE,
3205 EL_EMC_GATE_5_GRAY_ACTIVE,
3206 EL_EMC_GATE_6_GRAY_ACTIVE,
3207 EL_EMC_GATE_7_GRAY_ACTIVE,
3208 EL_EMC_GATE_8_GRAY_ACTIVE,
3213 static int ep_amoeboid[] =
3225 static int ep_amoebalive[] =
3236 static int ep_has_editor_content[] =
3254 static int ep_can_turn_each_move[] =
3256 /* !!! do something with this one !!! */
3260 static int ep_can_grow[] =
3274 static int ep_active_bomb[] =
3277 EL_DYNABOMB_PLAYER_1_ACTIVE,
3278 EL_DYNABOMB_PLAYER_2_ACTIVE,
3279 EL_DYNABOMB_PLAYER_3_ACTIVE,
3280 EL_DYNABOMB_PLAYER_4_ACTIVE,
3281 EL_SP_DISK_RED_ACTIVE,
3286 static int ep_inactive[] =
3318 EL_GATE_1_GRAY_ACTIVE,
3319 EL_GATE_2_GRAY_ACTIVE,
3320 EL_GATE_3_GRAY_ACTIVE,
3321 EL_GATE_4_GRAY_ACTIVE,
3330 EL_EM_GATE_1_GRAY_ACTIVE,
3331 EL_EM_GATE_2_GRAY_ACTIVE,
3332 EL_EM_GATE_3_GRAY_ACTIVE,
3333 EL_EM_GATE_4_GRAY_ACTIVE,
3342 EL_EMC_GATE_5_GRAY_ACTIVE,
3343 EL_EMC_GATE_6_GRAY_ACTIVE,
3344 EL_EMC_GATE_7_GRAY_ACTIVE,
3345 EL_EMC_GATE_8_GRAY_ACTIVE,
3347 EL_INVISIBLE_STEELWALL,
3355 EL_WALL_EMERALD_YELLOW,
3356 EL_DYNABOMB_INCREASE_NUMBER,
3357 EL_DYNABOMB_INCREASE_SIZE,
3358 EL_DYNABOMB_INCREASE_POWER,
3362 EL_SOKOBAN_FIELD_EMPTY,
3363 EL_SOKOBAN_FIELD_FULL,
3364 EL_WALL_EMERALD_RED,
3365 EL_WALL_EMERALD_PURPLE,
3366 EL_ACID_POOL_TOPLEFT,
3367 EL_ACID_POOL_TOPRIGHT,
3368 EL_ACID_POOL_BOTTOMLEFT,
3369 EL_ACID_POOL_BOTTOM,
3370 EL_ACID_POOL_BOTTOMRIGHT,
3374 EL_BD_MAGIC_WALL_DEAD,
3375 EL_AMOEBA_TO_DIAMOND,
3383 EL_SP_GRAVITY_PORT_RIGHT,
3384 EL_SP_GRAVITY_PORT_DOWN,
3385 EL_SP_GRAVITY_PORT_LEFT,
3386 EL_SP_GRAVITY_PORT_UP,
3387 EL_SP_PORT_HORIZONTAL,
3388 EL_SP_PORT_VERTICAL,
3399 EL_SP_HARDWARE_GRAY,
3400 EL_SP_HARDWARE_GREEN,
3401 EL_SP_HARDWARE_BLUE,
3403 EL_SP_HARDWARE_YELLOW,
3404 EL_SP_HARDWARE_BASE_1,
3405 EL_SP_HARDWARE_BASE_2,
3406 EL_SP_HARDWARE_BASE_3,
3407 EL_SP_HARDWARE_BASE_4,
3408 EL_SP_HARDWARE_BASE_5,
3409 EL_SP_HARDWARE_BASE_6,
3410 EL_SP_GRAVITY_ON_PORT_LEFT,
3411 EL_SP_GRAVITY_ON_PORT_RIGHT,
3412 EL_SP_GRAVITY_ON_PORT_UP,
3413 EL_SP_GRAVITY_ON_PORT_DOWN,
3414 EL_SP_GRAVITY_OFF_PORT_LEFT,
3415 EL_SP_GRAVITY_OFF_PORT_RIGHT,
3416 EL_SP_GRAVITY_OFF_PORT_UP,
3417 EL_SP_GRAVITY_OFF_PORT_DOWN,
3418 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
3419 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
3420 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
3421 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
3422 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
3423 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
3424 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
3425 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
3426 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
3427 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
3428 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
3429 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
3430 EL_SIGN_EXCLAMATION,
3431 EL_SIGN_RADIOACTIVITY,
3442 EL_STEELWALL_SLIPPERY,
3447 EL_EMC_WALL_SLIPPERY_1,
3448 EL_EMC_WALL_SLIPPERY_2,
3449 EL_EMC_WALL_SLIPPERY_3,
3450 EL_EMC_WALL_SLIPPERY_4,
3471 static int ep_em_slippery_wall[] =
3476 static int ep_gfx_crumbled[] =
3486 static int ep_editor_cascade_active[] =
3488 EL_INTERNAL_CASCADE_BD_ACTIVE,
3489 EL_INTERNAL_CASCADE_EM_ACTIVE,
3490 EL_INTERNAL_CASCADE_EMC_ACTIVE,
3491 EL_INTERNAL_CASCADE_RND_ACTIVE,
3492 EL_INTERNAL_CASCADE_SB_ACTIVE,
3493 EL_INTERNAL_CASCADE_SP_ACTIVE,
3494 EL_INTERNAL_CASCADE_DC_ACTIVE,
3495 EL_INTERNAL_CASCADE_DX_ACTIVE,
3496 EL_INTERNAL_CASCADE_CHARS_ACTIVE,
3497 EL_INTERNAL_CASCADE_CE_ACTIVE,
3498 EL_INTERNAL_CASCADE_GE_ACTIVE,
3499 EL_INTERNAL_CASCADE_USER_ACTIVE,
3500 EL_INTERNAL_CASCADE_GENERIC_ACTIVE,
3501 EL_INTERNAL_CASCADE_DYNAMIC_ACTIVE,
3506 static int ep_editor_cascade_inactive[] =
3508 EL_INTERNAL_CASCADE_BD,
3509 EL_INTERNAL_CASCADE_EM,
3510 EL_INTERNAL_CASCADE_EMC,
3511 EL_INTERNAL_CASCADE_RND,
3512 EL_INTERNAL_CASCADE_SB,
3513 EL_INTERNAL_CASCADE_SP,
3514 EL_INTERNAL_CASCADE_DC,
3515 EL_INTERNAL_CASCADE_DX,
3516 EL_INTERNAL_CASCADE_CHARS,
3517 EL_INTERNAL_CASCADE_CE,
3518 EL_INTERNAL_CASCADE_GE,
3519 EL_INTERNAL_CASCADE_USER,
3520 EL_INTERNAL_CASCADE_GENERIC,
3521 EL_INTERNAL_CASCADE_DYNAMIC,
3530 } element_properties[] =
3532 { ep_diggable, EP_DIGGABLE },
3533 { ep_collectible_only, EP_COLLECTIBLE_ONLY },
3534 { ep_dont_run_into, EP_DONT_RUN_INTO },
3535 { ep_dont_collide_with, EP_DONT_COLLIDE_WITH },
3536 { ep_dont_touch, EP_DONT_TOUCH },
3537 { ep_indestructible, EP_INDESTRUCTIBLE },
3538 { ep_slippery, EP_SLIPPERY },
3539 { ep_can_change, EP_CAN_CHANGE },
3540 { ep_can_move, EP_CAN_MOVE },
3541 { ep_can_fall, EP_CAN_FALL },
3542 { ep_can_smash_player, EP_CAN_SMASH_PLAYER },
3543 { ep_can_smash_enemies, EP_CAN_SMASH_ENEMIES },
3544 { ep_can_smash_everything, EP_CAN_SMASH_EVERYTHING },
3545 { ep_explodes_by_fire, EP_EXPLODES_BY_FIRE },
3546 { ep_explodes_smashed, EP_EXPLODES_SMASHED },
3547 { ep_explodes_impact, EP_EXPLODES_IMPACT },
3548 { ep_walkable_over, EP_WALKABLE_OVER },
3549 { ep_walkable_inside, EP_WALKABLE_INSIDE },
3550 { ep_walkable_under, EP_WALKABLE_UNDER },
3551 { ep_passable_over, EP_PASSABLE_OVER },
3552 { ep_passable_inside, EP_PASSABLE_INSIDE },
3553 { ep_passable_under, EP_PASSABLE_UNDER },
3554 { ep_droppable, EP_DROPPABLE },
3555 { ep_explodes_1x1_old, EP_EXPLODES_1X1_OLD },
3556 { ep_pushable, EP_PUSHABLE },
3557 { ep_explodes_cross_old, EP_EXPLODES_CROSS_OLD },
3558 { ep_protected, EP_PROTECTED },
3559 { ep_throwable, EP_THROWABLE },
3560 { ep_can_explode, EP_CAN_EXPLODE },
3561 { ep_gravity_reachable, EP_GRAVITY_REACHABLE },
3563 { ep_player, EP_PLAYER },
3564 { ep_can_pass_magic_wall, EP_CAN_PASS_MAGIC_WALL },
3565 { ep_switchable, EP_SWITCHABLE },
3566 { ep_bd_element, EP_BD_ELEMENT },
3567 { ep_sp_element, EP_SP_ELEMENT },
3568 { ep_sb_element, EP_SB_ELEMENT },
3570 { ep_food_dark_yamyam, EP_FOOD_DARK_YAMYAM },
3571 { ep_food_penguin, EP_FOOD_PENGUIN },
3572 { ep_food_pig, EP_FOOD_PIG },
3573 { ep_historic_wall, EP_HISTORIC_WALL },
3574 { ep_historic_solid, EP_HISTORIC_SOLID },
3575 { ep_classic_enemy, EP_CLASSIC_ENEMY },
3576 { ep_belt, EP_BELT },
3577 { ep_belt_active, EP_BELT_ACTIVE },
3578 { ep_belt_switch, EP_BELT_SWITCH },
3579 { ep_tube, EP_TUBE },
3580 { ep_keygate, EP_KEYGATE },
3581 { ep_amoeboid, EP_AMOEBOID },
3582 { ep_amoebalive, EP_AMOEBALIVE },
3583 { ep_has_editor_content, EP_HAS_EDITOR_CONTENT },
3584 { ep_can_turn_each_move, EP_CAN_TURN_EACH_MOVE },
3585 { ep_can_grow, EP_CAN_GROW },
3586 { ep_active_bomb, EP_ACTIVE_BOMB },
3587 { ep_inactive, EP_INACTIVE },
3589 { ep_em_slippery_wall, EP_EM_SLIPPERY_WALL },
3591 { ep_gfx_crumbled, EP_GFX_CRUMBLED },
3593 { ep_editor_cascade_active, EP_EDITOR_CASCADE_ACTIVE },
3594 { ep_editor_cascade_inactive, EP_EDITOR_CASCADE_INACTIVE },
3601 /* always start with reliable default values (element has no properties) */
3602 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
3603 for (j = 0; j < NUM_ELEMENT_PROPERTIES; j++)
3604 SET_PROPERTY(i, j, FALSE);
3606 /* set all base element properties from above array definitions */
3607 for (i = 0; element_properties[i].elements != NULL; i++)
3608 for (j = 0; (element_properties[i].elements)[j] != -1; j++)
3609 SET_PROPERTY((element_properties[i].elements)[j],
3610 element_properties[i].property, TRUE);
3612 /* copy properties to some elements that are only stored in level file */
3613 for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
3614 for (j = 0; copy_properties[j][0] != -1; j++)
3615 if (HAS_PROPERTY(copy_properties[j][0], i))
3616 for (k = 1; k <= 4; k++)
3617 SET_PROPERTY(copy_properties[j][k], i, TRUE);
3620 void InitElementPropertiesEngine(int engine_version)
3622 static int no_wall_properties[] =
3625 EP_COLLECTIBLE_ONLY,
3627 EP_DONT_COLLIDE_WITH,
3630 EP_CAN_SMASH_PLAYER,
3631 EP_CAN_SMASH_ENEMIES,
3632 EP_CAN_SMASH_EVERYTHING,
3637 EP_FOOD_DARK_YAMYAM,
3653 /* important: after initialization in InitElementPropertiesStatic(), the
3654 elements are not again initialized to a default value; therefore all
3655 changes have to make sure that they leave the element with a defined
3656 property (which means that conditional property changes must be set to
3657 a reliable default value before) */
3660 /* ---------- recursively resolve group elements ------------------------- */
3662 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
3663 for (j = 0; j < NUM_GROUP_ELEMENTS; j++)
3664 element_info[i].in_group[j] = FALSE;
3666 for (i = 0; i < NUM_GROUP_ELEMENTS; i++)
3667 resolve_group_element(EL_GROUP_START + i, 0);
3670 /* set all special, combined or engine dependent element properties */
3671 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
3673 /* ---------- INACTIVE ------------------------------------------------- */
3674 SET_PROPERTY(i, EP_INACTIVE, (i >= EL_CHAR_START && i <= EL_CHAR_END));
3676 /* ---------- WALKABLE, PASSABLE, ACCESSIBLE --------------------------- */
3677 SET_PROPERTY(i, EP_WALKABLE, (IS_WALKABLE_OVER(i) ||
3678 IS_WALKABLE_INSIDE(i) ||
3679 IS_WALKABLE_UNDER(i)));
3681 SET_PROPERTY(i, EP_PASSABLE, (IS_PASSABLE_OVER(i) ||
3682 IS_PASSABLE_INSIDE(i) ||
3683 IS_PASSABLE_UNDER(i)));
3685 SET_PROPERTY(i, EP_ACCESSIBLE_OVER, (IS_WALKABLE_OVER(i) ||
3686 IS_PASSABLE_OVER(i)));
3688 SET_PROPERTY(i, EP_ACCESSIBLE_INSIDE, (IS_WALKABLE_INSIDE(i) ||
3689 IS_PASSABLE_INSIDE(i)));
3691 SET_PROPERTY(i, EP_ACCESSIBLE_UNDER, (IS_WALKABLE_UNDER(i) ||
3692 IS_PASSABLE_UNDER(i)));
3694 SET_PROPERTY(i, EP_ACCESSIBLE, (IS_WALKABLE(i) ||
3697 /* ---------- COLLECTIBLE ---------------------------------------------- */
3698 SET_PROPERTY(i, EP_COLLECTIBLE, (IS_COLLECTIBLE_ONLY(i) ||
3702 /* ---------- SNAPPABLE ------------------------------------------------ */
3703 SET_PROPERTY(i, EP_SNAPPABLE, (IS_DIGGABLE(i) ||
3704 IS_COLLECTIBLE(i) ||
3708 /* ---------- WALL ----------------------------------------------------- */
3709 SET_PROPERTY(i, EP_WALL, TRUE); /* default: element is wall */
3711 for (j = 0; no_wall_properties[j] != -1; j++)
3712 if (HAS_PROPERTY(i, no_wall_properties[j]) ||
3713 i >= EL_FIRST_RUNTIME_UNREAL)
3714 SET_PROPERTY(i, EP_WALL, FALSE);
3716 if (IS_HISTORIC_WALL(i))
3717 SET_PROPERTY(i, EP_WALL, TRUE);
3719 /* ---------- SOLID_FOR_PUSHING ---------------------------------------- */
3720 if (engine_version < VERSION_IDENT(2,2,0,0))
3721 SET_PROPERTY(i, EP_SOLID_FOR_PUSHING, IS_HISTORIC_SOLID(i));
3723 SET_PROPERTY(i, EP_SOLID_FOR_PUSHING, (!IS_WALKABLE(i) &&
3725 !IS_COLLECTIBLE(i)));
3727 /* ---------- DRAGONFIRE_PROOF ----------------------------------------- */
3729 if (IS_HISTORIC_SOLID(i) || i == EL_EXPLOSION)
3730 SET_PROPERTY(i, EP_DRAGONFIRE_PROOF, TRUE);
3732 SET_PROPERTY(i, EP_DRAGONFIRE_PROOF, (IS_CUSTOM_ELEMENT(i) &&
3733 IS_INDESTRUCTIBLE(i)));
3735 /* ---------- EXPLOSION_PROOF ------------------------------------------ */
3737 SET_PROPERTY(i, EP_EXPLOSION_PROOF, TRUE);
3738 else if (engine_version < VERSION_IDENT(2,2,0,0))
3739 SET_PROPERTY(i, EP_EXPLOSION_PROOF, IS_INDESTRUCTIBLE(i));
3741 SET_PROPERTY(i, EP_EXPLOSION_PROOF, (IS_INDESTRUCTIBLE(i) &&
3745 if (IS_CUSTOM_ELEMENT(i))
3747 /* these are additional properties which are initially false when set */
3749 /* ---------- DONT_COLLIDE_WITH / DONT_RUN_INTO ---------------------- */
3751 SET_PROPERTY(i, EP_DONT_COLLIDE_WITH, TRUE);
3752 if (DONT_COLLIDE_WITH(i))
3753 SET_PROPERTY(i, EP_DONT_RUN_INTO, TRUE);
3755 /* ---------- CAN_SMASH_ENEMIES / CAN_SMASH_PLAYER ------------------- */
3756 if (CAN_SMASH_EVERYTHING(i))
3757 SET_PROPERTY(i, EP_CAN_SMASH_ENEMIES, TRUE);
3758 if (CAN_SMASH_ENEMIES(i))
3759 SET_PROPERTY(i, EP_CAN_SMASH_PLAYER, TRUE);
3762 /* ---------- CAN_SMASH ------------------------------------------------ */
3763 SET_PROPERTY(i, EP_CAN_SMASH, (CAN_SMASH_PLAYER(i) ||
3764 CAN_SMASH_ENEMIES(i) ||
3765 CAN_SMASH_EVERYTHING(i)));
3767 /* ---------- CAN_EXPLODE_BY_FIRE -------------------------------------- */
3768 SET_PROPERTY(i, EP_CAN_EXPLODE_BY_FIRE, (CAN_EXPLODE(i) &&
3769 EXPLODES_BY_FIRE(i)));
3771 /* ---------- CAN_EXPLODE_SMASHED -------------------------------------- */
3772 SET_PROPERTY(i, EP_CAN_EXPLODE_SMASHED, (CAN_EXPLODE(i) &&
3773 EXPLODES_SMASHED(i)));
3775 /* ---------- CAN_EXPLODE_IMPACT --------------------------------------- */
3776 SET_PROPERTY(i, EP_CAN_EXPLODE_IMPACT, (CAN_EXPLODE(i) &&
3777 EXPLODES_IMPACT(i)));
3779 /* ---------- CAN_EXPLODE_BY_DRAGONFIRE -------------------------------- */
3780 SET_PROPERTY(i, EP_CAN_EXPLODE_BY_DRAGONFIRE, CAN_EXPLODE_BY_FIRE(i));
3782 /* ---------- CAN_EXPLODE_BY_EXPLOSION --------------------------------- */
3783 SET_PROPERTY(i, EP_CAN_EXPLODE_BY_EXPLOSION, (CAN_EXPLODE_BY_FIRE(i) ||
3784 i == EL_BLACK_ORB));
3786 /* ---------- COULD_MOVE_INTO_ACID ------------------------------------- */
3787 SET_PROPERTY(i, EP_COULD_MOVE_INTO_ACID, (ELEM_IS_PLAYER(i) ||
3789 IS_CUSTOM_ELEMENT(i)));
3791 /* ---------- MAYBE_DONT_COLLIDE_WITH ---------------------------------- */
3792 SET_PROPERTY(i, EP_MAYBE_DONT_COLLIDE_WITH, (i == EL_SP_SNIKSNAK ||
3793 i == EL_SP_ELECTRON));
3795 /* ---------- CAN_MOVE_INTO_ACID --------------------------------------- */
3796 if (COULD_MOVE_INTO_ACID(i) && !IS_CUSTOM_ELEMENT(i))
3797 SET_PROPERTY(i, EP_CAN_MOVE_INTO_ACID,
3798 getMoveIntoAcidProperty(&level, i));
3800 /* ---------- DONT_COLLIDE_WITH ---------------------------------------- */
3801 if (MAYBE_DONT_COLLIDE_WITH(i))
3802 SET_PROPERTY(i, EP_DONT_COLLIDE_WITH,
3803 getDontCollideWithProperty(&level, i));
3805 /* ---------- SP_PORT -------------------------------------------------- */
3806 SET_PROPERTY(i, EP_SP_PORT, (IS_SP_ELEMENT(i) &&
3807 IS_PASSABLE_INSIDE(i)));
3809 /* ---------- CAN_BE_CLONED_BY_ANDROID --------------------------------- */
3810 for (j = 0; j < level.num_android_clone_elements; j++)
3811 SET_PROPERTY(i, EP_CAN_BE_CLONED_BY_ANDROID,
3813 IS_EQUAL_OR_IN_GROUP(i, level.android_clone_element[j])));
3815 /* ---------- CAN_CHANGE ----------------------------------------------- */
3816 SET_PROPERTY(i, EP_CAN_CHANGE, FALSE); /* default: cannot change */
3817 for (j = 0; j < element_info[i].num_change_pages; j++)
3818 if (element_info[i].change_page[j].can_change)
3819 SET_PROPERTY(i, EP_CAN_CHANGE, TRUE);
3821 /* ---------- HAS_ACTION ----------------------------------------------- */
3822 SET_PROPERTY(i, EP_HAS_ACTION, FALSE); /* default: has no action */
3823 for (j = 0; j < element_info[i].num_change_pages; j++)
3824 if (element_info[i].change_page[j].has_action)
3825 SET_PROPERTY(i, EP_HAS_ACTION, TRUE);
3827 /* ---------- CAN_CHANGE_OR_HAS_ACTION --------------------------------- */
3828 SET_PROPERTY(i, EP_CAN_CHANGE_OR_HAS_ACTION, (CAN_CHANGE(i) ||
3831 /* ---------- GFX_CRUMBLED --------------------------------------------- */
3833 SET_PROPERTY(i, EP_GFX_CRUMBLED,
3834 element_info[i].crumbled[ACTION_DEFAULT] !=
3835 element_info[i].graphic[ACTION_DEFAULT]);
3837 /* !!! THIS LOOKS CRAPPY FOR SAND ETC. WITHOUT CRUMBLED GRAPHICS !!! */
3838 SET_PROPERTY(i, EP_GFX_CRUMBLED,
3839 element_info[i].crumbled[ACTION_DEFAULT] != IMG_EMPTY);
3842 /* ---------- EDITOR_CASCADE ------------------------------------------- */
3843 SET_PROPERTY(i, EP_EDITOR_CASCADE, (IS_EDITOR_CASCADE_ACTIVE(i) ||
3844 IS_EDITOR_CASCADE_INACTIVE(i)));
3847 /* dynamically adjust element properties according to game engine version */
3849 static int ep_em_slippery_wall[] =
3854 EL_EXPANDABLE_WALL_HORIZONTAL,
3855 EL_EXPANDABLE_WALL_VERTICAL,
3856 EL_EXPANDABLE_WALL_ANY,
3860 /* special EM style gems behaviour */
3861 for (i = 0; ep_em_slippery_wall[i] != -1; i++)
3862 SET_PROPERTY(ep_em_slippery_wall[i], EP_EM_SLIPPERY_WALL,
3863 level.em_slippery_gems);
3865 /* "EL_EXPANDABLE_WALL_GROWING" wasn't slippery for EM gems in 2.0.1 */
3866 SET_PROPERTY(EL_EXPANDABLE_WALL_GROWING, EP_EM_SLIPPERY_WALL,
3867 (level.em_slippery_gems &&
3868 engine_version > VERSION_IDENT(2,0,1,0)));
3871 /* set default push delay values (corrected since version 3.0.7-1) */
3872 if (engine_version < VERSION_IDENT(3,0,7,1))
3874 game.default_push_delay_fixed = 2;
3875 game.default_push_delay_random = 8;
3879 game.default_push_delay_fixed = 8;
3880 game.default_push_delay_random = 8;
3883 /* set uninitialized push delay values of custom elements in older levels */
3884 for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++)
3886 int element = EL_CUSTOM_START + i;
3888 if (element_info[element].push_delay_fixed == -1)
3889 element_info[element].push_delay_fixed = game.default_push_delay_fixed;
3890 if (element_info[element].push_delay_random == -1)
3891 element_info[element].push_delay_random = game.default_push_delay_random;
3894 /* set some other uninitialized values of custom elements in older levels */
3895 if (engine_version < VERSION_IDENT(3,1,0,0))
3897 for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++)
3899 int element = EL_CUSTOM_START + i;
3901 element_info[element].access_direction = MV_ALL_DIRECTIONS;
3903 element_info[element].explosion_delay = 17;
3904 element_info[element].ignition_delay = 8;
3909 /* set element properties that were handled incorrectly in older levels */
3910 if (engine_version < VERSION_IDENT(3,1,0,0))
3912 SET_PROPERTY(EL_SP_SNIKSNAK, EP_DONT_COLLIDE_WITH, FALSE);
3913 SET_PROPERTY(EL_SP_ELECTRON, EP_DONT_COLLIDE_WITH, FALSE);
3917 /* this is needed because some graphics depend on element properties */
3918 if (game_status == GAME_MODE_PLAYING)
3919 InitElementGraphicInfo();
3922 static void InitGlobal()
3926 for (i = 0; i < MAX_NUM_ELEMENTS + 1; i++)
3928 /* check if element_name_info entry defined for each element in "main.h" */
3929 if (i < MAX_NUM_ELEMENTS && element_name_info[i].token_name == NULL)
3930 Error(ERR_EXIT, "undefined 'element_name_info' entry for element %d", i);
3932 element_info[i].token_name = element_name_info[i].token_name;
3933 element_info[i].class_name = element_name_info[i].class_name;
3934 element_info[i].editor_description=element_name_info[i].editor_description;
3937 global.autoplay_leveldir = NULL;
3938 global.convert_leveldir = NULL;
3940 global.frames_per_second = 0;
3941 global.fps_slowdown = FALSE;
3942 global.fps_slowdown_factor = 1;
3945 void Execute_Command(char *command)
3949 if (strcmp(command, "print graphicsinfo.conf") == 0)
3951 printf("# You can configure additional/alternative image files here.\n");
3952 printf("# (The entries below are default and therefore commented out.)\n");
3954 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
3956 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
3959 for (i = 0; image_config[i].token != NULL; i++)
3960 printf("# %s\n", getFormattedSetupEntry(image_config[i].token,
3961 image_config[i].value));
3965 else if (strcmp(command, "print soundsinfo.conf") == 0)
3967 printf("# You can configure additional/alternative sound files here.\n");
3968 printf("# (The entries below are default and therefore commented out.)\n");
3970 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
3972 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
3975 for (i = 0; sound_config[i].token != NULL; i++)
3976 printf("# %s\n", getFormattedSetupEntry(sound_config[i].token,
3977 sound_config[i].value));
3981 else if (strcmp(command, "print musicinfo.conf") == 0)
3983 printf("# You can configure additional/alternative music files here.\n");
3984 printf("# (The entries below are default and therefore commented out.)\n");
3986 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
3988 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
3991 for (i = 0; music_config[i].token != NULL; i++)
3992 printf("# %s\n", getFormattedSetupEntry(music_config[i].token,
3993 music_config[i].value));
3997 else if (strcmp(command, "print editorsetup.conf") == 0)
3999 printf("# You can configure your personal editor element list here.\n");
4000 printf("# (The entries below are default and therefore commented out.)\n");
4003 /* this is needed to be able to check element list for cascade elements */
4004 InitElementPropertiesStatic();
4005 InitElementPropertiesEngine(GAME_VERSION_ACTUAL);
4007 PrintEditorElementList();
4011 else if (strcmp(command, "print helpanim.conf") == 0)
4013 printf("# You can configure different element help animations here.\n");
4014 printf("# (The entries below are default and therefore commented out.)\n");
4017 for (i = 0; helpanim_config[i].token != NULL; i++)
4019 printf("# %s\n", getFormattedSetupEntry(helpanim_config[i].token,
4020 helpanim_config[i].value));
4022 if (strcmp(helpanim_config[i].token, "end") == 0)
4028 else if (strcmp(command, "print helptext.conf") == 0)
4030 printf("# You can configure different element help text here.\n");
4031 printf("# (The entries below are default and therefore commented out.)\n");
4034 for (i = 0; helptext_config[i].token != NULL; i++)
4035 printf("# %s\n", getFormattedSetupEntry(helptext_config[i].token,
4036 helptext_config[i].value));
4040 else if (strncmp(command, "dump level ", 11) == 0)
4042 char *filename = &command[11];
4044 if (!fileExists(filename))
4045 Error(ERR_EXIT, "cannot open file '%s'", filename);
4047 LoadLevelFromFilename(&level, filename);
4052 else if (strncmp(command, "dump tape ", 10) == 0)
4054 char *filename = &command[10];
4056 if (!fileExists(filename))
4057 Error(ERR_EXIT, "cannot open file '%s'", filename);
4059 LoadTapeFromFilename(filename);
4064 else if (strncmp(command, "autoplay ", 9) == 0)
4066 char *str_ptr = getStringCopy(&command[9]); /* read command parameters */
4068 while (*str_ptr != '\0') /* continue parsing string */
4070 /* cut leading whitespace from string, replace it by string terminator */
4071 while (*str_ptr == ' ' || *str_ptr == '\t')
4074 if (*str_ptr == '\0') /* end of string reached */
4077 if (global.autoplay_leveldir == NULL) /* read level set string */
4079 global.autoplay_leveldir = str_ptr;
4080 global.autoplay_all = TRUE; /* default: play all tapes */
4082 for (i = 0; i < MAX_TAPES_PER_SET; i++)
4083 global.autoplay_level[i] = FALSE;
4085 else /* read level number string */
4087 int level_nr = atoi(str_ptr); /* get level_nr value */
4089 if (level_nr >= 0 && level_nr < MAX_TAPES_PER_SET)
4090 global.autoplay_level[level_nr] = TRUE;
4092 global.autoplay_all = FALSE;
4095 /* advance string pointer to the next whitespace (or end of string) */
4096 while (*str_ptr != ' ' && *str_ptr != '\t' && *str_ptr != '\0')
4100 else if (strncmp(command, "convert ", 8) == 0)
4102 char *str_copy = getStringCopy(&command[8]);
4103 char *str_ptr = strchr(str_copy, ' ');
4105 global.convert_leveldir = str_copy;
4106 global.convert_level_nr = -1;
4108 if (str_ptr != NULL) /* level number follows */
4110 *str_ptr++ = '\0'; /* terminate leveldir string */
4111 global.convert_level_nr = atoi(str_ptr); /* get level_nr value */
4116 Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
4120 static void InitSetup()
4122 LoadSetup(); /* global setup info */
4124 /* set some options from setup file */
4126 if (setup.options.verbose)
4127 options.verbose = TRUE;
4130 static void InitGameInfo()
4132 game.restart_level = FALSE;
4135 static void InitPlayerInfo()
4139 /* choose default local player */
4140 local_player = &stored_player[0];
4142 for (i = 0; i < MAX_PLAYERS; i++)
4143 stored_player[i].connected = FALSE;
4145 local_player->connected = TRUE;
4148 static void InitArtworkInfo()
4153 static char *get_string_in_brackets(char *string)
4155 char *string_in_brackets = checked_malloc(strlen(string) + 3);
4157 sprintf(string_in_brackets, "[%s]", string);
4159 return string_in_brackets;
4162 static char *get_level_id_suffix(int id_nr)
4164 char *id_suffix = checked_malloc(1 + 3 + 1);
4166 if (id_nr < 0 || id_nr > 999)
4169 sprintf(id_suffix, ".%03d", id_nr);
4175 static char *get_element_class_token(int element)
4177 char *element_class_name = element_info[element].class_name;
4178 char *element_class_token = checked_malloc(strlen(element_class_name) + 3);
4180 sprintf(element_class_token, "[%s]", element_class_name);
4182 return element_class_token;
4185 static char *get_action_class_token(int action)
4187 char *action_class_name = &element_action_info[action].suffix[1];
4188 char *action_class_token = checked_malloc(strlen(action_class_name) + 3);
4190 sprintf(action_class_token, "[%s]", action_class_name);
4192 return action_class_token;
4196 static void InitArtworkConfig()
4198 static char *image_id_prefix[MAX_NUM_ELEMENTS + NUM_FONTS + 1];
4199 static char *sound_id_prefix[2 * MAX_NUM_ELEMENTS + 1];
4200 static char *music_id_prefix[NUM_MUSIC_PREFIXES + 1];
4201 static char *action_id_suffix[NUM_ACTIONS + 1];
4202 static char *direction_id_suffix[NUM_DIRECTIONS_FULL + 1];
4203 static char *special_id_suffix[NUM_SPECIAL_GFX_ARGS + 1];
4204 static char *level_id_suffix[MAX_LEVELS + 1];
4205 static char *dummy[1] = { NULL };
4206 static char *ignore_generic_tokens[] =
4212 static char **ignore_image_tokens;
4213 static char **ignore_sound_tokens;
4214 static char **ignore_music_tokens;
4215 int num_ignore_generic_tokens;
4216 int num_ignore_image_tokens;
4217 int num_ignore_sound_tokens;
4218 int num_ignore_music_tokens;
4221 /* dynamically determine list of generic tokens to be ignored */
4222 num_ignore_generic_tokens = 0;
4223 for (i = 0; ignore_generic_tokens[i] != NULL; i++)
4224 num_ignore_generic_tokens++;
4226 /* dynamically determine list of image tokens to be ignored */
4227 num_ignore_image_tokens = num_ignore_generic_tokens;
4228 for (i = 0; image_config_vars[i].token != NULL; i++)
4229 num_ignore_image_tokens++;
4230 ignore_image_tokens =
4231 checked_malloc((num_ignore_image_tokens + 1) * sizeof(char *));
4232 for (i = 0; i < num_ignore_generic_tokens; i++)
4233 ignore_image_tokens[i] = ignore_generic_tokens[i];
4234 for (i = 0; i < num_ignore_image_tokens - num_ignore_generic_tokens; i++)
4235 ignore_image_tokens[num_ignore_generic_tokens + i] =
4236 image_config_vars[i].token;
4237 ignore_image_tokens[num_ignore_image_tokens] = NULL;
4239 /* dynamically determine list of sound tokens to be ignored */
4240 num_ignore_sound_tokens = num_ignore_generic_tokens;
4241 ignore_sound_tokens =
4242 checked_malloc((num_ignore_sound_tokens + 1) * sizeof(char *));
4243 for (i = 0; i < num_ignore_generic_tokens; i++)
4244 ignore_sound_tokens[i] = ignore_generic_tokens[i];
4245 ignore_sound_tokens[num_ignore_sound_tokens] = NULL;
4247 /* dynamically determine list of music tokens to be ignored */
4248 num_ignore_music_tokens = num_ignore_generic_tokens;
4249 ignore_music_tokens =
4250 checked_malloc((num_ignore_music_tokens + 1) * sizeof(char *));
4251 for (i = 0; i < num_ignore_generic_tokens; i++)
4252 ignore_music_tokens[i] = ignore_generic_tokens[i];
4253 ignore_music_tokens[num_ignore_music_tokens] = NULL;
4255 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
4256 image_id_prefix[i] = element_info[i].token_name;
4257 for (i = 0; i < NUM_FONTS; i++)
4258 image_id_prefix[MAX_NUM_ELEMENTS + i] = font_info[i].token_name;
4259 image_id_prefix[MAX_NUM_ELEMENTS + NUM_FONTS] = NULL;
4261 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
4262 sound_id_prefix[i] = element_info[i].token_name;
4263 for (i = 0; i < MAX_NUM_ELEMENTS; i++)
4264 sound_id_prefix[MAX_NUM_ELEMENTS + i] =
4265 get_string_in_brackets(element_info[i].class_name);
4266 sound_id_prefix[2 * MAX_NUM_ELEMENTS] = NULL;
4268 for (i = 0; i < NUM_MUSIC_PREFIXES; i++)
4269 music_id_prefix[i] = music_prefix_info[i].prefix;
4270 music_id_prefix[NUM_MUSIC_PREFIXES] = NULL;
4272 for (i = 0; i < NUM_ACTIONS; i++)
4273 action_id_suffix[i] = element_action_info[i].suffix;
4274 action_id_suffix[NUM_ACTIONS] = NULL;
4276 for (i = 0; i < NUM_DIRECTIONS_FULL; i++)
4277 direction_id_suffix[i] = element_direction_info[i].suffix;
4278 direction_id_suffix[NUM_DIRECTIONS_FULL] = NULL;
4280 for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++)
4281 special_id_suffix[i] = special_suffix_info[i].suffix;
4282 special_id_suffix[NUM_SPECIAL_GFX_ARGS] = NULL;
4284 for (i = 0; i < MAX_LEVELS; i++)
4285 level_id_suffix[i] = get_level_id_suffix(i);
4286 level_id_suffix[MAX_LEVELS] = NULL;
4288 InitImageList(image_config, NUM_IMAGE_FILES, image_config_suffix,
4289 image_id_prefix, action_id_suffix, direction_id_suffix,
4290 special_id_suffix, ignore_image_tokens);
4291 InitSoundList(sound_config, NUM_SOUND_FILES, sound_config_suffix,
4292 sound_id_prefix, action_id_suffix, dummy,
4293 special_id_suffix, ignore_sound_tokens);
4294 InitMusicList(music_config, NUM_MUSIC_FILES, music_config_suffix,
4295 music_id_prefix, special_id_suffix, level_id_suffix,
4296 dummy, ignore_music_tokens);
4299 static void InitMixer()
4307 char *filename_font_initial = NULL;
4308 Bitmap *bitmap_font_initial = NULL;
4311 /* determine settings for initial font (for displaying startup messages) */
4312 for (i = 0; image_config[i].token != NULL; i++)
4314 for (j = 0; j < NUM_INITIAL_FONTS; j++)
4316 char font_token[128];
4319 sprintf(font_token, "%s_%d", CONFIG_TOKEN_FONT_INITIAL, j + 1);
4320 len_font_token = strlen(font_token);
4322 if (strcmp(image_config[i].token, font_token) == 0)
4323 filename_font_initial = image_config[i].value;
4324 else if (strlen(image_config[i].token) > len_font_token &&
4325 strncmp(image_config[i].token, font_token, len_font_token) == 0)
4327 if (strcmp(&image_config[i].token[len_font_token], ".x") == 0)
4328 font_initial[j].src_x = atoi(image_config[i].value);
4329 else if (strcmp(&image_config[i].token[len_font_token], ".y") == 0)
4330 font_initial[j].src_y = atoi(image_config[i].value);
4331 else if (strcmp(&image_config[i].token[len_font_token], ".width") == 0)
4332 font_initial[j].width = atoi(image_config[i].value);
4333 else if (strcmp(&image_config[i].token[len_font_token],".height") == 0)
4334 font_initial[j].height = atoi(image_config[i].value);
4339 for (j = 0; j < NUM_INITIAL_FONTS; j++)
4341 font_initial[j].num_chars = DEFAULT_NUM_CHARS_PER_FONT;
4342 font_initial[j].num_chars_per_line = DEFAULT_NUM_CHARS_PER_LINE;
4345 if (filename_font_initial == NULL) /* should not happen */
4346 Error(ERR_EXIT, "cannot get filename for '%s'", CONFIG_TOKEN_FONT_INITIAL);
4348 /* create additional image buffers for double-buffering */
4349 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
4350 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
4352 /* initialize screen properties */
4353 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
4354 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE,
4356 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
4357 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
4358 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
4360 bitmap_font_initial = LoadCustomImage(filename_font_initial);
4362 for (j = 0; j < NUM_INITIAL_FONTS; j++)
4363 font_initial[j].bitmap = bitmap_font_initial;
4365 InitFontGraphicInfo();
4367 DrawInitText(getProgramInitString(), 20, FC_YELLOW);
4368 DrawInitText(PROGRAM_COPYRIGHT_STRING, 50, FC_RED);
4370 DrawInitText("Loading graphics:", 120, FC_GREEN);
4373 void InitGfxBackground()
4377 drawto = backbuffer;
4378 fieldbuffer = bitmap_db_field;
4379 SetDrawtoField(DRAW_BACKBUFFER);
4381 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
4382 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
4383 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
4384 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
4386 for (x = 0; x < MAX_BUF_XSIZE; x++)
4387 for (y = 0; y < MAX_BUF_YSIZE; y++)
4390 redraw_mask = REDRAW_ALL;
4393 static void InitLevelInfo()
4395 LoadLevelInfo(); /* global level info */
4396 LoadLevelSetup_LastSeries(); /* last played series info */
4397 LoadLevelSetup_SeriesInfo(); /* last played level info */
4400 void InitLevelArtworkInfo()
4402 LoadLevelArtworkInfo();
4405 static void InitImages()
4407 setLevelArtworkDir(artwork.gfx_first);
4410 printf("::: InitImages for '%s' ['%s', '%s'] ['%s', '%s']\n",
4411 leveldir_current->identifier,
4412 artwork.gfx_current_identifier,
4413 artwork.gfx_current->identifier,
4414 leveldir_current->graphics_set,
4415 leveldir_current->graphics_path);
4418 ReloadCustomImages();
4420 LoadCustomElementDescriptions();
4421 LoadSpecialMenuDesignSettings();
4423 ReinitializeGraphics();
4426 static void InitSound(char *identifier)
4428 if (identifier == NULL)
4429 identifier = artwork.snd_current->identifier;
4431 /* set artwork path to send it to the sound server process */
4432 setLevelArtworkDir(artwork.snd_first);
4434 InitReloadCustomSounds(identifier);
4435 ReinitializeSounds();
4438 static void InitMusic(char *identifier)
4440 if (identifier == NULL)
4441 identifier = artwork.mus_current->identifier;
4443 /* set artwork path to send it to the sound server process */
4444 setLevelArtworkDir(artwork.mus_first);
4446 InitReloadCustomMusic(identifier);
4447 ReinitializeMusic();
4450 void InitNetworkServer()
4452 #if defined(NETWORK_AVALIABLE)
4456 if (!options.network)
4459 #if defined(NETWORK_AVALIABLE)
4460 nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
4462 if (!ConnectToServer(options.server_host, options.server_port))
4463 Error(ERR_EXIT, "cannot connect to network game server");
4465 SendToServer_PlayerName(setup.player_name);
4466 SendToServer_ProtocolVersion();
4469 SendToServer_NrWanted(nr_wanted);
4473 static char *getNewArtworkIdentifier(int type)
4475 static char *leveldir_current_identifier[3] = { NULL, NULL, NULL };
4476 static boolean last_override_level_artwork[3] = { FALSE, FALSE, FALSE };
4477 static boolean last_has_level_artwork_set[3] = { FALSE, FALSE, FALSE };
4478 static boolean initialized[3] = { FALSE, FALSE, FALSE };
4479 TreeInfo *artwork_first_node = ARTWORK_FIRST_NODE(artwork, type);
4480 boolean setup_override_artwork = SETUP_OVERRIDE_ARTWORK(setup, type);
4481 char *setup_artwork_set = SETUP_ARTWORK_SET(setup, type);
4482 char *leveldir_identifier = leveldir_current->identifier;
4484 /* !!! setLevelArtworkDir() should be moved to an earlier stage !!! */
4485 char *leveldir_artwork_set = setLevelArtworkDir(artwork_first_node);
4487 char *leveldir_artwork_set = LEVELDIR_ARTWORK_SET(leveldir_current, type);
4489 boolean has_level_artwork_set = (leveldir_artwork_set != NULL);
4490 char *artwork_current_identifier;
4491 char *artwork_new_identifier = NULL; /* default: nothing has changed */
4493 /* leveldir_current may be invalid (level group, parent link) */
4494 if (!validLevelSeries(leveldir_current))
4497 /* 1st step: determine artwork set to be activated in descending order:
4498 --------------------------------------------------------------------
4499 1. setup artwork (when configured to override everything else)
4500 2. artwork set configured in "levelinfo.conf" of current level set
4501 (artwork in level directory will have priority when loading later)
4502 3. artwork in level directory (stored in artwork sub-directory)
4503 4. setup artwork (currently configured in setup menu) */
4505 if (setup_override_artwork)
4506 artwork_current_identifier = setup_artwork_set;
4507 else if (leveldir_artwork_set != NULL)
4508 artwork_current_identifier = leveldir_artwork_set;
4509 else if (getTreeInfoFromIdentifier(artwork_first_node, leveldir_identifier))
4510 artwork_current_identifier = leveldir_identifier;
4512 artwork_current_identifier = setup_artwork_set;
4515 /* 2nd step: check if it is really needed to reload artwork set
4516 ------------------------------------------------------------ */
4519 if (type == ARTWORK_TYPE_GRAPHICS)
4520 printf("::: 0: '%s' ['%s', '%s'] ['%s' ('%s')]\n",
4521 artwork_new_identifier,
4522 ARTWORK_CURRENT_IDENTIFIER(artwork, type),
4523 artwork_current_identifier,
4524 leveldir_current->graphics_set,
4525 leveldir_current->identifier);
4528 /* ---------- reload if level set and also artwork set has changed ------- */
4529 if (leveldir_current_identifier[type] != leveldir_identifier &&
4530 (last_has_level_artwork_set[type] || has_level_artwork_set))
4531 artwork_new_identifier = artwork_current_identifier;
4533 leveldir_current_identifier[type] = leveldir_identifier;
4534 last_has_level_artwork_set[type] = has_level_artwork_set;
4537 if (type == ARTWORK_TYPE_GRAPHICS)
4538 printf("::: 1: '%s'\n", artwork_new_identifier);
4541 /* ---------- reload if "override artwork" setting has changed ----------- */
4542 if (last_override_level_artwork[type] != setup_override_artwork)
4543 artwork_new_identifier = artwork_current_identifier;
4545 last_override_level_artwork[type] = setup_override_artwork;
4548 if (type == ARTWORK_TYPE_GRAPHICS)
4549 printf("::: 2: '%s'\n", artwork_new_identifier);
4552 /* ---------- reload if current artwork identifier has changed ----------- */
4553 if (strcmp(ARTWORK_CURRENT_IDENTIFIER(artwork, type),
4554 artwork_current_identifier) != 0)
4555 artwork_new_identifier = artwork_current_identifier;
4557 *(ARTWORK_CURRENT_IDENTIFIER_PTR(artwork, type))= artwork_current_identifier;
4560 if (type == ARTWORK_TYPE_GRAPHICS)
4561 printf("::: 3: '%s'\n", artwork_new_identifier);
4564 /* ---------- do not reload directly after starting ---------------------- */
4565 if (!initialized[type])
4566 artwork_new_identifier = NULL;
4568 initialized[type] = TRUE;
4571 if (type == ARTWORK_TYPE_GRAPHICS)
4572 printf("::: 4: '%s'\n", artwork_new_identifier);
4576 if (type == ARTWORK_TYPE_GRAPHICS)
4577 printf("CHECKING OLD/NEW GFX:\n- OLD: %s\n- NEW: %s ['%s', '%s'] ['%s']\n",
4578 artwork.gfx_current_identifier, artwork_current_identifier,
4579 artwork.gfx_current->identifier, leveldir_current->graphics_set,
4580 artwork_new_identifier);
4583 return artwork_new_identifier;
4586 void ReloadCustomArtwork(int force_reload)
4588 char *gfx_new_identifier = getNewArtworkIdentifier(ARTWORK_TYPE_GRAPHICS);
4589 char *snd_new_identifier = getNewArtworkIdentifier(ARTWORK_TYPE_SOUNDS);
4590 char *mus_new_identifier = getNewArtworkIdentifier(ARTWORK_TYPE_MUSIC);
4591 boolean force_reload_gfx = (force_reload & (1 << ARTWORK_TYPE_GRAPHICS));
4592 boolean force_reload_snd = (force_reload & (1 << ARTWORK_TYPE_SOUNDS));
4593 boolean force_reload_mus = (force_reload & (1 << ARTWORK_TYPE_MUSIC));
4594 boolean redraw_screen = FALSE;
4596 if (gfx_new_identifier != NULL || force_reload_gfx)
4599 printf("RELOADING GRAPHICS '%s' -> '%s' ['%s', '%s']\n",
4600 artwork.gfx_current_identifier,
4602 artwork.gfx_current->identifier,
4603 leveldir_current->graphics_set);
4606 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
4610 redraw_screen = TRUE;
4613 if (snd_new_identifier != NULL || force_reload_snd)
4615 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
4617 InitSound(snd_new_identifier);
4619 redraw_screen = TRUE;
4622 if (mus_new_identifier != NULL || force_reload_mus)
4624 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
4626 InitMusic(mus_new_identifier);
4628 redraw_screen = TRUE;
4633 InitGfxBackground();
4635 /* force redraw of (open or closed) door graphics */
4636 SetDoorState(DOOR_OPEN_ALL);
4637 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
4641 void KeyboardAutoRepeatOffUnlessAutoplay()
4643 if (global.autoplay_leveldir == NULL)
4644 KeyboardAutoRepeatOff();
4648 /* ========================================================================= */
4650 /* ========================================================================= */
4654 InitGlobal(); /* initialize some global variables */
4656 if (options.execute_command)
4657 Execute_Command(options.execute_command);
4659 if (options.serveronly)
4661 #if defined(PLATFORM_UNIX)
4662 NetworkServer(options.server_port, options.serveronly);
4664 Error(ERR_WARN, "networking only supported in Unix version");
4667 exit(0); /* never reached, server loops forever */
4674 InitArtworkInfo(); /* needed before loading gfx, sound & music */
4675 InitArtworkConfig(); /* needed before forking sound child process */
4680 InitRND(NEW_RANDOMIZE);
4681 InitSimpleRND(NEW_RANDOMIZE);
4686 InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
4689 InitEventFilter(FilterMouseMotionEvents);
4691 InitElementPropertiesStatic();
4692 InitElementPropertiesEngine(GAME_VERSION_ACTUAL);
4697 InitLevelArtworkInfo();
4699 InitImages(); /* needs to know current level directory */
4700 InitSound(NULL); /* needs to know current level directory */
4701 InitMusic(NULL); /* needs to know current level directory */
4703 InitGfxBackground();
4705 if (global.autoplay_leveldir)
4710 else if (global.convert_leveldir)
4716 game_status = GAME_MODE_MAIN;
4724 InitNetworkServer();
4727 void CloseAllAndExit(int exit_value)
4732 CloseAudio(); /* called after freeing sounds (needed for SDL) */
4740 #if defined(TARGET_SDL)
4741 if (network_server) /* terminate network server */
4742 SDL_KillThread(server_thread);
4745 CloseVideoDisplay();
4746 ClosePlatformDependentStuff();