diff --git a/src/NotesLoaderSMA.cpp b/src/NotesLoaderSMA.cpp index 291f831e17..f2dc1f27d4 100644 --- a/src/NotesLoaderSMA.cpp +++ b/src/NotesLoaderSMA.cpp @@ -48,6 +48,7 @@ void SMALoader::ProcessMultipliers( TimingData &out, const int iRowsPerBeat, con void SMALoader::ProcessBeatsPerMeasure( TimingData &out, const RString sParam ) { std::vector vs1; + std::vector segments; split( sParam, ",", vs1 ); for (RString const &s1 : vs1) @@ -82,8 +83,21 @@ void SMALoader::ProcessBeatsPerMeasure( TimingData &out, const RString sParam ) fBeat, iNumerator ); continue; } + segments.push_back( TimeSignatureSegment(BeatToNoteRow(fBeat), iNumerator) ); + } - out.AddSegment( TimeSignatureSegment(BeatToNoteRow(fBeat), iNumerator) ); + // If there are any time signatures defined, but there isn't one + // for the very first beat of the song, then add one. + // Without it, calls to functions like TimingData::NoteRowToMeasureAndBeat + // can fail for charts that are otherwise valid. + if ( segments.size() > 0 && segments[0].GetRow() > 0 ) + { + out.AddSegment( TimeSignatureSegment(0, 4, 4) ); + } + + for( TimeSignatureSegment segment: segments ) + { + out.AddSegment( segment ); } }