Exemplo n.º 1
0
void CGameLobbyManager::DoPendingDeleteSession(CGameLobby *pLobby)
{
	CryLog("CGameLobbyManager::DoPendingDeleteSession() pLobby:%p", pLobby);

	if(pLobby == m_primaryLobby)
	{
		if(m_nextLobby)
		{
			CRY_ASSERT(m_primaryLobby && m_nextLobby);

			SAFE_DELETE(m_primaryLobby);
			m_primaryLobby = m_nextLobby;
			m_nextLobby = NULL;

			m_primaryLobby->SwitchToPrimaryLobby();

			SetPrivateGame(m_primaryLobby, m_primaryLobby->IsPrivateGame());

			CryLog("CGameLobbyManager::DoPendingDeleteSession - Moved to next session");
		}
		else
		{
			CryLog("CGameLobbyManager::DoPendingDeleteSession - No sessions left");
#ifdef USE_C2_FRONTEND
			CFlashFrontEnd *pFlashMenu = g_pGame->GetFlashMenu();
			if (pFlashMenu)
			{
				// Have to go all the way back to main then forward to play_online because the stack may
				// not include play_online (destroyed when we do a level rotation)
				if (IsMultiplayer() && pFlashMenu->IsScreenInStack("game_lobby"))
				{
					if (CMPMenuHub *pMPMenu = CMPMenuHub::GetMPMenuHub())
					{
						pMPMenu->GoToCurrentLobbyServiceScreen(); // go to correct lobby service screen - play_online or play_lan
					}
				}
			}
#endif //#ifdef USE_C2_FRONTEND
			CSquadManager *pSquadManager = g_pGame->GetSquadManager();
			if (pSquadManager)
			{
				pSquadManager->GameSessionIdChanged(CSquadManager::eGSC_LeftSession, CrySessionInvalidID);
			}

			SetPrivateGame(NULL, false);
		}
	}
	else if(pLobby == m_nextLobby)
	{
		CryLog("CGameLobbyManager::DoPendingDeleteSession - Next Lobby deleted");
		SAFE_DELETE(m_nextLobby);
	}

	m_bMergingIsComplete = false;
}
void CGameLobbyManager::DoPendingDeleteSession(CGameLobby *pLobby)
{
	CryLog("CGameLobbyManager::DoPendingDeleteSession() pLobby:%p", pLobby);

	if(pLobby == m_primaryLobby)
	{
		if(m_nextLobby)
		{
			CRY_ASSERT(m_primaryLobby && m_nextLobby);

			SAFE_DELETE(m_primaryLobby);
			m_primaryLobby = m_nextLobby;
			m_nextLobby = NULL;

			m_primaryLobby->SwitchToPrimaryLobby();

			SetPrivateGame(m_primaryLobby, m_primaryLobby->IsPrivateGame());

			CryLog("CGameLobbyManager::DoPendingDeleteSession - Moved to next session");
		}
		else
		{
			CryLog("CGameLobbyManager::DoPendingDeleteSession - No sessions left");















			CSquadManager *pSquadManager = g_pGame->GetSquadManager();
			if (pSquadManager)
			{
				pSquadManager->GameSessionIdChanged(CSquadManager::eGSC_LeftSession, CrySessionInvalidID);
			}

			SetPrivateGame(NULL, false);
		}
	}
	else if(pLobby == m_nextLobby)
	{
		CryLog("CGameLobbyManager::DoPendingDeleteSession - Next Lobby deleted");
		SAFE_DELETE(m_nextLobby);
	}

	m_bMergingIsComplete = false;
}
Exemplo n.º 3
0
void CUILobbyMP::SetMultiplayer( bool bIsMultiplayer )
{
	CGameLobbyManager *pGameLobbyMgr = g_pGame->GetGameLobbyManager();
	CSquadManager *pSquadMgr = g_pGame->GetSquadManager();

	if(pGameLobbyMgr)
	{
		pGameLobbyMgr->SetMultiplayer(bIsMultiplayer);
	}

	if(pSquadMgr)
	{
		pSquadMgr->SetMultiplayer(bIsMultiplayer);
	}

	gEnv->bMultiplayer = bIsMultiplayer;
}
Exemplo n.º 4
0
void CUILobbyMP::JoinGame(int sessionID)
{
	bool result = false;

	CGameLobby *pGameLobby = g_pGame->GetGameLobby();
	CGameLobbyManager *pGameLobbyMgr = g_pGame->GetGameLobbyManager();
	CSquadManager *pSquadMgr = g_pGame->GetSquadManager();

	if(pGameLobbyMgr)
	{
		pGameLobbyMgr->SetMultiplayer(true);
	}

	if(pSquadMgr)
	{
		pSquadMgr->SetMultiplayer(true);
	}

	if(pGameLobby && m_FoundServers.size() > sessionID)
		result = pGameLobby->JoinServer(m_FoundServers[sessionID].m_id, m_FoundServers[sessionID].m_data.m_name, CryMatchMakingInvalidConnectionUID, false);
	return;
}
Exemplo n.º 5
0
//-------------------------------------------------------------------------
void CGameLobbyManager::LeaveGameSession(ELeavingSessionReason reason)
{
	CryLog("CGameLobbyManager::LeaveGameSession() reason=%i multiplayer %d", (int) reason, gEnv->bMultiplayer);
	// Tell the game lobby that we want to quit
	// Note: If we're leaving in a group (because the squad is quitting) then we need to do special behaviour:
	//					If we're the squad session host then we need to tell the rest of the squad to quit
	//					If we're the game session host then the rest of the squad has to quit before we do

	if(gEnv->bMultiplayer || reason == eLSR_SwitchGameType)
	{
		if (IsLobbyMerging())
		{
			CancelMoveSession(m_primaryLobby);
		}

		bool canLeaveNow = true;
		CSquadManager *pSquadManager = g_pGame->GetSquadManager();

		ELobbyState lobbyState = m_primaryLobby->GetState();
		if (lobbyState != eLS_Game)
		{
			// If we're in a squad and we're the game session host then we need to be careful about leaving
			if (pSquadManager != NULL && pSquadManager->HaveSquadMates())
			{
				if (reason == eLSR_Menu)
				{
					// User requested quit
					//	- If we're not the squad session host then we're the only person leaving so we can do it straight away
					//	- If we're not the game session host then there are no ordering issues so again, we can just leave
					if (pSquadManager->InCharge())
					{
						if (m_primaryLobby->IsServer())
						{
							CryLog("  we're trying to leave but we're the squad and game host, need to leave last");
							pSquadManager->TellMembersToLeaveGameSession();
							canLeaveNow = false;
						}
						else
						{
							CryLog("  we're not the game host, can leave now");
							pSquadManager->TellMembersToLeaveGameSession();
						}
					}
				}
				else if (reason == eLSR_ReceivedSquadLeavingFromSquadHost)
				{
					// Squad leader requested quit
					if (m_primaryLobby->IsServer())
					{
						canLeaveNow = false;
					}
				}
				else if (reason == eLSR_ReceivedSquadLeavingFromGameHost)
				{
					pSquadManager->TellMembersToLeaveGameSession();
				}
			}
		}
		else
		{
			CryLog("  leaving a game that is not in the lobby state, tell the squad manager");
			pSquadManager->LeftGameSessionInProgress();
		}

		if (canLeaveNow)
		{
			m_primaryLobby->LeaveSession(true);
		}
		else
		{
			m_primaryLobby->LeaveAfterSquadMembers();
		}
	}
}