+void TestIfPlayerTouchesCustomElement(int x, int y)
+{
+ static boolean check_changing = FALSE;
+ static int xy[4][2] =
+ {
+ { 0, -1 },
+ { -1, 0 },
+ { +1, 0 },
+ { 0, +1 }
+ };
+ boolean center_is_player = (IS_PLAYER(x, y));
+ int i;
+
+ /* prevent TestIfPlayerTouchesCustomElement() from looping */
+ if (check_changing)
+ return;
+
+ check_changing = TRUE;
+
+ for (i=0; i<4; i++)
+ {
+ int xx = x + xy[i][0];
+ int yy = y + xy[i][1];
+
+ if (!IN_LEV_FIELD(xx, yy))
+ continue;
+
+ if (center_is_player)
+ {
+ 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;
+ }
+ }
+
+ check_changing = FALSE;
+}
+
+void TestIfElementTouchesCustomElement(int x, int y)
+{
+ static boolean check_changing = FALSE;
+ static int xy[4][2] =
+ {
+ { 0, -1 },
+ { -1, 0 },
+ { +1, 0 },
+ { 0, +1 }
+ };
+ boolean center_is_custom = (IS_CUSTOM_ELEMENT(Feld[x][y]));
+ int i;
+
+ /* prevent TestIfElementTouchesCustomElement() from looping */
+ if (check_changing)
+ return;
+
+ check_changing = TRUE;
+
+ for (i=0; i<4; i++)
+ {
+ int xx = x + xy[i][0];
+ int yy = y + xy[i][1];
+
+ if (!IN_LEV_FIELD(xx, yy))
+ continue;
+
+ if (center_is_custom &&
+ Feld[xx][yy] == element_info[Feld[x][y]].change.trigger_element)
+ {
+ CheckElementChange(x, y, Feld[x][y], CE_OTHER_IS_TOUCHING);
+ }
+
+ if (IS_CUSTOM_ELEMENT(Feld[xx][yy]) &&
+ Feld[x][y] == element_info[Feld[xx][yy]].change.trigger_element)
+ {
+ CheckElementChange(xx, yy, Feld[xx][yy], CE_OTHER_IS_TOUCHING);
+ }
+ }
+
+ check_changing = FALSE;
+}
+