From: Holger Schemel Date: Tue, 11 Jun 2024 21:09:43 +0000 (+0200) Subject: added single step support for BD engine X-Git-Tag: 4.4.0.0-test-2~7 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=8fdd23c078934ae797980a824fd145903c84cae7;p=rocksndiamonds.git added single step support for BD engine --- diff --git a/src/game_bd/bd_caveengine.c b/src/game_bd/bd_caveengine.c index 6d0e3fcd..5b2bfcdf 100644 --- a/src/game_bd/bd_caveengine.c +++ b/src/game_bd/bd_caveengine.c @@ -1570,6 +1570,9 @@ void gd_cave_iterate(GdCave *cave, GdDirection player_move, boolean player_fire, gd_cave_clear_sounds(cave); + game_bd.player_moving = FALSE; + game_bd.player_snapping = FALSE; + // if diagonal movements not allowed, // horizontal movements have precedence. [BROADRIBB] if (!cave->diagonal_movements) @@ -1835,15 +1838,25 @@ void gd_cave_iterate(GdCave *cave, GdDirection player_move, boolean player_fire, // if snapping anything and we have snapping explosions set. // but these is not true for pushing. if (remains == O_SPACE && player_fire && !push) + { remains = cave->snap_element; + game_bd.player_snapping = TRUE; + } + if (remains != O_SPACE || player_fire) + { // if any other element than space, player cannot move. // also if pressing fire, will not move. store_dir(cave, x, y, player_move, remains); + } else + { // if space remains there, the player moves. move(cave, x, y, player_move, O_PLAYER); + + game_bd.player_moving = TRUE; + } } } break; diff --git a/src/game_bd/bd_gameplay.c b/src/game_bd/bd_gameplay.c index 12eb53bc..3ca3e43c 100644 --- a/src/game_bd/bd_gameplay.c +++ b/src/game_bd/bd_gameplay.c @@ -188,6 +188,13 @@ GdGame *gd_game_new(const int cave, const int level) return game; } +boolean check_iteration_reached(GdGame *game) +{ + int millisecs_elapsed = 20; + + return (game->milliseconds_game + millisecs_elapsed >= game->cave->speed); +} + static void iterate_cave(GdGame *game, GdDirection player_move, boolean fire) { boolean suicide = FALSE; diff --git a/src/game_bd/bd_gameplay.h b/src/game_bd/bd_gameplay.h index aa9a48de..98659a48 100644 --- a/src/game_bd/bd_gameplay.h +++ b/src/game_bd/bd_gameplay.h @@ -112,6 +112,8 @@ GdGame *gd_game_new(const int cave, const int level); GdGame *gd_game_new_snapshot(GdCave *snapshot); GdGame *gd_game_new_test(GdCave *cave, int level); +boolean check_iteration_reached(GdGame *game); + void play_game_func(GdGame *game, int action); #endif // BD_GAMEPLAY_H diff --git a/src/game_bd/export_bd.h b/src/game_bd/export_bd.h index 35f2e687..883d4ace 100644 --- a/src/game_bd/export_bd.h +++ b/src/game_bd/export_bd.h @@ -43,6 +43,9 @@ struct GameInfo_BD boolean game_over; boolean cover_screen; + boolean player_moving; + boolean player_snapping; + // needed for updating panel int time_left; int gems_still_needed; diff --git a/src/game_bd/import_bd.h b/src/game_bd/import_bd.h index 53af1639..75e801c0 100644 --- a/src/game_bd/import_bd.h +++ b/src/game_bd/import_bd.h @@ -27,6 +27,7 @@ // ---------------------------------------------------------------------------- void InitGraphicInfo_BD(void); +boolean CheckSingleStepMode_BD(boolean, boolean, boolean); void PlayLevelSound_BD(int, int, int, int); void StopSound_BD(int, int); diff --git a/src/game_bd/main_bd.c b/src/game_bd/main_bd.c index dae512b6..7730ba9b 100644 --- a/src/game_bd/main_bd.c +++ b/src/game_bd/main_bd.c @@ -340,6 +340,9 @@ void InitGameEngine_BD(void) game_bd.game->itermax = 8; // default; dynamically changed at runtime game_bd.game->itermax_last = game_bd.game->itermax; + game_bd.player_moving = FALSE; + game_bd.player_snapping = FALSE; + // default: start with completely covered playfield int next_state = GAME_INT_START_UNCOVER + 1; @@ -437,6 +440,15 @@ void GameActions_BD(byte action[MAX_PLAYERS]) play_game_func(game_bd.game, action[0]); } + boolean single_step_mode_paused = + CheckSingleStepMode_BD(check_iteration_reached(game_bd.game), + game_bd.player_moving, + game_bd.player_snapping); + + // draw final movement animation frame before going to single step pause mode + if (single_step_mode_paused) + game_bd.game->itercycle = game_bd.game->itermax - 1; + RedrawPlayfield_BD(FALSE); UpdateGameDoorValues_BD(); diff --git a/src/tools.c b/src/tools.c index 1881220a..d56532d1 100644 --- a/src/tools.c +++ b/src/tools.c @@ -11215,6 +11215,26 @@ void InitGraphicInfo_EM(void) } } +static void CheckSaveEngineSnapshot_BD(boolean frame_max, + boolean player_moving, + boolean player_snapping) +{ + if (frame_max) + { + if (!local_player->was_waiting) + { + if (!CheckSaveEngineSnapshotToList()) + return; + + local_player->was_waiting = TRUE; + } + } + else if (player_moving || player_snapping) + { + local_player->was_waiting = FALSE; + } +} + static void CheckSaveEngineSnapshot_EM(int frame, boolean any_player_moving, boolean any_player_snapping, @@ -11272,6 +11292,19 @@ static void CheckSaveEngineSnapshot_MM(boolean element_clicked, } } +boolean CheckSingleStepMode_BD(boolean frame_max, + boolean player_moving, + boolean player_snapping) +{ + if (tape.single_step && tape.recording && !tape.pausing) + if (frame_max && FrameCounter > 6) + TapeTogglePause(TAPE_TOGGLE_AUTOMATIC); + + CheckSaveEngineSnapshot_BD(frame_max, player_moving, player_snapping); + + return tape.pausing; +} + boolean CheckSingleStepMode_EM(int frame, boolean any_player_moving, boolean any_player_snapping,