SongManager::LoadAllFromProfiles -> SongManager::LoadAllFromProfile
mount each memory card as needed, one at a time working on being able to start a timeout period in MEMCARDMAN::MountCard
This commit is contained in:
+13
-11
@@ -232,12 +232,11 @@ void GameState::PlayersFinalized()
|
||||
|
||||
MEMCARDMAN->LockCards();
|
||||
|
||||
/* Mount all available cards, for loading the profile and edits. */
|
||||
MEMCARDMAN->TryMountAllCards();
|
||||
|
||||
// apply saved default modifiers if any
|
||||
FOREACH_HumanPlayer( pn )
|
||||
{
|
||||
MEMCARDMAN->MountUsedCard( pn );
|
||||
|
||||
PROFILEMAN->LoadFirstAvailableProfile( pn ); // load full profile
|
||||
|
||||
if( !PROFILEMAN->IsUsingProfile(pn) )
|
||||
@@ -266,17 +265,18 @@ void GameState::PlayersFinalized()
|
||||
m_pPreferredSong = pProfile->m_lastSong.ToSong();
|
||||
if( m_pPreferredCourse == NULL )
|
||||
m_pPreferredCourse = pProfile->m_lastCourse.ToCourse();
|
||||
|
||||
SONGMAN->LoadAllFromProfile( (ProfileSlot) pn );
|
||||
MEMCARDMAN->UnmountCard( pn );
|
||||
}
|
||||
|
||||
SONGMAN->LoadAllFromProfiles();
|
||||
SONGMAN->LoadAllFromProfile( PROFILE_SLOT_MACHINE );
|
||||
|
||||
FOREACH_PlayerNumber( pn )
|
||||
{
|
||||
if( !IsHumanPlayer(pn) )
|
||||
ApplyModifiers( pn, DEFAULT_CPU_MODIFIERS );
|
||||
}
|
||||
|
||||
MEMCARDMAN->UnmountAllUsedCards();
|
||||
}
|
||||
|
||||
/* This data is added to each player profile, and to the machine profile per-player. */
|
||||
@@ -350,21 +350,23 @@ void GameState::EndGame()
|
||||
}
|
||||
}
|
||||
|
||||
MEMCARDMAN->MountAllUsedCards();
|
||||
|
||||
BOOKKEEPER->WriteToDisk();
|
||||
PROFILEMAN->SaveAllProfiles();
|
||||
|
||||
FOREACH_HumanPlayer( pn )
|
||||
{
|
||||
if( !PROFILEMAN->IsUsingProfile(pn) )
|
||||
continue;
|
||||
|
||||
if( PROFILEMAN->ProfileWasLoadedFromMemoryCard(pn) )
|
||||
MEMCARDMAN->MountUsedCard( pn );
|
||||
PROFILEMAN->SaveProfile( pn );
|
||||
MEMCARDMAN->UnmountCard( pn );
|
||||
|
||||
PROFILEMAN->UnloadProfile( pn );
|
||||
}
|
||||
|
||||
MEMCARDMAN->UnmountAllUsedCards();
|
||||
|
||||
PROFILEMAN->SaveMachineProfile();
|
||||
|
||||
// Reset the USB storage device numbers -after- saving
|
||||
CHECKPOINT;
|
||||
MEMCARDMAN->FlushAndReset();
|
||||
|
||||
@@ -248,51 +248,35 @@ void MemoryCardManager::TryMountAllCards()
|
||||
}
|
||||
|
||||
/* Called in EndGame just before writing the profile. Should block. */
|
||||
void MemoryCardManager::MountAllUsedCards()
|
||||
void MemoryCardManager::MountUsedCard( PlayerNumber pn )
|
||||
{
|
||||
FOREACH_EnabledPlayer( p )
|
||||
{
|
||||
if( m_Device[p].IsBlank() ) // they don't have an assigned card
|
||||
continue;
|
||||
|
||||
if( m_bTooLate[p] || !m_Device[p].bWriteTestSucceeded || !PROFILEMAN->ProfileWasLoadedFromMemoryCard(p) )
|
||||
continue;
|
||||
|
||||
MountCard( p );
|
||||
}
|
||||
}
|
||||
|
||||
/* Called in EndGame just after writing the profile. Called by PlayersFinalized just after
|
||||
* reading the profile. Should never block; use FlushAndReset to block until writes complete. */
|
||||
void MemoryCardManager::UnmountAllUsedCards()
|
||||
{
|
||||
FOREACH_EnabledPlayer( p )
|
||||
{
|
||||
if( m_Device[p].IsBlank() ) // they don't have an assigned card
|
||||
continue;
|
||||
|
||||
if( m_bTooLate[p] || !m_Device[p].bWriteTestSucceeded || !PROFILEMAN->ProfileWasLoadedFromMemoryCard(p) )
|
||||
continue;
|
||||
|
||||
UnmountCard( p );
|
||||
}
|
||||
if( m_Device[pn].IsBlank() ) // they don't have an assigned card
|
||||
return;
|
||||
|
||||
MountCard( pn );
|
||||
}
|
||||
|
||||
void MemoryCardManager::MountCard( PlayerNumber pn )
|
||||
{
|
||||
ASSERT( !m_Device[pn].IsBlank() );
|
||||
|
||||
if( !m_Device[pn].bWriteTestSucceeded || m_bTooLate[pn] )
|
||||
return;
|
||||
|
||||
/* Pause the mounting thread when we mount the first drive. */
|
||||
bool bNeedPause = true;
|
||||
bool bStartingMemoryCardAccess = true;
|
||||
FOREACH_PlayerNumber( p )
|
||||
if( m_bMounted[p] )
|
||||
bNeedPause = false;
|
||||
if( bNeedPause )
|
||||
bStartingMemoryCardAccess = false; /* already did */
|
||||
if( bStartingMemoryCardAccess )
|
||||
{
|
||||
/* We're starting to do stuff to the memory cards. */
|
||||
this->PauseMountingThread();
|
||||
}
|
||||
|
||||
if( !m_pDriver->MountAndTestWrite(&m_Device[pn]) )
|
||||
{
|
||||
if( bNeedPause )
|
||||
if( bStartingMemoryCardAccess )
|
||||
this->UnPauseMountingThread();
|
||||
|
||||
return;
|
||||
@@ -319,6 +303,8 @@ void MemoryCardManager::MountCard( PlayerNumber pn )
|
||||
}
|
||||
}
|
||||
|
||||
/* Called in EndGame just after writing the profile. Called by PlayersFinalized just after
|
||||
* reading the profile. Should never block; use FlushAndReset to block until writes complete. */
|
||||
void MemoryCardManager::UnmountCard( PlayerNumber pn )
|
||||
{
|
||||
ASSERT( !m_Device[pn].IsBlank() );
|
||||
|
||||
@@ -22,8 +22,7 @@ public:
|
||||
void LockCards(); // prevent removing or changing of memory cards
|
||||
void UnlockCards();
|
||||
void TryMountAllCards();
|
||||
void MountAllUsedCards();
|
||||
void UnmountAllUsedCards();
|
||||
void MountUsedCard( PlayerNumber pn );
|
||||
void MountCard( PlayerNumber pn );
|
||||
void UnmountCard( PlayerNumber pn );
|
||||
|
||||
|
||||
@@ -1175,48 +1175,45 @@ void SongManager::UpdateRankingCourses()
|
||||
}
|
||||
}
|
||||
|
||||
void SongManager::LoadAllFromProfiles()
|
||||
void SongManager::LoadAllFromProfile( ProfileSlot s )
|
||||
{
|
||||
FOREACH_ProfileSlot( s )
|
||||
if( !PROFILEMAN->IsUsingProfile(s) )
|
||||
return;
|
||||
|
||||
CString sProfileDir = PROFILEMAN->GetProfileDir( s );
|
||||
if( sProfileDir.empty() )
|
||||
return; // skip
|
||||
//
|
||||
// Load all .edit files.
|
||||
//
|
||||
{
|
||||
if( !PROFILEMAN->IsUsingProfile(s) )
|
||||
continue;
|
||||
CString sEditsDir = sProfileDir+"Edits/";
|
||||
|
||||
CString sProfileDir = PROFILEMAN->GetProfileDir( s );
|
||||
if( sProfileDir.empty() )
|
||||
continue; // skip
|
||||
//
|
||||
// Load all .edit files.
|
||||
//
|
||||
CStringArray asEditsFilesWithPath;
|
||||
GetDirListing( sEditsDir+"*.edit", asEditsFilesWithPath, false, true );
|
||||
|
||||
unsigned size = min( asEditsFilesWithPath.size(), (unsigned)MAX_EDITS_PER_PROFILE );
|
||||
|
||||
for( unsigned i=0; i<size; i++ )
|
||||
{
|
||||
CString sEditsDir = sProfileDir+"Edits/";
|
||||
CString fn = asEditsFilesWithPath[i];
|
||||
|
||||
CStringArray asEditsFilesWithPath;
|
||||
GetDirListing( sEditsDir+"*.edit", asEditsFilesWithPath, false, true );
|
||||
|
||||
unsigned size = min( asEditsFilesWithPath.size(), (unsigned)MAX_EDITS_PER_PROFILE );
|
||||
|
||||
for( unsigned i=0; i<size; i++ )
|
||||
int iBytes = FILEMAN->GetFileSizeInBytes( fn );
|
||||
if( iBytes > MAX_EDIT_SIZE_BYTES )
|
||||
{
|
||||
CString fn = asEditsFilesWithPath[i];
|
||||
|
||||
int iBytes = FILEMAN->GetFileSizeInBytes( fn );
|
||||
if( iBytes > MAX_EDIT_SIZE_BYTES )
|
||||
{
|
||||
LOG->Warn( "The file '%s' is unreasonably large. It won't be loaded.", fn.c_str() );
|
||||
continue;
|
||||
}
|
||||
|
||||
SMLoader::LoadEdit( fn, s );
|
||||
LOG->Warn( "The file '%s' is unreasonably large. It won't be loaded.", fn.c_str() );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Load all songs
|
||||
//
|
||||
{
|
||||
SMLoader::LoadEdit( fn, s );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Load all songs
|
||||
//
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void SongManager::FreeAllLoadedFromProfiles()
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
void RegenerateNonFixedCourses();
|
||||
void SetPreferences();
|
||||
|
||||
void LoadAllFromProfiles(); // song, edits
|
||||
void LoadAllFromProfile( ProfileSlot s ); // songs, edits
|
||||
void FreeAllLoadedFromProfiles();
|
||||
|
||||
void LoadGroupSymLinks( CString sDir, CString sGroupFolder );
|
||||
|
||||
Reference in New Issue
Block a user