Merge pull request #96 from kyzentun/UnloadProfile_optimization
Unload profile optimization
This commit is contained in:
+2
-2
@@ -529,7 +529,7 @@ bool GameCommand::IsPlayable( RString *why ) const
|
|||||||
/* If both sides are joined, disallow singles modes, since easy to select
|
/* If both sides are joined, disallow singles modes, since easy to select
|
||||||
* them accidentally, instead of versus mode. */
|
* them accidentally, instead of versus mode. */
|
||||||
if( m_pStyle->m_StyleType == StyleType_OnePlayerOneSide &&
|
if( m_pStyle->m_StyleType == StyleType_OnePlayerOneSide &&
|
||||||
GAMESTATE->GetNumSidesJoined() > 1 )
|
GAMESTATE->GetNumPlayersEnabled() > 1 )
|
||||||
{
|
{
|
||||||
if( why )
|
if( why )
|
||||||
*why = "too many players joined for ONE_PLAYER_ONE_CREDIT";
|
*why = "too many players joined for ONE_PLAYER_ONE_CREDIT";
|
||||||
@@ -669,9 +669,9 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
|
|||||||
switch( m_pStyle->m_StyleType )
|
switch( m_pStyle->m_StyleType )
|
||||||
{
|
{
|
||||||
case StyleType_OnePlayerOneSide:
|
case StyleType_OnePlayerOneSide:
|
||||||
|
case StyleType_OnePlayerTwoSides:
|
||||||
break;
|
break;
|
||||||
case StyleType_TwoPlayersTwoSides:
|
case StyleType_TwoPlayersTwoSides:
|
||||||
case StyleType_OnePlayerTwoSides:
|
|
||||||
case StyleType_TwoPlayersSharedSides:
|
case StyleType_TwoPlayersSharedSides:
|
||||||
{
|
{
|
||||||
FOREACH_PlayerNumber( p )
|
FOREACH_PlayerNumber( p )
|
||||||
|
|||||||
+17
-6
@@ -411,18 +411,29 @@ void GameState::JoinPlayer( PlayerNumber pn )
|
|||||||
|
|
||||||
void GameState::UnjoinPlayer( PlayerNumber pn )
|
void GameState::UnjoinPlayer( PlayerNumber pn )
|
||||||
{
|
{
|
||||||
|
/* Unjoin STATSMAN first, so steps used by this player are released
|
||||||
|
* and can be released by PROFILEMAN. */
|
||||||
|
STATSMAN->UnjoinPlayer( pn );
|
||||||
m_bSideIsJoined[pn] = false;
|
m_bSideIsJoined[pn] = false;
|
||||||
m_iPlayerStageTokens[pn] = 0;
|
m_iPlayerStageTokens[pn] = 0;
|
||||||
|
|
||||||
ResetPlayer( pn );
|
ResetPlayer( pn );
|
||||||
|
|
||||||
if( this->GetMasterPlayerNumber() == pn )
|
if( this->GetMasterPlayerNumber() == pn )
|
||||||
this->SetMasterPlayerNumber(GetFirstHumanPlayer());
|
{
|
||||||
|
// We can't use GetFirstHumanPlayer() because if both players were joined, GetFirstHumanPlayer() will always return PLAYER_1, even when PLAYER_1 is the player we're unjoining.
|
||||||
/* Unjoin STATSMAN first, so steps used by this player are released
|
FOREACH_HumanPlayer( hp )
|
||||||
* and can be released by PROFILEMAN. */
|
{
|
||||||
STATSMAN->UnjoinPlayer( pn );
|
if( pn != hp )
|
||||||
PROFILEMAN->UnloadProfile( pn );
|
{
|
||||||
|
this->SetMasterPlayerNumber(hp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( this->GetMasterPlayerNumber() == pn )
|
||||||
|
{
|
||||||
|
this->SetMasterPlayerNumber(PLAYER_INVALID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Message msg( MessageIDToString(Message_PlayerUnjoined) );
|
Message msg( MessageIDToString(Message_PlayerUnjoined) );
|
||||||
msg.SetParam( "Player", pn );
|
msg.SetParam( "Player", pn );
|
||||||
|
|||||||
@@ -349,6 +349,12 @@ bool ProfileManager::SaveLocalProfile( RString sProfileID )
|
|||||||
|
|
||||||
void ProfileManager::UnloadProfile( PlayerNumber pn )
|
void ProfileManager::UnloadProfile( PlayerNumber pn )
|
||||||
{
|
{
|
||||||
|
if( m_sProfileDir[pn].empty() )
|
||||||
|
{
|
||||||
|
// Don't bother unloading a profile that wasn't loaded in the first place.
|
||||||
|
// Saves us an expensive and pointless trip through all the songs.
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_sProfileDir[pn] = "";
|
m_sProfileDir[pn] = "";
|
||||||
m_sProfileDirImportedFrom[pn] = "";
|
m_sProfileDirImportedFrom[pn] = "";
|
||||||
m_bWasLoadedFromMemoryCard[pn] = false;
|
m_bWasLoadedFromMemoryCard[pn] = false;
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ bool ScreenSelectProfile::SetProfileIndex( PlayerNumber pn, int iProfileIndex )
|
|||||||
// unload player
|
// unload player
|
||||||
if( iProfileIndex == -2 )
|
if( iProfileIndex == -2 )
|
||||||
{
|
{
|
||||||
PROFILEMAN->UnloadProfile( pn );
|
// GAMESTATE->UnjoinPlayer takes care of unloading the profile.
|
||||||
GAMESTATE->UnjoinPlayer( pn );
|
GAMESTATE->UnjoinPlayer( pn );
|
||||||
MEMCARDMAN->UnlockCard( pn );
|
MEMCARDMAN->UnlockCard( pn );
|
||||||
MEMCARDMAN->UnmountCard( pn );
|
MEMCARDMAN->UnmountCard( pn );
|
||||||
|
|||||||
Reference in New Issue
Block a user