From 7ffc21d9a4a3772e2855611cd03c8942b8f0e395 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 15 Jun 2004 21:39:09 +0200 Subject: [PATCH] rnd-20040615-1-src * fixed bug (missing array boundary check) which caused broken tapes * fixed bug (when loading level template) which caused broken levels * fixed bug with new block last field code when using non-yellow player --- ChangeLog | 6 ++++ src/conftime.h | 2 +- src/files.c | 11 +++++- src/game.c | 91 +++++++++++++++++++++++++++++++++++++------------- 4 files changed, 85 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7604d7f5..adf52116 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-06-13 + * fixed bug (missing array boundary check) which caused broken tapes + * fixed bug (when loading level template) which caused broken levels + * fixed bug with new block last field code when using non-yellow player + 2004-06-12 * fixed bug when pressing "stop, pause, stop, play" on tape recorder * internal change of how the player blocks the last field when moving @@ -6,6 +11,7 @@ unsuccessfully trying to move, when he directly could move after that * the last two changes should make original Supaplex level 93 solvable * improved use of random number generator to make it less predictable + * fixed behaviour of slippery SP elements to let slip left, then right 2004-06-11 * fixed bug with wrong door state after trying to quickload empty tape diff --git a/src/conftime.h b/src/conftime.h index 71dbf466..ebd1d098 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2004-06-12 23:32]" +#define COMPILE_DATE_STRING "[2004-06-14 00:25]" diff --git a/src/files.c b/src/files.c index 3989a22a..7280860b 100644 --- a/src/files.c +++ b/src/files.c @@ -2235,10 +2235,14 @@ static void LoadLevel_InitVersion(struct LevelInfo *level, char *filename) } } -#if 1 +#if 1 /* USE_NEW_BLOCK_STYLE */ /* blocking the last field when moving was corrected in version 3.1.1 */ if (level->game_version < VERSION_IDENT(3,1,1,0)) { +#if 0 + printf("::: %d\n", level->block_last_field); +#endif + /* even "not blocking" was blocking the last field for one frame */ level->block_delay = (level->block_last_field ? 7 : 1); level->sp_block_delay = (level->sp_block_last_field ? 7 : 1); @@ -2488,8 +2492,13 @@ void LoadLevelTemplate(int nr) LoadLevelFromFilename_RND(&level_template, filename); #endif +#if 1 + LoadLevel_InitVersion(&level_template, filename); + LoadLevel_InitElements(&level_template, filename); +#else LoadLevel_InitVersion(&level, filename); LoadLevel_InitElements(&level, filename); +#endif ActivateLevelTemplate(); } diff --git a/src/game.c b/src/game.c index 244aef5e..9645f08e 100644 --- a/src/game.c +++ b/src/game.c @@ -28,10 +28,14 @@ #define USE_NEW_AMOEBA_CODE FALSE /* EXPERIMENTAL STUFF */ -#define USE_NEW_MOVE_STYLE TRUE *1 -#define USE_NEW_MOVE_DELAY TRUE *1 -#define USE_NEW_PUSH_DELAY TRUE *1 -#define USE_NEW_BLOCK_STYLE TRUE *1 +#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 /* for DigField() */ #define DF_NO_PUSH 0 @@ -392,18 +396,6 @@ struct ChangingElementInfo static struct ChangingElementInfo change_delay_list[] = { -#if USE_NEW_BLOCK_STYLE -#if 0 - { - EL_PLAYER_IS_LEAVING, - EL_EMPTY, - -1, /* delay for blocking field left by player set at runtime */ - NULL, - NULL, - NULL - }, -#endif -#endif { EL_NUT_BREAKING, EL_EMERALD, @@ -792,6 +784,11 @@ static void InitPlayerField(int x, int y, int element, boolean init_game) (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) @@ -1183,7 +1180,7 @@ static void resolve_group_element(int group_element, int recursion_depth) /* ============================================================================= - InitGameEngine() + InitGameEngine() ----------------------------------------------------------------------------- initialize game engine due to level / tape version number ============================================================================= @@ -1812,6 +1809,11 @@ void InitGame() 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; @@ -4633,8 +4635,15 @@ inline static void TurnRoundExt(int x, int y) 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 !!! */ + 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; } @@ -5428,13 +5437,39 @@ void StartMoving(int x, int y) 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; } @@ -9159,7 +9194,7 @@ void GameActions() } #endif -#if 1 +#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); @@ -9925,20 +9960,30 @@ void ScrollPlayer(struct PlayerInfo *player, int mode) player->actual_frame_counter = FrameCounter; player->GfxPos = move_stepsize * (player->MovPos / move_stepsize); +#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; -#if 1 MovDelay[last_jx][last_jy] = player->block_delay + 1; -#else - ChangeDelay[last_jx][last_jy] = player->block_last_field_delay; -#endif } #else #if USE_NEW_MOVE_STYLE - if (player->block_last_field && + 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 -- 2.34.1