2011-03-17 01:47:30 -04:00
|
|
|
#include "global.h"
|
|
|
|
|
#include "NotesLoaderSSC.h"
|
|
|
|
|
#include "BackgroundUtil.h"
|
|
|
|
|
#include "GameManager.h"
|
|
|
|
|
#include "MsdFile.h" // No JSON here.
|
|
|
|
|
#include "NoteTypes.h"
|
2011-05-09 23:16:56 -04:00
|
|
|
#include "NotesLoaderSM.h" // For programming shortcuts.
|
2011-03-17 01:47:30 -04:00
|
|
|
#include "RageFileManager.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "Song.h"
|
|
|
|
|
#include "SongManager.h"
|
|
|
|
|
#include "Steps.h"
|
2011-04-17 23:03:39 -04:00
|
|
|
#include "Attack.h"
|
2011-03-17 01:47:30 -04:00
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
|
2011-05-16 10:02:57 -04:00
|
|
|
void SSCLoader::ProcessWarps( TimingData &out, const RString sParam, const float fVersion )
|
2011-05-09 22:42:46 -04:00
|
|
|
{
|
|
|
|
|
vector<RString> arrayWarpExpressions;
|
|
|
|
|
split( sParam, ",", arrayWarpExpressions );
|
|
|
|
|
|
|
|
|
|
for( unsigned b=0; b<arrayWarpExpressions.size(); b++ )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> arrayWarpValues;
|
|
|
|
|
split( arrayWarpExpressions[b], "=", arrayWarpValues );
|
|
|
|
|
if( arrayWarpValues.size() != 2 )
|
|
|
|
|
{
|
2011-06-14 13:35:59 -04:00
|
|
|
LOG->UserLog("Song file",
|
|
|
|
|
this->GetSongTitle(),
|
|
|
|
|
"has an invalid #WARPS value \"%s\" (must have exactly one '='), ignored.",
|
2011-05-09 22:42:46 -04:00
|
|
|
arrayWarpExpressions[b].c_str() );
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const float fBeat = StringToFloat( arrayWarpValues[0] );
|
|
|
|
|
const float fNewBeat = StringToFloat( arrayWarpValues[1] );
|
2011-05-16 10:02:57 -04:00
|
|
|
// Early versions were absolute in beats. They should be relative.
|
2011-05-16 10:45:03 -04:00
|
|
|
if( ( fVersion < VERSION_SPLIT_TIMING && fNewBeat > fBeat ) )
|
|
|
|
|
{
|
2011-07-14 19:23:29 -04:00
|
|
|
out.AddSegment( SEGMENT_WARP, new WarpSegment(fBeat, fNewBeat - fBeat) );
|
2011-05-16 10:45:03 -04:00
|
|
|
}
|
|
|
|
|
else if( fNewBeat > 0 )
|
2011-07-14 19:23:29 -04:00
|
|
|
out.AddSegment( SEGMENT_WARP, new WarpSegment(fBeat, fNewBeat) );
|
2011-05-09 22:42:46 -04:00
|
|
|
else
|
|
|
|
|
{
|
2011-06-14 13:35:59 -04:00
|
|
|
LOG->UserLog("Song file",
|
|
|
|
|
this->GetSongTitle(),
|
|
|
|
|
"has an invalid Warp at beat %f, BPM %f.",
|
|
|
|
|
fBeat, fNewBeat );
|
2011-05-09 22:42:46 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SSCLoader::ProcessLabels( TimingData &out, const RString sParam )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> arrayLabelExpressions;
|
|
|
|
|
split( sParam, ",", arrayLabelExpressions );
|
|
|
|
|
|
|
|
|
|
for( unsigned b=0; b<arrayLabelExpressions.size(); b++ )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> arrayLabelValues;
|
|
|
|
|
split( arrayLabelExpressions[b], "=", arrayLabelValues );
|
|
|
|
|
if( arrayLabelValues.size() != 2 )
|
|
|
|
|
{
|
2011-06-14 13:35:59 -04:00
|
|
|
LOG->UserLog("Song file",
|
|
|
|
|
this->GetSongTitle(),
|
|
|
|
|
"has an invalid #LABELS value \"%s\" (must have exactly one '='), ignored.",
|
2011-05-09 22:42:46 -04:00
|
|
|
arrayLabelExpressions[b].c_str() );
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const float fBeat = StringToFloat( arrayLabelValues[0] );
|
|
|
|
|
RString sLabel = arrayLabelValues[1];
|
|
|
|
|
TrimRight(sLabel);
|
|
|
|
|
if( fBeat >= 0.0f )
|
2011-07-14 19:23:29 -04:00
|
|
|
out.AddSegment( SEGMENT_LABEL, new LabelSegment(fBeat, sLabel) );
|
2011-05-09 22:42:46 -04:00
|
|
|
else
|
|
|
|
|
{
|
2011-06-14 13:35:59 -04:00
|
|
|
LOG->UserLog("Song file",
|
|
|
|
|
this->GetSongTitle(),
|
|
|
|
|
"has an invalid Label at beat %f called %s.",
|
|
|
|
|
fBeat, sLabel.c_str() );
|
2011-05-09 22:42:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-09 14:45:30 -04:00
|
|
|
void SSCLoader::ProcessCombos( TimingData &out, const RString line, const int rowsPerBeat )
|
2011-05-09 22:42:46 -04:00
|
|
|
{
|
|
|
|
|
vector<RString> arrayComboExpressions;
|
2011-06-09 14:45:30 -04:00
|
|
|
split( line, ",", arrayComboExpressions );
|
2011-05-09 22:42:46 -04:00
|
|
|
|
|
|
|
|
for( unsigned f=0; f<arrayComboExpressions.size(); f++ )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> arrayComboValues;
|
|
|
|
|
split( arrayComboExpressions[f], "=", arrayComboValues );
|
2011-07-09 02:28:15 -04:00
|
|
|
unsigned size = arrayComboValues.size();
|
|
|
|
|
if( size < 2 )
|
2011-05-09 22:42:46 -04:00
|
|
|
{
|
2011-06-14 13:35:59 -04:00
|
|
|
LOG->UserLog("Song file",
|
|
|
|
|
this->GetSongTitle(),
|
2011-07-09 02:28:15 -04:00
|
|
|
"has an invalid #COMBOS value \"%s\" (must have at least one '='), ignored.",
|
2011-05-09 22:42:46 -04:00
|
|
|
arrayComboExpressions[f].c_str() );
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
const float fComboBeat = StringToFloat( arrayComboValues[0] );
|
2011-05-14 18:56:58 -04:00
|
|
|
const int iCombos = StringToInt( arrayComboValues[1] );
|
2011-07-09 02:28:15 -04:00
|
|
|
const int iMisses = (size == 2 ? iCombos : StringToInt(arrayComboValues[2]));
|
2011-07-14 19:23:29 -04:00
|
|
|
out.AddSegment( SEGMENT_COMBO, new ComboSegment( fComboBeat, iCombos, iMisses ) );
|
2011-05-09 22:42:46 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-25 22:44:41 +07:00
|
|
|
void SSCLoader::ProcessScrolls( TimingData &out, const RString sParam )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> vs1;
|
|
|
|
|
split( sParam, ",", vs1 );
|
|
|
|
|
|
|
|
|
|
FOREACH_CONST( RString, vs1, s1 )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> vs2;
|
|
|
|
|
split( *s1, "=", vs2 );
|
|
|
|
|
|
|
|
|
|
if( vs2.size() < 2 )
|
|
|
|
|
{
|
2011-06-14 13:35:59 -04:00
|
|
|
LOG->UserLog("Song file",
|
|
|
|
|
this->GetSongTitle(),
|
|
|
|
|
"has an scroll change with %i values.",
|
|
|
|
|
static_cast<int>(vs2.size()) );
|
2011-05-25 22:44:41 +07:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const float fBeat = StringToFloat( vs2[0] );
|
|
|
|
|
|
2011-07-14 19:23:29 -04:00
|
|
|
ScrollSegment * seg = new ScrollSegment(fBeat, StringToFloat( vs2[1] ) );
|
2011-05-25 22:44:41 +07:00
|
|
|
|
|
|
|
|
if( fBeat < 0 )
|
|
|
|
|
{
|
2011-06-14 13:35:59 -04:00
|
|
|
LOG->UserLog("Song file",
|
|
|
|
|
this->GetSongTitle(),
|
|
|
|
|
"has an scroll change with beat %f.",
|
|
|
|
|
fBeat );
|
2011-05-25 22:44:41 +07:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-14 19:23:29 -04:00
|
|
|
out.AddSegment( SEGMENT_SCROLL, seg );
|
2011-05-25 22:44:41 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-17 16:06:40 -04:00
|
|
|
bool SSCLoader::LoadNoteDataFromSimfile( const RString & cachePath, Steps &out )
|
|
|
|
|
{
|
|
|
|
|
LOG->Trace( "Loading notes from %s", cachePath.c_str() );
|
|
|
|
|
|
|
|
|
|
MsdFile msd;
|
|
|
|
|
if (!msd.ReadFile(cachePath, true))
|
|
|
|
|
{
|
|
|
|
|
LOG->UserLog("Unable to load any notes from",
|
|
|
|
|
cachePath,
|
|
|
|
|
"for this reason: %s",
|
|
|
|
|
msd.GetError().c_str());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool tryingSteps = false;
|
2011-07-18 11:27:28 -06:00
|
|
|
float storedVersion = 0;
|
2011-07-17 16:06:40 -04:00
|
|
|
const unsigned values = msd.GetNumValues();
|
|
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < values; i++)
|
|
|
|
|
{
|
|
|
|
|
const MsdFile::value_t ¶ms = msd.GetValue(i);
|
|
|
|
|
RString valueName = params[0];
|
|
|
|
|
valueName.MakeUpper();
|
|
|
|
|
RString matcher = params[1]; // mainly for debugging.
|
|
|
|
|
Trim(matcher);
|
|
|
|
|
|
|
|
|
|
if (valueName=="VERSION")
|
|
|
|
|
{
|
|
|
|
|
storedVersion = StringToFloat(matcher);
|
|
|
|
|
}
|
|
|
|
|
if (tryingSteps)
|
|
|
|
|
{
|
|
|
|
|
if( valueName=="STEPSTYPE" )
|
|
|
|
|
{
|
|
|
|
|
if (out.m_StepsType != GAMEMAN->StringToStepsType(matcher))
|
|
|
|
|
tryingSteps = false;
|
|
|
|
|
}
|
|
|
|
|
else if( valueName=="CHARTNAME")
|
|
|
|
|
{
|
|
|
|
|
if (storedVersion >= VERSION_CHART_NAME_TAG && out.GetChartName() != matcher)
|
|
|
|
|
tryingSteps = false;
|
|
|
|
|
}
|
|
|
|
|
else if( valueName=="DESCRIPTION" )
|
|
|
|
|
{
|
|
|
|
|
if (storedVersion < VERSION_CHART_NAME_TAG)
|
|
|
|
|
{
|
|
|
|
|
if (out.GetChartName() != matcher)
|
|
|
|
|
tryingSteps = false;
|
|
|
|
|
}
|
|
|
|
|
else if (out.GetDescription() != matcher)
|
|
|
|
|
tryingSteps = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( valueName=="DIFFICULTY" )
|
|
|
|
|
{
|
|
|
|
|
if (out.GetDifficulty() != StringToDifficulty(matcher))
|
|
|
|
|
tryingSteps = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( valueName=="METER" )
|
|
|
|
|
{
|
|
|
|
|
if (out.GetMeter() != StringToInt(matcher))
|
|
|
|
|
tryingSteps = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( valueName=="CREDIT" )
|
|
|
|
|
{
|
|
|
|
|
if (out.GetCredit() != matcher)
|
|
|
|
|
tryingSteps = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( valueName=="NOTES" || valueName=="NOTES2" )
|
|
|
|
|
{
|
|
|
|
|
out.SetSMNoteData(matcher);
|
|
|
|
|
out.TidyUpData();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(valueName == "NOTEDATA")
|
|
|
|
|
{
|
|
|
|
|
tryingSteps = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-09 21:27:47 -04:00
|
|
|
bool SSCLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCache )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
LOG->Trace( "Song::LoadFromSSCFile(%s)", sPath.c_str() );
|
|
|
|
|
|
|
|
|
|
MsdFile msd;
|
|
|
|
|
if( !msd.ReadFile( sPath, true ) )
|
|
|
|
|
{
|
|
|
|
|
LOG->UserLog( "Song file", sPath, "couldn't be opened: %s", msd.GetError().c_str() );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-09 20:48:23 -04:00
|
|
|
out.m_SongTiming.m_sFile = sPath; // songs still have their fallback timing.
|
2011-07-17 16:06:40 -04:00
|
|
|
out.m_sSongFileName = sPath;
|
2011-03-17 01:47:30 -04:00
|
|
|
|
|
|
|
|
int state = GETTING_SONG_INFO;
|
|
|
|
|
const unsigned values = msd.GetNumValues();
|
|
|
|
|
Steps* pNewNotes = NULL;
|
2011-05-10 17:44:12 +07:00
|
|
|
TimingData stepsTiming;
|
|
|
|
|
bool bHasOwnTiming = false;
|
2011-03-17 01:47:30 -04:00
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < values; i++ )
|
|
|
|
|
{
|
|
|
|
|
const MsdFile::value_t &sParams = msd.GetValue(i);
|
|
|
|
|
RString sValueName = sParams[0];
|
|
|
|
|
sValueName.MakeUpper();
|
|
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case GETTING_SONG_INFO:
|
|
|
|
|
{
|
|
|
|
|
if( sValueName=="VERSION" )
|
|
|
|
|
{
|
|
|
|
|
out.m_fVersion = StringToFloat( sParams[1] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="TITLE" )
|
|
|
|
|
{
|
|
|
|
|
out.m_sMainTitle = sParams[1];
|
2011-06-14 13:35:59 -04:00
|
|
|
this->SetSongTitle(sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="SUBTITLE" )
|
|
|
|
|
{
|
|
|
|
|
out.m_sSubTitle = sParams[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="ARTIST" )
|
|
|
|
|
{
|
|
|
|
|
out.m_sArtist = sParams[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="TITLETRANSLIT" )
|
|
|
|
|
{
|
|
|
|
|
out.m_sMainTitleTranslit = sParams[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="SUBTITLETRANSLIT" )
|
|
|
|
|
{
|
|
|
|
|
out.m_sSubTitleTranslit = sParams[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="ARTISTTRANSLIT" )
|
|
|
|
|
{
|
|
|
|
|
out.m_sArtistTranslit = sParams[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="GENRE" )
|
|
|
|
|
{
|
|
|
|
|
out.m_sGenre = sParams[1];
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-30 19:23:29 -05:00
|
|
|
else if( sValueName=="ORIGIN" )
|
|
|
|
|
{
|
|
|
|
|
out.m_sOrigin = sParams[1];
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
else if( sValueName=="CREDIT" )
|
|
|
|
|
{
|
|
|
|
|
out.m_sCredit = sParams[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="BANNER" )
|
|
|
|
|
{
|
|
|
|
|
out.m_sBannerFile = sParams[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="BACKGROUND" )
|
|
|
|
|
{
|
|
|
|
|
out.m_sBackgroundFile = sParams[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="LYRICSPATH" )
|
|
|
|
|
{
|
|
|
|
|
out.m_sLyricsFile = sParams[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="CDTITLE" )
|
|
|
|
|
{
|
|
|
|
|
out.m_sCDTitleFile = sParams[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="MUSIC" )
|
|
|
|
|
{
|
|
|
|
|
out.m_sMusicFile = sParams[1];
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-30 15:56:30 -04:00
|
|
|
else if( sValueName=="INSTRUMENTTRACK" )
|
|
|
|
|
{
|
|
|
|
|
SMLoader::ProcessInstrumentTracks( out, sParams[1] );
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
else if( sValueName=="MUSICLENGTH" )
|
|
|
|
|
{
|
|
|
|
|
if( !bFromCache )
|
|
|
|
|
continue;
|
|
|
|
|
out.m_fMusicLengthSeconds = StringToFloat( sParams[1] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="LASTBEATHINT" )
|
|
|
|
|
{
|
2011-06-30 01:11:38 -04:00
|
|
|
// unable to parse due to tag position. Ignore.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (sValueName == "LASTSECONDHINT")
|
|
|
|
|
{
|
2011-06-30 02:19:37 -04:00
|
|
|
out.SetSpecifiedLastSecond(StringToFloat(sParams[1]));
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="MUSICBYTES" )
|
|
|
|
|
{
|
|
|
|
|
; // ignore
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="SAMPLESTART" )
|
|
|
|
|
{
|
|
|
|
|
out.m_fMusicSampleStartSeconds = HHMMSSToSeconds( sParams[1] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="SAMPLELENGTH" )
|
|
|
|
|
{
|
|
|
|
|
out.m_fMusicSampleLengthSeconds = HHMMSSToSeconds( sParams[1] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="DISPLAYBPM" )
|
|
|
|
|
{
|
|
|
|
|
// #DISPLAYBPM:[xxx][xxx:xxx]|[*];
|
|
|
|
|
if( sParams[1] == "*" )
|
2011-04-05 22:40:33 -04:00
|
|
|
out.m_DisplayBPMType = DISPLAY_BPM_RANDOM;
|
2011-03-17 01:47:30 -04:00
|
|
|
else
|
|
|
|
|
{
|
2011-04-05 22:40:33 -04:00
|
|
|
out.m_DisplayBPMType = DISPLAY_BPM_SPECIFIED;
|
2011-03-17 01:47:30 -04:00
|
|
|
out.m_fSpecifiedBPMMin = StringToFloat( sParams[1] );
|
|
|
|
|
if( sParams[2].empty() )
|
|
|
|
|
out.m_fSpecifiedBPMMax = out.m_fSpecifiedBPMMin;
|
|
|
|
|
else
|
|
|
|
|
out.m_fSpecifiedBPMMax = StringToFloat( sParams[2] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="SELECTABLE" )
|
|
|
|
|
{
|
2011-05-11 16:48:51 -04:00
|
|
|
if(sParams[1].EqualsNoCase("YES"))
|
2011-03-17 01:47:30 -04:00
|
|
|
out.m_SelectionDisplay = out.SHOW_ALWAYS;
|
2011-05-11 16:48:51 -04:00
|
|
|
else if(sParams[1].EqualsNoCase("NO"))
|
2011-03-17 01:47:30 -04:00
|
|
|
out.m_SelectionDisplay = out.SHOW_NEVER;
|
|
|
|
|
// ROULETTE from 3.9 is no longer in use.
|
2011-05-11 16:48:51 -04:00
|
|
|
else if(sParams[1].EqualsNoCase("ROULETTE"))
|
2011-03-17 01:47:30 -04:00
|
|
|
out.m_SelectionDisplay = out.SHOW_ALWAYS;
|
|
|
|
|
/* The following two cases are just fixes to make sure simfiles that
|
|
|
|
|
* used 3.9+ features are not excluded here */
|
2011-05-11 16:48:51 -04:00
|
|
|
else if(sParams[1].EqualsNoCase("ES") || sParams[1].EqualsNoCase("OMES"))
|
2011-03-17 01:47:30 -04:00
|
|
|
out.m_SelectionDisplay = out.SHOW_ALWAYS;
|
2011-05-11 15:58:31 -04:00
|
|
|
else if( StringToInt(sParams[1]) > 0 )
|
2011-03-17 01:47:30 -04:00
|
|
|
out.m_SelectionDisplay = out.SHOW_ALWAYS;
|
|
|
|
|
else
|
|
|
|
|
LOG->UserLog( "Song file", sPath, "has an unknown #SELECTABLE value, \"%s\"; ignored.", sParams[1].c_str() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName.Left(strlen("BGCHANGES"))=="BGCHANGES" || sValueName=="ANIMATIONS" )
|
|
|
|
|
{
|
2011-05-14 16:56:50 -04:00
|
|
|
SMLoader::ProcessBGChanges( out, sValueName, sPath, sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="FGCHANGES" )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> aFGChangeExpressions;
|
|
|
|
|
split( sParams[1], ",", aFGChangeExpressions );
|
|
|
|
|
|
|
|
|
|
for( unsigned b=0; b<aFGChangeExpressions.size(); b++ )
|
|
|
|
|
{
|
|
|
|
|
BackgroundChange change;
|
2011-06-09 13:46:30 -04:00
|
|
|
if( LoadFromBGChangesString( change, aFGChangeExpressions[b] ) )
|
2011-03-17 01:47:30 -04:00
|
|
|
out.AddForegroundChange( change );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="KEYSOUNDS" )
|
|
|
|
|
{
|
|
|
|
|
split( sParams[1], ",", out.m_vsKeysoundFile );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Attacks loaded from file
|
|
|
|
|
else if( sValueName=="ATTACKS" )
|
|
|
|
|
{
|
2011-06-24 11:27:20 -04:00
|
|
|
ProcessAttackString(out.m_sAttackString, sParams);
|
|
|
|
|
ProcessAttacks(out.m_Attacks, sParams);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="OFFSET" )
|
|
|
|
|
{
|
2011-05-09 20:48:23 -04:00
|
|
|
out.m_SongTiming.m_fBeat0OffsetInSeconds = StringToFloat( sParams[1] );
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
/* Below are the song based timings that should only be used
|
|
|
|
|
* if the steps do not have their own timing. */
|
|
|
|
|
else if( sValueName=="STOPS" )
|
|
|
|
|
{
|
2011-05-09 22:42:46 -04:00
|
|
|
SMLoader::ProcessStops(out.m_SongTiming, sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
else if( sValueName=="DELAYS" )
|
|
|
|
|
{
|
2011-05-09 22:42:46 -04:00
|
|
|
SMLoader::ProcessDelays(out.m_SongTiming, sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="BPMS" )
|
|
|
|
|
{
|
2011-05-09 22:42:46 -04:00
|
|
|
SMLoader::ProcessBPMs(out.m_SongTiming, sParams[1]);
|
2011-03-24 19:58:36 -04:00
|
|
|
}
|
|
|
|
|
|
2011-05-16 10:02:57 -04:00
|
|
|
else if( sValueName=="WARPS" ) // Older versions allowed em here.
|
2011-03-24 19:58:36 -04:00
|
|
|
{
|
2011-05-16 10:02:57 -04:00
|
|
|
ProcessWarps( out.m_SongTiming, sParams[1], out.m_fVersion );
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-04-04 23:24:32 -04:00
|
|
|
|
|
|
|
|
else if( sValueName=="LABELS" )
|
|
|
|
|
{
|
2011-05-09 22:42:46 -04:00
|
|
|
ProcessLabels( out.m_SongTiming, sParams[1] );
|
2011-04-04 23:24:32 -04:00
|
|
|
}
|
2011-03-17 01:47:30 -04:00
|
|
|
|
|
|
|
|
else if( sValueName=="TIMESIGNATURES" )
|
|
|
|
|
{
|
2011-05-09 22:42:46 -04:00
|
|
|
SMLoader::ProcessTimeSignatures(out.m_SongTiming, sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="TICKCOUNTS" )
|
|
|
|
|
{
|
2011-05-09 22:42:46 -04:00
|
|
|
SMLoader::ProcessTickcounts(out.m_SongTiming, sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="COMBOS" )
|
|
|
|
|
{
|
2011-05-09 22:42:46 -04:00
|
|
|
ProcessCombos( out.m_SongTiming, sParams[1] );
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The following are cache tags. Never fill their values
|
|
|
|
|
* directly: only from the cached version. */
|
2011-06-30 01:11:38 -04:00
|
|
|
else if( sValueName=="FIRSTBEAT" || sValueName=="LASTBEAT" )
|
|
|
|
|
{
|
|
|
|
|
// no longer used.
|
|
|
|
|
}
|
|
|
|
|
else if (sValueName=="FIRSTSECOND")
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
if( bFromCache )
|
2011-06-30 02:19:37 -04:00
|
|
|
out.SetFirstSecond(StringToFloat(sParams[1]));
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
2011-06-30 02:10:58 -04:00
|
|
|
else if( sValueName=="LASTSECOND" )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
if( bFromCache )
|
2011-06-30 02:19:37 -04:00
|
|
|
out.SetLastSecond(StringToFloat(sParams[1]));
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="SONGFILENAME" )
|
|
|
|
|
{
|
|
|
|
|
if( bFromCache )
|
|
|
|
|
out.m_sSongFileName = sParams[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="HASMUSIC" )
|
|
|
|
|
{
|
|
|
|
|
if( bFromCache )
|
2011-05-11 15:58:31 -04:00
|
|
|
out.m_bHasMusic = StringToInt( sParams[1] ) != 0;
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="HASBANNER" )
|
|
|
|
|
{
|
|
|
|
|
if( bFromCache )
|
2011-05-11 15:58:31 -04:00
|
|
|
out.m_bHasBanner = StringToInt( sParams[1] ) != 0;
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This tag will get us to the next section.
|
|
|
|
|
else if( sValueName=="NOTEDATA" )
|
|
|
|
|
{
|
|
|
|
|
state = GETTING_STEP_INFO;
|
2011-05-09 22:47:47 +07:00
|
|
|
pNewNotes = out.CreateSteps();
|
2011-05-10 17:44:12 +07:00
|
|
|
stepsTiming = TimingData( out.m_SongTiming.m_fBeat0OffsetInSeconds );
|
|
|
|
|
bHasOwnTiming = false;
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case GETTING_STEP_INFO:
|
|
|
|
|
{
|
2011-07-07 13:40:19 -04:00
|
|
|
if (sValueName == "CHARTNAME")
|
2011-07-07 11:48:33 -04:00
|
|
|
{
|
2011-07-07 13:40:19 -04:00
|
|
|
pNewNotes->SetChartName(sParams[1]);
|
2011-07-07 11:48:33 -04:00
|
|
|
}
|
2011-03-17 01:47:30 -04:00
|
|
|
if( sValueName=="STEPSTYPE" )
|
|
|
|
|
{
|
|
|
|
|
pNewNotes->m_StepsType = GAMEMAN->StringToStepsType( sParams[1] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="CHARTSTYLE" )
|
|
|
|
|
{
|
|
|
|
|
pNewNotes->SetChartStyle( sParams[1] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="DESCRIPTION" )
|
|
|
|
|
{
|
2011-07-07 13:55:46 -04:00
|
|
|
if (out.m_fVersion < VERSION_CHART_NAME_TAG)
|
|
|
|
|
{
|
|
|
|
|
pNewNotes->SetChartName(sParams[1]);
|
|
|
|
|
}
|
2011-07-07 16:37:08 -04:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pNewNotes->SetDescription(sParams[1]);
|
|
|
|
|
}
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="DIFFICULTY" )
|
|
|
|
|
{
|
2011-05-15 03:18:34 -05:00
|
|
|
pNewNotes->SetDifficulty( StringToDifficulty( sParams[1] ) );
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="METER" )
|
|
|
|
|
{
|
2011-05-11 15:58:31 -04:00
|
|
|
pNewNotes->SetMeter( StringToInt( sParams[1] ) );
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="RADARVALUES" )
|
|
|
|
|
{
|
2011-07-17 16:06:40 -04:00
|
|
|
if (bFromCache)
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-07-17 16:06:40 -04:00
|
|
|
vector<RString> saValues;
|
|
|
|
|
split( sParams[1], ",", saValues, true );
|
|
|
|
|
|
|
|
|
|
int categories = NUM_RadarCategory;
|
|
|
|
|
if( out.m_fVersion < VERSION_RADAR_FAKE )
|
|
|
|
|
categories -= 1;
|
|
|
|
|
|
|
|
|
|
if( saValues.size() == (unsigned)categories * NUM_PLAYERS )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-07-17 16:06:40 -04:00
|
|
|
RadarValues v[NUM_PLAYERS];
|
|
|
|
|
FOREACH_PlayerNumber( pn )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-07-17 16:06:40 -04:00
|
|
|
// Can't use the foreach anymore due to flexible radar lines.
|
|
|
|
|
for( RadarCategory rc = (RadarCategory)0; rc < categories;
|
|
|
|
|
enum_add<RadarCategory>( rc, +1 ) )
|
|
|
|
|
{
|
|
|
|
|
v[pn][rc] = StringToFloat( saValues[pn*categories + rc] );
|
|
|
|
|
}
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-07-17 16:06:40 -04:00
|
|
|
pNewNotes->SetCachedRadarValues( v );
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
}
|
2011-07-17 16:06:40 -04:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// just recalc at time.
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="CREDIT" )
|
|
|
|
|
{
|
|
|
|
|
pNewNotes->SetCredit( sParams[1] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="NOTES" || sValueName=="NOTES2" )
|
|
|
|
|
{
|
|
|
|
|
state = GETTING_SONG_INFO;
|
2011-05-10 17:44:12 +07:00
|
|
|
if( bHasOwnTiming )
|
|
|
|
|
pNewNotes->m_Timing = stepsTiming;
|
2011-03-17 01:47:30 -04:00
|
|
|
pNewNotes->SetSMNoteData( sParams[1] );
|
|
|
|
|
pNewNotes->TidyUpData();
|
2011-07-17 16:06:40 -04:00
|
|
|
pNewNotes->SetFilename(sPath);
|
2011-03-17 01:47:30 -04:00
|
|
|
out.AddSteps( pNewNotes );
|
|
|
|
|
}
|
2011-05-10 17:44:12 +07:00
|
|
|
|
|
|
|
|
else if( sValueName=="BPMS" )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-05-10 17:44:12 +07:00
|
|
|
if( SMLoader::ProcessBPMs(stepsTiming, sParams[1]) )
|
|
|
|
|
bHasOwnTiming = true;
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-05-10 17:44:12 +07:00
|
|
|
|
|
|
|
|
else if( sValueName=="STOPS" )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-05-10 17:44:12 +07:00
|
|
|
SMLoader::ProcessStops(stepsTiming, sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-05-10 17:44:12 +07:00
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
else if( sValueName=="DELAYS" )
|
|
|
|
|
{
|
2011-05-10 17:44:12 +07:00
|
|
|
SMLoader::ProcessDelays(stepsTiming, sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-05-10 17:44:12 +07:00
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
else if( sValueName=="TIMESIGNATURES" )
|
|
|
|
|
{
|
2011-05-10 17:44:12 +07:00
|
|
|
SMLoader::ProcessTimeSignatures(stepsTiming, sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-05-10 17:44:12 +07:00
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
else if( sValueName=="TICKCOUNTS" )
|
|
|
|
|
{
|
2011-05-10 17:44:12 +07:00
|
|
|
SMLoader::ProcessTickcounts(stepsTiming, sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-05-10 17:44:12 +07:00
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
else if( sValueName=="COMBOS" )
|
|
|
|
|
{
|
2011-05-10 17:44:12 +07:00
|
|
|
ProcessCombos(stepsTiming, sParams[1]);
|
2011-05-09 23:16:56 -04:00
|
|
|
}
|
2011-05-10 17:44:12 +07:00
|
|
|
|
2011-05-09 23:16:56 -04:00
|
|
|
else if( sValueName=="WARPS" )
|
|
|
|
|
{
|
2011-05-16 10:02:57 -04:00
|
|
|
ProcessWarps(stepsTiming, sParams[1], out.m_fVersion);
|
2011-04-04 23:24:32 -04:00
|
|
|
}
|
2011-05-10 17:44:12 +07:00
|
|
|
|
2011-05-15 16:56:35 -04:00
|
|
|
else if( sValueName=="SPEEDS" )
|
2011-05-15 16:40:06 -04:00
|
|
|
{
|
|
|
|
|
ProcessSpeeds( stepsTiming, sParams[1] );
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-25 22:44:41 +07:00
|
|
|
else if( sValueName=="SCROLLS" )
|
|
|
|
|
{
|
|
|
|
|
ProcessScrolls( stepsTiming, sParams[1] );
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-16 10:02:57 -04:00
|
|
|
else if( sValueName=="FAKES" )
|
|
|
|
|
{
|
|
|
|
|
ProcessFakes( stepsTiming, sParams[1] );
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-09 23:16:56 -04:00
|
|
|
else if( sValueName=="LABELS" )
|
2011-04-04 23:24:32 -04:00
|
|
|
{
|
2011-05-10 17:44:12 +07:00
|
|
|
ProcessLabels(stepsTiming, sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-05-10 17:44:12 +07:00
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
else if( sValueName=="ATTACKS" )
|
|
|
|
|
{
|
2011-06-24 11:27:20 -04:00
|
|
|
ProcessAttackString(pNewNotes->m_sAttackString, sParams);
|
|
|
|
|
ProcessAttacks(pNewNotes->m_Attacks, sParams);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-05-10 17:44:12 +07:00
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
else if( sValueName=="OFFSET" )
|
|
|
|
|
{
|
2011-05-10 17:44:12 +07:00
|
|
|
stepsTiming.m_fBeat0OffsetInSeconds = StringToFloat( sParams[1] );
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-07-07 18:27:59 -04:00
|
|
|
|
|
|
|
|
else if( sValueName=="DISPLAYBPM" )
|
|
|
|
|
{
|
|
|
|
|
// #DISPLAYBPM:[xxx][xxx:xxx]|[*];
|
|
|
|
|
if( sParams[1] == "*" )
|
|
|
|
|
pNewNotes->SetDisplayBPM(DISPLAY_BPM_RANDOM);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pNewNotes->SetDisplayBPM(DISPLAY_BPM_SPECIFIED);
|
|
|
|
|
float min = StringToFloat(sParams[1]);
|
|
|
|
|
pNewNotes->SetMinBPM(min);
|
|
|
|
|
if(sParams[2].empty())
|
|
|
|
|
pNewNotes->SetMaxBPM(min);
|
|
|
|
|
else
|
|
|
|
|
pNewNotes->SetMaxBPM(StringToFloat(sParams[2]));
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-07-17 16:06:40 -04:00
|
|
|
else if( sValueName=="STEPFILENAME" )
|
|
|
|
|
{
|
|
|
|
|
state = GETTING_SONG_INFO;
|
|
|
|
|
if( bHasOwnTiming )
|
|
|
|
|
pNewNotes->m_Timing = stepsTiming;
|
|
|
|
|
pNewNotes->SetFilename(sParams[1]);
|
|
|
|
|
out.AddSteps( pNewNotes );
|
|
|
|
|
}
|
2011-03-17 01:47:30 -04:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
out.m_fVersion = STEPFILE_VERSION_NUMBER;
|
2011-05-16 23:44:06 -04:00
|
|
|
TidyUpData(out, bFromCache);
|
2011-03-17 01:47:30 -04:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SSCLoader::LoadEditFromFile( RString sEditFilePath, ProfileSlot slot, bool bAddStepsToSong )
|
|
|
|
|
{
|
|
|
|
|
LOG->Trace( "SSCLoader::LoadEditFromFile(%s)", sEditFilePath.c_str() );
|
|
|
|
|
|
|
|
|
|
int iBytes = FILEMAN->GetFileSizeInBytes( sEditFilePath );
|
|
|
|
|
if( iBytes > MAX_EDIT_STEPS_SIZE_BYTES )
|
|
|
|
|
{
|
2011-06-14 13:35:59 -04:00
|
|
|
LOG->UserLog("Edit file",
|
|
|
|
|
sEditFilePath,
|
|
|
|
|
"is unreasonably large. It won't be loaded." );
|
2011-03-17 01:47:30 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MsdFile msd;
|
|
|
|
|
if( !msd.ReadFile( sEditFilePath, true ) ) // unescape
|
|
|
|
|
{
|
2011-06-14 13:35:59 -04:00
|
|
|
LOG->UserLog("Edit file",
|
|
|
|
|
sEditFilePath,
|
|
|
|
|
"couldn't be opened: %s", msd.GetError().c_str() );
|
2011-03-17 01:47:30 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return LoadEditFromMsd( msd, sEditFilePath, slot, bAddStepsToSong );
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-14 13:35:59 -04:00
|
|
|
bool SSCLoader::LoadEditFromMsd(const MsdFile &msd,
|
|
|
|
|
const RString &sEditFilePath,
|
|
|
|
|
ProfileSlot slot,
|
|
|
|
|
bool bAddStepsToSong )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
Song* pSong = NULL;
|
|
|
|
|
Steps* pNewNotes = NULL;
|
|
|
|
|
bool bSSCFormat = false;
|
2011-05-10 08:58:24 -04:00
|
|
|
bool bHasOwnTiming = false;
|
|
|
|
|
TimingData stepsTiming;
|
2011-03-17 01:47:30 -04:00
|
|
|
|
|
|
|
|
for( unsigned i=0; i<msd.GetNumValues(); i++ )
|
|
|
|
|
{
|
|
|
|
|
int iNumParams = msd.GetNumParams(i);
|
|
|
|
|
const MsdFile::value_t &sParams = msd.GetValue(i);
|
|
|
|
|
RString sValueName = sParams[0];
|
|
|
|
|
sValueName.MakeUpper();
|
|
|
|
|
|
|
|
|
|
// handle the data
|
2011-05-16 10:02:57 -04:00
|
|
|
if( sValueName=="VERSION" )
|
|
|
|
|
{
|
|
|
|
|
pSong->m_fVersion = StringToFloat( sParams[1] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="SONG" )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
if( pSong )
|
|
|
|
|
{
|
|
|
|
|
LOG->UserLog( "Edit file", sEditFilePath, "has more than one #SONG tag." );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RString sSongFullTitle = sParams[1];
|
2011-06-14 13:35:59 -04:00
|
|
|
this->SetSongTitle(sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
sSongFullTitle.Replace( '\\', '/' );
|
|
|
|
|
|
|
|
|
|
pSong = SONGMAN->FindSong( sSongFullTitle );
|
|
|
|
|
if( pSong == NULL )
|
|
|
|
|
{
|
2011-06-14 13:35:59 -04:00
|
|
|
LOG->UserLog("Edit file",
|
|
|
|
|
sEditFilePath,
|
|
|
|
|
"requires a song \"%s\" that isn't present.",
|
|
|
|
|
sSongFullTitle.c_str() );
|
2011-03-17 01:47:30 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( pSong->GetNumStepsLoadedFromProfile(slot) >= MAX_EDITS_PER_SONG_PER_PROFILE )
|
|
|
|
|
{
|
2011-06-14 13:35:59 -04:00
|
|
|
LOG->UserLog("Song file",
|
|
|
|
|
sSongFullTitle,
|
|
|
|
|
"already has the maximum number of edits allowed for ProfileSlotP%d.",
|
|
|
|
|
slot+1 );
|
2011-03-17 01:47:30 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="NOTEDATA" )
|
|
|
|
|
{
|
2011-05-09 22:47:47 +07:00
|
|
|
pNewNotes = pSong->CreateSteps();
|
2011-03-17 01:47:30 -04:00
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
|
|
|
|
if( sValueName=="STEPSTYPE" )
|
|
|
|
|
{
|
|
|
|
|
pNewNotes->m_StepsType = GAMEMAN->StringToStepsType( sParams[1] );
|
|
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="CHARTSTYLE" )
|
|
|
|
|
{
|
|
|
|
|
pNewNotes->SetChartStyle( sParams[1] );
|
|
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="DESCRIPTION" )
|
|
|
|
|
{
|
|
|
|
|
pNewNotes->SetDescription( sParams[1] );
|
|
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="DIFFICULTY" )
|
|
|
|
|
{
|
2011-05-15 03:18:34 -05:00
|
|
|
pNewNotes->SetDifficulty( StringToDifficulty( sParams[1] ) );
|
2011-03-17 01:47:30 -04:00
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="METER" )
|
|
|
|
|
{
|
2011-05-11 15:58:31 -04:00
|
|
|
pNewNotes->SetMeter( StringToInt( sParams[1] ) );
|
2011-03-17 01:47:30 -04:00
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="RADARVALUES" )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> saValues;
|
|
|
|
|
split( sParams[1], ",", saValues, true );
|
|
|
|
|
if( saValues.size() == NUM_RadarCategory * NUM_PLAYERS )
|
|
|
|
|
{
|
|
|
|
|
RadarValues v[NUM_PLAYERS];
|
|
|
|
|
FOREACH_PlayerNumber( pn )
|
2011-06-14 13:35:59 -04:00
|
|
|
FOREACH_ENUM( RadarCategory, rc )
|
|
|
|
|
v[pn][rc] = StringToFloat( saValues[pn*NUM_RadarCategory + rc] );
|
2011-03-17 01:47:30 -04:00
|
|
|
pNewNotes->SetCachedRadarValues( v );
|
|
|
|
|
}
|
|
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="CREDIT" )
|
|
|
|
|
{
|
|
|
|
|
pNewNotes->SetCredit( sParams[1] );
|
|
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="BPMS" )
|
|
|
|
|
{
|
2011-05-10 08:58:24 -04:00
|
|
|
if( SMLoader::ProcessBPMs(stepsTiming, sParams[1]) )
|
|
|
|
|
bHasOwnTiming = true;
|
2011-03-17 01:47:30 -04:00
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
2011-05-10 08:58:24 -04:00
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
else if( sValueName=="STOPS" )
|
|
|
|
|
{
|
2011-05-10 08:58:24 -04:00
|
|
|
SMLoader::ProcessStops(stepsTiming, sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
2011-05-10 08:58:24 -04:00
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
else if( sValueName=="DELAYS" )
|
|
|
|
|
{
|
2011-05-10 08:58:24 -04:00
|
|
|
SMLoader::ProcessDelays(stepsTiming, sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
2011-05-10 08:58:24 -04:00
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
else if( sValueName=="TIMESIGNATURES" )
|
|
|
|
|
{
|
2011-05-10 08:58:24 -04:00
|
|
|
SMLoader::ProcessTimeSignatures(stepsTiming, sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
2011-05-10 08:58:24 -04:00
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
else if( sValueName=="TICKCOUNTS" )
|
|
|
|
|
{
|
2011-05-10 08:58:24 -04:00
|
|
|
SMLoader::ProcessTickcounts(stepsTiming, sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
2011-05-10 08:58:24 -04:00
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
else if( sValueName=="COMBOS" )
|
|
|
|
|
{
|
2011-05-10 08:58:24 -04:00
|
|
|
ProcessCombos(stepsTiming, sParams[1]);
|
|
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="WARPS" )
|
|
|
|
|
{
|
2011-05-16 10:02:57 -04:00
|
|
|
ProcessWarps(stepsTiming, sParams[1], pSong->m_fVersion);
|
|
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="SPEEDS" )
|
|
|
|
|
{
|
|
|
|
|
ProcessSpeeds( stepsTiming, sParams[1] );
|
|
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="FAKES" )
|
|
|
|
|
{
|
|
|
|
|
ProcessFakes( stepsTiming, sParams[1] );
|
2011-05-10 08:58:24 -04:00
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if( sValueName=="LABELS" )
|
|
|
|
|
{
|
|
|
|
|
ProcessLabels(stepsTiming, sParams[1]);
|
2011-03-17 01:47:30 -04:00
|
|
|
bSSCFormat = true;
|
|
|
|
|
}
|
|
|
|
|
else if( sValueName=="NOTES" )
|
|
|
|
|
{
|
|
|
|
|
if( pSong == NULL )
|
|
|
|
|
{
|
2011-06-14 13:35:59 -04:00
|
|
|
LOG->UserLog("Edit file",
|
|
|
|
|
sEditFilePath,
|
|
|
|
|
"doesn't have a #SONG tag preceeding the first #NOTES tag." );
|
2011-03-17 01:47:30 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !bSSCFormat && iNumParams < 7 )
|
|
|
|
|
{
|
2011-06-14 13:35:59 -04:00
|
|
|
LOG->UserLog("Edit file",
|
|
|
|
|
sEditFilePath,
|
|
|
|
|
"has %d fields in a #NOTES tag, but should have at least 7.",
|
|
|
|
|
iNumParams );
|
2011-03-17 01:47:30 -04:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( !bAddStepsToSong )
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if( bSSCFormat )
|
|
|
|
|
{
|
2011-05-10 08:58:24 -04:00
|
|
|
if ( bHasOwnTiming )
|
|
|
|
|
{
|
|
|
|
|
pNewNotes->m_Timing = stepsTiming;
|
|
|
|
|
}
|
2011-03-17 01:47:30 -04:00
|
|
|
pNewNotes->SetSMNoteData( sParams[1] );
|
|
|
|
|
pNewNotes->TidyUpData();
|
|
|
|
|
pSong->AddSteps( pNewNotes );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-05-09 22:47:47 +07:00
|
|
|
pNewNotes = pSong->CreateSteps();
|
2011-06-09 14:01:55 -04:00
|
|
|
LoadFromTokens(sParams[1],
|
|
|
|
|
sParams[2],
|
|
|
|
|
sParams[3],
|
|
|
|
|
sParams[4],
|
|
|
|
|
sParams[5],
|
|
|
|
|
sParams[6],
|
|
|
|
|
*pNewNotes);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pNewNotes->SetLoadedFromProfile( slot );
|
|
|
|
|
pNewNotes->SetDifficulty( Difficulty_Edit );
|
|
|
|
|
pNewNotes->SetFilename( sEditFilePath );
|
|
|
|
|
|
|
|
|
|
if( pSong->IsEditAlreadyLoaded(pNewNotes) )
|
|
|
|
|
{
|
2011-06-14 13:35:59 -04:00
|
|
|
LOG->UserLog("Edit file",
|
|
|
|
|
sEditFilePath,
|
|
|
|
|
"is a duplicate of another edit that was already loaded." );
|
2011-03-17 01:47:30 -04:00
|
|
|
SAFE_DELETE( pNewNotes );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pSong->AddSteps( pNewNotes );
|
|
|
|
|
return true; // Only allow one Steps per edit file!
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-06-14 13:35:59 -04:00
|
|
|
LOG->UserLog("Edit file",
|
|
|
|
|
sEditFilePath,
|
|
|
|
|
"has an unexpected value \"%s\".",
|
|
|
|
|
sValueName.c_str() );
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//return true;
|
|
|
|
|
// only load a SSC edit if it passes the checks. -aj
|
|
|
|
|
return bSSCFormat;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (c) 2011 Jason Felds
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|