#define USE_NEW_AMOEBA_CODE FALSE
/* EXPERIMENTAL STUFF */
-#define USE_NEW_MOVEMENT FALSE
+#define USE_NEW_STUFF TRUE * 1
+
+#define USE_NEW_MOVE_STYLE TRUE * USE_NEW_STUFF * 1
+#define USE_NEW_MOVE_DELAY TRUE * USE_NEW_STUFF * 1
+#define USE_NEW_PUSH_DELAY TRUE * USE_NEW_STUFF * 1
+#define USE_NEW_BLOCK_STYLE TRUE * USE_NEW_STUFF * 1 * 1
+#define USE_NEW_SP_SLIPPERY TRUE * USE_NEW_STUFF * 1
+#define USE_NEW_RANDOMIZE TRUE * USE_NEW_STUFF * 1
+
+#define USE_PUSH_BUGFIX TRUE * USE_NEW_STUFF * 1
/* for DigField() */
#define DF_NO_PUSH 0
/* forward declaration for internal use */
+static void AdvanceFrameAndPlayerCounters(int);
+
static boolean MovePlayerOneStep(struct PlayerInfo *, int, int, int, int);
static boolean MovePlayer(struct PlayerInfo *, int, int);
static void ScrollPlayer(struct PlayerInfo *, int);
level.sp_block_last_field :
level.block_last_field);
+#if USE_NEW_BLOCK_STYLE
+#if 1
+ player->block_delay = (player->block_last_field ?
+ (element == EL_SP_MURPHY ?
+ level.sp_block_delay :
+ level.block_delay) : 0);
+#else
+ player->block_delay = (element == EL_SP_MURPHY ?
+ (player->block_last_field ? 7 : 1) :
+ (player->block_last_field ? 7 : 1));
+#endif
+
+#if 0
+ printf("::: block_last_field == %d, block_delay = %d\n",
+ player->block_last_field, player->block_delay);
+#endif
+#endif
+
if (!options.network || player->connected)
{
player->active = TRUE;
game.engine_version = (tape.playing ? tape.engine_version :
level.game_version);
+ /* ---------------------------------------------------------------------- */
+ /* set flags for bugs and changes according to active game engine version */
+ /* ---------------------------------------------------------------------- */
+
+ /*
+ Type of bug/change:
+ Before 3.1.0, custom elements that "change when pushing" changed directly
+ after the player started pushing them (until then handled in "DigField()").
+ Since 3.1.0, these custom elements are not changed until the "pushing"
+ move of the element is finished (now handled in "ContinueMoving()").
+
+ Affected levels/tapes:
+ The first condition is generally needed for all levels/tapes before version
+ 3.1.0, which might use the old behaviour before it was changed; known tapes
+ that are affected are some tapes from the level set "Walpurgis Gardens" by
+ Jamie Cullen.
+ The second condition is an exception from the above case and is needed for
+ the special case of tapes recorded with game (not engine!) version 3.1.0 or
+ above (including some development versions of 3.1.0), but before it was
+ known that this change would break tapes like the above and was fixed in
+ 3.1.1, so that the changed behaviour was active although the engine version
+ while recording maybe was before 3.1.0. There is at least one tape that is
+ affected by this exception, which is the tape for the one-level set "Bug
+ Machine" by Juergen Bonhagen.
+ */
+
+ game.use_bug_change_when_pushing =
+ (game.engine_version < VERSION_IDENT(3,1,0,0) &&
+ !(tape.playing &&
+ tape.game_version >= VERSION_IDENT(3,1,0,0) &&
+ tape.game_version < VERSION_IDENT(3,1,1,0)));
+
+ /* ---------------------------------------------------------------------- */
+
/* dynamically adjust element properties according to game engine version */
InitElementPropertiesEngine(game.engine_version);
/* ---------- initialize player's initial move delay --------------------- */
+#if USE_NEW_MOVE_DELAY
+ /* dynamically adjust player properties according to level information */
+ game.initial_move_delay_value =
+ (level.double_speed ? MOVE_DELAY_HIGH_SPEED : MOVE_DELAY_NORMAL_SPEED);
+
+ /* dynamically adjust player properties according to game engine version */
+ game.initial_move_delay = (game.engine_version <= VERSION_IDENT(2,0,1,0) ?
+ game.initial_move_delay_value : 0);
+#else
/* dynamically adjust player properties according to game engine version */
game.initial_move_delay =
(game.engine_version <= VERSION_IDENT(2,0,1,0) ? INITIAL_MOVE_DELAY_ON :
/* dynamically adjust player properties according to level information */
game.initial_move_delay_value =
(level.double_speed ? MOVE_DELAY_HIGH_SPEED : MOVE_DELAY_NORMAL_SPEED);
+#endif
/* ---------- initialize player's initial push delay --------------------- */
{
if (IS_SP_ELEMENT(i))
{
+#if USE_NEW_MOVE_STYLE
+ /* set SP push delay to just enough to push under a falling zonk */
+ int delay = (game.engine_version >= VERSION_IDENT(3,1,1,0) ? 8 : 6);
+
+ element_info[i].push_delay_fixed = delay;
+ element_info[i].push_delay_random = 0;
+#else
element_info[i].push_delay_fixed = 6; /* just enough to escape ... */
element_info[i].push_delay_random = 0; /* ... from falling zonk */
+#endif
}
}
}
player->use_murphy_graphic = FALSE;
- player->block_last_field = FALSE;
+ player->block_last_field = FALSE; /* initialized in InitPlayerField() */
+ player->block_delay = -1; /* initialized in InitPlayerField() */
+
player->can_fall_into_acid = CAN_MOVE_INTO_ACID(player->element_nr);
player->actual_frame_counter = 0;
player->move_delay_reset_counter = 0;
- player->push_delay = 0;
+#if USE_NEW_PUSH_DELAY
+ player->push_delay = -1; /* initialized when pushing starts */
player->push_delay_value = game.initial_push_delay_value;
+#else
+ player->push_delay = 0;
+ player->push_delay_value = game.initial_push_delay_value;
+#endif
player->drop_delay = 0;
player->element_nr = some_player->element_nr;
#endif
+#if USE_NEW_BLOCK_STYLE
+ player->block_last_field = some_player->block_last_field;
+ player->block_delay = some_player->block_delay;
+#endif
+
StorePlayer[jx][jy] = player->element_nr;
player->jx = player->last_jx = jx;
player->jy = player->last_jy = jy;
{
ScrollPlayer(player, SCROLL_GO_ON);
ScrollScreen(NULL, SCROLL_GO_ON);
+
+#if USE_NEW_MOVE_DELAY
+ AdvanceFrameAndPlayerCounters(player->index_nr);
+#else
FrameCounter++;
+#endif
DrawPlayer(player);
xx = x + move_xy[MovDir[x][y]].x;
yy = y + move_xy[MovDir[x][y]].y;
+#if 1
+ /* !!! this bugfix breaks at least BD2K3, level 010 !!! [re-recorded] */
+ if (!IN_LEV_FIELD(xx, yy) ||
+ (!IS_FREE(xx, yy) && !IS_FOOD_PIG(Feld[xx][yy])))
+ MovDir[x][y] = old_move_dir;
+#else
if (!IS_FREE(xx, yy) && !IS_FOOD_PIG(Feld[xx][yy]))
MovDir[x][y] = old_move_dir;
+#endif
MovDelay[x][y] = 0;
}
MovDir[x][y] = new_move_dir;
if (old_move_dir != new_move_dir)
+ {
+#if 1
+ MovDelay[x][y] = GET_NEW_MOVE_DELAY(element);
+#else
MovDelay[x][y] = 9;
+#endif
+ }
}
}
can_fall_both = (can_fall_left && can_fall_right);
}
+#if USE_NEW_SP_SLIPPERY
+ /* !!! better use the same properties as for custom elements here !!! */
+ else if (game.engine_version >= VERSION_IDENT(3,1,1,0) &&
+ can_fall_both && IS_SP_ELEMENT(Feld[x][y + 1]))
+ {
+ can_fall_right = FALSE; /* slip down on left side */
+ can_fall_both = FALSE;
+ }
+#endif
+
+#if 1
+ if (can_fall_both)
+ {
+ if (game.emulation == EMU_BOULDERDASH ||
+ element == EL_BD_ROCK || element == EL_BD_DIAMOND)
+ can_fall_right = FALSE; /* slip down on left side */
+ else
+ can_fall_left = !(can_fall_right = RND(2));
+
+ can_fall_both = FALSE;
+ }
+#endif
+
if (can_fall_any)
{
+#if 0
if (can_fall_both &&
(game.emulation != EMU_BOULDERDASH &&
element != EL_BD_ROCK && element != EL_BD_DIAMOND))
can_fall_left = !(can_fall_right = RND(2));
+#endif
+ /* if not determined otherwise, prefer left side for slipping down */
InitMovingField(x, y, can_fall_left ? MV_LEFT : MV_RIGHT);
started_moving = TRUE;
}
else if (element == EL_PENGUIN)
TestIfFriendTouchesBadThing(newx, newy);
-#if USE_NEW_MOVEMENT
+#if USE_NEW_MOVE_STYLE
#if 0
if (CAN_FALL(element) && direction == MV_DOWN &&
(newy == lev_fieldy - 1 || !IS_FREE(x, newy + 1)) &&
/* give the player one last chance (one more frame) to move away */
if (CAN_FALL(element) && direction == MV_DOWN &&
(newy == lev_fieldy - 1 || !IS_FREE(x, newy + 1)) &&
- !IS_PLAYER(x, newy + 1))
+ (!IS_PLAYER(x, newy + 1) ||
+ game.engine_version < VERSION_IDENT(3,1,1,0)))
Impact(x, newy);
#else
if (CAN_FALL(element) && direction == MV_DOWN &&
#endif
#if 1
+
+#if USE_PUSH_BUGFIX
+#if 1
+ if (pushed_by_player && !game.use_bug_change_when_pushing)
+#else
+ if (pushed_by_player && game.engine_version >= VERSION_IDENT(3,1,0,0))
+#endif
+#else
if (pushed_by_player)
+#endif
+
{
#if 1
int dig_side = MV_DIR_OPPOSITE(direction);
}
#endif
+void AdvanceFrameAndPlayerCounters(int player_nr)
+{
+ int i;
+
+ /* advance frame counters (global frame counter and time frame counter) */
+ FrameCounter++;
+ TimeFrames++;
+
+ /* advance player counters (counters for move delay, move animation etc.) */
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ boolean advance_player_counters = (player_nr == -1 || player_nr == i);
+ int move_frames =
+ MOVE_DELAY_NORMAL_SPEED / stored_player[i].move_delay_value;
+
+ if (!advance_player_counters) /* not all players may be affected */
+ continue;
+
+ 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 USE_NEW_PUSH_DELAY
+ /* due to bugs in previous versions, counter must count up, not down */
+ if (stored_player[i].push_delay != -1)
+ stored_player[i].push_delay++;
+#endif
+
+ if (stored_player[i].drop_delay > 0)
+ stored_player[i].drop_delay--;
+ }
+}
+
void GameActions()
{
static unsigned long action_delay = 0;
#endif
#if 1
- /* for downwards compatibility, the following code emulates a fixed bug that
+ /* for backwards 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
Changed[x][y] = CE_BITMASK_DEFAULT;
ChangeEvent[x][y] = CE_BITMASK_DEFAULT;
+#if USE_NEW_BLOCK_STYLE
+ /* 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);
+ }
+#endif
+
#if DEBUG
if (ChangePage[x][y] != -1 && ChangeDelay[x][y] != 1)
{
stored_player[0].StepFrame);
#endif
-#if 1
+#if USE_NEW_MOVE_DELAY
+ AdvanceFrameAndPlayerCounters(-1); /* advance counters for all players */
+#else
FrameCounter++;
TimeFrames++;
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--;
}
local_player->show_envelope = 0;
}
#endif
+
+#if USE_NEW_RANDOMIZE
+ /* use random number generator in every frame to make it less predictable */
+ if (game.engine_version >= VERSION_IDENT(3,1,1,0))
+ RND(1);
+#endif
}
static boolean AllPlayersInSight(struct PlayerInfo *player, int x, int y)
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");
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);
{
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->is_moving = FALSE;
-#if USE_NEW_MOVEMENT
+#if USE_NEW_MOVE_STYLE
/* player is ALLOWED to move, but CANNOT move (something blocks his way) */
/* ensure that the player is also allowed to move in the next frame */
/* (currently, the player is forced to wait eight frames before he can try
again!!!) */
- player->move_delay = -1; /* allow direct movement in the next frame */
+ if (game.engine_version >= VERSION_IDENT(3,1,1,0))
+ player->move_delay = 0; /* allow direct movement in the next frame */
#endif
}
+#if USE_NEW_MOVE_DELAY
+ if (player->move_delay == -1) /* not yet initialized by DigField() */
+ player->move_delay = player->move_delay_value;
+#endif
+
if (game.engine_version < VERSION_IDENT(3,0,7,0))
{
TestIfHeroTouchesBadThing(jx, jy);
player->actual_frame_counter = FrameCounter;
player->GfxPos = move_stepsize * (player->MovPos / move_stepsize);
-#if USE_NEW_MOVEMENT
- if (player->block_last_field &&
+#if 0
+ printf("::: %06d: %d,%d: %d (%d) [%d]\n",
+ FrameCounter,
+ last_jx, last_jy, Feld[last_jx][last_jy], EL_EXPLOSION,
+ player->block_delay);
+#endif
+
+#if USE_NEW_BLOCK_STYLE
+
+#if 0
+ if (player->block_delay <= 0)
+ printf("::: ALERT! block_delay == %d\n", player->block_delay);
+#endif
+
+ if (player->block_delay > 0 &&
+ Feld[last_jx][last_jy] == EL_EMPTY)
+ {
+ Feld[last_jx][last_jy] = EL_PLAYER_IS_LEAVING;
+ MovDelay[last_jx][last_jy] = player->block_delay + 1;
+ }
+#else
+#if USE_NEW_MOVE_STYLE
+ if ((game.engine_version < VERSION_IDENT(3,1,1,0) ||
+ player->block_last_field) &&
Feld[last_jx][last_jy] == EL_EMPTY)
Feld[last_jx][last_jy] = EL_PLAYER_IS_LEAVING;
#else
if (Feld[last_jx][last_jy] == EL_EMPTY)
Feld[last_jx][last_jy] = EL_PLAYER_IS_LEAVING;
#endif
+#endif
#if 0
DrawPlayer(player);
player->MovPos += (player->MovPos > 0 ? -1 : 1) * move_stepsize;
player->GfxPos = move_stepsize * (player->MovPos / move_stepsize);
+#if USE_NEW_BLOCK_STYLE
+#else
if (!player->block_last_field &&
Feld[last_jx][last_jy] == EL_PLAYER_IS_LEAVING)
+#if 1
+ RemoveField(last_jx, last_jy);
+#else
Feld[last_jx][last_jy] = EL_EMPTY;
+#endif
+#endif
/* before DrawPlayer() to draw correct player graphic for this case */
if (player->MovPos == 0)
}
#endif
+#if USE_NEW_BLOCK_STYLE
+#else
if (player->block_last_field &&
Feld[last_jx][last_jy] == EL_PLAYER_IS_LEAVING)
+#if 1
+ RemoveField(last_jx, last_jy);
+#else
Feld[last_jx][last_jy] = EL_EMPTY;
+#endif
+#endif
player->last_jx = jx;
player->last_jy = jy;
if (mode == DF_NO_PUSH) /* player just stopped pushing */
{
player->is_switching = FALSE;
+#if USE_NEW_PUSH_DELAY
+ player->push_delay = -1;
+#else
player->push_delay = 0;
+#endif
return MF_NO_ACTION;
}
if (!checkDiagonalPushing(player, x, y, real_dx, real_dy))
return MF_NO_ACTION;
+#if USE_NEW_PUSH_DELAY
+
+#if 0
+ if ( (player->push_delay == -1) != (player->push_delay2 == 0) )
+ printf("::: ALERT: %d, %d [%d / %d]\n",
+ player->push_delay, player->push_delay2,
+ FrameCounter, FrameCounter / 50);
+#endif
+
+ if (player->push_delay == -1) /* new pushing; restart delay */
+ player->push_delay = 0;
+#else
if (player->push_delay == 0) /* new pushing; restart delay */
player->push_delay = FrameCounter;
+#endif
+
+#if USE_NEW_PUSH_DELAY
+#if 0
+ if ( (player->push_delay > 0) != (!xxx_fr) )
+ printf("::: PUSH BUG! %d, (%d -> %d) %d [%d / %d]\n",
+ player->push_delay,
+ xxx_pdv2, player->push_delay2, player->push_delay_value,
+ FrameCounter, FrameCounter / 50);
+#endif
+
+#if 0
+ if (player->push_delay > 0 &&
+ !(tape.playing && tape.file_version < FILE_VERSION_2_0) &&
+ element != EL_SPRING && element != EL_BALLOON)
+#else
+ /* !!! */
+ if (player->push_delay < player->push_delay_value &&
+ !(tape.playing && tape.file_version < FILE_VERSION_2_0) &&
+ element != EL_SPRING && element != EL_BALLOON)
+#endif
+#else
if (!FrameReached(&player->push_delay, player->push_delay_value) &&
!(tape.playing && tape.file_version < FILE_VERSION_2_0) &&
element != EL_SPRING && element != EL_BALLOON)
+#endif
{
/* make sure that there is no move delay before next try to push */
+#if USE_NEW_MOVE_DELAY
+ if (game.engine_version >= VERSION_IDENT(3,0,7,1))
+ player->move_delay = 0;
+#else
if (game.engine_version >= VERSION_IDENT(3,0,7,1))
player->move_delay = INITIAL_MOVE_DELAY_OFF;
+#endif
return MF_NO_ACTION;
}
else
player->push_delay_value = -1; /* get new value later */
+#if USE_PUSH_BUGFIX
+ /* now: check for element change _after_ element has been pushed! */
+#if 1
+ if (game.use_bug_change_when_pushing)
+#else
+ if (game.engine_version < VERSION_IDENT(3,1,0,0))
+#endif
+ {
+ CheckElementChangeByPlayer(x, y, element, CE_PUSHED_BY_PLAYER,
+ player->index_bit, dig_side);
+ CheckTriggeredElementChangeByPlayer(x,y,element,CE_OTHER_GETS_PUSHED,
+ player->index_bit, dig_side);
+ }
+
+#else
+
#if 1
/* check for element change _after_ element has been pushed! */
#else
#if 1
- /* !!! TEST ONLY !!! */
+ /* !!! TEST ONLY !!! */
CheckElementChangeByPlayer(x, y, element, CE_PUSHED_BY_PLAYER,
player->index_bit, dig_side);
CheckTriggeredElementChangeByPlayer(x, y, element,CE_OTHER_GETS_PUSHED,
CheckElementChangeByPlayer(x, y, element, CE_PUSHED_BY_PLAYER,
player->index_bit, dig_side);
#endif
+#endif
+
#endif
break;
return MF_NO_ACTION;
}
+#if USE_NEW_PUSH_DELAY
+ player->push_delay = -1;
+#else
player->push_delay = 0;
+#endif
if (Feld[x][y] != element) /* really digged/collected something */
player->is_collecting = !player->is_digging;