int element = Feld[jx][jy];
boolean player_relocated = (old_jx != jx || old_jy != jy);
+ int move_dir_horiz = (jx < old_jx ? MV_LEFT : jx > old_jx ? MV_RIGHT : 0);
+ int move_dir_vert = (jy < old_jy ? MV_UP : jy > old_jy ? MV_DOWN : 0);
+#if 1
+ int enter_side_horiz = MV_DIR_OPPOSITE(move_dir_horiz);
+ int enter_side_vert = MV_DIR_OPPOSITE(move_dir_vert);
+ int leave_side_horiz = move_dir_horiz;
+ int leave_side_vert = move_dir_vert;
+#else
static int trigger_sides[4][2] =
{
/* enter side leave side */
{ CH_SIDE_BOTTOM, CH_SIDE_TOP }, /* moving up */
{ CH_SIDE_TOP, CH_SIDE_BOTTOM } /* moving down */
};
- int move_dir_horiz = (jx < old_jx ? MV_LEFT : jx > old_jx ? MV_RIGHT : 0);
- int move_dir_vert = (jy < old_jy ? MV_UP : jy > old_jy ? MV_DOWN : 0);
int enter_side_horiz = trigger_sides[MV_DIR_BIT(move_dir_horiz)][0];
int enter_side_vert = trigger_sides[MV_DIR_BIT(move_dir_vert)][0];
- int enter_side = enter_side_horiz | enter_side_vert;
int leave_side_horiz = trigger_sides[MV_DIR_BIT(move_dir_horiz)][1];
int leave_side_vert = trigger_sides[MV_DIR_BIT(move_dir_vert)][1];
+#endif
+ int enter_side = enter_side_horiz | enter_side_vert;
int leave_side = leave_side_horiz | leave_side_vert;
if (player->GameOver) /* do not reanimate dead player */
Changed[jx][jy] = 0; /* allow another change */
#endif
+#if 0
+ printf("::: player entering %d, %d from %s ...\n", jx, jy,
+ enter_side == MV_LEFT ? "left" :
+ enter_side == MV_RIGHT ? "right" :
+ enter_side == MV_UP ? "top" :
+ enter_side == MV_DOWN ? "bottom" : "oops! no idea!");
+#endif
+
#if 1
if (IS_CUSTOM_ELEMENT(element))
CheckElementChangeByPlayer(jx, jy, element, CE_ENTERED_BY_PLAYER,
#if 1
if (pushed_by_player)
{
+#if 1
+ int dig_side = MV_DIR_OPPOSITE(direction);
+#else
static int trigger_sides[4] =
{
CH_SIDE_RIGHT, /* moving left */
CH_SIDE_TOP, /* moving down */
};
int dig_side = trigger_sides[MV_DIR_BIT(direction)];
+#endif
struct PlayerInfo *player = PLAYERINFO(x, y);
CheckElementChangeByPlayer(newx, newy, element, CE_PUSHED_BY_PLAYER,
(IS_WALKABLE(e) && ELEM_IS_PLAYER(content_element) &&
!IS_MOVING(ex, ey) && !IS_BLOCKED(ex, ey)));
#else
+
+#if 0
is_empty = (IS_FREE(ex, ey) ||
(IS_PLAYER(ex, ey) && IS_WALKABLE(content_element)));
+#else
+ is_empty = (IS_FREE(ex, ey) ||
+ (IS_FREE_OR_PLAYER(ex, ey) && IS_WALKABLE(content_element)));
+#endif
+
#endif
is_walkable = (is_empty || IS_WALKABLE(e));
is_diggable = (is_empty || IS_DIGGABLE(e));
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]) &&
+ (!IS_SP_PORT(Feld[newx][newy]) || move_dir == MV_UP) &&
+ (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]) &&
(level.can_pass_to_walkable || IS_FREE(nextx, nexty)))));
#endif
#endif
+#endif
}
static void CheckGravityMovement(struct PlayerInfo *player)
if (game.engine_version < VERSION_IDENT(3,1,0,0))
#endif
{
+ int move_direction = player->MovDir;
+#if 1
+ int enter_side = MV_DIR_OPPOSITE(move_direction);
+ int leave_side = move_direction;
+#else
static int trigger_sides[4][2] =
{
/* enter side leave side */
{ CH_SIDE_BOTTOM, CH_SIDE_TOP }, /* moving up */
{ CH_SIDE_TOP, CH_SIDE_BOTTOM } /* moving down */
};
- int move_direction = player->MovDir;
int enter_side = trigger_sides[MV_DIR_BIT(move_direction)][0];
int leave_side = trigger_sides[MV_DIR_BIT(move_direction)][1];
+#endif
int old_element = Feld[old_jx][old_jy];
int new_element = Feld[jx][jy];
if (game.engine_version >= VERSION_IDENT(3,1,0,0))
#endif
{
+ int move_direction = player->MovDir;
+#if 1
+ int enter_side = MV_DIR_OPPOSITE(move_direction);
+ int leave_side = move_direction;
+#else
static int trigger_sides[4][2] =
{
/* enter side leave side */
{ CH_SIDE_BOTTOM, CH_SIDE_TOP }, /* moving up */
{ CH_SIDE_TOP, CH_SIDE_BOTTOM } /* moving down */
};
- int move_direction = player->MovDir;
int enter_side = trigger_sides[MV_DIR_BIT(move_direction)][0];
int leave_side = trigger_sides[MV_DIR_BIT(move_direction)][1];
+#endif
int old_jx = last_jx;
int old_jy = last_jy;
int old_element = Feld[old_jx][old_jy];
int oldx, int oldy, int x, int y,
int real_dx, int real_dy, int mode)
{
- static int trigger_sides[4] =
- {
- CH_SIDE_RIGHT, /* moving left */
- CH_SIDE_LEFT, /* moving right */
- 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));
#endif
dy == -1 ? MV_UP :
dy == +1 ? MV_DOWN : MV_NO_MOVING);
int opposite_direction = MV_DIR_OPPOSITE(move_direction);
+#if 1
+ int dig_side = MV_DIR_OPPOSITE(move_direction);
+#else
+ static int trigger_sides[4] =
+ {
+ CH_SIDE_RIGHT, /* moving left */
+ CH_SIDE_LEFT, /* moving right */
+ CH_SIDE_BOTTOM, /* moving up */
+ CH_SIDE_TOP, /* moving down */
+ };
int dig_side = trigger_sides[MV_DIR_BIT(move_direction)];
+#endif
int old_element = Feld[jx][jy];
int element;
else if (IS_SWITCHABLE(element))
{
if (PLAYER_SWITCHING(player, x, y))
+ {
+ CheckTriggeredElementChangeByPlayer(x,y, element,
+ CE_OTHER_GETS_PRESSED,
+ player->index_bit, dig_side);
+
return MF_ACTION;
+ }
player->is_switching = TRUE;
player->switch_x = x;
#endif
}
+ CheckTriggeredElementChangeByPlayer(x, y, element,
+ CE_OTHER_IS_SWITCHING,
+ player->index_bit, dig_side);
+
+ CheckTriggeredElementChangeByPlayer(x,y, element,CE_OTHER_GETS_PRESSED,
+ player->index_bit, dig_side);
+
return MF_ACTION;
}
else
boolean DropElement(struct PlayerInfo *player)
{
+ int old_element, new_element;
+ int dropx = player->jx, dropy = player->jy;
+ int drop_direction = player->MovDir;
+#if 1
+ int drop_side = drop_direction;
+#else
static int trigger_sides[4] =
{
CH_SIDE_LEFT, /* dropping left */
CH_SIDE_TOP, /* dropping up */
CH_SIDE_BOTTOM, /* dropping down */
};
- int old_element, new_element;
- int dropx = player->jx, dropy = player->jy;
- int drop_direction = player->MovDir;
int drop_side = trigger_sides[MV_DIR_BIT(drop_direction)];
+#endif
int drop_element = (player->inventory_size > 0 ?
player->inventory_element[player->inventory_size - 1] :
player->inventory_infinite_element != EL_UNDEFINED ?
void DumpTile(int x, int y)
{
int sx = SCREENX(x);
- int sy = SCREENX(y);
+ int sy = SCREENY(y);
printf_line("-", 79);
printf("Field Info: SCREEN(%d, %d), LEVEL(%d, %d)\n", sx, sy, x, y);
/* draw elements the player is just walking/passing through/under */
/* ----------------------------------------------------------------------- */
- /* handle the field the player is leaving ... */
- if (player_is_moving && IS_ACCESSIBLE_INSIDE(last_element))
- DrawLevelField(last_jx, last_jy);
- else if (player_is_moving && IS_ACCESSIBLE_UNDER(last_element))
- DrawLevelFieldThruMask(last_jx, last_jy);
+ if (player_is_moving)
+ {
+ /* handle the field the player is leaving ... */
+ if (IS_ACCESSIBLE_INSIDE(last_element))
+ DrawLevelField(last_jx, last_jy);
+ else if (IS_ACCESSIBLE_UNDER(last_element))
+ DrawLevelFieldThruMask(last_jx, last_jy);
+ }
+
+#if 1
+ /* do not redraw accessible elements if the player is just pushing them */
+ if (!player_is_moving || !player->is_pushing)
+ {
+ /* ... and the field the player is entering */
+ if (IS_ACCESSIBLE_INSIDE(element))
+ DrawLevelField(jx, jy);
+ else if (IS_ACCESSIBLE_UNDER(element))
+ DrawLevelFieldThruMask(jx, jy);
+ }
+
+#else
#if 0
/* !!! I have forgotton what this should be good for !!! */
else if (IS_ACCESSIBLE_UNDER(element))
DrawLevelFieldThruMask(jx, jy);
}
+#endif
if (setup.direct_draw)
{
int el_act_dir2img(int element, int action, int direction)
{
element = GFX_ELEMENT(element);
- direction = MV_DIR_BIT(direction);
+ direction = MV_DIR_BIT(direction); /* default: MV_NO_MOVING => MV_DOWN */
return element_info[element].direction_graphic[action][direction];
}
static int el_act_dir2crm(int element, int action, int direction)
{
element = GFX_ELEMENT(element);
- direction = MV_DIR_BIT(direction);
+ direction = MV_DIR_BIT(direction); /* default: MV_NO_MOVING => MV_DOWN */
return element_info[element].direction_crumbled[action][direction];
}