Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/bflib_sndlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,9 @@ extern "C" void set_music_volume(SoundVolume value) {

extern "C" TbBool play_music(const char * fname) {
std::lock_guard<std::mutex> 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.
Expand Down
6 changes: 4 additions & 2 deletions src/lvl_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Loading