optimize profile loading
This commit is contained in:
@@ -201,6 +201,8 @@ void GameState::PlayersFinalized()
|
|||||||
// apply saved default modifiers if any
|
// apply saved default modifiers if any
|
||||||
FOREACH_HumanPlayer( pn )
|
FOREACH_HumanPlayer( pn )
|
||||||
{
|
{
|
||||||
|
PROFILEMAN->LoadFirstAvailableProfile( pn, false ); // load full profile
|
||||||
|
|
||||||
if( !PROFILEMAN->IsUsingProfile(pn) )
|
if( !PROFILEMAN->IsUsingProfile(pn) )
|
||||||
continue; // skip
|
continue; // skip
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ void MemoryCardManager::Update( float fDelta )
|
|||||||
{
|
{
|
||||||
for( unsigned i=0; i<vOld.size(); i++ )
|
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
|
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()) );
|
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++ )
|
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
|
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()) );
|
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();
|
AssignUnassignedCards();
|
||||||
|
|
||||||
|
// Load profiles from cards that were just connected.
|
||||||
if( !m_bCardsLocked )
|
if( !m_bCardsLocked )
|
||||||
{
|
{
|
||||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
FOREACH_PlayerNumber( pn )
|
||||||
PROFILEMAN->LoadFirstAvailableProfile( (PlayerNumber)p );
|
{
|
||||||
|
bool bPlayersCardWasJustConnected = find(vConnects.begin(),vConnects.end(),m_Device[pn]) != vConnects.end();
|
||||||
|
if( bPlayersCardWasJustConnected )
|
||||||
|
PROFILEMAN->LoadFirstAvailableProfile( pn, true ); // fast load
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SCREENMAN->RefreshCreditsMessages();
|
SCREENMAN->RefreshCreditsMessages();
|
||||||
}
|
}
|
||||||
@@ -153,8 +158,6 @@ void MemoryCardManager::LockCards( bool bLock )
|
|||||||
// clear too late flag
|
// clear too late flag
|
||||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||||
m_bTooLate[p] = false;
|
m_bTooLate[p] = false;
|
||||||
|
|
||||||
AssignUnassignedCards();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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.empty() );
|
||||||
ASSERT( sProfileDir.Right(1) == "/" );
|
ASSERT( sProfileDir.Right(1) == "/" );
|
||||||
@@ -89,13 +89,10 @@ bool ProfileManager::LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIs
|
|||||||
m_sProfileDir[pn] = sProfileDir;
|
m_sProfileDir[pn] = sProfileDir;
|
||||||
m_bWasLoadedFromMemoryCard[pn] = bIsMemCard;
|
m_bWasLoadedFromMemoryCard[pn] = bIsMemCard;
|
||||||
|
|
||||||
bool bResult = m_Profile[pn].LoadAllFromDir( m_sProfileDir[pn] );
|
if( bLoadNamesOnly )
|
||||||
if( !bResult )
|
m_Profile[pn].LoadEditableDataFromDir( m_sProfileDir[pn] );
|
||||||
{
|
else
|
||||||
LOG->Warn( "Attempting to load profile from '%s' and does not exist", sProfileDir.c_str() );
|
m_Profile[pn].LoadAllFromDir( m_sProfileDir[pn] );
|
||||||
UnloadProfile( pn );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -114,7 +111,7 @@ bool ProfileManager::CreateProfile( CString sProfileDir, CString sName )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProfileManager::LoadDefaultProfileFromMachine( PlayerNumber pn )
|
bool ProfileManager::LoadDefaultProfileFromMachine( PlayerNumber pn, bool bLoadNamesOnly )
|
||||||
{
|
{
|
||||||
CString sProfileID = PREFSMAN->m_sDefaultLocalProfileID[pn];
|
CString sProfileID = PREFSMAN->m_sDefaultLocalProfileID[pn];
|
||||||
if( sProfileID.empty() )
|
if( sProfileID.empty() )
|
||||||
@@ -125,10 +122,10 @@ bool ProfileManager::LoadDefaultProfileFromMachine( PlayerNumber pn )
|
|||||||
|
|
||||||
CString sDir = USER_PROFILES_DIR + sProfileID + "/";
|
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 );
|
UnloadProfile( pn );
|
||||||
#ifndef _XBOX
|
#ifndef _XBOX
|
||||||
@@ -142,13 +139,13 @@ bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn )
|
|||||||
sDir += '/';
|
sDir += '/';
|
||||||
|
|
||||||
bool bResult;
|
bool bResult;
|
||||||
bResult = LoadProfile( pn, sDir, true );
|
bResult = LoadProfile( pn, sDir, true, bLoadNamesOnly );
|
||||||
if( bResult )
|
if( bResult )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
CreateMemoryCardProfile( pn );
|
CreateMemoryCardProfile( pn );
|
||||||
|
|
||||||
bResult = LoadProfile( pn, sDir, true );
|
bResult = LoadProfile( pn, sDir, true, bLoadNamesOnly );
|
||||||
return bResult;
|
return bResult;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -172,12 +169,12 @@ bool ProfileManager::CreateMemoryCardProfile( PlayerNumber pn )
|
|||||||
return CreateProfile( sDir, NEW_MEM_CARD_NAME );
|
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;
|
return true;
|
||||||
|
|
||||||
if( LoadDefaultProfileFromMachine(pn) )
|
if( LoadDefaultProfileFromMachine(pn,bLoadNamesOnly) )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ public:
|
|||||||
void GetLocalProfileIDs( vector<CString> &asProfileIDsOut ) const;
|
void GetLocalProfileIDs( vector<CString> &asProfileIDsOut ) const;
|
||||||
void GetLocalProfileNames( vector<CString> &asNamesOut ) const;
|
void GetLocalProfileNames( vector<CString> &asNamesOut ) const;
|
||||||
|
|
||||||
bool LoadFirstAvailableProfile( PlayerNumber pn ); // memory card or local profile
|
bool LoadFirstAvailableProfile( PlayerNumber pn, bool bLoadNamesOnly ); // memory card or local profile
|
||||||
bool LoadProfileFromMemoryCard( PlayerNumber pn );
|
bool LoadProfileFromMemoryCard( PlayerNumber pn, bool bLoadNamesOnly );
|
||||||
bool SaveProfile( PlayerNumber pn ) const;
|
bool SaveProfile( PlayerNumber pn ) const;
|
||||||
void UnloadProfile( PlayerNumber pn );
|
void UnloadProfile( PlayerNumber pn );
|
||||||
|
|
||||||
@@ -103,9 +103,9 @@ public:
|
|||||||
// void ReadSM300NoteScores();
|
// void ReadSM300NoteScores();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool LoadDefaultProfileFromMachine( PlayerNumber pn );
|
bool LoadDefaultProfileFromMachine( PlayerNumber pn, bool bLoadNamesOnly );
|
||||||
bool CreateMemoryCardProfile( PlayerNumber pn );
|
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 );
|
bool CreateProfile( CString sProfileDir, CString sName );
|
||||||
|
|
||||||
// Directory that contains the profile. Either on local machine or
|
// Directory that contains the profile. Either on local machine or
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ bool Screen::JoinInput( const DeviceInput& DeviceI, const InputEventType type, c
|
|||||||
if( GAMESTATE->m_MasterPlayerNumber == PLAYER_INVALID )
|
if( GAMESTATE->m_MasterPlayerNumber == PLAYER_INVALID )
|
||||||
GAMESTATE->m_MasterPlayerNumber = MenuI.player;
|
GAMESTATE->m_MasterPlayerNumber = MenuI.player;
|
||||||
|
|
||||||
PROFILEMAN->LoadFirstAvailableProfile( MenuI.player );
|
PROFILEMAN->LoadFirstAvailableProfile( MenuI.player, true ); // fast load
|
||||||
SCREENMAN->RefreshCreditsMessages();
|
SCREENMAN->RefreshCreditsMessages();
|
||||||
|
|
||||||
SCREENMAN->PlayStartSound();
|
SCREENMAN->PlayStartSound();
|
||||||
|
|||||||
@@ -110,8 +110,8 @@ void ScreenEvaluation::Init()
|
|||||||
|
|
||||||
if( PREFSMAN->m_bScreenTestMode )
|
if( PREFSMAN->m_bScreenTestMode )
|
||||||
{
|
{
|
||||||
PROFILEMAN->LoadFirstAvailableProfile(PLAYER_1);
|
PROFILEMAN->LoadFirstAvailableProfile(PLAYER_1, false);
|
||||||
PROFILEMAN->LoadFirstAvailableProfile(PLAYER_2);
|
PROFILEMAN->LoadFirstAvailableProfile(PLAYER_2, false);
|
||||||
|
|
||||||
GAMESTATE->m_PlayMode = PLAY_MODE_ARCADE;
|
GAMESTATE->m_PlayMode = PLAY_MODE_ARCADE;
|
||||||
GAMESTATE->m_CurStyle = STYLE_DANCE_VERSUS;
|
GAMESTATE->m_CurStyle = STYLE_DANCE_VERSUS;
|
||||||
|
|||||||
Reference in New Issue
Block a user