Skip to content

Commit

Permalink
Don't hang when Inn music failed to load. Fixes EasyRPG#956
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghabry committed Aug 1, 2016
1 parent 3448f30 commit 877baa2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/audio_sdl.cpp
Expand Up @@ -246,15 +246,11 @@ void SdlAudio::BGM_OnPlayedOnce() {
}

void SdlAudio::BGM_Play(std::string const& file, int volume, int pitch, int fadein) {
bgm_stop = false;
played_once = false;

FILE* filehandle = FileFinder::fopenUTF8(file, "rb");
if (!filehandle) {
Output::Warning("Music not readable: %s", file.c_str());
return;
}

audio_decoder = AudioDecoder::Create(filehandle, file);
if (audio_decoder) {
SetupAudioDecoder(filehandle, file, volume, pitch, fadein);
Expand All @@ -264,6 +260,9 @@ void SdlAudio::BGM_Play(std::string const& file, int volume, int pitch, int fade

SDL_RWops *rw = SDL_RWFromFile(file.c_str(), "rb");

bgm_stop = false;
played_once = false;

#if SDL_MIXER_MAJOR_VERSION>1
bgm.reset(Mix_LoadMUS_RW(rw, 0), &Mix_FreeMusic);
#else
Expand Down
7 changes: 6 additions & 1 deletion src/game_interpreter_map.cpp
Expand Up @@ -480,7 +480,12 @@ bool Game_Interpreter_Map::ContinuationShowInnFinish(RPG::EventCommand const& /*
return false;

const RPG::Music& bgm_inn = Game_System::GetSystemBGM(Game_System::BGM_Inn);
if (bgm_inn.name.empty() || bgm_inn.name == "(OFF)" || bgm_inn.name == "(Brak)" || Audio().BGM_PlayedOnce()) {
if (bgm_inn.name.empty() ||
bgm_inn.name == "(OFF)" ||
bgm_inn.name == "(Brak)" ||
!Audio().BGM_IsPlaying() ||
Audio().BGM_PlayedOnce()) {

Game_System::BgmStop();
continuation = NULL;
Graphics::Transition(Graphics::TransitionFadeIn, 36, false);
Expand Down

0 comments on commit 877baa2

Please sign in to comment.