Beispiel #1
0
SFRoom* SFRoomManager::GetEmptyRoom()
{
	EmptyRoomMap::iterator iter = m_EmptyRoomMap.begin();

	if(iter == m_EmptyRoomMap.end())
		return NULL;

	SFRoom* pRoom = iter->second;

	SFASSERT(pRoom->GetRoomState() == ROOM_STATE_NONE);

	m_EmptyRoomMap.erase(iter);

	return pRoom;
}
Beispiel #2
0
SFRoom* SFRoomManager::GetRoom( int RoomIndex )
{
	if(RoomIndex < 0 || RoomIndex >= MAX_ROOM_COUNT)
	{
		SFASSERT(0);
		return NULL;
	}

	SFRoom* pRoom = m_RoomArray[RoomIndex];

	if(pRoom->GetRoomState() == ROOM_STATE_NONE)
	{
		return NULL;
	}

	return pRoom;
}
Beispiel #3
0
BOOL SFRoomManager::OnCreateRoom( SFPlayerLobby* pLobbyState, int GameMode )
{
	SFRoom* pRoom = GetEmptyRoom();
	SFPlayer* pPlayer = pLobbyState->GetOwner();

	if(NULL == pRoom)
		return FALSE;

	SFASSERT(pRoom->GetRoomState() == ROOM_STATE_NONE);

	pRoom->Open(pPlayer);
	pRoom->ChangeState(ROOM_STATE_WAIT);
	pPlayer->SetRoomIndex(pRoom->GetRoomIndex());

	_GameModeInfo* pInfo = pRoom->GetGameModeInfo();
	pInfo->SetGameMode(GameMode);

	m_ActiveRoomMap.insert(std::make_pair(pRoom->GetRoomIndex(), pRoom));

	return TRUE;
}