fixed music bug for Momir and Random game types. The functions that determined if a file existed did not handle errors properly. Instead it would return an empty string which when appended to the base path would always return true. Thus a non-existent file would always be treated as if it existed. The guards I put in test for empty strings before continuing evaluation. I may have been a little judicious in the places where I put the gaurds in. We can remove the guards if it turns out we don't need them in all the places.

This commit is contained in:
techdragon.nguyen@gmail.com
2012-02-23 02:11:14 +00:00
parent 3d62be4549
commit 42cdd27e0b
4 changed files with 10 additions and 3 deletions

View File

@@ -242,7 +242,10 @@ void GameStateDuel::End()
//TODO Move This to utils or ResourceManager. Don't we have more generic functions that can do that?
bool GameStateDuel::MusicExist(string FileName)
{
return FileExists(WResourceManager::Instance()->musicFile(FileName));
string musicFilename = WResourceManager::Instance()->musicFile(FileName);
if (musicFilename.length() < 1) return false;
return FileExists(musicFilename);
}
void GameStateDuel::ConstructOpponentMenu()
@@ -438,7 +441,8 @@ void GameStateDuel::Update(float dt)
else if (mParent->gameType == GAME_TYPE_RANDOM1 || mParent->gameType == GAME_TYPE_RANDOM2) musictrack
= "ai_baka_music_random.mp3";
if (!MusicExist(musictrack)) musictrack = "ai_baka_music.mp3";
if (!MusicExist(musictrack))
musictrack = "ai_baka_music.mp3";
GameApp::playMusic(musictrack);
}