From 18b2ff07b35cfa9831999b65e963c41771e49cf6 Mon Sep 17 00:00:00 2001 From: Thai Pangsakulyanont Date: Sun, 9 Oct 2011 18:33:45 +0700 Subject: [PATCH] fix a bug when the BMS file has a keysounded note, but the #WAV entry points to a file with invalid name, or points to a nonexistant file, for example #WAVAA NoSuchFile.wav #00101:AA In which case, the note will be assigned the first valid keysound, instead of not being assigned keysound at all. This is a very silly bug with a simple fix, but didn't manage to fix it before SM5P4 comes out. Sorry for that. --- src/NotesLoaderBMS.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/NotesLoaderBMS.cpp b/src/NotesLoaderBMS.cpp index f964d3f31e..91277e70af 100644 --- a/src/NotesLoaderBMS.cpp +++ b/src/NotesLoaderBMS.cpp @@ -274,7 +274,7 @@ class BMSSong { public: BMSSong( Song *song ); - unsigned AllocateKeysound( RString filename, RString path ); + int AllocateKeysound( RString filename, RString path ); Song *GetSong(); }; @@ -294,7 +294,7 @@ Song *BMSSong::GetSong() return out; } -unsigned BMSSong::AllocateKeysound( RString filename, RString path ) +int BMSSong::AllocateKeysound( RString filename, RString path ) { if( mapKeysoundToIndex.find( filename ) != mapKeysoundToIndex.end() ) { @@ -306,7 +306,7 @@ unsigned BMSSong::AllocateKeysound( RString filename, RString path ) // FIXME: garbled song names seem to crash the app. // this might not be the best place to put this code. if( !utf8_is_valid(filename) ) - return false; + return -1; /* Due to bugs in some programs, many BMS files have a "WAV" extension * on files in the BMS for files that actually have some other extension. @@ -336,7 +336,7 @@ unsigned BMSSong::AllocateKeysound( RString filename, RString path ) { mapKeysoundToIndex[filename] = -1; LOG->UserLog( "Song file", dir, "references key \"%s\" that can't be found", normalizedFilename.c_str() ); - return false; + return -1; } if( mapKeysoundToIndex.find( normalizedFilename ) != mapKeysoundToIndex.end() )