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::EthernetStateCallback(UCryLobbyEventData eventData, void *arg) { if(eventData.pEthernetStateData) { CryLog("[GameLobbyManager] EthernetStateCallback state %d", eventData.pEthernetStateData->m_curState); CGameLobbyManager *pGameLobbyManager = (CGameLobbyManager*)arg; CRY_ASSERT(pGameLobbyManager); #ifdef GAME_IS_CRYSIS2 if(g_pGame->HasExclusiveControllerIndex()) { #ifdef USE_C2_FRONTEND CFlashFrontEnd *pFlashFrontEnd = g_pGame->GetFlashMenu(); CMPMenuHub *pMPMenuHub = pFlashFrontEnd ? pFlashFrontEnd->GetMPMenu() : NULL; #endif //#ifdef USE_C2_FRONTEND ECableState newState = eventData.pEthernetStateData->m_curState; #ifdef USE_C2_FRONTEND if(pMPMenuHub) { pMPMenuHub->EthernetStateChanged(newState); } #endif //#ifdef USE_C2_FRONTEND // cable has been removed, clear dialog if(newState == eCS_Unplugged || newState == eCS_Disconnected) { #ifdef GAME_IS_CRYSIS2 CWarningsManager *pWM = g_pGame->GetWarnings(); if(pWM) { pWM->RemoveWarning("ChatRestricted"); } #endif } } #endif pGameLobbyManager->m_isCableConnected = (eventData.pEthernetStateData->m_curState == eCS_Connected) ? true : false; } }
//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); } } } }
//------------------------------------------------------------------------- // Process a search result. void CGameBrowser::MatchmakingSessionSearchCallback(CryLobbyTaskID taskID, ECryLobbyError error, SCrySessionSearchResult* session, void* arg) { #ifdef USE_C2_FRONTEND CFlashFrontEnd *menu = g_pGame->GetFlashMenu(); CMPMenuHub *mpMenuHub = menu ? menu->GetMPMenu() : NULL; CGameBrowser* pGameBrowser = (CGameBrowser*) arg; if (error == eCLE_SuccessContinue || error == eCLE_Success) { if(session && mpMenuHub != NULL && GameLobbyData::IsCompatibleVersion(GameLobbyData::GetSearchResultsData(session, LID_MATCHDATA_VERSION))) { CUIServerList::SServerInfo si; si.m_hostName = session->m_data.m_name; CRY_TODO(20, 5, 2010, "In the case where too many servers have been filtered out, start a new search query and merge the results with the existing ones"); int requiredDLCs = GameLobbyData::GetSearchResultsData(session, LID_MATCHDATA_REQUIRED_DLCS); CryLog("Found server (%s), num data (%d): with DLC version %d", si.m_hostName.c_str(), session->m_data.m_numData, requiredDLCs); if (g_pGameCVars->g_ignoreDLCRequirements || CDLCManager::MeetsDLCRequirements(requiredDLCs, g_pGame->GetDLCManager()->GetSquadCommonDLCs()) || pGameBrowser->m_bFavouriteIdSearch) { si.m_numPlayers = session->m_numFilledSlots; si.m_maxPlayers = session->m_data.m_numPublicSlots; si.m_gameTypeName = GameLobbyData::GetGameRulesFromHash(GameLobbyData::GetSearchResultsData(session, LID_MATCHDATA_GAMEMODE)); si.m_gameTypeDisplayName = si.m_gameTypeName.c_str(); si.m_mapName = GameLobbyData::GetMapFromHash(GameLobbyData::GetSearchResultsData(session, LID_MATCHDATA_MAP)); si.m_mapDisplayName = PathUtil::GetFileName(si.m_mapName.c_str()).c_str(); si.m_friends = (session->m_numFriends>0); si.m_reqPassword = session->m_flags&eCSSRF_RequirePassword; uint32 variantId = GameLobbyData::GetSearchResultsData(session, LID_MATCHDATA_VARIANT); CPlaylistManager *pPlaylistManager = g_pGame->GetPlaylistManager(); if (pPlaylistManager) { const SGameVariant* pVariant = pPlaylistManager->GetVariant(variantId); if (pVariant) { si.m_gameVariantName = pVariant->m_name.c_str(); si.m_gameVariantDisplayName = CHUDUtils::LocalizeString(pVariant->m_localName.c_str()); } } // Get more readable map name and game type if (ILocalizationManager* pLocMgr = gEnv->pSystem->GetLocalizationManager()) { si.m_mapDisplayName = CHUDUtils::LocalizeString(g_pGame->GetMappedLevelName(si.m_mapDisplayName.c_str())); CryFixedStringT<64> tmpString; tmpString.Format("ui_rules_%s", si.m_gameTypeName.c_str()); SLocalizedInfoGame outInfo; if (pLocMgr->GetLocalizedInfoByKey(tmpString.c_str(), outInfo)) { wstring wcharstr = outInfo.swTranslatedText; CryStringUtils::WStrToUTF8(wcharstr, si.m_gameTypeDisplayName); } } #if USE_CRYLOBBY_GAMESPY int numData = session->m_data.m_numData; for (int i=0; i<numData; ++i) { SCryLobbyUserData& pUserData = session->m_data.m_data[i]; if (pUserData.m_id == LID_MATCHDATA_FAVOURITE_ID) { CRY_ASSERT(pUserData.m_type == eCLUDT_Int32); if (pUserData.m_type == eCLUDT_Int32) { si.m_sessionFavouriteKeyId = pUserData.m_int32; } } else if ((pUserData.m_id == LID_MATCHDATA_REGION)) { CRY_ASSERT(pUserData.m_type == eCLUDT_Int32); if (pUserData.m_type == eCLUDT_Int32) { si.m_region = pUserData.m_int32; } } else if ((pUserData.m_id == LID_MATCHDATA_OFFICIAL)) { CRY_ASSERT(pUserData.m_type == eCLUDT_Int32); if (pUserData.m_type == eCLUDT_Int32) { si.m_official = (pUserData.m_int32!=0); } } } #endif // FIXME : // Make server id unique in some other way.... si.m_serverId = (int)session->m_id.get(); // for lack of unique ids deref the pointer location of the server. This is the id that gets sent to flash... si.m_sessionId = session->m_id; si.m_ping = session->m_ping; if (pGameBrowser->m_bFavouriteIdSearch) { #if IMPLEMENT_PC_BLADES if (si.m_sessionFavouriteKeyId != INVALID_SESSION_FAVOURITE_ID) { for (uint32 i = 0; i < pGameBrowser->m_currentSearchFavouriteIdIndex; ++i) { if (si.m_sessionFavouriteKeyId == pGameBrowser->m_searchFavouriteIds[i]) { g_pGame->GetGameServerLists()->ServerFound(si, pGameBrowser->m_currentFavouriteIdSearchType, si.m_sessionFavouriteKeyId); // Invalidate any current search favourite ids, as it has been found pGameBrowser->m_searchFavouriteIds[i] = INVALID_SESSION_FAVOURITE_ID; break; } } } #endif } else { mpMenuHub->AddServer(si); } } } } else if (error != eCLE_SuccessUnreachable) { CryLogAlways("CGameBrowser search for sessions error %d", (int)error); CGameLobby::ShowErrorDialog(error, NULL, NULL, NULL); } if ((error != eCLE_SuccessContinue) && (error != eCLE_SuccessUnreachable)) { CryLogAlways("CCGameBrowser::MatchmakingSessionSearchCallback DONE"); pGameBrowser->FinishedSearch(true, !pGameBrowser->m_bFavouriteIdSearch); // FavouriteId might start another search after this one has finished } #endif //#ifdef USE_C2_FRONTEND }