optimize profile loading

This commit is contained in:
Chris Danford
2004-03-29 06:47:10 +00:00
parent ef193252bc
commit d6e52f6aac
6 changed files with 31 additions and 29 deletions
+2
View File
@@ -201,6 +201,8 @@ void GameState::PlayersFinalized()
// apply saved default modifiers if any
FOREACH_HumanPlayer( pn )
{
PROFILEMAN->LoadFirstAvailableProfile( pn, false ); // load full profile
if( !PROFILEMAN->IsUsingProfile(pn) )
continue; // skip
+9 -6
View File
@@ -63,7 +63,7 @@ void MemoryCardManager::Update( float fDelta )
{
for( unsigned i=0; i<vOld.size(); i++ )
{
const UsbStorageDevice old = vOld[i];
const UsbStorageDevice &old = vOld[i];
if( find(vNew.begin(),vNew.end(),old) == vNew.end() ) // didn't find
{
LOG->Trace( ssprintf("Disconnected bus %d port %d device %d path %s", old.iBus, old.iPortOnHub, old.iDeviceOnBus, old.sOsMountDir.c_str()) );
@@ -76,7 +76,7 @@ void MemoryCardManager::Update( float fDelta )
{
for( unsigned i=0; i<vNew.size(); i++ )
{
const UsbStorageDevice newd = vNew[i];
const UsbStorageDevice &newd = vNew[i];
if( find(vOld.begin(),vOld.end(),newd) == vOld.end() ) // didn't find
{
LOG->Trace( ssprintf("Connected bus %d port %d device %d path %s", newd.iBus, newd.iPortOnHub, newd.iDeviceOnBus, newd.sOsMountDir.c_str()) );
@@ -107,10 +107,15 @@ void MemoryCardManager::Update( float fDelta )
AssignUnassignedCards();
// Load profiles from cards that were just connected.
if( !m_bCardsLocked )
{
for( int p=0; p<NUM_PLAYERS; p++ )
PROFILEMAN->LoadFirstAvailableProfile( (PlayerNumber)p );
FOREACH_PlayerNumber( pn )
{
bool bPlayersCardWasJustConnected = find(vConnects.begin(),vConnects.end(),m_Device[pn]) != vConnects.end();
if( bPlayersCardWasJustConnected )
PROFILEMAN->LoadFirstAvailableProfile( pn, true ); // fast load
}
}
SCREENMAN->RefreshCreditsMessages();
}
@@ -153,8 +158,6 @@ void MemoryCardManager::LockCards( bool bLock )
// clear too late flag
for( int p=0; p<NUM_PLAYERS; p++ )
m_bTooLate[p] = false;
AssignUnassignedCards();
}
}
+13 -16
View File
@@ -81,7 +81,7 @@ void ProfileManager::GetLocalProfileNames( vector<CString> &asNamesOut ) const
}
bool ProfileManager::LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIsMemCard )
bool ProfileManager::LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIsMemCard, bool bLoadNamesOnly )
{
ASSERT( !sProfileDir.empty() );
ASSERT( sProfileDir.Right(1) == "/" );
@@ -89,13 +89,10 @@ bool ProfileManager::LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIs
m_sProfileDir[pn] = sProfileDir;
m_bWasLoadedFromMemoryCard[pn] = bIsMemCard;
bool bResult = m_Profile[pn].LoadAllFromDir( m_sProfileDir[pn] );
if( !bResult )
{
LOG->Warn( "Attempting to load profile from '%s' and does not exist", sProfileDir.c_str() );
UnloadProfile( pn );
return false;
}
if( bLoadNamesOnly )
m_Profile[pn].LoadEditableDataFromDir( m_sProfileDir[pn] );
else
m_Profile[pn].LoadAllFromDir( m_sProfileDir[pn] );
return true;
}
@@ -114,7 +111,7 @@ bool ProfileManager::CreateProfile( CString sProfileDir, CString sName )
return true;
}
bool ProfileManager::LoadDefaultProfileFromMachine( PlayerNumber pn )
bool ProfileManager::LoadDefaultProfileFromMachine( PlayerNumber pn, bool bLoadNamesOnly )
{
CString sProfileID = PREFSMAN->m_sDefaultLocalProfileID[pn];
if( sProfileID.empty() )
@@ -125,10 +122,10 @@ bool ProfileManager::LoadDefaultProfileFromMachine( PlayerNumber pn )
CString sDir = USER_PROFILES_DIR + sProfileID + "/";
return LoadProfile( pn, sDir, false );
return LoadProfile( pn, sDir, false, bLoadNamesOnly );
}
bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn )
bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn, bool bLoadNamesOnly )
{
UnloadProfile( pn );
#ifndef _XBOX
@@ -142,13 +139,13 @@ bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn )
sDir += '/';
bool bResult;
bResult = LoadProfile( pn, sDir, true );
bResult = LoadProfile( pn, sDir, true, bLoadNamesOnly );
if( bResult )
return true;
CreateMemoryCardProfile( pn );
bResult = LoadProfile( pn, sDir, true );
bResult = LoadProfile( pn, sDir, true, bLoadNamesOnly );
return bResult;
}
#endif
@@ -172,12 +169,12 @@ bool ProfileManager::CreateMemoryCardProfile( PlayerNumber pn )
return CreateProfile( sDir, NEW_MEM_CARD_NAME );
}
bool ProfileManager::LoadFirstAvailableProfile( PlayerNumber pn )
bool ProfileManager::LoadFirstAvailableProfile( PlayerNumber pn, bool bLoadNamesOnly )
{
if( LoadProfileFromMemoryCard(pn) )
if( LoadProfileFromMemoryCard(pn,bLoadNamesOnly) )
return true;
if( LoadDefaultProfileFromMachine(pn) )
if( LoadDefaultProfileFromMachine(pn,bLoadNamesOnly) )
return true;
return false;
+4 -4
View File
@@ -33,8 +33,8 @@ public:
void GetLocalProfileIDs( vector<CString> &asProfileIDsOut ) const;
void GetLocalProfileNames( vector<CString> &asNamesOut ) const;
bool LoadFirstAvailableProfile( PlayerNumber pn ); // memory card or local profile
bool LoadProfileFromMemoryCard( PlayerNumber pn );
bool LoadFirstAvailableProfile( PlayerNumber pn, bool bLoadNamesOnly ); // memory card or local profile
bool LoadProfileFromMemoryCard( PlayerNumber pn, bool bLoadNamesOnly );
bool SaveProfile( PlayerNumber pn ) const;
void UnloadProfile( PlayerNumber pn );
@@ -103,9 +103,9 @@ public:
// void ReadSM300NoteScores();
private:
bool LoadDefaultProfileFromMachine( PlayerNumber pn );
bool LoadDefaultProfileFromMachine( PlayerNumber pn, bool bLoadNamesOnly );
bool CreateMemoryCardProfile( PlayerNumber pn );
bool LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIsMemCard );
bool LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIsMemCard, bool bLoadNamesOnly );
bool CreateProfile( CString sProfileDir, CString sName );
// Directory that contains the profile. Either on local machine or
+1 -1
View File
@@ -196,7 +196,7 @@ bool Screen::JoinInput( const DeviceInput& DeviceI, const InputEventType type, c
if( GAMESTATE->m_MasterPlayerNumber == PLAYER_INVALID )
GAMESTATE->m_MasterPlayerNumber = MenuI.player;
PROFILEMAN->LoadFirstAvailableProfile( MenuI.player );
PROFILEMAN->LoadFirstAvailableProfile( MenuI.player, true ); // fast load
SCREENMAN->RefreshCreditsMessages();
SCREENMAN->PlayStartSound();
+2 -2
View File
@@ -110,8 +110,8 @@ void ScreenEvaluation::Init()
if( PREFSMAN->m_bScreenTestMode )
{
PROFILEMAN->LoadFirstAvailableProfile(PLAYER_1);
PROFILEMAN->LoadFirstAvailableProfile(PLAYER_2);
PROFILEMAN->LoadFirstAvailableProfile(PLAYER_1, false);
PROFILEMAN->LoadFirstAvailableProfile(PLAYER_2, false);
GAMESTATE->m_PlayMode = PLAY_MODE_ARCADE;
GAMESTATE->m_CurStyle = STYLE_DANCE_VERSUS;