clean m_vPlayedStageStats as players unjoin
This commit is contained in:
@@ -361,6 +361,8 @@ void GameState::UnjoinPlayer( PlayerNumber pn )
|
||||
if( m_MasterPlayerNumber == pn )
|
||||
m_MasterPlayerNumber = GAMESTATE->GetFirstHumanPlayer();
|
||||
|
||||
STATSMAN->UnjoinPlayer( pn );
|
||||
|
||||
Message msg( MessageIDToString(Message_PlayerUnjoined) );
|
||||
msg.SetParam( "Player", pn );
|
||||
MESSAGEMAN->Broadcast( msg );
|
||||
|
||||
@@ -24,6 +24,7 @@ Grade GetGradeFromPercent( float fPercent, bool bMerciful );
|
||||
|
||||
void PlayerStageStats::Init()
|
||||
{
|
||||
m_bJoined = false;
|
||||
m_vpPlayedSteps.clear();
|
||||
m_vpPossibleSteps.clear();
|
||||
m_fAliveSeconds = 0;
|
||||
@@ -63,6 +64,7 @@ void PlayerStageStats::Init()
|
||||
|
||||
void PlayerStageStats::AddStats( const PlayerStageStats& other )
|
||||
{
|
||||
m_bJoined = other.m_bJoined;
|
||||
FOREACH_CONST( Steps*, other.m_vpPlayedSteps, s )
|
||||
m_vpPlayedSteps.push_back( *s );
|
||||
FOREACH_CONST( Steps*, other.m_vpPossibleSteps, s )
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
int GetLessonScoreNeeded() const;
|
||||
void ResetScoreForLesson();
|
||||
|
||||
bool m_bJoined;
|
||||
vector<Steps*> m_vpPlayedSteps;
|
||||
vector<Steps*> m_vpPossibleSteps;
|
||||
float m_fAliveSeconds; // how far into the music did they last before failing? Updated by Gameplay, scaled by music rate.
|
||||
|
||||
@@ -846,6 +846,12 @@ void ScreenGameplay::InitSongQueues()
|
||||
if( pi->GetPlayerStageStats() )
|
||||
pi->GetPlayerStageStats()->m_vpPossibleSteps = pi->m_vpStepsQueue;
|
||||
}
|
||||
|
||||
FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi )
|
||||
{
|
||||
if( pi->GetPlayerStageStats() )
|
||||
pi->GetPlayerStageStats()->m_bJoined = true;
|
||||
}
|
||||
}
|
||||
|
||||
ScreenGameplay::~ScreenGameplay()
|
||||
|
||||
@@ -210,6 +210,32 @@ void StatsManager::CommitStatsToProfiles()
|
||||
}
|
||||
}
|
||||
|
||||
void StatsManager::UnjoinPlayer( PlayerNumber pn )
|
||||
{
|
||||
/* A player has been unjoined. Clear his data from m_vPlayedStageStats, and
|
||||
* purge any m_vPlayedStageStats that no longer have any player data because
|
||||
* all of the players that were playing at the time have been unjoined. */
|
||||
FOREACH( StageStats, m_vPlayedStageStats, ss )
|
||||
ss->m_player[pn] = PlayerStageStats();
|
||||
|
||||
for( int i = 0; i < (int) m_vPlayedStageStats.size(); ++i )
|
||||
{
|
||||
StageStats &ss = m_vPlayedStageStats[i];
|
||||
bool bIsActive = false;
|
||||
FOREACH_PlayerNumber( p )
|
||||
if( ss.m_player[p].m_bJoined )
|
||||
bIsActive = true;
|
||||
FOREACH_MultiPlayer( mp )
|
||||
if( ss.m_multiPlayer[mp].m_bJoined )
|
||||
bIsActive = true;
|
||||
if( bIsActive )
|
||||
continue;
|
||||
|
||||
m_vPlayedStageStats.erase( m_vPlayedStageStats.begin()+i );
|
||||
--i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// lua start
|
||||
#include "LuaBinding.h"
|
||||
|
||||
@@ -26,6 +26,8 @@ public:
|
||||
|
||||
void CommitStatsToProfiles();
|
||||
|
||||
void UnjoinPlayer( PlayerNumber pn );
|
||||
|
||||
// Lua
|
||||
void PushSelf( lua_State *L );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user