don't unload edit steps while they're in use
This commit is contained in:
@@ -359,8 +359,6 @@ void GameState::JoinPlayer( PlayerNumber pn )
|
|||||||
|
|
||||||
void GameState::UnjoinPlayer( PlayerNumber pn )
|
void GameState::UnjoinPlayer( PlayerNumber pn )
|
||||||
{
|
{
|
||||||
PROFILEMAN->UnloadProfile( pn );
|
|
||||||
|
|
||||||
m_bSideIsJoined[pn] = false;
|
m_bSideIsJoined[pn] = false;
|
||||||
m_iPlayerStageTokens[pn] = 0;
|
m_iPlayerStageTokens[pn] = 0;
|
||||||
|
|
||||||
@@ -369,8 +367,10 @@ void GameState::UnjoinPlayer( PlayerNumber pn )
|
|||||||
if( m_MasterPlayerNumber == pn )
|
if( m_MasterPlayerNumber == pn )
|
||||||
m_MasterPlayerNumber = GetFirstHumanPlayer();
|
m_MasterPlayerNumber = GetFirstHumanPlayer();
|
||||||
|
|
||||||
|
/* Unjoin STATSMAN first, so steps used by this player are released
|
||||||
|
* and can be released by PROFILEMAN. */
|
||||||
STATSMAN->UnjoinPlayer( pn );
|
STATSMAN->UnjoinPlayer( pn );
|
||||||
|
PROFILEMAN->UnloadProfile( pn );
|
||||||
|
|
||||||
Message msg( MessageIDToString(Message_PlayerUnjoined) );
|
Message msg( MessageIDToString(Message_PlayerUnjoined) );
|
||||||
msg.SetParam( "Player", pn );
|
msg.SetParam( "Player", pn );
|
||||||
|
|||||||
@@ -1263,7 +1263,9 @@ bool Song::Matches(RString sGroup, RString sSong) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Song::FreeAllLoadedFromProfile( ProfileSlot slot )
|
/* If apInUse is set, it contains a list of steps which are in use elsewhere, and
|
||||||
|
* should not be deleted. */
|
||||||
|
void Song::FreeAllLoadedFromProfile( ProfileSlot slot, const set<Steps*> *setInUse )
|
||||||
{
|
{
|
||||||
/* DeleteSteps will remove and recreate autogen notes, which may reorder
|
/* DeleteSteps will remove and recreate autogen notes, which may reorder
|
||||||
* m_vpSteps, so be careful not to skip over entries. */
|
* m_vpSteps, so be careful not to skip over entries. */
|
||||||
@@ -1273,8 +1275,11 @@ void Song::FreeAllLoadedFromProfile( ProfileSlot slot )
|
|||||||
Steps* pSteps = m_vpSteps[s];
|
Steps* pSteps = m_vpSteps[s];
|
||||||
if( !pSteps->WasLoadedFromProfile() )
|
if( !pSteps->WasLoadedFromProfile() )
|
||||||
continue;
|
continue;
|
||||||
if( slot == ProfileSlot_Invalid || pSteps->GetLoadedFromProfileSlot() == slot )
|
if( slot != ProfileSlot_Invalid && pSteps->GetLoadedFromProfileSlot() != slot )
|
||||||
apToRemove.push_back( pSteps );
|
continue;
|
||||||
|
if( setInUse != NULL && setInUse->find(pSteps) != setInUse->end() )
|
||||||
|
continue;
|
||||||
|
apToRemove.push_back( pSteps );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( unsigned i = 0; i < apToRemove.size(); ++i )
|
for( unsigned i = 0; i < apToRemove.size(); ++i )
|
||||||
|
|||||||
@@ -1585,8 +1585,11 @@ void SongManager::FreeAllLoadedFromProfile( ProfileSlot slot )
|
|||||||
RefreshCourseGroupInfo();
|
RefreshCourseGroupInfo();
|
||||||
|
|
||||||
/* Free profile steps. */
|
/* Free profile steps. */
|
||||||
|
set<Steps*> setInUse;
|
||||||
|
if( STATSMAN )
|
||||||
|
STATSMAN->GetStepsInUse( setInUse );
|
||||||
FOREACH( Song*, m_pSongs, s )
|
FOREACH( Song*, m_pSongs, s )
|
||||||
(*s)->FreeAllLoadedFromProfile( slot );
|
(*s)->FreeAllLoadedFromProfile( slot, &setInUse );
|
||||||
|
|
||||||
// After freeing some Steps pointers, the cache will be invalid.
|
// After freeing some Steps pointers, the cache will be invalid.
|
||||||
StepsID::ClearCache();
|
StepsID::ClearCache();
|
||||||
|
|||||||
@@ -229,7 +229,24 @@ void StatsManager::UnjoinPlayer( PlayerNumber pn )
|
|||||||
m_vPlayedStageStats.erase( m_vPlayedStageStats.begin()+i );
|
m_vPlayedStageStats.erase( m_vPlayedStageStats.begin()+i );
|
||||||
--i;
|
--i;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsManager::GetStepsInUse( set<Steps*> &apInUseOut ) const
|
||||||
|
{
|
||||||
|
for( int i = 0; i < (int) m_vPlayedStageStats.size(); ++i )
|
||||||
|
{
|
||||||
|
FOREACH_PlayerNumber( pn )
|
||||||
|
{
|
||||||
|
const PlayerStageStats &pss = m_vPlayedStageStats[i].m_player[pn];
|
||||||
|
apInUseOut.insert( pss.m_vpPossibleSteps.begin(), pss.m_vpPossibleSteps.end() );
|
||||||
|
}
|
||||||
|
|
||||||
|
FOREACH_MultiPlayer( mp )
|
||||||
|
{
|
||||||
|
const PlayerStageStats &pss = m_vPlayedStageStats[i].m_multiPlayer[mp];
|
||||||
|
apInUseOut.insert( pss.m_vpPossibleSteps.begin(), pss.m_vpPossibleSteps.end() );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// lua start
|
// lua start
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public:
|
|||||||
static void CommitStatsToProfiles( const StageStats *pSS );
|
static void CommitStatsToProfiles( const StageStats *pSS );
|
||||||
|
|
||||||
void UnjoinPlayer( PlayerNumber pn );
|
void UnjoinPlayer( PlayerNumber pn );
|
||||||
|
void GetStepsInUse( set<Steps*> &apInUseOut ) const;
|
||||||
|
|
||||||
// Lua
|
// Lua
|
||||||
void PushSelf( lua_State *L );
|
void PushSelf( lua_State *L );
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "EnumHelper.h"
|
#include "EnumHelper.h"
|
||||||
#include "RageUtil_AutoPtr.h"
|
#include "RageUtil_AutoPtr.h"
|
||||||
#include "RageTypes.h"
|
#include "RageTypes.h"
|
||||||
|
#include <set>
|
||||||
|
|
||||||
class Steps;
|
class Steps;
|
||||||
class Style;
|
class Style;
|
||||||
@@ -212,7 +213,7 @@ public:
|
|||||||
void AddSteps( Steps* pSteps ); // we are responsible for deleting the memory pointed to by pSteps!
|
void AddSteps( Steps* pSteps ); // we are responsible for deleting the memory pointed to by pSteps!
|
||||||
void DeleteSteps( const Steps* pSteps, bool bReAutoGen = true );
|
void DeleteSteps( const Steps* pSteps, bool bReAutoGen = true );
|
||||||
|
|
||||||
void FreeAllLoadedFromProfile( ProfileSlot slot = ProfileSlot_Invalid );
|
void FreeAllLoadedFromProfile( ProfileSlot slot = ProfileSlot_Invalid, const set<Steps*> *setInUse = NULL );
|
||||||
bool WasLoadedFromProfile() const { return m_LoadedFromProfile != ProfileSlot_Invalid; }
|
bool WasLoadedFromProfile() const { return m_LoadedFromProfile != ProfileSlot_Invalid; }
|
||||||
void GetStepsLoadedFromProfile( ProfileSlot slot, vector<Steps*> &vpStepsOut ) const;
|
void GetStepsLoadedFromProfile( ProfileSlot slot, vector<Steps*> &vpStepsOut ) const;
|
||||||
int GetNumStepsLoadedFromProfile( ProfileSlot slot ) const;
|
int GetNumStepsLoadedFromProfile( ProfileSlot slot ) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user