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:
Jason Felds
2006-07-21 18:52:15 +00:00
parent b5c16eb9c1
commit 0014c5097e
+54 -20
View File
@@ -10,6 +10,11 @@
#include "song.h" #include "song.h"
#include "Steps.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 #if 0
void KSFLoader::RemoveHoles( NoteData &out, const Song &song ) 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++ ) for( int t=0; t<13; t++ )
iHoldStartRow[t] = -1; iHoldStartRow[t] = -1;
// LOG->Trace("Getting steps from %s now: 500", sPath.c_str());
for( unsigned r=0; r<asRows.size(); r++ ) for( unsigned r=0; r<asRows.size(); r++ )
{ {
RString& sRowString = asRows[r]; RString& sRowString = asRows[r];
@@ -292,6 +299,9 @@ bool KSFLoader::LoadGlobalData( const RString &sPath, Song &out )
RageException::Throw( "Error opening file \"%s\": %s", sPath.c_str(), msd.GetError().c_str() ); 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; 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++ ) for( unsigned i=0; i < msd.GetNumValues(); i++ )
{ {
@@ -307,13 +317,25 @@ bool KSFLoader::LoadGlobalData( const RString &sPath, Song &out )
out.AddBPMSegment( BPMSegment(0, BPM1) ); out.AddBPMSegment( BPMSegment(0, BPM1) );
} }
else if( 0==stricmp(sValueName,"BPM2") ) else if( 0==stricmp(sValueName,"BPM2") )
{
KIUComplient = true;
BPM2 = StringToFloat( sParams[1] ); BPM2 = StringToFloat( sParams[1] );
}
else if( 0==stricmp(sValueName,"BPM3") ) else if( 0==stricmp(sValueName,"BPM3") )
{
KIUComplient = true;
BPM3 = StringToFloat( sParams[1] ); BPM3 = StringToFloat( sParams[1] );
}
else if( 0==stricmp(sValueName,"BUNKI") ) else if( 0==stricmp(sValueName,"BUNKI") )
{
KIUComplient = true;
BPMPos2 = StringToFloat( sParams[1] ) / 100.0f; BPMPos2 = StringToFloat( sParams[1] ) / 100.0f;
}
else if( 0==stricmp(sValueName,"BUNKI2") ) else if( 0==stricmp(sValueName,"BUNKI2") )
{
KIUComplient = true;
BPMPos3 = StringToFloat( sParams[1] ) / 100.0f; BPMPos3 = StringToFloat( sParams[1] ) / 100.0f;
}
else if( 0==stricmp(sValueName,"STARTTIME") ) else if( 0==stricmp(sValueName,"STARTTIME") )
{ {
SMGap1 = -StringToFloat( sParams[1] )/100; SMGap1 = -StringToFloat( sParams[1] )/100;
@@ -321,41 +343,53 @@ bool KSFLoader::LoadGlobalData( const RString &sPath, Song &out )
} }
// This is currently required for more accurate BPM changes. // This is currently required for more accurate BPM changes.
else if( 0==stricmp(sValueName,"STARTTIME2") ) else if( 0==stricmp(sValueName,"STARTTIME2") )
{
KIUComplient = true;
SMGap2 = -StringToFloat( sParams[1] )/100; 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") || else if( 0==stricmp(sValueName,"TICKCOUNT") ||
0==stricmp(sValueName,"STEP") || 0==stricmp(sValueName,"STEP") ||
0==stricmp(sValueName,"DIFFICULTY") || 0==stricmp(sValueName,"DIFFICULTY"))
0==stricmp(sValueName,"STARTTIME3") )
{ {
/* TICKCOUNT, STEP, and DIFFICULTY are handled in LoadFromKSFFile. /* TICKCOUNT, STEP, and DIFFICULTY are handled in LoadFromKSFFile.
* STARTTIME3 is expected but unnecessary. Do not warn. */ * Do not warn for them. */
continue; continue;
} }
else else
LOG->Trace( "Unexpected value named '%s'", sValueName.c_str() ); LOG->Trace( "Unexpected value named '%s'", sValueName.c_str() );
} }
/* At this time, only KSF files that use the traditional syntax can be /* The KIU BPM syntax puts all of its changes at the top, making it easier
* converted, and even then, not all of them will work smoothly. The * and faster to get the right data. Otherwise, we've got one of two situations:
* formulas are more accurate at this point, however. As soon as support * a KSF file with no BPM changes whatsoever, or a KSF file with Direct Move
* for the other Pump simulators is supported (mostly Direct Move), this * syntax. Unfortunately, they will require a further scan in order to determine
* section will be expanded. */ * whether or not there are changes, or even stops, within the file. That will be
if( BPM2 > 0 && BPMPos2 > 0 ) * implemented later. */
if (KIUComplient)
{ {
const float BeatsPerSecond = BPM1 / 60.0f; if( BPM2 > 0 && BPMPos2 > 0 )
const float beat = (BPMPos2 + SMGap1) * BeatsPerSecond; {
LOG->Trace( "BPM %f, BPS %f, BPMPos2 %f, beat %f", 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 ); BPM1, BeatsPerSecond, BPMPos2, beat );
out.AddBPMSegment( BPMSegment(BeatToNoteRow(beat), BPM2) ); out.AddBPMSegment( BPMSegment(BeatToNoteRow(beat), BPM2) );
} }
if( BPM3 > 0 && BPMPos3 > 0 ) if( BPM3 > 0 && BPMPos3 > 0 )
{ {
const float BeatsPerSecond = BPM2 / 60.0f; const float BeatsPerSecond = BPM2 / 60.0f;
const float beat = (BPMPos3 + SMGap2) * BeatsPerSecond; //The line below isn't perfect, but works better than previous versions.
LOG->Trace( "BPM %f, BPS %f, BPMPos3 %f, beat %f", const float beat = (BPMPos3 + SMGap2) * BeatsPerSecond;
LOG->Trace( "BPM %f, BPS %f, BPMPos3 %f, beat %f",
BPM2, BeatsPerSecond, BPMPos3, beat ); 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. */ /* Try to fill in missing bits of information from the pathname. */