コード例 #1
0
ファイル: UILobbyMP.cpp プロジェクト: kitnet/crynegine
void CUILobbyMP::WriteLeaderBoard()
{

	ICryLobby *Lobby = gEnv->pNetwork->GetLobby();
	CGameLobby* pGameLobby = g_pGame->GetGameLobby();
	ICryLobbyService *Service = (Lobby) ? Lobby->GetLobbyService() : NULL;
	ICryStats *Stats = (Service != NULL) ? Service->GetStats() : NULL;


	unsigned int user = g_pGame->GetPlayerProfileManager()->GetExclusiveControllerDeviceIndex();
	CryUserID userID = Service->GetUserID(user);
	ECryLobbyError Error;
	
	SCryStatsLeaderBoardWrite leaderboard;
	leaderboard.id = 0;
	leaderboard.data.numColumns = 0;
	leaderboard.data.pColumns = NULL;
	leaderboard.data.score.score = 311;
	leaderboard.data.score.id = 0;










	Error = Stats->StatsWriteLeaderBoards(pGameLobby->GetCurrentSessionHandle(), user, &leaderboard, 1, NULL, CUILobbyMP::WriteLeaderboardCallback, this);

}
コード例 #2
0
ECryLobbyError CGameLobbyManager::DoUserSignOut()
{
	CryLog("CGameLobbyManager::DoUserSignOut");
	ECryLobbyError error = eCLE_Success;

	if(m_signOutTaskID == CryLobbyInvalidTaskID)
	{
		ICryLobby *pLobby = FakeGetLobby();
		ICryLobbyService *pLobbyService = pLobby ? pLobby->GetLobbyService() : NULL;

		if(pLobbyService)
		{
			ICrySignIn* pSignIn = pLobbyService->GetSignIn();

			if ( pSignIn )
			{
//				error = pSignIn->SignOutUser( g_pGame->GetExclusiveControllerDeviceIndex(), &m_signOutTaskID, UserSignoutCallback, this );

				if(error == eCLE_Success)
				{
					// Notify UI? michiel
				}
			}
		}
	}
	else
	{
		CryLog("  not starting signout task as we already have one in progress");
	}

	return error;
}
コード例 #3
0
ファイル: GameBrowser.cpp プロジェクト: Aytunes/Tanks
//-------------------------------------------------------------------------
ECryLobbyError CGameBrowser::StartSearchingForServers(SCrySessionSearchParam* param, CryMatchmakingSessionSearchCallback cb, void* cbArg, const bool bFavouriteIdSearch)
{
	m_bFavouriteIdSearch = bFavouriteIdSearch;
	m_delayedSearchType = eDST_None;
	m_lastSearchTime = gEnv->pTimer->GetCurrTime(); 

#if defined(USE_SESSION_SEARCH_SIMULATOR)	
	if( m_pSessionSearchSimulator && gEnv->pConsole->GetCVar( "gl_searchSimulatorEnabled" )->GetIVal() )
	{
		const char* filepath = gEnv->pConsole->GetCVar( "gl_searchSimulatorFilepath" )->GetString();
		if( filepath != NULL && strcmpi( filepath, m_pSessionSearchSimulator->GetCurrentFilepath() ) != 0  )
		{
			m_pSessionSearchSimulator->OpenSessionListXML( filepath );
		}

		m_pSessionSearchSimulator->OutputSessionListBlock( m_searchingTask, cb, cbArg );
		return eCLE_Success;
	}
	else
#endif //defined(USE_SESSION_SEARCH_SIMULATOR)
	{
		ECryLobbyError error = eCLE_ServiceNotSupported;
		ICryLobby *lobby = gEnv->pNetwork->GetLobby();
		IPlayerProfileManager *pPlayerProfileManager = gEnv->pGame->GetIGameFramework()->GetIPlayerProfileManager();
		uint32 userIndex = pPlayerProfileManager ? pPlayerProfileManager->GetExclusiveControllerDeviceIndex() : 0;
		if(lobby)
		{
			CryLobbyTaskID previousTask = m_searchingTask;
			error = lobby->GetLobbyService()->GetMatchMaking()->SessionSearch(userIndex, param, &m_searchingTask, cb, cbArg);
			CryLog("CGameBrowser::StartSearchingForServers previousTask=%u, newTask=%u", previousTask, m_searchingTask);
		}
		return error;
	}
}
コード例 #4
0
ファイル: UILobbyMP.cpp プロジェクト: kitnet/crynegine
void CUILobbyMP::ReadLeaderBoard()
{
	ICryLobby *Lobby = gEnv->pNetwork->GetLobby();
	ICryLobbyService *Service = (Lobby) ? Lobby->GetLobbyService() : NULL;
	ICryStats *Stats = (Service != NULL) ? Service->GetStats() : NULL;




	const CryStatsLeaderBoardID id = 0;


	unsigned int user = g_pGame->GetPlayerProfileManager()->GetExclusiveControllerDeviceIndex();
	CryUserID userID = Service->GetUserID(user);


	ECryLobbyError Error;

	// Fetch local users score
	if(Stats)
	{
		Error = Stats->StatsReadLeaderBoardByUserID(id, &userID, 1, NULL, CUILobbyMP::ReadLeaderBoardCB, NULL);
	}

	//Fetch top 10 list
	//Error = Stats->StatsReadLeaderBoardByRankForRange(id, 1, 10, NULL, CUILobbyMP::ReadLeaderBoardCB, NULL);

}
コード例 #5
0
ファイル: AntiCheatManager.cpp プロジェクト: aronarts/FireNET
void CAntiCheatManager::HandleDelayedKicks(float dt)
{
	for(int i = m_DelayedKickData.size() - 1; i >= 0; i--)
	{
		SDelayedKickData& rKickData = m_DelayedKickData[i];
		const float fTimeUntilKick = rKickData.fKickCountdown - dt;
		if(fTimeUntilKick <= 0.0f)
		{
			ICryLobby *pLobby = gEnv->pNetwork->GetLobby();
			if (pLobby)
			{
				ICryMatchMaking *pMatchmaking = pLobby->GetMatchMaking();
				if (pMatchmaking)
				{
					pMatchmaking->Kick(&rKickData.userId, rKickData.reason);
				}
			}

			m_DelayedKickData[i] = m_DelayedKickData[m_DelayedKickData.size()-1];
			m_DelayedKickData.pop_back();
		}
		else
		{
			rKickData.fKickCountdown = fTimeUntilKick;
		}
	}
}
コード例 #6
0
	ECryLobbyError SendToAll( CCryLobbyPacket* pPacket, CrySessionHandle h, SSessionNames &clients, bool bCheckConnectionState )
	{
		ECryLobbyError result = eCLE_Success;

		ICryLobby *pLobby = gEnv->pNetwork->GetLobby();
		if (pLobby)
		{
			ICryMatchMaking *pMatchMaking = pLobby->GetMatchMaking();
			if (pMatchMaking)
			{
				const unsigned int numClients = clients.m_sessionNames.size();
				// Start from 1 since we don't want to send to ourselves (unless we're a dedicated server)
				const int startIndex = gEnv->IsDedicated() ? 0 : 1;
				for (unsigned int i = startIndex; (i < numClients) && (result == eCLE_Success); ++ i)
				{
					SSessionNames::SSessionName &client = clients.m_sessionNames[i];

					if (!bCheckConnectionState || client.m_bFullyConnected)
					{
						result = pMatchMaking->SendToClient(pPacket, h, client.m_conId);
					}
				}
			}
		}

		return result;
	}
