sort input

clear input, so we don't accumulate if we load twice
This commit is contained in:
Glenn Maynard
2003-03-25 01:14:53 +00:00
parent 92c44716f8
commit 51b9c3beec
+8
View File
@@ -13,6 +13,10 @@
#include <map> #include <map>
using namespace std; using namespace std;
static int CompareLyricSegments(const LyricSegment &seg1, const LyricSegment &seg2)
{
return seg1.m_fStartTime < seg2.m_fStartTime;
}
bool LyricsLoader::LoadFromLRCFile( CString sPath, Song &out ) bool LyricsLoader::LoadFromLRCFile( CString sPath, Song &out )
{ {
@@ -29,6 +33,8 @@ bool LyricsLoader::LoadFromLRCFile( CString sPath, Song &out )
RageColor CurrentColor(0,1,0,1); RageColor CurrentColor(0,1,0,1);
out.m_LyricSegments.clear();
while(input.good() && getline(input, line)) while(input.good() && getline(input, line))
{ {
if(!line.compare(0, 2, "//")) if(!line.compare(0, 2, "//"))
@@ -83,6 +89,8 @@ bool LyricsLoader::LoadFromLRCFile( CString sPath, Song &out )
} }
sort( out.m_LyricSegments.begin(), out.m_LyricSegments.end(), CompareLyricSegments );
return true; return true;
} }