Start detecting which files have errors.

Guess we needed this as a class/struct after all.
This commit is contained in:
Jason Felds
2011-06-14 13:35:59 -04:00
parent 23e71e1574
commit 3b1260bb79
4 changed files with 186 additions and 53 deletions
+62 -20
View File
@@ -23,10 +23,11 @@ void SSCLoader::ProcessWarps( TimingData &out, const RString sParam, const float
{
vector<RString> arrayWarpValues;
split( arrayWarpExpressions[b], "=", arrayWarpValues );
// XXX: Hard to tell which file caused this.
if( arrayWarpValues.size() != 2 )
{
LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid #WARPS value \"%s\" (must have exactly one '='), ignored.",
LOG->UserLog("Song file",
this->GetSongTitle(),
"has an invalid #WARPS value \"%s\" (must have exactly one '='), ignored.",
arrayWarpExpressions[b].c_str() );
continue;
}
@@ -42,7 +43,10 @@ void SSCLoader::ProcessWarps( TimingData &out, const RString sParam, const float
out.AddWarpSegment( WarpSegment(fBeat, fNewBeat) );
else
{
LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid Warp at beat %f, BPM %f.", fBeat, fNewBeat );
LOG->UserLog("Song file",
this->GetSongTitle(),
"has an invalid Warp at beat %f, BPM %f.",
fBeat, fNewBeat );
}
}
}
@@ -58,7 +62,9 @@ void SSCLoader::ProcessLabels( TimingData &out, const RString sParam )
split( arrayLabelExpressions[b], "=", arrayLabelValues );
if( arrayLabelValues.size() != 2 )
{
LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid #LABELS value \"%s\" (must have exactly one '='), ignored.",
LOG->UserLog("Song file",
this->GetSongTitle(),
"has an invalid #LABELS value \"%s\" (must have exactly one '='), ignored.",
arrayLabelExpressions[b].c_str() );
continue;
}
@@ -70,7 +76,10 @@ void SSCLoader::ProcessLabels( TimingData &out, const RString sParam )
out.AddLabelSegment( LabelSegment(fBeat, sLabel) );
else
{
LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid Label at beat %f called %s.", fBeat, sLabel.c_str() );
LOG->UserLog("Song file",
this->GetSongTitle(),
"has an invalid Label at beat %f called %s.",
fBeat, sLabel.c_str() );
}
}
@@ -87,13 +96,15 @@ void SSCLoader::ProcessCombos( TimingData &out, const RString line, const int ro
split( arrayComboExpressions[f], "=", arrayComboValues );
if( arrayComboValues.size() != 2 )
{
LOG->UserLog( "Song file", "(UNKNOWN)", "has an invalid #COMBOS value \"%s\" (must have exactly one '='), ignored.",
LOG->UserLog("Song file",
this->GetSongTitle(),
"has an invalid #COMBOS value \"%s\" (must have exactly one '='), ignored.",
arrayComboExpressions[f].c_str() );
continue;
}
const float fComboBeat = StringToFloat( arrayComboValues[0] );
const int iCombos = StringToInt( arrayComboValues[1] );
ComboSegment new_seg( BeatToNoteRow( fComboBeat ), iCombos );
ComboSegment new_seg( fComboBeat, iCombos );
out.AddComboSegment( new_seg );
}
}
@@ -110,7 +121,10 @@ void SSCLoader::ProcessScrolls( TimingData &out, const RString sParam )
if( vs2.size() < 2 )
{
LOG->UserLog( "Song file", "(UNKNOWN)", "has an scroll change with %i values.", (int)vs2.size() );
LOG->UserLog("Song file",
this->GetSongTitle(),
"has an scroll change with %i values.",
static_cast<int>(vs2.size()) );
continue;
}
@@ -120,7 +134,10 @@ void SSCLoader::ProcessScrolls( TimingData &out, const RString sParam )
if( fBeat < 0 )
{
LOG->UserLog( "Song file", "(UNKNOWN)", "has an scroll change with beat %f.", fBeat );
LOG->UserLog("Song file",
this->GetSongTitle(),
"has an scroll change with beat %f.",
fBeat );
continue;
}
@@ -166,6 +183,7 @@ bool SSCLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach
else if( sValueName=="TITLE" )
{
out.m_sMainTitle = sParams[1];
this->SetSongTitle(sParams[1]);
}
else if( sValueName=="SUBTITLE" )
@@ -564,21 +582,28 @@ bool SSCLoader::LoadEditFromFile( RString sEditFilePath, ProfileSlot slot, bool
int iBytes = FILEMAN->GetFileSizeInBytes( sEditFilePath );
if( iBytes > MAX_EDIT_STEPS_SIZE_BYTES )
{
LOG->UserLog( "Edit file", sEditFilePath, "is unreasonably large. It won't be loaded." );
LOG->UserLog("Edit file",
sEditFilePath,
"is unreasonably large. It won't be loaded." );
return false;
}
MsdFile msd;
if( !msd.ReadFile( sEditFilePath, true ) ) // unescape
{
LOG->UserLog( "Edit file", sEditFilePath, "couldn't be opened: %s", msd.GetError().c_str() );
LOG->UserLog("Edit file",
sEditFilePath,
"couldn't be opened: %s", msd.GetError().c_str() );
return false;
}
return LoadEditFromMsd( msd, sEditFilePath, slot, bAddStepsToSong );
}
bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePath, ProfileSlot slot, bool bAddStepsToSong )
bool SSCLoader::LoadEditFromMsd(const MsdFile &msd,
const RString &sEditFilePath,
ProfileSlot slot,
bool bAddStepsToSong )
{
Song* pSong = NULL;
Steps* pNewNotes = NULL;
@@ -608,18 +633,25 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat
}
RString sSongFullTitle = sParams[1];
this->SetSongTitle(sParams[1]);
sSongFullTitle.Replace( '\\', '/' );
pSong = SONGMAN->FindSong( sSongFullTitle );
if( pSong == NULL )
{
LOG->UserLog( "Edit file", sEditFilePath, "requires a song \"%s\" that isn't present.", sSongFullTitle.c_str() );
LOG->UserLog("Edit file",
sEditFilePath,
"requires a song \"%s\" that isn't present.",
sSongFullTitle.c_str() );
return false;
}
if( pSong->GetNumStepsLoadedFromProfile(slot) >= MAX_EDITS_PER_SONG_PER_PROFILE )
{
LOG->UserLog( "Song file", sSongFullTitle, "already has the maximum number of edits allowed for ProfileSlotP%d.", slot+1 );
LOG->UserLog("Song file",
sSongFullTitle,
"already has the maximum number of edits allowed for ProfileSlotP%d.",
slot+1 );
return false;
}
}
@@ -667,8 +699,8 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat
{
RadarValues v[NUM_PLAYERS];
FOREACH_PlayerNumber( pn )
FOREACH_ENUM( RadarCategory, rc )
v[pn][rc] = StringToFloat( saValues[pn*NUM_RadarCategory + rc] );
FOREACH_ENUM( RadarCategory, rc )
v[pn][rc] = StringToFloat( saValues[pn*NUM_RadarCategory + rc] );
pNewNotes->SetCachedRadarValues( v );
}
bSSCFormat = true;
@@ -744,13 +776,18 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat
{
if( pSong == NULL )
{
LOG->UserLog( "Edit file", sEditFilePath, "doesn't have a #SONG tag preceeding the first #NOTES tag." );
LOG->UserLog("Edit file",
sEditFilePath,
"doesn't have a #SONG tag preceeding the first #NOTES tag." );
return false;
}
if ( !bSSCFormat && iNumParams < 7 )
{
LOG->UserLog( "Edit file", sEditFilePath, "has %d fields in a #NOTES tag, but should have at least 7.", iNumParams );
LOG->UserLog("Edit file",
sEditFilePath,
"has %d fields in a #NOTES tag, but should have at least 7.",
iNumParams );
continue;
}
@@ -785,7 +822,9 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat
if( pSong->IsEditAlreadyLoaded(pNewNotes) )
{
LOG->UserLog( "Edit file", sEditFilePath, "is a duplicate of another edit that was already loaded." );
LOG->UserLog("Edit file",
sEditFilePath,
"is a duplicate of another edit that was already loaded." );
SAFE_DELETE( pNewNotes );
return false;
}
@@ -795,7 +834,10 @@ bool SSCLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePat
}
else
{
LOG->UserLog( "Edit file", sEditFilePath, "has an unexpected value \"%s\".", sValueName.c_str() );
LOG->UserLog("Edit file",
sEditFilePath,
"has an unexpected value \"%s\".",
sValueName.c_str() );
}
}