示例#1
0
BOOL SFLogicEntry::OnConnectPlayer(int serial)
{
	SFPlayer* pPlayer = m_pPlayerPool->Alloc();

	if(pPlayer == NULL)
		return FALSE;

	pPlayer->Reset();
	pPlayer->SetSerial(serial);

	pPlayer->ChangeState(PLAYER_STATE_INIT);

	m_PlayerMap.insert(PlayerMap::value_type(serial, pPlayer));

	SendAuthPacket(serial);

	return TRUE;
}
示例#2
0
BOOL SFLogicEntry::OnDisconnectPlayer(int serial)
{
	PlayerMap::iterator iter = m_PlayerMap.find(serial);
	
	if(iter == m_PlayerMap.end())
	{
		SFASSERT(0);
		return FALSE;
	}

	SFPlayer* pPlayer = iter->second;

	m_pPlayerManager->DelPlayer(pPlayer);

///////////////////////////////////////////////////////////
//20120619 이런식으로 짜면 실수할 여지가 크다.... 나중에 수정할 수 있도록 한다.
///////////////////////////////////////////////////////////
	if (pPlayer->GetPlayerState() == PLAYER_STATE_LOADING ||
		pPlayer->GetPlayerState() == PLAYER_STATE_ROOM ||
		pPlayer->GetPlayerState() == PLAYER_STATE_PLAY ||
		pPlayer->GetPlayerState() == PLAYER_STATE_PLAYEND ||
		pPlayer->GetPlayerState() == PLAYER_STATE_PLAYREADY)
	{
		SFRoomManager* pManager = GetRoomManager();
		SFRoom* pRoom = pManager->GetRoom(pPlayer->GetRoomIndex());
		pRoom->GetRoomFSM()->OnLeaveRoom(pPlayer);
	}

	pPlayer->ChangeState(PLAYER_STATE_NONE);

	m_pPlayerPool->Release(pPlayer);

	m_PlayerMap.erase(iter);

	return TRUE;
}