diff --git a/serverbrowser/BaseGamesPage.cpp b/serverbrowser/BaseGamesPage.cpp index 5f76f78d..d87900c0 100644 --- a/serverbrowser/BaseGamesPage.cpp +++ b/serverbrowser/BaseGamesPage.cpp @@ -46,13 +46,13 @@ bool GameSupportsReplay() #endif //-------------------------------------------------------------------------------------------------------- -bool IsReplayServer( gameserveritem_t &server ) +bool IsReplayServer( newgameserver_t &server ) { bool bReplay = false; if ( GameSupportsReplay() ) { - if ( server.m_szGameTags && server.m_szGameTags[0] ) + if ( server.m_szGameTags[0] ) { CUtlVector TagList; V_SplitString( server.m_szGameTags, ",", TagList ); @@ -156,11 +156,11 @@ CBaseGamesPage::CBaseGamesPage( vgui::Panel *parent, const char *name, EPageType m_pConnect = new Button(this, "ConnectButton", "#ServerBrowser_Connect"); m_pConnect->SetEnabled(false); m_pRefreshAll = new Button(this, "RefreshButton", "#ServerBrowser_Refresh"); - m_pRefreshQuick = new Button(this, "RefreshQuickButton", "#ServerBrowser_RefreshQuick"); m_pAddServer = new Button(this, "AddServerButton", "#ServerBrowser_AddServer"); m_pAddCurrentServer = new Button(this, "AddCurrentServerButton", "#ServerBrowser_AddCurrentServer"); m_pGameList = new CGameListPanel(this, "gamelist"); m_pGameList->SetAllowUserModificationOfColumns(true); + m_pRefreshQuick = new Button(this, "RefreshQuickButton", "#ServerBrowser_RefreshQuick"); m_pQuickList = new PanelListPanel(this, "quicklist"); m_pQuickList->SetFirstColumnWidth( 0 ); @@ -191,14 +191,14 @@ CBaseGamesPage::CBaseGamesPage( vgui::Panel *parent, const char *name, EPageType 300, // maxwidth 0 // flags ); - m_pGameList->AddColumnHeader( k_nColumn_Players, "Players", "#ServerBrowser_Players", 55, ListPanel::COLUMN_FIXEDSIZE); - m_pGameList->AddColumnHeader( k_nColumn_Bots, "Bots", "#ServerBrowser_Bots", 40, ListPanel::COLUMN_FIXEDSIZE); + m_pGameList->AddColumnHeader( k_nColumn_Players, "Players", "#ServerBrowser_Players", 80, ListPanel::COLUMN_FIXEDSIZE); + m_pGameList->AddColumnHeader( k_nColumn_Bots, "Bots", "#ServerBrowser_Bots", 60, ListPanel::COLUMN_FIXEDSIZE); m_pGameList->AddColumnHeader( k_nColumn_Map, "Map", "#ServerBrowser_Map", 90, 90, // minwidth 300, // maxwidth 0 // flags ); - m_pGameList->AddColumnHeader( k_nColumn_Ping, "Ping", "#ServerBrowser_Latency", 55, ListPanel::COLUMN_FIXEDSIZE); + m_pGameList->AddColumnHeader( k_nColumn_Ping, "Ping", "#ServerBrowser_Latency", 55, ListPanel::COLUMN_RESIZEWITHWINDOW); m_pGameList->SetColumnHeaderTooltip( k_nColumn_Password, "#ServerBrowser_PasswordColumn_Tooltip"); m_pGameList->SetColumnHeaderTooltip( k_nColumn_Bots, "#ServerBrowser_BotColumn_Tooltip"); @@ -280,12 +280,10 @@ void CBaseGamesPage::PerformLayout() if (SupportsItem(IGameList::GETNEWLIST)) { - m_pRefreshQuick->SetVisible(true); m_pRefreshAll->SetText("#ServerBrowser_RefreshAll"); } else { - m_pRefreshQuick->SetVisible(false); m_pRefreshAll->SetText("#ServerBrowser_Refresh"); } @@ -313,25 +311,8 @@ void CBaseGamesPage::PerformLayout() m_pRefreshAll->SetText( "#ServerBrowser_StopRefreshingList" ); } - if (m_pGameList->GetItemCount() > 0) - { - m_pRefreshQuick->SetEnabled(true); - } - else - { - m_pRefreshQuick->SetEnabled(false); - } - -/* if ( !steamapicontext->SteamMatchmakingServers() || !steamapicontext->SteamMatchmaking() ) - { - m_pAddCurrentServer->SetVisible( false ); - m_pRefreshQuick->SetEnabled( false ); - m_pAddServer->SetEnabled( false ); - m_pConnect->SetEnabled( false ); - m_pRefreshAll->SetEnabled( false ); - m_pAddToFavoritesButton->SetEnabled( false ); - m_pGameList->SetEmptyListText( "#ServerBrowser_SteamRunning" ); - }*/ + m_pRefreshQuick->SetVisible( false ); + m_pFilter->SetVisible(false); Repaint(); } @@ -378,20 +359,6 @@ struct serverqualitysort_t int ServerQualitySort( const serverqualitysort_t *pSQ1, const serverqualitysort_t *pSQ2 ) { - int iMaxP = sb_mod_suggested_maxplayers.GetInt(); - if ( iMaxP && pSQ1->iMaxPlayerCount != pSQ2->iMaxPlayerCount ) - { - if ( pSQ1->iMaxPlayerCount > iMaxP ) - return 1; - if ( pSQ2->iMaxPlayerCount > iMaxP ) - return -1; - } - - if ( pSQ1->iPing <= 100 && pSQ2->iPing <= 100 && pSQ1->iPlayerCount != pSQ2->iPlayerCount ) - { - return pSQ2->iPlayerCount - pSQ1->iPlayerCount; - } - return pSQ1->iPing - pSQ2->iPing; } @@ -400,156 +367,72 @@ int ServerQualitySort( const serverqualitysort_t *pSQ1, const serverqualitysort_ //----------------------------------------------------------------------------- void CBaseGamesPage::SelectQuickListServers( void ) { - int iIndex = m_pQuickList->FirstItem(); - - while ( iIndex != m_pQuickList->InvalidItemID() ) - { - CQuickListPanel *pQuickListPanel = dynamic_cast< CQuickListPanel *> ( m_pQuickList->GetItemPanel( iIndex ) ); - - if ( pQuickListPanel ) - { - CUtlVector< serverqualitysort_t > vecServerQuality; - - int iElement = m_quicklistserverlist.Find( pQuickListPanel->GetName() ); - - if ( iElement != m_quicklistserverlist.InvalidIndex() ) - { - CQuickListMapServerList *vecMapServers = &m_quicklistserverlist[iElement]; - - if ( vecMapServers ) - { - for ( int i =0; i < vecMapServers->Count(); i++ ) - { - int iListID = vecMapServers->Element( i ); - - serverqualitysort_t serverquality; - - serverquality.iIndex = iListID; - - KeyValues *kv = NULL; - if ( m_pGameList->IsValidItemID( iListID ) ) - { - kv = m_pGameList->GetItem( iListID ); - } - - if ( kv ) - { - serverquality.iPing = kv->GetInt( "ping", 0 ); - serverquality.iPlayerCount = kv->GetInt( "PlayerCount", 0 ); - serverquality.iMaxPlayerCount = kv->GetInt( "MaxPlayerCount", 0 ); - } - - vecServerQuality.AddToTail( serverquality ); - } - - vecServerQuality.Sort( ServerQualitySort ); - - serverqualitysort_t bestserver = vecServerQuality.Head(); - - if ( m_pGameList->IsValidItemID( bestserver.iIndex ) ) - { - pQuickListPanel->SetServerInfo( m_pGameList->GetItem( bestserver.iIndex ), bestserver.iIndex, vecServerQuality.Count() ); - } - } - } - } - - iIndex = m_pQuickList->NextItem( iIndex ); - } - - //Force the connect button to recalculate its state. - OnItemSelected(); } -int ServerMapnameSortFunc( const servermaps_t *p1, const servermaps_t *p2 ) +int ServerPingSortFunc( const serverping_t *p1, const serverping_t *p2 ) { - //If they're both on disc OR both missing then sort them alphabetically - if ( (p1->bOnDisk && p2->bOnDisk) || (!p1->bOnDisk && !p2->bOnDisk ) ) - return Q_strcmp( p1->pFriendlyName, p2->pFriendlyName ); - - //Otherwise maps you have show up first - return p2->bOnDisk - p1->bOnDisk; + return p1->m_nPing - p2->m_nPing; } //----------------------------------------------------------------------------- // Purpose: prepares all the QuickListPanel map panels... //----------------------------------------------------------------------------- -void CBaseGamesPage::PrepareQuickListMap( const char *pMapName, int iListID ) +void CBaseGamesPage::PrepareQuickListMap( newgameserver_t *server, int iListID ) { char szMapName[ 512 ]; - Q_snprintf( szMapName, sizeof( szMapName ), "%s", pMapName ); + Q_snprintf( szMapName, sizeof( szMapName ), "%s", server->m_szMap ); Q_strlower( szMapName ); char path[ 512 ]; Q_snprintf( path, sizeof( path ), "maps/%s.bsp", szMapName ); - - int iIndex = m_quicklistserverlist.Find( szMapName ); - if ( m_quicklistserverlist.IsValidIndex( iIndex ) == false ) + char szFriendlyName[MAX_MAP_NAME]; + const char *pszFriendlyGameTypeName = ServerBrowser().GetMapFriendlyNameAndGameType( szMapName, szFriendlyName, sizeof(szFriendlyName) ); + + //Add the map to our list of panels. + if ( m_pQuickList ) { - CQuickListMapServerList vecMapServers; - iIndex = m_quicklistserverlist.Insert( szMapName, vecMapServers ); + serverping_t serverping; + const char *pFriendlyName = CloneString( szFriendlyName ); + const char *pOriginalName = CloneString( szMapName ); - char szFriendlyName[MAX_MAP_NAME]; - const char *pszFriendlyGameTypeName = ServerBrowser().GetMapFriendlyNameAndGameType( szMapName, szFriendlyName, sizeof(szFriendlyName) ); + char path[ 512 ]; + Q_snprintf( path, sizeof( path ), "maps/%s.bsp", szMapName ); - //Add the map to our list of panels. - if ( m_pQuickList ) + CQuickListPanel *pQuickListPanel = new CQuickListPanel( m_pQuickList, "QuickListPanel"); + + if ( pQuickListPanel ) { - servermaps_t servermap; + pQuickListPanel->InvalidateLayout(); + pQuickListPanel->SetName( pOriginalName ); + pQuickListPanel->SetMapName( pFriendlyName ); + pQuickListPanel->SetImage( pOriginalName ); + pQuickListPanel->SetGameType( pszFriendlyGameTypeName ); + pQuickListPanel->SetVisible( true ); + pQuickListPanel->SetRefreshing(); + pQuickListPanel->SetServerInfo( m_pGameList->GetItem( iListID ), iListID, 1 ); - servermap.pFriendlyName = CloneString( szFriendlyName ); - servermap.pOriginalName = CloneString( szMapName ); + serverping.iPanelIndex = m_pQuickList->AddItem( NULL, pQuickListPanel ); - char path[ 512 ]; - Q_snprintf( path, sizeof( path ), "maps/%s.bsp", szMapName ); + serverping.m_nPing = server->m_nPing; - servermap.bOnDisk = g_pFullFileSystem->FileExists( path, "MOD" ); - - CQuickListPanel *pQuickListPanel = new CQuickListPanel( m_pQuickList, "QuickListPanel"); - - if ( pQuickListPanel ) - { - pQuickListPanel->InvalidateLayout(); - pQuickListPanel->SetName( servermap.pOriginalName ); - pQuickListPanel->SetMapName( servermap.pFriendlyName ); - pQuickListPanel->SetImage( servermap.pOriginalName ); - pQuickListPanel->SetGameType( pszFriendlyGameTypeName ); - pQuickListPanel->SetVisible( true ); - pQuickListPanel->SetRefreshing(); - - servermap.iPanelIndex = m_pQuickList->AddItem( NULL, pQuickListPanel ); - } - - m_vecMapNamesFound.AddToTail( servermap ); - m_vecMapNamesFound.Sort( ServerMapnameSortFunc ); + m_vecServersFound.AddToTail( serverping ); + m_vecServersFound.Sort( ServerPingSortFunc ); } - //Now make sure that list is sorted. - CUtlVector *pPanelSort = m_pQuickList->GetSortedVector(); - - if ( pPanelSort ) - { - pPanelSort->RemoveAll(); - - for ( int i = 0; i < m_vecMapNamesFound.Count(); i++ ) - { - pPanelSort->AddToTail( m_vecMapNamesFound[i].iPanelIndex ); - } - } } - if ( iIndex != m_quicklistserverlist.InvalidIndex() ) - { - CQuickListMapServerList *vecMapServers = &m_quicklistserverlist[iIndex]; + //Now make sure that list is sorted. + CUtlVector *pPanelSort = m_pQuickList->GetSortedVector(); - if ( vecMapServers ) + if ( pPanelSort ) + { + pPanelSort->RemoveAll(); + + for ( int i = 0; i < m_vecServersFound.Count(); i++ ) { - if ( vecMapServers->Find( iListID ) == vecMapServers->InvalidIndex() ) - { - vecMapServers->AddToTail( iListID ); - } + pPanelSort->AddToTail( m_vecServersFound[i].iPanelIndex ); } } } @@ -557,21 +440,10 @@ void CBaseGamesPage::PrepareQuickListMap( const char *pMapName, int iListID ) //----------------------------------------------------------------------------- // Purpose: gets information about specified server //----------------------------------------------------------------------------- -gameserveritem_t *CBaseGamesPage::GetServer( unsigned int serverID ) +newgameserver_t *CBaseGamesPage::GetServer( unsigned int serverID ) { - if ( !steamapicontext->SteamMatchmakingServers() ) - return NULL; - - // No point checking for >= 0 when serverID is unsigned. - //if ( serverID >= 0 ) - { - return steamapicontext->SteamMatchmakingServers()->GetServerDetails( m_hRequest, serverID ); - } - //else - //{ - // Assert( !"Unable to return a useful entry" ); - // return NULL; // bugbug Alfred: temp Favorites/History objects won't return a good value here... - //} + if( serverID >= m_serversInfo.Count() ) return NULL; + return &m_serversInfo[serverID]; } //----------------------------------------------------------------------------- @@ -680,8 +552,8 @@ void CBaseGamesPage::CreateFilters() int iItemID = m_pGameFilter->AddItem(ModList().GetModName(i), pkv); m_mapGamesFilterItem.Insert( ModList().GetAppID(i).ToUint64(), iItemID ); } - pkv->deleteThis(); + pkv->deleteThis(); } @@ -710,7 +582,7 @@ void CBaseGamesPage::LoadFilterSettings() m_bFilterNoEmptyServers = filter->GetInt("NoEmpty"); m_bFilterNoPasswordedServers = filter->GetInt("NoPassword"); m_bFilterReplayServers = filter->GetInt("Replay"); - m_pQuickListCheckButton->SetSelected( filter->GetInt( "QuickList", 0 ) ); + m_pQuickListCheckButton->SetSelected( filter->GetInt( "QuickList", IsAndroid() ) ); int secureFilter = filter->GetInt("Secure"); m_pSecureFilter->ActivateItem(secureFilter); @@ -1005,7 +877,13 @@ void CBaseGamesPage::UpdateFilterAndQuickListVisibility() int wide, tall; GetSize( wide, tall ); - SetSize( 624, 278 ); + + int w = 640; int h = 384; + + w = IsProportional() ? vgui::scheme()->GetProportionalScaledValue(w) : w; + h = IsProportional() ? vgui::scheme()->GetProportionalScaledValue(h) : h; + + SetSize( w, h ); UpdateDerivedLayouts(); UpdateGameFilter(); @@ -1018,12 +896,10 @@ void CBaseGamesPage::UpdateFilterAndQuickListVisibility() SetSize( wide, tall ); - m_pQuickList->SetVisible( showQuickList ); m_pGameList->SetVisible( !showQuickList ); m_pFilter->SetVisible( !showQuickList ); - m_pFilterString->SetVisible ( !showQuickList ); - + m_pFilterString->SetVisible ( !showQuickList ); InvalidateLayout(); @@ -1638,7 +1514,6 @@ void CBaseGamesPage::SetRefreshing(bool state) m_pGameList->SetEmptyListText(""); m_pRefreshAll->SetText("#ServerBrowser_StopRefreshingList"); m_pRefreshAll->SetCommand("stoprefresh"); - m_pRefreshQuick->SetEnabled(false); } else { @@ -1654,14 +1529,6 @@ void CBaseGamesPage::SetRefreshing(bool state) m_pRefreshAll->SetCommand("GetNewList"); // 'refresh quick' button is only enabled if there are servers in the list - if (m_pGameList->GetItemCount() > 0) - { - m_pRefreshQuick->SetEnabled(true); - } - else - { - m_pRefreshQuick->SetEnabled(false); - } } } @@ -1762,7 +1629,7 @@ int CBaseGamesPage::GetSelectedItemsCount() //----------------------------------------------------------------------------- void CBaseGamesPage::OnAddToFavorites() { - if ( !steamapicontext->SteamMatchmakingServers() ) +/* if ( !steamapicontext->SteamMatchmakingServers() ) return; // loop through all the selected favorites @@ -1776,7 +1643,7 @@ void CBaseGamesPage::OnAddToFavorites() // add to favorites list ServerBrowserDialog().AddServerToFavorites(*pServer); } - } + }*/ } //----------------------------------------------------------------------------- @@ -1838,6 +1705,8 @@ void CBaseGamesPage::StartRefresh() MatchMakingKeyValuePair_t *pFilters; int nFilters = GetServerFilters( &pFilters ); + m_serversInfo.SetCount(0); + /* if ( m_hRequest ) { steamapicontext->SteamMatchmakingServers()->ReleaseRequest( m_hRequest ); @@ -1852,7 +1721,6 @@ void CBaseGamesPage::StartRefresh() m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestHistoryServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this ); break;*/ case eInternetServer: - Msg("RequestInternetServerList\n"); g_pServersInfo->RequestInternetServerList(COM_GetModDirectory(), this); //m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestInternetServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this ); break; @@ -1878,20 +1746,7 @@ void CBaseGamesPage::StartRefresh() void CBaseGamesPage::ClearQuickList( void ) { m_pQuickList->DeleteAllItems(); - m_vecMapNamesFound.RemoveAll(); - - int iIndex = m_quicklistserverlist.First(); - - while ( iIndex != m_quicklistserverlist.InvalidIndex() ) - { - CQuickListMapServerList *vecMapServers = &m_quicklistserverlist[iIndex]; - - vecMapServers->RemoveAll(); - - iIndex = m_quicklistserverlist.Next( iIndex ); - } - - m_quicklistserverlist.RemoveAll(); + m_vecServersFound.RemoveAll(); } //----------------------------------------------------------------------------- @@ -1925,8 +1780,7 @@ void CBaseGamesPage::StopRefresh() m_iServerRefreshCount = 0; // Stop the server list refreshing - if ( steamapicontext->SteamMatchmakingServers() ) - steamapicontext->SteamMatchmakingServers()->CancelQuery( m_hRequest ); + g_pServersInfo->StopRefresh(); // update UI RefreshComplete( nServerResponded ); @@ -1940,7 +1794,8 @@ void CBaseGamesPage::StopRefresh() //----------------------------------------------------------------------------- void CBaseGamesPage::RefreshComplete( NServerResponse response ) { - SelectQuickListServers(); + //Force the connect button to recalculate its state. + OnItemSelected(); } //----------------------------------------------------------------------------- @@ -2235,12 +2090,7 @@ void CBaseGamesPage::ServerResponded( newgameserver_t &server ) kv->SetString("GameDir", pServerItem->m_szGameDir); kv->SetString("GameDesc", pServerItem->m_szGameDescription); kv->SetInt("password", pServerItem->m_bPassword ? m_nImageIndexPassword : 0); - - if ( pServerItem->m_nBotPlayers > 0 ) - kv->SetInt("bots", pServerItem->m_nBotPlayers); - else - kv->SetString("bots", ""); - + kv->SetInt("bots", pServerItem->m_nBotPlayers); kv->SetInt("secure", 0); @@ -2257,51 +2107,21 @@ void CBaseGamesPage::ServerResponded( newgameserver_t &server ) kv->SetInt("Ping", pServerItem->m_nPing); - kv->SetString("Tags", ""); + kv->SetString("Tags", pServerItem->m_szGameTags); kv->SetInt("Replay", 0); -/* if ( pServerItem->m_ulTimeLastPlayed ) - { - // construct a time string for last played time - struct tm *now; - now = localtime( (time_t*)&pServerItem->m_ulTimeLastPlayed ); - - if ( now ) - { - char buf[64]; - strftime(buf, sizeof(buf), "%a %d %b %I:%M%p", now); - Q_strlower(buf + strlen(buf) - 4); - kv->SetString("LastPlayed", buf); - } - }*/ - int iServerIndex = m_serversInfo.AddToTail( server ); - //if ( !m_pGameList->IsValidItemID( pServer->m_iListID ) ) + // new server, add to list + int iListID = m_pGameList->AddItem(kv, iServerIndex, false, false); - // new server, add to list - int iListID = m_pGameList->AddItem(kv, iServerIndex, false, false); - /*if ( m_bAutoSelectFirstItemInGameList && m_pGameList->GetItemCount() == 1 ) - { - m_pGameList->AddSelectedItem( pServer->m_iListID ); - }*/ + m_pGameList->SetItemVisible( iListID, true ); + kv->deleteThis(); - m_pGameList->SetItemVisible( iListID, true ); - - kv->deleteThis(); - -/* else - { - // tell the list that we've changed the data - m_pGameList->ApplyItemChanges( pServer->m_iListID ); - m_pGameList->SetItemVisible( pServer->m_iListID, !removeItem ); - }*/ - - PrepareQuickListMap( pServerItem->m_szMap, iListID ); + PrepareQuickListMap( &server, iListID ); UpdateStatus(); m_iServerRefreshCount++; - } //----------------------------------------------------------------------------- diff --git a/serverbrowser/BaseGamesPage.h b/serverbrowser/BaseGamesPage.h index fca73685..d3e0ce87 100644 --- a/serverbrowser/BaseGamesPage.h +++ b/serverbrowser/BaseGamesPage.h @@ -66,12 +66,10 @@ public: virtual void OnCursorExited(); }; -struct servermaps_t +struct serverping_t { - const char *pOriginalName; - const char *pFriendlyName; - int iPanelIndex; - bool bOnDisk; + int m_nPing; + int iPanelIndex; }; struct gametypes_t @@ -120,7 +118,7 @@ public: virtual void ApplySchemeSettings(vgui::IScheme *pScheme); // gets information about specified server - virtual gameserveritem_t *GetServer(unsigned int serverID); + virtual newgameserver_t *GetServer(unsigned int serverID); virtual const char *GetConnectCode(); uint32 GetServerFilters( MatchMakingKeyValuePair_t **pFilters ); @@ -144,7 +142,7 @@ public: virtual void UpdateDerivedLayouts( void ); - void PrepareQuickListMap( const char *pMapName, int iListID ); + void PrepareQuickListMap( newgameserver_t *server, int iListID ); void SelectQuickListServers( void ); vgui::Panel *GetActiveList( void ); virtual bool IsQuickListButtonChecked() @@ -242,7 +240,7 @@ protected: CUtlVector m_vecServerFilters; CUtlDict< CQuickListMapServerList, int > m_quicklistserverlist; int m_iServerRefreshCount; - CUtlVector< servermaps_t > m_vecMapNamesFound; + CUtlVector m_vecServersFound; EPageType m_eMatchMakingType; diff --git a/serverbrowser/DialogAddServer.cpp b/serverbrowser/DialogAddServer.cpp index 5dbc9ed5..50ce17ca 100644 --- a/serverbrowser/DialogAddServer.cpp +++ b/serverbrowser/DialogAddServer.cpp @@ -177,15 +177,13 @@ void CDialogAddServer::OnOK() if ( AllowInvalidIPs() || netaddr.IsValid() ) { - gameserveritem_t server; + newgameserver_t server; memset(&server, 0, sizeof(server)); - server.SetName( address ); + strncpy( server.m_szServerName, address, sizeof(server.m_szServerName) ); // We assume here that the query and connection ports are the same. This is why it's much // better if they click "Servers" and choose a server in there. - server.m_NetAdr.Init( netaddr.GetIPHostByteOrder(), netaddr.GetPort(), netaddr.GetPort() ); - - server.m_nAppID = 0; + server.m_NetAdr = netaddr; FinishAddServer( server ); } else @@ -257,21 +255,21 @@ void CDialogAddServer::TestServers() m_pTabPanel->AddPage( m_pDiscoveredGames, str ); m_pTabPanel->InvalidateLayout(); - FOR_EACH_VEC( vecAdress, iAddress ) +/* FOR_EACH_VEC( vecAdress, iAddress ) { m_Queries.AddToTail( steamapicontext->SteamMatchmakingServers()->PingServer( vecAdress[ iAddress ].GetIPHostByteOrder(), vecAdress[ iAddress ].GetPort(), this ) ); - } + }*/ } //----------------------------------------------------------------------------- // Purpose: A server answered our ping //----------------------------------------------------------------------------- -void CDialogAddServer::ServerResponded( gameserveritem_t &server ) +void CDialogAddServer::ServerResponded( newgameserver_t &server ) { KeyValues *kv = new KeyValues( "Server" ); - kv->SetString( "name", server.GetName() ); + kv->SetString( "name", server.m_szServerName ); kv->SetString( "map", server.m_szMap ); kv->SetString( "GameDir", server.m_szGameDir ); kv->SetString( "GameDesc", server.m_szGameDescription ); @@ -279,21 +277,9 @@ void CDialogAddServer::ServerResponded( gameserveritem_t &server ) kv->SetInt( "password", server.m_bPassword ? 1 : 0); kv->SetInt( "bots", server.m_nBotPlayers ? 2 : 0); kv->SetInt( "Replay", IsReplayServer( server ) ? 5 : 0 ); + kv->SetInt("secure", 0); - if ( server.m_bSecure ) - { - // show the denied icon if banned from secure servers, the secure icon otherwise - kv->SetInt("secure", ServerBrowser().IsVACBannedFromGame( server.m_nAppID ) ? 4 : 3); - } - else - { - kv->SetInt("secure", 0); - } - - netadr_t reportedIPAddr; - reportedIPAddr.SetIP( server.m_NetAdr.GetIP() ); - reportedIPAddr.SetPort( server.m_NetAdr.GetConnectionPort() ); - kv->SetString("IPAddr", reportedIPAddr.ToString() ); + kv->SetString("IPAddr", server.m_NetAdr.ToString() ); char buf[32]; Q_snprintf(buf, sizeof(buf), "%d / %d", server.m_nPlayers, server.m_nMaxPlayers); @@ -366,7 +352,7 @@ void CDialogAddServer::OnItemSelected() //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- -void CDialogAddServer::FinishAddServer( gameserveritem_t &pServer ) +void CDialogAddServer::FinishAddServer( newgameserver_t &pServer ) { ServerBrowserDialog().AddServerToFavorites( pServer ); } diff --git a/serverbrowser/DialogAddServer.h b/serverbrowser/DialogAddServer.h index c340904b..6128561c 100644 --- a/serverbrowser/DialogAddServer.h +++ b/serverbrowser/DialogAddServer.h @@ -17,7 +17,7 @@ class IGameList; //----------------------------------------------------------------------------- // Purpose: Dialog which lets the user add a server by IP address //----------------------------------------------------------------------------- -class CDialogAddServer : public vgui::Frame, public ISteamMatchmakingPingResponse +class CDialogAddServer : public vgui::Frame //, public ISteamMatchmakingPingResponse { DECLARE_CLASS_SIMPLE( CDialogAddServer, vgui::Frame ); friend class CAddServerGameList; @@ -26,7 +26,7 @@ public: CDialogAddServer(vgui::Panel *parent, IGameList *gameList); ~CDialogAddServer(); - void ServerResponded( gameserveritem_t &server ); + void ServerResponded( newgameserver_t &server ); void ServerFailedToRespond(); void ApplySchemeSettings( vgui::IScheme *pScheme ); @@ -40,7 +40,7 @@ private: void TestServers(); MESSAGE_FUNC( OnTextChanged, "TextChanged" ); - virtual void FinishAddServer( gameserveritem_t &pServer ); + virtual void FinishAddServer( newgameserver_t &pServer ); virtual bool AllowInvalidIPs( void ) { return false; } protected: @@ -54,7 +54,7 @@ protected: vgui::TextEntry *m_pTextEntry; vgui::ListPanel *m_pDiscoveredGames; int m_OriginalHeight; - CUtlVector m_Servers; + CUtlVector m_Servers; CUtlVector m_Queries; }; diff --git a/serverbrowser/InternetGames.cpp b/serverbrowser/InternetGames.cpp index 2e77e0ab..00a46ccf 100644 --- a/serverbrowser/InternetGames.cpp +++ b/serverbrowser/InternetGames.cpp @@ -23,7 +23,7 @@ CInternetGames::CInternetGames(vgui::Panel *parent, const char *panelName, EPage m_fLastSort = 0.0f; m_bDirty = false; m_bRequireUpdate = true; - m_bOfflineMode = false; //ro!IsSteamGameServerBrowsingEnabled(); + m_bOfflineMode = false; m_bAnyServersRetrievedFromMaster = false; m_bNoServersListedOnMaster = false; @@ -311,7 +311,7 @@ int CInternetGames::GetRegionCodeToFilter() bool CInternetGames::CheckTagFilter( gameserveritem_t &server ) { // Servers without tags go in the official games, servers with tags go in custom games - bool bOfficialServer = !( server.m_szGameTags && server.m_szGameTags[0] ); + bool bOfficialServer = !server.m_szGameTags[0]; if ( !bOfficialServer ) return false; diff --git a/serverbrowser/ServerBrowserDialog.cpp b/serverbrowser/ServerBrowserDialog.cpp index b3e9738b..2ba47348 100644 --- a/serverbrowser/ServerBrowserDialog.cpp +++ b/serverbrowser/ServerBrowserDialog.cpp @@ -59,6 +59,7 @@ void GetMostCommonQueryPorts( CUtlVector &ports ) //----------------------------------------------------------------------------- CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent, "CServerBrowserDialog") { + SetProportional( NeedProportional() ); s_InternetDlg = this; m_szGameName[0] = 0; @@ -67,19 +68,25 @@ CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent, m_pFilterData = NULL; m_pFavorites = NULL; m_pHistory = NULL; + m_pLanGames = NULL; LoadUserData(); m_pInternetGames = new CInternetGames(this); +/* m_pFavorites = new CFavoriteGames(this); m_pHistory = new CHistoryGames(this); - - // TODO(nillerusr): implement spectate games without steam - //m_pSpectateGames = new CSpectateGames(this); + m_pSpectateGames = new CSpectateGames(this); m_pLanGames = new CLanGames(this); +*/ - SetMinimumSize( 640, 384 ); - SetSize( 640, 384 ); + int w = 640; int h = 384; + + w = IsProportional() ? vgui::scheme()->GetProportionalScaledValue(w) : w; + h = IsProportional() ? vgui::scheme()->GetProportionalScaledValue(h) : h; + + SetMinimumSize( w, h ); + SetSize( w, h ); m_pGameList = m_pInternetGames; @@ -89,10 +96,10 @@ CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent, m_pTabPanel = new PropertySheet(this, "GameTabs"); m_pTabPanel->SetTabWidth(72); m_pTabPanel->AddPage(m_pInternetGames, "#ServerBrowser_InternetTab"); - m_pTabPanel->AddPage(m_pFavorites, "#ServerBrowser_FavoritesTab"); - m_pTabPanel->AddPage(m_pHistory, "#ServerBrowser_HistoryTab"); + //m_pTabPanel->AddPage(m_pFavorites, "#ServerBrowser_FavoritesTab"); + //m_pTabPanel->AddPage(m_pHistory, "#ServerBrowser_HistoryTab"); //m_pTabPanel->AddPage(m_pSpectateGames, "#ServerBrowser_SpectateTab"); - m_pTabPanel->AddPage(m_pLanGames, "#ServerBrowser_LanTab"); + //m_pTabPanel->AddPage(m_pLanGames, "#ServerBrowser_LanTab"); m_pTabPanel->AddActionSignalTarget(this); @@ -109,7 +116,7 @@ CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent, { m_pTabPanel->SetActivePage(m_pSpectateGames); } - else */ + else if (!Q_stricmp(gameList, "favorites")) { m_pTabPanel->SetActivePage(m_pFavorites); @@ -122,7 +129,7 @@ CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent, { m_pTabPanel->SetActivePage(m_pLanGames); } - else + else*/ { m_pTabPanel->SetActivePage(m_pInternetGames); } @@ -160,7 +167,7 @@ void CServerBrowserDialog::Initialize() //----------------------------------------------------------------------------- // Purpose: returns a server in the list //----------------------------------------------------------------------------- -gameserveritem_t *CServerBrowserDialog::GetServer( unsigned int serverID ) +newgameserver_t *CServerBrowserDialog::GetServer( unsigned int serverID ) { if (m_pGameList) return m_pGameList->GetServer( serverID ); @@ -257,7 +264,7 @@ void CServerBrowserDialog::SaveUserData() { m_pSavedData->SetString("GameList", "spectate"); } - else */ + else if (m_pGameList == m_pFavorites) { m_pSavedData->SetString("GameList", "favorites"); @@ -270,7 +277,7 @@ void CServerBrowserDialog::SaveUserData() { m_pSavedData->SetString("GameList", "history"); } - else + else*/ { m_pSavedData->SetString("GameList", "internet"); } @@ -363,9 +370,9 @@ CServerBrowserDialog *CServerBrowserDialog::GetInstance() //----------------------------------------------------------------------------- // Purpose: Adds a server to the list of favorites //----------------------------------------------------------------------------- -void CServerBrowserDialog::AddServerToFavorites(gameserveritem_t &server) +void CServerBrowserDialog::AddServerToFavorites(newgameserver_t &server) { - if ( steamapicontext->SteamMatchmaking() ) +/* if ( steamapicontext->SteamMatchmaking() ) { steamapicontext->SteamMatchmaking()->AddFavoriteGame( server.m_nAppID, @@ -374,7 +381,7 @@ void CServerBrowserDialog::AddServerToFavorites(gameserveritem_t &server) server.m_NetAdr.GetQueryPort(), k_unFavoriteFlagFavorite, time( NULL ) ); - } + }*/ } //----------------------------------------------------------------------------- @@ -527,10 +534,10 @@ void CServerBrowserDialog::OnActiveGameName( KeyValues *pKV ) void CServerBrowserDialog::ReloadFilterSettings() { m_pInternetGames->LoadFilterSettings(); - //m_pSpectateGames->LoadFilterSettings(); + /*m_pSpectateGames->LoadFilterSettings(); m_pFavorites->LoadFilterSettings(); m_pLanGames->LoadFilterSettings(); - m_pHistory->LoadFilterSettings(); + m_pHistory->LoadFilterSettings();*/ } //----------------------------------------------------------------------------- @@ -572,7 +579,7 @@ void CServerBrowserDialog::OnConnectToGame( KeyValues *pMessageValues ) } // forward to favorites - m_pFavorites->OnConnectToGame(); + //m_pFavorites->OnConnectToGame(); m_bCurrentlyConnected = true; @@ -582,7 +589,7 @@ void CServerBrowserDialog::OnConnectToGame( KeyValues *pMessageValues ) { iQuickListBitField |= ( 1 << 1 ); } -/* if ( m_pSpectateGames && m_pSpectateGames->IsQuickListButtonChecked() ) + /*if ( m_pSpectateGames && m_pSpectateGames->IsQuickListButtonChecked() ) { iQuickListBitField |= ( 1 << 2 ); }*/ @@ -625,7 +632,7 @@ void CServerBrowserDialog::OnDisconnectFromGame( void ) memset( &m_CurrentConnection, 0, sizeof(gameserveritem_t) ); // forward to favorites - m_pFavorites->OnDisconnectFromGame(); + //m_pFavorites->OnDisconnectFromGame(); } //----------------------------------------------------------------------------- @@ -634,10 +641,10 @@ void CServerBrowserDialog::OnDisconnectFromGame( void ) void CServerBrowserDialog::OnLoadingStarted( void ) { m_pInternetGames->OnLoadingStarted(); -// m_pSpectateGames->OnLoadingStarted(); +/* m_pSpectateGames->OnLoadingStarted(); m_pFavorites->OnLoadingStarted(); m_pLanGames->OnLoadingStarted(); - m_pHistory->OnLoadingStarted(); + m_pHistory->OnLoadingStarted();*/ } //----------------------------------------------------------------------------- diff --git a/serverbrowser/ServerBrowserDialog.h b/serverbrowser/ServerBrowserDialog.h index 8180a9f1..dfd4955f 100644 --- a/serverbrowser/ServerBrowserDialog.h +++ b/serverbrowser/ServerBrowserDialog.h @@ -31,7 +31,7 @@ public: void Open( void ); // gets server info - gameserveritem_t *GetServer(unsigned int serverID); + newgameserver_t *GetServer(unsigned int serverID); // called every frame virtual void OnTick(); @@ -49,7 +49,7 @@ public: static CServerBrowserDialog *GetInstance(); // Adds a server to the list of favorites - void AddServerToFavorites(gameserveritem_t &server); + void AddServerToFavorites(newgameserver_t &server); // begins the process of joining a server from a game list // the game info dialog it opens will also update the game list @@ -118,11 +118,12 @@ private: // property sheet vgui::PropertySheet *m_pTabPanel; - CFavoriteGames *m_pFavorites; - CHistoryGames *m_pHistory; + CInternetGames *m_pInternetGames; //CSpectateGames *m_pSpectateGames; CLanGames *m_pLanGames; + CFavoriteGames *m_pFavorites; + CHistoryGames *m_pHistory; KeyValues *m_pSavedData; KeyValues *m_pFilterData; diff --git a/serverbrowser/ServerListCompare.cpp b/serverbrowser/ServerListCompare.cpp index f17678bd..6e195f59 100644 --- a/serverbrowser/ServerListCompare.cpp +++ b/serverbrowser/ServerListCompare.cpp @@ -7,15 +7,15 @@ #include "pch_serverbrowser.h" -bool IsReplayServer( gameserveritem_t &server ); +bool IsReplayServer( newgameserver_t &server ); //----------------------------------------------------------------------------- // Purpose: List password column sort function //----------------------------------------------------------------------------- int __cdecl PasswordCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2) { - gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData); - gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData); + newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData); + newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData); if ( !s1 && s2 ) return -1; @@ -37,8 +37,8 @@ int __cdecl PasswordCompare(ListPanel *pPanel, const ListPanelItem &p1, const Li //----------------------------------------------------------------------------- int __cdecl BotsCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2) { - gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData); - gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData); + newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData); + newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData); if ( !s1 && s2 ) return -1; @@ -60,21 +60,6 @@ int __cdecl BotsCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPa //----------------------------------------------------------------------------- int __cdecl SecureCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2) { - gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData); - gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData); - - if ( !s1 && s2 ) - return -1; - if ( !s2 && s1 ) - return 1; - if ( !s1 && !s2 ) - return 0; - - if ( s1->m_bSecure < s2->m_bSecure ) - return 1; - else if ( s1->m_bSecure > s2->m_bSecure ) - return -1; - return 0; } @@ -83,8 +68,8 @@ int __cdecl SecureCompare(ListPanel *pPanel, const ListPanelItem &p1, const List //----------------------------------------------------------------------------- int __cdecl IPAddressCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2) { - gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData); - gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData); + newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData); + newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData); if ( !s1 && s2 ) return -1; @@ -106,8 +91,8 @@ int __cdecl IPAddressCompare(ListPanel *pPanel, const ListPanelItem &p1, const L //----------------------------------------------------------------------------- int __cdecl PingCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2) { - gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData); - gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData); + newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData); + newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData); if ( !s1 && s2 ) return -1; @@ -132,8 +117,8 @@ int __cdecl PingCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPa //----------------------------------------------------------------------------- int __cdecl MapCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2) { - gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData); - gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData); + newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData); + newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData); if ( !s1 && s2 ) return -1; @@ -150,8 +135,8 @@ int __cdecl MapCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPan //----------------------------------------------------------------------------- int __cdecl GameCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2) { - gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData); - gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData); + newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData); + newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData); if ( !s1 && s2 ) return -1; @@ -171,8 +156,8 @@ int __cdecl GameCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPa //----------------------------------------------------------------------------- int __cdecl ServerNameCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2) { - gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData); - gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData); + newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData); + newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData); if ( !s1 && s2 ) return -1; @@ -181,7 +166,7 @@ int __cdecl ServerNameCompare(ListPanel *pPanel, const ListPanelItem &p1, const if ( !s1 && !s2 ) return 0; - return Q_stricmp( s1->GetName(), s2->GetName() ); + return Q_stricmp( s1->m_szServerName, s2->m_szServerName ); } //----------------------------------------------------------------------------- @@ -189,8 +174,8 @@ int __cdecl ServerNameCompare(ListPanel *pPanel, const ListPanelItem &p1, const //----------------------------------------------------------------------------- int __cdecl PlayersCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2) { - gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData); - gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData); + newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData); + newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData); if ( !s1 && s2 ) return -1; @@ -224,22 +209,6 @@ int __cdecl PlayersCompare(ListPanel *pPanel, const ListPanelItem &p1, const Lis //----------------------------------------------------------------------------- int __cdecl LastPlayedCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2) { - gameserveritem_t *s1 = ServerBrowserDialog().GetServer( p1.userData ); - gameserveritem_t *s2 = ServerBrowserDialog().GetServer( p2.userData ); - - if ( !s1 && s2 ) - return -1; - if ( !s2 && s1 ) - return 1; - if ( !s1 && !s2 ) - return 0; - - // compare number of players - if ( s1->m_ulTimeLastPlayed > s2->m_ulTimeLastPlayed ) - return -1; - if ( s1->m_ulTimeLastPlayed < s2->m_ulTimeLastPlayed ) - return 1; - return 0; } @@ -248,8 +217,8 @@ int __cdecl LastPlayedCompare(ListPanel *pPanel, const ListPanelItem &p1, const //----------------------------------------------------------------------------- int __cdecl TagsCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2) { - gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData); - gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData); + newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData); + newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData); if ( !s1 && s2 ) return -1; @@ -266,8 +235,8 @@ int __cdecl TagsCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPa //----------------------------------------------------------------------------- int __cdecl ReplayCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2) { - gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData); - gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData); + newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData); + newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData); if ( !s1 && s2 ) return -1; diff --git a/serverbrowser/igamelist.h b/serverbrowser/igamelist.h index 3944c9b0..3be6fcda 100644 --- a/serverbrowser/igamelist.h +++ b/serverbrowser/igamelist.h @@ -20,7 +20,7 @@ class gameserveritem_t; #include "FindSteamServers.h" #endif #include "netadr.h" - +#include "engine/iserversinfo.h" typedef enum { @@ -75,7 +75,7 @@ public: virtual bool IsRefreshing() = 0; // gets information about specified server - virtual gameserveritem_t *GetServer(unsigned int serverID) = 0; + virtual newgameserver_t *GetServer(unsigned int serverID) = 0; // called when Connect button is pressed virtual void OnBeginConnect() = 0; diff --git a/serverbrowser/pch_serverbrowser.h b/serverbrowser/pch_serverbrowser.h index 8e44f2ba..6812359c 100644 --- a/serverbrowser/pch_serverbrowser.h +++ b/serverbrowser/pch_serverbrowser.h @@ -69,7 +69,7 @@ #include "replay/ienginereplay.h" extern bool GameSupportsReplay(); -extern bool IsReplayServer( gameserveritem_t &server ); +extern bool IsReplayServer( newgameserver_t &server ); #pragma warning( disable: 4355 ) // warning C4355: 'this' : used in base member initializer list