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.
This commit is contained in:
Thai Pangsakulyanont
2011-10-09 18:33:45 +07:00
parent aacd7e25be
commit 18b2ff07b3
+4 -4
View File
@@ -274,7 +274,7 @@ class BMSSong {
public: public:
BMSSong( Song *song ); BMSSong( Song *song );
unsigned AllocateKeysound( RString filename, RString path ); int AllocateKeysound( RString filename, RString path );
Song *GetSong(); Song *GetSong();
}; };
@@ -294,7 +294,7 @@ Song *BMSSong::GetSong()
return out; return out;
} }
unsigned BMSSong::AllocateKeysound( RString filename, RString path ) int BMSSong::AllocateKeysound( RString filename, RString path )
{ {
if( mapKeysoundToIndex.find( filename ) != mapKeysoundToIndex.end() ) 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. // FIXME: garbled song names seem to crash the app.
// this might not be the best place to put this code. // this might not be the best place to put this code.
if( !utf8_is_valid(filename) ) if( !utf8_is_valid(filename) )
return false; return -1;
/* Due to bugs in some programs, many BMS files have a "WAV" extension /* 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. * 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; mapKeysoundToIndex[filename] = -1;
LOG->UserLog( "Song file", dir, "references key \"%s\" that can't be found", normalizedFilename.c_str() ); 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() ) if( mapKeysoundToIndex.find( normalizedFilename ) != mapKeysoundToIndex.end() )