Example #1
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;
}
Example #2
0
BOOL SFRoomManager::SendRoomPage( SFPlayerLobby* pLobbyState, int PageIndex /*= 0*/ )
{
	SFPlayer* pOwner = pLobbyState->GetOwner();
	int roomCnt = m_ActiveRoomMap.size();

	//if(roomCnt == 0)
		//return TRUE;

	SFProtobufPacket<SFPacketStore::RoomList> roomList = SFProtobufPacket<SFPacketStore::RoomList>(CGSF::RoomList);
	roomList.SetOwnerSerial(pOwner->GetSerial());

	if(m_ActiveRoomMap.size() <= MAX_ROOM_COUNT_PER_PAGE)
	{
		ActiveRoomMap::iterator iter = m_ActiveRoomMap.begin();

		for(;iter != m_ActiveRoomMap.end(); iter++)
		{
			SFPacketStore::RoomList::RoomInfo* pRoomInfo = roomList.GetData().add_info();
			SFRoom* pRoom = iter->second;

			pRoomInfo->set_roomindex(pRoom->GetRoomIndex());

			std::string roomName = "GameRoom";
			roomName += std::to_string(pRoom->GetRoomIndex());

			pRoomInfo->set_roomname(roomName);

			pRoomInfo->set_roomchief(pRoom->GetRoomChief()->GetPlayerName());
			pRoomInfo->set_usercount(pRoom->GetRoomMemberMap().size());
			pRoomInfo->set_maxusercount(4);
			pRoomInfo->set_needpassword(0);
			pRoomInfo->set_gamemode(pRoom->GetGameModeInfo()->GameMode);
		}
	}

	SFLogicEntry::GetLogicEntry()->SendRequest(&roomList);

	return TRUE;
}