コード例 #7
0
CGameLobbyManager::CGameLobbyManager() : REGISTER_GAME_MECHANISM(CGameLobbyManager)
{
	m_primaryLobby = new CGameLobby(this);
	m_nextLobby = NULL;

	for (int i=0; i<MAX_LOCAL_USERS; ++i)
	{
		m_onlineState[i] = eOS_SignedOut;
	}

	m_multiplayer = false;
	
	m_pendingPrimarySessionDelete = false;
	m_pendingNextSessionDelete = false;
	
	m_isCableConnected = true;
	m_isChatRestricted = false;
	m_bMergingIsComplete = false;

	m_signOutTaskID= CryLobbyInvalidTaskID;

	m_pMatchMakingHandler = new CMatchMakingHandler();

	ICryLobby *pLobby = FakeGetLobby();
	if(pLobby)
	{
		pLobby->RegisterEventInterest(eCLSE_OnlineState, CGameLobbyManager::OnlineCallback, this);
		pLobby->RegisterEventInterest(eCLSE_EthernetState, CGameLobbyManager::EthernetStateCallback, this);
		pLobby->RegisterEventInterest(eCLSE_ChatRestricted, CGameLobbyManager::ChatRestrictedCallback, this);
	}
}
コード例 #8
0
CGameLobbyManager::~CGameLobbyManager()
{
	ICryLobby *pLobby = gEnv->pNetwork->GetLobby();
	pLobby->UnregisterEventInterest(eCLSE_OnlineState, CGameLobbyManager::OnlineCallback, this);
	pLobby->UnregisterEventInterest(eCLSE_EthernetState, CGameLobbyManager::EthernetStateCallback, this);
	pLobby->UnregisterEventInterest(eCLSE_ChatRestricted, CGameLobbyManager::ChatRestrictedCallback, this);

	SAFE_DELETE(m_primaryLobby);
	SAFE_DELETE(m_nextLobby);
	SAFE_DELETE(m_pMatchMakingHandler);
}
コード例 #9
0
ファイル: AntiCheatManager.cpp プロジェクト: aronarts/FireNET
void CAntiCheatManager::KickPlayer(const CryUserID& userId, EDisconnectionCause reason, int nConfidence)
{
	if (userId.IsValid())
	{
		ICryLobby *pLobby = gEnv->pNetwork->GetLobby();
		if (pLobby)
		{
			ICryMatchMaking *pMatchmaking = pLobby->GetMatchMaking();
			if (pMatchmaking)
			{
				pMatchmaking->Kick(&userId, reason);
			}
		}
	}
}
コード例 #10
0
ファイル: GameBrowser.cpp プロジェクト: Aytunes/Tanks
//-------------------------------------------------------------------------
void CGameBrowser::CancelSearching(bool feedback /*= true*/)
{
	CryLogAlways("CGameBrowser::CancelSearching");

	if (m_searchingTask != CryLobbyInvalidTaskID)
	{
		CryLog("  canceling search task %u", m_searchingTask);
		ICryLobby *pLobby = gEnv->pNetwork->GetLobby();
		pLobby->GetMatchMaking()->CancelTask(m_searchingTask);
		// Calling FinishedSearch will clear m_searchingTask
	}

	m_delayedSearchType = eDST_None;

	FinishedSearch(feedback, true);
}
コード例 #11
0
	virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
	{
		switch (event)
		{
		case eFE_Initialize:
			{
			}
			break;
		case eFE_Activate:
#if CRY_PLATFORM_DURANGO

			if(IsPortActive(pActInfo, EIP_Poll))
			{

				size_t memberCountParty = Live::State::Party::Instance().GetPartyMembers()->size();

				CryLogAlways("Partymembers: %d", memberCountParty);

				static MatchmakingUtils::INetworkingUser_impl s_networkingUser;

				ICryLobby *pLobby = gEnv->pNetwork->GetLobby();
				if (pLobby)
				{
					ICryMatchMaking *pMatchmaking = pLobby->GetMatchMaking();
					if (pMatchmaking)
					{
						pMatchmaking->SetINetworkingUser(&s_networkingUser);
					}
				}	

				HRESULT hr = MatchmakingUtils::InitiateSession( "PlayerSkillAutoEval", "", 0);
			}


			if(IsPortActive(pActInfo, EIP_Launch))
			{
				MatchmakingUtils::SetLaunching();
			}

			if(IsPortActive(pActInfo, EIP_Leave))
			{
				MatchmakingUtils::QuitMatchmaking();
			}
#endif
			break;
		}
	}
