+#if 0
+ if (check_changing) /* prevent this function from running into a loop */
+ return;
+
+ check_changing = TRUE;
+#endif
+
+ for (i=0; i<4; i++)
+ {
+ int xx = x + xy[i][0];
+ int yy = y + xy[i][1];
+ int center_side = change_sides[i][0];
+ int border_side = change_sides[i][1];
+
+ if (!IN_LEV_FIELD(xx, yy))
+ continue;
+
+#if 1
+ if (IS_PLAYER(x, y))
+ {
+ CheckTriggeredElementSideChange(xx, yy, Feld[xx][yy], border_side,
+ CE_OTHER_GETS_TOUCHED);
+ CheckElementSideChange(xx, yy, Feld[xx][yy], border_side,
+ CE_TOUCHED_BY_PLAYER, -1);
+ }
+ else if (IS_PLAYER(xx, yy))
+ {
+ CheckTriggeredElementSideChange(x, y, Feld[x][y], center_side,
+ CE_OTHER_GETS_TOUCHED);
+ CheckElementSideChange(x, y, Feld[x][y], center_side,
+ CE_TOUCHED_BY_PLAYER, -1);
+
+ break;
+ }
+#else
+ if (IS_PLAYER(x, y))
+ {
+ CheckTriggeredElementChange(xx, yy, Feld[xx][yy], CE_OTHER_GETS_TOUCHED);
+ CheckElementChange(xx, yy, Feld[xx][yy], CE_TOUCHED_BY_PLAYER);
+ }
+ else if (IS_PLAYER(xx, yy))
+ {
+ CheckTriggeredElementChange(x, y, Feld[x][y], CE_OTHER_GETS_TOUCHED);
+ CheckElementChange(x, y, Feld[x][y], CE_TOUCHED_BY_PLAYER);
+
+ break;
+ }
+#endif
+ }
+
+#if 0
+ check_changing = FALSE;
+#endif
+}
+
+void TestIfElementTouchesCustomElement(int x, int y)
+{
+#if 0
+ static boolean check_changing = FALSE;
+#endif
+ static int xy[4][2] =
+ {
+ { 0, -1 },
+ { -1, 0 },
+ { +1, 0 },
+ { 0, +1 }
+ };
+ static int change_sides[4][2] =
+ {
+ /* center side border side */
+ { CH_SIDE_TOP, CH_SIDE_BOTTOM }, /* check top */
+ { CH_SIDE_LEFT, CH_SIDE_RIGHT }, /* check left */
+ { CH_SIDE_RIGHT, CH_SIDE_LEFT }, /* check right */
+ { CH_SIDE_BOTTOM, CH_SIDE_TOP } /* check bottom */
+ };
+ boolean change_center_element = FALSE;
+ int center_element_change_page = 0;
+ int center_element = Feld[x][y];
+ int i, j;
+
+#if 0
+ if (check_changing) /* prevent this function from running into a loop */
+ return;
+
+ check_changing = TRUE;
+#endif
+
+ for (i=0; i<4; i++)
+ {
+ int xx = x + xy[i][0];
+ int yy = y + xy[i][1];
+ int center_side = change_sides[i][0];
+ int border_side = change_sides[i][1];
+ int border_element;
+
+ if (!IN_LEV_FIELD(xx, yy))
+ continue;
+
+ border_element = Feld[xx][yy];
+
+ /* check for change of center element (but change it only once) */
+ if (IS_CUSTOM_ELEMENT(center_element) &&
+ HAS_ANY_CHANGE_EVENT(center_element, CE_OTHER_IS_TOUCHING) &&
+ !change_center_element)
+ {
+ for (j=0; j < element_info[center_element].num_change_pages; j++)
+ {
+ struct ElementChangeInfo *change =
+ &element_info[center_element].change_page[j];
+
+ if (change->events & CH_EVENT_BIT(CE_OTHER_IS_TOUCHING) &&
+ change->sides & border_side &&
+ change->trigger_element == border_element)
+ {
+ change_center_element = TRUE;
+ center_element_change_page = j;
+
+ break;
+ }
+ }
+ }
+
+ /* check for change of border element */
+ if (IS_CUSTOM_ELEMENT(border_element) &&
+ HAS_ANY_CHANGE_EVENT(border_element, CE_OTHER_IS_TOUCHING))
+ {
+ for (j=0; j < element_info[border_element].num_change_pages; j++)
+ {
+ struct ElementChangeInfo *change =
+ &element_info[border_element].change_page[j];
+
+ if (change->events & CH_EVENT_BIT(CE_OTHER_IS_TOUCHING) &&
+ change->sides & center_side &&
+ change->trigger_element == center_element)
+ {
+ CheckElementSideChange(xx, yy, border_element, CH_SIDE_ANY,
+ CE_OTHER_IS_TOUCHING, j);
+ break;
+ }
+ }
+ }
+ }
+
+ if (change_center_element)
+ CheckElementSideChange(x, y, center_element, CH_SIDE_ANY,
+ CE_OTHER_IS_TOUCHING, center_element_change_page);
+
+#if 0
+ check_changing = FALSE;
+#endif
+}
+
+void TestIfGoodThingHitsBadThing(int good_x, int good_y, int good_move_dir)
+{
+ int i, kill_x = -1, kill_y = -1;
+ static int test_xy[4][2] =
+ {
+ { 0, -1 },
+ { -1, 0 },
+ { +1, 0 },
+ { 0, +1 }
+ };
+ static int test_dir[4] =
+ {
+ MV_UP,
+ MV_LEFT,
+ MV_RIGHT,
+ MV_DOWN
+ };
+
+ for (i=0; i<4; i++)
+ {