bool LobbyGame::IsEveryoneReady()
{
	const LobbyClientMap &aMap = mClientList->GetClientMap();
	for(LobbyClientMap::const_iterator anItr = aMap.begin(); anItr!=aMap.end(); ++anItr)
	{
		LobbyClient *aClient = anItr->second;
		if(aClient->IsPlayer() && !aClient->IsCaptain(true) && !aClient->IsPlayerReady())
			return false;
	}

	return true;
}
void StagingLogic::HandlePlayerJoined(ReadBuffer &theMsg, LobbyClient *theSender)
{
	if(!theSender->IsCaptain(true))
		return;

	unsigned short aClientId = theMsg.ReadShort();
	LobbyClient *aClient = mGame->GetClient(aClientId);
	if(aClient==NULL)
		return;

	if(!aClient->IsPlayer()) 
	{
		LobbyPlayerPtr aPlayer = LobbyPlayer::CreatePlayer();
		if(!aPlayer->ReadData(theMsg))
			return;

		aClient->SetPlayer(aPlayer);
	}
	else
	{
		// already know about him (can happen if we're the captain or it's our client right after we joined)
		if(!IAmCaptain()) // already got ourselves in the join game reply
			return;
	}

	LobbyEvent::BroadcastEvent(new PlayerChangedEvent(aClient,LobbyChangeType_Add));
	if(aClient->SameTeam(mMyClient))
		LobbyEvent::BroadcastEvent(new PlayerTeamChangedEvent(aClient,LobbyChangeType_Add));

	mGame->HandlePlayerJoined(aClient);
	if(LobbyPersistentData::GetStagingSoundEffects())
		LobbyMisc::PlaySound(LobbyGlobal_PlayerJoined_Sound);

	if(mEveryoneReadySoundState && !aClient->IsPlayerReady())
		mEveryoneReadySoundState = false;

	UpdateStartButton();
}