コード例 #12
0
ファイル: AntiCheatManager.cpp プロジェクト: aronarts/FireNET
void CAntiCheatManager::BanPlayer_Internal(uint16 channelId, float timeout, int nConfidence)
{
	CGameLobby* pGameLobby = g_pGame->GetGameLobby();
	if (pGameLobby)
	{
		CryUserID userId = pGameLobby->GetUserIDFromChannelID(channelId);
		if (userId.IsValid())
		{
			ICryLobby *pLobby = gEnv->pNetwork->GetLobby();
			if (pLobby)
			{
				ICryMatchMaking *pMatchmaking = pLobby->GetMatchMaking();
				if (pMatchmaking)
				{
					pMatchmaking->Ban(&userId, timeout);
				}
			}
		}
	}
}
コード例 #13
0
ファイル: UILobbyMP.cpp プロジェクト: kitnet/crynegine
void CUILobbyMP::AwardTrophy(int trophy)
{
	ICryLobby* pLobby = gEnv->pNetwork->GetLobby();
	unsigned int user = g_pGame->GetPlayerProfileManager()->GetExclusiveControllerDeviceIndex();
	if(user != IPlatformOS::Unknown_User)
	{
		uint32 achievementId = trophy;

		//-- Award() only puts awards into a queue to be awarded.
		//-- This code here only asserts that the award was added to the queue successfully, not if the award was successfully unlocked.
		//-- Function has been modified for a CryLobbyTaskId, callback and callback args parameters, similar to most other lobby functions,
		//-- to allow for callback to trigger when the award is successfully unlocked (eCLE_Success) or failed to unlock (eCLE_InternalError).
		//-- In the case of trying to unlock an award that has already been unlocked, the callback will return eCLE_Success.
		//-- Successful return value of the Award function has been changed from incorrect eCRE_Awarded to more sensible eCRE_Queued.
		if(pLobby && pLobby->GetReward())
		{
			ECryRewardError error = pLobby->GetReward()->Award(user, achievementId, NULL, NULL, NULL);
		}
	}

}
コード例 #14
0
void CGameAchievements::GiveAchievement(int achievement)
{
	if(AllowAchievement())
	{
		CPersistantStats::GetInstance()->OnGiveAchievement(achievement);

		ICryLobby* pLobby = gEnv->pNetwork->GetLobby();
		IPlatformOS* pOS = gEnv->pSystem->GetPlatformOS();
		if(pLobby != NULL && pOS != NULL)
		{
			ICryReward* pReward = pLobby->GetReward();
			if(pReward)
			{
				unsigned int user = g_pGame->GetExclusiveControllerDeviceIndex();
				if(user != IPlatformOS::Unknown_User)
				{
					uint32 achievementId = achievement + ACHIEVEMENT_STARTINDEX;

					//-- Award() only puts awards into a queue to be awarded.
					//-- This code here only asserts that the award was added to the queue successfully, not if the award was successfully unlocked.
					//-- Function has been modified for a CryLobbyTaskId, callback and callback args parameters, similar to most other lobby functions,
					//-- to allow for callback to trigger when the award is successfully unlocked (eCLE_Success) or failed to unlock (eCLE_InternalError).
					//-- In the case of trying to unlock an award that has already been unlocked, the callback will return eCLE_Success.
					//-- Successful return value of the Award function has been changed from incorrect eCRE_Awarded to more sensible eCRE_Queued.
					CRY_TODO(3,9,2010, "Register a callback to inform game when queued award is processed successfully or failed.");

					ECryRewardError error = pReward->Award(user, achievementId, NULL, NULL, NULL);
					CryLog("Award error %d", error);
					CRY_ASSERT(error == eCRE_Queued);
				}
			}
		}
	}
	else
	{
		CryLog("Not Awarding achievement - have been disabled");
	}
}
コード例 #15
0
ファイル: GameAchievements.cpp プロジェクト: Aytunes/Tanks
void CGameAchievements::GiveAchievement(ECryGameSDKAchievement achievement)
{
	if(AllowAchievement())
	{
		assert(achievement >= 0 && achievement < eA_NumAchievements);

#ifdef GAME_IS_CRYSIS2
		CPersistantStats::GetInstance()->OnGiveAchievement(achievement);
#endif

		ICryLobby* pLobby = gEnv->pNetwork->GetLobby();
		IPlatformOS* pOS = gEnv->pSystem->GetPlatformOS();
		if(pLobby != NULL && pOS != NULL)
		{
			ICryReward* pReward = pLobby->GetReward();
			if(pReward)
			{
				unsigned int user = 0;
#ifdef GAME_IS_CRYSIS2
				unsigned int user = g_pGame->GetExclusiveControllerDeviceIndex();
#endif
				if(user != IPlatformOS::Unknown_User)
				{
					uint32 achievementId = achievement + ACHIEVEMENT_STARTINDEX;

					ECryRewardError error = pReward->Award(user, achievementId, NULL, NULL, NULL);
					CryLog("Award error %d", error);
					CRY_ASSERT(error == eCRE_Queued);
				}
			}
		}
	}
	else
	{
		CryLog("Not Awarding achievement - have been disabled");
	}
}
コード例 #16
0
ファイル: UILobbyMP.cpp プロジェクト: kitnet/crynegine
void CUILobbyMP::RegisterLeaderBoard()
{
	ICryLobby *Lobby = gEnv->pNetwork->GetLobby();
	ICryLobbyService *Service = (Lobby) ? Lobby->GetLobbyService() : NULL;
	ICryStats *pStats = (Service != NULL) ? Service->GetStats() : NULL;
	ECryLobbyError Error;

	// Really basic leaderboard
	SCryStatsLeaderBoardWrite leaderboards;



	leaderboards.id = 0;

	leaderboards.data.score.id = 0;
	leaderboards.data.score.score = 0;
	leaderboards.data.numColumns = 0;
	leaderboards.data.pColumns = NULL;

	if(pStats)
	{
		Error = pStats->StatsRegisterLeaderBoards(&leaderboards, 1, NULL, CUILobbyMP::RegisterLeaderboardCB, NULL);
	}
}
コード例 #17
0
ファイル: GameLobbyManager.cpp プロジェクト: AiYong/CryGame
ECryLobbyError CGameLobbyManager::DoUserSignOut()
{
	CryLog("CGameLobbyManager::DoUserSignOut");
	ECryLobbyError error = eCLE_Success;

	if(m_signOutTaskID == CryLobbyInvalidTaskID)
	{
		ICryLobby *pLobby = gEnv->pNetwork->GetLobby();
		ICryLobbyService *pLobbyService = pLobby ? pLobby->GetLobbyService() : NULL;

		if(pLobbyService)
		{
#ifdef GAME_IS_CRYSIS2
			error = pLobbyService->UserSignOut(g_pGame->GetExclusiveControllerDeviceIndex(), &m_signOutTaskID, UserSignoutCallback, this);
#endif
		}
	}
	else
	{
		CryLog("  not starting signout task as we already have one in progress");
	}

	return error;
}
コード例 #18
0
ファイル: RichPresence.cpp プロジェクト: aronarts/FireNET
bool CRichPresence::SetRichPresence(ERichPresenceState state)
{
	// don't set rich presence if we don't have a controller yet
	if(!g_pGame->HasExclusiveControllerIndex())
	{
		CryLog("[Rich Presence] not setting rich presence, no player set");
		return true;
	}

	CrySessionID sessionID = CrySessionInvalidID;

	if((m_currentState == state) && GameNetworkUtils::CompareCrySessionId(sessionID, m_currentSessionID))
	{
		if(state != eRPS_InGame || !gEnv->bMultiplayer)
		{
			CryLog("[Rich Presence] not setting rich presence state %d multiplayer %d", state, gEnv->bMultiplayer);
			return true;
		}
	}

	// we are already setting rich presence, so wait until that task has finished
	if (m_taskID != CryLobbyInvalidTaskID)
	{
		CryLog("  already setting rich presence, setting desired state to %d", state);
		m_desiredState = state;
		return false;
	}

	ICryLobby *pLobby = gEnv->pNetwork->GetLobby();
	ICryLobbyService *pLobbyService = pLobby ? pLobby->GetLobbyService(eCLS_Online) : NULL;
	ICryLobbyUI *pLobbyUI = pLobbyService ? pLobbyService->GetLobbyUI() : NULL;
	ECryLobbyError error = eCLE_Success;

	m_pendingSessionID = sessionID;

	if(pLobbyUI)
	{
		uint32 userIndex = g_pGame->GetExclusiveControllerDeviceIndex();
		
		CryLog("[Rich Presence] SetRichPresence %d userIndex %d", state, userIndex);

		switch(state)
		{
			case eRPS_Idle:
			{
				SCryLobbyUserData data;

				data.m_id = RICHPRESENCE_ID;
				data.m_type = eCLUDT_Int32;
				data.m_int32 = RICHPRESENCE_IDLE;
				
				error = pLobbyUI->SetRichPresence(userIndex, &data, 1, &m_taskID, CRichPresence::SetRichPresenceCallback, this);
				break;
			}

			case eRPS_FrontEnd:
			{
				SCryLobbyUserData data;

				data.m_id = RICHPRESENCE_ID;
				data.m_type = eCLUDT_Int32;
				data.m_int32 = RICHPRESENCE_FRONTEND;

				error = pLobbyUI->SetRichPresence(userIndex, &data, 1, &m_taskID, CRichPresence::SetRichPresenceCallback, this);
				break;
			}

			case eRPS_Lobby:
			{
				SCryLobbyUserData data;

				data.m_id = RICHPRESENCE_ID;
				data.m_type = eCLUDT_Int32;
				data.m_int32 = RICHPRESENCE_LOBBY;

				error = pLobbyUI->SetRichPresence(userIndex, &data, 1, &m_taskID, CRichPresence::SetRichPresenceCallback, this);
				break;
			}

			case eRPS_InGame:
			{
				if(gEnv->bMultiplayer)
				{
					CGameRules *pGameRules = g_pGame->GetGameRules();
					IGameFramework *pGameFramework = g_pGame->GetIGameFramework();
					const char *levelName = pGameFramework ? pGameFramework->GetLevelName() : NULL;
					const char *gameRulesName = pGameRules ? pGameRules->GetEntity()->GetClass()->GetName() : NULL;
					int32 gameMode = 0;
					int32 map = 0;

					if(levelName)
					{
						levelName = PathUtil::GetFileName(levelName);
						TRichPresenceMap::const_iterator iter = m_richPresence.find(levelName);
						map = (iter == m_richPresence.end()) ? 0 : iter->second;
					}

					if(gameRulesName)
					{
						TRichPresenceMap::const_iterator iter = m_richPresence.find(gameRulesName);
						gameMode = (iter == m_richPresence.end()) ? 0 : iter->second;
					}

					SCryLobbyUserData data[eRPT_Max];
					
					data[eRPT_String].m_id = RICHPRESENCE_ID;
					data[eRPT_String].m_type = eCLUDT_Int32;
					data[eRPT_String].m_int32 = RICHPRESENCE_GAMEPLAY;
					
					data[eRPT_Param1].m_id = RICHPRESENCE_GAMEMODES;
					data[eRPT_Param1].m_type = eCLUDT_Int32;
					data[eRPT_Param1].m_int32 = gameMode;
					
					data[eRPT_Param2].m_id = RICHPRESENCE_MAPS;
					data[eRPT_Param2].m_type = eCLUDT_Int32;
					data[eRPT_Param2].m_int32 = map;

					error = pLobbyUI->SetRichPresence(userIndex, data, 3, &m_taskID, CRichPresence::SetRichPresenceCallback, this);
				}
				else
				{
					SCryLobbyUserData data;

					data.m_id = RICHPRESENCE_ID;
					data.m_type = eCLUDT_Int32;
					data.m_int32 = RICHPRESENCE_SINGLEPLAYER;
					
					error = pLobbyUI->SetRichPresence(userIndex, &data, 1, &m_taskID, CRichPresence::SetRichPresenceCallback, this);
				}
				break;
			}

			default:
				CryLog("[RichPresence] SetRichPresence - unknown rich presence %d", state);
				break;
		}

		if(error != eCLE_Success)
		{
			// failed to set rich presence, possibly because of too many lobby tasks, store it and try again later
			m_desiredState = state;
			m_pendingSessionID = CrySessionInvalidID;
			
			CryLog("[Rich Presence] SetRichPresence - Rich presence %s with error code %d", error == eCLE_Success ? "succeeded" : "failed", error);
		}
		else
		{
			m_pendingState = state;
			m_desiredState = eRPS_None;

			CryLog("[Rich Presence] SetRichPresence - Rich presence has been successfully started");
		}
	}
#if !defined(_RELEASE)
	else
	{
		error = eCLE_InternalError;
		CryLog("[Rich Presence] SetRichPresence called but we have no lobby, tried to set state to %d", state);
	}
#endif

	return (error == eCLE_Success);
}
コード例 #19
0
ファイル: GameLobbyManager.cpp プロジェクト: AiYong/CryGame
//Handles online state changes - when you sign out it returns you
void CGameLobbyManager::OnlineCallback(UCryLobbyEventData eventData, void *arg)
{
	if (g_pGameCVars->g_ProcessOnlineCallbacks == 0)
		return;

	if(eventData.pOnlineStateData)
	{
		CGameLobbyManager *pLobbyManager = static_cast<CGameLobbyManager*>(arg);
		CRY_ASSERT(eventData.pOnlineStateData->m_user < MAX_LOCAL_USERS);
		pLobbyManager->m_onlineState[eventData.pOnlineStateData->m_user] = eventData.pOnlineStateData->m_curState;

		IPlayerProfileManager *pPlayerProfileManager = gEnv->pGame->GetIGameFramework()->GetIPlayerProfileManager();
		uint32 userIndex = pPlayerProfileManager ? pPlayerProfileManager->GetExclusiveControllerDeviceIndex() : 0;

#ifndef _RELEASE
		const char *pEventType = "eOS_Unknown";
		if (eventData.pOnlineStateData->m_curState == eOS_SignedOut)
		{
			pEventType = "eOS_SignedOut";
		}
		else if (eventData.pOnlineStateData->m_curState == eOS_SigningIn)
		{
			pEventType = "eOS_SigningIn";
		}
		else if (eventData.pOnlineStateData->m_curState == eOS_SignedIn)
		{
			pEventType = "eOS_SignedIn";
		}
		CryLog("[GameLobbyManager] OnlineCallback: eventType=%s, user=%u, currentUser=%u", pEventType, eventData.pOnlineStateData->m_user, userIndex);

		ICryLobby *pLobby = gEnv->pNetwork->GetLobby();
		if (g_pGameCVars->autotest_enabled && pLobby != NULL && (pLobby->GetLobbyServiceType() == eCLS_LAN))
		{
			// Don't care about signing out if we're in the autotester and in LAN mode
			return;
		}
#endif




		{
			EOnlineState onlineState = eventData.pOnlineStateData->m_curState;
			if(onlineState == eOS_SignedOut)
			{
				if(eventData.pOnlineStateData->m_reason != eCLE_CyclingForInvite)
				{
#ifdef USE_C2_FRONTEND
					CFlashFrontEnd *pFlashFrontEnd = g_pGame->GetFlashMenu();
					CMPMenuHub *pMPMenuHub = pFlashFrontEnd ? pFlashFrontEnd->GetMPMenu() : NULL;

					if(pMPMenuHub)
					{
#if INCLUDE_DEDICATED_LEADERBOARDS
						pFlashFrontEnd->ClearDelaySessionLeave();
#endif
						pMPMenuHub->OnlineStateChanged(eventData.pOnlineStateData->m_curState, eventData.pOnlineStateData->m_reason, eventData.pOnlineStateData->m_serviceConnected);
					}
#endif //#ifdef USE_C2_FRONTEND

#if !defined(XENON) && !defined(PS3)
					IPlayerProfileManager *pPPM = gEnv->pGame->GetIGameFramework()->GetIPlayerProfileManager();
					if(pPPM)
					{
						pPPM->ClearOnlineAttributes();
					}
#endif

#ifdef GAME_IS_CRYSIS2
					CWarningsManager *pWM = g_pGame->GetWarnings();
					if(pWM)
					{
						pWM->RemoveWarning("ChatRestricted");
					}
#endif
				}

				pLobbyManager->LeaveGameSession(eLSR_SignedOut);
			}					
		}
	}
}
コード例 #20
0
ファイル: GameBrowser.cpp プロジェクト: hybridsix/Code
//-------------------------------------------------------------------------
void CGameBrowser::StartSearchingForServers(CryMatchmakingSessionSearchCallback cb)
{
	ICryLobby *lobby = gEnv->pNetwork->GetLobby();
	if (lobby != NULL && lobby->GetLobbyService())
	{
		CCCPOINT (GameLobby_StartSearchingForServers);

		if (CanStartSearch())
		{
			CryLog("[UI] Delayed Searching for sessions");
			m_delayedSearchType = eDST_Full;

			NOTIFY_UILOBBY_MP(SearchStarted());

			return;
		}

		SCrySessionSearchParam param;
		SCrySessionSearchData data[START_SEARCHING_FOR_SERVERS_NUM_DATA];

		param.m_type = REQUIRED_SESSIONS_QUERY;
		param.m_data = data;
#if defined(XENON) || defined(PS3)
		param.m_numFreeSlots = max(g_pGame->GetSquadManager()->GetSquadSize(), 1);
#else
		param.m_numFreeSlots = 0; 
#endif
		param.m_maxNumReturn = g_pGameCVars->g_maxGameBrowserResults;
		param.m_ranked = false;

		int curData = 0;

#if defined(XENON)
		data[curData].m_operator = eCSSO_Equal;
		data[curData].m_data.m_id = REQUIRED_SESSIONS_SEARCH_PARAM;
		data[curData].m_data.m_type = eCLUDT_Int32;
		data[curData].m_data.m_int32 = 0;
		++curData;
#endif

		CRY_ASSERT_MESSAGE( curData < START_SEARCHING_FOR_SERVERS_NUM_DATA, "Session search data buffer overrun" );
		data[curData].m_operator = eCSSO_Equal;
		data[curData].m_data.m_id = LID_MATCHDATA_VERSION;
		data[curData].m_data.m_type = eCLUDT_Int32;
		data[curData].m_data.m_int32 = GameLobbyData::GetVersion();
		++curData;


		// if you want to use this, make sure the search query in the SPA asks for this param as well
		if (!g_pGameCVars->g_ignoreDLCRequirements)
		{
			// Note: GetSquadCommonDLCs is actually a bit field, so it should really be doing a bitwise & to determine
			// if the client can join the server. However this is not supported so the less than equal operator
			// is used instead. This may return some false positives but never any false negatives, the false
			// positives will be filtered out when the results are retreived.
			CRY_ASSERT_MESSAGE( curData < START_SEARCHING_FOR_SERVERS_NUM_DATA, "Session search data buffer overrun" );
			data[curData].m_operator = eCSSO_LessThanEqual;
			data[curData].m_data.m_id = LID_MATCHDATA_REQUIRED_DLCS;
			data[curData].m_data.m_type = eCLUDT_Int32;
			data[curData].m_data.m_int32 = g_pGame->GetDLCManager()->GetSquadCommonDLCs();
			++curData;
		}

		param.m_numData = curData;

		CRY_ASSERT_MESSAGE(m_searchingTask==CryLobbyInvalidTaskID,"CGameBrowser Trying to search for sessions when you think you are already searching.");

		ECryLobbyError error = StartSearchingForServers(&param, cb, this, false);

		CRY_ASSERT_MESSAGE(error==eCLE_Success,"CGameBrowser searching for sessions failed.");

		if (error == eCLE_Success)
		{
			NOTIFY_UILOBBY_MP(SearchStarted());

			CryLogAlways("CCGameBrowser::StartSearchingForServers %d", m_searchingTask);
		}
		else
		{
			NOTIFY_UILOBBY_MP(SearchCompleted());

			m_searchingTask = CryLobbyInvalidTaskID;
		}
	}
	else
	{
		CRY_ASSERT_MESSAGE(0,"CGameBrowser Cannot search for servers : no lobby service available.");
	}
}
コード例 #21
0
ファイル: GameBrowser.cpp プロジェクト: Aytunes/Tanks
//-------------------------------------------------------------------------
bool CGameBrowser::DoFavouriteIdSearch()
{
	CryLog("[UI] DoFavouriteIdSearch");

	bool bResult = false;

#if USE_CRYLOBBY_GAMESPY
	const int k_maxNumData = START_SEARCHING_FOR_SERVERS_NUM_DATA + MAX_NUM_PER_FRIEND_ID_SEARCH;
	SCrySessionSearchParam param;
	SCrySessionSearchData data[k_maxNumData];

	param.m_type = REQUIRED_SESSIONS_QUERY;
	param.m_data = data;
	param.m_numFreeSlots = 0;
	param.m_maxNumReturn = MAX_NUM_PER_FRIEND_ID_SEARCH;
	param.m_ranked = false;

	int curData = 0;

	data[curData].m_operator = eCSSO_Equal;
	data[curData].m_data.m_id = LID_MATCHDATA_VERSION;
	data[curData].m_data.m_type = eCLUDT_Int32;
	data[curData].m_data.m_int32 = GameLobbyData::GetVersion();
	curData++;

	uint32 numAdded = 0;
#if IMPLEMENT_PC_BLADES
	for (; m_currentSearchFavouriteIdIndex<m_numSearchFavouriteIds && numAdded<MAX_NUM_PER_FRIEND_ID_SEARCH; ++m_currentSearchFavouriteIdIndex)
	{
		if (m_searchFavouriteIds[m_currentSearchFavouriteIdIndex] != INVALID_SESSION_FAVOURITE_ID)
		{
			CRY_ASSERT_MESSAGE( curData < k_maxNumData, "Session search data buffer overrun" );
			data[curData].m_operator = eCSSO_Equal;
			data[curData].m_data.m_id = LID_MATCHDATA_FAVOURITE_ID;
			data[curData].m_data.m_type = eCLUDT_Int32;
			data[curData].m_data.m_int32 = m_searchFavouriteIds[m_currentSearchFavouriteIdIndex];
			curData++;

			++numAdded;

			CryLog("[UI] Do favourite ID search for %d, on index %d of %d", m_searchFavouriteIds[m_currentSearchFavouriteIdIndex], m_currentSearchFavouriteIdIndex, m_numSearchFavouriteIds);
		}
	}
#endif

	param.m_numData = curData;

	if (numAdded > 0)
	{
		ICryLobby *pLobby = gEnv->pNetwork->GetLobby();
		if (pLobby)
		{
			if (pLobby->GetLobbyService())
			{
				CRY_ASSERT_MESSAGE(m_searchingTask==CryLobbyInvalidTaskID,"CGameBrowser Trying to search for sessions when you think you are already searching.");

				ECryLobbyError result = StartSearchingForServers(&param, CGameBrowser::MatchmakingSessionSearchCallback, this, true);

				CryLog("CCGameBrowser::DoFavouriteIdSearch result=%u, taskId=%u", result, m_searchingTask);
				if (result == eCLE_Success)
				{
					bResult = true;
				}
				else
				{
					m_searchingTask = CryLobbyInvalidTaskID;
				}
			}
		}
	}
#endif

	return bResult;
}
コード例 #22
0
ファイル: GameBrowser.cpp プロジェクト: Aytunes/Tanks
//-------------------------------------------------------------------------
void CGameBrowser::StartSearchingForServers(CryMatchmakingSessionSearchCallback cb)
{
	ICryLobby *lobby = gEnv->pNetwork->GetLobby();
	if (lobby != NULL && lobby->GetLobbyService())
	{
#ifdef GAME_IS_CRYSIS2
		CCCPOINT (GameLobby_StartSearchingForServers);
#endif

		if (CanStartSearch())
		{
			CryLog("[UI] Delayed Searching for sessions");
			m_delayedSearchType = eDST_Full;

#ifdef USE_C2_FRONTEND
			if (CMPMenuHub *pMPMenu = CMPMenuHub::GetMPMenuHub())
			{
				pMPMenu->StartSearching();
			}
#endif //#ifdef USE_C2_FRONTEND

			return;
		}

		SCrySessionSearchParam param;
		SCrySessionSearchData data[START_SEARCHING_FOR_SERVERS_NUM_DATA];

		param.m_type = REQUIRED_SESSIONS_QUERY;
		param.m_data = data;



		param.m_numFreeSlots = 0; 

		param.m_maxNumReturn = g_pGameCVars->g_maxGameBrowserResults;
		param.m_ranked = false;

		int curData = 0;









		CRY_ASSERT_MESSAGE( curData < START_SEARCHING_FOR_SERVERS_NUM_DATA, "Session search data buffer overrun" );
		data[curData].m_operator = eCSSO_Equal;
		data[curData].m_data.m_id = LID_MATCHDATA_VERSION;
		data[curData].m_data.m_type = eCLUDT_Int32;
		data[curData].m_data.m_int32 = GameLobbyData::GetVersion();
		curData++;

#ifdef GAME_IS_CRYSIS2
		if (!g_pGameCVars->g_ignoreDLCRequirements)
		{
			// Note: GetSquadCommonDLCs is actually a bit field, so it should really be doing a bitwise & to determine
			// if the client can join the server. However this is not supported so the less than equal operator
			// is used instead. This may return some false positives but never any false negatives, the false
			// positives will be filtered out when the results are retreived.
			CRY_ASSERT_MESSAGE( curData < START_SEARCHING_FOR_SERVERS_NUM_DATA, "Session search data buffer overrun" );
			data[curData].m_operator = eCSSO_LessThanEqual;
			data[curData].m_data.m_id = LID_MATCHDATA_REQUIRED_DLCS;
			data[curData].m_data.m_type = eCLUDT_Int32;
			data[curData].m_data.m_int32 = g_pGame->GetDLCManager()->GetSquadCommonDLCs();
			curData++;
		}
#endif

#if USE_CRYLOBBY_GAMESPY
		uint32	region = eSR_All;	// Game side support for region filtering needs to change this.

		if ( region != eSR_All )
		{
			CRY_ASSERT_MESSAGE( curData < START_SEARCHING_FOR_SERVERS_NUM_DATA, "Session search data buffer overrun" );
			data[curData].m_operator = eCSSO_BitwiseAndNotEqualZero;
			data[curData].m_data.m_id = LID_MATCHDATA_REGION;
			data[curData].m_data.m_type = eCLUDT_Int32;
			data[curData].m_data.m_int32 = region;
			curData++;
		}

		int32		favouriteID = 0;	// Game side support for favourite servers needs to change this.

		if ( favouriteID )
		{
			CRY_ASSERT_MESSAGE( curData < START_SEARCHING_FOR_SERVERS_NUM_DATA, "Session search data buffer overrun" );
			data[curData].m_operator = eCSSO_Equal;
			data[curData].m_data.m_id = LID_MATCHDATA_FAVOURITE_ID;
			data[curData].m_data.m_type = eCLUDT_Int32;
			data[curData].m_data.m_int32 = favouriteID;
			curData++;
		}

#endif

		param.m_numData = curData;

		CRY_ASSERT_MESSAGE(m_searchingTask==CryLobbyInvalidTaskID,"CGameBrowser Trying to search for sessions when you think you are already searching.");

		ECryLobbyError error = StartSearchingForServers(&param, cb, this, false);


		CRY_ASSERT_MESSAGE(error==eCLE_Success,"CGameBrowser searching for sessions failed.");

#ifdef USE_C2_FRONTEND
		CMPMenuHub *pMPMenu = CMPMenuHub::GetMPMenuHub();

		if (error == eCLE_Success)
		{
			if (pMPMenu)
			{
				pMPMenu->StartSearching();
			}

			CryLogAlways("CCGameBrowser::StartSearchingForServers %d", m_searchingTask);
		}
		else
		{
			if (pMPMenu)
			{
				pMPMenu->SearchComplete();
			}

			m_searchingTask = CryLobbyInvalidTaskID;
		}
#endif //#ifdef USE_C2_FRONTEND
	}
	else
	{
		CRY_ASSERT_MESSAGE(0,"CGameBrowser Cannot search for servers : no lobby service available.");
	}
}
コード例 #23
0
//Handles online state changes - when you sign out it returns you
void CGameLobbyManager::OnlineCallback(UCryLobbyEventData eventData, void *arg)
{
	if (g_pGameCVars->g_ProcessOnlineCallbacks == 0)
		return;

	if(eventData.pOnlineStateData)
	{
		CGameLobbyManager *pLobbyManager = static_cast<CGameLobbyManager*>(arg);

#if defined(DEDICATED_SERVER)
		EOnlineState previousState = pLobbyManager->m_onlineState[eventData.pOnlineStateData->m_user];
#endif

		CRY_ASSERT(eventData.pOnlineStateData->m_user < MAX_LOCAL_USERS);
		pLobbyManager->m_onlineState[eventData.pOnlineStateData->m_user] = eventData.pOnlineStateData->m_curState;

		uint32 userIndex = g_pGame->GetExclusiveControllerDeviceIndex();

		ICryLobby *pLobby = FakeGetLobby();

#ifndef _RELEASE
		const char *pEventType = "eOS_Unknown";
		if (eventData.pOnlineStateData->m_curState == eOS_SignedOut)
		{
			pEventType = "eOS_SignedOut";
		}
		else if (eventData.pOnlineStateData->m_curState == eOS_SigningIn)
		{
			pEventType = "eOS_SigningIn";
		}
		else if (eventData.pOnlineStateData->m_curState == eOS_SignedIn)
		{
			pEventType = "eOS_SignedIn";
		}
		CryLog("[GameLobbyManager] OnlineCallback: eventType=%s, user=%u, currentUser=%u", pEventType, eventData.pOnlineStateData->m_user, userIndex);

		if (g_pGameCVars->autotest_enabled && pLobby != NULL && (pLobby->GetLobbyServiceType() == eCLS_LAN))
		{
			// Don't care about signing out if we're in the autotester and in LAN mode
			return;
		}
#endif

		{
			EOnlineState onlineState = eventData.pOnlineStateData->m_curState;
			if(onlineState == eOS_SignedOut)
			{
				if(pLobby && pLobby->GetLobbyServiceType() == eCLS_Online)
				{
					if(eventData.pOnlineStateData->m_reason != eCLE_CyclingForInvite)
					{
						CErrorHandling *pErrorHandling = CErrorHandling::GetInstance();
						if (pErrorHandling)
						{
							pErrorHandling->OnFatalError(CErrorHandling::eFE_PlatformServiceSignedOut);
						}
						else
						{
							pLobbyManager->LeaveGameSession(eLSR_SignedOut);
						}

						IPlayerProfileManager *pPPM = g_pGame->GetIGameFramework()->GetIPlayerProfileManager();
						if(pPPM)
						{
							pPPM->ClearOnlineAttributes();
						}

#if 0 // old frontend
						CWarningsManager *pWM = g_pGame->GetWarnings();
						if(pWM)
						{
							pWM->RemoveWarning("ChatRestricted");
						}
#endif 
					}


#if defined(DEDICATED_SERVER)
					if (previousState != eOS_SignedOut)
					{
						CryLogAlways("We've been signed out, reason=%u, bailing", eventData.pOnlineStateData->m_reason);
						gEnv->pConsole->ExecuteString("quit", false, true);
					}
#endif
				}
			}					
		}
	}
}