X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=756bd63d2db921c21af53ad662247ea28376f3e0;hb=6da339c01258cd7edee0c181260578a1795bf8ed;hp=ca2fa98e521542e1b723fc73479e592c76a6744b;hpb=2fd4947ab48cc80c2a5b38f26e207635f5d40cf3;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index ca2fa98e..756bd63d 100644 --- a/src/game.c +++ b/src/game.c @@ -2239,7 +2239,7 @@ static void UpdateGameControlValues(void) game_sp.time_played : level.game_engine_type == GAME_ENGINE_TYPE_MM ? game_mm.energy_left : - game.no_time_limit ? TimePlayed : TimeLeft); + game.no_level_time_limit ? TimePlayed : TimeLeft); int score = (game.LevelSolved ? game.LevelSolved_CountingScore : level.game_engine_type == GAME_ENGINE_TYPE_EM ? @@ -3680,7 +3680,8 @@ void InitGame(void) player->can_fall_into_acid = CAN_MOVE_INTO_ACID(player->element_nr); - player->actual_frame_counter = 0; + player->actual_frame_counter.count = 0; + player->actual_frame_counter.value = 1; player->step_counter = 0; @@ -3818,7 +3819,8 @@ void InitGame(void) game.panel.active = TRUE; - game.no_time_limit = (level.time == 0); + game.no_level_time_limit = (level.time == 0); + game.time_limit = (leveldir_current->time_limit && setup.time_limit); game.yamyam_content_nr = 0; game.robot_wheel_active = FALSE; @@ -4726,7 +4728,7 @@ void InitAmoebaNr(int x, int y) static void LevelSolved_SetFinalGameValues(void) { - game.time_final = (game.no_time_limit ? TimePlayed : TimeLeft); + game.time_final = (game.no_level_time_limit ? TimePlayed : TimeLeft); game.score_time_final = (level.use_step_counter ? TimePlayed : TimePlayed * FRAMES_PER_SECOND + TimeFrames); @@ -4835,7 +4837,7 @@ void GameWon(void) time_final = 0; time_frames = time_frames_left; } - else if (game.no_time_limit && TimePlayed < time_final_max) + else if (game.no_level_time_limit && TimePlayed < time_final_max) { time_final = time_final_max; time_frames = time_frames_final_max - time_frames_played; @@ -5050,6 +5052,9 @@ void GameEnd(void) if (setup.auto_play_next_level) { + scores.continue_playing = TRUE; + scores.next_level_nr = level_nr; + LoadLevel(level_nr); SaveLevelSetup_SeriesInfo(); @@ -5062,9 +5067,7 @@ void GameEnd(void) DrawHallOfFame(last_level_nr); } - else if (setup.auto_play_next_level && setup.increment_levels && - last_level_nr < leveldir_current->last_level && - !network_playing) + else if (scores.continue_playing) { StartGameActions(network.enabled, setup.autorecord, level.random_seed); } @@ -7677,25 +7680,19 @@ static void TurnRoundExt(int x, int y) } else if (move_pattern & MV_MAZE_RUNNER_STYLE) { - static int test_xy[7][2] = + static int test_xy[4][2] = { { 0, -1 }, { -1, 0 }, { +1, 0 }, - { 0, +1 }, - { 0, -1 }, - { -1, 0 }, - { +1, 0 }, + { 0, +1 } }; - static int test_dir[7] = + static int test_dir[4] = { MV_UP, MV_LEFT, MV_RIGHT, - MV_DOWN, - MV_UP, - MV_LEFT, - MV_RIGHT, + MV_DOWN }; boolean hunter_mode = (move_pattern == MV_MAZE_HUNTER); int move_preference = -1000000; // start with very low preference @@ -7705,11 +7702,12 @@ static void TurnRoundExt(int x, int y) for (i = 0; i < NUM_DIRECTIONS; i++) { - int move_dir = test_dir[start_test + i]; + int j = (start_test + i) % 4; + int move_dir = test_dir[j]; int move_dir_preference; - xx = x + test_xy[start_test + i][0]; - yy = y + test_xy[start_test + i][1]; + xx = x + test_xy[j][0]; + yy = y + test_xy[j][1]; if (hunter_mode && IN_LEV_FIELD(xx, yy) && (IS_PLAYER(xx, yy) || Tile[xx][yy] == EL_PLAYER_IS_LEAVING)) @@ -9137,17 +9135,16 @@ static void AmoebaToDiamondBD(int ax, int ay, int new_element) static void AmoebaGrowing(int x, int y) { - static unsigned int sound_delay = 0; - static unsigned int sound_delay_value = 0; + static DelayCounter sound_delay = { 0 }; if (!MovDelay[x][y]) // start new growing cycle { MovDelay[x][y] = 7; - if (DelayReached(&sound_delay, sound_delay_value)) + if (DelayReached(&sound_delay)) { PlayLevelSoundElementAction(x, y, Store[x][y], ACTION_GROWING); - sound_delay_value = 30; + sound_delay.value = 30; } } @@ -9173,15 +9170,14 @@ static void AmoebaGrowing(int x, int y) static void AmoebaShrinking(int x, int y) { - static unsigned int sound_delay = 0; - static unsigned int sound_delay_value = 0; + static DelayCounter sound_delay = { 0 }; if (!MovDelay[x][y]) // start new shrinking cycle { MovDelay[x][y] = 7; - if (DelayReached(&sound_delay, sound_delay_value)) - sound_delay_value = 30; + if (DelayReached(&sound_delay)) + sound_delay.value = 30; } if (MovDelay[x][y]) // wait some time before shrinking @@ -10226,7 +10222,7 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) DisplayGameControlValues(); - if (!TimeLeft && setup.time_limit) + if (!TimeLeft && game.time_limit) for (i = 0; i < MAX_PLAYERS; i++) KillPlayer(&stored_player[i]); } @@ -11636,18 +11632,18 @@ static void CheckLevelTime_StepCounter(void) { TimeLeft--; - if (TimeLeft <= 10 && setup.time_limit && !game.LevelSolved) + if (TimeLeft <= 10 && game.time_limit && !game.LevelSolved) PlaySound(SND_GAME_RUNNING_OUT_OF_TIME); game_panel_controls[GAME_PANEL_TIME].value = TimeLeft; DisplayGameControlValues(); - if (!TimeLeft && setup.time_limit && !game.LevelSolved) + if (!TimeLeft && game.time_limit && !game.LevelSolved) for (i = 0; i < MAX_PLAYERS; i++) KillPlayer(&stored_player[i]); } - else if (game.no_time_limit && !game.all_players_gone) + else if (game.no_level_time_limit && !game.all_players_gone) { game_panel_controls[GAME_PANEL_TIME].value = TimePlayed; @@ -11685,7 +11681,7 @@ static void CheckLevelTime(void) { TimeLeft--; - if (TimeLeft <= 10 && setup.time_limit) + if (TimeLeft <= 10 && game.time_limit) PlaySound(SND_GAME_RUNNING_OUT_OF_TIME); /* this does not make sense: game_panel_controls[GAME_PANEL_TIME].value @@ -11693,7 +11689,7 @@ static void CheckLevelTime(void) game_panel_controls[GAME_PANEL_TIME].value = TimeLeft; - if (!TimeLeft && setup.time_limit) + if (!TimeLeft && game.time_limit) { if (level.game_engine_type == GAME_ENGINE_TYPE_EM) game_em.lev->killed_out_of_time = TRUE; @@ -11702,12 +11698,12 @@ static void CheckLevelTime(void) KillPlayer(&stored_player[i]); } } - else if (game.no_time_limit && !game.all_players_gone) + else if (game.no_level_time_limit && !game.all_players_gone) { game_panel_controls[GAME_PANEL_TIME].value = TimePlayed; } - game_em.lev->time = (game.no_time_limit ? TimePlayed : TimeLeft); + game_em.lev->time = (game.no_level_time_limit ? TimePlayed : TimeLeft); } if (tape.recording || tape.playing) @@ -13194,7 +13190,7 @@ void ScrollPlayer(struct PlayerInfo *player, int mode) if (mode == SCROLL_INIT) { - player->actual_frame_counter = FrameCounter; + player->actual_frame_counter.count = FrameCounter; player->GfxPos = move_stepsize * (player->MovPos / move_stepsize); if ((player->block_last_field || player->block_delay_adjustment > 0) && @@ -13223,7 +13219,7 @@ void ScrollPlayer(struct PlayerInfo *player, int mode) if (player->MovPos != 0) // player has not yet reached destination return; } - else if (!FrameReached(&player->actual_frame_counter, 1)) + else if (!FrameReached(&player->actual_frame_counter)) return; if (player->MovPos != 0) @@ -13346,20 +13342,22 @@ void ScrollPlayer(struct PlayerInfo *player, int mode) void ScrollScreen(struct PlayerInfo *player, int mode) { - static unsigned int screen_frame_counter = 0; + static DelayCounter screen_frame_counter = { 0 }; if (mode == SCROLL_INIT) { // set scrolling step size according to actual player's moving speed ScrollStepSize = TILEX / player->move_delay_value; - screen_frame_counter = FrameCounter; + screen_frame_counter.count = FrameCounter; + screen_frame_counter.value = 1; + ScreenMovDir = player->MovDir; ScreenMovPos = player->MovPos; ScreenGfxPos = ScrollStepSize * (ScreenMovPos / ScrollStepSize); return; } - else if (!FrameReached(&screen_frame_counter, 1)) + else if (!FrameReached(&screen_frame_counter)) return; if (ScreenMovPos) @@ -14881,7 +14879,7 @@ static int DigField(struct PlayerInfo *player, if (level.time > 0 || level.use_time_orb_bug) { TimeLeft += level.time_orb_time; - game.no_time_limit = FALSE; + game.no_level_time_limit = FALSE; game_panel_controls[GAME_PANEL_TIME].value = TimeLeft; @@ -15691,6 +15689,7 @@ void RequestQuitGameExt(boolean skip_request, boolean quick_quit, char *message) { // prevent short reactivation of overlay buttons while closing door SetOverlayActive(FALSE); + UnmapGameButtons(); // door may still be open due to skipped or envelope style request CloseDoor(score_info_tape_play ? DOOR_CLOSE_ALL : DOOR_CLOSE_1); @@ -16298,6 +16297,10 @@ void CreateGameButtons(void) int y = (is_touch_button ? pos->y : GDI_ACTIVE_POS(pos->y)); int id = i; + // do not use touch buttons if overlay touch buttons are disabled + if (is_touch_button && !setup.touch.overlay_buttons) + continue; + if (gfx->bitmap == NULL) { game_gadget[id] = NULL;