test whether the song required for an edit is present before copying it. Fixes "game said it copied N edits, but none of them are showing".
This commit is contained in:
@@ -348,7 +348,7 @@ bool CourseLoaderCRS::LoadFromCRSFile( const RString &_sPath, Course &out )
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CourseLoaderCRS::LoadEdit( const RString &sEditFilePath, ProfileSlot slot )
|
||||
bool CourseLoaderCRS::LoadEditFromFile( const RString &sEditFilePath, ProfileSlot slot )
|
||||
{
|
||||
LOG->Trace( "CourseLoaderCRS::LoadEdit(%s)", sEditFilePath.c_str() );
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
static bool LoadFromCRSFile( const RString &sPath, Course &out );
|
||||
static bool LoadFromMsd( const RString &sPath, const MsdFile &msd, Course &out, bool bFromCache );
|
||||
static bool LoadFromBuffer( const RString &sPath, const RString &sBuffer, Course &out );
|
||||
static bool LoadEdit( const RString &sEditFilePath, ProfileSlot slot );
|
||||
static bool LoadEditFromFile( const RString &sEditFilePath, ProfileSlot slot );
|
||||
static bool LoadEditFromBuffer( const RString &sBuffer, const RString &sPath, ProfileSlot slot );
|
||||
};
|
||||
|
||||
|
||||
@@ -462,9 +462,9 @@ bool SMLoader::LoadFromDir( const RString &sPath, Song &out )
|
||||
return LoadFromSMFile( sPath + aFileNames[0], out );
|
||||
}
|
||||
|
||||
bool SMLoader::LoadEdit( RString sEditFilePath, ProfileSlot slot )
|
||||
bool SMLoader::LoadEditFromFile( RString sEditFilePath, ProfileSlot slot, bool bAddStepsToSong )
|
||||
{
|
||||
LOG->Trace( "SMLoader::LoadEdit(%s)", sEditFilePath.c_str() );
|
||||
LOG->Trace( "SMLoader::LoadEditFromFile(%s)", sEditFilePath.c_str() );
|
||||
|
||||
int iBytes = FILEMAN->GetFileSizeInBytes( sEditFilePath );
|
||||
if( iBytes > MAX_EDIT_STEPS_SIZE_BYTES )
|
||||
@@ -480,17 +480,17 @@ bool SMLoader::LoadEdit( RString sEditFilePath, ProfileSlot slot )
|
||||
return false;
|
||||
}
|
||||
|
||||
return LoadEditFromMsd( msd, sEditFilePath, slot );
|
||||
return LoadEditFromMsd( msd, sEditFilePath, slot, bAddStepsToSong );
|
||||
}
|
||||
|
||||
bool SMLoader::LoadEditFromBuffer( const RString &sBuffer, const RString &sEditFilePath, ProfileSlot slot )
|
||||
{
|
||||
MsdFile msd;
|
||||
msd.ReadFromString( sBuffer );
|
||||
return LoadEditFromMsd( msd, sEditFilePath, slot );
|
||||
return LoadEditFromMsd( msd, sEditFilePath, slot, true );
|
||||
}
|
||||
|
||||
bool SMLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePath, ProfileSlot slot )
|
||||
bool SMLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePath, ProfileSlot slot, bool bAddStepsToSong )
|
||||
{
|
||||
Song* pSong = NULL;
|
||||
|
||||
@@ -541,6 +541,9 @@ bool SMLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePath
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !bAddStepsToSong )
|
||||
return true;
|
||||
|
||||
Steps* pNewNotes = new Steps;
|
||||
LoadFromSMTokens(
|
||||
sParams[1], sParams[2], sParams[3], sParams[4], sParams[5], sParams[6],
|
||||
|
||||
@@ -38,10 +38,9 @@ public:
|
||||
void TidyUpData( Song &song, bool cache );
|
||||
static bool LoadTimingFromFile( const RString &fn, TimingData &out );
|
||||
static void LoadTimingFromSMFile( const MsdFile &msd, TimingData &out );
|
||||
static bool LoadEdit( RString sEditFilePath, ProfileSlot slot );
|
||||
static bool LoadEditFromFile( RString sEditFilePath, ProfileSlot slot, bool bAddStepsToSong );
|
||||
static bool LoadEditFromBuffer( const RString &sBuffer, const RString &sEditFilePath, ProfileSlot slot );
|
||||
private:
|
||||
static bool LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePath, ProfileSlot slot );
|
||||
static bool LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePath, ProfileSlot slot, bool bAddStepsToSong );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "PlayerState.h"
|
||||
#include "LocalizedString.h"
|
||||
#include "StepMania.h"
|
||||
#include "NotesLoaderSM.h"
|
||||
|
||||
static LocalizedString BOOKKEEPING_DATA_CLEARED( "ScreenServiceAction", "Bookkeeping data cleared." );
|
||||
static RString ClearBookkeepingData()
|
||||
@@ -175,11 +176,12 @@ static RString TransferStatsMemoryCardToMachine()
|
||||
return s;
|
||||
}
|
||||
|
||||
static void CopyEdits( const RString &sFromProfileDir, const RString &sToProfileDir, int &iNumAttempted, int &iNumSuccessful, int &iNumOverwritten )
|
||||
static void CopyEdits( const RString &sFromProfileDir, const RString &sToProfileDir, int &iNumSucceeded, int &iNumOverwritten, int &iNumIgnored, int &iNumErrored )
|
||||
{
|
||||
iNumAttempted = 0;
|
||||
iNumSuccessful = 0;
|
||||
iNumSucceeded = 0;
|
||||
iNumOverwritten = 0;
|
||||
iNumIgnored = 0;
|
||||
iNumErrored = 0;
|
||||
|
||||
{
|
||||
RString sFromDir = sFromProfileDir + EDIT_STEPS_SUBDIR;
|
||||
@@ -189,17 +191,27 @@ static void CopyEdits( const RString &sFromProfileDir, const RString &sToProfile
|
||||
GetDirListing( sFromDir+"*.edit", vsFiles, false, false );
|
||||
FOREACH_CONST( RString, vsFiles, i )
|
||||
{
|
||||
iNumAttempted++;
|
||||
if( DoesFileExist(sToDir+*i) )
|
||||
iNumOverwritten++;
|
||||
bool bSuccess = FileCopy( sFromDir+*i, sToDir+*i );
|
||||
if( bSuccess )
|
||||
iNumSuccessful++;
|
||||
iNumSucceeded++;
|
||||
else
|
||||
iNumErrored++;
|
||||
|
||||
// Test whether the song we need for this edit is present and ignore this edit if not present.
|
||||
if( !SMLoader::LoadEditFromFile( sFromDir+*i, ProfileSlot_Machine, false ) )
|
||||
{
|
||||
iNumIgnored++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
FILEMAN->FlushDirCache( sToDir );
|
||||
}
|
||||
|
||||
// TODO: Seprarate copying stats for steps and courses
|
||||
|
||||
{
|
||||
RString sFromDir = sFromProfileDir + EDIT_COURSES_SUBDIR;
|
||||
RString sToDir = sToProfileDir + EDIT_COURSES_SUBDIR;
|
||||
@@ -208,12 +220,13 @@ static void CopyEdits( const RString &sFromProfileDir, const RString &sToProfile
|
||||
GetDirListing( sFromDir+"*.crs", vsFiles, false, false );
|
||||
FOREACH_CONST( RString, vsFiles, i )
|
||||
{
|
||||
iNumAttempted++;
|
||||
if( DoesFileExist(sToDir+*i) )
|
||||
iNumOverwritten++;
|
||||
bool bSuccess = FileCopy( sFromDir+*i, sToDir+*i );
|
||||
if( bSuccess )
|
||||
iNumSuccessful++;
|
||||
iNumSucceeded++;
|
||||
else
|
||||
iNumErrored++;
|
||||
}
|
||||
|
||||
FILEMAN->FlushDirCache( sToDir );
|
||||
@@ -225,24 +238,27 @@ static LocalizedString EDITS_NOT_COPIED ( "ScreenServiceAction", "Edits not cop
|
||||
static LocalizedString COPIED_TO_CARD ( "ScreenServiceAction", "Copied to P%d card:" );
|
||||
static LocalizedString COPIED ( "ScreenServiceAction", "%d copied" );
|
||||
static LocalizedString OVERWRITTEN ( "ScreenServiceAction", "%d overwritten" );
|
||||
static LocalizedString ADDED_AND_OVERWRITTEN ( "ScreenServiceAction", "%d added, %d overwritten" );
|
||||
static LocalizedString ADDED ( "ScreenServiceAction", "%d added" );
|
||||
static LocalizedString IGNORED ( "ScreenServiceAction", "%d ignored" );
|
||||
static LocalizedString FAILED ( "ScreenServiceAction", "%d failed" );
|
||||
static LocalizedString DELETED ( "ScreenServiceAction", "%d deleted" );
|
||||
|
||||
static RString CopyEdits( const RString &sFromProfileDir, const RString &sToProfileDir, const RString &sDisplayDir )
|
||||
{
|
||||
int iNumAttempted = 0;
|
||||
int iNumSuccessful = 0;
|
||||
int iNumSucceeded = 0;
|
||||
int iNumOverwritten = 0;
|
||||
int iNumIgnored = 0;
|
||||
int iNumErrored = 0;
|
||||
|
||||
CopyEdits( sFromProfileDir, sToProfileDir, iNumAttempted, iNumSuccessful, iNumOverwritten );
|
||||
CopyEdits( sFromProfileDir, sToProfileDir, iNumSucceeded, iNumOverwritten, iNumIgnored, iNumErrored );
|
||||
|
||||
vector<RString> vs;
|
||||
vs.push_back( sDisplayDir );
|
||||
vs.push_back( ssprintf( COPIED.GetValue(), iNumSuccessful ) );
|
||||
vs.push_back( ssprintf( OVERWRITTEN.GetValue(), iNumOverwritten ) );
|
||||
if( iNumSuccessful < iNumAttempted )
|
||||
vs.push_back( ssprintf( FAILED.GetValue(), iNumAttempted-iNumSuccessful ) );
|
||||
vs.push_back( ssprintf( COPIED.GetValue(), iNumSucceeded ) + ", " + ssprintf( OVERWRITTEN.GetValue(), iNumOverwritten ) );
|
||||
if( iNumIgnored )
|
||||
vs.push_back( ssprintf( IGNORED.GetValue(), iNumIgnored ) );
|
||||
if( iNumErrored )
|
||||
vs.push_back( ssprintf( FAILED.GetValue(), iNumErrored ) );
|
||||
return join( "\n", vs );
|
||||
}
|
||||
|
||||
@@ -343,7 +359,7 @@ static RString SyncEditsMachineToMemoryCard()
|
||||
MEMCARDMAN->UnmountCard(pn);
|
||||
|
||||
RString sRet = ssprintf( COPIED_TO_CARD.GetValue(), pn+1 ) + " ";
|
||||
sRet += ssprintf( ADDED_AND_OVERWRITTEN.GetValue(), iNumAdded, iNumOverwritten );
|
||||
sRet += ssprintf( ADDED.GetValue(), iNumAdded ) + ", " + ssprintf( OVERWRITTEN.GetValue(), iNumOverwritten );
|
||||
if( iNumDeleted )
|
||||
sRet += RString(" ") + ssprintf( DELETED.GetValue(), iNumDeleted );
|
||||
if( iNumFailed )
|
||||
|
||||
@@ -1395,7 +1395,7 @@ void SongManager::LoadAllFromProfileDir( const RString &sProfileDir, ProfileSlot
|
||||
{
|
||||
RString fn = vsFiles[i];
|
||||
|
||||
SMLoader::LoadEdit( fn, slot );
|
||||
SMLoader::LoadEditFromFile( fn, slot, true );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1415,7 +1415,7 @@ void SongManager::LoadAllFromProfileDir( const RString &sProfileDir, ProfileSlot
|
||||
{
|
||||
RString fn = vsFiles[i];
|
||||
|
||||
CourseLoaderCRS::LoadEdit( fn, slot );
|
||||
CourseLoaderCRS::LoadEditFromFile( fn, slot );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user