+ ScrollLevel(dx, dy);
+ DrawAllPlayers();
+
+ /* scroll in two steps of half tile size to make things smoother */
+ BlitBitmap(drawto_field, window, fx, fy, SXSIZE, SYSIZE, SX, SY);
+ FlushDisplay();
+ Delay(wait_delay_value);
+
+ /* scroll second step to align at full tile size */
+ BackToFront();
+ Delay(wait_delay_value);
+ }
+#endif
+
+ DrawPlayer(player);
+ BackToFront();
+ Delay(wait_delay_value);
+ }
+}
+
+void RelocatePlayer(int jx, int jy, int el_player_raw)
+{
+#if 1
+ int el_player = GET_VALID_PLAYER_ELEMENT(el_player_raw);
+#else
+ int el_player = (el_player_raw == EL_SP_MURPHY ? EL_PLAYER_1 :el_player_raw);
+#endif
+ struct PlayerInfo *player = &stored_player[el_player - EL_PLAYER_1];
+ boolean ffwd_delay = (tape.playing && tape.fast_forward);
+ boolean no_delay = (tape.warp_forward);
+ int frame_delay_value = (ffwd_delay ? FfwdFrameDelay : GameFrameDelay);
+ int wait_delay_value = (no_delay ? 0 : frame_delay_value);
+ int old_jx = player->jx;
+ int old_jy = player->jy;
+ int old_element = Feld[old_jx][old_jy];
+ int element = Feld[jx][jy];
+ boolean player_relocated = (old_jx != jx || old_jy != jy);
+
+ int move_dir_horiz = (jx < old_jx ? MV_LEFT : jx > old_jx ? MV_RIGHT : 0);
+ int move_dir_vert = (jy < old_jy ? MV_UP : jy > old_jy ? MV_DOWN : 0);
+#if 1
+ int enter_side_horiz = MV_DIR_OPPOSITE(move_dir_horiz);
+ int enter_side_vert = MV_DIR_OPPOSITE(move_dir_vert);
+ int leave_side_horiz = move_dir_horiz;
+ int leave_side_vert = move_dir_vert;
+#else
+ static int trigger_sides[4][2] =
+ {
+ /* enter side leave side */
+ { CH_SIDE_RIGHT, CH_SIDE_LEFT }, /* moving left */
+ { CH_SIDE_LEFT, CH_SIDE_RIGHT }, /* moving right */
+ { CH_SIDE_BOTTOM, CH_SIDE_TOP }, /* moving up */
+ { CH_SIDE_TOP, CH_SIDE_BOTTOM } /* moving down */
+ };
+ int enter_side_horiz = trigger_sides[MV_DIR_BIT(move_dir_horiz)][0];
+ int enter_side_vert = trigger_sides[MV_DIR_BIT(move_dir_vert)][0];
+ int leave_side_horiz = trigger_sides[MV_DIR_BIT(move_dir_horiz)][1];
+ int leave_side_vert = trigger_sides[MV_DIR_BIT(move_dir_vert)][1];
+#endif
+ int enter_side = enter_side_horiz | enter_side_vert;
+ int leave_side = leave_side_horiz | leave_side_vert;
+
+ if (player->GameOver) /* do not reanimate dead player */
+ return;
+
+ if (!player_relocated) /* no need to relocate the player */
+ return;
+
+ if (IS_PLAYER(jx, jy)) /* player already placed at new position */
+ {
+ RemoveField(jx, jy); /* temporarily remove newly placed player */
+ DrawLevelField(jx, jy);
+ }
+
+ if (player->present)
+ {
+ while (player->MovPos)
+ {
+ ScrollPlayer(player, SCROLL_GO_ON);
+ ScrollScreen(NULL, SCROLL_GO_ON);
+
+#if USE_NEW_MOVE_DELAY
+ AdvanceFrameAndPlayerCounters(player->index_nr);
+#else
+ FrameCounter++;
+#endif
+
+ DrawPlayer(player);
+
+ BackToFront();
+ Delay(wait_delay_value);
+ }
+
+ DrawPlayer(player); /* needed here only to cleanup last field */
+ DrawLevelField(player->jx, player->jy); /* remove player graphic */
+
+ player->is_moving = FALSE;
+ }
+
+#if 1
+ if (IS_CUSTOM_ELEMENT(old_element))
+ CheckElementChangeByPlayer(old_jx, old_jy, old_element,
+ CE_LEFT_BY_PLAYER,
+ player->index_bit, leave_side);
+
+ CheckTriggeredElementChangeByPlayer(old_jx, old_jy, old_element,
+ CE_OTHER_GETS_LEFT,
+ player->index_bit, leave_side);
+#endif
+
+ Feld[jx][jy] = el_player;
+ InitPlayerField(jx, jy, el_player, TRUE);
+
+ if (!ELEM_IS_PLAYER(element)) /* player may be set on walkable element */
+ {
+ Feld[jx][jy] = element;
+ InitField(jx, jy, FALSE);
+ }
+
+#if 1
+ if (player == local_player) /* only visually relocate local player */
+ DrawRelocatePlayer(player);
+#endif
+
+#if 1
+ TestIfHeroTouchesBadThing(jx, jy);
+ TestIfPlayerTouchesCustomElement(jx, jy);
+#endif
+
+#if 0
+ printf("::: %d,%d: %d\n", jx, jy-1, Changed[jx][jy-1]);
+#endif
+
+#if 0
+#if 0
+ /* needed to allow change of walkable custom element by entering player */
+ if (!(Changed[jx][jy] & CH_EVENT_BIT(CE_ENTERED_BY_PLAYER)))
+ Changed[jx][jy] = 0; /* allow another change (but prevent loop) */
+#else
+ /* needed to allow change of walkable custom element by entering player */
+ Changed[jx][jy] = 0; /* allow another change */
+#endif
+#endif
+
+#if 0
+ printf("::: player entering %d, %d from %s ...\n", jx, jy,
+ enter_side == MV_LEFT ? "left" :
+ enter_side == MV_RIGHT ? "right" :
+ enter_side == MV_UP ? "top" :
+ enter_side == MV_DOWN ? "bottom" : "oops! no idea!");
+#endif
+
+#if 1
+ if (IS_CUSTOM_ELEMENT(element))
+ CheckElementChangeByPlayer(jx, jy, element, CE_ENTERED_BY_PLAYER,
+ player->index_bit, enter_side);
+
+ CheckTriggeredElementChangeByPlayer(jx, jy, element,
+ CE_OTHER_GETS_ENTERED,
+ player->index_bit, enter_side);
+#endif
+}
+
+void Explode(int ex, int ey, int phase, int mode)
+{
+ int x, y;
+#if 0
+ int num_phase = 9;
+#endif
+
+ /* !!! eliminate this variable !!! */
+ int delay = (game.emulation == EMU_SUPAPLEX ? 3 : 2);
+
+#if 1
+ int last_phase;
+#else
+ int last_phase = num_phase * delay;
+ int half_phase = (num_phase / 2) * delay;
+ int first_phase_after_start = EX_PHASE_START + 1;
+#endif
+ int border_element;
+
+ if (game.explosions_delayed)
+ {
+ ExplodeField[ex][ey] = mode;
+ return;
+ }
+
+ if (phase == EX_PHASE_START) /* initialize 'Store[][]' field */
+ {
+ int center_element = Feld[ex][ey];
+
+#if 0
+ printf("::: start explosion %d,%d [%d]\n", ex, ey, FrameCounter);
+#endif
+
+#if 0
+ /* --- This is only really needed (and now handled) in "Impact()". --- */
+ /* do not explode moving elements that left the explode field in time */
+ if (game.engine_version >= VERSION_IDENT(2,2,0,7) &&
+ center_element == EL_EMPTY &&
+ (mode == EX_TYPE_NORMAL || mode == EX_TYPE_CENTER))
+ return;
+#endif
+
+ if (mode == EX_TYPE_NORMAL || mode == EX_TYPE_CENTER)
+ PlayLevelSoundAction(ex, ey, ACTION_EXPLODING);
+
+ /* remove things displayed in background while burning dynamite */
+ if (Back[ex][ey] != EL_EMPTY && !IS_INDESTRUCTIBLE(Back[ex][ey]))
+ Back[ex][ey] = 0;
+
+ if (IS_MOVING(ex, ey) || IS_BLOCKED(ex, ey))
+ {
+ /* put moving element to center field (and let it explode there) */
+ center_element = MovingOrBlocked2Element(ex, ey);
+ RemoveMovingField(ex, ey);
+ Feld[ex][ey] = center_element;
+ }
+
+#if 1
+
+#if 1
+ last_phase = element_info[center_element].explosion_delay + 1;
+#else
+ last_phase = element_info[center_element].explosion_delay;
+#endif
+
+#if 0
+ printf("::: %d -> %d\n", center_element, last_phase);
+#endif
+#endif
+
+ for (y = ey - 1; y <= ey + 1; y++) for (x = ex - 1; x <= ex + 1; x++)
+ {
+ int xx = x - ex + 1;
+ int yy = y - ey + 1;
+ int element;
+
+#if 1
+#if 1
+ if (!IN_LEV_FIELD(x, y) ||
+ (mode & EX_TYPE_SINGLE_TILE && (x != ex || y != ey)) ||
+ (mode == EX_TYPE_CROSS && (x != ex && y != ey)))
+ continue;
+#else
+ if (!IN_LEV_FIELD(x, y) ||
+ (mode != EX_TYPE_NORMAL && (x != ex || y != ey)))
+ continue;
+#endif
+#else
+ if (!IN_LEV_FIELD(x, y) ||
+ ((mode != EX_TYPE_NORMAL ||
+ center_element == EL_AMOEBA_TO_DIAMOND) &&
+ (x != ex || y != ey)))