diff --git a/stepmania/src/NotesLoaderBMS.cpp b/stepmania/src/NotesLoaderBMS.cpp index 41dde60260..096a2fd03c 100644 --- a/stepmania/src/NotesLoaderBMS.cpp +++ b/stepmania/src/NotesLoaderBMS.cpp @@ -285,6 +285,15 @@ bool BMSLoader::LoadFromBMSFile( const RString &sPath, const NameToData_t &mapNa MeasureToTimeSig_t mapMeasureToTimeSig; ReadTimeSigs( mapNameToData, mapMeasureToTimeSig ); + int iHoldStarts[NUM_BMS_TRACKS]; + int iHoldPrevs[NUM_BMS_TRACKS]; + + for( int i = 0; i < NUM_BMS_TRACKS; ++i ) + { + iHoldStarts[i] = -1; + iHoldPrevs[i] = -1; + } + NameToData_t::const_iterator it; for( it = mapNameToData.lower_bound("#00000"); it != mapNameToData.end(); ++it ) { @@ -305,11 +314,10 @@ bool BMSLoader::LoadFromBMSFile( const RString &sPath, const NameToData_t &mapNa RString sNoteId = sNoteData.substr( i, 2 ); if( sNoteId != "00" ) { - TapNote tn = TAP_ORIGINAL_TAP; + vTapNotes.push_back( TAP_ORIGINAL_TAP ); map::const_iterator it = m_mapWavIdToKeysoundIndex.find( sNoteId ); if( it != m_mapWavIdToKeysoundIndex.end() ) - tn.iKeysoundIndex = it->second; - vTapNotes.push_back( tn ); + vTapNotes.back().iKeysoundIndex = it->second; } else { @@ -320,30 +328,29 @@ bool BMSLoader::LoadFromBMSFile( const RString &sPath, const NameToData_t &mapNa const unsigned uNumNotesInThisMeasure = vTapNotes.size(); for( unsigned j=0; j= BMS_AUTO_KEYSOUND_1 ) + iLastEmptyTrack >= BMS_AUTO_KEYSOUND_1 ) { + tn.type = TapNote::autoKeysound; bmsTrack = (BmsTrack)iLastEmptyTrack; } else @@ -354,20 +361,53 @@ bool BMSLoader::LoadFromBMSFile( const RString &sPath, const NameToData_t &mapNa } else if( bIsHold ) { - tn.type = TapNote::hold_head; + if( iHoldStarts[bmsTrack] == -1 ) + { + // Start of a hold. + iHoldStarts[bmsTrack] = row; + iHoldPrevs[bmsTrack] = row; + } + else + { + // We're continuing a hold. + iHoldPrevs[bmsTrack] = row; + } + continue; } - else - { - tn.type = TapNote::tap; - } - - ndNotes.SetTapNote( bmsTrack, row, tn ); } + if( iHoldStarts[bmsTrack] != -1 ) + { + // This is ending a hold. + const int iBegin = iHoldStarts[bmsTrack]; + const int iEnd = iHoldPrevs[bmsTrack]; + + if( iBegin < iEnd ) + ndNotes.AddHoldNote( bmsTrack, iBegin, iEnd, TAP_ORIGINAL_HOLD_HEAD ); + else + ndNotes.SetTapNote( bmsTrack, iBegin, TAP_ORIGINAL_TAP ); + iHoldStarts[bmsTrack] = -1; + iHoldPrevs[bmsTrack] = -1; + } + // Don't bother inserting empty taps. + if( tn.type != TapNote::empty ) + ndNotes.SetTapNote( bmsTrack, row, tn ); } } } - // we're done reading in all of the BMS values + // We're done reading in all of the BMS values. Time to check for any unfinished holds. + for( int iTrack = 0; iTrack < NUM_BMS_TRACKS; ++iTrack ) + { + const int iBegin = iHoldStarts[iTrack]; + const int iEnd = iHoldPrevs[iTrack]; + + if( iBegin == -1 ) + continue; + if( iBegin < iEnd ) + ndNotes.AddHoldNote( iTrack, iBegin, iEnd, TAP_ORIGINAL_HOLD_HEAD ); + else + ndNotes.SetTapNote( iTrack, iBegin, TAP_ORIGINAL_TAP ); + } out.m_StepsType = DetermineStepsType( iPlayer, ndNotes ); if( out.m_StepsType == STEPS_TYPE_INVALID )