+static void InitMixer()
+{
+ OpenAudio();
+ StartMixer();
+}
+
+static void ReinitializeGraphics()
+{
+ InitElementGraphicInfo(); /* element game graphic mapping */
+ InitElementSpecialGraphicInfo(); /* element special graphic mapping */
+ InitGraphicInfo(); /* graphic properties mapping */
+
+ InitElementSmallImages(); /* create editor and preview images */
+ InitFontGraphicInfo(); /* initialize text drawing functions */
+
+ SetMainBackgroundImage(IMG_BACKGROUND);
+ SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
+
+ InitGadgets();
+ InitToons();
+}
+
+static void ReinitializeSounds()
+{
+ InitElementSoundInfo(); /* element game sound mapping */
+ InitSoundInfo(); /* sound properties mapping */
+
+ InitPlaySoundLevel(); /* internal game sound settings */
+}
+
+static void ReinitializeMusic()
+{
+ /* currently nothing to do */
+}
+
+static void InitImages()
+{
+ ReloadCustomImages();
+
+ LoadCustomElementDescriptions();
+ LoadSpecialMenuDesignSettings();
+
+ ReinitializeGraphics();
+}
+
+static void InitSound()
+{
+ InitReloadCustomSounds(artwork.snd_current->identifier);
+ ReinitializeSounds();
+}
+
+static void InitMusic()
+{
+ InitReloadCustomMusic(artwork.mus_current->identifier);
+ ReinitializeMusic();
+}
+
+static void InitTileClipmasks()
+{
+#if 0
+#if defined(TARGET_X11)
+ XGCValues clip_gc_values;
+ unsigned long clip_gc_valuemask;
+
+#if defined(TARGET_X11_NATIVE)
+
+#if 0
+ GC copy_clipmask_gc;
+
+ static struct
+ {
+ int start;
+ int count;
+ }
+ tile_needs_clipping[] =
+ {
+ { GFX_SPIELER1_UP, 4 },
+ { GFX_SPIELER1_DOWN, 4 },
+ { GFX_SPIELER1_LEFT, 4 },
+ { GFX_SPIELER1_RIGHT, 4 },
+ { GFX_SPIELER1_PUSH_LEFT, 4 },
+ { GFX_SPIELER1_PUSH_RIGHT, 4 },
+ { GFX_SPIELER2_UP, 4 },
+ { GFX_SPIELER2_DOWN, 4 },
+ { GFX_SPIELER2_LEFT, 4 },
+ { GFX_SPIELER2_RIGHT, 4 },
+ { GFX_SPIELER2_PUSH_LEFT, 4 },
+ { GFX_SPIELER2_PUSH_RIGHT, 4 },
+ { GFX_SPIELER3_UP, 4 },
+ { GFX_SPIELER3_DOWN, 4 },
+ { GFX_SPIELER3_LEFT, 4 },
+ { GFX_SPIELER3_RIGHT, 4 },
+ { GFX_SPIELER3_PUSH_LEFT, 4 },
+ { GFX_SPIELER3_PUSH_RIGHT, 4 },
+ { GFX_SPIELER4_UP, 4 },
+ { GFX_SPIELER4_DOWN, 4 },
+ { GFX_SPIELER4_LEFT, 4 },
+ { GFX_SPIELER4_RIGHT, 4 },
+ { GFX_SPIELER4_PUSH_LEFT, 4 },
+ { GFX_SPIELER4_PUSH_RIGHT, 4 },
+ { GFX_SP_MURPHY, 1 },
+ { GFX_MURPHY_GO_LEFT, 3 },
+ { GFX_MURPHY_GO_RIGHT, 3 },
+ { GFX_MURPHY_SNAP_UP, 1 },
+ { GFX_MURPHY_SNAP_DOWN, 1 },
+ { GFX_MURPHY_SNAP_RIGHT, 1 },
+ { GFX_MURPHY_SNAP_LEFT, 1 },
+ { GFX_MURPHY_PUSH_RIGHT, 1 },
+ { GFX_MURPHY_PUSH_LEFT, 1 },
+ { GFX_GEBLUBBER, 4 },
+ { GFX_DYNAMIT, 7 },
+ { GFX_DYNABOMB, 4 },
+ { GFX_EXPLOSION, 8 },
+ { GFX_SOKOBAN_OBJEKT, 1 },
+ { GFX_FUNKELN_BLAU, 3 },
+ { GFX_FUNKELN_WEISS, 3 },
+ { GFX2_SHIELD_PASSIVE, 3 },
+ { GFX2_SHIELD_ACTIVE, 3 },
+ { -1, 0 }
+ };
+#endif
+
+#endif /* TARGET_X11_NATIVE */
+#endif /* TARGET_X11 */
+
+ int i;
+
+ /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
+ for (i=0; i<NUM_TILES; i++)
+ tile_clipmask[i] = None;
+
+#if defined(TARGET_X11)
+ /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
+ often very slow when preparing a masked XCopyArea() for big Pixmaps.
+ To prevent this, create small (tile-sized) mask Pixmaps which will then
+ be set much faster with XSetClipOrigin() and speed things up a lot. */
+
+ clip_gc_values.graphics_exposures = False;
+ clip_gc_valuemask = GCGraphicsExposures;
+ tile_clip_gc = XCreateGC(display, window->drawable,
+ clip_gc_valuemask, &clip_gc_values);
+
+#if 0
+ for (i=0; i<NUM_BITMAPS; i++)
+ {
+ if (pix[i]->clip_mask)
+ {
+ clip_gc_values.graphics_exposures = False;
+ clip_gc_values.clip_mask = pix[i]->clip_mask;
+ clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
+ pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
+ clip_gc_valuemask, &clip_gc_values);
+ }
+ }
+#endif
+
+#if defined(TARGET_X11_NATIVE)
+
+#if 0
+ /* create graphic context structures needed for clipping */
+ clip_gc_values.graphics_exposures = False;
+ clip_gc_valuemask = GCGraphicsExposures;
+ copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
+ clip_gc_valuemask, &clip_gc_values);
+
+ /* create only those clipping Pixmaps we really need */
+ for (i=0; tile_needs_clipping[i].start>=0; i++)
+ {
+ int j;
+
+ for (j=0; j<tile_needs_clipping[i].count; j++)
+ {
+ int tile = tile_needs_clipping[i].start + j;
+ int graphic = tile;
+ int src_x, src_y;
+ Bitmap *src_bitmap;
+ Pixmap src_pixmap;
+
+ getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
+ src_pixmap = src_bitmap->clip_mask;
+
+ tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
+ TILEX, TILEY, 1);
+
+ XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
+ src_x, src_y, TILEX, TILEY, 0, 0);
+ }
+ }
+
+ XFreeGC(display, copy_clipmask_gc);
+#endif
+
+#endif /* TARGET_X11_NATIVE */
+#endif /* TARGET_X11 */
+#endif
+}
+
+void FreeTileClipmasks()
+{
+#if 0
+#if defined(TARGET_X11)
+ int i;
+
+ for (i=0; i<NUM_TILES; i++)
+ {
+ if (tile_clipmask[i] != None)
+ {
+ XFreePixmap(display, tile_clipmask[i]);
+ tile_clipmask[i] = None;
+ }
+ }
+
+ if (tile_clip_gc)
+ XFreeGC(display, tile_clip_gc);
+ tile_clip_gc = None;
+
+#if 0
+ for (i=0; i<NUM_BITMAPS; i++)
+ {
+ if (pix[i] != NULL && pix[i]->stored_clip_gc)
+ {
+ XFreeGC(display, pix[i]->stored_clip_gc);
+ pix[i]->stored_clip_gc = None;
+ }
+ }
+#endif
+
+#endif /* TARGET_X11 */
+#endif
+}
+
+void InitGfx()
+{
+ char *filename_font_initial = NULL;
+ Bitmap *bitmap_font_initial = NULL;
+ int i, j;
+
+ /* determine settings for initial font (for displaying startup messages) */
+ for (i=0; image_config[i].token != NULL; i++)
+ {
+ for (j=0; j < NUM_INITIAL_FONTS; j++)
+ {
+ char font_token[128];
+ int len_font_token;
+
+ sprintf(font_token, "%s_%d", CONFIG_TOKEN_FONT_INITIAL, j + 1);
+ len_font_token = strlen(font_token);
+
+ if (strcmp(image_config[i].token, font_token) == 0)
+ filename_font_initial = image_config[i].value;
+ else if (strlen(image_config[i].token) > len_font_token &&
+ strncmp(image_config[i].token, font_token, len_font_token) == 0)
+ {
+ if (strcmp(&image_config[i].token[len_font_token], ".x") == 0)
+ font_initial[j].src_x = atoi(image_config[i].value);
+ else if (strcmp(&image_config[i].token[len_font_token], ".y") == 0)
+ font_initial[j].src_y = atoi(image_config[i].value);
+ else if (strcmp(&image_config[i].token[len_font_token], ".width") == 0)
+ font_initial[j].width = atoi(image_config[i].value);
+ else if (strcmp(&image_config[i].token[len_font_token],".height") == 0)
+ font_initial[j].height = atoi(image_config[i].value);
+ }
+ }
+ }
+
+ if (filename_font_initial == NULL) /* should not happen */
+ Error(ERR_EXIT, "cannot get filename for '%s'", CONFIG_TOKEN_FONT_INITIAL);
+
+ /* initialize screen properties */
+ InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
+ REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
+ InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
+ InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
+ InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
+
+ /* create additional image buffers for double-buffering */
+ bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
+ bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
+
+ bitmap_font_initial = LoadCustomImage(filename_font_initial);
+
+ for (j=0; j < NUM_INITIAL_FONTS; j++)
+ font_initial[j].bitmap = bitmap_font_initial;
+
+ InitFontGraphicInfo();
+
+ DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
+ DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
+
+ DrawInitText("Loading graphics:", 120, FC_GREEN);
+
+ InitTileClipmasks();
+}
+
+void InitGfxBackground()
+{
+ int x, y;
+
+ drawto = backbuffer;
+ fieldbuffer = bitmap_db_field;
+ SetDrawtoField(DRAW_BACKBUFFER);
+
+ BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
+ 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
+ ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
+ ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
+
+ for (x=0; x<MAX_BUF_XSIZE; x++)
+ for (y=0; y<MAX_BUF_YSIZE; y++)
+ redraw[x][y] = 0;
+ redraw_tiles = 0;
+ redraw_mask = REDRAW_ALL;
+}
+
+void ReloadCustomArtwork()
+{
+ static char *leveldir_current_identifier = NULL;
+ static boolean last_override_level_graphics = FALSE;
+ static boolean last_override_level_sounds = FALSE;
+ static boolean last_override_level_music = FALSE;
+ /* identifier for new artwork; default: artwork configured in setup */
+ char *gfx_new_identifier = artwork.gfx_current->identifier;
+ char *snd_new_identifier = artwork.snd_current->identifier;
+ char *mus_new_identifier = artwork.mus_current->identifier;
+ boolean redraw_screen = FALSE;
+
+ if (leveldir_current_identifier == NULL)
+ leveldir_current_identifier = leveldir_current->identifier;
+
+#if 0
+ printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
+ leveldir_current->graphics_set);
+ printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
+ leveldir_current->identifier);
+#endif
+
+#if 0
+ printf("graphics --> '%s' ('%s')\n",
+ artwork.gfx_current_identifier, artwork.gfx_current->filename);
+ printf("sounds --> '%s' ('%s')\n",
+ artwork.snd_current_identifier, artwork.snd_current->filename);
+ printf("music --> '%s' ('%s')\n",
+ artwork.mus_current_identifier, artwork.mus_current->filename);
+#endif
+
+ /* leveldir_current may be invalid (level group, parent link) */
+ if (!validLevelSeries(leveldir_current))
+ return;
+
+ /* when a new level series was selected, check if there was a change
+ in custom artwork stored in level series directory */
+ if (leveldir_current_identifier != leveldir_current->identifier)
+ {
+ char *identifier_old = leveldir_current_identifier;
+ char *identifier_new = leveldir_current->identifier;
+
+ if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
+ getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
+ gfx_new_identifier = identifier_new;
+ if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
+ getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
+ snd_new_identifier = identifier_new;
+ if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
+ getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
+ mus_new_identifier = identifier_new;
+
+ leveldir_current_identifier = leveldir_current->identifier;
+ }
+
+ /* custom level artwork configured in level series configuration file
+ always overrides custom level artwork stored in level series directory
+ and (level independant) custom artwork configured in setup menue */
+ if (leveldir_current->graphics_set != NULL)
+ gfx_new_identifier = leveldir_current->graphics_set;
+ if (leveldir_current->sounds_set != NULL)
+ snd_new_identifier = leveldir_current->sounds_set;
+ if (leveldir_current->music_set != NULL)
+ mus_new_identifier = leveldir_current->music_set;
+
+ if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
+ last_override_level_graphics != setup.override_level_graphics)
+ {
+#if 0
+ printf("RELOADING GRAPHICS '%s' -> '%s' ('%s')\n",
+ artwork.gfx_current_identifier,
+ artwork.gfx_current->identifier,
+ gfx_new_identifier);
+#endif
+
+ setLevelArtworkDir(artwork.gfx_first);
+
+ ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
+
+ InitImages();
+
+ FreeTileClipmasks();
+ InitTileClipmasks();
+
+ artwork.gfx_current_identifier = artwork.gfx_current->identifier;
+ last_override_level_graphics = setup.override_level_graphics;
+
+ redraw_screen = TRUE;
+ }
+
+ if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
+ last_override_level_sounds != setup.override_level_sounds)
+ {
+#if 0
+ printf("RELOADING SOUNDS '%s' -> '%s' ('%s')\n",
+ artwork.snd_current_identifier,
+ artwork.snd_current->identifier,
+ snd_new_identifier);
+#endif
+
+ /* set artwork path to send it to the sound server process */
+ setLevelArtworkDir(artwork.snd_first);
+
+ InitReloadCustomSounds(snd_new_identifier);
+ ReinitializeSounds();
+
+ artwork.snd_current_identifier = artwork.snd_current->identifier;
+ last_override_level_sounds = setup.override_level_sounds;
+
+ redraw_screen = TRUE;
+ }
+
+ if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
+ last_override_level_music != setup.override_level_music)
+ {
+ /* set artwork path to send it to the sound server process */
+ setLevelArtworkDir(artwork.mus_first);
+
+ InitReloadCustomMusic(mus_new_identifier);
+ ReinitializeMusic();
+
+ artwork.mus_current_identifier = artwork.mus_current->identifier;
+ last_override_level_music = setup.override_level_music;
+
+ redraw_screen = TRUE;
+ }
+
+ if (redraw_screen)
+ {
+ InitGfxBackground();
+
+ /* force redraw of (open or closed) door graphics */
+ SetDoorState(DOOR_OPEN_ALL);
+ CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
+ }
+}
+
+void FreeGadgets()
+{
+ FreeLevelEditorGadgets();
+ FreeGameButtons();
+ FreeTapeButtons();
+ FreeToolButtons();
+ FreeScreenGadgets();
+}
+
+void InitGadgets()
+{
+ static boolean gadgets_initialized = FALSE;
+
+ if (gadgets_initialized)
+ FreeGadgets();
+
+ CreateLevelEditorGadgets();
+ CreateGameButtons();
+ CreateTapeButtons();
+ CreateToolButtons();
+ CreateScreenGadgets();
+
+ gadgets_initialized = TRUE;
+}
+
+void InitElementSmallImages()
+{
+ struct PropertyMapping *property_mapping = getImageListPropertyMapping();
+ int num_property_mappings = getImageListPropertyMappingSize();
+ int i;
+
+ /* initialize normal images from static configuration */
+ for (i=0; element_to_graphic[i].element > -1; i++)
+ CreateImageWithSmallImages(element_to_graphic[i].graphic);
+
+ /* initialize special images from static configuration */
+ for (i=0; element_to_special_graphic[i].element > -1; i++)
+ CreateImageWithSmallImages(element_to_special_graphic[i].graphic);
+
+ /* initialize images from dynamic configuration */
+ for (i=0; i < num_property_mappings; i++)
+ if (property_mapping[i].artwork_index < MAX_NUM_ELEMENTS)
+ CreateImageWithSmallImages(property_mapping[i].artwork_index);
+}
+
+static int getFontBitmapID(int font_nr)
+{
+ int special = -1;
+
+ if (game_status == MAINMENU || game_status == TYPENAME)
+ special = GFX_SPECIAL_ARG_MAIN;
+ else if (game_status == CHOOSELEVEL)
+ special = GFX_SPECIAL_ARG_LEVELS;
+ else if (game_status == HALLOFFAME)
+ special = GFX_SPECIAL_ARG_SCORES;
+ else if (game_status == LEVELED)
+ special = GFX_SPECIAL_ARG_EDITOR;
+ else if (game_status == HELPSCREEN)
+ special = GFX_SPECIAL_ARG_INFO;
+ else if (game_status == SETUP)
+ special = GFX_SPECIAL_ARG_SETUP;
+ else if (game_status == PSEUDO_PREVIEW)
+ special = GFX_SPECIAL_ARG_PREVIEW;
+ else if (game_status == PLAYING || game_status == PSEUDO_DOOR)
+ special = GFX_SPECIAL_ARG_DOOR;
+
+ if (special != -1)
+ return font_info[font_nr].special_bitmap_id[special];
+ else
+ return font_nr;
+}
+
+void InitFontGraphicInfo()
+{
+ static struct FontBitmapInfo *font_bitmap_info = NULL;
+ struct PropertyMapping *property_mapping = getImageListPropertyMapping();
+ int num_property_mappings = getImageListPropertyMappingSize();
+ int num_font_bitmaps = NUM_FONTS;
+ int i, j;
+
+ if (graphic_info == NULL) /* still at startup phase */
+ {
+ InitFontInfo(font_initial, NUM_INITIAL_FONTS, getFontBitmapID);
+
+ return;
+ }
+
+ /* ---------- initialize font graphic definitions ---------- */
+
+ /* always start with reliable default values (normal font graphics) */
+ for (i=0; i < NUM_FONTS; i++)
+ font_info[i].graphic = FONT_INITIAL_1;
+
+ /* initialize normal font/graphic mapping from static configuration */
+ for (i=0; font_to_graphic[i].font_nr > -1; i++)
+ {
+ int font_nr = font_to_graphic[i].font_nr;
+ int special = font_to_graphic[i].special;
+ int graphic = font_to_graphic[i].graphic;
+
+ if (special != -1)
+ continue;
+
+ font_info[font_nr].graphic = graphic;
+ }
+
+ /* always start with reliable default values (special font graphics) */
+ for (i=0; i < NUM_FONTS; i++)
+ {
+ for (j=0; j < NUM_SPECIAL_GFX_ARGS; j++)
+ {
+ font_info[i].special_graphic[j] = font_info[i].graphic;
+ font_info[i].special_bitmap_id[j] = i;
+ }
+ }
+
+ /* initialize special font/graphic mapping from static configuration */
+ for (i=0; font_to_graphic[i].font_nr > -1; i++)
+ {
+ int font_nr = font_to_graphic[i].font_nr;
+ int special = font_to_graphic[i].special;
+ int graphic = font_to_graphic[i].graphic;
+
+ if (special >= 0 && special < NUM_SPECIAL_GFX_ARGS)
+ {
+ font_info[font_nr].special_graphic[special] = graphic;
+ font_info[font_nr].special_bitmap_id[special] = num_font_bitmaps;
+ num_font_bitmaps++;
+ }
+ }
+
+ /* initialize special element/graphic mapping from dynamic configuration */
+ for (i=0; i < num_property_mappings; i++)
+ {
+ int font_nr = property_mapping[i].base_index - MAX_NUM_ELEMENTS;
+ int special = property_mapping[i].ext3_index;
+ int graphic = property_mapping[i].artwork_index;
+
+ if (font_nr < 0)
+ continue;
+
+ if (special >= 0 && special < NUM_SPECIAL_GFX_ARGS)
+ {
+ font_info[font_nr].special_graphic[special] = graphic;
+ font_info[font_nr].special_bitmap_id[special] = num_font_bitmaps;
+ num_font_bitmaps++;
+ }
+ }
+
+ /* ---------- initialize font bitmap array ---------- */
+
+ if (font_bitmap_info != NULL)
+ free(font_bitmap_info);
+
+ font_bitmap_info =
+ checked_calloc(num_font_bitmaps * sizeof(struct FontBitmapInfo));
+
+ /* ---------- initialize font bitmap definitions ---------- */
+
+ for (i=0; i < NUM_FONTS; i++)
+ {
+ if (i < NUM_INITIAL_FONTS)
+ {
+ font_bitmap_info[i] = font_initial[i];
+ continue;
+ }
+
+ for (j=0; j < NUM_SPECIAL_GFX_ARGS; j++)
+ {
+ int font_bitmap_id = font_info[i].special_bitmap_id[j];
+ int graphic = font_info[i].special_graphic[j];
+
+ /* copy font relevant information from graphics information */
+ font_bitmap_info[font_bitmap_id].bitmap = graphic_info[graphic].bitmap;
+ font_bitmap_info[font_bitmap_id].src_x = graphic_info[graphic].src_x;
+ font_bitmap_info[font_bitmap_id].src_y = graphic_info[graphic].src_y;
+ font_bitmap_info[font_bitmap_id].width = graphic_info[graphic].width;
+ font_bitmap_info[font_bitmap_id].height = graphic_info[graphic].height;
+ font_bitmap_info[font_bitmap_id].draw_x = graphic_info[graphic].draw_x;
+ font_bitmap_info[font_bitmap_id].draw_y = graphic_info[graphic].draw_y;
+ }
+ }
+
+ InitFontInfo(font_bitmap_info, num_font_bitmaps, getFontBitmapID);
+}
+
+void InitElementGraphicInfo()
+{
+ struct PropertyMapping *property_mapping = getImageListPropertyMapping();
+ int num_property_mappings = getImageListPropertyMappingSize();
+ int i, act, dir;
+
+ /* set values to -1 to identify later as "uninitialized" values */
+ for (i=0; i<MAX_NUM_ELEMENTS; i++)
+ {
+ for (act=0; act<NUM_ACTIONS; act++)
+ {
+ element_info[i].graphic[act] = -1;
+
+ for (dir=0; dir<NUM_DIRECTIONS; dir++)
+ element_info[i].direction_graphic[act][dir] = -1;
+ }
+ }
+
+ /* initialize normal element/graphic mapping from static configuration */
+ for (i=0; element_to_graphic[i].element > -1; i++)
+ {
+ int element = element_to_graphic[i].element;
+ int action = element_to_graphic[i].action;
+ int direction = element_to_graphic[i].direction;
+ int graphic = element_to_graphic[i].graphic;
+
+ if (action < 0)
+ action = ACTION_DEFAULT;
+
+ if (direction > -1)
+ element_info[element].direction_graphic[action][direction] = graphic;
+ else
+ element_info[element].graphic[action] = graphic;
+ }
+
+ /* initialize normal element/graphic mapping from dynamic configuration */
+ for (i=0; i < num_property_mappings; i++)
+ {
+ int element = property_mapping[i].base_index;
+ int action = property_mapping[i].ext1_index;
+ int direction = property_mapping[i].ext2_index;
+ int special = property_mapping[i].ext3_index;
+ int graphic = property_mapping[i].artwork_index;
+
+ if (element >= MAX_NUM_ELEMENTS || special != -1)
+ continue;
+
+ if (action < 0)
+ action = ACTION_DEFAULT;
+
+ if (direction > -1)
+ element_info[element].direction_graphic[action][direction] = graphic;
+ else
+ element_info[element].graphic[action] = graphic;
+ }
+
+ /* now set all '-1' values to element specific default values */
+ for (i=0; i<MAX_NUM_ELEMENTS; i++)
+ {
+ int default_action_graphic = element_info[i].graphic[ACTION_DEFAULT];
+ int default_action_direction_graphic[NUM_DIRECTIONS];
+
+ if (default_action_graphic == -1)
+ default_action_graphic = IMG_CHAR_QUESTION;
+
+ for (dir=0; dir<NUM_DIRECTIONS; dir++)
+ {
+ default_action_direction_graphic[dir] =
+ element_info[i].direction_graphic[ACTION_DEFAULT][dir];
+
+ if (default_action_direction_graphic[dir] == -1)
+ default_action_direction_graphic[dir] = default_action_graphic;
+ }
+
+ for (act=0; act<NUM_ACTIONS; act++)
+ {
+ for (dir=0; dir<NUM_DIRECTIONS; dir++)
+ {
+ int default_direction_graphic = element_info[i].graphic[act];
+
+ /* no graphic for current action -- use default direction graphic */
+ if (default_direction_graphic == -1)
+ default_direction_graphic = default_action_direction_graphic[dir];
+
+ if (element_info[i].direction_graphic[act][dir] == -1)
+ element_info[i].direction_graphic[act][dir] =
+ default_direction_graphic;
+ }
+
+ /* no graphic for this specific action -- use default action graphic */
+ if (element_info[i].graphic[act] == -1)
+ element_info[i].graphic[act] = default_action_graphic;
+ }
+ }
+
+#if 0
+#if DEBUG
+ if (options.verbose)
+ {
+ for (i=0; i<MAX_NUM_ELEMENTS; i++)
+ if (element_info[i].graphic[ACTION_DEFAULT] == IMG_CHAR_QUESTION &&
+ i != EL_CHAR_QUESTION)
+ Error(ERR_RETURN, "warning: no graphic for element '%s' (%d)",
+ element_info[i].token_name, i);
+ }
+#endif
+#endif
+}
+
+void InitElementSpecialGraphicInfo()