+ Feld[move_x][move_y] = EL_EMC_SPRING_BUMPER_ACTIVE;
+ ResetGfxAnimation(move_x, move_y);
+ DrawLevelField(move_x, move_y);
+
+ MovDir[x][y] = back_dir;
+ }
+ else if (!SPRING_CAN_ENTER_FIELD(element, move_x, move_y) ||
+ SPRING_CAN_ENTER_FIELD(element, x, y + 1))
+ MovDir[x][y] = MV_NONE;
+ }
+#else
+ if (MovDir[x][y] & MV_HORIZONTAL &&
+ (!SPRING_CAN_ENTER_FIELD(element, move_x, move_y) ||
+ SPRING_CAN_ENTER_FIELD(element, x, y + 1)))
+ MovDir[x][y] = MV_NONE;
+#endif
+
+ MovDelay[x][y] = 0;
+ }
+ else if (element == EL_ROBOT ||
+ element == EL_SATELLITE ||
+ element == EL_PENGUIN ||
+ element == EL_EMC_ANDROID)
+ {
+ int attr_x = -1, attr_y = -1;
+
+ if (AllPlayersGone)
+ {
+ attr_x = ExitX;
+ attr_y = ExitY;
+ }
+ else
+ {
+ int i;
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ struct PlayerInfo *player = &stored_player[i];
+ int jx = player->jx, jy = player->jy;
+
+ if (!player->active)
+ continue;
+
+ if (attr_x == -1 ||
+ ABS(jx - x) + ABS(jy - y) < ABS(attr_x - x) + ABS(attr_y - y))
+ {
+ attr_x = jx;
+ attr_y = jy;
+ }
+ }
+ }
+
+ if (element == EL_ROBOT && ZX >= 0 && ZY >= 0 &&
+ (Feld[ZX][ZY] == EL_ROBOT_WHEEL_ACTIVE ||
+ game.engine_version < VERSION_IDENT(3,1,0,0)))
+ {
+ attr_x = ZX;
+ attr_y = ZY;
+ }
+
+ if (element == EL_PENGUIN)
+ {
+ int i;
+ static int xy[4][2] =
+ {
+ { 0, -1 },
+ { -1, 0 },
+ { +1, 0 },
+ { 0, +1 }
+ };
+
+ for (i = 0; i < NUM_DIRECTIONS; i++)
+ {
+ int ex = x + xy[i][0];
+ int ey = y + xy[i][1];
+
+ if (IN_LEV_FIELD(ex, ey) && (Feld[ex][ey] == EL_EXIT_OPEN ||
+ Feld[ex][ey] == EL_EM_EXIT_OPEN ||
+ Feld[ex][ey] == EL_STEEL_EXIT_OPEN ||
+ Feld[ex][ey] == EL_EM_STEEL_EXIT_OPEN))
+ {
+ attr_x = ex;
+ attr_y = ey;
+ break;
+ }
+ }
+ }
+
+ MovDir[x][y] = MV_NONE;
+ if (attr_x < x)
+ MovDir[x][y] |= (AllPlayersGone ? MV_RIGHT : MV_LEFT);
+ else if (attr_x > x)
+ MovDir[x][y] |= (AllPlayersGone ? MV_LEFT : MV_RIGHT);
+ if (attr_y < y)
+ MovDir[x][y] |= (AllPlayersGone ? MV_DOWN : MV_UP);
+ else if (attr_y > y)
+ MovDir[x][y] |= (AllPlayersGone ? MV_UP : MV_DOWN);
+
+ if (element == EL_ROBOT)
+ {
+ int newx, newy;
+
+ if (MovDir[x][y] & MV_HORIZONTAL && MovDir[x][y] & MV_VERTICAL)
+ MovDir[x][y] &= (RND(2) ? MV_HORIZONTAL : MV_VERTICAL);
+ Moving2Blocked(x, y, &newx, &newy);
+
+ if (IN_LEV_FIELD(newx, newy) && IS_FREE_OR_PLAYER(newx, newy))
+ MovDelay[x][y] = 8 + 8 * !RND(3);
+ else
+ MovDelay[x][y] = 16;
+ }
+ else if (element == EL_PENGUIN)
+ {
+ int newx, newy;
+
+ MovDelay[x][y] = 1;
+
+ if (MovDir[x][y] & MV_HORIZONTAL && MovDir[x][y] & MV_VERTICAL)
+ {
+ boolean first_horiz = RND(2);
+ int new_move_dir = MovDir[x][y];
+
+ MovDir[x][y] =
+ new_move_dir & (first_horiz ? MV_HORIZONTAL : MV_VERTICAL);
+ Moving2Blocked(x, y, &newx, &newy);
+
+ if (PENGUIN_CAN_ENTER_FIELD(element, newx, newy))
+ return;
+
+ MovDir[x][y] =
+ new_move_dir & (!first_horiz ? MV_HORIZONTAL : MV_VERTICAL);
+ Moving2Blocked(x, y, &newx, &newy);
+
+ if (PENGUIN_CAN_ENTER_FIELD(element, newx, newy))
+ return;
+
+ MovDir[x][y] = old_move_dir;
+ return;
+ }
+ }
+ else if (element == EL_SATELLITE)
+ {
+ int newx, newy;
+
+ MovDelay[x][y] = 1;
+
+ if (MovDir[x][y] & MV_HORIZONTAL && MovDir[x][y] & MV_VERTICAL)
+ {
+ boolean first_horiz = RND(2);
+ int new_move_dir = MovDir[x][y];
+
+ MovDir[x][y] =
+ new_move_dir & (first_horiz ? MV_HORIZONTAL : MV_VERTICAL);
+ Moving2Blocked(x, y, &newx, &newy);
+
+ if (SATELLITE_CAN_ENTER_FIELD(newx, newy))
+ return;
+
+ MovDir[x][y] =
+ new_move_dir & (!first_horiz ? MV_HORIZONTAL : MV_VERTICAL);
+ Moving2Blocked(x, y, &newx, &newy);
+
+ if (SATELLITE_CAN_ENTER_FIELD(newx, newy))
+ return;
+
+ MovDir[x][y] = old_move_dir;
+ return;
+ }
+ }
+ else if (element == EL_EMC_ANDROID)
+ {
+ static int check_pos[16] =
+ {
+ -1, /* 0 => (invalid) */
+ 7, /* 1 => MV_LEFT */
+ 3, /* 2 => MV_RIGHT */
+ -1, /* 3 => (invalid) */
+ 1, /* 4 => MV_UP */
+ 0, /* 5 => MV_LEFT | MV_UP */
+ 2, /* 6 => MV_RIGHT | MV_UP */
+ -1, /* 7 => (invalid) */
+ 5, /* 8 => MV_DOWN */
+ 6, /* 9 => MV_LEFT | MV_DOWN */
+ 4, /* 10 => MV_RIGHT | MV_DOWN */
+ -1, /* 11 => (invalid) */
+ -1, /* 12 => (invalid) */
+ -1, /* 13 => (invalid) */
+ -1, /* 14 => (invalid) */
+ -1, /* 15 => (invalid) */
+ };
+ static struct
+ {
+ int dx, dy;
+ int dir;
+ } check_xy[8] =
+ {
+ { -1, -1, MV_LEFT | MV_UP },
+ { 0, -1, MV_UP },
+ { +1, -1, MV_RIGHT | MV_UP },
+ { +1, 0, MV_RIGHT },
+ { +1, +1, MV_RIGHT | MV_DOWN },
+ { 0, +1, MV_DOWN },
+ { -1, +1, MV_LEFT | MV_DOWN },
+ { -1, 0, MV_LEFT },
+ };
+ int start_pos, check_order;
+ boolean can_clone = FALSE;
+ int i;
+
+ /* check if there is any free field around current position */
+ for (i = 0; i < 8; i++)
+ {
+ int newx = x + check_xy[i].dx;
+ int newy = y + check_xy[i].dy;
+
+ if (IN_LEV_FIELD_AND_IS_FREE(newx, newy))
+ {
+ can_clone = TRUE;
+
+ break;
+ }
+ }
+
+ if (can_clone) /* randomly find an element to clone */
+ {
+ can_clone = FALSE;
+
+ start_pos = check_pos[RND(8)];
+ check_order = (RND(2) ? -1 : +1);
+
+ for (i = 0; i < 8; i++)
+ {
+ int pos_raw = start_pos + i * check_order;
+ int pos = (pos_raw + 8) % 8;
+ int newx = x + check_xy[pos].dx;
+ int newy = y + check_xy[pos].dy;
+
+ if (ANDROID_CAN_CLONE_FIELD(newx, newy))
+ {
+ element_info[element].move_leave_type = LEAVE_TYPE_LIMITED;
+ element_info[element].move_leave_element = EL_TRIGGER_ELEMENT;
+
+ Store[x][y] = Feld[newx][newy];
+
+ can_clone = TRUE;
+
+ break;
+ }
+ }
+ }
+
+ if (can_clone) /* randomly find a direction to move */
+ {
+ can_clone = FALSE;
+
+ start_pos = check_pos[RND(8)];
+ check_order = (RND(2) ? -1 : +1);
+
+ for (i = 0; i < 8; i++)
+ {
+ int pos_raw = start_pos + i * check_order;
+ int pos = (pos_raw + 8) % 8;
+ int newx = x + check_xy[pos].dx;
+ int newy = y + check_xy[pos].dy;
+ int new_move_dir = check_xy[pos].dir;
+
+ if (IN_LEV_FIELD_AND_IS_FREE(newx, newy))
+ {
+ MovDir[x][y] = new_move_dir;
+ MovDelay[x][y] = level.android_clone_time * 8 + 1;
+
+ can_clone = TRUE;
+
+ break;
+ }
+ }
+ }
+
+ if (can_clone) /* cloning and moving successful */
+ return;
+
+ /* cannot clone -- try to move towards player */
+
+ start_pos = check_pos[MovDir[x][y] & 0x0f];
+ check_order = (RND(2) ? -1 : +1);
+
+ for (i = 0; i < 3; i++)
+ {
+ /* first check start_pos, then previous/next or (next/previous) pos */
+ int pos_raw = start_pos + (i < 2 ? i : -1) * check_order;
+ int pos = (pos_raw + 8) % 8;
+ int newx = x + check_xy[pos].dx;
+ int newy = y + check_xy[pos].dy;
+ int new_move_dir = check_xy[pos].dir;
+
+ if (IS_PLAYER(newx, newy))
+ break;
+
+ if (ANDROID_CAN_ENTER_FIELD(element, newx, newy))
+ {
+ MovDir[x][y] = new_move_dir;
+ MovDelay[x][y] = level.android_move_time * 8 + 1;
+
+ break;
+ }
+ }
+ }
+ }
+ else if (move_pattern == MV_TURNING_LEFT ||
+ move_pattern == MV_TURNING_RIGHT ||
+ move_pattern == MV_TURNING_LEFT_RIGHT ||
+ move_pattern == MV_TURNING_RIGHT_LEFT ||
+ move_pattern == MV_TURNING_RANDOM ||
+ move_pattern == MV_ALL_DIRECTIONS)
+ {
+ boolean can_turn_left =
+ CUSTOM_ELEMENT_CAN_ENTER_FIELD(element, left_x, left_y);
+ boolean can_turn_right =
+ CUSTOM_ELEMENT_CAN_ENTER_FIELD(element, right_x,right_y);
+
+ if (element_info[element].move_stepsize == 0) /* "not moving" */
+ return;
+
+ if (move_pattern == MV_TURNING_LEFT)
+ MovDir[x][y] = left_dir;
+ else if (move_pattern == MV_TURNING_RIGHT)
+ MovDir[x][y] = right_dir;
+ else if (move_pattern == MV_TURNING_LEFT_RIGHT)
+ MovDir[x][y] = (can_turn_left || !can_turn_right ? left_dir : right_dir);
+ else if (move_pattern == MV_TURNING_RIGHT_LEFT)
+ MovDir[x][y] = (can_turn_right || !can_turn_left ? right_dir : left_dir);
+ else if (move_pattern == MV_TURNING_RANDOM)
+ MovDir[x][y] = (can_turn_left && !can_turn_right ? left_dir :
+ can_turn_right && !can_turn_left ? right_dir :
+ RND(2) ? left_dir : right_dir);
+ else if (can_turn_left && can_turn_right)
+ MovDir[x][y] = (RND(3) ? (RND(2) ? left_dir : right_dir) : back_dir);
+ else if (can_turn_left)
+ MovDir[x][y] = (RND(2) ? left_dir : back_dir);
+ else if (can_turn_right)
+ MovDir[x][y] = (RND(2) ? right_dir : back_dir);
+ else
+ MovDir[x][y] = back_dir;
+
+ MovDelay[x][y] = GET_NEW_MOVE_DELAY(element);
+ }
+ else if (move_pattern == MV_HORIZONTAL ||
+ move_pattern == MV_VERTICAL)
+ {
+ if (move_pattern & old_move_dir)
+ MovDir[x][y] = back_dir;
+ else if (move_pattern == MV_HORIZONTAL)
+ MovDir[x][y] = (RND(2) ? MV_LEFT : MV_RIGHT);
+ else if (move_pattern == MV_VERTICAL)
+ MovDir[x][y] = (RND(2) ? MV_UP : MV_DOWN);
+
+ MovDelay[x][y] = GET_NEW_MOVE_DELAY(element);
+ }
+ else if (move_pattern & MV_ANY_DIRECTION)
+ {
+ MovDir[x][y] = move_pattern;
+ MovDelay[x][y] = GET_NEW_MOVE_DELAY(element);
+ }
+ else if (move_pattern & MV_WIND_DIRECTION)
+ {
+ MovDir[x][y] = game.wind_direction;
+ MovDelay[x][y] = GET_NEW_MOVE_DELAY(element);
+ }
+ else if (move_pattern == MV_ALONG_LEFT_SIDE)
+ {
+ if (CUSTOM_ELEMENT_CAN_ENTER_FIELD(element, left_x, left_y))
+ MovDir[x][y] = left_dir;
+ else if (!CUSTOM_ELEMENT_CAN_ENTER_FIELD(element, move_x, move_y))
+ MovDir[x][y] = right_dir;
+
+ if (MovDir[x][y] != old_move_dir)
+ MovDelay[x][y] = GET_NEW_MOVE_DELAY(element);
+ }
+ else if (move_pattern == MV_ALONG_RIGHT_SIDE)
+ {
+ if (CUSTOM_ELEMENT_CAN_ENTER_FIELD(element, right_x, right_y))
+ MovDir[x][y] = right_dir;
+ else if (!CUSTOM_ELEMENT_CAN_ENTER_FIELD(element, move_x, move_y))
+ MovDir[x][y] = left_dir;
+
+ if (MovDir[x][y] != old_move_dir)
+ MovDelay[x][y] = GET_NEW_MOVE_DELAY(element);
+ }
+ else if (move_pattern == MV_TOWARDS_PLAYER ||
+ move_pattern == MV_AWAY_FROM_PLAYER)
+ {
+ int attr_x = -1, attr_y = -1;
+ int newx, newy;
+ boolean move_away = (move_pattern == MV_AWAY_FROM_PLAYER);
+
+ if (AllPlayersGone)
+ {
+ attr_x = ExitX;
+ attr_y = ExitY;
+ }
+ else
+ {
+ int i;
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ struct PlayerInfo *player = &stored_player[i];
+ int jx = player->jx, jy = player->jy;
+
+ if (!player->active)
+ continue;
+
+ if (attr_x == -1 ||
+ ABS(jx - x) + ABS(jy - y) < ABS(attr_x - x) + ABS(attr_y - y))
+ {
+ attr_x = jx;
+ attr_y = jy;
+ }
+ }
+ }
+
+ MovDir[x][y] = MV_NONE;
+ if (attr_x < x)
+ MovDir[x][y] |= (move_away ? MV_RIGHT : MV_LEFT);
+ else if (attr_x > x)
+ MovDir[x][y] |= (move_away ? MV_LEFT : MV_RIGHT);
+ if (attr_y < y)
+ MovDir[x][y] |= (move_away ? MV_DOWN : MV_UP);
+ else if (attr_y > y)
+ MovDir[x][y] |= (move_away ? MV_UP : MV_DOWN);
+
+ MovDelay[x][y] = GET_NEW_MOVE_DELAY(element);
+
+ if (MovDir[x][y] & MV_HORIZONTAL && MovDir[x][y] & MV_VERTICAL)
+ {
+ boolean first_horiz = RND(2);
+ int new_move_dir = MovDir[x][y];
+
+ if (element_info[element].move_stepsize == 0) /* "not moving" */
+ {
+ first_horiz = (ABS(attr_x - x) >= ABS(attr_y - y));
+ MovDir[x][y] &= (first_horiz ? MV_HORIZONTAL : MV_VERTICAL);
+
+ return;
+ }
+
+ MovDir[x][y] =
+ new_move_dir & (first_horiz ? MV_HORIZONTAL : MV_VERTICAL);
+ Moving2Blocked(x, y, &newx, &newy);
+
+ if (CUSTOM_ELEMENT_CAN_ENTER_FIELD(element, newx, newy))
+ return;
+
+ MovDir[x][y] =
+ new_move_dir & (!first_horiz ? MV_HORIZONTAL : MV_VERTICAL);
+ Moving2Blocked(x, y, &newx, &newy);
+
+ if (CUSTOM_ELEMENT_CAN_ENTER_FIELD(element, newx, newy))
+ return;
+
+ MovDir[x][y] = old_move_dir;
+ }
+ }
+ else if (move_pattern == MV_WHEN_PUSHED ||
+ move_pattern == MV_WHEN_DROPPED)
+ {
+ if (!CUSTOM_ELEMENT_CAN_ENTER_FIELD(element, move_x, move_y))
+ MovDir[x][y] = MV_NONE;
+
+ MovDelay[x][y] = 0;
+ }
+ else if (move_pattern & MV_MAZE_RUNNER_STYLE)
+ {
+ static int test_xy[7][2] =
+ {
+ { 0, -1 },
+ { -1, 0 },
+ { +1, 0 },
+ { 0, +1 },
+ { 0, -1 },
+ { -1, 0 },
+ { +1, 0 },
+ };
+ static int test_dir[7] =
+ {
+ MV_UP,
+ MV_LEFT,
+ MV_RIGHT,
+ MV_DOWN,
+ MV_UP,
+ MV_LEFT,
+ MV_RIGHT,
+ };
+ boolean hunter_mode = (move_pattern == MV_MAZE_HUNTER);
+ int move_preference = -1000000; /* start with very low preference */
+ int new_move_dir = MV_NONE;
+ int start_test = RND(4);
+ int i;
+
+ for (i = 0; i < NUM_DIRECTIONS; i++)
+ {
+ int move_dir = test_dir[start_test + i];
+ int move_dir_preference;
+
+ xx = x + test_xy[start_test + i][0];
+ yy = y + test_xy[start_test + i][1];
+
+ if (hunter_mode && IN_LEV_FIELD(xx, yy) &&
+ (IS_PLAYER(xx, yy) || Feld[xx][yy] == EL_PLAYER_IS_LEAVING))
+ {
+ new_move_dir = move_dir;
+
+ break;
+ }
+
+ if (!CUSTOM_ELEMENT_CAN_ENTER_FIELD(element, xx, yy))
+ continue;
+
+ move_dir_preference = -1 * RunnerVisit[xx][yy];
+ if (hunter_mode && PlayerVisit[xx][yy] > 0)
+ move_dir_preference = PlayerVisit[xx][yy];
+
+ if (move_dir_preference > move_preference)
+ {
+ /* prefer field that has not been visited for the longest time */
+ move_preference = move_dir_preference;
+ new_move_dir = move_dir;
+ }
+ else if (move_dir_preference == move_preference &&
+ move_dir == old_move_dir)
+ {
+ /* prefer last direction when all directions are preferred equally */
+ move_preference = move_dir_preference;
+ new_move_dir = move_dir;
+ }
+ }
+
+ MovDir[x][y] = new_move_dir;
+ if (old_move_dir != new_move_dir)
+ MovDelay[x][y] = GET_NEW_MOVE_DELAY(element);
+ }
+}
+
+static void TurnRound(int x, int y)
+{
+ int direction = MovDir[x][y];
+
+ TurnRoundExt(x, y);
+
+ GfxDir[x][y] = MovDir[x][y];
+
+ if (direction != MovDir[x][y])
+ GfxFrame[x][y] = 0;
+
+ if (MovDelay[x][y])
+ GfxAction[x][y] = ACTION_TURNING_FROM_LEFT + MV_DIR_TO_BIT(direction);
+
+ ResetGfxFrame(x, y, FALSE);
+}
+
+static boolean JustBeingPushed(int x, int y)
+{
+ int i;
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ struct PlayerInfo *player = &stored_player[i];
+
+ if (player->active && player->is_pushing && player->MovPos)
+ {
+ int next_jx = player->jx + (player->jx - player->last_jx);
+ int next_jy = player->jy + (player->jy - player->last_jy);
+
+ if (x == next_jx && y == next_jy)
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+void StartMoving(int x, int y)
+{
+ boolean started_moving = FALSE; /* some elements can fall _and_ move */
+ int element = Feld[x][y];
+
+ if (Stop[x][y])
+ return;
+
+ if (MovDelay[x][y] == 0)
+ GfxAction[x][y] = ACTION_DEFAULT;
+
+ if (CAN_FALL(element) && y < lev_fieldy - 1)
+ {
+ if ((x > 0 && IS_PLAYER(x - 1, y)) ||
+ (x < lev_fieldx - 1 && IS_PLAYER(x + 1, y)))
+ if (JustBeingPushed(x, y))
+ return;
+
+ if (element == EL_QUICKSAND_FULL)
+ {
+ if (IS_FREE(x, y + 1))
+ {
+ InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+
+ Feld[x][y] = EL_QUICKSAND_EMPTYING;
+#if USE_QUICKSAND_BD_ROCK_BUGFIX
+ if (Store[x][y] != EL_ROCK && Store[x][y] != EL_BD_ROCK)
+ Store[x][y] = EL_ROCK;
+#else
+ Store[x][y] = EL_ROCK;
+#endif
+
+ PlayLevelSoundAction(x, y, ACTION_EMPTYING);
+ }
+ else if (Feld[x][y + 1] == EL_QUICKSAND_EMPTY)
+ {
+ if (!MovDelay[x][y])
+ MovDelay[x][y] = TILEY + 1;
+
+ if (MovDelay[x][y])
+ {
+ MovDelay[x][y]--;
+ if (MovDelay[x][y])
+ return;
+ }
+
+ Feld[x][y] = EL_QUICKSAND_EMPTY;
+ Feld[x][y + 1] = EL_QUICKSAND_FULL;
+ Store[x][y + 1] = Store[x][y];
+ Store[x][y] = 0;
+
+ PlayLevelSoundAction(x, y, ACTION_FILLING);
+ }
+ }
+ else if (element == EL_QUICKSAND_FAST_FULL)
+ {
+ if (IS_FREE(x, y + 1))
+ {
+ InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+
+ Feld[x][y] = EL_QUICKSAND_FAST_EMPTYING;
+#if USE_QUICKSAND_BD_ROCK_BUGFIX
+ if (Store[x][y] != EL_ROCK && Store[x][y] != EL_BD_ROCK)
+ Store[x][y] = EL_ROCK;
+#else
+ Store[x][y] = EL_ROCK;
+#endif
+
+ PlayLevelSoundAction(x, y, ACTION_EMPTYING);
+ }
+ else if (Feld[x][y + 1] == EL_QUICKSAND_FAST_EMPTY)
+ {
+ if (!MovDelay[x][y])
+ MovDelay[x][y] = TILEY + 1;
+
+ if (MovDelay[x][y])
+ {
+ MovDelay[x][y]--;
+ if (MovDelay[x][y])
+ return;
+ }
+
+ Feld[x][y] = EL_QUICKSAND_FAST_EMPTY;
+ Feld[x][y + 1] = EL_QUICKSAND_FAST_FULL;
+ Store[x][y + 1] = Store[x][y];
+ Store[x][y] = 0;
+
+ PlayLevelSoundAction(x, y, ACTION_FILLING);
+ }
+ }
+ else if ((element == EL_ROCK || element == EL_BD_ROCK) &&
+ Feld[x][y + 1] == EL_QUICKSAND_EMPTY)
+ {
+ InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+
+ Feld[x][y] = EL_QUICKSAND_FILLING;
+ Store[x][y] = element;
+
+ PlayLevelSoundAction(x, y, ACTION_FILLING);
+ }
+ else if ((element == EL_ROCK || element == EL_BD_ROCK) &&
+ Feld[x][y + 1] == EL_QUICKSAND_FAST_EMPTY)
+ {
+ InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+
+ Feld[x][y] = EL_QUICKSAND_FAST_FILLING;
+ Store[x][y] = element;
+
+ PlayLevelSoundAction(x, y, ACTION_FILLING);
+ }
+ else if (element == EL_MAGIC_WALL_FULL)
+ {
+ if (IS_FREE(x, y + 1))
+ {
+ InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+
+ Feld[x][y] = EL_MAGIC_WALL_EMPTYING;
+ Store[x][y] = EL_CHANGED(Store[x][y]);
+ }
+ else if (Feld[x][y + 1] == EL_MAGIC_WALL_ACTIVE)
+ {
+ if (!MovDelay[x][y])
+ MovDelay[x][y] = TILEY/4 + 1;
+
+ if (MovDelay[x][y])
+ {
+ MovDelay[x][y]--;
+ if (MovDelay[x][y])
+ return;
+ }
+
+ Feld[x][y] = EL_MAGIC_WALL_ACTIVE;
+ Feld[x][y + 1] = EL_MAGIC_WALL_FULL;
+ Store[x][y + 1] = EL_CHANGED(Store[x][y]);
+ Store[x][y] = 0;
+ }
+ }
+ else if (element == EL_BD_MAGIC_WALL_FULL)
+ {
+ if (IS_FREE(x, y + 1))
+ {
+ InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+
+ Feld[x][y] = EL_BD_MAGIC_WALL_EMPTYING;
+ Store[x][y] = EL_CHANGED_BD(Store[x][y]);
+ }
+ else if (Feld[x][y + 1] == EL_BD_MAGIC_WALL_ACTIVE)
+ {
+ if (!MovDelay[x][y])
+ MovDelay[x][y] = TILEY/4 + 1;
+
+ if (MovDelay[x][y])
+ {
+ MovDelay[x][y]--;
+ if (MovDelay[x][y])
+ return;
+ }
+
+ Feld[x][y] = EL_BD_MAGIC_WALL_ACTIVE;
+ Feld[x][y + 1] = EL_BD_MAGIC_WALL_FULL;
+ Store[x][y + 1] = EL_CHANGED_BD(Store[x][y]);
+ Store[x][y] = 0;
+ }
+ }
+ else if (element == EL_DC_MAGIC_WALL_FULL)
+ {
+ if (IS_FREE(x, y + 1))
+ {
+ InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+
+ Feld[x][y] = EL_DC_MAGIC_WALL_EMPTYING;
+ Store[x][y] = EL_CHANGED_DC(Store[x][y]);
+ }
+ else if (Feld[x][y + 1] == EL_DC_MAGIC_WALL_ACTIVE)
+ {
+ if (!MovDelay[x][y])
+ MovDelay[x][y] = TILEY/4 + 1;
+
+ if (MovDelay[x][y])
+ {
+ MovDelay[x][y]--;
+ if (MovDelay[x][y])
+ return;
+ }
+
+ Feld[x][y] = EL_DC_MAGIC_WALL_ACTIVE;
+ Feld[x][y + 1] = EL_DC_MAGIC_WALL_FULL;
+ Store[x][y + 1] = EL_CHANGED_DC(Store[x][y]);
+ Store[x][y] = 0;
+ }
+ }
+ else if ((CAN_PASS_MAGIC_WALL(element) &&
+ (Feld[x][y + 1] == EL_MAGIC_WALL_ACTIVE ||
+ Feld[x][y + 1] == EL_BD_MAGIC_WALL_ACTIVE)) ||
+ (CAN_PASS_DC_MAGIC_WALL(element) &&
+ (Feld[x][y + 1] == EL_DC_MAGIC_WALL_ACTIVE)))
+
+ {
+ InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+
+ Feld[x][y] =
+ (Feld[x][y + 1] == EL_MAGIC_WALL_ACTIVE ? EL_MAGIC_WALL_FILLING :
+ Feld[x][y + 1] == EL_BD_MAGIC_WALL_ACTIVE ? EL_BD_MAGIC_WALL_FILLING :
+ EL_DC_MAGIC_WALL_FILLING);
+ Store[x][y] = element;
+ }
+ else if (CAN_FALL(element) && Feld[x][y + 1] == EL_ACID)
+ {
+ SplashAcid(x, y + 1);
+
+ InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+
+ Store[x][y] = EL_ACID;
+ }
+ else if (
+#if USE_FIX_IMPACT_COLLISION
+ (game.engine_version >= VERSION_IDENT(3,1,0,0) &&
+ CheckImpact[x][y] && !IS_FREE(x, y + 1)) ||
+#else
+ (game.engine_version >= VERSION_IDENT(3,1,0,0) &&
+ CheckCollision[x][y] && !IS_FREE(x, y + 1)) ||
+#endif
+ (game.engine_version >= VERSION_IDENT(3,0,7,0) &&
+ CAN_FALL(element) && WasJustFalling[x][y] &&
+ (Feld[x][y + 1] == EL_BLOCKED || IS_PLAYER(x, y + 1))) ||
+
+ (game.engine_version < VERSION_IDENT(2,2,0,7) &&
+ CAN_FALL(element) && WasJustMoving[x][y] && !Pushed[x][y + 1] &&
+ (Feld[x][y + 1] == EL_BLOCKED)))
+ {
+ /* this is needed for a special case not covered by calling "Impact()"
+ from "ContinueMoving()": if an element moves to a tile directly below
+ another element which was just falling on that tile (which was empty
+ in the previous frame), the falling element above would just stop
+ instead of smashing the element below (in previous version, the above
+ element was just checked for "moving" instead of "falling", resulting
+ in incorrect smashes caused by horizontal movement of the above
+ element; also, the case of the player being the element to smash was
+ simply not covered here... :-/ ) */
+
+ CheckCollision[x][y] = 0;
+ CheckImpact[x][y] = 0;
+
+ Impact(x, y);
+ }
+ else if (IS_FREE(x, y + 1) && element == EL_SPRING && level.use_spring_bug)
+ {
+ if (MovDir[x][y] == MV_NONE)
+ {
+ InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+ }
+ }
+ else if (IS_FREE(x, y + 1) || Feld[x][y + 1] == EL_DIAMOND_BREAKING)
+ {
+ if (WasJustFalling[x][y]) /* prevent animation from being restarted */
+ MovDir[x][y] = MV_DOWN;
+
+ InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+ }
+ else if (element == EL_AMOEBA_DROP)
+ {
+ Feld[x][y] = EL_AMOEBA_GROWING;
+ Store[x][y] = EL_AMOEBA_WET;
+ }
+ else if (((IS_SLIPPERY(Feld[x][y + 1]) && !IS_PLAYER(x, y + 1)) ||
+ (IS_EM_SLIPPERY_WALL(Feld[x][y + 1]) && IS_GEM(element))) &&
+ !IS_FALLING(x, y + 1) && !WasJustMoving[x][y + 1] &&
+ element != EL_DX_SUPABOMB && element != EL_SP_DISK_ORANGE)
+ {
+ boolean can_fall_left = (x > 0 && IS_FREE(x - 1, y) &&
+ (IS_FREE(x - 1, y + 1) ||
+ Feld[x - 1][y + 1] == EL_ACID));
+ boolean can_fall_right = (x < lev_fieldx - 1 && IS_FREE(x + 1, y) &&
+ (IS_FREE(x + 1, y + 1) ||
+ Feld[x + 1][y + 1] == EL_ACID));
+ boolean can_fall_any = (can_fall_left || can_fall_right);
+ boolean can_fall_both = (can_fall_left && can_fall_right);
+ int slippery_type = element_info[Feld[x][y + 1]].slippery_type;
+
+#if USE_NEW_ALL_SLIPPERY
+ if (can_fall_any && slippery_type != SLIPPERY_ANY_RANDOM)
+ {
+ if (slippery_type == SLIPPERY_ANY_LEFT_RIGHT && can_fall_both)
+ can_fall_right = FALSE;
+ else if (slippery_type == SLIPPERY_ANY_RIGHT_LEFT && can_fall_both)
+ can_fall_left = FALSE;
+ else if (slippery_type == SLIPPERY_ONLY_LEFT)
+ can_fall_right = FALSE;
+ else if (slippery_type == SLIPPERY_ONLY_RIGHT)
+ can_fall_left = FALSE;
+
+ can_fall_any = (can_fall_left || can_fall_right);
+ can_fall_both = FALSE;
+ }
+#else
+ if (can_fall_any && IS_CUSTOM_ELEMENT(Feld[x][y + 1]))
+ {
+ if (slippery_type == SLIPPERY_ONLY_LEFT)
+ can_fall_right = FALSE;
+ else if (slippery_type == SLIPPERY_ONLY_RIGHT)
+ can_fall_left = FALSE;
+ else if (slippery_type == SLIPPERY_ANY_LEFT_RIGHT && can_fall_both)
+ can_fall_right = FALSE;
+ else if (slippery_type == SLIPPERY_ANY_RIGHT_LEFT && can_fall_both)
+ can_fall_left = FALSE;
+
+ can_fall_any = (can_fall_left || can_fall_right);
+ can_fall_both = (can_fall_left && can_fall_right);
+ }
+#endif
+
+#if USE_NEW_ALL_SLIPPERY
+#else
+#if USE_NEW_SP_SLIPPERY
+ /* !!! better use the same properties as for custom elements here !!! */
+ else if (game.engine_version >= VERSION_IDENT(3,1,1,0) &&
+ can_fall_both && IS_SP_ELEMENT(Feld[x][y + 1]))
+ {
+ can_fall_right = FALSE; /* slip down on left side */
+ can_fall_both = FALSE;
+ }
+#endif
+#endif
+
+#if USE_NEW_ALL_SLIPPERY
+ if (can_fall_both)
+ {
+ if (element == EL_BD_ROCK || element == EL_BD_DIAMOND)
+ can_fall_right = FALSE; /* slip down on left side */
+ else
+ can_fall_left = !(can_fall_right = RND(2));
+
+ can_fall_both = FALSE;
+ }
+#else
+ if (can_fall_both)
+ {
+ if (game.emulation == EMU_BOULDERDASH ||
+ element == EL_BD_ROCK || element == EL_BD_DIAMOND)
+ can_fall_right = FALSE; /* slip down on left side */
+ else
+ can_fall_left = !(can_fall_right = RND(2));
+
+ can_fall_both = FALSE;
+ }
+#endif
+
+ if (can_fall_any)
+ {
+ /* if not determined otherwise, prefer left side for slipping down */
+ InitMovingField(x, y, can_fall_left ? MV_LEFT : MV_RIGHT);
+ started_moving = TRUE;
+ }
+ }
+#if 0
+ else if (IS_BELT_ACTIVE(Feld[x][y + 1]) && !CAN_MOVE(element))
+#else
+ else if (IS_BELT_ACTIVE(Feld[x][y + 1]))
+#endif
+ {
+ boolean left_is_free = (x > 0 && IS_FREE(x - 1, y));
+ boolean right_is_free = (x < lev_fieldx - 1 && IS_FREE(x + 1, y));
+ int belt_nr = getBeltNrFromBeltActiveElement(Feld[x][y + 1]);
+ int belt_dir = game.belt_dir[belt_nr];
+
+ if ((belt_dir == MV_LEFT && left_is_free) ||
+ (belt_dir == MV_RIGHT && right_is_free))
+ {
+ int nextx = (belt_dir == MV_LEFT ? x - 1 : x + 1);
+
+ InitMovingField(x, y, belt_dir);
+ started_moving = TRUE;
+
+ Pushed[x][y] = TRUE;
+ Pushed[nextx][y] = TRUE;
+
+ GfxAction[x][y] = ACTION_DEFAULT;
+ }
+ else
+ {
+ MovDir[x][y] = 0; /* if element was moving, stop it */
+ }
+ }
+ }
+
+ /* not "else if" because of elements that can fall and move (EL_SPRING) */
+#if 0
+ if (CAN_MOVE(element) && !started_moving && MovDir[x][y] != MV_NONE)
+#else
+ if (CAN_MOVE(element) && !started_moving)
+#endif
+ {
+ int move_pattern = element_info[element].move_pattern;
+ int newx, newy;
+
+#if 0
+#if DEBUG
+ if (MovDir[x][y] == MV_NONE)
+ {
+ printf("StartMoving(): %d,%d: element %d ['%s'] not moving\n",
+ x, y, element, element_info[element].token_name);
+ printf("StartMoving(): This should never happen!\n");
+ }
+#endif
+#endif
+
+ Moving2Blocked(x, y, &newx, &newy);
+
+ if (IS_PUSHABLE(element) && JustBeingPushed(x, y))
+ return;
+
+ if (game.engine_version >= VERSION_IDENT(3,1,0,0) &&
+ CheckCollision[x][y] && !IN_LEV_FIELD_AND_IS_FREE(newx, newy))
+ {
+ WasJustMoving[x][y] = 0;
+ CheckCollision[x][y] = 0;
+
+ TestIfElementHitsCustomElement(x, y, MovDir[x][y]);
+
+ if (Feld[x][y] != element) /* element has changed */
+ return;
+ }
+
+ if (!MovDelay[x][y]) /* start new movement phase */
+ {
+ /* all objects that can change their move direction after each step
+ (YAMYAM, DARK_YAMYAM and PACMAN go straight until they hit a wall */
+
+ if (element != EL_YAMYAM &&
+ element != EL_DARK_YAMYAM &&
+ element != EL_PACMAN &&
+ !(move_pattern & MV_ANY_DIRECTION) &&
+ move_pattern != MV_TURNING_LEFT &&
+ move_pattern != MV_TURNING_RIGHT &&
+ move_pattern != MV_TURNING_LEFT_RIGHT &&
+ move_pattern != MV_TURNING_RIGHT_LEFT &&
+ move_pattern != MV_TURNING_RANDOM)
+ {
+ TurnRound(x, y);
+
+ if (MovDelay[x][y] && (element == EL_BUG ||
+ element == EL_SPACESHIP ||
+ element == EL_SP_SNIKSNAK ||
+ element == EL_SP_ELECTRON ||
+ element == EL_MOLE))
+ DrawLevelField(x, y);
+ }
+ }
+
+ if (MovDelay[x][y]) /* wait some time before next movement */
+ {
+ MovDelay[x][y]--;
+
+ if (element == EL_ROBOT ||
+ element == EL_YAMYAM ||
+ element == EL_DARK_YAMYAM)
+ {
+ DrawLevelElementAnimationIfNeeded(x, y, element);
+ PlayLevelSoundAction(x, y, ACTION_WAITING);
+ }
+ else if (element == EL_SP_ELECTRON)
+ DrawLevelElementAnimationIfNeeded(x, y, element);
+ else if (element == EL_DRAGON)
+ {
+ int i;
+ int dir = MovDir[x][y];
+ int dx = (dir == MV_LEFT ? -1 : dir == MV_RIGHT ? +1 : 0);
+ int dy = (dir == MV_UP ? -1 : dir == MV_DOWN ? +1 : 0);
+ int graphic = (dir == MV_LEFT ? IMG_FLAMES_1_LEFT :
+ dir == MV_RIGHT ? IMG_FLAMES_1_RIGHT :
+ dir == MV_UP ? IMG_FLAMES_1_UP :
+ dir == MV_DOWN ? IMG_FLAMES_1_DOWN : IMG_EMPTY);
+ int frame = getGraphicAnimationFrame(graphic, GfxFrame[x][y]);
+
+ GfxAction[x][y] = ACTION_ATTACKING;
+
+ if (IS_PLAYER(x, y))
+ DrawPlayerField(x, y);
+ else
+ DrawLevelField(x, y);
+
+ PlayLevelSoundActionIfLoop(x, y, ACTION_ATTACKING);
+
+ for (i = 1; i <= 3; i++)
+ {
+ int xx = x + i * dx;
+ int yy = y + i * dy;
+ int sx = SCREENX(xx);
+ int sy = SCREENY(yy);
+ int flame_graphic = graphic + (i - 1);
+
+ if (!IN_LEV_FIELD(xx, yy) || IS_DRAGONFIRE_PROOF(Feld[xx][yy]))
+ break;
+
+ if (MovDelay[x][y])
+ {
+ int flamed = MovingOrBlocked2Element(xx, yy);
+
+ /* !!! */
+#if 0
+ if (IS_CLASSIC_ENEMY(flamed) || CAN_EXPLODE_BY_DRAGONFIRE(flamed))
+ Bang(xx, yy);
+ else if (IS_MOVING(xx, yy) || IS_BLOCKED(xx, yy))
+ RemoveMovingField(xx, yy);
+ else
+ RemoveField(xx, yy);
+#else
+ if (IS_CLASSIC_ENEMY(flamed) || CAN_EXPLODE_BY_DRAGONFIRE(flamed))
+ Bang(xx, yy);
+ else
+ RemoveMovingField(xx, yy);
+#endif
+
+ ChangeDelay[xx][yy] = 0;
+
+ Feld[xx][yy] = EL_FLAMES;
+
+ if (IN_SCR_FIELD(sx, sy))
+ {
+ DrawLevelFieldCrumbledSand(xx, yy);
+ DrawGraphic(sx, sy, flame_graphic, frame);
+ }
+ }
+ else
+ {
+ if (Feld[xx][yy] == EL_FLAMES)
+ Feld[xx][yy] = EL_EMPTY;
+ DrawLevelField(xx, yy);
+ }
+ }
+ }
+
+ if (MovDelay[x][y]) /* element still has to wait some time */
+ {
+ PlayLevelSoundAction(x, y, ACTION_WAITING);
+
+ return;
+ }
+ }
+
+ /* now make next step */
+
+ Moving2Blocked(x, y, &newx, &newy); /* get next screen position */
+
+ if (DONT_COLLIDE_WITH(element) &&
+ IN_LEV_FIELD(newx, newy) && IS_PLAYER(newx, newy) &&
+ !PLAYER_ENEMY_PROTECTED(newx, newy))
+ {
+ TestIfBadThingRunsIntoPlayer(x, y, MovDir[x][y]);
+
+ return;
+ }
+
+ else if (CAN_MOVE_INTO_ACID(element) &&
+ IN_LEV_FIELD(newx, newy) && Feld[newx][newy] == EL_ACID &&
+ !IS_MV_DIAGONAL(MovDir[x][y]) &&
+ (MovDir[x][y] == MV_DOWN ||
+ game.engine_version >= VERSION_IDENT(3,1,0,0)))
+ {
+ SplashAcid(newx, newy);
+ Store[x][y] = EL_ACID;
+ }
+ else if (element == EL_PENGUIN && IN_LEV_FIELD(newx, newy))
+ {
+ if (Feld[newx][newy] == EL_EXIT_OPEN ||
+ Feld[newx][newy] == EL_EM_EXIT_OPEN ||
+ Feld[newx][newy] == EL_STEEL_EXIT_OPEN ||
+ Feld[newx][newy] == EL_EM_STEEL_EXIT_OPEN)
+ {
+ RemoveField(x, y);
+ DrawLevelField(x, y);
+
+ PlayLevelSound(newx, newy, SND_PENGUIN_PASSING);
+ if (IN_SCR_FIELD(SCREENX(newx), SCREENY(newy)))
+ DrawGraphicThruMask(SCREENX(newx),SCREENY(newy), el2img(element), 0);
+
+ local_player->friends_still_needed--;
+ if (!local_player->friends_still_needed &&
+ !local_player->GameOver && AllPlayersGone)
+ PlayerWins(local_player);
+
+ return;
+ }
+ else if (IS_FOOD_PENGUIN(Feld[newx][newy]))
+ {
+ if (DigField(local_player, x, y, newx, newy, 0,0, DF_DIG) == MP_MOVING)
+ DrawLevelField(newx, newy);
+ else
+ GfxDir[x][y] = MovDir[x][y] = MV_NONE;
+ }
+ else if (!IS_FREE(newx, newy))
+ {
+ GfxAction[x][y] = ACTION_WAITING;
+
+ if (IS_PLAYER(x, y))
+ DrawPlayerField(x, y);
+ else
+ DrawLevelField(x, y);
+
+ return;
+ }
+ }
+ else if (element == EL_PIG && IN_LEV_FIELD(newx, newy))
+ {
+ if (IS_FOOD_PIG(Feld[newx][newy]))
+ {
+ if (IS_MOVING(newx, newy))
+ RemoveMovingField(newx, newy);
+ else
+ {
+ Feld[newx][newy] = EL_EMPTY;
+ DrawLevelField(newx, newy);
+ }
+
+ PlayLevelSound(x, y, SND_PIG_DIGGING);
+ }
+ else if (!IS_FREE(newx, newy))
+ {
+ if (IS_PLAYER(x, y))
+ DrawPlayerField(x, y);
+ else
+ DrawLevelField(x, y);
+
+ return;
+ }
+ }
+ else if (element == EL_EMC_ANDROID && IN_LEV_FIELD(newx, newy))
+ {
+ if (Store[x][y] != EL_EMPTY)
+ {
+ boolean can_clone = FALSE;
+ int xx, yy;
+
+ /* check if element to clone is still there */
+ for (yy = y - 1; yy <= y + 1; yy++) for (xx = x - 1; xx <= x + 1; xx++)
+ {
+ if (IN_LEV_FIELD(xx, yy) && Feld[xx][yy] == Store[x][y])
+ {
+ can_clone = TRUE;
+
+ break;
+ }
+ }
+
+ /* cannot clone or target field not free anymore -- do not clone */
+ if (!can_clone || !ANDROID_CAN_ENTER_FIELD(element, newx, newy))
+ Store[x][y] = EL_EMPTY;
+ }
+
+ if (ANDROID_CAN_ENTER_FIELD(element, newx, newy))
+ {
+ if (IS_MV_DIAGONAL(MovDir[x][y]))
+ {
+ int diagonal_move_dir = MovDir[x][y];
+ int stored = Store[x][y];
+ int change_delay = 8;
+ int graphic;
+
+ /* android is moving diagonally */
+
+ CreateField(x, y, EL_DIAGONAL_SHRINKING);
+
+ Store[x][y] = (stored == EL_ACID ? EL_EMPTY : stored);
+ GfxElement[x][y] = EL_EMC_ANDROID;
+ GfxAction[x][y] = ACTION_SHRINKING;
+ GfxDir[x][y] = diagonal_move_dir;
+ ChangeDelay[x][y] = change_delay;
+
+ graphic = el_act_dir2img(GfxElement[x][y], GfxAction[x][y],
+ GfxDir[x][y]);
+
+ DrawLevelGraphicAnimation(x, y, graphic);
+ PlayLevelSoundAction(x, y, ACTION_SHRINKING);
+
+ if (Feld[newx][newy] == EL_ACID)
+ {
+ SplashAcid(newx, newy);
+
+ return;
+ }
+
+ CreateField(newx, newy, EL_DIAGONAL_GROWING);
+
+ Store[newx][newy] = EL_EMC_ANDROID;
+ GfxElement[newx][newy] = EL_EMC_ANDROID;
+ GfxAction[newx][newy] = ACTION_GROWING;
+ GfxDir[newx][newy] = diagonal_move_dir;
+ ChangeDelay[newx][newy] = change_delay;
+
+ graphic = el_act_dir2img(GfxElement[newx][newy],
+ GfxAction[newx][newy], GfxDir[newx][newy]);
+
+ DrawLevelGraphicAnimation(newx, newy, graphic);
+ PlayLevelSoundAction(newx, newy, ACTION_GROWING);
+
+ return;
+ }
+ else
+ {
+ Feld[newx][newy] = EL_EMPTY;
+ DrawLevelField(newx, newy);
+
+ PlayLevelSoundAction(x, y, ACTION_DIGGING);
+ }
+ }
+ else if (!IS_FREE(newx, newy))
+ {
+#if 0
+ if (IS_PLAYER(x, y))
+ DrawPlayerField(x, y);
+ else
+ DrawLevelField(x, y);
+#endif
+
+ return;
+ }
+ }
+ else if (IS_CUSTOM_ELEMENT(element) &&
+ CUSTOM_ELEMENT_CAN_ENTER_FIELD(element, newx, newy))
+ {
+ int new_element = Feld[newx][newy];
+
+ if (!IS_FREE(newx, newy))
+ {
+ int action = (IS_DIGGABLE(new_element) ? ACTION_DIGGING :
+ IS_COLLECTIBLE(new_element) ? ACTION_COLLECTING :
+ ACTION_BREAKING);
+
+ /* no element can dig solid indestructible elements */
+ if (IS_INDESTRUCTIBLE(new_element) &&
+ !IS_DIGGABLE(new_element) &&
+ !IS_COLLECTIBLE(new_element))
+ return;
+
+ if (AmoebaNr[newx][newy] &&
+ (new_element == EL_AMOEBA_FULL ||
+ new_element == EL_BD_AMOEBA ||
+ new_element == EL_AMOEBA_GROWING))
+ {
+ AmoebaCnt[AmoebaNr[newx][newy]]--;
+ AmoebaCnt2[AmoebaNr[newx][newy]]--;
+ }
+
+ if (IS_MOVING(newx, newy))
+ RemoveMovingField(newx, newy);
+ else
+ {
+ RemoveField(newx, newy);
+ DrawLevelField(newx, newy);
+ }
+
+ /* if digged element was about to explode, prevent the explosion */
+ ExplodeField[newx][newy] = EX_TYPE_NONE;
+
+ PlayLevelSoundAction(x, y, action);
+ }
+
+ Store[newx][newy] = EL_EMPTY;
+#if 1
+ /* this makes it possible to leave the removed element again */
+ if (IS_EQUAL_OR_IN_GROUP(new_element, MOVE_ENTER_EL(element)))
+ Store[newx][newy] = new_element;
+#else
+ if (IS_EQUAL_OR_IN_GROUP(new_element, MOVE_ENTER_EL(element)))
+ {
+ int move_leave_element = element_info[element].move_leave_element;
+
+ /* this makes it possible to leave the removed element again */
+ Store[newx][newy] = (move_leave_element == EL_TRIGGER_ELEMENT ?
+ new_element : move_leave_element);
+ }
+#endif
+
+ if (move_pattern & MV_MAZE_RUNNER_STYLE)
+ {
+ RunnerVisit[x][y] = FrameCounter;
+ PlayerVisit[x][y] /= 8; /* expire player visit path */
+ }
+ }
+ else if (element == EL_DRAGON && IN_LEV_FIELD(newx, newy))
+ {
+ if (!IS_FREE(newx, newy))
+ {
+ if (IS_PLAYER(x, y))
+ DrawPlayerField(x, y);
+ else
+ DrawLevelField(x, y);
+
+ return;
+ }
+ else
+ {
+ boolean wanna_flame = !RND(10);
+ int dx = newx - x, dy = newy - y;
+ int newx1 = newx + 1 * dx, newy1 = newy + 1 * dy;
+ int newx2 = newx + 2 * dx, newy2 = newy + 2 * dy;
+ int element1 = (IN_LEV_FIELD(newx1, newy1) ?
+ MovingOrBlocked2Element(newx1, newy1) : EL_STEELWALL);
+ int element2 = (IN_LEV_FIELD(newx2, newy2) ?
+ MovingOrBlocked2Element(newx2, newy2) : EL_STEELWALL);
+
+ if ((wanna_flame ||
+ IS_CLASSIC_ENEMY(element1) ||
+ IS_CLASSIC_ENEMY(element2)) &&
+ element1 != EL_DRAGON && element2 != EL_DRAGON &&
+ element1 != EL_FLAMES && element2 != EL_FLAMES)
+ {
+ ResetGfxAnimation(x, y);
+ GfxAction[x][y] = ACTION_ATTACKING;
+
+ if (IS_PLAYER(x, y))
+ DrawPlayerField(x, y);
+ else
+ DrawLevelField(x, y);
+
+ PlayLevelSound(x, y, SND_DRAGON_ATTACKING);
+
+ MovDelay[x][y] = 50;
+
+ /* !!! */
+#if 0
+ RemoveField(newx, newy);
+#endif
+ Feld[newx][newy] = EL_FLAMES;
+ if (IN_LEV_FIELD(newx1, newy1) && Feld[newx1][newy1] == EL_EMPTY)
+ {
+#if 0
+ RemoveField(newx1, newy1);
+#endif
+ Feld[newx1][newy1] = EL_FLAMES;
+ }
+ if (IN_LEV_FIELD(newx2, newy2) && Feld[newx2][newy2] == EL_EMPTY)
+ {
+#if 0
+ RemoveField(newx2, newy2);
+#endif
+ Feld[newx2][newy2] = EL_FLAMES;
+ }
+
+ return;
+ }
+ }
+ }
+ else if (element == EL_YAMYAM && IN_LEV_FIELD(newx, newy) &&
+ Feld[newx][newy] == EL_DIAMOND)
+ {
+ if (IS_MOVING(newx, newy))
+ RemoveMovingField(newx, newy);
+ else
+ {
+ Feld[newx][newy] = EL_EMPTY;
+ DrawLevelField(newx, newy);
+ }
+
+ PlayLevelSound(x, y, SND_YAMYAM_DIGGING);
+ }
+ else if (element == EL_DARK_YAMYAM && IN_LEV_FIELD(newx, newy) &&
+ IS_FOOD_DARK_YAMYAM(Feld[newx][newy]))
+ {
+ if (AmoebaNr[newx][newy])
+ {
+ AmoebaCnt2[AmoebaNr[newx][newy]]--;
+ if (Feld[newx][newy] == EL_AMOEBA_FULL ||
+ Feld[newx][newy] == EL_BD_AMOEBA)
+ AmoebaCnt[AmoebaNr[newx][newy]]--;
+ }
+
+#if 0
+ /* !!! test !!! */
+ if (IS_MOVING(newx, newy) || IS_BLOCKED(newx, newy))
+ {
+ RemoveMovingField(newx, newy);
+ }
+#else
+ if (IS_MOVING(newx, newy))
+ {
+ RemoveMovingField(newx, newy);
+ }
+#endif
+ else
+ {
+ Feld[newx][newy] = EL_EMPTY;
+ DrawLevelField(newx, newy);
+ }
+
+ PlayLevelSound(x, y, SND_DARK_YAMYAM_DIGGING);
+ }
+ else if ((element == EL_PACMAN || element == EL_MOLE)
+ && IN_LEV_FIELD(newx, newy) && IS_AMOEBOID(Feld[newx][newy]))
+ {
+ if (AmoebaNr[newx][newy])
+ {
+ AmoebaCnt2[AmoebaNr[newx][newy]]--;
+ if (Feld[newx][newy] == EL_AMOEBA_FULL ||
+ Feld[newx][newy] == EL_BD_AMOEBA)
+ AmoebaCnt[AmoebaNr[newx][newy]]--;
+ }
+
+ if (element == EL_MOLE)
+ {
+ Feld[newx][newy] = EL_AMOEBA_SHRINKING;
+ PlayLevelSound(x, y, SND_MOLE_DIGGING);
+
+ ResetGfxAnimation(x, y);
+ GfxAction[x][y] = ACTION_DIGGING;
+ DrawLevelField(x, y);
+
+ MovDelay[newx][newy] = 0; /* start amoeba shrinking delay */
+
+ return; /* wait for shrinking amoeba */
+ }
+ else /* element == EL_PACMAN */
+ {
+ Feld[newx][newy] = EL_EMPTY;
+ DrawLevelField(newx, newy);
+ PlayLevelSound(x, y, SND_PACMAN_DIGGING);
+ }
+ }
+ else if (element == EL_MOLE && IN_LEV_FIELD(newx, newy) &&
+ (Feld[newx][newy] == EL_AMOEBA_SHRINKING ||
+ (Feld[newx][newy] == EL_EMPTY && Stop[newx][newy])))
+ {
+ /* wait for shrinking amoeba to completely disappear */
+ return;
+ }
+ else if (!IN_LEV_FIELD(newx, newy) || !IS_FREE(newx, newy))
+ {
+ /* object was running against a wall */
+
+ TurnRound(x, y);
+
+#if 0
+ /* !!! NEW "CE_BLOCKED" STUFF !!! -- DOES NOT WORK YET... !!! */
+ if (move_pattern & MV_ANY_DIRECTION &&
+ move_pattern == MovDir[x][y])
+ {
+ int blocking_element =
+ (IN_LEV_FIELD(newx, newy) ? Feld[newx][newy] : BorderElement);
+
+ CheckElementChangeBySide(x, y, element, blocking_element, CE_BLOCKED,
+ MovDir[x][y]);
+
+ element = Feld[x][y]; /* element might have changed */
+ }
+#endif
+
+ if (GFX_ELEMENT(element) != EL_SAND) /* !!! FIX THIS (crumble) !!! */
+ DrawLevelElementAnimation(x, y, element);
+
+ if (DONT_TOUCH(element))
+ TestIfBadThingTouchesPlayer(x, y);
+
+ return;
+ }
+
+ InitMovingField(x, y, MovDir[x][y]);
+
+ PlayLevelSoundAction(x, y, ACTION_MOVING);
+ }
+
+ if (MovDir[x][y])
+ ContinueMoving(x, y);
+}
+
+void ContinueMoving(int x, int y)
+{
+ int element = Feld[x][y];
+ struct ElementInfo *ei = &element_info[element];
+ int direction = MovDir[x][y];
+ int dx = (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0);
+ int dy = (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0);
+ int newx = x + dx, newy = y + dy;
+ int stored = Store[x][y];
+ int stored_new = Store[newx][newy];
+ boolean pushed_by_player = (Pushed[x][y] && IS_PLAYER(x, y));
+ boolean pushed_by_conveyor = (Pushed[x][y] && !IS_PLAYER(x, y));
+ boolean last_line = (newy == lev_fieldy - 1);
+
+ MovPos[x][y] += getElementMoveStepsize(x, y);
+
+ if (pushed_by_player) /* special case: moving object pushed by player */
+ MovPos[x][y] = SIGN(MovPos[x][y]) * (TILEX - ABS(PLAYERINFO(x,y)->MovPos));
+
+ if (ABS(MovPos[x][y]) < TILEX)
+ {
+#if 0
+ int ee = Feld[x][y];
+ int gg = el_act_dir2img(element, GfxAction[x][y], GfxDir[x][y]);
+ int ff = getGraphicAnimationFrame(gg, GfxFrame[x][y]);
+
+ printf("::: %d.%d: moving %d ... [%d, %d, %d] [%d, %d, %d]\n",
+ x, y, ABS(MovPos[x][y]),
+ ee, gg, ff,
+ GfxAction[x][y], GfxDir[x][y], GfxFrame[x][y]);
+#endif
+
+ DrawLevelField(x, y);
+
+ return; /* element is still moving */
+ }
+
+ /* element reached destination field */
+
+ Feld[x][y] = EL_EMPTY;
+ Feld[newx][newy] = element;
+ MovPos[x][y] = 0; /* force "not moving" for "crumbled sand" */
+
+ if (Store[x][y] == EL_ACID) /* element is moving into acid pool */
+ {
+ element = Feld[newx][newy] = EL_ACID;
+ }
+ else if (element == EL_MOLE)
+ {
+ Feld[x][y] = EL_SAND;
+
+ DrawLevelFieldCrumbledSandNeighbours(x, y);
+ }
+ else if (element == EL_QUICKSAND_FILLING)
+ {
+ element = Feld[newx][newy] = get_next_element(element);
+ Store[newx][newy] = Store[x][y];
+ }
+ else if (element == EL_QUICKSAND_EMPTYING)
+ {
+ Feld[x][y] = get_next_element(element);
+ element = Feld[newx][newy] = Store[x][y];
+ }
+ else if (element == EL_QUICKSAND_FAST_FILLING)
+ {
+ element = Feld[newx][newy] = get_next_element(element);
+ Store[newx][newy] = Store[x][y];
+ }
+ else if (element == EL_QUICKSAND_FAST_EMPTYING)
+ {
+ Feld[x][y] = get_next_element(element);
+ element = Feld[newx][newy] = Store[x][y];
+ }
+ else if (element == EL_MAGIC_WALL_FILLING)
+ {
+ element = Feld[newx][newy] = get_next_element(element);
+ if (!game.magic_wall_active)
+ element = Feld[newx][newy] = EL_MAGIC_WALL_DEAD;
+ Store[newx][newy] = Store[x][y];
+ }
+ else if (element == EL_MAGIC_WALL_EMPTYING)
+ {
+ Feld[x][y] = get_next_element(element);
+ if (!game.magic_wall_active)
+ Feld[x][y] = EL_MAGIC_WALL_DEAD;
+ element = Feld[newx][newy] = Store[x][y];
+
+#if USE_NEW_CUSTOM_VALUE
+ InitField(newx, newy, FALSE);
+#endif
+ }
+ else if (element == EL_BD_MAGIC_WALL_FILLING)
+ {
+ element = Feld[newx][newy] = get_next_element(element);
+ if (!game.magic_wall_active)
+ element = Feld[newx][newy] = EL_BD_MAGIC_WALL_DEAD;
+ Store[newx][newy] = Store[x][y];
+ }
+ else if (element == EL_BD_MAGIC_WALL_EMPTYING)
+ {
+ Feld[x][y] = get_next_element(element);
+ if (!game.magic_wall_active)
+ Feld[x][y] = EL_BD_MAGIC_WALL_DEAD;
+ element = Feld[newx][newy] = Store[x][y];
+
+#if USE_NEW_CUSTOM_VALUE
+ InitField(newx, newy, FALSE);
+#endif
+ }
+ else if (element == EL_DC_MAGIC_WALL_FILLING)
+ {
+ element = Feld[newx][newy] = get_next_element(element);
+ if (!game.magic_wall_active)
+ element = Feld[newx][newy] = EL_DC_MAGIC_WALL_DEAD;
+ Store[newx][newy] = Store[x][y];
+ }
+ else if (element == EL_DC_MAGIC_WALL_EMPTYING)
+ {
+ Feld[x][y] = get_next_element(element);
+ if (!game.magic_wall_active)
+ Feld[x][y] = EL_DC_MAGIC_WALL_DEAD;
+ element = Feld[newx][newy] = Store[x][y];
+
+#if USE_NEW_CUSTOM_VALUE
+ InitField(newx, newy, FALSE);
+#endif
+ }
+ else if (element == EL_AMOEBA_DROPPING)
+ {
+ Feld[x][y] = get_next_element(element);
+ element = Feld[newx][newy] = Store[x][y];
+ }
+ else if (element == EL_SOKOBAN_OBJECT)
+ {
+ if (Back[x][y])
+ Feld[x][y] = Back[x][y];
+
+ if (Back[newx][newy])
+ Feld[newx][newy] = EL_SOKOBAN_FIELD_FULL;
+
+ Back[x][y] = Back[newx][newy] = 0;
+ }
+
+ Store[x][y] = EL_EMPTY;
+ MovPos[x][y] = 0;
+ MovDir[x][y] = 0;
+ MovDelay[x][y] = 0;
+
+ MovDelay[newx][newy] = 0;
+
+ if (CAN_CHANGE_OR_HAS_ACTION(element))
+ {
+ /* copy element change control values to new field */
+ ChangeDelay[newx][newy] = ChangeDelay[x][y];
+ ChangePage[newx][newy] = ChangePage[x][y];
+ ChangeCount[newx][newy] = ChangeCount[x][y];
+ ChangeEvent[newx][newy] = ChangeEvent[x][y];
+ }
+
+#if USE_NEW_CUSTOM_VALUE
+ CustomValue[newx][newy] = CustomValue[x][y];
+#endif
+
+ ChangeDelay[x][y] = 0;
+ ChangePage[x][y] = -1;
+ ChangeCount[x][y] = 0;
+ ChangeEvent[x][y] = -1;
+
+#if USE_NEW_CUSTOM_VALUE
+ CustomValue[x][y] = 0;
+#endif
+
+ /* copy animation control values to new field */
+ GfxFrame[newx][newy] = GfxFrame[x][y];
+ GfxRandom[newx][newy] = GfxRandom[x][y]; /* keep same random value */
+ GfxAction[newx][newy] = GfxAction[x][y]; /* keep action one frame */
+ GfxDir[newx][newy] = GfxDir[x][y]; /* keep element direction */
+
+ Pushed[x][y] = Pushed[newx][newy] = FALSE;
+
+ /* some elements can leave other elements behind after moving */
+#if 1
+ if (ei->move_leave_element != EL_EMPTY &&
+ (ei->move_leave_type == LEAVE_TYPE_UNLIMITED || stored != EL_EMPTY) &&
+ (!IS_PLAYER(x, y) || IS_WALKABLE(ei->move_leave_element)))
+#else
+ if (IS_CUSTOM_ELEMENT(element) && ei->move_leave_element != EL_EMPTY &&
+ (ei->move_leave_type == LEAVE_TYPE_UNLIMITED || stored != EL_EMPTY) &&
+ (!IS_PLAYER(x, y) || IS_WALKABLE(ei->move_leave_element)))
+#endif
+ {
+ int move_leave_element = ei->move_leave_element;
+
+#if 1
+#if 1
+ /* this makes it possible to leave the removed element again */
+ if (ei->move_leave_element == EL_TRIGGER_ELEMENT)
+ move_leave_element = (stored == EL_ACID ? EL_EMPTY : stored);
+#else
+ /* this makes it possible to leave the removed element again */
+ if (ei->move_leave_element == EL_TRIGGER_ELEMENT)
+ move_leave_element = stored;
+#endif
+#else
+ /* this makes it possible to leave the removed element again */
+ if (ei->move_leave_type == LEAVE_TYPE_LIMITED &&
+ ei->move_leave_element == EL_TRIGGER_ELEMENT)
+ move_leave_element = stored;
+#endif
+
+ Feld[x][y] = move_leave_element;
+
+ if (element_info[Feld[x][y]].move_direction_initial == MV_START_PREVIOUS)
+ MovDir[x][y] = direction;
+
+ InitField(x, y, FALSE);
+
+ if (GFX_CRUMBLED(Feld[x][y]))
+ DrawLevelFieldCrumbledSandNeighbours(x, y);
+
+ if (ELEM_IS_PLAYER(move_leave_element))
+ RelocatePlayer(x, y, move_leave_element);
+ }
+
+ /* do this after checking for left-behind element */
+ ResetGfxAnimation(x, y); /* reset animation values for old field */
+
+ if (!CAN_MOVE(element) ||
+ (CAN_FALL(element) && direction == MV_DOWN &&
+ (element == EL_SPRING ||
+ element_info[element].move_pattern == MV_WHEN_PUSHED ||
+ element_info[element].move_pattern == MV_WHEN_DROPPED)))
+ GfxDir[x][y] = MovDir[newx][newy] = 0;
+
+ DrawLevelField(x, y);
+ DrawLevelField(newx, newy);
+
+ Stop[newx][newy] = TRUE; /* ignore this element until the next frame */
+
+ /* prevent pushed element from moving on in pushed direction */
+ if (pushed_by_player && CAN_MOVE(element) &&
+ element_info[element].move_pattern & MV_ANY_DIRECTION &&
+ !(element_info[element].move_pattern & direction))
+ TurnRound(newx, newy);
+
+ /* prevent elements on conveyor belt from moving on in last direction */
+ if (pushed_by_conveyor && CAN_FALL(element) &&
+ direction & MV_HORIZONTAL)
+ MovDir[newx][newy] = 0;
+
+ if (!pushed_by_player)
+ {
+ int nextx = newx + dx, nexty = newy + dy;
+ boolean check_collision_again = IN_LEV_FIELD_AND_IS_FREE(nextx, nexty);
+
+ WasJustMoving[newx][newy] = CHECK_DELAY_MOVING;
+
+ if (CAN_FALL(element) && direction == MV_DOWN)
+ WasJustFalling[newx][newy] = CHECK_DELAY_FALLING;
+
+ if ((!CAN_FALL(element) || direction == MV_DOWN) && check_collision_again)
+ CheckCollision[newx][newy] = CHECK_DELAY_COLLISION;
+
+#if USE_FIX_IMPACT_COLLISION
+ if (CAN_FALL(element) && direction == MV_DOWN && check_collision_again)
+ CheckImpact[newx][newy] = CHECK_DELAY_IMPACT;
+#endif
+ }
+
+ if (DONT_TOUCH(element)) /* object may be nasty to player or others */
+ {
+ TestIfBadThingTouchesPlayer(newx, newy);
+ TestIfBadThingTouchesFriend(newx, newy);
+
+ if (!IS_CUSTOM_ELEMENT(element))
+ TestIfBadThingTouchesOtherBadThing(newx, newy);
+ }
+ else if (element == EL_PENGUIN)
+ TestIfFriendTouchesBadThing(newx, newy);
+
+ /* give the player one last chance (one more frame) to move away */
+ if (CAN_FALL(element) && direction == MV_DOWN &&
+ (last_line || (!IS_FREE(x, newy + 1) &&
+ (!IS_PLAYER(x, newy + 1) ||
+ game.engine_version < VERSION_IDENT(3,1,1,0)))))
+ Impact(x, newy);
+
+ if (pushed_by_player && !game.use_change_when_pushing_bug)
+ {
+ int push_side = MV_DIR_OPPOSITE(direction);
+ struct PlayerInfo *player = PLAYERINFO(x, y);
+
+ CheckElementChangeByPlayer(newx, newy, element, CE_PUSHED_BY_PLAYER,
+ player->index_bit, push_side);
+ CheckTriggeredElementChangeByPlayer(newx,newy, element, CE_PLAYER_PUSHES_X,
+ player->index_bit, push_side);
+ }
+
+ if (element == EL_EMC_ANDROID && pushed_by_player) /* make another move */
+ MovDelay[newx][newy] = 1;
+
+ CheckTriggeredElementChangeBySide(x, y, element, CE_MOVE_OF_X, direction);
+
+ TestIfElementTouchesCustomElement(x, y); /* empty or new element */
+
+#if 0
+ if (ChangePage[newx][newy] != -1) /* delayed change */
+ {
+ int page = ChangePage[newx][newy];
+ struct ElementChangeInfo *change = &ei->change_page[page];
+
+ ChangePage[newx][newy] = -1;
+
+ if (change->can_change)
+ {
+ if (ChangeElement(newx, newy, element, page))
+ {
+ if (change->post_change_function)
+ change->post_change_function(newx, newy);
+ }
+ }
+
+ if (change->has_action)
+ ExecuteCustomElementAction(newx, newy, element, page);
+ }
+#endif
+
+ TestIfElementHitsCustomElement(newx, newy, direction);
+ TestIfPlayerTouchesCustomElement(newx, newy);
+ TestIfElementTouchesCustomElement(newx, newy);
+
+ if (IS_CUSTOM_ELEMENT(element) && ei->move_enter_element != EL_EMPTY &&
+ IS_EQUAL_OR_IN_GROUP(stored_new, ei->move_enter_element))
+ CheckElementChangeBySide(newx, newy, element, stored_new, CE_DIGGING_X,
+ MV_DIR_OPPOSITE(direction));
+}
+
+int AmoebeNachbarNr(int ax, int ay)
+{
+ int i;
+ int element = Feld[ax][ay];
+ int group_nr = 0;
+ static int xy[4][2] =
+ {
+ { 0, -1 },
+ { -1, 0 },
+ { +1, 0 },
+ { 0, +1 }
+ };
+
+ for (i = 0; i < NUM_DIRECTIONS; i++)
+ {
+ int x = ax + xy[i][0];
+ int y = ay + xy[i][1];
+
+ if (!IN_LEV_FIELD(x, y))
+ continue;
+
+ if (Feld[x][y] == element && AmoebaNr[x][y] > 0)
+ group_nr = AmoebaNr[x][y];
+ }
+
+ return group_nr;
+}
+
+void AmoebenVereinigen(int ax, int ay)
+{
+ int i, x, y, xx, yy;
+ int new_group_nr = AmoebaNr[ax][ay];
+ static int xy[4][2] =
+ {
+ { 0, -1 },
+ { -1, 0 },
+ { +1, 0 },
+ { 0, +1 }
+ };
+
+ if (new_group_nr == 0)
+ return;
+
+ for (i = 0; i < NUM_DIRECTIONS; i++)
+ {
+ x = ax + xy[i][0];
+ y = ay + xy[i][1];
+
+ if (!IN_LEV_FIELD(x, y))
+ continue;
+
+ if ((Feld[x][y] == EL_AMOEBA_FULL ||
+ Feld[x][y] == EL_BD_AMOEBA ||
+ Feld[x][y] == EL_AMOEBA_DEAD) &&
+ AmoebaNr[x][y] != new_group_nr)
+ {
+ int old_group_nr = AmoebaNr[x][y];
+
+ if (old_group_nr == 0)
+ return;
+
+ AmoebaCnt[new_group_nr] += AmoebaCnt[old_group_nr];
+ AmoebaCnt[old_group_nr] = 0;
+ AmoebaCnt2[new_group_nr] += AmoebaCnt2[old_group_nr];
+ AmoebaCnt2[old_group_nr] = 0;
+
+ SCAN_PLAYFIELD(xx, yy)
+ {
+ if (AmoebaNr[xx][yy] == old_group_nr)
+ AmoebaNr[xx][yy] = new_group_nr;