diff --git a/stepmania/src/NotesLoaderKSF.cpp b/stepmania/src/NotesLoaderKSF.cpp index 8f8bbfbf70..2358179dc3 100644 --- a/stepmania/src/NotesLoaderKSF.cpp +++ b/stepmania/src/NotesLoaderKSF.cpp @@ -70,7 +70,8 @@ bool KSFLoader::LoadFromKSFFile( const RString &sPath, Steps &out, const Song &s if( !msd.ReadFile( sPath ) ) RageException::Throw( "Error opening file '%s'.", sPath.c_str() ); - m_bTickCount = -1; // this is the value we read for TICKCOUNT + m_iTickCount = -1; // this is the value we read for TICKCOUNT + m_vNoteRows.clear(); //Start from a clean slate. for( unsigned i=0; iWarn( "Invalid tick count: %d", m_bTickCount ); + LOG->Warn( "Invalid tick count: %d", m_iTickCount ); return false; } } else if( 0==stricmp(sValueName,"STEP") ) { - continue; // This was handled in LoadGlobalData: no need to repeat. + RString theSteps = sParams[1]; + TrimLeft( theSteps ); + split( theSteps, "\n", m_vNoteRows, true ); } else if( 0==stricmp(sValueName,"DIFFICULTY") ) { @@ -98,10 +101,10 @@ bool KSFLoader::LoadFromKSFFile( const RString &sPath, Steps &out, const Song &s } } - if( m_bTickCount == -1 ) + if( m_iTickCount == -1 ) { - m_bTickCount = 2; - LOG->Warn( "\"%s\": TICKCOUNT not found; defaulting to %i", sPath.c_str(), m_bTickCount ); + m_iTickCount = 2; + LOG->Warn( "\"%s\": TICKCOUNT not found; defaulting to %i", sPath.c_str(), m_iTickCount ); } NoteData notedata; // read it into here @@ -164,11 +167,11 @@ bool KSFLoader::LoadFromKSFFile( const RString &sPath, Steps &out, const Song &s m_bTickChangeNeeded = false; int newTick = -1; - m_bCurBeat = 0.0f; + m_fCurBeat = 0.0f; float prevBeat = 0.0f; // Used for hold tails. - for( unsigned r=0; r 0 ? m_bTickCount : 2; + m_iTickCount = atoi( sParams[1] ); + m_iTickCount = m_iTickCount > 0 ? m_iTickCount : 2; } else if ( 0==stricmp(sValueName,"STEP") ) { /* STEP will always be the last header in a KSF file by design. Due to * the Direct Move syntax, it is best to get the rows of notes here. */ - theSteps = sParams[1]; + RString theSteps = sParams[1]; TrimLeft( theSteps ); - split( theSteps, "\n", m_bNoteRows, true ); + split( theSteps, "\n", m_vNoteRows, true ); } else if( 0==stricmp(sValueName,"DIFFICULTY")) @@ -409,12 +420,10 @@ bool KSFLoader::LoadGlobalData( const RString &sPath, Song &out ) LOG->Trace( "Unexpected value named '%s'", sValueName.c_str() ); } - /* The KIU BPM syntax puts all of its changes at the top, making it easier - * and faster to get the right data. Otherwise, we've got one of two situations: - * a KSF file with no BPM changes whatsoever, or a KSF file with Direct Move - * syntax. Unfortunately, they will require a further scan in order to determine - * whether or not there are changes, or even stops, within the file. That will be - * implemented later. */ + /* BPM Change checks are done here. If m_bKIUCompliant, it's short and sweet. + * Otherwise, the whole file has to be processed. Right now, this is only + * called once, for the initial file (often the Crazy steps). Hopefully that + * will end up changing soon. */ if (m_bKIUCompliant) { if( BPM2 > 0 && BPMPos2 > 0 ) @@ -439,14 +448,14 @@ bool KSFLoader::LoadGlobalData( const RString &sPath, Song &out ) else { - int tickToChange = m_bTickCount; - m_bCurBeat = 0.0f; + int tickToChange = m_iTickCount; + m_fCurBeat = 0.0f; float speedToChange = 0.0f, timeToStop = 0.0f; m_bDMRequired = m_bBPMChangeNeeded = m_bBPMStopNeeded = m_bTickChangeNeeded = false; - for (unsigned i=0; i < m_bNoteRows.size(); i++) + for (unsigned i=0; i < m_vNoteRows.size(); i++) { - RString& NoteRowString = m_bNoteRows[i]; + RString& NoteRowString = m_vNoteRows[i]; StripCrnl( NoteRowString ); if( NoteRowString == "" ) @@ -498,28 +507,25 @@ bool KSFLoader::LoadGlobalData( const RString &sPath, Song &out ) if (m_bTickChangeNeeded) { - m_bTickCount = tickToChange; + m_iTickCount = tickToChange; m_bTickChangeNeeded = false; } if (m_bBPMChangeNeeded) { - LOG->Trace( "Adding tempo change of %f BPM at beat %f", speedToChange, m_bCurBeat); - out.AddBPMSegment(BPMSegment(BeatToNoteRow(m_bCurBeat),speedToChange)); + LOG->Trace( "Adding tempo change of %f BPM at beat %f", speedToChange, m_fCurBeat); + out.AddBPMSegment(BPMSegment(BeatToNoteRow(m_fCurBeat),speedToChange)); m_bBPMChangeNeeded = false; } if (m_bBPMStopNeeded) { - LOG->Trace( "Adding tempo freeze of %f seconds at beat %f", timeToStop, m_bCurBeat); - out.AddStopSegment(StopSegment(BeatToNoteRow(m_bCurBeat),timeToStop)); + LOG->Trace( "Adding tempo freeze of %f seconds at beat %f", timeToStop, m_fCurBeat); + out.AddStopSegment(StopSegment(BeatToNoteRow(m_fCurBeat),timeToStop)); m_bBPMStopNeeded = false; } - m_bCurBeat += 1.0f / m_bTickCount; + m_fCurBeat += 1.0f / m_iTickCount; } } - //if (m_bDMRequired) - // LOG->Warn("%s uses the Direct Move syntax; at this point, mileage may vary.", sPath.c_str()); - /* Try to fill in missing bits of information from the pathname. */ { vector asBits; @@ -552,6 +558,9 @@ bool KSFLoader::LoadFromDir( const RString &sDir, Song &out ) if( arrayKSFFileNames.empty() ) RageException::Throw( "Couldn't find any KSF files in '%s'", sDir.c_str() ); + /* If only the first file is read, it will cause problems for other simfiles with + * different BPM changes and tickcounts. This command will probably have to be + * changed in the future. */ if( !LoadGlobalData(out.GetSongDir() + arrayKSFFileNames[0], out) ) return false; diff --git a/stepmania/src/NotesLoaderKSF.h b/stepmania/src/NotesLoaderKSF.h index acc317cfc3..30d29fdda5 100644 --- a/stepmania/src/NotesLoaderKSF.h +++ b/stepmania/src/NotesLoaderKSF.h @@ -26,9 +26,9 @@ private: bool m_bBPMChangeNeeded; bool m_bBPMStopNeeded; bool m_bTickChangeNeeded; - int m_bTickCount; - float m_bCurBeat; - vector m_bNoteRows; + int m_iTickCount; + float m_fCurBeat; + vector m_vNoteRows; };