((e) == EL_TRIGGER_ELEMENT ? (ch)->actual_trigger_element : \
(e) == EL_TRIGGER_PLAYER ? (ch)->actual_trigger_player : (e))
+#define GET_VALID_PLAYER_ELEMENT(e) \
+ ((e) >= EL_PLAYER_1 && (e) <= EL_PLAYER_4 ? (e) : EL_PLAYER_1)
+
#define CAN_GROW_INTO(e) \
- (e == EL_SAND || (IS_DIGGABLE(e) && level.grow_into_diggable))
+ ((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) || \
network_player_action_received = FALSE;
-#if defined(PLATFORM_UNIX)
+#if defined(NETWORK_AVALIABLE)
/* initial null action */
if (network_playing)
SendToServer_MovePlayer(MV_NO_MOVING);
void RelocatePlayer(int jx, int jy, int el_player_raw)
{
+#if 1
+ int el_player = GET_VALID_PLAYER_ELEMENT(el_player_raw);
+#else
int el_player = (el_player_raw == EL_SP_MURPHY ? EL_PLAYER_1 :el_player_raw);
+#endif
struct PlayerInfo *player = &stored_player[el_player - EL_PLAYER_1];
boolean ffwd_delay = (tape.playing && tape.fast_forward);
boolean no_delay = (tape.warp_forward);
int 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,
continue;
#endif
+#if 1
+ if (IS_PLAYER(x, y) && SHIELD_ON(PLAYERINFO(x, y)) &&
+ (game.engine_version < VERSION_IDENT(3,1,0,0) ||
+ (x == ex && y == ey)))
+#else
if (IS_PLAYER(x, y) && SHIELD_ON(PLAYERINFO(x, y)))
+#endif
{
if (IS_ACTIVE_BOMB(element))
{
/* re-activate things under the bomb like gate or penguin */
+#if 1
+ Feld[x][y] = (Back[x][y] ? Back[x][y] : EL_EMPTY);
+ Back[x][y] = 0;
+#else
Feld[x][y] = (Store[x][y] ? Store[x][y] : EL_EMPTY);
Store[x][y] = 0;
+#endif
}
continue;
#if 0
if (IS_INDESTRUCTIBLE(element))
Back[x][y] = element;
+#else
+#if 1
+ if (IS_WALKABLE(element) && IS_INDESTRUCTIBLE(element) &&
+ (x != ex || y != ey))
+ Back[x][y] = element;
#else
if (IS_WALKABLE(element) && IS_INDESTRUCTIBLE(element))
Back[x][y] = element;
+#endif
#endif
/* ignite explodable elements reached by other explosion */
#if 1
border_element = Store2[x][y];
+#if 1
+ if (IS_PLAYER(x, y) && !PLAYER_EXPLOSION_PROTECTED(x, y))
+ border_element = StorePlayer[x][y];
+#else
if (IS_PLAYER(x, y))
border_element = StorePlayer[x][y];
+#endif
#if 0
printf("::: phase == %d\n", phase);
boolean border_explosion = FALSE;
#if 1
+#if 1
+ if (IS_PLAYER(x, y) && PLAYERINFO(x, y)->present &&
+ !PLAYER_EXPLOSION_PROTECTED(x, y))
+#else
if (IS_PLAYER(x, y) && PLAYERINFO(x, y)->present)
+#endif
#else
if (IS_PLAYER(x, y))
#endif
Explode(x, y, EX_PHASE_START, EX_TYPE_BORDER);
#if 1
+#if 1
+ if (element != EL_EMPTY && element != EL_EXPLOSION &&
+ !IS_DIGGABLE(element) && !dynabomb_xl)
+ break;
+#else
if (element != EL_EMPTY && element != EL_EXPLOSION &&
!CAN_GROW_INTO(element) && !dynabomb_xl)
break;
+#endif
#else
/* !!! extend EL_SAND to anything diggable (but maybe not SP_BASE) !!! */
if (element != EL_EMPTY && element != EL_EXPLOSION &&
Explode(x, y, EX_PHASE_START, EX_TYPE_CENTER);
break;
default:
+#if 1
+ if (element_info[element].explosion_type == EXPLODES_CROSS)
+#else
if (CAN_EXPLODE_CROSS(element))
+#endif
#if 1
Explode(x, y, EX_PHASE_START, EX_TYPE_CROSS);
#else
DynaExplode(x, y);
#endif
+#if 1
+ else if (element_info[element].explosion_type == EXPLODES_1X1)
+#else
else if (CAN_EXPLODE_1X1(element))
+#endif
Explode(x, y, EX_PHASE_START, EX_TYPE_CENTER);
else
Explode(x, y, EX_PHASE_START, EX_TYPE_NORMAL);
#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));
}
#if 1
- /* !!! indirect change before direct change !!! */
+ /* this uses direct change before indirect change */
CheckTriggeredElementChangeByPage(x,y,old_element,CE_OTHER_IS_CHANGING,page);
#endif
#endif
*/
-#if defined(PLATFORM_UNIX)
+#if defined(NETWORK_AVALIABLE)
/* last chance to get network player actions without main loop delay */
HandleNetworking();
#endif
stored_player[i].effective_action = stored_player[i].action;
}
-#if defined(PLATFORM_UNIX)
+#if defined(NETWORK_AVALIABLE)
if (network_playing)
SendToServer_MovePlayer(summarized_player_action);
#endif
TimeFrames = 0;
TapeTime++;
- if (!level.use_step_counter)
+ for (i = 0; i < MAX_PLAYERS; i++)
{
- TimePlayed++;
+ struct PlayerInfo *player = &stored_player[i];
- for (i = 0; i < MAX_PLAYERS; i++)
+ if (SHIELD_ON(player))
{
- struct PlayerInfo *player = &stored_player[i];
+ player->shield_normal_time_left--;
- if (SHIELD_ON(player))
- {
- player->shield_normal_time_left--;
-
- if (player->shield_deadly_time_left > 0)
- player->shield_deadly_time_left--;
- }
+ if (player->shield_deadly_time_left > 0)
+ player->shield_deadly_time_left--;
}
+ }
+
+ if (!level.use_step_counter)
+ {
+ TimePlayed++;
if (TimeLeft > 0)
{
#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[nextx][nexty], move_dir) &&
(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];
TimePlayed++;
- 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 (TimeLeft > 0)
{
TimeLeft--;
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
+ boolean is_player = (IS_PLAYER(oldx, oldy) || mode != DF_DIG);
+ boolean player_was_pushing = player->is_pushing;
int jx = oldx, jy = oldy;
int dx = x - jx, dy = y - jy;
int nextx = x + dx, nexty = y + dy;
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;
- if (player->MovPos == 0)
+ if (is_player) /* function can also be called by EL_PENGUIN */
{
- player->is_digging = FALSE;
- player->is_collecting = FALSE;
- }
+ if (player->MovPos == 0)
+ {
+ player->is_digging = FALSE;
+ player->is_collecting = FALSE;
+ }
- if (player->MovPos == 0) /* last pushing move finished */
- player->is_pushing = FALSE;
+ if (player->MovPos == 0) /* last pushing move finished */
+ player->is_pushing = FALSE;
- if (mode == DF_NO_PUSH) /* player just stopped pushing */
- {
- player->is_switching = FALSE;
- player->push_delay = 0;
+ if (mode == DF_NO_PUSH) /* player just stopped pushing */
+ {
+ player->is_switching = FALSE;
+ player->push_delay = 0;
- return MF_NO_ACTION;
+ return MF_NO_ACTION;
+ }
}
if (IS_MOVING(x, y) || IS_PLAYER(x, y))
element = Feld[x][y];
+ if (!is_player && !IS_COLLECTIBLE(element)) /* penguin cannot collect it */
+ return MF_NO_ACTION;
+
if (mode == DF_SNAP && !IS_SNAPPABLE(element) &&
game.engine_version >= VERSION_IDENT(2,2,0,0))
return MF_NO_ACTION;
#if 1
- if (game.gravity && !player->is_auto_moving &&
+ if (game.gravity && is_player && !player->is_auto_moving &&
canFallDown(player) && move_direction != MV_DOWN &&
!canMoveToValidFieldWithGravity(jx, jy, move_direction))
return MF_NO_ACTION; /* player cannot walk here due to gravity */
if (IS_WALKABLE(element))
#endif
{
+ int sound_element = SND_ELEMENT(element);
int sound_action = ACTION_WALKING;
#if 0
}
/* play sound from background or player, whatever is available */
- if (element_info[element].sound[sound_action] != SND_UNDEFINED)
- PlayLevelSoundElementAction(x, y, element, sound_action);
+ if (element_info[sound_element].sound[sound_action] != SND_UNDEFINED)
+ PlayLevelSoundElementAction(x, y, sound_element, sound_action);
else
PlayLevelSoundElementAction(x, y, player->element_nr, sound_action);
{
RemoveField(x, y);
- if (mode != DF_SNAP)
+ if (is_player && mode != DF_SNAP)
{
GfxElement[x][y] = element;
player->is_collecting = TRUE;
RaiseScoreElement(element);
PlayLevelSoundElementAction(x, y, element, ACTION_COLLECTING);
- CheckTriggeredElementChangeByPlayer(x, y, element,
- CE_OTHER_GETS_COLLECTED,
- player->index_bit, dig_side);
+ if (is_player)
+ CheckTriggeredElementChangeByPlayer(x, y, element,
+ CE_OTHER_GETS_COLLECTED,
+ player->index_bit, dig_side);
#if 1
if (mode == DF_SNAP)
#endif
#if 1
- if (game.engine_version >= VERSION_IDENT(3,0,7,1))
+
+#if 1
+ if (game.engine_version >= VERSION_IDENT(3,1,0,0))
+ {
+ if (player->push_delay_value == -1 || !player_was_pushing)
+ player->push_delay_value = GET_NEW_PUSH_DELAY(element);
+ }
+ else if (game.engine_version >= VERSION_IDENT(3,0,7,1))
{
if (player->push_delay_value == -1)
player->push_delay_value = GET_NEW_PUSH_DELAY(element);
}
+#else
+ if (game.engine_version >= VERSION_IDENT(3,0,7,1))
+ {
+ if (player->push_delay_value == -1 || !player_was_pushing)
+ player->push_delay_value = GET_NEW_PUSH_DELAY(element);
+ }
+#endif
else if (game.engine_version >= VERSION_IDENT(2,2,0,7))
{
if (!player->is_pushing)
#endif
#if 0
- printf("::: push delay: %ld [%d, %d] [%d]\n",
- player->push_delay_value, FrameCounter, game.engine_version,
- player->is_pushing);
+ printf("::: push delay: %ld -> %ld [%d, %d] [%d / %d] [%d '%s': %d]\n",
+ player->push_delay, player->push_delay_value,
+ FrameCounter, game.engine_version,
+ player_was_pushing, player->is_pushing,
+ element, element_info[element].token_name,
+ GET_NEW_PUSH_DELAY(element));
#endif
player->is_pushing = TRUE;
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 ?
static void PlayLevelSoundElementAction(int x, int y, int element, int action)
{
- int sound_effect = element_info[element].sound[action];
+ int sound_effect = element_info[SND_ELEMENT(element)].sound[action];
if (sound_effect != SND_UNDEFINED)
PlayLevelSound(x, y, sound_effect);
static void PlayLevelSoundElementActionIfLoop(int x, int y, int element,
int action)
{
- int sound_effect = element_info[element].sound[action];
+ int sound_effect = element_info[SND_ELEMENT(element)].sound[action];
if (sound_effect != SND_UNDEFINED && IS_LOOP_SOUND(sound_effect))
PlayLevelSound(x, y, sound_effect);
static void PlayLevelSoundActionIfLoop(int x, int y, int action)
{
- int sound_effect = element_info[Feld[x][y]].sound[action];
+ int sound_effect = element_info[SND_ELEMENT(Feld[x][y])].sound[action];
if (sound_effect != SND_UNDEFINED && IS_LOOP_SOUND(sound_effect))
PlayLevelSound(x, y, sound_effect);
static void StopLevelSoundActionIfLoop(int x, int y, int action)
{
- int sound_effect = element_info[Feld[x][y]].sound[action];
+ int sound_effect = element_info[SND_ELEMENT(Feld[x][y])].sound[action];
if (sound_effect != SND_UNDEFINED && IS_LOOP_SOUND(sound_effect))
StopSound(sound_effect);
Request("Do you really want to quit the game ?",
REQ_ASK | REQ_STAY_CLOSED))
{
-#if defined(PLATFORM_UNIX)
+#if defined(NETWORK_AVALIABLE)
if (options.network)
SendToServer_StopPlaying();
else
case GAME_CTRL_ID_PAUSE:
if (options.network)
{
-#if defined(PLATFORM_UNIX)
+#if defined(NETWORK_AVALIABLE)
if (tape.pausing)
SendToServer_ContinuePlaying();
else
case GAME_CTRL_ID_PLAY:
if (tape.pausing)
{
-#if defined(PLATFORM_UNIX)
+#if defined(NETWORK_AVALIABLE)
if (options.network)
SendToServer_ContinuePlaying();
else