X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=f8289cc9138937767facf986edaa3b21fa908628;hb=564a563aee2c9fdb37116d41342b36eda63c1f6a;hp=572758d93ba61a642c4c8414f9de9ec7fede4278;hpb=416b848f652f72bb4d4e77417bc89cbc3e9e277c;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 572758d9..f8289cc9 100644 --- a/src/game.c +++ b/src/game.c @@ -101,7 +101,13 @@ #define GET_MAX_MOVE_DELAY(e) ( (element_info[e].move_delay_fixed) + \ (element_info[e].move_delay_random)) -#if 1 +#define ELEMENT_CAN_ENTER_FIELD_BASE(e, x, y, condition) \ + (IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \ + (CAN_MOVE_INTO_ACID(e) && \ + Feld[x][y] == EL_ACID) || \ + (condition))) + +#if 0 #define ELEMENT_CAN_ENTER_FIELD_GENERIC(e, x, y, condition) \ (IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \ (condition) || \ @@ -112,8 +118,11 @@ #define ELEMENT_CAN_ENTER_FIELD_GENERIC(e, x, y, condition) \ (IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \ (condition) || \ + (CAN_MOVE_INTO_ACID(e) && \ + Feld[x][y] == EL_ACID) || \ (DONT_COLLIDE_WITH(e) && \ - IS_FREE_OR_PLAYER(x, y)))) + IS_PLAYER(x, y) && \ + !PLAYER_ENEMY_PROTECTED(x, y)))) #endif #define ELEMENT_CAN_ENTER_FIELD_GENERIC_2(x, y, condition) \ @@ -129,7 +138,11 @@ #define ELEMENT_CAN_ENTER_FIELD_OR_ACID_2(x, y) \ ELEMENT_CAN_ENTER_FIELD_GENERIC_2(x, y, (Feld[x][y] == EL_ACID)) -#define ENEMY_CAN_ENTER_FIELD(x, y) (IN_LEV_FIELD(x, y) && IS_FREE(x, y)) +#if 0 +#define ENEMY_CAN_ENTER_FIELD(e, x, y) (IN_LEV_FIELD(x, y) && IS_FREE(x, y)) +#else +#define ENEMY_CAN_ENTER_FIELD(e, x, y) ELEMENT_CAN_ENTER_FIELD_BASE(e, x, y, 0) +#endif #define YAMYAM_CAN_ENTER_FIELD(x, y) \ (IN_LEV_FIELD(x, y) && (IS_FREE_OR_PLAYER(x, y) || \ @@ -153,17 +166,6 @@ Feld[x][y] == EL_EXIT_OPEN || \ Feld[x][y] == EL_ACID)) -#if 0 -#if 1 -#define MAZE_RUNNER_CAN_ENTER_FIELD(x, y) \ - (IN_LEV_FIELD(x, y) && IS_FREE(x, y)) -#else -#define MAZE_RUNNER_CAN_ENTER_FIELD(x, y) \ - (IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \ - IS_FOOD_DARK_YAMYAM(Feld[x][y]))) -#endif -#endif - #define GROUP_NR(e) ((e) - EL_GROUP_START) #define MOVE_ENTER_EL(e) (element_info[e].move_enter_element) #define IS_IN_GROUP(e, nr) (element_info[e].in_group[nr] == TRUE) @@ -172,7 +174,7 @@ #define IS_EQUAL_OR_IN_GROUP(e, ge) \ (IS_GROUP_ELEMENT(ge) ? IS_IN_GROUP(e, GROUP_NR(ge)) : (e) == (ge)) -#if 1 +#if 0 #define CE_ENTER_FIELD_COND(e, x, y) \ (!IS_PLAYER(x, y) && \ (Feld[x][y] == EL_ACID || \ @@ -180,10 +182,7 @@ #else #define CE_ENTER_FIELD_COND(e, x, y) \ (!IS_PLAYER(x, y) && \ - (Feld[x][y] == EL_ACID || \ - Feld[x][y] == MOVE_ENTER_EL(e) || \ - (IS_GROUP_ELEMENT(MOVE_ENTER_EL(e)) && \ - IS_IN_GROUP_EL(Feld[x][y], MOVE_ENTER_EL(e))))) + IS_EQUAL_OR_IN_GROUP(Feld[x][y], MOVE_ENTER_EL(e))) #endif #define CUSTOM_ELEMENT_CAN_ENTER_FIELD(e, x, y) \ @@ -213,6 +212,8 @@ static boolean MovePlayer(struct PlayerInfo *, int, int); static void ScrollPlayer(struct PlayerInfo *, int); static void ScrollScreen(struct PlayerInfo *, int); +int DigField(struct PlayerInfo *, int, int, int, int, int, int, int); + static void InitBeltMovement(void); static void CloseAllOpenTimegates(void); static void CheckGravityMovement(struct PlayerInfo *); @@ -497,6 +498,28 @@ collect_count_list[] = { EL_UNDEFINED, 0 }, }; +struct +{ + int element; + int direction; +} +tube_access[] = +{ + { EL_TUBE_ANY, MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN }, + { EL_TUBE_VERTICAL, MV_UP | MV_DOWN }, + { EL_TUBE_HORIZONTAL, MV_LEFT | MV_RIGHT }, + { EL_TUBE_VERTICAL_LEFT, MV_LEFT | MV_UP | MV_DOWN }, + { EL_TUBE_VERTICAL_RIGHT, MV_RIGHT | MV_UP | MV_DOWN }, + { EL_TUBE_HORIZONTAL_UP, MV_LEFT | MV_RIGHT | MV_UP }, + { EL_TUBE_HORIZONTAL_DOWN, MV_LEFT | MV_RIGHT | MV_DOWN }, + { EL_TUBE_LEFT_UP, MV_LEFT | MV_UP }, + { EL_TUBE_LEFT_DOWN, MV_LEFT | MV_DOWN }, + { EL_TUBE_RIGHT_UP, MV_RIGHT | MV_UP }, + { EL_TUBE_RIGHT_DOWN, MV_RIGHT | MV_DOWN }, + + { EL_UNDEFINED, 0 } +}; + static unsigned long trigger_events[MAX_NUM_ELEMENTS]; #define IS_AUTO_CHANGING(e) (element_info[e].change_events & \ @@ -838,6 +861,36 @@ static void InitField(int x, int y, boolean init_game) } } +static inline void InitField_WithBug1(int x, int y, boolean init_game) +{ + InitField(x, y, init_game); + + /* not needed to call InitMovDir() -- already done by InitField()! */ + if (game.engine_version < VERSION_IDENT(3,0,9,0) && + CAN_MOVE(Feld[x][y])) + InitMovDir(x, y); +} + +static inline void InitField_WithBug2(int x, int y, boolean init_game) +{ + int old_element = Feld[x][y]; + + InitField(x, y, init_game); + + /* not needed to call InitMovDir() -- already done by InitField()! */ + if (game.engine_version < VERSION_IDENT(3,0,9,0) && + CAN_MOVE(old_element) && + (old_element < EL_MOLE_LEFT || old_element > EL_MOLE_DOWN)) + InitMovDir(x, y); + + /* this case is in fact a combination of not less than three bugs: + first, it calls InitMovDir() for elements that can move, although this is + already done by InitField(); then, it checks the element that was at this + field _before_ the call to InitField() (which can change it) + + */ +} + void DrawGameDoorValues() { int i, j; @@ -1157,6 +1210,18 @@ static void InitGameEngine() for (i = 0; collect_count_list[i].element != EL_UNDEFINED; i++) element_info[collect_count_list[i].element].collect_count = collect_count_list[i].count; + + /* ---------- initialize access direction -------------------------------- */ + + /* initialize access direction values to default */ + for (i = 0; i < MAX_NUM_ELEMENTS; i++) + if (!IS_CUSTOM_ELEMENT(i)) + element_info[i].access_direction = MV_ALL_DIRECTIONS; + + /* set access direction value for certain elements from pre-defined list */ + for (i = 0; tube_access[i].element != EL_UNDEFINED; i++) + element_info[tube_access[i].element].access_direction = + tube_access[i].direction; } @@ -1315,7 +1380,7 @@ void InitGame() player->inventory_size = 0; - DigField(player, 0, 0, 0, 0, DF_NO_PUSH); + DigField(player, 0, 0, 0, 0, 0, 0, DF_NO_PUSH); SnapField(player, 0, 0); player->LevelSolved = FALSE; @@ -2270,8 +2335,25 @@ void RemoveMovingField(int x, int y) if (IS_MOVING(x, y)) { Moving2Blocked(x, y, &newx, &newy); +#if 0 if (Feld[newx][newy] != EL_BLOCKED) return; +#else + if (Feld[newx][newy] != EL_BLOCKED) + { + /* element is moving, but target field is not free (blocked), but + already occupied by something different (example: acid pool); + in this case, only remove the moving field, but not the target */ + + RemoveField(oldx, oldy); + + Store[oldx][oldy] = Store2[oldx][oldy] = 0; + + DrawLevelField(oldx, oldy); + + return; + } +#endif } else if (element == EL_BLOCKED) { @@ -2731,8 +2813,10 @@ void Explode(int ex, int ey, int phase, int mode) KillHeroUnlessExplosionProtected(x, y); border_explosion = TRUE; +#if 0 if (phase == last_phase) printf("::: IS_PLAYER\n"); +#endif } else if (CAN_EXPLODE_BY_EXPLOSION(border_element)) { @@ -2741,8 +2825,10 @@ void Explode(int ex, int ey, int phase, int mode) Bang(x, y); border_explosion = TRUE; +#if 0 if (phase == last_phase) printf("::: CAN_EXPLODE_BY_EXPLOSION\n"); +#endif } else if (border_element == EL_AMOEBA_TO_DIAMOND) { @@ -2750,11 +2836,13 @@ void Explode(int ex, int ey, int phase, int mode) Store2[x][y] = 0; border_explosion = TRUE; +#if 0 if (phase == last_phase) printf("::: EL_AMOEBA_TO_DIAMOND [%d, %d] [%d]\n", element_info[border_element].explosion_delay, element_info[border_element].ignition_delay, phase); +#endif } #if 1 @@ -2824,11 +2912,21 @@ void Explode(int ex, int ey, int phase, int mode) ChangeDelay[x][y] = 0; ChangePage[x][y] = -1; +#if 1 + InitField_WithBug2(x, y, FALSE); +#else InitField(x, y, FALSE); #if 1 /* !!! not needed !!! */ +#if 1 + if (game.engine_version < VERSION_IDENT(3,0,9,0) && + CAN_MOVE(Feld[x][y]) && Feld[x][y] != EL_MOLE) + InitMovDir(x, y); +#else if (CAN_MOVE(element)) InitMovDir(x, y); +#endif +#endif #endif DrawLevelField(x, y); @@ -3019,23 +3117,42 @@ void Bang(int x, int y) void SplashAcid(int x, int y) { +#if 1 + if (IN_LEV_FIELD(x - 1, y - 1) && IS_FREE(x - 1, y - 1) && + (!IN_LEV_FIELD(x - 1, y - 2) || + !CAN_FALL(MovingOrBlocked2Element(x - 1, y - 2)))) + Feld[x - 1][y - 1] = EL_ACID_SPLASH_LEFT; + + if (IN_LEV_FIELD(x + 1, y - 1) && IS_FREE(x + 1, y - 1) && + (!IN_LEV_FIELD(x + 1, y - 2) || + !CAN_FALL(MovingOrBlocked2Element(x + 1, y - 2)))) + Feld[x + 1][y - 1] = EL_ACID_SPLASH_RIGHT; + + PlayLevelSound(x, y, SND_ACID_SPLASHING); +#else + /* input: position of element entering acid (obsolete) */ + int element = Feld[x][y]; + if (!IN_LEV_FIELD(x, y + 1) || Feld[x][y + 1] != EL_ACID) + return; + if (element != EL_ACID_SPLASH_LEFT && element != EL_ACID_SPLASH_RIGHT) { PlayLevelSound(x, y, SND_ACID_SPLASHING); - if (IN_LEV_FIELD(x-1, y) && IS_FREE(x-1, y) && - (!IN_LEV_FIELD(x-1, y-1) || - !CAN_FALL(MovingOrBlocked2Element(x-1, y-1)))) - Feld[x-1][y] = EL_ACID_SPLASH_LEFT; + if (IN_LEV_FIELD(x - 1, y) && IS_FREE(x - 1, y) && + (!IN_LEV_FIELD(x - 1, y - 1) || + !CAN_FALL(MovingOrBlocked2Element(x - 1, y - 1)))) + Feld[x - 1][y] = EL_ACID_SPLASH_LEFT; - if (IN_LEV_FIELD(x+1, y) && IS_FREE(x+1, y) && - (!IN_LEV_FIELD(x+1, y-1) || - !CAN_FALL(MovingOrBlocked2Element(x+1, y-1)))) - Feld[x+1][y] = EL_ACID_SPLASH_RIGHT; + if (IN_LEV_FIELD(x + 1, y) && IS_FREE(x + 1, y) && + (!IN_LEV_FIELD(x + 1, y - 1) || + !CAN_FALL(MovingOrBlocked2Element(x + 1, y - 1)))) + Feld[x + 1][y] = EL_ACID_SPLASH_RIGHT; } +#endif } static void InitBeltMovement() @@ -3360,7 +3477,7 @@ inline static int getElementMoveStepsize(int x, int y) /* special values for move stepsize for spring and things on conveyor belt */ if (horiz_move) { -#if 1 +#if 0 if (element == EL_SPRING) step = sign * MOVE_STEPSIZE_NORMAL * 2; else if (CAN_FALL(element) && !CAN_MOVE(element) && @@ -3412,7 +3529,7 @@ void Impact(int x, int y) if (!lastline && smashed == EL_ACID) /* element falls into acid */ { - SplashAcid(x, y); + SplashAcid(x, y + 1); return; } @@ -3663,9 +3780,9 @@ inline static void TurnRoundExt(int x, int y) { TestIfBadThingTouchesOtherBadThing(x, y); - if (ENEMY_CAN_ENTER_FIELD(right_x, right_y)) + if (ENEMY_CAN_ENTER_FIELD(element, right_x, right_y)) MovDir[x][y] = right_dir; - else if (!ENEMY_CAN_ENTER_FIELD(move_x, move_y)) + else if (!ENEMY_CAN_ENTER_FIELD(element, move_x, move_y)) MovDir[x][y] = left_dir; if (element == EL_BUG && MovDir[x][y] != old_move_dir) @@ -3678,9 +3795,9 @@ inline static void TurnRoundExt(int x, int y) { TestIfBadThingTouchesOtherBadThing(x, y); - if (ENEMY_CAN_ENTER_FIELD(left_x, left_y)) + if (ENEMY_CAN_ENTER_FIELD(element, left_x, left_y)) MovDir[x][y] = left_dir; - else if (!ENEMY_CAN_ENTER_FIELD(move_x, move_y)) + else if (!ENEMY_CAN_ENTER_FIELD(element, move_x, move_y)) MovDir[x][y] = right_dir; if ((element == EL_SPACESHIP || @@ -4305,7 +4422,9 @@ static boolean JustBeingPushed(int x, int y) void StartMoving(int x, int y) { +#if 0 boolean use_spring_bug = (game.engine_version < VERSION_IDENT(2,2,0,0)); +#endif boolean started_moving = FALSE; /* some elements can fall _and_ move */ int element = Feld[x][y]; @@ -4454,7 +4573,7 @@ void StartMoving(int x, int y) else if (CAN_FALL(element) && Feld[x][y + 1] == EL_ACID) #endif { - SplashAcid(x, y); + SplashAcid(x, y + 1); InitMovingField(x, y, MV_DOWN); started_moving = TRUE; @@ -4502,7 +4621,7 @@ void StartMoving(int x, int y) Impact(x, y); } - else if (IS_FREE(x, y + 1) && element == EL_SPRING && use_spring_bug) + else if (IS_FREE(x, y + 1) && element == EL_SPRING && level.use_spring_bug) { if (MovDir[x][y] == MV_NO_MOVING) { @@ -4578,7 +4697,7 @@ void StartMoving(int x, int y) started_moving = TRUE; } } -#if 1 +#if 0 else if (IS_BELT_ACTIVE(Feld[x][y + 1]) && !CAN_MOVE(element)) #else else if (IS_BELT_ACTIVE(Feld[x][y + 1])) @@ -4592,11 +4711,24 @@ void StartMoving(int x, int y) if ((belt_dir == MV_LEFT && left_is_free) || (belt_dir == MV_RIGHT && right_is_free)) { +#if 1 + int nextx = (belt_dir == MV_LEFT ? x - 1 : x + 1); +#endif + InitMovingField(x, y, belt_dir); started_moving = TRUE; +#if 1 + Pushed[x][y] = TRUE; + Pushed[nextx][y] = TRUE; +#endif + GfxAction[x][y] = ACTION_DEFAULT; } + else + { + MovDir[x][y] = 0; /* if element was moving, stop it */ + } } } @@ -4846,6 +4978,18 @@ void StartMoving(int x, int y) #endif } +#if 1 +#if 1 + else if (CAN_MOVE_INTO_ACID(element) && + IN_LEV_FIELD(newx, newy) && Feld[newx][newy] == EL_ACID && + (MovDir[x][y] == MV_DOWN || + game.engine_version > VERSION_IDENT(3,0,8,0))) +#else + else if (CAN_MOVE_INTO_ACID(element) && MovDir[x][y] == MV_DOWN && + IN_LEV_FIELD(newx, newy) && Feld[newx][newy] == EL_ACID) +#endif +#else + else if ((element == EL_PENGUIN || element == EL_ROBOT || element == EL_SATELLITE || @@ -4853,8 +4997,9 @@ void StartMoving(int x, int y) IS_CUSTOM_ELEMENT(element)) && IN_LEV_FIELD(newx, newy) && MovDir[x][y] == MV_DOWN && Feld[newx][newy] == EL_ACID) +#endif { - SplashAcid(x, y); + SplashAcid(newx, newy); Store[x][y] = EL_ACID; } else if (element == EL_PENGUIN && IN_LEV_FIELD(newx, newy)) @@ -4882,7 +5027,7 @@ void StartMoving(int x, int y) } else if (IS_FOOD_PENGUIN(Feld[newx][newy])) { - if (DigField(local_player, newx, newy, 0, 0, DF_DIG) == MF_MOVING) + if (DigField(local_player, x, y, newx, newy, 0,0, DF_DIG) == MF_MOVING) DrawLevelField(newx, newy); else GfxDir[x][y] = MovDir[x][y] = MV_NO_MOVING; @@ -5069,8 +5214,15 @@ void StartMoving(int x, int y) AmoebaCnt[AmoebaNr[newx][newy]]--; } +#if 0 + /* !!! test !!! */ + if (IS_MOVING(newx, newy) || IS_BLOCKED(newx, newy)) +#else if (IS_MOVING(newx, newy)) +#endif + { RemoveMovingField(newx, newy); + } else { Feld[newx][newy] = EL_EMPTY; @@ -5172,12 +5324,25 @@ void ContinueMoving(int x, int y) #if 0 int nextx = newx + dx, nexty = newy + dy; #endif - boolean pushed = Pushed[x][y]; +#if 1 + boolean pushed_by_player = (Pushed[x][y] && IS_PLAYER(x, y)); + boolean pushed_by_conveyor = (Pushed[x][y] && !IS_PLAYER(x, y)); +#else + boolean pushed_by_player = Pushed[x][y]; +#endif MovPos[x][y] += getElementMoveStepsize(x, y); - if (pushed) /* special case: moving object pushed by player */ +#if 0 + if (pushed_by_player && IS_PLAYER(x, y)) + { + /* special case: moving object pushed by player */ + MovPos[x][y] = SIGN(MovPos[x][y]) * (TILEX - ABS(PLAYERINFO(x,y)->MovPos)); + } +#else + if (pushed_by_player) /* special case: moving object pushed by player */ MovPos[x][y] = SIGN(MovPos[x][y]) * (TILEX - ABS(PLAYERINFO(x,y)->MovPos)); +#endif if (ABS(MovPos[x][y]) < TILEX) { @@ -5329,12 +5494,19 @@ void ContinueMoving(int x, int y) Stop[newx][newy] = TRUE; /* ignore this element until the next frame */ /* prevent pushed element from moving on in pushed direction */ - if (pushed && CAN_MOVE(element) && + if (pushed_by_player && CAN_MOVE(element) && element_info[element].move_pattern & MV_ANY_DIRECTION && !(element_info[element].move_pattern & direction)) TurnRound(newx, newy); - if (!pushed) /* special case: moving object pushed by player */ +#if 1 + /* 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; +#endif + + if (!pushed_by_player) { WasJustMoving[newx][newy] = 3; @@ -6364,9 +6536,13 @@ static void ChangeElementNowExt(int x, int y, int target_element) if (element_info[Feld[x][y]].move_direction_initial == MV_START_PREVIOUS) MovDir[x][y] = previous_move_direction; +#if 1 + InitField_WithBug1(x, y, FALSE); +#else InitField(x, y, FALSE); if (CAN_MOVE(Feld[x][y])) InitMovDir(x, y); +#endif DrawLevelField(x, y); @@ -6949,7 +7125,7 @@ static byte PlayerActions(struct PlayerInfo *player, byte player_action) /* no actions for this player (no input at player's configured device) */ - DigField(player, 0, 0, 0, 0, DF_NO_PUSH); + DigField(player, 0, 0, 0, 0, 0, 0, DF_NO_PUSH); SnapField(player, 0, 0); CheckGravityMovement(player); @@ -7030,7 +7206,7 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) /* no actions for this player (no input at player's configured device) */ - DigField(player, 0, 0, 0, 0, DF_NO_PUSH); + DigField(player, 0, 0, 0, 0, 0, 0, DF_NO_PUSH); SnapField(player, 0, 0); CheckGravityMovement(player); @@ -7164,7 +7340,19 @@ void GameActions() #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++) { @@ -7172,8 +7360,15 @@ void GameActions() 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); @@ -7773,9 +7968,14 @@ static void CheckGravityMovement(struct PlayerInfo *player) canEnterSupaplexPort(new_jx, new_jy, dx, dy)))); /* !!! extend EL_SAND to anything diggable !!! */ + 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_moving_to_valid_field && - !IS_WALKABLE_INSIDE(Feld[jx][jy])) + !player_is_standing_on_valid_field && + !player_is_moving_to_valid_field) player->programmed_action = MV_DOWN; } } @@ -7835,7 +8035,7 @@ boolean MovePlayerOneStep(struct PlayerInfo *player, { if (element == EL_ACID && dx == 0 && dy == 1) { - SplashAcid(jx, jy); + SplashAcid(new_jx, new_jy); Feld[jx][jy] = EL_PLAYER_1; InitMovingField(jx, jy, MV_DOWN); Store[jx][jy] = EL_ACID; @@ -7848,7 +8048,7 @@ boolean MovePlayerOneStep(struct PlayerInfo *player, return MF_MOVING; } - can_move = DigField(player, new_jx, new_jy, real_dx, real_dy, DF_DIG); + can_move = DigField(player, jx, jy, new_jx, new_jy, real_dx,real_dy, DF_DIG); if (can_move != MF_MOVING) return can_move; @@ -8882,7 +9082,8 @@ static boolean checkDiagonalPushing(struct PlayerInfo *player, */ int DigField(struct PlayerInfo *player, - int x, int y, int real_dx, int real_dy, int mode) + int oldx, int oldy, int x, int y, + int real_dx, int real_dy, int mode) { static int change_sides[4] = { @@ -8891,8 +9092,10 @@ int DigField(struct PlayerInfo *player, CH_SIDE_BOTTOM, /* moving up */ CH_SIDE_TOP, /* moving down */ }; +#if 0 boolean use_spring_bug = (game.engine_version < VERSION_IDENT(2,2,0,0)); - int jx = player->jx, jy = player->jy; +#endif + int jx = oldx, jy = oldy; int dx = x - jx, dy = y - jy; int nextx = x + dx, nexty = y + dy; int move_direction = (dx == -1 ? MV_LEFT : @@ -8901,6 +9104,7 @@ int DigField(struct PlayerInfo *player, dy == +1 ? MV_DOWN : MV_NO_MOVING); int opposite_direction = MV_DIR_OPPOSITE(move_direction); int dig_side = change_sides[MV_DIR_BIT(move_direction)]; + int old_element = Feld[jx][jy]; int element; if (player->MovPos == 0) @@ -8923,6 +9127,8 @@ int DigField(struct PlayerInfo *player, if (IS_MOVING(x, y) || IS_PLAYER(x, y)) return MF_NO_ACTION; +#if 0 + #if 0 if (IS_TUBE(Feld[jx][jy]) || IS_TUBE(Back[jx][jy])) #else @@ -8959,8 +9165,15 @@ int DigField(struct PlayerInfo *player, return MF_NO_ACTION; /* tube has no opening in this direction */ } - if (IS_CUSTOM_ELEMENT(Feld[jx][jy]) && IS_WALKABLE(Feld[jx][jy]) && - !(element_info[Feld[jx][jy]].access_direction & move_direction)) +#else + + if (IS_TUBE(Back[jx][jy]) && game.engine_version >= VERSION_IDENT(2,2,0,0)) + old_element = Back[jx][jy]; + +#endif + + if (IS_WALKABLE(old_element) && + !(element_info[old_element].access_direction & move_direction)) return MF_NO_ACTION; /* field has no opening in this direction */ element = Feld[x][y]; @@ -9035,6 +9248,7 @@ int DigField(struct PlayerInfo *player, PlayLevelSound(x, y, SND_CLASS_SP_PORT_PASSING); break; +#if 0 case EL_TUBE_ANY: case EL_TUBE_VERTICAL: case EL_TUBE_HORIZONTAL: @@ -9077,6 +9291,7 @@ int DigField(struct PlayerInfo *player, PlayLevelSound(x, y, SND_CLASS_TUBE_WALKING); } break; +#endif default: @@ -9084,8 +9299,7 @@ int DigField(struct PlayerInfo *player, { int sound_action = ACTION_WALKING; - if (IS_CUSTOM_ELEMENT(element) && - !(element_info[element].access_direction & opposite_direction)) + if (!(element_info[element].access_direction & opposite_direction)) return MF_NO_ACTION; /* field not accessible from this direction */ if (element >= EL_GATE_1 && element <= EL_GATE_4) @@ -9294,7 +9508,7 @@ int DigField(struct PlayerInfo *player, return MF_NO_ACTION; if (CAN_FALL(element) && IN_LEV_FIELD(x, y + 1) && IS_FREE(x, y + 1) && - !(element == EL_SPRING && use_spring_bug)) + !(element == EL_SPRING && level.use_spring_bug)) return MF_NO_ACTION; #if 1 @@ -9612,7 +9826,7 @@ boolean SnapField(struct PlayerInfo *player, int dx, int dy) player->is_dropping = FALSE; - if (DigField(player, x, y, 0, 0, DF_SNAP) == MF_NO_ACTION) + if (DigField(player, jx, jy, x, y, 0, 0, DF_SNAP) == MF_NO_ACTION) return FALSE; player->is_snapping = TRUE; @@ -9711,9 +9925,13 @@ boolean DropElement(struct PlayerInfo *player) if (Feld[jx][jy] == new_element) /* uninitialized unless CE change */ { +#if 1 + InitField_WithBug1(jx, jy, FALSE); +#else InitField(jx, jy, FALSE); if (CAN_MOVE(Feld[jx][jy])) InitMovDir(jx, jy); +#endif } new_element = Feld[jx][jy];