X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=b1254556955778c3d660d44bc45a19d023a1c171;hb=f5665efaa42ea2570819237740046ff1360c4ef6;hp=a37659ec7a704f5159c1a771b4edc04ee823e9eb;hpb=7344cb1d0c4fb6c05604d93fc7e99bc678c1937e;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index a37659ec..b1254556 100644 --- a/src/game.c +++ b/src/game.c @@ -43,10 +43,12 @@ /* for Explode() */ #define EX_PHASE_START 0 -#define EX_NO_EXPLOSION 0 -#define EX_NORMAL 1 -#define EX_CENTER 2 -#define EX_BORDER 3 +#define EX_TYPE_NONE 0 +#define EX_TYPE_NORMAL (1 << 0) +#define EX_TYPE_CENTER (1 << 1) +#define EX_TYPE_BORDER (1 << 2) +#define EX_TYPE_CROSS (1 << 3) +#define EX_TYPE_SINGLE_TILE (EX_TYPE_CENTER | EX_TYPE_BORDER) /* special positions in the game control window (relative to control window) */ #define XX_LEVEL 37 @@ -98,6 +100,8 @@ #define GET_NEW_PUSH_DELAY(e) ( (element_info[e].push_delay_fixed) + \ RND(element_info[e].push_delay_random)) +#define GET_NEW_DROP_DELAY(e) ( (element_info[e].drop_delay_fixed) + \ + RND(element_info[e].drop_delay_random)) #define GET_NEW_MOVE_DELAY(e) ( (element_info[e].move_delay_fixed) + \ RND(element_info[e].move_delay_random)) #define GET_MAX_MOVE_DELAY(e) ( (element_info[e].move_delay_fixed) + \ @@ -107,6 +111,9 @@ ((e) == EL_TRIGGER_ELEMENT ? (ch)->actual_trigger_element : \ (e) == EL_TRIGGER_PLAYER ? (ch)->actual_trigger_player : (e)) +#define CAN_GROW_INTO(e) \ + (e == EL_SAND || (IS_DIGGABLE(e) && level.grow_into_diggable)) + #define ELEMENT_CAN_ENTER_FIELD_BASE_X(x, y, condition) \ (IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \ (condition))) @@ -261,6 +268,11 @@ #define IN_LEV_FIELD_AND_IS_FREE(x, y) (IN_LEV_FIELD(x, y) && IS_FREE(x, y)) #define IN_LEV_FIELD_AND_NOT_FREE(x, y) (IN_LEV_FIELD(x, y) && !IS_FREE(x, y)) +#define ACCESS_FROM(e, d) (element_info[e].access_direction &(d)) +#define IS_WALKABLE_FROM(e, d) (IS_WALKABLE(e) && ACCESS_FROM(e, d)) +#define IS_PASSABLE_FROM(e, d) (IS_PASSABLE(e) && ACCESS_FROM(e, d)) +#define IS_ACCESSIBLE_FROM(e, d) (IS_ACCESSIBLE(e) && ACCESS_FROM(e, d)) + /* game button identifiers */ #define GAME_CTRL_ID_STOP 0 #define GAME_CTRL_ID_PAUSE 1 @@ -592,7 +604,7 @@ struct int element; int direction; } -tube_access[] = +access_direction_list[] = { { EL_TUBE_ANY, MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN }, { EL_TUBE_VERTICAL, MV_UP | MV_DOWN }, @@ -606,7 +618,19 @@ tube_access[] = { EL_TUBE_RIGHT_UP, MV_RIGHT | MV_UP }, { EL_TUBE_RIGHT_DOWN, MV_RIGHT | MV_DOWN }, - { EL_UNDEFINED, 0 } + { EL_SP_PORT_LEFT, MV_RIGHT }, + { EL_SP_PORT_RIGHT, MV_LEFT }, + { EL_SP_PORT_UP, MV_DOWN }, + { EL_SP_PORT_DOWN, MV_UP }, + { EL_SP_PORT_HORIZONTAL, MV_LEFT | MV_RIGHT }, + { EL_SP_PORT_VERTICAL, MV_UP | MV_DOWN }, + { EL_SP_PORT_ANY, MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN }, + { EL_SP_GRAVITY_PORT_LEFT, MV_RIGHT }, + { EL_SP_GRAVITY_PORT_RIGHT, MV_LEFT }, + { EL_SP_GRAVITY_PORT_UP, MV_DOWN }, + { EL_SP_GRAVITY_PORT_DOWN, MV_UP }, + + { EL_UNDEFINED, MV_NO_MOVING } }; static unsigned long trigger_events[MAX_NUM_ELEMENTS]; @@ -975,9 +999,10 @@ static inline void InitField_WithBug2(int x, int y, boolean init_game) /* 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) - - */ + field _before_ the call to InitField() (which can change it); lastly, it + was not called for "mole with direction" elements, which were treated as + "cannot move" due to (fixed) wrong element initialization in "src/init.c" + */ } inline void DrawGameValue_Emeralds(int value) @@ -1201,6 +1226,10 @@ static void InitGameEngine() ei->change->post_change_function = ch_delay->post_change_function; ei->change_events |= CH_EVENT_BIT(CE_DELAY); + +#if 1 + SET_PROPERTY(ch_delay->element, EP_CAN_CHANGE, TRUE); +#endif } #if 1 @@ -1345,6 +1374,7 @@ static void InitGameEngine() element_info[e].move_stepsize = move_stepsize_list[i].move_stepsize; } +#if 0 /* ---------- initialize move dig/leave ---------------------------------- */ for (i = 0; i < MAX_NUM_ELEMENTS; i++) @@ -1352,6 +1382,7 @@ static void InitGameEngine() element_info[i].can_leave_element = FALSE; element_info[i].can_leave_element_last = FALSE; } +#endif /* ---------- initialize gem count --------------------------------------- */ @@ -1367,15 +1398,15 @@ static void InitGameEngine() /* ---------- initialize access direction -------------------------------- */ - /* initialize access direction values to default */ + /* initialize access direction values to default (access from every side) */ 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; + for (i = 0; access_direction_list[i].element != EL_UNDEFINED; i++) + element_info[access_direction_list[i].element].access_direction = + access_direction_list[i].direction; } @@ -1459,6 +1490,7 @@ void InitGame() player->is_waiting = FALSE; player->is_moving = FALSE; + player->is_auto_moving = FALSE; player->is_digging = FALSE; player->is_snapping = FALSE; player->is_collecting = FALSE; @@ -1609,7 +1641,7 @@ void InitGame() ExplodePhase[x][y] = 0; ExplodeDelay[x][y] = 0; - ExplodeField[x][y] = EX_NO_EXPLOSION; + ExplodeField[x][y] = EX_TYPE_NONE; RunnerVisit[x][y] = 0; PlayerVisit[x][y] = 0; @@ -1649,7 +1681,7 @@ void InitGame() if (!IS_CUSTOM_ELEMENT(i)) { int num_phase = 8; - int delay = ((IS_SP_ELEMENT(i) && + int delay = (((IS_SP_ELEMENT(i) && i != EL_EMPTY_SPACE) && game.engine_version >= VERSION_IDENT(3,1,0,0)) || game.emulation == EMU_SUPAPLEX ? 3 : 2); int last_phase = (num_phase + 1) * delay; @@ -2070,6 +2102,12 @@ void InitMovDir(int x, int y) else if (move_pattern == MV_ALONG_LEFT_SIDE || move_pattern == MV_ALONG_RIGHT_SIDE) { +#if 1 + /* use random direction as default start direction */ + if (game.engine_version >= VERSION_IDENT(3,1,0,2)) + MovDir[x][y] = 1 << RND(4); +#endif + for (i = 0; i < NUM_DIRECTIONS; i++) { int x1 = x + xy[i][0]; @@ -2610,20 +2648,16 @@ void RelocatePlayer(int x, int y, int element_raw) int element = (element_raw == EL_SP_MURPHY ? EL_PLAYER_1 : element_raw); struct PlayerInfo *player = &stored_player[element - EL_PLAYER_1]; boolean ffwd_delay = (tape.playing && tape.fast_forward); - boolean no_delay = (tape.index_search); + boolean no_delay = (tape.warp_forward); int frame_delay_value = (ffwd_delay ? FfwdFrameDelay : GameFrameDelay); int wait_delay_value = (no_delay ? 0 : frame_delay_value); -#if 1 int old_jx, old_jy; -#endif if (player->GameOver) /* do not reanimate dead player */ return; -#if 1 RemoveField(x, y); /* temporarily remove newly placed player */ DrawLevelField(x, y); -#endif if (player->present) { @@ -2645,19 +2679,51 @@ void RelocatePlayer(int x, int y, int element_raw) player->is_moving = FALSE; } -#if 1 old_jx = player->jx; old_jy = player->jy; -#endif Feld[x][y] = element; InitPlayerField(x, y, element, TRUE); -#if 0 - if (player == local_player) + if (player != local_player) /* do not visually relocate other players */ + return; + + if (level.instant_relocation) { #if 1 + int offset = (setup.scroll_delay ? 3 : 0); + int jx = local_player->jx; + int jy = local_player->jy; + if (!IN_VIS_FIELD(SCREENX(jx), SCREENY(jy))) + { + scroll_x = (local_player->jx < SBX_Left + MIDPOSX ? SBX_Left : + local_player->jx > SBX_Right + MIDPOSX ? SBX_Right : + local_player->jx - MIDPOSX); + + scroll_y = (local_player->jy < SBY_Upper + MIDPOSY ? SBY_Upper : + local_player->jy > SBY_Lower + MIDPOSY ? SBY_Lower : + local_player->jy - MIDPOSY); + } + else + { + 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); + + 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_x < SBX_Left || scroll_x > SBX_Right) + scroll_x = (scroll_x < SBX_Left ? SBX_Left : SBX_Right); + + /* 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); + } +#else scroll_x += (local_player->jx - old_jx); scroll_y += (local_player->jy - old_jy); @@ -2668,30 +2734,69 @@ void RelocatePlayer(int x, int y, int element_raw) /* 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); - -#else - scroll_x = (local_player->jx < SBX_Left + MIDPOSX ? SBX_Left : - local_player->jx > SBX_Right + MIDPOSX ? SBX_Right : - local_player->jx - MIDPOSX); - - scroll_y = (local_player->jy < SBY_Upper + MIDPOSY ? SBY_Upper : - local_player->jy > SBY_Lower + MIDPOSY ? SBY_Lower : - local_player->jy - MIDPOSY); #endif RedrawPlayfield(TRUE, 0,0,0,0); + } + else + { +#if 1 #if 0 - DrawAllPlayers(); - BackToFront(); + int offset = (setup.scroll_delay ? 3 : 0); + int jx = local_player->jx; + int jy = local_player->jy; #endif - } + int scroll_xx = -999, scroll_yy = -999; + + ScrollScreen(NULL, SCROLL_GO_ON); /* scroll last frame to full tile */ + + while (scroll_xx != scroll_x || scroll_yy != scroll_y) + { + int dx = 0, dy = 0; + int fx = FX, fy = FY; + + scroll_xx = (local_player->jx < SBX_Left + MIDPOSX ? SBX_Left : + local_player->jx > SBX_Right + MIDPOSX ? SBX_Right : + local_player->jx - MIDPOSX); + scroll_yy = (local_player->jy < SBY_Upper + MIDPOSY ? SBY_Upper : + local_player->jy > SBY_Lower + MIDPOSY ? SBY_Lower : + local_player->jy - MIDPOSY); + + dx = (scroll_xx < scroll_x ? +1 : scroll_xx > scroll_x ? -1 : 0); + dy = (scroll_yy < scroll_y ? +1 : scroll_yy > scroll_y ? -1 : 0); + +#if 1 + if (dx == 0 && dy == 0) /* no scrolling needed at all */ + break; #else + if (scroll_xx == scroll_x && scroll_yy == scroll_y) + break; +#endif - if (player == local_player) - { + scroll_x -= dx; + scroll_y -= dy; + + fx += dx * TILEX / 2; + fy += dy * TILEY / 2; + + 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); + } +#else int scroll_xx = -999, scroll_yy = -999; + ScrollScreen(NULL, SCROLL_GO_ON); /* scroll last frame to full tile */ + while (scroll_xx != scroll_x || scroll_yy != scroll_y) { int dx = 0, dy = 0; @@ -2708,6 +2813,14 @@ void RelocatePlayer(int x, int y, int element_raw) dx = (scroll_xx < scroll_x ? +1 : scroll_xx > scroll_x ? -1 : 0); dy = (scroll_yy < scroll_y ? +1 : scroll_yy > scroll_y ? -1 : 0); +#if 1 + if (dx == 0 && dy == 0) /* no scrolling needed at all */ + break; +#else + if (scroll_xx == scroll_x && scroll_yy == scroll_y) + break; +#endif + scroll_x -= dx; scroll_y -= dy; @@ -2726,8 +2839,8 @@ void RelocatePlayer(int x, int y, int element_raw) BackToFront(); Delay(wait_delay_value); } - } #endif + } } void Explode(int ex, int ey, int phase, int mode) @@ -2767,11 +2880,12 @@ void Explode(int ex, int ey, int phase, int mode) /* --- 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_NORMAL || mode == EX_CENTER)) + center_element == EL_EMPTY && + (mode == EX_TYPE_NORMAL || mode == EX_TYPE_CENTER)) return; #endif - if (mode == EX_NORMAL || mode == EX_CENTER) + if (mode == EX_TYPE_NORMAL || mode == EX_TYPE_CENTER) PlayLevelSoundAction(ex, ey, ACTION_EXPLODING); /* remove things displayed in background while burning dynamite */ @@ -2806,11 +2920,20 @@ void Explode(int ex, int ey, int phase, int mode) int element; #if 1 - if (!IN_LEV_FIELD(x, y) || (mode != EX_NORMAL && (x != ex || y != ey))) +#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_NORMAL || center_element == EL_AMOEBA_TO_DIAMOND) && + ((mode != EX_TYPE_NORMAL || + center_element == EL_AMOEBA_TO_DIAMOND) && (x != ex || y != ey))) continue; #endif @@ -2949,7 +3072,7 @@ void Explode(int ex, int ey, int phase, int mode) Store[x][y] = EL_EMPTY; if (x != ex || y != ey || - center_element == EL_AMOEBA_TO_DIAMOND || mode == EX_BORDER) + center_element == EL_AMOEBA_TO_DIAMOND || mode == EX_TYPE_BORDER) Store2[x][y] = element; #if 0 @@ -3139,6 +3262,10 @@ void Explode(int ex, int ey, int phase, int mode) { int element; +#if 0 + printf("::: done: phase == %d\n", phase); +#endif + #if 0 printf("::: explosion %d,%d done [%d]\n", x, y, FrameCounter); #endif @@ -3272,7 +3399,7 @@ void DynaExplode(int ex, int ey) player->dynabombs_left++; } - Explode(ex, ey, EX_PHASE_START, EX_CENTER); + Explode(ex, ey, EX_PHASE_START, EX_TYPE_CENTER); for (i = 0; i < NUM_DIRECTIONS; i++) { @@ -3291,14 +3418,18 @@ void DynaExplode(int ex, int ey) if (element == EL_EXPLOSION && IS_ACTIVE_BOMB(Store2[x][y])) continue; - Explode(x, y, EX_PHASE_START, EX_BORDER); + Explode(x, y, EX_PHASE_START, EX_TYPE_BORDER); +#if 1 + if (element != EL_EMPTY && element != EL_EXPLOSION && + !CAN_GROW_INTO(element) && !dynabomb_xl) + break; +#else /* !!! extend EL_SAND to anything diggable (but maybe not SP_BASE) !!! */ - if (element != EL_EMPTY && - element != EL_SAND && - element != EL_EXPLOSION && - !dynabomb_xl) + if (element != EL_EMPTY && element != EL_EXPLOSION && + element != EL_SAND && !dynabomb_xl) break; +#endif } } } @@ -3351,7 +3482,7 @@ void Bang(int x, int y) case EL_PACMAN: case EL_MOLE: RaiseScoreElement(element); - Explode(x, y, EX_PHASE_START, EX_NORMAL); + Explode(x, y, EX_PHASE_START, EX_TYPE_NORMAL); break; case EL_DYNABOMB_PLAYER_1_ACTIVE: case EL_DYNABOMB_PLAYER_2_ACTIVE: @@ -3369,17 +3500,21 @@ void Bang(int x, int y) case EL_AMOEBA_TO_DIAMOND: #endif if (IS_PLAYER(x, y)) - Explode(x, y, EX_PHASE_START, EX_NORMAL); + Explode(x, y, EX_PHASE_START, EX_TYPE_NORMAL); else - Explode(x, y, EX_PHASE_START, EX_CENTER); + Explode(x, y, EX_PHASE_START, EX_TYPE_CENTER); break; default: - if (CAN_EXPLODE_DYNA(element)) + if (CAN_EXPLODE_CROSS(element)) +#if 1 + Explode(x, y, EX_PHASE_START, EX_TYPE_CROSS); +#else DynaExplode(x, y); +#endif else if (CAN_EXPLODE_1X1(element)) - Explode(x, y, EX_PHASE_START, EX_CENTER); + Explode(x, y, EX_PHASE_START, EX_TYPE_CENTER); else - Explode(x, y, EX_PHASE_START, EX_NORMAL); + Explode(x, y, EX_PHASE_START, EX_TYPE_NORMAL); break; } @@ -5234,11 +5369,30 @@ void StartMoving(int x, int 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 +#if 0 + if (ChangeDelay[xx][yy]) + printf("::: !!! [%d]\n", (IS_MOVING(xx, yy) || + Feld[xx][yy] == EL_BLOCKED)); +#endif + +#if 1 + ChangeDelay[xx][yy] = 0; +#endif Feld[xx][yy] = EL_FLAMES; if (IN_SCR_FIELD(sx, sy)) { @@ -5438,8 +5592,21 @@ void StartMoving(int x, int y) PlayLevelSoundAction(x, y, action); } +#if 1 +#if 1 + Store[newx][newy] = EL_EMPTY; + if (IS_EQUAL_OR_IN_GROUP(new_element, MOVE_ENTER_EL(element))) + Store[newx][newy] = element_info[element].move_leave_element; +#else + Store[newx][newy] = EL_EMPTY; + if (IS_EQUAL_OR_IN_GROUP(new_element, MOVE_ENTER_EL(element)) || + element_info[element].move_leave_type == LEAVE_TYPE_UNLIMITED) + Store[newx][newy] = element_info[element].move_leave_element; +#endif +#else if (IS_EQUAL_OR_IN_GROUP(new_element, MOVE_ENTER_EL(element))) element_info[element].can_leave_element = TRUE; +#endif if (move_pattern & MV_MAZE_RUNNER_STYLE) { @@ -5492,11 +5659,25 @@ void StartMoving(int x, int y) 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; } @@ -5628,6 +5809,7 @@ void StartMoving(int x, int y) void ContinueMoving(int x, int y) { int element = Feld[x][y]; + int stored = Store[x][y]; struct ElementInfo *ei = &element_info[element]; int direction = MovDir[x][y]; int dx = (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0); @@ -5732,16 +5914,34 @@ void ContinueMoving(int x, int y) { element = Feld[newx][newy] = EL_ACID; } +#if 0 + else if (IS_CUSTOM_ELEMENT(element) && !IS_PLAYER(x, y) && + ei->move_leave_element != EL_EMPTY && + (ei->move_leave_type == LEAVE_TYPE_UNLIMITED || + Store[x][y] != EL_EMPTY)) + { + /* some elements can leave other elements behind after moving */ + + Feld[x][y] = ei->move_leave_element; + InitField(x, y, FALSE); - Store[x][y] = 0; + if (GFX_CRUMBLED(Feld[x][y])) + DrawLevelFieldCrumbledSandNeighbours(x, y); + } +#endif + + Store[x][y] = EL_EMPTY; MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0; MovDelay[newx][newy] = 0; - /* copy element change control values to new field */ - ChangeDelay[newx][newy] = ChangeDelay[x][y]; - ChangePage[newx][newy] = ChangePage[x][y]; - Changed[newx][newy] = Changed[x][y]; - ChangeEvent[newx][newy] = ChangeEvent[x][y]; + if (CAN_CHANGE(element)) + { + /* copy element change control values to new field */ + ChangeDelay[newx][newy] = ChangeDelay[x][y]; + ChangePage[newx][newy] = ChangePage[x][y]; + Changed[newx][newy] = Changed[x][y]; + ChangeEvent[newx][newy] = ChangeEvent[x][y]; + } ChangeDelay[x][y] = 0; ChangePage[x][y] = -1; @@ -5759,6 +5959,22 @@ void ContinueMoving(int x, int y) ResetGfxAnimation(x, y); /* reset animation values for old field */ #if 1 + if (IS_CUSTOM_ELEMENT(element) && !IS_PLAYER(x, y) && + ei->move_leave_element != EL_EMPTY && + (ei->move_leave_type == LEAVE_TYPE_UNLIMITED || + stored != EL_EMPTY)) + { + /* some elements can leave other elements behind after moving */ + + Feld[x][y] = ei->move_leave_element; + InitField(x, y, FALSE); + + if (GFX_CRUMBLED(Feld[x][y])) + DrawLevelFieldCrumbledSandNeighbours(x, y); + } +#endif + +#if 0 /* some elements can leave other elements behind after moving */ if (IS_CUSTOM_ELEMENT(element) && !IS_PLAYER(x, y) && ei->move_leave_element != EL_EMPTY && @@ -5793,9 +6009,18 @@ void ContinueMoving(int x, int y) MovDir[newx][newy] = 0; */ +#if 0 if (!CAN_MOVE(element) || (CAN_FALL(element) && direction == MV_DOWN)) GfxDir[x][y] = MovDir[newx][newy] = 0; +#else + 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; +#endif #endif #endif @@ -6232,6 +6457,15 @@ void AmoebeAbleger(int ax, int ay) if (!IN_LEV_FIELD(x, y)) return; +#if 1 + if (IS_FREE(x, y) || + CAN_GROW_INTO(Feld[x][y]) || + Feld[x][y] == EL_QUICKSAND_EMPTY) + { + newax = x; + neway = y; + } +#else /* !!! extend EL_SAND to anything diggable (but maybe not SP_BASE) !!! */ if (IS_FREE(x, y) || Feld[x][y] == EL_SAND || Feld[x][y] == EL_QUICKSAND_EMPTY) @@ -6239,6 +6473,7 @@ void AmoebeAbleger(int ax, int ay) newax = x; neway = y; } +#endif if (newax == ax && neway == ay) return; @@ -6257,6 +6492,16 @@ void AmoebeAbleger(int ax, int ay) if (!IN_LEV_FIELD(x, y)) continue; +#if 1 + if (IS_FREE(x, y) || + CAN_GROW_INTO(Feld[x][y]) || + Feld[x][y] == EL_QUICKSAND_EMPTY) + { + newax = x; + neway = y; + break; + } +#else /* !!! extend EL_SAND to anything diggable (but maybe not SP_BASE) !!! */ if (IS_FREE(x, y) || Feld[x][y] == EL_SAND || Feld[x][y] == EL_QUICKSAND_EMPTY) @@ -6265,6 +6510,7 @@ void AmoebeAbleger(int ax, int ay) neway = y; break; } +#endif else if (IS_PLAYER(x, y)) waiting_for_player = TRUE; } @@ -6402,6 +6648,20 @@ void Life(int ax, int ay) changed = TRUE; } } +#if 1 + else if (IS_FREE(xx, yy) || CAN_GROW_INTO(Feld[xx][yy])) + { /* free border field */ + if (nachbarn >= life[2] && nachbarn <= life[3]) + { + Feld[xx][yy] = element; + MovDelay[xx][yy] = (element == EL_GAME_OF_LIFE ? 0 : life_time-1); + if (!Stop[xx][yy]) + DrawLevelField(xx, yy); + Stop[xx][yy] = TRUE; + changed = TRUE; + } + } +#else /* !!! extend EL_SAND to anything diggable (but maybe not SP_BASE) !!! */ else if (IS_FREE(xx, yy) || Feld[xx][yy] == EL_SAND) { /* free border field */ @@ -6415,6 +6675,7 @@ void Life(int ax, int ay) changed = TRUE; } } +#endif } if (changed) @@ -7035,9 +7296,8 @@ static void ChangeElement(int x, int y, int page) struct ElementInfo *ei = &element_info[element]; struct ElementChangeInfo *change = &ei->change_page[page]; -#if 0 #ifdef DEBUG - if (!CAN_CHANGE(element)) + if (!CAN_CHANGE(element) && !CAN_CHANGE(Back[x][y])) { printf("\n\n"); printf("ChangeElement(): %d,%d: element = %d ('%s')\n", @@ -7046,8 +7306,18 @@ static void ChangeElement(int x, int y, int page) printf("\n\n"); } #endif + + /* this can happen with classic bombs on walkable, changing elements */ + if (!CAN_CHANGE(element)) + { +#if 0 + if (!CAN_CHANGE(Back[x][y])) /* prevent permanent repetition */ + ChangeDelay[x][y] = 0; #endif + return; + } + if (ChangeDelay[x][y] == 0) /* initialize element change */ { ChangeDelay[x][y] = ( change->delay_fixed * change->delay_frames + @@ -7191,6 +7461,20 @@ static boolean CheckElementChangeExt(int x, int y, element = Feld[x][y]; } +#if 1 + if (Feld[x][y] != element) /* check if element has already changed */ + { +#if 0 + printf("::: %d ('%s') != %d ('%s') [%d]\n", + Feld[x][y], element_info[Feld[x][y]].token_name, + element, element_info[element].token_name, + trigger_event); +#endif + + return FALSE; + } +#endif + #if 1 if (trigger_page < 0) { @@ -7608,7 +7892,7 @@ void GameActions() action_delay_value = (tape.playing && tape.fast_forward ? FfwdFrameDelay : GameFrameDelay); - if (tape.playing && tape.index_search && !tape.pausing) + if (tape.playing && tape.warp_forward && !tape.pausing) action_delay_value = 0; /* ---------- main game synchronization point ---------- */ @@ -7992,7 +8276,7 @@ void GameActions() CheckDynamite(x, y); #if 0 else if (element == EL_EXPLOSION && !game.explosions_delayed) - Explode(x, y, ExplodePhase[x][y], EX_NORMAL); + Explode(x, y, ExplodePhase[x][y], EX_TYPE_NORMAL); #endif else if (element == EL_AMOEBA_GROWING) AmoebeWaechst(x, y); @@ -8075,6 +8359,21 @@ void GameActions() #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 || @@ -8089,6 +8388,7 @@ void GameActions() (IN_LEV_FIELD(x, y+1) && Feld[x][y+1] == EL_AMOEBA_WET)) Feld[x][y] = EL_AMOEBA_DROP; } +#endif random = random * 129 + 1; } @@ -8108,9 +8408,9 @@ void GameActions() 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_NORMAL); + Explode(x, y, ExplodePhase[x][y], EX_TYPE_NORMAL); - ExplodeField[x][y] = EX_NO_EXPLOSION; + ExplodeField[x][y] = EX_TYPE_NONE; } game.explosions_delayed = TRUE; @@ -8361,6 +8661,7 @@ void ScrollLevel(int dx, int dy) redraw_mask |= REDRAW_FIELD; } +#if 0 static boolean canEnterSupaplexPort(int x, int y, int dx, int dy) { int nextx = x + dx, nexty = y + dy; @@ -8392,6 +8693,63 @@ static boolean canEnterSupaplexPort(int x, int y, int dx, int dy) 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_DIGGABLE(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 +} static void CheckGravityMovement(struct PlayerInfo *player) { @@ -8404,56 +8762,97 @@ static void CheckGravityMovement(struct PlayerInfo *player) 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)); - int jx = player->jx, jy = player->jy; +#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; -#if 1 - boolean player_is_snapping = player->effective_action & JOY_BUTTON_1; -#else - boolean player_is_snapping = player->action & JOY_BUTTON_1; + 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)))); + 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]) && - !(element_info[Feld[jx][jy]].access_direction & MV_DOWN))); + (IS_WALKABLE(Feld[jx][jy]) && !ACCESS_FROM(Feld[jx][jy], MV_DOWN))); +#endif #if 0 - printf("::: checking gravity NOW [%d, %d, %d] [%d] ...\n", + 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_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 @@ -8575,7 +8974,9 @@ boolean MovePlayerOneStep(struct PlayerInfo *player, player->step_counter++; +#if 0 player->drop_delay = 0; +#endif PlayerVisit[jx][jy] = FrameCounter; @@ -8646,6 +9047,9 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) #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; @@ -8708,7 +9112,7 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) { if (jx != old_jx) /* player has moved horizontally */ { - if ((player->MovDir == MV_LEFT && scroll_x > jx - MIDPOSX + offset) || + 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); @@ -8720,13 +9124,13 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) 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) || + 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) || + 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); @@ -8738,7 +9142,7 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) 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) || + if ((player->MovDir == MV_UP && scroll_y > old_scroll_y) || (player->MovDir == MV_DOWN && scroll_y < old_scroll_y)) scroll_y = old_scroll_y; } @@ -8792,7 +9196,8 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) player->is_dropping = FALSE; -#if 1 +#if 0 + /* !!! ENABLE THIS FOR OLD VERSIONS !!! */ { static int trigger_sides[4][2] = { @@ -8807,24 +9212,22 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) int leave_side = trigger_sides[MV_DIR_BIT(move_direction)][1]; #if 1 + CheckTriggeredElementChangePlayer(old_jx, old_jy, Feld[old_jx][old_jy], + CE_OTHER_GETS_LEFT, + player->index_bit, leave_side); + if (IS_CUSTOM_ELEMENT(Feld[old_jx][old_jy])) - { - CheckTriggeredElementChangePlayer(old_jx, old_jy, Feld[old_jx][old_jy], - CE_OTHER_GETS_LEFT, - player->index_bit, leave_side); CheckElementChangePlayer(old_jx, old_jy, Feld[old_jx][old_jy], CE_LEFT_BY_PLAYER, player->index_bit, leave_side); - } + + CheckTriggeredElementChangePlayer(jx, jy, Feld[jx][jy], + CE_OTHER_GETS_ENTERED, + player->index_bit, enter_side); if (IS_CUSTOM_ELEMENT(Feld[jx][jy])) - { - CheckTriggeredElementChangePlayer(jx, jy, Feld[jx][jy], - CE_OTHER_GETS_ENTERED, - player->index_bit, enter_side); CheckElementChangePlayer(jx, jy, Feld[jx][jy], CE_ENTERED_BY_PLAYER, player->index_bit, enter_side); - } #endif } @@ -8941,8 +9344,9 @@ void ScrollPlayer(struct PlayerInfo *player, int mode) player->LevelSolved = player->GameOver = TRUE; } -#if 0 +#if 1 /* !!! ENABLE THIS FOR NEW VERSIONS !!! */ + /* this breaks one level: "machine", level 000 */ { static int trigger_sides[4][2] = { @@ -8959,24 +9363,22 @@ void ScrollPlayer(struct PlayerInfo *player, int mode) int old_jy = last_jy; #if 1 + CheckTriggeredElementChangePlayer(old_jx, old_jy, Feld[old_jx][old_jy], + CE_OTHER_GETS_LEFT, + player->index_bit, leave_side); + if (IS_CUSTOM_ELEMENT(Feld[old_jx][old_jy])) - { - CheckTriggeredElementChangePlayer(old_jx, old_jy, Feld[old_jx][old_jy], - CE_OTHER_GETS_LEFT, - player->index_bit, leave_side); CheckElementChangePlayer(old_jx, old_jy, Feld[old_jx][old_jy], CE_LEFT_BY_PLAYER, player->index_bit, leave_side); - } + + CheckTriggeredElementChangePlayer(jx, jy, Feld[jx][jy], + CE_OTHER_GETS_ENTERED, + player->index_bit, enter_side); if (IS_CUSTOM_ELEMENT(Feld[jx][jy])) - { - CheckTriggeredElementChangePlayer(jx, jy, Feld[jx][jy], - CE_OTHER_GETS_ENTERED, - player->index_bit, enter_side); CheckElementChangePlayer(jx, jy, Feld[jx][jy], CE_ENTERED_BY_PLAYER, player->index_bit, enter_side); - } #endif } @@ -9895,8 +10297,10 @@ int DigField(struct PlayerInfo *player, #endif - if (IS_WALKABLE(old_element) && - !(element_info[old_element].access_direction & move_direction)) + if (IS_WALKABLE(old_element) && !ACCESS_FROM(old_element, move_direction)) + return MF_NO_ACTION; /* field has no opening in this direction */ + + if (IS_PASSABLE(old_element) && !ACCESS_FROM(old_element,opposite_direction)) return MF_NO_ACTION; /* field has no opening in this direction */ element = Feld[x][y]; @@ -9907,6 +10311,7 @@ int DigField(struct PlayerInfo *player, switch (element) { +#if 0 case EL_SP_PORT_LEFT: case EL_SP_PORT_RIGHT: case EL_SP_PORT_UP: @@ -9974,6 +10379,7 @@ int DigField(struct PlayerInfo *player, PlayLevelSound(x, y, SND_CLASS_SP_PORT_PASSING); break; +#endif #if 0 case EL_TUBE_ANY: @@ -10026,15 +10432,22 @@ int DigField(struct PlayerInfo *player, { int sound_action = ACTION_WALKING; - if (!(element_info[element].access_direction & opposite_direction)) + if (!ACCESS_FROM(element, opposite_direction)) return MF_NO_ACTION; /* field not accessible from this direction */ - if (element >= EL_GATE_1 && element <= EL_GATE_4) +#if 1 + if (element == EL_EMPTY_SPACE && + game.gravity && !player->is_auto_moving && + canFallDown(player) && move_direction != MV_DOWN) + return MF_NO_ACTION; /* player cannot walk here due to gravity */ +#endif + + if (IS_GATE(element)) { if (!player->key[element - EL_GATE_1]) return MF_NO_ACTION; } - else if (element >= EL_GATE_1_GRAY && element <= EL_GATE_4_GRAY) + else if (IS_GATE_GRAY(element)) { if (!player->key[element - EL_GATE_1_GRAY]) return MF_NO_ACTION; @@ -10060,28 +10473,55 @@ int DigField(struct PlayerInfo *player, } else if (IS_PASSABLE(element)) { +#if 1 + if (!canPassField(x, y, move_direction)) + return MF_NO_ACTION; +#else + +#if 1 + if (!IN_LEV_FIELD(nextx, nexty) || IS_PLAYER(nextx, nexty) || + !IS_WALKABLE_FROM(Feld[nextx][nexty], move_direction) || + (!level.can_pass_to_walkable && !IS_FREE(nextx, nexty))) + return MF_NO_ACTION; +#else if (!IN_LEV_FIELD(nextx, nexty) || !IS_FREE(nextx, nexty)) return MF_NO_ACTION; +#endif +#if 1 + if (!ACCESS_FROM(element, opposite_direction)) + return MF_NO_ACTION; /* field not accessible from this direction */ +#else if (IS_CUSTOM_ELEMENT(element) && - !(element_info[element].access_direction & opposite_direction)) + !ACCESS_FROM(element, opposite_direction)) return MF_NO_ACTION; /* field not accessible from this direction */ +#endif #if 1 if (CAN_MOVE(element)) /* only fixed elements can be passed! */ return MF_NO_ACTION; #endif - if (element >= EL_EM_GATE_1 && element <= EL_EM_GATE_4) +#endif + + if (IS_EM_GATE(element)) { if (!player->key[element - EL_EM_GATE_1]) return MF_NO_ACTION; } - else if (element >= EL_EM_GATE_1_GRAY && element <= EL_EM_GATE_4_GRAY) + else if (IS_EM_GATE_GRAY(element)) { if (!player->key[element - EL_EM_GATE_1_GRAY]) return MF_NO_ACTION; } + else if (IS_SP_PORT(element)) + { + if (element == EL_SP_GRAVITY_PORT_LEFT || + element == EL_SP_GRAVITY_PORT_RIGHT || + element == EL_SP_GRAVITY_PORT_UP || + element == EL_SP_GRAVITY_PORT_DOWN) + game.gravity = !game.gravity; + } /* automatically move to the next field with double speed */ player->programmed_action = move_direction; @@ -10120,7 +10560,7 @@ int DigField(struct PlayerInfo *player, PlayLevelSoundElementAction(x, y, element, ACTION_DIGGING); CheckTriggeredElementChangePlayer(x, y, element, CE_OTHER_GETS_DIGGED, - player->index_bit, CH_SIDE_ANY); + player->index_bit, dig_side); #if 1 if (mode == DF_SNAP) @@ -10220,7 +10660,7 @@ int DigField(struct PlayerInfo *player, CheckTriggeredElementChangePlayer(x, y, element, CE_OTHER_GETS_COLLECTED, - player->index_bit, CH_SIDE_ANY); + player->index_bit, dig_side); #if 1 if (mode == DF_SNAP) @@ -10585,15 +11025,25 @@ boolean SnapField(struct PlayerInfo *player, int dx, int dy) boolean DropElement(struct PlayerInfo *player) { + static int trigger_sides[4] = + { + CH_SIDE_LEFT, /* dropping left */ + CH_SIDE_RIGHT, /* dropping right */ + CH_SIDE_TOP, /* dropping up */ + CH_SIDE_BOTTOM, /* dropping down */ + }; int jx = player->jx, jy = player->jy; + int drop_direction = player->MovDir; + int drop_side = trigger_sides[MV_DIR_BIT(drop_direction)]; int old_element = Feld[jx][jy]; - int new_element = (player->inventory_size > 0 ? - player->inventory_element[player->inventory_size - 1] : - player->inventory_infinite_element != EL_UNDEFINED ? - player->inventory_infinite_element : - player->dynabombs_left > 0 ? - EL_DYNABOMB_PLAYER_1_ACTIVE + player->index_nr : - EL_UNDEFINED); + int drop_element = (player->inventory_size > 0 ? + player->inventory_element[player->inventory_size - 1] : + player->inventory_infinite_element != EL_UNDEFINED ? + player->inventory_infinite_element : + player->dynabombs_left > 0 ? + EL_DYNABOMB_PLAYER_1_ACTIVE + player->index_nr : + EL_UNDEFINED); + int new_element = drop_element; /* default: element does not change */ /* check if player is active, not moving and ready to drop */ if (!player->active || player->MovPos || player->drop_delay > 0) @@ -10662,11 +11112,20 @@ boolean DropElement(struct PlayerInfo *player) Changed[jx][jy] = 0; /* allow another change */ #endif +#if 1 + /* !!! TEST ONLY !!! */ + CheckElementChangePlayer(jx, jy, new_element, CE_DROPPED_BY_PLAYER, + player->index_bit, drop_side); + CheckTriggeredElementChangePlayer(jx, jy, new_element, + CE_OTHER_GETS_DROPPED, + player->index_bit, drop_side); +#else CheckTriggeredElementChangePlayer(jx, jy, new_element, CE_OTHER_GETS_DROPPED, - player->index_bit, CH_SIDE_ANY); + player->index_bit, drop_side); CheckElementChangePlayer(jx, jy, new_element, CE_DROPPED_BY_PLAYER, - player->index_bit, CH_SIDE_ANY); + player->index_bit, drop_side); +#endif TestIfElementTouchesCustomElement(jx, jy); } @@ -10701,12 +11160,14 @@ boolean DropElement(struct PlayerInfo *player) #endif } - new_element = Feld[jx][jy]; + new_element = Feld[jx][jy]; /* element might have changed */ if (IS_CUSTOM_ELEMENT(new_element) && CAN_MOVE(new_element) && element_info[new_element].move_pattern == MV_WHEN_DROPPED) { +#if 0 int move_stepsize = element_info[new_element].move_stepsize; +#endif int direction, dx, dy, nextx, nexty; if (element_info[new_element].move_direction_initial == MV_START_AUTOMATIC) @@ -10739,13 +11200,19 @@ boolean DropElement(struct PlayerInfo *player) #endif } +#if 0 player->drop_delay = 2 * TILEX / move_stepsize + 1; +#endif } #if 0 player->drop_delay = 8 + 8 + 8; #endif +#if 1 + player->drop_delay = GET_NEW_DROP_DELAY(drop_element); +#endif + #endif player->is_dropping = TRUE; @@ -10971,21 +11438,15 @@ void RequestQuitGame(boolean ask_if_really_quit) { #if 1 - if (tape.playing && tape.index_search) - { - SetDrawDeactivationMask(REDRAW_NONE); - audio.sound_deactivated = FALSE; - } + if (tape.playing && tape.deactivate_display) + TapeDeactivateDisplayOff(TRUE); #endif OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK); #if 1 - if (tape.playing && tape.index_search) - { - SetDrawDeactivationMask(REDRAW_FIELD); - audio.sound_deactivated = TRUE; - } + if (tape.playing && tape.deactivate_display) + TapeDeactivateDisplayOn(); #endif }