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"
28 #include "conf_e2g.c" /* include auto-generated data structure definitions */
29 #include "conf_esg.c" /* include auto-generated data structure definitions */
30 #include "conf_e2s.c" /* include auto-generated data structure definitions */
31 #include "conf_fnt.c" /* include auto-generated data structure definitions */
34 #define CONFIG_TOKEN_FONT_INITIAL "font.initial"
37 struct FontBitmapInfo font_initial[NUM_INITIAL_FONTS];
40 static void InitTileClipmasks()
43 #if defined(TARGET_X11)
44 XGCValues clip_gc_values;
45 unsigned long clip_gc_valuemask;
47 #if defined(TARGET_X11_NATIVE)
57 tile_needs_clipping[] =
59 { GFX_SPIELER1_UP, 4 },
60 { GFX_SPIELER1_DOWN, 4 },
61 { GFX_SPIELER1_LEFT, 4 },
62 { GFX_SPIELER1_RIGHT, 4 },
63 { GFX_SPIELER1_PUSH_LEFT, 4 },
64 { GFX_SPIELER1_PUSH_RIGHT, 4 },
65 { GFX_SPIELER2_UP, 4 },
66 { GFX_SPIELER2_DOWN, 4 },
67 { GFX_SPIELER2_LEFT, 4 },
68 { GFX_SPIELER2_RIGHT, 4 },
69 { GFX_SPIELER2_PUSH_LEFT, 4 },
70 { GFX_SPIELER2_PUSH_RIGHT, 4 },
71 { GFX_SPIELER3_UP, 4 },
72 { GFX_SPIELER3_DOWN, 4 },
73 { GFX_SPIELER3_LEFT, 4 },
74 { GFX_SPIELER3_RIGHT, 4 },
75 { GFX_SPIELER3_PUSH_LEFT, 4 },
76 { GFX_SPIELER3_PUSH_RIGHT, 4 },
77 { GFX_SPIELER4_UP, 4 },
78 { GFX_SPIELER4_DOWN, 4 },
79 { GFX_SPIELER4_LEFT, 4 },
80 { GFX_SPIELER4_RIGHT, 4 },
81 { GFX_SPIELER4_PUSH_LEFT, 4 },
82 { GFX_SPIELER4_PUSH_RIGHT, 4 },
84 { GFX_MURPHY_GO_LEFT, 3 },
85 { GFX_MURPHY_GO_RIGHT, 3 },
86 { GFX_MURPHY_SNAP_UP, 1 },
87 { GFX_MURPHY_SNAP_DOWN, 1 },
88 { GFX_MURPHY_SNAP_RIGHT, 1 },
89 { GFX_MURPHY_SNAP_LEFT, 1 },
90 { GFX_MURPHY_PUSH_RIGHT, 1 },
91 { GFX_MURPHY_PUSH_LEFT, 1 },
96 { GFX_SOKOBAN_OBJEKT, 1 },
97 { GFX_FUNKELN_BLAU, 3 },
98 { GFX_FUNKELN_WEISS, 3 },
99 { GFX2_SHIELD_PASSIVE, 3 },
100 { GFX2_SHIELD_ACTIVE, 3 },
105 #endif /* TARGET_X11_NATIVE */
106 #endif /* TARGET_X11 */
110 /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
111 for (i=0; i<NUM_TILES; i++)
112 tile_clipmask[i] = None;
114 #if defined(TARGET_X11)
115 /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
116 often very slow when preparing a masked XCopyArea() for big Pixmaps.
117 To prevent this, create small (tile-sized) mask Pixmaps which will then
118 be set much faster with XSetClipOrigin() and speed things up a lot. */
120 clip_gc_values.graphics_exposures = False;
121 clip_gc_valuemask = GCGraphicsExposures;
122 tile_clip_gc = XCreateGC(display, window->drawable,
123 clip_gc_valuemask, &clip_gc_values);
126 for (i=0; i<NUM_BITMAPS; i++)
128 if (pix[i]->clip_mask)
130 clip_gc_values.graphics_exposures = False;
131 clip_gc_values.clip_mask = pix[i]->clip_mask;
132 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
133 pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
134 clip_gc_valuemask, &clip_gc_values);
139 #if defined(TARGET_X11_NATIVE)
142 /* create graphic context structures needed for clipping */
143 clip_gc_values.graphics_exposures = False;
144 clip_gc_valuemask = GCGraphicsExposures;
145 copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
146 clip_gc_valuemask, &clip_gc_values);
148 /* create only those clipping Pixmaps we really need */
149 for (i=0; tile_needs_clipping[i].start>=0; i++)
153 for (j=0; j<tile_needs_clipping[i].count; j++)
155 int tile = tile_needs_clipping[i].start + j;
161 getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
162 src_pixmap = src_bitmap->clip_mask;
164 tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
167 XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
168 src_x, src_y, TILEX, TILEY, 0, 0);
172 XFreeGC(display, copy_clipmask_gc);
175 #endif /* TARGET_X11_NATIVE */
176 #endif /* TARGET_X11 */
180 void FreeTileClipmasks()
183 #if defined(TARGET_X11)
186 for (i=0; i<NUM_TILES; i++)
188 if (tile_clipmask[i] != None)
190 XFreePixmap(display, tile_clipmask[i]);
191 tile_clipmask[i] = None;
196 XFreeGC(display, tile_clip_gc);
200 for (i=0; i<NUM_BITMAPS; i++)
202 if (pix[i] != NULL && pix[i]->stored_clip_gc)
204 XFreeGC(display, pix[i]->stored_clip_gc);
205 pix[i]->stored_clip_gc = None;
210 #endif /* TARGET_X11 */
216 FreeLevelEditorGadgets();
225 static boolean gadgets_initialized = FALSE;
227 if (gadgets_initialized)
230 CreateLevelEditorGadgets();
234 CreateScreenGadgets();
236 gadgets_initialized = TRUE;
239 void InitElementSmallImages()
241 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
242 int num_property_mappings = getImageListPropertyMappingSize();
245 /* initialize normal images from static configuration */
246 for (i=0; element_to_graphic[i].element > -1; i++)
247 CreateImageWithSmallImages(element_to_graphic[i].graphic);
249 /* initialize special images from static configuration */
250 for (i=0; element_to_special_graphic[i].element > -1; i++)
251 CreateImageWithSmallImages(element_to_special_graphic[i].graphic);
253 /* initialize images from dynamic configuration */
254 for (i=0; i < num_property_mappings; i++)
255 if (property_mapping[i].artwork_index < MAX_NUM_ELEMENTS)
256 CreateImageWithSmallImages(property_mapping[i].artwork_index);
259 static int getFontBitmapID(int font_nr)
263 if (game_status == MAINMENU || game_status == TYPENAME)
264 special = GFX_SPECIAL_ARG_MAIN;
265 else if (game_status == CHOOSELEVEL)
266 special = GFX_SPECIAL_ARG_LEVELS;
267 else if (game_status == HALLOFFAME)
268 special = GFX_SPECIAL_ARG_SCORES;
269 else if (game_status == LEVELED)
270 special = GFX_SPECIAL_ARG_EDITOR;
271 else if (game_status == HELPSCREEN)
272 special = GFX_SPECIAL_ARG_INFO;
273 else if (game_status == SETUP)
274 special = GFX_SPECIAL_ARG_SETUP;
275 else if (game_status == PSEUDO_PREVIEW)
276 special = GFX_SPECIAL_ARG_PREVIEW;
277 else if (game_status == PLAYING || game_status == PSEUDO_DOOR)
278 special = GFX_SPECIAL_ARG_DOOR;
281 return font_info[font_nr].special_bitmap_id[special];
286 void InitFontGraphicInfo()
288 static struct FontBitmapInfo *font_bitmap_info = NULL;
289 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
290 int num_property_mappings = getImageListPropertyMappingSize();
291 int num_font_bitmaps = NUM_FONTS;
294 if (graphic_info == NULL) /* still at startup phase */
296 InitFontInfo(font_initial, NUM_INITIAL_FONTS, getFontBitmapID);
301 /* ---------- initialize font graphic definitions ---------- */
303 /* always start with reliable default values (normal font graphics) */
304 for (i=0; i < NUM_FONTS; i++)
305 font_info[i].graphic = FONT_INITIAL_1;
307 /* initialize normal font/graphic mapping from static configuration */
308 for (i=0; font_to_graphic[i].font_nr > -1; i++)
310 int font_nr = font_to_graphic[i].font_nr;
311 int special = font_to_graphic[i].special;
312 int graphic = font_to_graphic[i].graphic;
317 font_info[font_nr].graphic = graphic;
320 /* always start with reliable default values (special font graphics) */
321 for (i=0; i < NUM_FONTS; i++)
323 for (j=0; j < NUM_SPECIAL_GFX_ARGS; j++)
325 font_info[i].special_graphic[j] = font_info[i].graphic;
326 font_info[i].special_bitmap_id[j] = i;
330 /* initialize special font/graphic mapping from static configuration */
331 for (i=0; font_to_graphic[i].font_nr > -1; i++)
333 int font_nr = font_to_graphic[i].font_nr;
334 int special = font_to_graphic[i].special;
335 int graphic = font_to_graphic[i].graphic;
337 if (special >= 0 && special < NUM_SPECIAL_GFX_ARGS)
339 font_info[font_nr].special_graphic[special] = graphic;
340 font_info[font_nr].special_bitmap_id[special] = num_font_bitmaps;
345 /* initialize special element/graphic mapping from dynamic configuration */
346 for (i=0; i < num_property_mappings; i++)
348 int font_nr = property_mapping[i].base_index - MAX_NUM_ELEMENTS;
349 int special = property_mapping[i].ext3_index;
350 int graphic = property_mapping[i].artwork_index;
355 if (special >= 0 && special < NUM_SPECIAL_GFX_ARGS)
357 font_info[font_nr].special_graphic[special] = graphic;
358 font_info[font_nr].special_bitmap_id[special] = num_font_bitmaps;
363 /* ---------- initialize font bitmap array ---------- */
365 if (font_bitmap_info != NULL)
366 free(font_bitmap_info);
369 checked_calloc(num_font_bitmaps * sizeof(struct FontBitmapInfo));
371 /* ---------- initialize font bitmap definitions ---------- */
373 for (i=0; i < NUM_FONTS; i++)
375 if (i < NUM_INITIAL_FONTS)
377 font_bitmap_info[i] = font_initial[i];
381 for (j=0; j < NUM_SPECIAL_GFX_ARGS; j++)
383 int font_bitmap_id = font_info[i].special_bitmap_id[j];
384 int graphic = font_info[i].special_graphic[j];
386 /* copy font relevant information from graphics information */
387 font_bitmap_info[font_bitmap_id].bitmap = graphic_info[graphic].bitmap;
388 font_bitmap_info[font_bitmap_id].src_x = graphic_info[graphic].src_x;
389 font_bitmap_info[font_bitmap_id].src_y = graphic_info[graphic].src_y;
390 font_bitmap_info[font_bitmap_id].width = graphic_info[graphic].width;
391 font_bitmap_info[font_bitmap_id].height = graphic_info[graphic].height;
392 font_bitmap_info[font_bitmap_id].draw_x = graphic_info[graphic].draw_x;
393 font_bitmap_info[font_bitmap_id].draw_y = graphic_info[graphic].draw_y;
397 InitFontInfo(font_bitmap_info, num_font_bitmaps, getFontBitmapID);
400 void InitElementGraphicInfo()
402 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
403 int num_property_mappings = getImageListPropertyMappingSize();
406 /* set values to -1 to identify later as "uninitialized" values */
407 for (i=0; i<MAX_NUM_ELEMENTS; i++)
409 for (act=0; act<NUM_ACTIONS; act++)
411 element_info[i].graphic[act] = -1;
413 for (dir=0; dir<NUM_DIRECTIONS; dir++)
414 element_info[i].direction_graphic[act][dir] = -1;
418 /* initialize normal element/graphic mapping from static configuration */
419 for (i=0; element_to_graphic[i].element > -1; i++)
421 int element = element_to_graphic[i].element;
422 int action = element_to_graphic[i].action;
423 int direction = element_to_graphic[i].direction;
424 int graphic = element_to_graphic[i].graphic;
427 action = ACTION_DEFAULT;
430 element_info[element].direction_graphic[action][direction] = graphic;
432 element_info[element].graphic[action] = graphic;
435 /* initialize normal element/graphic mapping from dynamic configuration */
436 for (i=0; i < num_property_mappings; i++)
438 int element = property_mapping[i].base_index;
439 int action = property_mapping[i].ext1_index;
440 int direction = property_mapping[i].ext2_index;
441 int special = property_mapping[i].ext3_index;
442 int graphic = property_mapping[i].artwork_index;
444 if (element >= MAX_NUM_ELEMENTS || special != -1)
448 action = ACTION_DEFAULT;
451 element_info[element].direction_graphic[action][direction] = graphic;
453 element_info[element].graphic[action] = graphic;
456 /* now set all '-1' values to element specific default values */
457 for (i=0; i<MAX_NUM_ELEMENTS; i++)
459 int default_action_graphic = element_info[i].graphic[ACTION_DEFAULT];
460 int default_action_direction_graphic[NUM_DIRECTIONS];
462 if (default_action_graphic == -1)
463 default_action_graphic = IMG_CHAR_QUESTION;
465 for (dir=0; dir<NUM_DIRECTIONS; dir++)
467 default_action_direction_graphic[dir] =
468 element_info[i].direction_graphic[ACTION_DEFAULT][dir];
470 if (default_action_direction_graphic[dir] == -1)
471 default_action_direction_graphic[dir] = default_action_graphic;
474 for (act=0; act<NUM_ACTIONS; act++)
476 for (dir=0; dir<NUM_DIRECTIONS; dir++)
478 int default_direction_graphic = element_info[i].graphic[act];
480 /* no graphic for current action -- use default direction graphic */
481 if (default_direction_graphic == -1)
482 default_direction_graphic = default_action_direction_graphic[dir];
484 if (element_info[i].direction_graphic[act][dir] == -1)
485 element_info[i].direction_graphic[act][dir] =
486 default_direction_graphic;
489 /* no graphic for this specific action -- use default action graphic */
490 if (element_info[i].graphic[act] == -1)
491 element_info[i].graphic[act] = default_action_graphic;
499 for (i=0; i<MAX_NUM_ELEMENTS; i++)
500 if (element_info[i].graphic[ACTION_DEFAULT] == IMG_CHAR_QUESTION &&
501 i != EL_CHAR_QUESTION)
502 Error(ERR_RETURN, "warning: no graphic for element '%s' (%d)",
503 element_info[i].token_name, i);
509 void InitElementSpecialGraphicInfo()
511 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
512 int num_property_mappings = getImageListPropertyMappingSize();
515 /* always start with reliable default values */
516 for (i=0; i < MAX_NUM_ELEMENTS; i++)
517 for (j=0; j < NUM_SPECIAL_GFX_ARGS; j++)
518 element_info[i].special_graphic[j] =
519 element_info[i].graphic[ACTION_DEFAULT];
521 /* initialize special element/graphic mapping from static configuration */
522 for (i=0; element_to_special_graphic[i].element > -1; i++)
524 int element = element_to_special_graphic[i].element;
525 int special = element_to_special_graphic[i].special;
526 int graphic = element_to_special_graphic[i].graphic;
527 boolean base_redefined = getImageListEntry(el2img(element))->redefined;
528 boolean special_redefined = getImageListEntry(graphic)->redefined;
530 if (base_redefined && !special_redefined)
533 element_info[element].special_graphic[special] = graphic;
536 /* initialize special element/graphic mapping from dynamic configuration */
537 for (i=0; i < num_property_mappings; i++)
539 int element = property_mapping[i].base_index;
540 int special = property_mapping[i].ext3_index;
541 int graphic = property_mapping[i].artwork_index;
543 if (element >= MAX_NUM_ELEMENTS)
546 if (special >= 0 && special < NUM_SPECIAL_GFX_ARGS)
547 element_info[element].special_graphic[special] = graphic;
551 static void set_graphic_parameters(int graphic, char **parameter_raw)
553 Bitmap *src_bitmap = getBitmapFromImageID(graphic);
554 int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
555 int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
556 int parameter[NUM_GFX_ARGS];
559 /* get integer values from string parameters */
560 for (i=0; i < NUM_GFX_ARGS; i++)
562 get_parameter_value(image_config_suffix[i].token, parameter_raw[i],
563 image_config_suffix[i].type);
565 graphic_info[graphic].bitmap = src_bitmap;
567 /* start with reliable default values */
568 graphic_info[graphic].src_x = 0;
569 graphic_info[graphic].src_y = 0;
570 graphic_info[graphic].width = TILEX;
571 graphic_info[graphic].height = TILEY;
572 graphic_info[graphic].offset_x = 0; /* one or both of these values ... */
573 graphic_info[graphic].offset_y = 0; /* ... will be corrected later */
575 /* optional x and y tile position of animation frame sequence */
576 if (parameter[GFX_ARG_XPOS] != ARG_UNDEFINED_VALUE)
577 graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
578 if (parameter[GFX_ARG_YPOS] != ARG_UNDEFINED_VALUE)
579 graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
581 /* optional x and y pixel position of animation frame sequence */
582 if (parameter[GFX_ARG_X] != ARG_UNDEFINED_VALUE)
583 graphic_info[graphic].src_x = parameter[GFX_ARG_X];
584 if (parameter[GFX_ARG_Y] != ARG_UNDEFINED_VALUE)
585 graphic_info[graphic].src_y = parameter[GFX_ARG_Y];
587 /* optional width and height of each animation frame */
588 if (parameter[GFX_ARG_WIDTH] != ARG_UNDEFINED_VALUE)
589 graphic_info[graphic].width = parameter[GFX_ARG_WIDTH];
590 if (parameter[GFX_ARG_HEIGHT] != ARG_UNDEFINED_VALUE)
591 graphic_info[graphic].height = parameter[GFX_ARG_HEIGHT];
593 /* correct x or y offset dependant of vertical or horizontal frame order */
594 if (parameter[GFX_ARG_VERTICAL]) /* frames are ordered vertically */
596 if (parameter[GFX_ARG_OFFSET] != ARG_UNDEFINED_VALUE)
597 graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET];
599 graphic_info[graphic].offset_y = graphic_info[graphic].height;
601 else /* frames are ordered horizontally */
603 if (parameter[GFX_ARG_OFFSET] != ARG_UNDEFINED_VALUE)
604 graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET];
606 graphic_info[graphic].offset_x = graphic_info[graphic].width;
609 /* optionally, the x and y offset of frames can be specified directly */
610 if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
611 graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
612 if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
613 graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
615 /* automatically determine correct number of frames, if not defined */
616 if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
617 graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
618 else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
619 graphic_info[graphic].anim_frames = num_xtiles;
620 else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
621 graphic_info[graphic].anim_frames = num_ytiles;
623 graphic_info[graphic].anim_frames = 1;
625 graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
626 if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
627 graphic_info[graphic].anim_delay = 1;
629 if (parameter[GFX_ARG_ANIM_MODE] != ANIM_NONE)
630 graphic_info[graphic].anim_mode = parameter[GFX_ARG_ANIM_MODE];
631 else if (graphic_info[graphic].anim_frames > 1)
632 graphic_info[graphic].anim_mode = ANIM_LOOP;
634 /* automatically determine correct start frame, if not defined */
635 if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
636 graphic_info[graphic].anim_start_frame = 0;
637 else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
638 graphic_info[graphic].anim_start_frame =
639 graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
641 graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];
643 /* animation synchronized with global frame counter, not move position */
644 graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
646 /* this is only used for toon animations */
647 graphic_info[graphic].step_offset = parameter[GFX_ARG_STEP_OFFSET];
648 graphic_info[graphic].step_delay = parameter[GFX_ARG_STEP_DELAY];
650 /* this is only used for drawing font characters */
651 graphic_info[graphic].draw_x = parameter[GFX_ARG_DRAW_XOFFSET];
652 graphic_info[graphic].draw_y = parameter[GFX_ARG_DRAW_YOFFSET];
655 static void InitGraphicInfo()
657 int fallback_graphic = IMG_CHAR_EXCLAM;
658 struct FileInfo *fallback_image = getImageListEntry(fallback_graphic);
659 Bitmap *fallback_bitmap = getBitmapFromImageID(fallback_graphic);
660 int num_images = getImageListSize();
663 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
664 static boolean clipmasks_initialized = FALSE;
666 XGCValues clip_gc_values;
667 unsigned long clip_gc_valuemask;
668 GC copy_clipmask_gc = None;
671 if (graphic_info != NULL)
674 graphic_info = checked_calloc(num_images * sizeof(struct GraphicInfo));
676 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
677 if (clipmasks_initialized)
679 for (i=0; i<num_images; i++)
681 if (graphic_info[i].clip_mask)
682 XFreePixmap(display, graphic_info[i].clip_mask);
683 if (graphic_info[i].clip_gc)
684 XFreeGC(display, graphic_info[i].clip_gc);
686 graphic_info[i].clip_mask = None;
687 graphic_info[i].clip_gc = None;
692 for (i=0; i<num_images; i++)
694 struct FileInfo *image = getImageListEntry(i);
697 int first_frame, last_frame;
699 set_graphic_parameters(i, image->parameter);
701 /* now check if no animation frames are outside of the loaded image */
703 if (graphic_info[i].bitmap == NULL)
704 continue; /* skip check for optional images that are undefined */
707 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
708 if (src_x < 0 || src_y < 0 ||
709 src_x + TILEX > src_bitmap->width ||
710 src_y + TILEY > src_bitmap->height)
712 Error(ERR_RETURN_LINE, "-");
713 Error(ERR_RETURN, "warning: error found in config file:");
714 Error(ERR_RETURN, "- config file: '%s'",
715 getImageConfigFilename());
716 Error(ERR_RETURN, "- config token: '%s'",
717 getTokenFromImageID(i));
718 Error(ERR_RETURN, "- image file: '%s'",
719 src_bitmap->source_filename);
721 "error: first animation frame out of bounds (%d, %d)",
723 Error(ERR_RETURN, "custom graphic rejected for this element/action");
725 if (i == fallback_graphic)
726 Error(ERR_EXIT, "fatal error: no fallback graphic available");
728 Error(ERR_RETURN, "fallback done to 'char_exclam' for this graphic");
729 Error(ERR_RETURN_LINE, "-");
731 set_graphic_parameters(i, fallback_image->default_parameter);
732 graphic_info[i].bitmap = fallback_bitmap;
735 last_frame = graphic_info[i].anim_frames - 1;
736 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
737 if (src_x < 0 || src_y < 0 ||
738 src_x + TILEX > src_bitmap->width ||
739 src_y + TILEY > src_bitmap->height)
741 Error(ERR_RETURN_LINE, "-");
742 Error(ERR_RETURN, "warning: error found in config file:");
743 Error(ERR_RETURN, "- config file: '%s'",
744 getImageConfigFilename());
745 Error(ERR_RETURN, "- config token: '%s'",
746 getTokenFromImageID(i));
747 Error(ERR_RETURN, "- image file: '%s'",
748 src_bitmap->source_filename);
750 "error: last animation frame (%d) out of bounds (%d, %d)",
751 last_frame, src_x, src_y);
752 Error(ERR_RETURN, "custom graphic rejected for this element/action");
754 if (i == fallback_graphic)
755 Error(ERR_EXIT, "fatal error: no fallback graphic available");
757 Error(ERR_RETURN, "fallback done to 'char_exclam' for this graphic");
758 Error(ERR_RETURN_LINE, "-");
760 set_graphic_parameters(i, fallback_image->default_parameter);
761 graphic_info[i].bitmap = fallback_bitmap;
764 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
765 /* currently we need only a tile clip mask from the first frame */
766 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
768 if (copy_clipmask_gc == None)
770 clip_gc_values.graphics_exposures = False;
771 clip_gc_valuemask = GCGraphicsExposures;
772 copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
773 clip_gc_valuemask, &clip_gc_values);
776 graphic_info[i].clip_mask =
777 XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
779 src_pixmap = src_bitmap->clip_mask;
780 XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
781 copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
783 clip_gc_values.graphics_exposures = False;
784 clip_gc_values.clip_mask = graphic_info[i].clip_mask;
785 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
787 graphic_info[i].clip_gc =
788 XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
792 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
793 if (copy_clipmask_gc)
794 XFreeGC(display, copy_clipmask_gc);
796 clipmasks_initialized = TRUE;
800 static void InitElementSoundInfo()
802 struct PropertyMapping *property_mapping = getSoundListPropertyMapping();
803 int num_property_mappings = getSoundListPropertyMappingSize();
806 /* set values to -1 to identify later as "uninitialized" values */
807 for (i=0; i < MAX_NUM_ELEMENTS; i++)
808 for (act=0; act < NUM_ACTIONS; act++)
809 element_info[i].sound[act] = -1;
811 /* initialize element/sound mapping from static configuration */
812 for (i=0; element_to_sound[i].element > -1; i++)
814 int element = element_to_sound[i].element;
815 int action = element_to_sound[i].action;
816 int sound = element_to_sound[i].sound;
817 boolean is_class = element_to_sound[i].is_class;
820 action = ACTION_DEFAULT;
823 element_info[element].sound[action] = sound;
825 for (j=0; j < MAX_NUM_ELEMENTS; j++)
826 if (strcmp(element_info[j].class_name,
827 element_info[element].class_name) == 0)
828 element_info[j].sound[action] = sound;
831 /* initialize element/sound mapping from dynamic configuration */
832 for (i=0; i < num_property_mappings; i++)
834 int element = property_mapping[i].base_index;
835 int action = property_mapping[i].ext1_index;
836 int sound = property_mapping[i].artwork_index;
838 if (element >= MAX_NUM_ELEMENTS)
842 action = ACTION_DEFAULT;
844 element_info[element].sound[action] = sound;
847 /* initialize element class/sound mapping from dynamic configuration */
848 for (i=0; i < num_property_mappings; i++)
850 int element_class = property_mapping[i].base_index - MAX_NUM_ELEMENTS;
851 int action = property_mapping[i].ext1_index;
852 int sound = property_mapping[i].artwork_index;
854 if (element_class < 0 || element_class >= MAX_NUM_ELEMENTS)
858 action = ACTION_DEFAULT;
860 for (j=0; j < MAX_NUM_ELEMENTS; j++)
861 if (strcmp(element_info[j].class_name,
862 element_info[element_class].class_name) == 0)
863 element_info[j].sound[action] = sound;
866 /* now set all '-1' values to element specific default values */
867 for (i=0; i<MAX_NUM_ELEMENTS; i++)
869 int default_action_sound = element_info[i].sound[ACTION_DEFAULT];
871 for (act=0; act < NUM_ACTIONS; act++)
873 /* no sound for this specific action -- use default action sound */
874 if (element_info[i].sound[act] == -1)
875 element_info[i].sound[act] = default_action_sound;
880 static void set_sound_parameters(int sound, char **parameter_raw)
882 int parameter[NUM_SND_ARGS];
885 /* get integer values from string parameters */
886 for (i=0; i < NUM_SND_ARGS; i++)
888 get_parameter_value(sound_config_suffix[i].token, parameter_raw[i],
889 sound_config_suffix[i].type);
891 /* explicit loop mode setting in configuration overrides default value */
892 if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
893 sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP];
896 static void InitSoundInfo()
898 struct PropertyMapping *property_mapping = getSoundListPropertyMapping();
899 int num_property_mappings = getSoundListPropertyMappingSize();
900 int *sound_effect_properties;
901 int num_sounds = getSoundListSize();
904 if (sound_info != NULL)
907 sound_effect_properties = checked_calloc(num_sounds * sizeof(int));
908 sound_info = checked_calloc(num_sounds * sizeof(struct SoundInfo));
910 /* initialize sound effect for all elements to "no sound" */
911 for (i=0; i<MAX_NUM_ELEMENTS; i++)
912 for (j=0; j<NUM_ACTIONS; j++)
913 element_info[i].sound[j] = SND_UNDEFINED;
915 for (i=0; i<num_sounds; i++)
917 struct FileInfo *sound = getSoundListEntry(i);
918 int len_effect_text = strlen(sound->token);
920 sound_effect_properties[i] = ACTION_OTHER;
921 sound_info[i].loop = FALSE;
923 /* determine all loop sounds and identify certain sound classes */
925 for (j=0; element_action_info[j].suffix; j++)
927 int len_action_text = strlen(element_action_info[j].suffix);
929 if (len_action_text < len_effect_text &&
930 strcmp(&sound->token[len_effect_text - len_action_text],
931 element_action_info[j].suffix) == 0)
933 sound_effect_properties[i] = element_action_info[j].value;
935 if (element_action_info[j].is_loop_sound)
936 sound_info[i].loop = TRUE;
940 /* associate elements and some selected sound actions */
942 for (j=0; j<MAX_NUM_ELEMENTS; j++)
944 if (element_info[j].class_name)
946 int len_class_text = strlen(element_info[j].class_name);
948 if (len_class_text + 1 < len_effect_text &&
949 strncmp(sound->token,
950 element_info[j].class_name, len_class_text) == 0 &&
951 sound->token[len_class_text] == '.')
953 int sound_action_value = sound_effect_properties[i];
955 element_info[j].sound[sound_action_value] = i;
960 set_sound_parameters(i, sound->parameter);
963 free(sound_effect_properties);
965 /* initialize element/sound mapping from dynamic configuration */
966 for (i=0; i < num_property_mappings; i++)
968 int element = property_mapping[i].base_index;
969 int action = property_mapping[i].ext1_index;
970 int sound = property_mapping[i].artwork_index;
973 action = ACTION_DEFAULT;
975 element_info[element].sound[action] = sound;
981 int element = EL_CUSTOM_11;
984 while (element_action_info[j].suffix)
986 printf("element %d, sound action '%s' == %d\n",
987 element, element_action_info[j].suffix,
988 element_info[element].sound[j]);
993 PlaySoundLevelElementAction(0,0, EL_CUSTOM_11, ACTION_PUSHING);
999 int element = EL_SAND;
1000 int sound_action = ACTION_DIGGING;
1003 while (element_action_info[j].suffix)
1005 if (element_action_info[j].value == sound_action)
1006 printf("element %d, sound action '%s' == %d\n",
1007 element, element_action_info[j].suffix,
1008 element_info[element].sound[sound_action]);
1015 static void ReinitializeGraphics()
1017 InitElementGraphicInfo(); /* element game graphic mapping */
1018 InitElementSpecialGraphicInfo(); /* element special graphic mapping */
1019 InitGraphicInfo(); /* graphic properties mapping */
1021 InitElementSmallImages(); /* create editor and preview images */
1022 InitFontGraphicInfo(); /* initialize text drawing functions */
1024 SetMainBackgroundImage(IMG_BACKGROUND);
1025 SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
1031 static void ReinitializeSounds()
1033 InitElementSoundInfo(); /* element game sound mapping */
1034 InitSoundInfo(); /* sound properties mapping */
1037 InitElementSoundInfo(); /* element game sound mapping */
1040 InitPlaySoundLevel(); /* internal game sound settings */
1043 static void ReinitializeMusic()
1045 /* currently nothing to do */
1048 void InitElementProperties()
1052 static int ep_amoebalive[] =
1059 static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
1061 static int ep_amoeboid[] =
1069 static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
1071 static int ep_schluessel[] =
1082 static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
1084 static int ep_pforte[] =
1103 EL_SWITCHGATE_OPENING,
1104 EL_SWITCHGATE_CLOSED,
1105 EL_SWITCHGATE_CLOSING,
1107 EL_TIMEGATE_OPENING,
1109 EL_TIMEGATE_CLOSING,
1113 EL_TUBE_VERTICAL_LEFT,
1114 EL_TUBE_VERTICAL_RIGHT,
1115 EL_TUBE_HORIZONTAL_UP,
1116 EL_TUBE_HORIZONTAL_DOWN,
1122 static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
1124 static int ep_solid[] =
1128 EL_EXPANDABLE_WALL_HORIZONTAL,
1129 EL_EXPANDABLE_WALL_VERTICAL,
1130 EL_EXPANDABLE_WALL_ANY,
1143 EL_QUICKSAND_FILLING,
1144 EL_QUICKSAND_EMPTYING,
1146 EL_MAGIC_WALL_ACTIVE,
1147 EL_MAGIC_WALL_EMPTYING,
1148 EL_MAGIC_WALL_FILLING,
1152 EL_BD_MAGIC_WALL_ACTIVE,
1153 EL_BD_MAGIC_WALL_EMPTYING,
1154 EL_BD_MAGIC_WALL_FULL,
1155 EL_BD_MAGIC_WALL_FILLING,
1156 EL_BD_MAGIC_WALL_DEAD,
1165 EL_SP_TERMINAL_ACTIVE,
1169 EL_INVISIBLE_WALL_ACTIVE,
1170 EL_SWITCHGATE_SWITCH_UP,
1171 EL_SWITCHGATE_SWITCH_DOWN,
1173 EL_TIMEGATE_SWITCH_ACTIVE,
1185 /* the following elements are a direct copy of "indestructible" elements,
1186 except "EL_ACID", which is "indestructible", but not "solid"! */
1191 EL_ACID_POOL_TOPLEFT,
1192 EL_ACID_POOL_TOPRIGHT,
1193 EL_ACID_POOL_BOTTOMLEFT,
1194 EL_ACID_POOL_BOTTOM,
1195 EL_ACID_POOL_BOTTOMRIGHT,
1196 EL_SP_HARDWARE_GRAY,
1197 EL_SP_HARDWARE_GREEN,
1198 EL_SP_HARDWARE_BLUE,
1200 EL_SP_HARDWARE_YELLOW,
1201 EL_SP_HARDWARE_BASE_1,
1202 EL_SP_HARDWARE_BASE_2,
1203 EL_SP_HARDWARE_BASE_3,
1204 EL_SP_HARDWARE_BASE_4,
1205 EL_SP_HARDWARE_BASE_5,
1206 EL_SP_HARDWARE_BASE_6,
1207 EL_INVISIBLE_STEELWALL,
1208 EL_INVISIBLE_STEELWALL_ACTIVE,
1209 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
1210 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
1211 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
1212 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
1213 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
1214 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
1215 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
1216 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
1217 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
1218 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
1219 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
1220 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
1222 EL_LIGHT_SWITCH_ACTIVE,
1223 EL_SIGN_EXCLAMATION,
1224 EL_SIGN_RADIOACTIVITY,
1235 EL_STEELWALL_SLANTED,
1258 EL_SWITCHGATE_OPENING,
1259 EL_SWITCHGATE_CLOSED,
1260 EL_SWITCHGATE_CLOSING,
1262 EL_TIMEGATE_OPENING,
1264 EL_TIMEGATE_CLOSING,
1268 EL_TUBE_VERTICAL_LEFT,
1269 EL_TUBE_VERTICAL_RIGHT,
1270 EL_TUBE_HORIZONTAL_UP,
1271 EL_TUBE_HORIZONTAL_DOWN,
1277 static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1279 static int ep_indestructible[] =
1283 EL_ACID_POOL_TOPLEFT,
1284 EL_ACID_POOL_TOPRIGHT,
1285 EL_ACID_POOL_BOTTOMLEFT,
1286 EL_ACID_POOL_BOTTOM,
1287 EL_ACID_POOL_BOTTOMRIGHT,
1288 EL_SP_HARDWARE_GRAY,
1289 EL_SP_HARDWARE_GREEN,
1290 EL_SP_HARDWARE_BLUE,
1292 EL_SP_HARDWARE_YELLOW,
1293 EL_SP_HARDWARE_BASE_1,
1294 EL_SP_HARDWARE_BASE_2,
1295 EL_SP_HARDWARE_BASE_3,
1296 EL_SP_HARDWARE_BASE_4,
1297 EL_SP_HARDWARE_BASE_5,
1298 EL_SP_HARDWARE_BASE_6,
1299 EL_INVISIBLE_STEELWALL,
1300 EL_INVISIBLE_STEELWALL_ACTIVE,
1301 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
1302 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
1303 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
1304 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
1305 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
1306 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
1307 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
1308 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
1309 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
1310 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
1311 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
1312 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
1314 EL_LIGHT_SWITCH_ACTIVE,
1315 EL_SIGN_EXCLAMATION,
1316 EL_SIGN_RADIOACTIVITY,
1327 EL_STEELWALL_SLANTED,
1350 EL_SWITCHGATE_OPENING,
1351 EL_SWITCHGATE_CLOSED,
1352 EL_SWITCHGATE_CLOSING,
1354 EL_TIMEGATE_OPENING,
1356 EL_TIMEGATE_CLOSING,
1360 EL_TUBE_VERTICAL_LEFT,
1361 EL_TUBE_VERTICAL_RIGHT,
1362 EL_TUBE_HORIZONTAL_UP,
1363 EL_TUBE_HORIZONTAL_DOWN,
1369 static int ep_indestructible_num = SIZEOF_ARRAY_INT(ep_indestructible);
1371 static int ep_slippery[] =
1385 EL_ROBOT_WHEEL_ACTIVE,
1391 EL_ACID_POOL_TOPLEFT,
1392 EL_ACID_POOL_TOPRIGHT,
1402 EL_STEELWALL_SLANTED,
1406 static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1408 static int ep_enemy[] =
1421 static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1423 static int ep_mauer[] =
1448 EL_EXPANDABLE_WALL_HORIZONTAL,
1449 EL_EXPANDABLE_WALL_VERTICAL,
1450 EL_EXPANDABLE_WALL_ANY,
1451 EL_EXPANDABLE_WALL_GROWING,
1458 EL_SP_HARDWARE_GRAY,
1459 EL_SP_HARDWARE_GREEN,
1460 EL_SP_HARDWARE_BLUE,
1462 EL_SP_HARDWARE_YELLOW,
1463 EL_SP_HARDWARE_BASE_1,
1464 EL_SP_HARDWARE_BASE_2,
1465 EL_SP_HARDWARE_BASE_3,
1466 EL_SP_HARDWARE_BASE_4,
1467 EL_SP_HARDWARE_BASE_5,
1468 EL_SP_HARDWARE_BASE_6,
1470 EL_SP_TERMINAL_ACTIVE,
1473 EL_INVISIBLE_STEELWALL,
1474 EL_INVISIBLE_STEELWALL_ACTIVE,
1476 EL_INVISIBLE_WALL_ACTIVE,
1477 EL_STEELWALL_SLANTED,
1491 static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1493 static int ep_can_fall[] =
1508 EL_BD_MAGIC_WALL_FULL,
1519 static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1521 static int ep_can_smash[] =
1544 static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1546 static int ep_can_change[] =
1557 static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1559 static int ep_can_move[] =
1579 static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1581 static int ep_could_move[] =
1591 EL_BD_BUTTERFLY_RIGHT,
1593 EL_BD_BUTTERFLY_LEFT,
1594 EL_BD_BUTTERFLY_DOWN,
1595 EL_BD_FIREFLY_RIGHT,
1604 static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1606 static int ep_dont_touch[] =
1613 static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1615 static int ep_dont_go_to[] =
1629 EL_SP_BUGGY_BASE_ACTIVE,
1633 static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1635 static int ep_mampf2[] =
1660 static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1662 static int ep_bd_element[] =
1689 static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1691 static int ep_sb_element[] =
1696 EL_SOKOBAN_FIELD_EMPTY,
1697 EL_SOKOBAN_FIELD_FULL,
1699 EL_INVISIBLE_STEELWALL
1701 static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1703 static int ep_gem[] =
1712 static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1714 static int ep_inactive[] =
1751 EL_INVISIBLE_STEELWALL,
1759 EL_WALL_EMERALD_YELLOW,
1760 EL_DYNABOMB_INCREASE_NUMBER,
1761 EL_DYNABOMB_INCREASE_SIZE,
1762 EL_DYNABOMB_INCREASE_POWER,
1764 EL_SOKOBAN_FIELD_EMPTY,
1765 EL_SOKOBAN_FIELD_FULL,
1766 EL_WALL_EMERALD_RED,
1767 EL_WALL_EMERALD_PURPLE,
1768 EL_ACID_POOL_TOPLEFT,
1769 EL_ACID_POOL_TOPRIGHT,
1770 EL_ACID_POOL_BOTTOMLEFT,
1771 EL_ACID_POOL_BOTTOM,
1772 EL_ACID_POOL_BOTTOMRIGHT,
1776 EL_BD_MAGIC_WALL_DEAD,
1777 EL_AMOEBA_TO_DIAMOND,
1785 EL_SP_GRAVITY_PORT_RIGHT,
1786 EL_SP_GRAVITY_PORT_DOWN,
1787 EL_SP_GRAVITY_PORT_LEFT,
1788 EL_SP_GRAVITY_PORT_UP,
1789 EL_SP_PORT_HORIZONTAL,
1790 EL_SP_PORT_VERTICAL,
1799 EL_SP_HARDWARE_GRAY,
1800 EL_SP_HARDWARE_GREEN,
1801 EL_SP_HARDWARE_BLUE,
1803 EL_SP_HARDWARE_YELLOW,
1804 EL_SP_HARDWARE_BASE_1,
1805 EL_SP_HARDWARE_BASE_2,
1806 EL_SP_HARDWARE_BASE_3,
1807 EL_SP_HARDWARE_BASE_4,
1808 EL_SP_HARDWARE_BASE_5,
1809 EL_SP_HARDWARE_BASE_6,
1810 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
1811 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
1812 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
1813 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
1814 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
1815 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
1816 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
1817 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
1818 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
1819 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
1820 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
1821 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
1822 EL_SIGN_EXCLAMATION,
1823 EL_SIGN_RADIOACTIVITY,
1834 EL_STEELWALL_SLANTED,
1848 static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
1850 static int ep_explosive[] =
1855 EL_DYNABOMB_PLAYER_1_ACTIVE,
1856 EL_DYNABOMB_PLAYER_2_ACTIVE,
1857 EL_DYNABOMB_PLAYER_3_ACTIVE,
1858 EL_DYNABOMB_PLAYER_4_ACTIVE,
1859 EL_DYNABOMB_INCREASE_NUMBER,
1860 EL_DYNABOMB_INCREASE_SIZE,
1861 EL_DYNABOMB_INCREASE_POWER,
1862 EL_SP_DISK_RED_ACTIVE,
1876 static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
1878 static int ep_mampf3[] =
1889 static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
1891 static int ep_pushable[] =
1898 EL_SOKOBAN_FIELD_FULL,
1908 static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
1910 static int ep_player[] =
1917 static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
1919 static int ep_has_content[] =
1927 static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
1929 static int ep_eatable[] =
1934 EL_SP_BUGGY_BASE_ACTIVATING,
1937 EL_INVISIBLE_SAND_ACTIVE
1939 static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
1941 static int ep_sp_element[] =
1949 EL_SP_HARDWARE_GRAY,
1957 EL_SP_GRAVITY_PORT_RIGHT,
1958 EL_SP_GRAVITY_PORT_DOWN,
1959 EL_SP_GRAVITY_PORT_LEFT,
1960 EL_SP_GRAVITY_PORT_UP,
1965 EL_SP_PORT_VERTICAL,
1966 EL_SP_PORT_HORIZONTAL,
1972 EL_SP_HARDWARE_BASE_1,
1973 EL_SP_HARDWARE_GREEN,
1974 EL_SP_HARDWARE_BLUE,
1976 EL_SP_HARDWARE_YELLOW,
1977 EL_SP_HARDWARE_BASE_2,
1978 EL_SP_HARDWARE_BASE_3,
1979 EL_SP_HARDWARE_BASE_4,
1980 EL_SP_HARDWARE_BASE_5,
1981 EL_SP_HARDWARE_BASE_6,
1984 /* additional elements that appeared in newer Supaplex levels */
1986 /* more than one murphy in a level results in an inactive clone */
1989 static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
1991 static int ep_quick_gate[] =
2005 EL_SP_GRAVITY_PORT_LEFT,
2006 EL_SP_GRAVITY_PORT_RIGHT,
2007 EL_SP_GRAVITY_PORT_UP,
2008 EL_SP_GRAVITY_PORT_DOWN,
2009 EL_SP_PORT_HORIZONTAL,
2010 EL_SP_PORT_VERTICAL,
2015 static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
2017 static int ep_over_player[] =
2023 EL_SP_GRAVITY_PORT_LEFT,
2024 EL_SP_GRAVITY_PORT_RIGHT,
2025 EL_SP_GRAVITY_PORT_UP,
2026 EL_SP_GRAVITY_PORT_DOWN,
2027 EL_SP_PORT_HORIZONTAL,
2028 EL_SP_PORT_VERTICAL,
2033 EL_TUBE_VERTICAL_LEFT,
2034 EL_TUBE_VERTICAL_RIGHT,
2035 EL_TUBE_HORIZONTAL_UP,
2036 EL_TUBE_HORIZONTAL_DOWN,
2042 static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
2044 static int ep_active_bomb[] =
2047 EL_DYNABOMB_PLAYER_1_ACTIVE,
2048 EL_DYNABOMB_PLAYER_2_ACTIVE,
2049 EL_DYNABOMB_PLAYER_3_ACTIVE,
2050 EL_DYNABOMB_PLAYER_4_ACTIVE,
2051 EL_SP_DISK_RED_ACTIVE
2053 static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
2055 static int ep_belt[] =
2057 EL_CONVEYOR_BELT_1_LEFT,
2058 EL_CONVEYOR_BELT_1_MIDDLE,
2059 EL_CONVEYOR_BELT_1_RIGHT,
2060 EL_CONVEYOR_BELT_2_LEFT,
2061 EL_CONVEYOR_BELT_2_MIDDLE,
2062 EL_CONVEYOR_BELT_2_RIGHT,
2063 EL_CONVEYOR_BELT_3_LEFT,
2064 EL_CONVEYOR_BELT_3_MIDDLE,
2065 EL_CONVEYOR_BELT_3_RIGHT,
2066 EL_CONVEYOR_BELT_4_LEFT,
2067 EL_CONVEYOR_BELT_4_MIDDLE,
2068 EL_CONVEYOR_BELT_4_RIGHT,
2070 static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
2072 static int ep_belt_active[] =
2074 EL_CONVEYOR_BELT_1_LEFT_ACTIVE,
2075 EL_CONVEYOR_BELT_1_MIDDLE_ACTIVE,
2076 EL_CONVEYOR_BELT_1_RIGHT_ACTIVE,
2077 EL_CONVEYOR_BELT_2_LEFT_ACTIVE,
2078 EL_CONVEYOR_BELT_2_MIDDLE_ACTIVE,
2079 EL_CONVEYOR_BELT_2_RIGHT_ACTIVE,
2080 EL_CONVEYOR_BELT_3_LEFT_ACTIVE,
2081 EL_CONVEYOR_BELT_3_MIDDLE_ACTIVE,
2082 EL_CONVEYOR_BELT_3_RIGHT_ACTIVE,
2083 EL_CONVEYOR_BELT_4_LEFT_ACTIVE,
2084 EL_CONVEYOR_BELT_4_MIDDLE_ACTIVE,
2085 EL_CONVEYOR_BELT_4_RIGHT_ACTIVE,
2087 static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
2089 static int ep_belt_switch[] =
2091 EL_CONVEYOR_BELT_1_SWITCH_LEFT,
2092 EL_CONVEYOR_BELT_1_SWITCH_MIDDLE,
2093 EL_CONVEYOR_BELT_1_SWITCH_RIGHT,
2094 EL_CONVEYOR_BELT_2_SWITCH_LEFT,
2095 EL_CONVEYOR_BELT_2_SWITCH_MIDDLE,
2096 EL_CONVEYOR_BELT_2_SWITCH_RIGHT,
2097 EL_CONVEYOR_BELT_3_SWITCH_LEFT,
2098 EL_CONVEYOR_BELT_3_SWITCH_MIDDLE,
2099 EL_CONVEYOR_BELT_3_SWITCH_RIGHT,
2100 EL_CONVEYOR_BELT_4_SWITCH_LEFT,
2101 EL_CONVEYOR_BELT_4_SWITCH_MIDDLE,
2102 EL_CONVEYOR_BELT_4_SWITCH_RIGHT,
2104 static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
2106 static int ep_tube[] =
2111 EL_TUBE_VERTICAL_LEFT,
2112 EL_TUBE_VERTICAL_RIGHT,
2113 EL_TUBE_HORIZONTAL_UP,
2114 EL_TUBE_HORIZONTAL_DOWN,
2120 static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
2122 static long ep1_bit[] =
2129 EP_BIT_INDESTRUCTIBLE,
2156 static long ep2_bit[] =
2163 static int *ep1_array[] =
2197 static int *ep2_array[] =
2204 static int *ep1_num[] =
2211 &ep_indestructible_num,
2231 &ep_has_content_num,
2235 &ep_over_player_num,
2238 static int *ep2_num[] =
2241 &ep_belt_active_num,
2242 &ep_belt_switch_num,
2245 static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2246 static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2248 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2254 for (i=0; i<num_properties1; i++)
2255 for (j=0; j<*(ep1_num[i]); j++)
2256 Properties1[(ep1_array[i])[j]] |= ep1_bit[i];
2257 for (i=0; i<num_properties2; i++)
2258 for (j=0; j<*(ep2_num[i]); j++)
2259 Properties2[(ep2_array[i])[j]] |= ep2_bit[i];
2261 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2262 Properties1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2265 static void InitGlobal()
2267 global.autoplay_leveldir = NULL;
2269 global.frames_per_second = 0;
2270 global.fps_slowdown = FALSE;
2271 global.fps_slowdown_factor = 1;
2274 void Execute_Command(char *command)
2276 if (strcmp(command, "print graphicsinfo.conf") == 0)
2280 printf("# You can configure additional/alternative image files here.\n");
2281 printf("# (The images below are default and therefore commented out.)\n");
2283 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2285 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2288 for (i=0; image_config[i].token != NULL; i++)
2290 getFormattedSetupEntry(image_config[i].token,
2291 image_config[i].value));
2295 else if (strcmp(command, "print soundsinfo.conf") == 0)
2299 printf("# You can configure additional/alternative sound files here.\n");
2300 printf("# (The sounds below are default and therefore commented out.)\n");
2302 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2304 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2307 for (i=0; sound_config[i].token != NULL; i++)
2309 getFormattedSetupEntry(sound_config[i].token,
2310 sound_config[i].value));
2314 else if (strcmp(command, "print musicinfo.conf") == 0)
2316 printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2318 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2320 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2324 else if (strncmp(command, "dump level ", 11) == 0)
2326 char *filename = &command[11];
2328 if (access(filename, F_OK) != 0)
2329 Error(ERR_EXIT, "cannot open file '%s'", filename);
2331 LoadLevelFromFilename(filename);
2336 else if (strncmp(command, "dump tape ", 10) == 0)
2338 char *filename = &command[10];
2340 if (access(filename, F_OK) != 0)
2341 Error(ERR_EXIT, "cannot open file '%s'", filename);
2343 LoadTapeFromFilename(filename);
2348 else if (strncmp(command, "autoplay ", 9) == 0)
2350 char *str_copy = getStringCopy(&command[9]);
2351 char *str_ptr = strchr(str_copy, ' ');
2353 global.autoplay_leveldir = str_copy;
2354 global.autoplay_level_nr = -1;
2356 if (str_ptr != NULL)
2358 *str_ptr++ = '\0'; /* terminate leveldir string */
2359 global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
2364 Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
2368 static void InitSetup()
2370 LoadSetup(); /* global setup info */
2372 /* set some options from setup file */
2374 if (setup.options.verbose)
2375 options.verbose = TRUE;
2378 static void InitPlayerInfo()
2382 /* choose default local player */
2383 local_player = &stored_player[0];
2385 for (i=0; i<MAX_PLAYERS; i++)
2386 stored_player[i].connected = FALSE;
2388 local_player->connected = TRUE;
2391 static void InitArtworkInfo()
2396 static char *get_element_class_token(int element)
2398 char *element_class_name = element_info[element].class_name;
2399 char *element_class_token = checked_malloc(strlen(element_class_name) + 3);
2401 sprintf(element_class_token, "[%s]", element_class_name);
2403 return element_class_token;
2406 static void InitArtworkConfig()
2408 static char *image_id_prefix[MAX_NUM_ELEMENTS + NUM_FONTS + 1];
2409 static char *sound_id_prefix[MAX_NUM_ELEMENTS + MAX_NUM_ELEMENTS + 1];
2410 static char *action_id_suffix[NUM_ACTIONS + 1];
2411 static char *direction_id_suffix[NUM_DIRECTIONS + 1];
2412 static char *special_id_suffix[NUM_SPECIAL_GFX_ARGS + 1];
2413 static char *dummy[1] = { NULL };
2414 static char *ignore_image_tokens[] =
2419 "menu.draw_xoffset",
2420 "menu.draw_yoffset",
2421 "menu.draw_xoffset.MAIN",
2422 "menu.draw_yoffset.MAIN",
2427 static char *ignore_sound_tokens[] =
2435 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2436 image_id_prefix[i] = element_info[i].token_name;
2437 for (i=0; i<NUM_FONTS; i++)
2438 image_id_prefix[MAX_NUM_ELEMENTS + i] = font_info[i].token_name;
2439 image_id_prefix[MAX_NUM_ELEMENTS + NUM_FONTS] = NULL;
2441 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2442 sound_id_prefix[i] = element_info[i].token_name;
2443 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2444 sound_id_prefix[MAX_NUM_ELEMENTS + i] = get_element_class_token(i);
2445 sound_id_prefix[MAX_NUM_ELEMENTS + MAX_NUM_ELEMENTS] = NULL;
2447 for (i=0; i<NUM_ACTIONS; i++)
2448 action_id_suffix[i] = element_action_info[i].suffix;
2449 action_id_suffix[NUM_ACTIONS] = NULL;
2451 for (i=0; i<NUM_DIRECTIONS; i++)
2452 direction_id_suffix[i] = element_direction_info[i].suffix;
2453 direction_id_suffix[NUM_DIRECTIONS] = NULL;
2455 for (i=0; i<NUM_SPECIAL_GFX_ARGS; i++)
2456 special_id_suffix[i] = special_suffix_info[i].suffix;
2457 special_id_suffix[NUM_SPECIAL_GFX_ARGS] = NULL;
2459 InitImageList(image_config, NUM_IMAGE_FILES, image_config_suffix,
2460 image_id_prefix, action_id_suffix, direction_id_suffix,
2461 special_id_suffix, ignore_image_tokens);
2462 InitSoundList(sound_config, NUM_SOUND_FILES, sound_config_suffix,
2463 sound_id_prefix, action_id_suffix, dummy,
2464 special_id_suffix, ignore_sound_tokens);
2467 static void InitMixer()
2475 char *filename_font_initial = NULL;
2476 Bitmap *bitmap_font_initial = NULL;
2479 /* determine settings for initial font (for displaying startup messages) */
2480 for (i=0; image_config[i].token != NULL; i++)
2482 for (j=0; j < NUM_INITIAL_FONTS; j++)
2484 char font_token[128];
2487 sprintf(font_token, "%s_%d", CONFIG_TOKEN_FONT_INITIAL, j + 1);
2488 len_font_token = strlen(font_token);
2490 if (strcmp(image_config[i].token, font_token) == 0)
2491 filename_font_initial = image_config[i].value;
2492 else if (strlen(image_config[i].token) > len_font_token &&
2493 strncmp(image_config[i].token, font_token, len_font_token) == 0)
2495 if (strcmp(&image_config[i].token[len_font_token], ".x") == 0)
2496 font_initial[j].src_x = atoi(image_config[i].value);
2497 else if (strcmp(&image_config[i].token[len_font_token], ".y") == 0)
2498 font_initial[j].src_y = atoi(image_config[i].value);
2499 else if (strcmp(&image_config[i].token[len_font_token], ".width") == 0)
2500 font_initial[j].width = atoi(image_config[i].value);
2501 else if (strcmp(&image_config[i].token[len_font_token],".height") == 0)
2502 font_initial[j].height = atoi(image_config[i].value);
2507 if (filename_font_initial == NULL) /* should not happen */
2508 Error(ERR_EXIT, "cannot get filename for '%s'", CONFIG_TOKEN_FONT_INITIAL);
2510 /* initialize screen properties */
2511 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
2512 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
2513 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
2514 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
2515 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
2517 /* create additional image buffers for double-buffering */
2518 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
2519 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
2521 bitmap_font_initial = LoadCustomImage(filename_font_initial);
2523 for (j=0; j < NUM_INITIAL_FONTS; j++)
2524 font_initial[j].bitmap = bitmap_font_initial;
2526 InitFontGraphicInfo();
2528 DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
2529 DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
2531 DrawInitText("Loading graphics:", 120, FC_GREEN);
2533 InitTileClipmasks();
2536 void InitGfxBackground()
2540 drawto = backbuffer;
2541 fieldbuffer = bitmap_db_field;
2542 SetDrawtoField(DRAW_BACKBUFFER);
2544 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
2545 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
2546 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
2547 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
2549 for (x=0; x<MAX_BUF_XSIZE; x++)
2550 for (y=0; y<MAX_BUF_YSIZE; y++)
2553 redraw_mask = REDRAW_ALL;
2556 static void InitLevelInfo()
2558 LoadLevelInfo(); /* global level info */
2559 LoadLevelSetup_LastSeries(); /* last played series info */
2560 LoadLevelSetup_SeriesInfo(); /* last played level info */
2563 void InitLevelArtworkInfo()
2565 LoadLevelArtworkInfo();
2568 static void InitImages()
2570 ReloadCustomImages();
2572 LoadCustomElementDescriptions();
2573 LoadSpecialMenuDesignSettings();
2575 ReinitializeGraphics();
2578 static void InitSound()
2580 InitReloadCustomSounds(artwork.snd_current->identifier);
2581 ReinitializeSounds();
2584 static void InitMusic()
2586 InitReloadCustomMusic(artwork.mus_current->identifier);
2587 ReinitializeMusic();
2590 void InitNetworkServer()
2592 #if defined(PLATFORM_UNIX)
2596 if (!options.network)
2599 #if defined(PLATFORM_UNIX)
2600 nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
2602 if (!ConnectToServer(options.server_host, options.server_port))
2603 Error(ERR_EXIT, "cannot connect to network game server");
2605 SendToServer_PlayerName(setup.player_name);
2606 SendToServer_ProtocolVersion();
2609 SendToServer_NrWanted(nr_wanted);
2613 void ReloadCustomArtwork()
2615 static char *leveldir_current_identifier = NULL;
2616 static boolean last_override_level_graphics = FALSE;
2617 static boolean last_override_level_sounds = FALSE;
2618 static boolean last_override_level_music = FALSE;
2619 /* identifier for new artwork; default: artwork configured in setup */
2620 char *gfx_new_identifier = artwork.gfx_current->identifier;
2621 char *snd_new_identifier = artwork.snd_current->identifier;
2622 char *mus_new_identifier = artwork.mus_current->identifier;
2623 boolean redraw_screen = FALSE;
2625 if (leveldir_current_identifier == NULL)
2626 leveldir_current_identifier = leveldir_current->identifier;
2629 printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
2630 leveldir_current->graphics_set);
2631 printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
2632 leveldir_current->identifier);
2636 printf("graphics --> '%s' ('%s')\n",
2637 artwork.gfx_current_identifier, artwork.gfx_current->filename);
2638 printf("sounds --> '%s' ('%s')\n",
2639 artwork.snd_current_identifier, artwork.snd_current->filename);
2640 printf("music --> '%s' ('%s')\n",
2641 artwork.mus_current_identifier, artwork.mus_current->filename);
2644 /* leveldir_current may be invalid (level group, parent link) */
2645 if (!validLevelSeries(leveldir_current))
2648 /* when a new level series was selected, check if there was a change
2649 in custom artwork stored in level series directory */
2650 if (leveldir_current_identifier != leveldir_current->identifier)
2652 char *identifier_old = leveldir_current_identifier;
2653 char *identifier_new = leveldir_current->identifier;
2655 if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
2656 getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
2657 gfx_new_identifier = identifier_new;
2658 if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
2659 getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
2660 snd_new_identifier = identifier_new;
2661 if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
2662 getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
2663 mus_new_identifier = identifier_new;
2665 leveldir_current_identifier = leveldir_current->identifier;
2668 /* custom level artwork configured in level series configuration file
2669 always overrides custom level artwork stored in level series directory
2670 and (level independant) custom artwork configured in setup menue */
2671 if (leveldir_current->graphics_set != NULL)
2672 gfx_new_identifier = leveldir_current->graphics_set;
2673 if (leveldir_current->sounds_set != NULL)
2674 snd_new_identifier = leveldir_current->sounds_set;
2675 if (leveldir_current->music_set != NULL)
2676 mus_new_identifier = leveldir_current->music_set;
2678 if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
2679 last_override_level_graphics != setup.override_level_graphics)
2682 printf("RELOADING GRAPHICS '%s' -> '%s' ('%s')\n",
2683 artwork.gfx_current_identifier,
2684 artwork.gfx_current->identifier,
2685 gfx_new_identifier);
2688 setLevelArtworkDir(artwork.gfx_first);
2690 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
2694 FreeTileClipmasks();
2695 InitTileClipmasks();
2697 artwork.gfx_current_identifier = artwork.gfx_current->identifier;
2698 last_override_level_graphics = setup.override_level_graphics;
2700 redraw_screen = TRUE;
2703 if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
2704 last_override_level_sounds != setup.override_level_sounds)
2707 printf("RELOADING SOUNDS '%s' -> '%s' ('%s')\n",
2708 artwork.snd_current_identifier,
2709 artwork.snd_current->identifier,
2710 snd_new_identifier);
2713 /* set artwork path to send it to the sound server process */
2714 setLevelArtworkDir(artwork.snd_first);
2716 InitReloadCustomSounds(snd_new_identifier);
2717 ReinitializeSounds();
2719 artwork.snd_current_identifier = artwork.snd_current->identifier;
2720 last_override_level_sounds = setup.override_level_sounds;
2722 redraw_screen = TRUE;
2725 if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
2726 last_override_level_music != setup.override_level_music)
2728 /* set artwork path to send it to the sound server process */
2729 setLevelArtworkDir(artwork.mus_first);
2731 InitReloadCustomMusic(mus_new_identifier);
2732 ReinitializeMusic();
2734 artwork.mus_current_identifier = artwork.mus_current->identifier;
2735 last_override_level_music = setup.override_level_music;
2737 redraw_screen = TRUE;
2742 InitGfxBackground();
2744 /* force redraw of (open or closed) door graphics */
2745 SetDoorState(DOOR_OPEN_ALL);
2746 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
2751 /* ========================================================================= */
2753 /* ========================================================================= */
2757 InitGlobal(); /* initialize some global variables */
2759 if (options.execute_command)
2760 Execute_Command(options.execute_command);
2762 if (options.serveronly)
2764 #if defined(PLATFORM_UNIX)
2765 NetworkServer(options.server_port, options.serveronly);
2767 Error(ERR_WARN, "networking only supported in Unix version");
2769 exit(0); /* never reached */
2775 InitArtworkInfo(); /* needed before loading gfx, sound & music */
2776 InitArtworkConfig(); /* needed before forking sound child process */
2781 InitRND(NEW_RANDOMIZE);
2782 InitSimpleRND(NEW_RANDOMIZE);
2787 InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
2790 InitEventFilter(FilterMouseMotionEvents);
2792 InitElementProperties();
2797 InitLevelArtworkInfo();
2799 InitImages(); /* needs to know current level directory */
2800 InitSound(); /* needs to know current level directory */
2801 InitMusic(); /* needs to know current level directory */
2803 InitGfxBackground();
2805 if (global.autoplay_leveldir)
2811 game_status = MAINMENU;
2815 InitNetworkServer();
2818 void CloseAllAndExit(int exit_value)
2823 CloseAudio(); /* called after freeing sounds (needed for SDL) */
2826 FreeTileClipmasks();
2828 CloseVideoDisplay();
2829 ClosePlatformDependantStuff();