- (example: a level that contains EL_PLAYER_3 as the only player would
- incorrectly give EL_PLAYER_1 for "player->element_nr") */
- int player_element = PLAYERINFO(xx, yy)->initial_element;
-
- CheckElementChangeBySide(x, y, center_element, player_element,
- CE_TOUCHING_X, border_side);
- }
-#endif
- }
-}
-
-#else
-
-void TestIfElementTouchesCustomElement_OLD(int x, int y)
-{
- static int xy[4][2] =
- {
- { 0, -1 },
- { -1, 0 },
- { +1, 0 },
- { 0, +1 }
- };
- static int trigger_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 */
- };
- static int touch_dir[4] =
- {
- MV_LEFT | MV_RIGHT,
- MV_UP | MV_DOWN,
- MV_UP | MV_DOWN,
- MV_LEFT | MV_RIGHT
- };
- boolean change_center_element = FALSE;
- int center_element = Feld[x][y]; /* should always be non-moving! */
- int i;
-
- for (i = 0; i < NUM_DIRECTIONS; i++)
- {
- int xx = x + xy[i][0];
- int yy = y + xy[i][1];
- int center_side = trigger_sides[i][0];
- int border_side = trigger_sides[i][1];
- int border_element;
-
- if (!IN_LEV_FIELD(xx, yy))
- continue;
-
- if (game.engine_version < VERSION_IDENT(3,0,7,0))
- border_element = Feld[xx][yy]; /* may be moving! */
- else if (!IS_MOVING(xx, yy) && !IS_BLOCKED(xx, yy))
- border_element = Feld[xx][yy];
- else if (MovDir[xx][yy] & touch_dir[i]) /* elements are touching */
- border_element = MovingOrBlocked2Element(xx, yy);
- else
- continue; /* center and border element do not touch */
-
- /* check for change of center element (but change it only once) */
- if (!change_center_element)
- change_center_element =
- CheckElementChangeBySide(x, y, center_element, border_element,
- CE_TOUCHING_X, border_side);
-
- /* check for change of border element */
- CheckElementChangeBySide(xx, yy, border_element, center_element,
- CE_TOUCHING_X, center_side);
- }
-}
-
-#endif
-
-void TestIfElementHitsCustomElement(int x, int y, int direction)
-{
- int dx = (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0);
- int dy = (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0);
- int hitx = x + dx, hity = y + dy;
- int hitting_element = Feld[x][y];
- int touched_element;
-
- if (IN_LEV_FIELD(hitx, hity) && IS_FREE(hitx, hity))
- return;
-
- touched_element = (IN_LEV_FIELD(hitx, hity) ?
- MovingOrBlocked2Element(hitx, hity) : EL_STEELWALL);
-
- if (IN_LEV_FIELD(hitx, hity))
- {
- int opposite_direction = MV_DIR_OPPOSITE(direction);
- int hitting_side = direction;
- int touched_side = opposite_direction;
- boolean object_hit = (!IS_MOVING(hitx, hity) ||
- MovDir[hitx][hity] != direction ||
- ABS(MovPos[hitx][hity]) <= TILEY / 2);
-
- object_hit = TRUE;
-
- if (object_hit)
- {
- CheckElementChangeBySide(x, y, hitting_element, touched_element,
- CE_HITTING_X, touched_side);
-
- CheckElementChangeBySide(hitx, hity, touched_element, hitting_element,
- CE_HIT_BY_X, hitting_side);
-
- CheckElementChangeBySide(hitx, hity, touched_element, hitting_element,
- CE_HIT_BY_SOMETHING, opposite_direction);
-
-#if USE_FIX_CE_ACTION_WITH_PLAYER
- if (IS_PLAYER(hitx, hity))
- {
- /* use player element that is initially defined in the level playfield,
- not the player element that corresponds to the runtime player number
- (example: a level that contains EL_PLAYER_3 as the only player would
- incorrectly give EL_PLAYER_1 for "player->element_nr") */
- int player_element = PLAYERINFO(hitx, hity)->initial_element;