diff --git a/src/bflib_sndlib.cpp b/src/bflib_sndlib.cpp index 1864da8069..645a743cce 100644 --- a/src/bflib_sndlib.cpp +++ b/src/bflib_sndlib.cpp @@ -500,7 +500,9 @@ extern "C" void set_music_volume(SoundVolume value) { extern "C" TbBool play_music(const char * fname) { std::lock_guard guard(g_mix_mutex); - game.music_track = -1; + if (strcmp(game.music_fname, fname) == 0) + return false; + game.music_track = -1; snprintf(game.music_fname, sizeof(game.music_fname), "%s", fname); // Mix_PlayMusic will stop anything currently playing and eventually // calls on_music_finished so theres no need to call Mix_FreeMusic first. diff --git a/src/lvl_script_commands.c b/src/lvl_script_commands.c index 4fb043ec04..99554f89e0 100644 --- a/src/lvl_script_commands.c +++ b/src/lvl_script_commands.c @@ -4363,15 +4363,17 @@ static void set_music_check(const struct ScriptLine *scline) static void set_music_process(struct ScriptContext *context) { short track = context->value->chars[0]; + if ((track > 0) && (game.music_track == track)) + { + return; + } if (track == 0) { SCRPTLOG("Stopping music"); stop_music(); } else if (track < 0) { const char * fname = script_strval(context->value->longs[1]); - SCRPTLOG("Playing music from %s", fname); play_music(prepare_file_fmtpath(FGrp_CmpgMedia, "%s", fname)); } else { - SCRPTLOG("Playing music track %d", track); play_music_track(track); } }