+ if (stored_player[i].drop_delay > 0)
+ stored_player[i].drop_delay--;
+ }
+}
+
+void GameActions()
+{
+ static unsigned long action_delay = 0;
+ unsigned long action_delay_value;
+ int magic_wall_x = 0, magic_wall_y = 0;
+ int i, x, y, element, graphic;
+ byte *recorded_player_action;
+ byte summarized_player_action = 0;
+#if 1
+ byte tape_action[MAX_PLAYERS];
+#endif
+
+ if (game_status != GAME_MODE_PLAYING)
+ return;
+
+ action_delay_value =
+ (tape.playing && tape.fast_forward ? FfwdFrameDelay : GameFrameDelay);
+
+ if (tape.playing && tape.warp_forward && !tape.pausing)
+ action_delay_value = 0;
+
+ /* ---------- main game synchronization point ---------- */
+
+ WaitUntilDelayReached(&action_delay, action_delay_value);
+
+ if (network_playing && !network_player_action_received)
+ {
+ /*
+#ifdef DEBUG
+ printf("DEBUG: try to get network player actions in time\n");
+#endif
+ */
+
+#if defined(NETWORK_AVALIABLE)
+ /* last chance to get network player actions without main loop delay */
+ HandleNetworking();
+#endif
+
+ if (game_status != GAME_MODE_PLAYING)
+ return;
+
+ if (!network_player_action_received)
+ {
+ /*
+#ifdef DEBUG
+ printf("DEBUG: failed to get network player actions in time\n");
+#endif
+ */
+ return;
+ }
+ }
+
+ if (tape.pausing)
+ return;
+
+#if 0
+ printf("::: getting new tape action [%d]\n", FrameCounter);
+#endif
+
+ recorded_player_action = (tape.playing ? TapePlayAction() : NULL);
+
+#if 1
+ if (recorded_player_action == NULL && tape.pausing)
+ return;
+#endif
+
+#if 0
+ printf("::: %d\n", stored_player[0].action);
+#endif
+
+#if 0
+ if (recorded_player_action != NULL)
+ for (i = 0; i < MAX_PLAYERS; i++)
+ stored_player[i].action = recorded_player_action[i];
+#endif
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ summarized_player_action |= stored_player[i].action;
+
+ if (!network_playing)
+ stored_player[i].effective_action = stored_player[i].action;
+ }
+
+#if defined(NETWORK_AVALIABLE)
+ if (network_playing)
+ SendToServer_MovePlayer(summarized_player_action);
+#endif
+
+ if (!options.network && !setup.team_mode)
+ local_player->effective_action = summarized_player_action;
+
+#if 1
+ if (recorded_player_action != NULL)
+ for (i = 0; i < MAX_PLAYERS; i++)
+ stored_player[i].effective_action = recorded_player_action[i];
+#endif
+
+#if 1
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ tape_action[i] = stored_player[i].effective_action;
+
+ if (tape.recording && tape_action[i] && !tape.player_participates[i])
+ tape.player_participates[i] = TRUE; /* player just appeared from CE */
+ }
+
+ /* only save actions from input devices, but not programmed actions */
+ if (tape.recording)
+ TapeRecordAction(tape_action);
+#endif
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ int actual_player_action = stored_player[i].effective_action;
+
+#if 1
+ /* !!! THIS BREAKS THE FOLLOWING TAPES: !!!
+ - rnd_equinox_tetrachloride 048
+ - rnd_equinox_tetrachloride_ii 096
+ - rnd_emanuel_schmieg 002
+ - doctor_sloan_ww 001, 020
+ */
+ if (stored_player[i].MovPos == 0)
+ CheckGravityMovement(&stored_player[i]);
+#endif
+
+#if 1
+ /* overwrite programmed action with tape action */
+ if (stored_player[i].programmed_action)
+ actual_player_action = stored_player[i].programmed_action;
+#endif
+
+#if 0
+ if (stored_player[i].programmed_action)
+ printf("::: %d\n", stored_player[i].programmed_action);
+#endif
+
+ if (recorded_player_action)
+ {
+#if 0
+ if (stored_player[i].programmed_action &&
+ stored_player[i].programmed_action != recorded_player_action[i])
+ printf("::: %d: %d <-> %d\n", i,
+ stored_player[i].programmed_action, recorded_player_action[i]);
+#endif
+
+#if 0
+ actual_player_action = recorded_player_action[i];
+#endif
+ }
+
+#if 0
+ /* overwrite tape action with programmed action */
+ if (stored_player[i].programmed_action)
+ actual_player_action = stored_player[i].programmed_action;
+#endif
+
+#if 0
+ if (i == 0)
+ printf("::: action: %d: %x [%d]\n",
+ stored_player[i].MovPos, actual_player_action, FrameCounter);
+#endif
+
+#if 1
+ PlayerActions(&stored_player[i], actual_player_action);
+#else
+ tape_action[i] = PlayerActions(&stored_player[i], actual_player_action);
+
+ if (tape.recording && tape_action[i] && !tape.player_participates[i])
+ tape.player_participates[i] = TRUE; /* player just appeared from CE */
+#endif
+
+ ScrollPlayer(&stored_player[i], SCROLL_GO_ON);
+ }
+
+#if 0
+ if (tape.recording)
+ TapeRecordAction(tape_action);
+#endif
+
+ network_player_action_received = FALSE;
+
+ ScrollScreen(NULL, SCROLL_GO_ON);
+
+#if 0
+ FrameCounter++;
+ TimeFrames++;
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ stored_player[i].Frame++;
+#endif
+
+#if 1
+ /* for downwards compatibility, the following code emulates a fixed bug that
+ occured when pushing elements (causing elements that just made their last
+ pushing step to already (if possible) make their first falling step in the
+ same game frame, which is bad); this code is also needed to use the famous
+ "spring push bug" which is used in older levels and might be wanted to be
+ used also in newer levels, but in this case the buggy pushing code is only
+ affecting the "spring" element and no other elements */
+
+#if 1
+ if (game.engine_version < VERSION_IDENT(2,2,0,7) || level.use_spring_bug)
+#else
+ if (game.engine_version < VERSION_IDENT(2,2,0,7))
+#endif
+ {
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ struct PlayerInfo *player = &stored_player[i];
+ int x = player->jx;
+ int y = player->jy;
+
+#if 1
+ if (player->active && player->is_pushing && player->is_moving &&
+ IS_MOVING(x, y) &&
+ (game.engine_version < VERSION_IDENT(2,2,0,7) ||
+ Feld[x][y] == EL_SPRING))
+#else
+ if (player->active && player->is_pushing && player->is_moving &&
+ IS_MOVING(x, y))
+#endif
+ {
+ ContinueMoving(x, y);
+
+ /* continue moving after pushing (this is actually a bug) */
+ if (!IS_MOVING(x, y))
+ {
+ Stop[x][y] = FALSE;
+ }
+ }
+ }
+ }
+#endif
+
+ for (y = 0; y < lev_fieldy; y++) for (x = 0; x < lev_fieldx; x++)
+ {
+ Changed[x][y] = CE_BITMASK_DEFAULT;
+ ChangeEvent[x][y] = CE_BITMASK_DEFAULT;
+
+ /* this must be handled before main playfield loop */
+ if (Feld[x][y] == EL_PLAYER_IS_LEAVING)
+ {
+ MovDelay[x][y]--;
+ if (MovDelay[x][y] <= 0)
+ RemoveField(x, y);
+ }
+
+#if DEBUG
+ if (ChangePage[x][y] != -1 && ChangeDelay[x][y] != 1)
+ {
+ printf("GameActions(): x = %d, y = %d: ChangePage != -1\n", x, y);
+ printf("GameActions(): This should never happen!\n");
+
+ ChangePage[x][y] = -1;
+ }
+#endif
+
+ Stop[x][y] = FALSE;
+ if (WasJustMoving[x][y] > 0)
+ WasJustMoving[x][y]--;
+ if (WasJustFalling[x][y] > 0)
+ WasJustFalling[x][y]--;
+ if (CheckCollision[x][y] > 0)
+ CheckCollision[x][y]--;
+
+ GfxFrame[x][y]++;
+
+#if 1
+ /* reset finished pushing action (not done in ContinueMoving() to allow
+ continous pushing animation for elements with zero push delay) */
+ if (GfxAction[x][y] == ACTION_PUSHING && !IS_MOVING(x, y))
+ {
+ ResetGfxAnimation(x, y);
+ DrawLevelField(x, y);
+ }
+#endif
+
+#if DEBUG
+ if (IS_BLOCKED(x, y))
+ {
+ int oldx, oldy;
+
+ Blocked2Moving(x, y, &oldx, &oldy);
+ if (!IS_MOVING(oldx, oldy))
+ {
+ printf("GameActions(): (BLOCKED => MOVING) context corrupted!\n");
+ printf("GameActions(): BLOCKED: x = %d, y = %d\n", x, y);
+ printf("GameActions(): !MOVING: oldx = %d, oldy = %d\n", oldx, oldy);
+ printf("GameActions(): This should never happen!\n");
+ }
+ }
+#endif
+ }
+
+ for (y = 0; y < lev_fieldy; y++) for (x = 0; x < lev_fieldx; x++)
+ {
+ element = Feld[x][y];
+#if 1
+ graphic = el_act_dir2img(element, GfxAction[x][y], GfxDir[x][y]);
+#else
+ graphic = el2img(element);
+#endif
+
+#if 0
+ if (element == -1)
+ {
+ printf("::: %d,%d: %d [%d]\n", x, y, element, FrameCounter);
+
+ element = graphic = 0;
+ }
+#endif
+
+ if (graphic_info[graphic].anim_global_sync)
+ GfxFrame[x][y] = FrameCounter;
+
+ if (ANIM_MODE(graphic) == ANIM_RANDOM &&
+ IS_NEXT_FRAME(GfxFrame[x][y], graphic))
+ ResetRandomAnimationValue(x, y);
+
+ SetRandomAnimationValue(x, y);
+
+#if 1
+ PlayLevelSoundActionIfLoop(x, y, GfxAction[x][y]);
+#endif
+
+ if (IS_INACTIVE(element))
+ {
+ if (IS_ANIMATED(graphic))
+ DrawLevelGraphicAnimationIfNeeded(x, y, graphic);
+
+ continue;
+ }
+
+#if 1
+ /* this may take place after moving, so 'element' may have changed */
+#if 0
+ if (IS_CHANGING(x, y))
+#else
+ if (IS_CHANGING(x, y) &&
+ (game.engine_version < VERSION_IDENT(3,0,7,1) || !Stop[x][y]))
+#endif
+ {
+#if 0
+ ChangeElement(x, y, ChangePage[x][y] != -1 ? ChangePage[x][y] :
+ element_info[element].event_page_nr[CE_DELAY]);
+#else
+ ChangeElement(x, y, element_info[element].event_page_nr[CE_DELAY]);
+#endif
+
+ element = Feld[x][y];
+ graphic = el_act_dir2img(element, GfxAction[x][y], GfxDir[x][y]);
+ }
+#endif
+
+ if (!IS_MOVING(x, y) && (CAN_FALL(element) || CAN_MOVE(element)))
+ {
+ StartMoving(x, y);
+
+#if 1
+ element = Feld[x][y];
+ graphic = el_act_dir2img(element, GfxAction[x][y], GfxDir[x][y]);
+#if 0
+ if (element == EL_MOLE)
+ printf("::: %d, %d, %d [%d]\n",
+ IS_ANIMATED(graphic), IS_MOVING(x, y), Stop[x][y],
+ GfxAction[x][y]);
+#endif
+#if 0
+ if (element == EL_YAMYAM)
+ printf("::: %d, %d, %d\n",
+ IS_ANIMATED(graphic), IS_MOVING(x, y), Stop[x][y]);
+#endif
+#endif
+
+ if (IS_ANIMATED(graphic) &&
+ !IS_MOVING(x, y) &&
+ !Stop[x][y])
+ {
+ DrawLevelGraphicAnimationIfNeeded(x, y, graphic);
+
+#if 0
+ if (element == EL_BUG)
+ printf("::: %d, %d\n", graphic, GfxFrame[x][y]);
+#endif
+
+#if 0
+ if (element == EL_MOLE)
+ printf("::: %d, %d\n", graphic, GfxFrame[x][y]);
+#endif
+ }
+
+ if (IS_GEM(element) || element == EL_SP_INFOTRON)
+ EdelsteinFunkeln(x, y);
+ }
+ else if ((element == EL_ACID ||
+ element == EL_EXIT_OPEN ||
+ element == EL_SP_EXIT_OPEN ||
+ element == EL_SP_TERMINAL ||
+ element == EL_SP_TERMINAL_ACTIVE ||
+ element == EL_EXTRA_TIME ||
+ element == EL_SHIELD_NORMAL ||
+ element == EL_SHIELD_DEADLY) &&
+ IS_ANIMATED(graphic))
+ DrawLevelGraphicAnimationIfNeeded(x, y, graphic);
+ else if (IS_MOVING(x, y))
+ ContinueMoving(x, y);
+ else if (IS_ACTIVE_BOMB(element))
+ CheckDynamite(x, y);
+#if 0
+ else if (element == EL_EXPLOSION && !game.explosions_delayed)
+ Explode(x, y, ExplodePhase[x][y], EX_TYPE_NORMAL);
+#endif
+ else if (element == EL_AMOEBA_GROWING)
+ AmoebeWaechst(x, y);
+ else if (element == EL_AMOEBA_SHRINKING)
+ AmoebaDisappearing(x, y);
+
+#if !USE_NEW_AMOEBA_CODE
+ else if (IS_AMOEBALIVE(element))
+ AmoebeAbleger(x, y);
+#endif
+
+ else if (element == EL_GAME_OF_LIFE || element == EL_BIOMAZE)
+ Life(x, y);
+ else if (element == EL_EXIT_CLOSED)
+ CheckExit(x, y);
+ else if (element == EL_SP_EXIT_CLOSED)
+ CheckExitSP(x, y);
+ else if (element == EL_EXPANDABLE_WALL_GROWING)
+ MauerWaechst(x, y);
+ else if (element == EL_EXPANDABLE_WALL ||
+ element == EL_EXPANDABLE_WALL_HORIZONTAL ||
+ element == EL_EXPANDABLE_WALL_VERTICAL ||
+ element == EL_EXPANDABLE_WALL_ANY)
+ MauerAbleger(x, y);
+ else if (element == EL_FLAMES)
+ CheckForDragon(x, y);
+#if 0
+ else if (IS_AUTO_CHANGING(element))
+ ChangeElement(x, y);
+#endif
+ else if (element == EL_EXPLOSION)
+ ; /* drawing of correct explosion animation is handled separately */
+ else if (IS_ANIMATED(graphic) && !IS_CHANGING(x, y))
+ DrawLevelGraphicAnimationIfNeeded(x, y, graphic);
+
+#if 0
+ /* this may take place after moving, so 'element' may have changed */
+ if (IS_AUTO_CHANGING(Feld[x][y]))
+ ChangeElement(x, y);
+#endif
+
+ if (IS_BELT_ACTIVE(element))
+ PlayLevelSoundAction(x, y, ACTION_ACTIVE);
+
+ if (game.magic_wall_active)
+ {
+ int jx = local_player->jx, jy = local_player->jy;
+
+ /* play the element sound at the position nearest to the player */
+ if ((element == EL_MAGIC_WALL_FULL ||
+ element == EL_MAGIC_WALL_ACTIVE ||
+ element == EL_MAGIC_WALL_EMPTYING ||
+ element == EL_BD_MAGIC_WALL_FULL ||
+ element == EL_BD_MAGIC_WALL_ACTIVE ||
+ element == EL_BD_MAGIC_WALL_EMPTYING) &&
+ ABS(x-jx) + ABS(y-jy) < ABS(magic_wall_x-jx) + ABS(magic_wall_y-jy))
+ {
+ magic_wall_x = x;
+ magic_wall_y = y;
+ }
+ }
+ }
+
+#if USE_NEW_AMOEBA_CODE
+ /* new experimental amoeba growth stuff */
+#if 1
+ if (!(FrameCounter % 8))
+#endif
+ {
+ static unsigned long random = 1684108901;
+
+ for (i = 0; i < level.amoeba_speed * 28 / 8; i++)
+ {
+#if 0
+ x = (random >> 10) % lev_fieldx;
+ y = (random >> 20) % lev_fieldy;
+#else
+ x = RND(lev_fieldx);
+ y = RND(lev_fieldy);
+#endif
+ element = Feld[x][y];
+
+#if 1
+ if (!IS_PLAYER(x,y) &&
+ (element == EL_EMPTY ||
+ CAN_GROW_INTO(element) ||
+ element == EL_QUICKSAND_EMPTY ||
+ element == EL_ACID_SPLASH_LEFT ||
+ element == EL_ACID_SPLASH_RIGHT))
+ {
+ if ((IN_LEV_FIELD(x, y-1) && Feld[x][y-1] == EL_AMOEBA_WET) ||
+ (IN_LEV_FIELD(x-1, y) && Feld[x-1][y] == EL_AMOEBA_WET) ||
+ (IN_LEV_FIELD(x+1, y) && Feld[x+1][y] == EL_AMOEBA_WET) ||
+ (IN_LEV_FIELD(x, y+1) && Feld[x][y+1] == EL_AMOEBA_WET))
+ Feld[x][y] = EL_AMOEBA_DROP;
+ }
+#else
+ /* !!! extend EL_SAND to anything diggable (but maybe not SP_BASE) !!! */
+ if (!IS_PLAYER(x,y) &&
+ (element == EL_EMPTY ||
+ element == EL_SAND ||
+ element == EL_QUICKSAND_EMPTY ||
+ element == EL_ACID_SPLASH_LEFT ||
+ element == EL_ACID_SPLASH_RIGHT))
+ {
+ if ((IN_LEV_FIELD(x, y-1) && Feld[x][y-1] == EL_AMOEBA_WET) ||
+ (IN_LEV_FIELD(x-1, y) && Feld[x-1][y] == EL_AMOEBA_WET) ||
+ (IN_LEV_FIELD(x+1, y) && Feld[x+1][y] == EL_AMOEBA_WET) ||
+ (IN_LEV_FIELD(x, y+1) && Feld[x][y+1] == EL_AMOEBA_WET))
+ Feld[x][y] = EL_AMOEBA_DROP;
+ }
+#endif
+
+ random = random * 129 + 1;
+ }
+ }
+#endif
+
+#if 0
+ if (game.explosions_delayed)
+#endif
+ {
+ game.explosions_delayed = FALSE;
+
+ for (y = 0; y < lev_fieldy; y++) for (x = 0; x < lev_fieldx; x++)
+ {
+ element = Feld[x][y];
+
+ if (ExplodeField[x][y])
+ Explode(x, y, EX_PHASE_START, ExplodeField[x][y]);
+ else if (element == EL_EXPLOSION)
+ Explode(x, y, ExplodePhase[x][y], EX_TYPE_NORMAL);
+
+ ExplodeField[x][y] = EX_TYPE_NONE;
+ }
+
+ game.explosions_delayed = TRUE;
+ }
+
+ if (game.magic_wall_active)
+ {
+ if (!(game.magic_wall_time_left % 4))
+ {
+ int element = Feld[magic_wall_x][magic_wall_y];
+
+ if (element == EL_BD_MAGIC_WALL_FULL ||
+ element == EL_BD_MAGIC_WALL_ACTIVE ||
+ element == EL_BD_MAGIC_WALL_EMPTYING)
+ PlayLevelSound(magic_wall_x, magic_wall_y, SND_BD_MAGIC_WALL_ACTIVE);
+ else
+ PlayLevelSound(magic_wall_x, magic_wall_y, SND_MAGIC_WALL_ACTIVE);
+ }
+
+ if (game.magic_wall_time_left > 0)
+ {
+ game.magic_wall_time_left--;
+ if (!game.magic_wall_time_left)
+ {
+ for (y = 0; y < lev_fieldy; y++) for (x = 0; x < lev_fieldx; x++)
+ {
+ element = Feld[x][y];
+
+ if (element == EL_MAGIC_WALL_ACTIVE ||
+ element == EL_MAGIC_WALL_FULL)
+ {
+ Feld[x][y] = EL_MAGIC_WALL_DEAD;
+ DrawLevelField(x, y);
+ }
+ else if (element == EL_BD_MAGIC_WALL_ACTIVE ||
+ element == EL_BD_MAGIC_WALL_FULL)
+ {
+ Feld[x][y] = EL_BD_MAGIC_WALL_DEAD;
+ DrawLevelField(x, y);
+ }
+ }
+
+ game.magic_wall_active = FALSE;
+ }
+ }
+ }
+
+ if (game.light_time_left > 0)
+ {
+ game.light_time_left--;
+
+ if (game.light_time_left == 0)
+ RedrawAllLightSwitchesAndInvisibleElements();
+ }
+
+ if (game.timegate_time_left > 0)
+ {
+ game.timegate_time_left--;
+
+ if (game.timegate_time_left == 0)
+ CloseAllOpenTimegates();
+ }
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ struct PlayerInfo *player = &stored_player[i];
+
+ if (SHIELD_ON(player))
+ {
+ if (player->shield_deadly_time_left)
+ PlayLevelSound(player->jx, player->jy, SND_SHIELD_DEADLY_ACTIVE);
+ else if (player->shield_normal_time_left)
+ PlayLevelSound(player->jx, player->jy, SND_SHIELD_NORMAL_ACTIVE);
+ }
+ }
+
+ if (TimeFrames >= FRAMES_PER_SECOND)
+ {
+ TimeFrames = 0;
+ TapeTime++;
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ struct PlayerInfo *player = &stored_player[i];
+
+ if (SHIELD_ON(player))
+ {
+ player->shield_normal_time_left--;
+
+ if (player->shield_deadly_time_left > 0)
+ player->shield_deadly_time_left--;
+ }
+ }
+
+ if (!level.use_step_counter)
+ {
+ TimePlayed++;
+
+ if (TimeLeft > 0)
+ {
+ TimeLeft--;
+
+ if (TimeLeft <= 10 && setup.time_limit)
+ PlaySoundStereo(SND_GAME_RUNNING_OUT_OF_TIME, SOUND_MIDDLE);
+
+ DrawGameValue_Time(TimeLeft);
+
+ if (!TimeLeft && setup.time_limit)
+ for (i = 0; i < MAX_PLAYERS; i++)
+ KillHero(&stored_player[i]);
+ }
+ else if (level.time == 0 && !AllPlayersGone) /* level w/o time limit */
+ DrawGameValue_Time(TimePlayed);
+ }
+
+ if (tape.recording || tape.playing)
+ DrawVideoDisplay(VIDEO_STATE_TIME_ON, TapeTime);
+ }
+
+ DrawAllPlayers();
+ PlayAllPlayersSound();
+
+ if (options.debug) /* calculate frames per second */
+ {
+ static unsigned long fps_counter = 0;
+ static int fps_frames = 0;
+ unsigned long fps_delay_ms = Counter() - fps_counter;
+
+ fps_frames++;
+
+ if (fps_delay_ms >= 500) /* calculate fps every 0.5 seconds */
+ {
+ global.frames_per_second = 1000 * (float)fps_frames / fps_delay_ms;
+
+ fps_frames = 0;
+ fps_counter = Counter();
+ }
+
+ redraw_mask |= REDRAW_FPS;
+ }
+
+#if 0
+ if (stored_player[0].jx != stored_player[0].last_jx ||
+ stored_player[0].jy != stored_player[0].last_jy)
+ printf("::: %d, %d, %d, %d, %d\n",
+ stored_player[0].MovDir,
+ stored_player[0].MovPos,
+ stored_player[0].GfxPos,
+ stored_player[0].Frame,
+ stored_player[0].StepFrame);
+#endif
+
+#if USE_NEW_MOVE_DELAY
+ AdvanceFrameAndPlayerCounters(-1); /* advance counters for all players */
+#else
+ FrameCounter++;
+ TimeFrames++;
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ int move_frames =
+ MOVE_DELAY_NORMAL_SPEED / stored_player[i].move_delay_value;
+
+ stored_player[i].Frame += move_frames;
+
+ if (stored_player[i].MovPos != 0)
+ stored_player[i].StepFrame += move_frames;
+
+#if USE_NEW_MOVE_DELAY
+ if (stored_player[i].move_delay > 0)
+ stored_player[i].move_delay--;
+#endif
+
+ if (stored_player[i].drop_delay > 0)
+ stored_player[i].drop_delay--;
+ }
+#endif
+
+#if 1
+ if (local_player->show_envelope != 0 && local_player->MovPos == 0)
+ {
+ ShowEnvelope(local_player->show_envelope - EL_ENVELOPE_1);
+
+ local_player->show_envelope = 0;
+ }
+#endif
+}
+
+static boolean AllPlayersInSight(struct PlayerInfo *player, int x, int y)
+{
+ int min_x = x, min_y = y, max_x = x, max_y = y;
+ int i;
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ int jx = stored_player[i].jx, jy = stored_player[i].jy;
+
+ if (!stored_player[i].active || &stored_player[i] == player)
+ continue;
+
+ min_x = MIN(min_x, jx);
+ min_y = MIN(min_y, jy);
+ max_x = MAX(max_x, jx);
+ max_y = MAX(max_y, jy);
+ }
+
+ return (max_x - min_x < SCR_FIELDX && max_y - min_y < SCR_FIELDY);
+}
+
+static boolean AllPlayersInVisibleScreen()
+{
+ int i;
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ int jx = stored_player[i].jx, jy = stored_player[i].jy;
+
+ if (!stored_player[i].active)
+ continue;
+
+ if (!IN_VIS_FIELD(SCREENX(jx), SCREENY(jy)))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+void ScrollLevel(int dx, int dy)
+{
+ int softscroll_offset = (setup.soft_scrolling ? TILEX : 0);
+ int x, y;
+
+ BlitBitmap(drawto_field, drawto_field,
+ FX + TILEX * (dx == -1) - softscroll_offset,
+ FY + TILEY * (dy == -1) - softscroll_offset,
+ SXSIZE - TILEX * (dx!=0) + 2 * softscroll_offset,
+ SYSIZE - TILEY * (dy!=0) + 2 * softscroll_offset,
+ FX + TILEX * (dx == 1) - softscroll_offset,
+ FY + TILEY * (dy == 1) - softscroll_offset);
+
+ if (dx)
+ {
+ x = (dx == 1 ? BX1 : BX2);
+ for (y = BY1; y <= BY2; y++)
+ DrawScreenField(x, y);
+ }
+
+ if (dy)
+ {
+ y = (dy == 1 ? BY1 : BY2);
+ for (x = BX1; x <= BX2; x++)
+ DrawScreenField(x, y);
+ }
+
+ redraw_mask |= REDRAW_FIELD;
+}
+
+#if 0
+static boolean canEnterSupaplexPort(int x, int y, int dx, int dy)
+{
+ int nextx = x + dx, nexty = y + dy;
+ int element = Feld[x][y];
+
+ if ((dx == -1 &&
+ element != EL_SP_PORT_LEFT &&
+ element != EL_SP_GRAVITY_PORT_LEFT &&
+ element != EL_SP_PORT_HORIZONTAL &&
+ element != EL_SP_PORT_ANY) ||
+ (dx == +1 &&
+ element != EL_SP_PORT_RIGHT &&
+ element != EL_SP_GRAVITY_PORT_RIGHT &&
+ element != EL_SP_PORT_HORIZONTAL &&
+ element != EL_SP_PORT_ANY) ||
+ (dy == -1 &&
+ element != EL_SP_PORT_UP &&
+ element != EL_SP_GRAVITY_PORT_UP &&
+ element != EL_SP_PORT_VERTICAL &&
+ element != EL_SP_PORT_ANY) ||
+ (dy == +1 &&
+ element != EL_SP_PORT_DOWN &&
+ element != EL_SP_GRAVITY_PORT_DOWN &&
+ element != EL_SP_PORT_VERTICAL &&
+ element != EL_SP_PORT_ANY) ||
+ !IN_LEV_FIELD(nextx, nexty) ||
+ !IS_FREE(nextx, nexty))
+ return FALSE;
+
+ return TRUE;
+}
+#endif
+
+static boolean canFallDown(struct PlayerInfo *player)
+{
+ int jx = player->jx, jy = player->jy;
+
+ return (IN_LEV_FIELD(jx, jy + 1) &&
+ (IS_FREE(jx, jy + 1) ||
+ (Feld[jx][jy + 1] == EL_ACID && player->can_fall_into_acid)) &&
+ IS_WALKABLE_FROM(Feld[jx][jy], MV_DOWN) &&
+ !IS_WALKABLE_INSIDE(Feld[jx][jy]));
+}
+
+static boolean canPassField(int x, int y, int move_dir)
+{
+ int opposite_dir = MV_DIR_OPPOSITE(move_dir);
+ int dx = (move_dir & MV_LEFT ? -1 : move_dir & MV_RIGHT ? +1 : 0);
+ int dy = (move_dir & MV_UP ? -1 : move_dir & MV_DOWN ? +1 : 0);
+ int nextx = x + dx;
+ int nexty = y + dy;
+ int element = Feld[x][y];
+
+ return (IS_PASSABLE_FROM(element, opposite_dir) &&
+ !CAN_MOVE(element) &&
+ IN_LEV_FIELD(nextx, nexty) && !IS_PLAYER(nextx, nexty) &&
+ IS_WALKABLE_FROM(Feld[nextx][nexty], move_dir) &&
+ (level.can_pass_to_walkable || IS_FREE(nextx, nexty)));
+}
+
+static boolean canMoveToValidFieldWithGravity(int x, int y, int move_dir)
+{
+ int opposite_dir = MV_DIR_OPPOSITE(move_dir);
+ int dx = (move_dir & MV_LEFT ? -1 : move_dir & MV_RIGHT ? +1 : 0);
+ int dy = (move_dir & MV_UP ? -1 : move_dir & MV_DOWN ? +1 : 0);
+ int newx = x + dx;
+ int newy = y + dy;
+#if 0
+ int nextx = newx + dx;
+ int nexty = newy + dy;
+#endif
+
+#if 1
+ return (IN_LEV_FIELD(newx, newy) && !IS_FREE_OR_PLAYER(newx, newy) &&
+ IS_GRAVITY_REACHABLE(Feld[newx][newy]) &&
+#if 0
+ (!IS_SP_PORT(Feld[newx][newy]) || move_dir == MV_UP) &&
+#endif
+ (IS_DIGGABLE(Feld[newx][newy]) ||
+ IS_WALKABLE_FROM(Feld[newx][newy], opposite_dir) ||
+ canPassField(newx, newy, move_dir)));
+#else
+#if 1
+ return (IN_LEV_FIELD(newx, newy) && !IS_FREE_OR_PLAYER(newx, newy) &&
+ IS_GRAVITY_REACHABLE(Feld[newx][newy]) &&
+ (IS_DIGGABLE(Feld[newx][newy]) ||
+ IS_WALKABLE_FROM(Feld[newx][newy], opposite_dir) ||
+ canPassField(newx, newy, move_dir)));
+#else
+#if 1
+ return (IN_LEV_FIELD(newx, newy) && !IS_FREE_OR_PLAYER(newx, newy) &&
+ (IS_DIGGABLE_WITH_GRAVITY(Feld[newx][newy]) ||
+ IS_WALKABLE_FROM(Feld[newx][newy], opposite_dir) ||
+ canPassField(newx, newy, move_dir)));
+#else
+ return (IN_LEV_FIELD(newx, newy) && !IS_FREE_OR_PLAYER(newx, newy) &&
+ (IS_DIGGABLE(Feld[newx][newy]) ||
+ IS_WALKABLE_FROM(Feld[newx][newy], opposite_dir) ||
+ (IS_PASSABLE_FROM(Feld[newx][newy], opposite_dir) &&
+ !CAN_MOVE(Feld[newx][newy]) &&
+ IN_LEV_FIELD(nextx, nexty) && !IS_PLAYER(nextx, nexty) &&
+ IS_WALKABLE_FROM(Feld[nextx][nexty], move_dir) &&
+ (level.can_pass_to_walkable || IS_FREE(nextx, nexty)))));
+#endif
+#endif
+#endif
+}
+
+static void CheckGravityMovement(struct PlayerInfo *player)
+{
+ if (game.gravity && !player->programmed_action)
+ {
+#if 1
+ int move_dir_horizontal = player->effective_action & MV_HORIZONTAL;
+ int move_dir_vertical = player->effective_action & MV_VERTICAL;
+#else
+ int move_dir_horizontal = player->action & MV_HORIZONTAL;
+ int move_dir_vertical = player->action & MV_VERTICAL;
+#endif
+
+#if 1
+ boolean player_is_snapping = player->effective_action & JOY_BUTTON_1;
+#else
+ boolean player_is_snapping = player->action & JOY_BUTTON_1;
+#endif
+
+ int jx = player->jx, jy = player->jy;
+
+ boolean player_is_moving_to_valid_field =
+ (!player_is_snapping &&
+ (canMoveToValidFieldWithGravity(jx, jy, move_dir_horizontal) ||
+ canMoveToValidFieldWithGravity(jx, jy, move_dir_vertical)));
+
+#if 0
+ int move_dir =
+ (player->last_move_dir & MV_HORIZONTAL ?
+ (move_dir_vertical ? move_dir_vertical : move_dir_horizontal) :
+ (move_dir_horizontal ? move_dir_horizontal : move_dir_vertical));
+#endif
+
+#if 0
+ int opposite_dir = MV_DIR_OPPOSITE(move_dir);
+ int dx = (move_dir & MV_LEFT ? -1 : move_dir & MV_RIGHT ? +1 : 0);
+ int dy = (move_dir & MV_UP ? -1 : move_dir & MV_DOWN ? +1 : 0);
+ int new_jx = jx + dx, new_jy = jy + dy;
+ int nextx = new_jx + dx, nexty = new_jy + dy;
+#endif
+
+#if 1
+
+#if 1
+ boolean player_can_fall_down = canFallDown(player);
+#else
+ boolean player_can_fall_down =
+ (IN_LEV_FIELD(jx, jy + 1) &&
+ (IS_FREE(jx, jy + 1) ||
+ (Feld[jx][jy + 1] == EL_ACID && player->can_fall_into_acid)));
+#endif
+
+#else
+ boolean player_can_fall_down =
+ (IN_LEV_FIELD(jx, jy + 1) &&
+ (IS_FREE(jx, jy + 1)));
+#endif
+
+#if 0
+ boolean player_is_moving_to_valid_field =
+ (
+#if 1
+ !player_is_snapping &&
+#endif
+
+#if 1
+ IN_LEV_FIELD(new_jx, new_jy) &&
+ (IS_DIGGABLE(Feld[new_jx][new_jy]) ||
+ (IS_SP_PORT(Feld[new_jx][new_jy]) &&
+ element_info[Feld[new_jx][new_jy]].access_direction & opposite_dir &&
+ IN_LEV_FIELD(nextx, nexty) &&
+ element_info[Feld[nextx][nexty]].access_direction & move_dir))
+#else
+ IN_LEV_FIELD(new_jx, new_jy) &&
+ (Feld[new_jx][new_jy] == EL_SP_BASE ||
+ Feld[new_jx][new_jy] == EL_SAND ||
+ (IS_SP_PORT(Feld[new_jx][new_jy]) &&
+ canEnterSupaplexPort(new_jx, new_jy, dx, dy)))
+ /* !!! extend EL_SAND to anything diggable !!! */
+#endif
+ );
+#endif
+
+#if 0
+ boolean player_is_standing_on_valid_field =
+ (IS_WALKABLE_INSIDE(Feld[jx][jy]) ||
+ (IS_WALKABLE(Feld[jx][jy]) && !ACCESS_FROM(Feld[jx][jy], MV_DOWN)));
+#endif
+
+#if 0
+ printf("::: checking gravity NOW [%d, %d, %d] [%d] [%d / %d] ...\n",
+ player_can_fall_down,
+ player_is_standing_on_valid_field,
+ player_is_moving_to_valid_field,
+ (player_is_moving_to_valid_field ? Feld[new_jx][new_jy] : -1),
+ player->effective_action,
+ player->can_fall_into_acid);
+#endif
+
+ if (player_can_fall_down &&
+#if 0
+ !player_is_standing_on_valid_field &&
+#endif
+ !player_is_moving_to_valid_field)
+ {
+#if 0
+ printf("::: setting programmed_action to MV_DOWN [%d,%d - %d] ...\n",
+ jx, jy, FrameCounter);
+#endif
+
+ player->programmed_action = MV_DOWN;
+ }
+ }
+}
+
+static void CheckGravityMovementWhenNotMoving(struct PlayerInfo *player)
+{
+#if 1
+ return CheckGravityMovement(player);
+#endif
+
+ if (game.gravity && !player->programmed_action)
+ {
+ int jx = player->jx, jy = player->jy;
+ boolean field_under_player_is_free =
+ (IN_LEV_FIELD(jx, jy + 1) && IS_FREE(jx, jy + 1));
+ boolean player_is_standing_on_valid_field =
+ (IS_WALKABLE_INSIDE(Feld[jx][jy]) ||
+ (IS_WALKABLE(Feld[jx][jy]) &&
+ !(element_info[Feld[jx][jy]].access_direction & MV_DOWN)));
+
+ if (field_under_player_is_free && !player_is_standing_on_valid_field)
+ player->programmed_action = MV_DOWN;
+ }
+}
+
+/*
+ MovePlayerOneStep()
+ -----------------------------------------------------------------------------
+ dx, dy: direction (non-diagonal) to try to move the player to
+ real_dx, real_dy: direction as read from input device (can be diagonal)
+*/
+
+boolean MovePlayerOneStep(struct PlayerInfo *player,
+ int dx, int dy, int real_dx, int real_dy)
+{
+#if 0
+ 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 move_direction = (dx == -1 ? MV_LEFT :
+ dx == +1 ? MV_RIGHT :
+ dy == -1 ? MV_UP :
+ dy == +1 ? MV_DOWN : MV_NO_MOVING);
+ int enter_side = trigger_sides[MV_DIR_BIT(move_direction)][0];
+ int leave_side = trigger_sides[MV_DIR_BIT(move_direction)][1];
+#endif
+ int jx = player->jx, jy = player->jy;
+ int new_jx = jx + dx, new_jy = jy + dy;
+ int element;
+ int can_move;
+
+ if (!player->active || (!dx && !dy))
+ return MF_NO_ACTION;
+
+ player->MovDir = (dx < 0 ? MV_LEFT :
+ dx > 0 ? MV_RIGHT :
+ dy < 0 ? MV_UP :
+ dy > 0 ? MV_DOWN : MV_NO_MOVING);
+
+ if (!IN_LEV_FIELD(new_jx, new_jy))
+ return MF_NO_ACTION;
+
+ if (!options.network && !AllPlayersInSight(player, new_jx, new_jy))
+ return MF_NO_ACTION;
+
+#if 0
+ element = MovingOrBlocked2Element(new_jx, new_jy);
+#else
+ element = MovingOrBlocked2ElementIfNotLeaving(new_jx, new_jy);
+#endif
+
+ if (DONT_RUN_INTO(element))
+ {
+ if (element == EL_ACID && dx == 0 && dy == 1)
+ {
+ SplashAcid(new_jx, new_jy);
+ Feld[jx][jy] = EL_PLAYER_1;
+ InitMovingField(jx, jy, MV_DOWN);
+ Store[jx][jy] = EL_ACID;
+ ContinueMoving(jx, jy);
+ BuryHero(player);
+ }
+ else
+ TestIfHeroRunsIntoBadThing(jx, jy, player->MovDir);
+
+ return MF_MOVING;
+ }
+
+ can_move = DigField(player, jx, jy, new_jx, new_jy, real_dx,real_dy, DF_DIG);
+ if (can_move != MF_MOVING)
+ return can_move;
+
+ /* check if DigField() has caused relocation of the player */
+ if (player->jx != jx || player->jy != jy)
+ return MF_NO_ACTION;
+
+ StorePlayer[jx][jy] = 0;
+ player->last_jx = jx;
+ player->last_jy = jy;
+ player->jx = new_jx;
+ player->jy = new_jy;
+ StorePlayer[new_jx][new_jy] = player->element_nr;
+
+ player->MovPos =
+ (dx > 0 || dy > 0 ? -1 : 1) * (TILEX - TILEX / player->move_delay_value);
+
+ player->step_counter++;
+
+#if 0
+ player->drop_delay = 0;
+#endif
+
+ PlayerVisit[jx][jy] = FrameCounter;
+
+ ScrollPlayer(player, SCROLL_INIT);
+
+#if 0
+ if (IS_CUSTOM_ELEMENT(Feld[jx][jy]))
+ {
+ CheckTriggeredElementChangeBySide(jx, jy, Feld[jx][jy], CE_OTHER_GETS_LEFT,
+ leave_side);
+ CheckElementChangeBySide(jx,jy, Feld[jx][jy],CE_LEFT_BY_PLAYER,leave_side);
+ }
+
+ if (IS_CUSTOM_ELEMENT(Feld[new_jx][new_jy]))
+ {
+ CheckTriggeredElementChangeBySide(new_jx, new_jy, Feld[new_jx][new_jy],
+ CE_OTHER_GETS_ENTERED, enter_side);
+ CheckElementChangeBySide(new_jx, new_jy, Feld[new_jx][new_jy],
+ CE_ENTERED_BY_PLAYER, enter_side);
+ }
+#endif
+
+ return MF_MOVING;
+}
+
+boolean MovePlayer(struct PlayerInfo *player, int dx, int dy)
+{
+ int jx = player->jx, jy = player->jy;
+ int old_jx = jx, old_jy = jy;
+ int moved = MF_NO_ACTION;
+
+#if 1
+ if (!player->active)
+ return FALSE;
+
+ if (!dx && !dy)
+ {
+ if (player->MovPos == 0)
+ {
+ player->is_moving = FALSE;
+ player->is_digging = FALSE;
+ player->is_collecting = FALSE;
+ player->is_snapping = FALSE;
+ player->is_pushing = FALSE;
+ }
+
+ return FALSE;
+ }
+#else
+ if (!player->active || (!dx && !dy))
+ return FALSE;
+#endif
+
+#if 0
+ if (!FrameReached(&player->move_delay, player->move_delay_value) &&
+ !tape.playing)
+ return FALSE;
+#else
+
+#if 1
+
+#if 0
+ printf("::: %d <= %d < %d ?\n", player->move_delay, FrameCounter,
+ player->move_delay + player->move_delay_value);
+#endif
+
+#if USE_NEW_MOVE_DELAY
+ if (player->move_delay > 0)
+#else
+ if (!FrameReached(&player->move_delay, player->move_delay_value))
+#endif
+ {
+#if 0
+ printf("::: can NOT move\n");
+#endif
+
+ return FALSE;
+ }
+#else
+ if (!FrameReached(&player->move_delay, player->move_delay_value) &&
+ !(tape.playing && tape.file_version < FILE_VERSION_2_0))
+ return FALSE;
+#endif
+
+#endif
+
+#if 0
+ printf("::: COULD move now\n");
+#endif
+
+#if USE_NEW_MOVE_DELAY
+ player->move_delay = -1; /* set to "uninitialized" value */
+#endif
+
+ /* store if player is automatically moved to next field */
+ player->is_auto_moving = (player->programmed_action != MV_NO_MOVING);
+
+ /* remove the last programmed player action */
+ player->programmed_action = 0;
+
+ if (player->MovPos)
+ {
+ /* should only happen if pre-1.2 tape recordings are played */
+ /* this is only for backward compatibility */
+
+ int original_move_delay_value = player->move_delay_value;
+
+#if DEBUG
+ printf("THIS SHOULD ONLY HAPPEN WITH PRE-1.2 LEVEL TAPES. [%ld]\n",
+ tape.counter);
+#endif
+
+ /* scroll remaining steps with finest movement resolution */
+ player->move_delay_value = MOVE_DELAY_NORMAL_SPEED;
+
+ 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
+
+ DrawAllPlayers();
+ BackToFront();
+ }
+
+ player->move_delay_value = original_move_delay_value;
+ }
+
+ if (player->last_move_dir & MV_HORIZONTAL)
+ {
+ if (!(moved |= MovePlayerOneStep(player, 0, dy, dx, dy)))
+ moved |= MovePlayerOneStep(player, dx, 0, dx, dy);
+ }
+ else
+ {
+ if (!(moved |= MovePlayerOneStep(player, dx, 0, dx, dy)))
+ moved |= MovePlayerOneStep(player, 0, dy, dx, dy);
+ }
+
+ jx = player->jx;
+ jy = player->jy;
+
+ if (moved & MF_MOVING && !ScreenMovPos &&
+ (player == local_player || !options.network))
+ {
+ int old_scroll_x = scroll_x, old_scroll_y = scroll_y;
+ int offset = (setup.scroll_delay ? 3 : 0);
+
+ if (!IN_VIS_FIELD(SCREENX(jx), SCREENY(jy)))
+ {
+ /* actual player has left the screen -- scroll in that direction */
+ if (jx != old_jx) /* player has moved horizontally */
+ scroll_x += (jx - old_jx);
+ else /* player has moved vertically */
+ scroll_y += (jy - old_jy);
+ }
+ else
+ {
+ if (jx != old_jx) /* player has moved horizontally */
+ {
+ if ((player->MovDir == MV_LEFT && scroll_x > jx - MIDPOSX + offset) ||
+ (player->MovDir == MV_RIGHT && scroll_x < jx - MIDPOSX - offset))
+ scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : +offset);
+
+ /* don't scroll over playfield boundaries */
+ if (scroll_x < SBX_Left || scroll_x > SBX_Right)
+ scroll_x = (scroll_x < SBX_Left ? SBX_Left : SBX_Right);
+
+ /* don't scroll more than one field at a time */
+ scroll_x = old_scroll_x + SIGN(scroll_x - old_scroll_x);
+
+ /* don't scroll against the player's moving direction */
+ if ((player->MovDir == MV_LEFT && scroll_x > old_scroll_x) ||
+ (player->MovDir == MV_RIGHT && scroll_x < old_scroll_x))
+ scroll_x = old_scroll_x;
+ }
+ else /* player has moved vertically */
+ {
+ if ((player->MovDir == MV_UP && scroll_y > jy - MIDPOSY + offset) ||
+ (player->MovDir == MV_DOWN && scroll_y < jy - MIDPOSY - offset))
+ scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : +offset);
+
+ /* don't scroll over playfield boundaries */
+ if (scroll_y < SBY_Upper || scroll_y > SBY_Lower)
+ scroll_y = (scroll_y < SBY_Upper ? SBY_Upper : SBY_Lower);
+
+ /* don't scroll more than one field at a time */
+ scroll_y = old_scroll_y + SIGN(scroll_y - old_scroll_y);
+
+ /* don't scroll against the player's moving direction */
+ if ((player->MovDir == MV_UP && scroll_y > old_scroll_y) ||
+ (player->MovDir == MV_DOWN && scroll_y < old_scroll_y))
+ scroll_y = old_scroll_y;
+ }
+ }
+
+ if (scroll_x != old_scroll_x || scroll_y != old_scroll_y)
+ {
+ if (!options.network && !AllPlayersInVisibleScreen())
+ {
+ scroll_x = old_scroll_x;
+ scroll_y = old_scroll_y;
+ }
+ else
+ {
+ ScrollScreen(player, SCROLL_INIT);
+ ScrollLevel(old_scroll_x - scroll_x, old_scroll_y - scroll_y);
+ }
+ }
+ }
+
+#if 0
+#if 1
+ InitPlayerGfxAnimation(player, ACTION_DEFAULT);
+#else
+ if (!(moved & MF_MOVING) && !player->is_pushing)
+ player->Frame = 0;
+#endif
+#endif
+
+ player->StepFrame = 0;
+
+ if (moved & MF_MOVING)
+ {
+#if 0
+ printf("::: REALLY moves now\n");
+#endif
+
+ if (old_jx != jx && old_jy == jy)
+ player->MovDir = (old_jx < jx ? MV_RIGHT : MV_LEFT);
+ else if (old_jx == jx && old_jy != jy)
+ player->MovDir = (old_jy < jy ? MV_DOWN : MV_UP);
+
+ DrawLevelField(jx, jy); /* for "crumbled sand" */
+
+ player->last_move_dir = player->MovDir;
+ player->is_moving = TRUE;
+#if 1
+ player->is_snapping = FALSE;
+#endif