More Direct Move syntax preparation. If the global variable is not recommended (it will be needed in KSFLoader::LoadFromKSFFile), please advise or make the recommende fixes.
This commit is contained in:
@@ -10,6 +10,11 @@
|
||||
#include "song.h"
|
||||
#include "Steps.h"
|
||||
|
||||
/* Global variables aren't the best way to go about this, but this
|
||||
* will be required to start implementing the Direct Move syntax. */
|
||||
|
||||
bool KIUComplient;
|
||||
|
||||
#if 0
|
||||
void KSFLoader::RemoveHoles( NoteData &out, const Song &song )
|
||||
{
|
||||
@@ -159,6 +164,8 @@ bool KSFLoader::LoadFromKSFFile( const RString &sPath, Steps &out, const Song &s
|
||||
for( int t=0; t<13; t++ )
|
||||
iHoldStartRow[t] = -1;
|
||||
|
||||
// LOG->Trace("Getting steps from %s now: 500", sPath.c_str());
|
||||
|
||||
for( unsigned r=0; r<asRows.size(); r++ )
|
||||
{
|
||||
RString& sRowString = asRows[r];
|
||||
@@ -292,7 +299,10 @@ bool KSFLoader::LoadGlobalData( const RString &sPath, Song &out )
|
||||
RageException::Throw( "Error opening file \"%s\": %s", sPath.c_str(), msd.GetError().c_str() );
|
||||
|
||||
float SMGap1 = 0, SMGap2 = 0, BPM1 = -1, BPMPos2 = -1, BPM2 = -1, BPMPos3 = -1, BPM3 = -1;
|
||||
KIUComplient = false;
|
||||
|
||||
// LOG->Trace("Getting tags for %s now: 300", sPath.c_str());
|
||||
|
||||
for( unsigned i=0; i < msd.GetNumValues(); i++ )
|
||||
{
|
||||
const MsdFile::value_t &sParams = msd.GetValue(i);
|
||||
@@ -307,13 +317,25 @@ bool KSFLoader::LoadGlobalData( const RString &sPath, Song &out )
|
||||
out.AddBPMSegment( BPMSegment(0, BPM1) );
|
||||
}
|
||||
else if( 0==stricmp(sValueName,"BPM2") )
|
||||
{
|
||||
KIUComplient = true;
|
||||
BPM2 = StringToFloat( sParams[1] );
|
||||
}
|
||||
else if( 0==stricmp(sValueName,"BPM3") )
|
||||
{
|
||||
KIUComplient = true;
|
||||
BPM3 = StringToFloat( sParams[1] );
|
||||
}
|
||||
else if( 0==stricmp(sValueName,"BUNKI") )
|
||||
{
|
||||
KIUComplient = true;
|
||||
BPMPos2 = StringToFloat( sParams[1] ) / 100.0f;
|
||||
}
|
||||
else if( 0==stricmp(sValueName,"BUNKI2") )
|
||||
{
|
||||
KIUComplient = true;
|
||||
BPMPos3 = StringToFloat( sParams[1] ) / 100.0f;
|
||||
}
|
||||
else if( 0==stricmp(sValueName,"STARTTIME") )
|
||||
{
|
||||
SMGap1 = -StringToFloat( sParams[1] )/100;
|
||||
@@ -321,42 +343,54 @@ bool KSFLoader::LoadGlobalData( const RString &sPath, Song &out )
|
||||
}
|
||||
// This is currently required for more accurate BPM changes.
|
||||
else if( 0==stricmp(sValueName,"STARTTIME2") )
|
||||
{
|
||||
KIUComplient = true;
|
||||
SMGap2 = -StringToFloat( sParams[1] )/100;
|
||||
}
|
||||
else if ( 0==stricmp(sValueName,"STARTTIME3") )
|
||||
{
|
||||
// STARTTIME3 only ensures this is a KIU complient simfile.
|
||||
KIUComplient = true;
|
||||
}
|
||||
else if( 0==stricmp(sValueName,"TICKCOUNT") ||
|
||||
0==stricmp(sValueName,"STEP") ||
|
||||
0==stricmp(sValueName,"DIFFICULTY") ||
|
||||
0==stricmp(sValueName,"STARTTIME3") )
|
||||
0==stricmp(sValueName,"DIFFICULTY"))
|
||||
{
|
||||
/* TICKCOUNT, STEP, and DIFFICULTY are handled in LoadFromKSFFile.
|
||||
* STARTTIME3 is expected but unnecessary. Do not warn. */
|
||||
* Do not warn for them. */
|
||||
continue;
|
||||
}
|
||||
else
|
||||
LOG->Trace( "Unexpected value named '%s'", sValueName.c_str() );
|
||||
}
|
||||
|
||||
/* At this time, only KSF files that use the traditional syntax can be
|
||||
* converted, and even then, not all of them will work smoothly. The
|
||||
* formulas are more accurate at this point, however. As soon as support
|
||||
* for the other Pump simulators is supported (mostly Direct Move), this
|
||||
* section will be expanded. */
|
||||
if( BPM2 > 0 && BPMPos2 > 0 )
|
||||
/* 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. */
|
||||
if (KIUComplient)
|
||||
{
|
||||
const float BeatsPerSecond = BPM1 / 60.0f;
|
||||
const float beat = (BPMPos2 + SMGap1) * BeatsPerSecond;
|
||||
LOG->Trace( "BPM %f, BPS %f, BPMPos2 %f, beat %f",
|
||||
if( BPM2 > 0 && BPMPos2 > 0 )
|
||||
{
|
||||
const float BeatsPerSecond = BPM1 / 60.0f;
|
||||
const float beat = (BPMPos2 + SMGap1) * BeatsPerSecond;
|
||||
LOG->Trace( "BPM %f, BPS %f, BPMPos2 %f, beat %f",
|
||||
BPM1, BeatsPerSecond, BPMPos2, beat );
|
||||
out.AddBPMSegment( BPMSegment(BeatToNoteRow(beat), BPM2) );
|
||||
}
|
||||
|
||||
if( BPM3 > 0 && BPMPos3 > 0 )
|
||||
{
|
||||
const float BeatsPerSecond = BPM2 / 60.0f;
|
||||
const float beat = (BPMPos3 + SMGap2) * BeatsPerSecond;
|
||||
LOG->Trace( "BPM %f, BPS %f, BPMPos3 %f, beat %f",
|
||||
out.AddBPMSegment( BPMSegment(BeatToNoteRow(beat), BPM2) );
|
||||
}
|
||||
|
||||
if( BPM3 > 0 && BPMPos3 > 0 )
|
||||
{
|
||||
const float BeatsPerSecond = BPM2 / 60.0f;
|
||||
//The line below isn't perfect, but works better than previous versions.
|
||||
const float beat = (BPMPos3 + SMGap2) * BeatsPerSecond;
|
||||
LOG->Trace( "BPM %f, BPS %f, BPMPos3 %f, beat %f",
|
||||
BPM2, BeatsPerSecond, BPMPos3, beat );
|
||||
out.AddBPMSegment( BPMSegment(BeatToNoteRow(beat), BPM3) );
|
||||
}
|
||||
out.AddBPMSegment( BPMSegment(BeatToNoteRow(beat), BPM3) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Try to fill in missing bits of information from the pathname. */
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user