- set_graphic_parameters(i, fallback_image->default_parameter);
- graphic_info[i].bitmap = fallback_bitmap;
- }
-
- last_frame = graphic_info[i].anim_frames - 1;
- getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
- if (src_x < 0 || src_y < 0 ||
- src_x + TILEX > src_bitmap->width ||
- src_y + TILEY > src_bitmap->height)
- {
- Error(ERR_RETURN_LINE, "-");
- Error(ERR_RETURN, "warning: error found in config file:");
- Error(ERR_RETURN, "- config file: '%s'",
- getImageConfigFilename());
- Error(ERR_RETURN, "- config token: '%s'",
- getTokenFromImageID(i));
- Error(ERR_RETURN, "- image file: '%s'",
- src_bitmap->source_filename);
- Error(ERR_RETURN,
- "error: last animation frame (%d) out of bounds (%d, %d)",
- last_frame, src_x, src_y);
- Error(ERR_RETURN, "custom graphic rejected for this element/action");
-
- if (i == fallback_graphic)
- Error(ERR_EXIT, "fatal error: no fallback graphic available");
-
- Error(ERR_RETURN, "fallback done to 'char_exclam' for this graphic");
- Error(ERR_RETURN_LINE, "-");
-
- set_graphic_parameters(i, fallback_image->default_parameter);
- graphic_info[i].bitmap = fallback_bitmap;
- }
-
-#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
- /* currently we need only a tile clip mask from the first frame */
- getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
-
- if (copy_clipmask_gc == None)
- {
- clip_gc_values.graphics_exposures = False;
- clip_gc_valuemask = GCGraphicsExposures;
- copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
- clip_gc_valuemask, &clip_gc_values);
- }
-
- graphic_info[i].clip_mask =
- XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
-
- src_pixmap = src_bitmap->clip_mask;
- XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
- copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
-
- clip_gc_values.graphics_exposures = False;
- clip_gc_values.clip_mask = graphic_info[i].clip_mask;
- clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
-
- graphic_info[i].clip_gc =
- XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
-#endif
- }
-
-#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
- if (copy_clipmask_gc)
- XFreeGC(display, copy_clipmask_gc);
-
- clipmasks_initialized = TRUE;
-#endif
-}
-
-static void InitElementSoundInfo()
-{
- struct PropertyMapping *property_mapping = getSoundListPropertyMapping();
- int num_property_mappings = getSoundListPropertyMappingSize();
- int i, j, act;
-
- /* 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].sound[act] = -1;
-
- /* initialize element/sound mapping from static configuration */
- for (i=0; element_to_sound[i].element > -1; i++)
- {
- int element = element_to_sound[i].element;
- int action = element_to_sound[i].action;
- int sound = element_to_sound[i].sound;
- boolean is_class = element_to_sound[i].is_class;
-
- if (action < 0)
- action = ACTION_DEFAULT;
-
- if (!is_class)
- element_info[element].sound[action] = sound;
- else
- for (j=0; j < MAX_NUM_ELEMENTS; j++)
- if (strcmp(element_info[j].class_name,
- element_info[element].class_name) == 0)
- element_info[j].sound[action] = sound;
- }
-
- /* initialize element/sound 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 sound = property_mapping[i].artwork_index;
-
- if (element >= MAX_NUM_ELEMENTS)
- continue;
-
- if (action < 0)
- action = ACTION_DEFAULT;
-
- element_info[element].sound[action] = sound;
- }
-
- /* initialize element class/sound mapping from dynamic configuration */
- for (i=0; i < num_property_mappings; i++)
- {
- int element_class = property_mapping[i].base_index - MAX_NUM_ELEMENTS;
- int action = property_mapping[i].ext1_index;
- int sound = property_mapping[i].artwork_index;
-
- if (element_class < 0 || element_class >= MAX_NUM_ELEMENTS)
- continue;
-
- if (action < 0)
- action = ACTION_DEFAULT;
-
- for (j=0; j < MAX_NUM_ELEMENTS; j++)
- if (strcmp(element_info[j].class_name,
- element_info[element_class].class_name) == 0)
- element_info[j].sound[action] = sound;
- }
-
- /* now set all '-1' values to element specific default values */
- for (i=0; i<MAX_NUM_ELEMENTS; i++)
- {
- int default_action_sound = element_info[i].sound[ACTION_DEFAULT];
-
- for (act=0; act < NUM_ACTIONS; act++)
- {
- /* no sound for this specific action -- use default action sound */
- if (element_info[i].sound[act] == -1)
- element_info[i].sound[act] = default_action_sound;
- }
- }
-}
-
-static void set_sound_parameters(int sound, char **parameter_raw)
-{
- int parameter[NUM_SND_ARGS];
- int i;
-
- /* get integer values from string parameters */
- for (i=0; i < NUM_SND_ARGS; i++)
- parameter[i] =
- get_parameter_value(sound_config_suffix[i].token, parameter_raw[i],
- sound_config_suffix[i].type);
-
- /* explicit loop mode setting in configuration overrides default value */
- if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
- sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP];
-}
-
-static void InitSoundInfo()
-{
- struct PropertyMapping *property_mapping = getSoundListPropertyMapping();
- int num_property_mappings = getSoundListPropertyMappingSize();
- int *sound_effect_properties;
- int num_sounds = getSoundListSize();
- int i, j;
-
- if (sound_info != NULL)
- free(sound_info);
-
- sound_effect_properties = checked_calloc(num_sounds * sizeof(int));
- sound_info = checked_calloc(num_sounds * sizeof(struct SoundInfo));
-
- /* initialize sound effect for all elements to "no sound" */
- for (i=0; i<MAX_NUM_ELEMENTS; i++)
- for (j=0; j<NUM_ACTIONS; j++)
- element_info[i].sound[j] = SND_UNDEFINED;
-
- for (i=0; i<num_sounds; i++)
- {
- struct FileInfo *sound = getSoundListEntry(i);
- int len_effect_text = strlen(sound->token);
-
- sound_effect_properties[i] = ACTION_OTHER;
- sound_info[i].loop = FALSE;
-
- /* determine all loop sounds and identify certain sound classes */
-
- for (j=0; element_action_info[j].suffix; j++)
- {
- int len_action_text = strlen(element_action_info[j].suffix);
-
- if (len_action_text < len_effect_text &&
- strcmp(&sound->token[len_effect_text - len_action_text],
- element_action_info[j].suffix) == 0)
- {
- sound_effect_properties[i] = element_action_info[j].value;
-
- if (element_action_info[j].is_loop_sound)
- sound_info[i].loop = TRUE;
- }
- }
-
- /* associate elements and some selected sound actions */
-
- for (j=0; j<MAX_NUM_ELEMENTS; j++)
- {
- if (element_info[j].class_name)
- {
- int len_class_text = strlen(element_info[j].class_name);
-
- if (len_class_text + 1 < len_effect_text &&
- strncmp(sound->token,
- element_info[j].class_name, len_class_text) == 0 &&
- sound->token[len_class_text] == '.')
- {
- int sound_action_value = sound_effect_properties[i];
-
- element_info[j].sound[sound_action_value] = i;
- }
- }
- }
-
- set_sound_parameters(i, sound->parameter);
- }
-
- free(sound_effect_properties);
-
- /* initialize element/sound 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 sound = property_mapping[i].artwork_index;
-
- if (action < 0)
- action = ACTION_DEFAULT;
-
- element_info[element].sound[action] = sound;
- }
-
-#if 0
- /* TEST ONLY */
- {
- int element = EL_CUSTOM_11;
- int j = 0;
-
- while (element_action_info[j].suffix)
- {
- printf("element %d, sound action '%s' == %d\n",
- element, element_action_info[j].suffix,
- element_info[element].sound[j]);
- j++;
- }
- }
-
- PlaySoundLevelElementAction(0,0, EL_CUSTOM_11, ACTION_PUSHING);
-#endif
-
-#if 0
- /* TEST ONLY */
- {
- int element = EL_SAND;
- int sound_action = ACTION_DIGGING;
- int j = 0;
-
- while (element_action_info[j].suffix)
- {
- if (element_action_info[j].value == sound_action)
- printf("element %d, sound action '%s' == %d\n",
- element, element_action_info[j].suffix,
- element_info[element].sound[sound_action]);
- j++;
- }
- }
-#endif
-}
-
-void InitElementProperties()
-{
- int i, j;
-
- static int ep_amoebalive[] =
- {
- EL_AMOEBA_WET,
- EL_AMOEBA_DRY,
- EL_AMOEBA_FULL,
- EL_BD_AMOEBA
- };
- static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
-
- static int ep_amoeboid[] =
- {
- EL_AMOEBA_DEAD,
- EL_AMOEBA_WET,
- EL_AMOEBA_DRY,
- EL_AMOEBA_FULL,
- EL_BD_AMOEBA
- };
- static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
-
- static int ep_schluessel[] =
- {
- EL_KEY_1,
- EL_KEY_2,
- EL_KEY_3,
- EL_KEY_4,
- EL_EM_KEY_1,
- EL_EM_KEY_2,
- EL_EM_KEY_3,
- EL_EM_KEY_4
- };
- static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
-
- static int ep_pforte[] =
- {
- EL_GATE_1,
- EL_GATE_2,
- EL_GATE_3,
- EL_GATE_4,
- EL_GATE_1_GRAY,
- EL_GATE_2_GRAY,
- EL_GATE_3_GRAY,
- EL_GATE_4_GRAY,
- EL_EM_GATE_1,
- EL_EM_GATE_2,
- EL_EM_GATE_3,
- EL_EM_GATE_4,
- EL_EM_GATE_1_GRAY,
- EL_EM_GATE_2_GRAY,
- EL_EM_GATE_3_GRAY,
- EL_EM_GATE_4_GRAY,
- EL_SWITCHGATE_OPEN,
- EL_SWITCHGATE_OPENING,
- EL_SWITCHGATE_CLOSED,
- EL_SWITCHGATE_CLOSING,
- EL_TIMEGATE_OPEN,
- EL_TIMEGATE_OPENING,
- EL_TIMEGATE_CLOSED,
- EL_TIMEGATE_CLOSING,
- EL_TUBE_ANY,
- EL_TUBE_VERTICAL,
- EL_TUBE_HORIZONTAL,
- EL_TUBE_VERTICAL_LEFT,
- EL_TUBE_VERTICAL_RIGHT,
- EL_TUBE_HORIZONTAL_UP,
- EL_TUBE_HORIZONTAL_DOWN,
- EL_TUBE_LEFT_UP,
- EL_TUBE_LEFT_DOWN,
- EL_TUBE_RIGHT_UP,
- EL_TUBE_RIGHT_DOWN
- };
- static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);