+static void SetGlobalAnimEventsForCustomElements(int list_pos)
+{
+ int num_events = GetGlobalAnimEventValueCount(list_pos);
+ int i;
+
+ for (i = 0; i < num_events; i++)
+ {
+ int event = GetGlobalAnimEventValue(list_pos, i);
+
+ if (event & ANIM_EVENT_CE_CHANGE)
+ {
+ int nr = (event >> ANIM_EVENT_CE_BIT) & 0xff;
+
+ if (nr >= 0 && nr < NUM_CUSTOM_ELEMENTS)
+ element_info[EL_CUSTOM_START + nr].has_anim_event = TRUE;
+ }
+ }
+}
+
+void InitGlobalAnimEventsForCustomElements(void)
+{
+ int m, a, p;
+ int control;
+
+ // custom element events for global animations only relevant while playing
+ m = GAME_MODE_PLAYING;
+
+ for (a = 0; a < NUM_GLOBAL_ANIMS; a++)
+ {
+ int ctrl_id = GLOBAL_ANIM_ID_CONTROL_FIRST + a;
+
+ control = global_anim_info[ctrl_id].graphic[GLOBAL_ANIM_ID_PART_BASE][m];
+
+ // if no base animation parameters defined, use default values
+ if (control == IMG_UNDEFINED)
+ control = IMG_INTERNAL_GLOBAL_ANIM_DEFAULT;
+
+ SetGlobalAnimEventsForCustomElements(graphic_info[control].init_event);
+ SetGlobalAnimEventsForCustomElements(graphic_info[control].anim_event);
+
+ for (p = 0; p < NUM_GLOBAL_ANIM_PARTS_ALL; p++)
+ {
+ control = global_anim_info[ctrl_id].graphic[p][m];
+
+ if (control == IMG_UNDEFINED)
+ continue;
+
+ SetGlobalAnimEventsForCustomElements(graphic_info[control].init_event);
+ SetGlobalAnimEventsForCustomElements(graphic_info[control].anim_event);
+ }
+ }
+}
+