//------------------------------------------------------------------------- // Returns the NAT type when set-up. void CGameBrowser::GetNatTypeCallback(UCryLobbyEventData eventData, void *arg) { SCryLobbyNatTypeData *natTypeData = eventData.pNatTypeData; if (natTypeData) { CGameBrowser* pGameBrowser = (CGameBrowser*) arg; pGameBrowser->SetNatType(natTypeData->m_curState); const char* natString = pGameBrowser->GetNatTypeString(); CryLog( "natString=%s", natString); #if !defined(_RELEASE) if(g_pGameCVars) { g_pGameCVars->net_nat_type->ForceSet(natString); } #endif if(g_pGame) { #ifdef USE_C2_FRONTEND if (CFlashFrontEnd *flashMenu = g_pGame->GetFlashMenu()) { if (flashMenu->GetMPMenu()) flashMenu->GetMPMenu()->UpdateNatType(natString); } #endif //#ifdef USE_C2_FRONTEND } } }
void CUILobbyMP::SearchGames(bool bLan) { //Clear results m_FoundServers.clear(); CGameBrowser *pGameBrowser = g_pGame->GetGameBrowser(); if (pGameBrowser) { if(bLan) CGameLobby::SetLobbyService(eCLS_LAN); else CGameLobby::SetLobbyService(eCLS_Online); pGameBrowser->CancelSearching(false); pGameBrowser->StartSearchingForServers(CUILobbyMP::MatchmakingSessionSearchCallback); } }
//------------------------------------------------------------------------- // Returns the NAT type when set-up. void CGameBrowser::GetNatTypeCallback(UCryLobbyEventData eventData, void *arg) { SCryLobbyNatTypeData *natTypeData = eventData.pNatTypeData; if (natTypeData) { CGameBrowser* pGameBrowser = (CGameBrowser*) arg; pGameBrowser->SetNatType(natTypeData->m_curState); const char* natString = pGameBrowser->GetNatTypeString(); CryLog( "natString=%s", natString); #if !defined(_RELEASE) if(g_pGameCVars) { g_pGameCVars->net_nat_type->ForceSet(natString); } #endif if(g_pGame) { NOTIFY_UILOBBY_MP(UpdateNatType()); } } }
//------------------------------------------------------------------------- // 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 }
//------------------------------------------------------------------------- // Process a search result. void CGameBrowser::MatchmakingSessionSearchCallback(CryLobbyTaskID taskID, ECryLobbyError error, SCrySessionSearchResult* session, void* arg) { CGameBrowser* pGameBrowser = (CGameBrowser*) arg; if (error == eCLE_SuccessContinue || error == eCLE_Success) { } 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 } }