X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=ee6de4e8fd13b2ee20f78413c8c628b648c6e118;hb=aeb435acf0e7c74ff293f4958cf969ff82eac89d;hp=8978e70750489ebe4c15af503f0d3ae9c461537c;hpb=47da774c66f9325f9d27cddb5a697514154e2de9;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 8978e707..ee6de4e8 100644 --- a/src/game.c +++ b/src/game.c @@ -1052,6 +1052,7 @@ static void PlayLevelSoundElementActionIfLoop(int, int, int, int); static void PlayLevelSoundActionIfLoop(int, int, int); static void StopLevelSoundActionIfLoop(int, int, int); static void PlayLevelMusic(); +static void FadeLevelSoundsAndMusic(); static void HandleGameButtons(struct GadgetInfo *); @@ -3118,7 +3119,7 @@ void InitGame() if (CheckIfGlobalBorderHasChanged()) fade_mask = REDRAW_ALL; - FadeSoundsAndMusic(); + FadeLevelSoundsAndMusic(); ExpireSoundLoops(TRUE); @@ -11212,7 +11213,7 @@ void GameActionsExt() AdvanceFrameAndPlayerCounters(-1); /* advance counters for all players */ - if (options.debug) /* calculate frames per second */ + if (global.show_frames_per_second) { static unsigned int fps_counter = 0; static int fps_frames = 0; @@ -11220,15 +11221,20 @@ void GameActionsExt() fps_frames++; - if (fps_delay_ms >= 500) /* calculate fps every 0.5 seconds */ + if (fps_delay_ms >= 500) /* calculate FPS every 0.5 seconds */ { global.frames_per_second = 1000 * (float)fps_frames / fps_delay_ms; fps_frames = 0; fps_counter = Counter(); + + /* always draw FPS to screen after FPS value was updated */ + redraw_mask |= REDRAW_FPS; } - redraw_mask |= REDRAW_FPS; + /* only draw FPS if no screen areas are deactivated (invisible warp mode) */ + if (GetDrawDeactivationMask() == REDRAW_NONE) + redraw_mask |= REDRAW_FPS; } } @@ -14227,12 +14233,43 @@ static void StopLevelSoundActionIfLoop(int x, int y, int action) StopSound(sound_effect); } -static void PlayLevelMusic() +static int getLevelMusicNr() { if (levelset.music[level_nr] != MUS_UNDEFINED) - PlayMusic(levelset.music[level_nr]); /* from config file */ + return levelset.music[level_nr]; /* from config file */ else - PlayMusic(MAP_NOCONF_MUSIC(level_nr)); /* from music dir */ + return MAP_NOCONF_MUSIC(level_nr); /* from music dir */ +} + +static void FadeLevelSounds() +{ + FadeSounds(); +} + +static void FadeLevelMusic() +{ + int music_nr = getLevelMusicNr(); + char *curr_music = getCurrentlyPlayingMusicFilename(); + char *next_music = getMusicListEntry(music_nr)->filename; + + if (!strEqual(curr_music, next_music)) + FadeMusic(); +} + +void FadeLevelSoundsAndMusic() +{ + FadeLevelSounds(); + FadeLevelMusic(); +} + +static void PlayLevelMusic() +{ + int music_nr = getLevelMusicNr(); + char *curr_music = getCurrentlyPlayingMusicFilename(); + char *next_music = getMusicListEntry(music_nr)->filename; + + if (!strEqual(curr_music, next_music)) + PlayMusic(music_nr); } void PlayLevelSound_EM(int xx, int yy, int element_em, int sample)