From 41aa50e66ef1c832e0b9f3a9da83575e00e12e1c Mon Sep 17 00:00:00 2001 From: nillerusr Date: Sun, 29 Jan 2023 19:26:04 +0300 Subject: [PATCH] WIP: Begin rewriting serverbrowser --- engine/masterserver.cpp | 16 ++ serverbrowser/BaseGamesPage.cpp | 243 ++++++++++++------ serverbrowser/BaseGamesPage.h | 28 +- serverbrowser/DialogAddServer.cpp | 20 -- serverbrowser/DialogAddServer.h | 14 - serverbrowser/DialogGameInfo.cpp | 30 +-- serverbrowser/FavoriteGames.cpp | 4 +- serverbrowser/FavoriteGames.h | 2 +- serverbrowser/HistoryGames.cpp | 20 +- serverbrowser/HistoryGames.h | 2 +- serverbrowser/InternetGames.cpp | 23 +- serverbrowser/InternetGames.h | 6 +- serverbrowser/LanGames.cpp | 4 +- serverbrowser/LanGames.h | 2 +- serverbrowser/ServerBrowser.cpp | 14 +- serverbrowser/ServerBrowserDialog.cpp | 141 ++-------- serverbrowser/ServerBrowserDialog.h | 15 +- serverbrowser/pch_serverbrowser.h | 6 +- .../{ => unused}/BlacklistedServers.cpp | 0 .../{ => unused}/BlacklistedServers.h | 0 serverbrowser/{ => unused}/CustomGames.cpp | 0 serverbrowser/{ => unused}/CustomGames.h | 0 serverbrowser/{ => unused}/FriendsGames.cpp | 0 serverbrowser/{ => unused}/FriendsGames.h | 0 serverbrowser/{ => unused}/SpectateGames.cpp | 0 serverbrowser/{ => unused}/SpectateGames.h | 0 serverbrowser/wscript | 8 +- 27 files changed, 265 insertions(+), 333 deletions(-) rename serverbrowser/{ => unused}/BlacklistedServers.cpp (100%) rename serverbrowser/{ => unused}/BlacklistedServers.h (100%) rename serverbrowser/{ => unused}/CustomGames.cpp (100%) rename serverbrowser/{ => unused}/CustomGames.h (100%) rename serverbrowser/{ => unused}/FriendsGames.cpp (100%) rename serverbrowser/{ => unused}/FriendsGames.h (100%) rename serverbrowser/{ => unused}/SpectateGames.cpp (100%) rename serverbrowser/{ => unused}/SpectateGames.h (100%) diff --git a/engine/masterserver.cpp b/engine/masterserver.cpp index 62d7e614..f3803d45 100644 --- a/engine/masterserver.cpp +++ b/engine/masterserver.cpp @@ -80,6 +80,8 @@ private: bool m_bNoMasters; CUtlLinkedList m_serverAddresses; + + IServerListResponse *m_serverListResponse; }; static CMaster s_MasterServer; @@ -87,6 +89,8 @@ IMaster *master = (IMaster *)&s_MasterServer; IServersInfo *g_pServersInfo = (IServersInfo*)&s_MasterServer; +EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CMaster, IServersInfo, SERVERLIST_INTERFACE_VERSION, s_MasterServer ); + #define HEARTBEAT_SECONDS 140.0 //----------------------------------------------------------------------------- @@ -97,6 +101,9 @@ CMaster::CMaster( void ) m_pMasterAddresses = NULL; m_bNoMasters = false; m_bInitialized = false; + + m_serverListResponse = NULL; + Init(); } @@ -165,6 +172,11 @@ void CMaster::ProcessConnectionlessPacket( netpacket_t *packet ) char hostname[1024]; msg.ReadString(hostname, sizeof(hostname)); + newgameserver_t s; + s.m_NetAdr = packet->from; + s.SetName( hostname ); + + m_serverListResponse->ServerResponded( s ); break; } } @@ -180,6 +192,8 @@ void CMaster::RequestServersInfo() { const netadr_t adr = m_serverAddresses[i]; + Msg("Request server info %s\n", adr.ToString()); + msg.WriteLong( CONNECTIONLESS_HEADER ); msg.WriteByte( C2S_INFOREQUEST ); @@ -474,6 +488,8 @@ void CMaster::RequestInternetServerList(const char *gamedir, IServerListResponse { if( m_bNoMasters ) return; + m_serverListResponse = response; + ALIGN4 char buf[256] ALIGN4_POST; bf_write msg(buf, sizeof(buf)); diff --git a/serverbrowser/BaseGamesPage.cpp b/serverbrowser/BaseGamesPage.cpp index 6cef8827..e0f80b63 100644 --- a/serverbrowser/BaseGamesPage.cpp +++ b/serverbrowser/BaseGamesPage.cpp @@ -322,7 +322,7 @@ void CBaseGamesPage::PerformLayout() m_pRefreshQuick->SetEnabled(false); } - if ( !steamapicontext->SteamMatchmakingServers() || !steamapicontext->SteamMatchmaking() ) +/* if ( !steamapicontext->SteamMatchmakingServers() || !steamapicontext->SteamMatchmaking() ) { m_pAddCurrentServer->SetVisible( false ); m_pRefreshQuick->SetEnabled( false ); @@ -331,7 +331,7 @@ void CBaseGamesPage::PerformLayout() m_pRefreshAll->SetEnabled( false ); m_pAddToFavoritesButton->SetEnabled( false ); m_pGameList->SetEmptyListText( "#ServerBrowser_SteamRunning" ); - } + }*/ Repaint(); } @@ -797,19 +797,19 @@ void CBaseGamesPage::UpdateGameFilter() // Purpose: Handles incoming server refresh data // updates the server browser with the refreshed information from the server itself //----------------------------------------------------------------------------- -void CBaseGamesPage::ServerResponded( gameserveritem_t &server ) +/*void CBaseGamesPage::ServerResponded( gameserveritem_t &server ) { int nIndex = -1; // start at -1 and work backwards to find the next free slot for this adhoc query while ( m_mapServers.Find( nIndex ) != m_mapServers.InvalidIndex() ) nIndex--; ServerResponded( nIndex, &server ); -} +}*/ //----------------------------------------------------------------------------- // Purpose: Callback for ISteamMatchmakingServerListResponse //----------------------------------------------------------------------------- -void CBaseGamesPage::ServerResponded( HServerListRequest hReq, int iServer ) +/*void CBaseGamesPage::ServerResponded( HServerListRequest hReq, int iServer ) { gameserveritem_t *pServerItem = steamapicontext->SteamMatchmakingServers()->GetServerDetails( hReq, iServer ); if ( !pServerItem ) @@ -825,15 +825,17 @@ void CBaseGamesPage::ServerResponded( HServerListRequest hReq, int iServer ) pServerItem->m_nMaxPlayers = (uint8)(int8)pServerItem->m_nMaxPlayers; ServerResponded( iServer, pServerItem ); -} +}*/ //----------------------------------------------------------------------------- // Purpose: Handles incoming server refresh data // updates the server browser with the refreshed information from the server itself //----------------------------------------------------------------------------- + void CBaseGamesPage::ServerResponded( int iServer, gameserveritem_t *pServerItem ) { +#if 0 int iServerMap = m_mapServers.Find( iServer ); if ( iServerMap == m_mapServers.InvalidIndex() ) { @@ -988,6 +990,7 @@ void CBaseGamesPage::ServerResponded( int iServer, gameserveritem_t *pServerItem PrepareQuickListMap( pServerItem->m_szMap, pServer->m_iListID ); UpdateStatus(); m_iServerRefreshCount++; +#endif } //----------------------------------------------------------------------------- @@ -1143,11 +1146,10 @@ void CBaseGamesPage::OnTextChanged(Panel *panel, const char *text) //----------------------------------------------------------------------------- void CBaseGamesPage::ApplyGameFilters() { +#if 0 if ( !steamapicontext->SteamMatchmakingServers() ) return; - m_iServersBlacklisted = 0; - // loop through all the servers checking filters FOR_EACH_MAP_FAST( m_mapServers, i ) { @@ -1215,6 +1217,7 @@ void CBaseGamesPage::ApplyGameFilters() m_pGameList->SortList(); InvalidateLayout(); Repaint(); +#endif } //----------------------------------------------------------------------------- @@ -1224,14 +1227,10 @@ void CBaseGamesPage::UpdateStatus() { if (m_pGameList->GetItemCount() > 1) { - wchar_t header[256]; - wchar_t count[128]; - wchar_t blacklistcount[128]; + wchar_t msg[256]; - _snwprintf( count, Q_ARRAYSIZE(count), L"%d", m_pGameList->GetItemCount() ); - _snwprintf( blacklistcount, Q_ARRAYSIZE(blacklistcount), L"%d", m_iServersBlacklisted ); - g_pVGuiLocalize->ConstructString( header, sizeof( header ), g_pVGuiLocalize->Find( "#ServerBrowser_ServersCountWithBlacklist"), 2, count, blacklistcount ); - m_pGameList->SetColumnHeaderText( k_nColumn_Name, header); + _snwprintf( msg, Q_ARRAYSIZE(msg), L"%S( %d )", g_pVGuiLocalize->Find( "#ServerBrowser_Servers"), m_pGameList->GetItemCount() ); + m_pGameList->SetColumnHeaderText( k_nColumn_Name, msg); } else { @@ -1529,19 +1528,12 @@ void CBaseGamesPage::RecalculateFilterString() // Purpose: Checks to see if the server passes the primary filters // if the server fails the filters, it will not be refreshed again //----------------------------------------------------------------------------- -bool CBaseGamesPage::CheckPrimaryFilters( gameserveritem_t &server ) +bool CBaseGamesPage::CheckPrimaryFilters( newgameserver_t &server ) { - if (m_szGameFilter[0] && ( server.m_szGameDir[0] || server.m_nPing ) && Q_stricmp(m_szGameFilter, server.m_szGameDir ) ) + if (m_szGameFilter[0] && server.m_szGameDir[0] && Q_stricmp(m_szGameFilter, server.m_szGameDir ) ) { return false; } - - // If it's blacklisted, we ignore it too - if ( ServerBrowserDialog().IsServerBlacklisted( server ) ) - { - m_iServersBlacklisted++; - return false; - } return true; } @@ -1551,7 +1543,7 @@ bool CBaseGamesPage::CheckPrimaryFilters( gameserveritem_t &server ) // server will be continued to be pinged if it fails the filter, since // the relvent server data is dynamic //----------------------------------------------------------------------------- -bool CBaseGamesPage::CheckSecondaryFilters( gameserveritem_t &server ) +bool CBaseGamesPage::CheckSecondaryFilters( newgameserver_t &server ) { bool bFilterNoEmpty = m_bFilterNoEmptyServers; bool bFilterNoFull = m_bFilterNoFullServers; @@ -1595,7 +1587,7 @@ bool CBaseGamesPage::CheckSecondaryFilters( gameserveritem_t &server ) return false; } - if ( iFilterSecure == FILTER_SECURESERVERSONLY && !server.m_bSecure ) + /*if ( iFilterSecure == FILTER_SECURESERVERSONLY && !server.m_bSecure ) { return false; } @@ -1608,7 +1600,7 @@ bool CBaseGamesPage::CheckSecondaryFilters( gameserveritem_t &server ) if ( m_bFilterReplayServers && !IsReplayServer( server ) ) { return false; - } + }*/ if ( m_pQuickList->IsVisible() == false ) { @@ -1787,37 +1779,15 @@ void CBaseGamesPage::OnAddToFavorites() } } -//----------------------------------------------------------------------------- -// Purpose: adds a server to the blacklist -//----------------------------------------------------------------------------- -void CBaseGamesPage::OnAddToBlacklist() -{ - if ( !steamapicontext->SteamMatchmakingServers() ) - return; - - // loop through all the selected favorites - for (int i = 0; i < m_pGameList->GetSelectedItemsCount(); i++) - { - int serverID = m_pGameList->GetItemUserData(m_pGameList->GetSelectedItem(i)); - - gameserveritem_t *pServer = steamapicontext->SteamMatchmakingServers()->GetServerDetails( m_hRequest, serverID ); - if ( pServer ) - { - ServerBrowserDialog().AddServerToBlacklist(*pServer); - } - } - ServerBrowserDialog().BlacklistsChanged(); -} - - //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- +#if 0 void CBaseGamesPage::ServerFailedToRespond( HServerListRequest hReq, int iServer ) { ServerResponded( hReq, iServer ); } - +#endif //----------------------------------------------------------------------------- // Purpose: removes the server from the UI list @@ -1864,41 +1834,37 @@ void CBaseGamesPage::OnRefreshServer( int serverID ) //----------------------------------------------------------------------------- void CBaseGamesPage::StartRefresh() { - if ( !steamapicontext->SteamMatchmakingServers() ) - return; - ClearServerList(); MatchMakingKeyValuePair_t *pFilters; int nFilters = GetServerFilters( &pFilters ); - if ( m_hRequest ) +/* if ( m_hRequest ) { steamapicontext->SteamMatchmakingServers()->ReleaseRequest( m_hRequest ); m_hRequest = NULL; - } + }*/ switch ( m_eMatchMakingType ) { - case eFavoritesServer: +/* case eFavoritesServer: m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestFavoritesServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this ); break; case eHistoryServer: m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestHistoryServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this ); - break; + break;*/ case eInternetServer: - m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestInternetServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this ); + Msg("RequestInternetServerList\n"); + g_pServersInfo->RequestInternetServerList(COM_GetModDirectory(), this); + //m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestInternetServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this ); break; - case eSpectatorServer: +/* case eSpectatorServer: m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestSpectatorServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this ); break; - case eFriendsServer: - m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestFriendsServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this ); - break; case eLANServer: m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestLANServerList( GetFilterAppID().AppID(), this ); break; default: Assert( !"Unknown server type" ); - break; + break;*/ } SetRefreshing( true ); @@ -1936,7 +1902,6 @@ void CBaseGamesPage::ClearServerList() m_mapServers.RemoveAll(); m_mapServerIP.RemoveAll(); m_pGameList->RemoveAll(); - m_iServersBlacklisted = 0; ClearQuickList(); } @@ -1964,7 +1929,7 @@ void CBaseGamesPage::StopRefresh() steamapicontext->SteamMatchmakingServers()->CancelQuery( m_hRequest ); // update UI - RefreshComplete( m_hRequest, eServerResponded ); + RefreshComplete( nServerResponded ); // apply settings ApplyGameFilters(); @@ -1973,7 +1938,7 @@ void CBaseGamesPage::StopRefresh() //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- -void CBaseGamesPage::RefreshComplete( HServerListRequest hRequest, EMatchMakingServerResponse response ) +void CBaseGamesPage::RefreshComplete( NServerResponse response ) { SelectQuickListServers(); } @@ -2116,7 +2081,7 @@ void CDialogServerWarning::OnCommand(const char *command) PostMessage(this, new KeyValues("Close")); // join the game - ServerBrowserDialog().JoinGame( m_pGameList, m_iServerID ); + //ServerBrowserDialog().JoinGame( m_pGameList, m_iServerID ); } else { @@ -2142,16 +2107,16 @@ void CDialogServerWarning::OnButtonToggled(Panel *panel, int state) void CBaseGamesPage::OnBeginConnect() { KeyValues *pKV = NULL; - int serverID = GetSelectedServerID( &pKV ); + int iServerIndex = GetSelectedServerID( &pKV ); - if ( serverID == -1 ) + if ( iServerIndex == -1 ) return; // Stop the current refresh StopRefresh(); ConVarRef sb_dontshow_maxplayer_warning( "sb_dontshow_maxplayer_warning", true ); - if ( sb_dontshow_maxplayer_warning.IsValid() ) +/* if ( sb_dontshow_maxplayer_warning.IsValid() ) { // If the server is above the suggested maxplayers, warn the player int iMaxP = sb_mod_suggested_maxplayers.GetInt(); @@ -2177,10 +2142,10 @@ void CBaseGamesPage::OnBeginConnect() return; } } - } + }*/ // join the game - ServerBrowserDialog().JoinGame(this, serverID); + ServerBrowserDialog().JoinGame(this, &m_serversInfo[iServerIndex]); } //----------------------------------------------------------------------------- @@ -2197,7 +2162,7 @@ void CBaseGamesPage::OnViewGameInfo() StopRefresh(); // join the game - ServerBrowserDialog().OpenGameInfoDialog(this, serverID); + //ServerBrowserDialog().OpenGameInfoDialog(this, serverID); } //----------------------------------------------------------------------------- @@ -2222,9 +2187,6 @@ const char *CBaseGamesPage::GetConnectCode() case eLANServer: pszConnectCode = "serverbrowser_lan"; break; - case eFriendsServer: - pszConnectCode = "serverbrowser_friends"; - break; case eFavoritesServer: pszConnectCode = "serverbrowser_favorites"; break; @@ -2239,6 +2201,119 @@ const char *CBaseGamesPage::GetConnectCode() return pszConnectCode; } +void CBaseGamesPage::ServerResponded( newgameserver_t &server ) +{ + Msg("Serverbrowser: hostname %s\n", server.GetName()); + + Assert( server.m_NetAdr.GetIP() != 0 ); + + newgameserver_t *pServerItem = &server; + + // check filters + bool removeItem = false; +#if 0 + if ( !CheckPrimaryFilters( server ) ) + { + // server has been filtered at a primary level + // remove from lists + //pServer->m_bDoNotRefresh = true; + + // remove from UI list + //removeItem = true; + return; + } + else if (!CheckSecondaryFilters( server )) + { + // we still ping this server in the future; however it is removed from UI list + return; + } +#endif + + // new entry + KeyValues *kv = new KeyValues("Server"); + + kv->SetString("name", pServerItem->GetName()); + kv->SetString("map", pServerItem->m_szMap); + 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("secure", 0); + + kv->SetString( "IPAddr", pServerItem->m_NetAdr.ToString() ); + + int nAdjustedForBotsPlayers = max( 0, pServerItem->m_nPlayers - pServerItem->m_nBotPlayers ); + + char buf[32]; + Q_snprintf(buf, sizeof(buf), "%d / %d", nAdjustedForBotsPlayers, pServerItem->m_nMaxPlayers ); + kv->SetString("Players", buf); + + kv->SetInt("PlayerCount", nAdjustedForBotsPlayers ); + kv->SetInt("MaxPlayerCount", pServerItem->m_nMaxPlayers ); + + kv->SetInt("Ping", pServerItem->m_nPing); + + kv->SetString("Tags", ""); + + 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); + } + }*/ + +// if ( pServer->m_bDoNotRefresh ) + { + // clear out the vars + kv->SetString("Ping", ""); + kv->SetWString("GameDesc", g_pVGuiLocalize->Find("#ServerBrowser_NotResponding")); + kv->SetString("Players", ""); + kv->SetString("map", ""); + } + + 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); + /*if ( m_bAutoSelectFirstItemInGameList && m_pGameList->GetItemCount() == 1 ) + { + m_pGameList->AddSelectedItem( pServer->m_iListID ); + }*/ + + 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 ); + UpdateStatus(); + m_iServerRefreshCount++; + +} //----------------------------------------------------------------------------- // Purpose: Refresh if our favorites list changed @@ -2252,8 +2327,6 @@ void CBaseGamesPage::OnFavoritesMsg( FavoritesListChanged_t *pFavListChanged ) case eInternetServer: case eLANServer: case eSpectatorServer: - case eFriendsServer: - return; case eFavoritesServer: case eHistoryServer: // check containing property sheet to see if the page is visible. @@ -2276,8 +2349,6 @@ void CBaseGamesPage::OnFavoritesMsg( FavoritesListChanged_t *pFavListChanged ) case eInternetServer: case eLANServer: case eSpectatorServer: - case eFriendsServer: - break; case eFavoritesServer: case eHistoryServer: { @@ -2286,8 +2357,10 @@ void CBaseGamesPage::OnFavoritesMsg( FavoritesListChanged_t *pFavListChanged ) { if ( pFavListChanged->m_bAdd ) { - if ( steamapicontext->SteamMatchmakingServers() ) - steamapicontext->SteamMatchmakingServers()->PingServer( pFavListChanged->m_nIP, pFavListChanged->m_nQueryPort, this ); + + // TODO(nillerusr): implement this + // if ( steamapicontext->SteamMatchmakingServers() ) + // steamapicontext->SteamMatchmakingServers()->PingServer( pFavListChanged->m_nIP, pFavListChanged->m_nQueryPort, this ); } // ignore deletes of fav's we didn't have } @@ -2295,8 +2368,8 @@ void CBaseGamesPage::OnFavoritesMsg( FavoritesListChanged_t *pFavListChanged ) { if ( pFavListChanged->m_bAdd ) { - if ( m_mapServerIP[ iIPServer ] > 0 ) - ServerResponded( m_hRequest, m_mapServerIP[ iIPServer ] ); + // if ( m_mapServerIP[ iIPServer ] > 0 ) + // ServerResponded( m_hRequest, m_mapServerIP[ iIPServer ] ); } else { diff --git a/serverbrowser/BaseGamesPage.h b/serverbrowser/BaseGamesPage.h index 2d69b1d1..fca73685 100644 --- a/serverbrowser/BaseGamesPage.h +++ b/serverbrowser/BaseGamesPage.h @@ -12,6 +12,7 @@ #endif #include "tier1/utldict.h" +#include "engine/iserversinfo.h" class CBaseGamesPage; @@ -82,7 +83,7 @@ struct gametypes_t //----------------------------------------------------------------------------- // Purpose: Base property page for all the games lists (internet/favorites/lan/etc.) //----------------------------------------------------------------------------- -class CBaseGamesPage : public vgui::PropertyPage, public IGameList, public ISteamMatchmakingServerListResponse, public ISteamMatchmakingPingResponse +class CBaseGamesPage : public vgui::PropertyPage, public IGameList, public IServerListResponse //, public ISteamMatchmakingPingResponse { DECLARE_CLASS_SIMPLE( CBaseGamesPage, vgui::PropertyPage ); @@ -138,7 +139,6 @@ public: // adds a server to the favorites MESSAGE_FUNC( OnAddToFavorites, "AddToFavorites" ); - MESSAGE_FUNC( OnAddToBlacklist, "AddToBlacklist" ); virtual void StartRefresh(); @@ -173,14 +173,14 @@ protected: void UpdateStatus(); // ISteamMatchmakingServerListResponse callbacks - virtual void ServerResponded( HServerListRequest hReq, int iServer ); - virtual void ServerResponded( int iServer, gameserveritem_t *pServerItem ); - virtual void ServerFailedToRespond( HServerListRequest hReq, int iServer ); - virtual void RefreshComplete( HServerListRequest hReq, EMatchMakingServerResponse response ) = 0; + virtual void ServerResponded( newgameserver_t &server ); + virtual void RefreshComplete( NServerResponse response ); // ISteamMatchmakingPingResponse callbacks - virtual void ServerResponded( gameserveritem_t &server ); - virtual void ServerFailedToRespond() {} + //virtual void ServerResponded( gameserveritem_t &server ); + //virtual void ServerFailedToRespond() {} + + virtual void ServerResponded( int iServer, gameserveritem_t *pServerItem ); // Removes server from list void RemoveServer( serverdisplay_t &server ); @@ -190,10 +190,10 @@ protected: // filtering methods // returns true if filters passed; false if failed - virtual bool CheckPrimaryFilters( gameserveritem_t &server); - virtual bool CheckSecondaryFilters( gameserveritem_t &server ); - virtual bool CheckTagFilter( gameserveritem_t &server ) { return true; } - virtual bool CheckWorkshopFilter( gameserveritem_t &server ) { return true; } + virtual bool CheckPrimaryFilters( newgameserver_t &server); + virtual bool CheckSecondaryFilters( newgameserver_t &server ); + virtual bool CheckTagFilter( newgameserver_t &server ) { return true; } + virtual bool CheckWorkshopFilter( newgameserver_t &server ) { return true; } virtual int GetInvalidServerListID(); virtual void OnSaveFilter(KeyValues *filter); @@ -236,6 +236,9 @@ protected: CUtlMap m_mapGamesFilterItem; CUtlMap m_mapServers; CUtlMap m_mapServerIP; + + CUtlVector m_serversInfo; + CUtlVector m_vecServerFilters; CUtlDict< CQuickListMapServerList, int > m_quicklistserverlist; int m_iServerRefreshCount; @@ -316,7 +319,6 @@ private: bool m_bFilterNoEmptyServers; bool m_bFilterNoPasswordedServers; int m_iSecureFilter; - int m_iServersBlacklisted; bool m_bFilterReplayServers; CGameID m_iLimitToAppID; diff --git a/serverbrowser/DialogAddServer.cpp b/serverbrowser/DialogAddServer.cpp index cbba58eb..5dbc9ed5 100644 --- a/serverbrowser/DialogAddServer.cpp +++ b/serverbrowser/DialogAddServer.cpp @@ -370,23 +370,3 @@ void CDialogAddServer::FinishAddServer( gameserveritem_t &pServer ) { ServerBrowserDialog().AddServerToFavorites( pServer ); } - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -void CDialogAddBlacklistedServer::FinishAddServer( gameserveritem_t &pServer ) -{ - ServerBrowserDialog().AddServerToBlacklist( pServer ); - ServerBrowserDialog().BlacklistsChanged(); -} - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -void CDialogAddBlacklistedServer::ApplySchemeSettings( vgui::IScheme *pScheme ) -{ - BaseClass::ApplySchemeSettings( pScheme ); - - m_pAddServerButton->SetText( "#ServerBrowser_AddAddressToBlacklist" ); - m_pAddSelectedServerButton->SetText( "#ServerBrowser_AddSelectedToBlacklist" ); -} diff --git a/serverbrowser/DialogAddServer.h b/serverbrowser/DialogAddServer.h index 7abaee1a..c340904b 100644 --- a/serverbrowser/DialogAddServer.h +++ b/serverbrowser/DialogAddServer.h @@ -58,18 +58,4 @@ protected: CUtlVector m_Queries; }; -class CDialogAddBlacklistedServer : public CDialogAddServer -{ - DECLARE_CLASS_SIMPLE( CDialogAddBlacklistedServer, CDialogAddServer ); -public: - CDialogAddBlacklistedServer( vgui::Panel *parent, IGameList *gameList) : - CDialogAddServer( parent, gameList ) - { - } - - virtual void FinishAddServer( gameserveritem_t &pServer ); - void ApplySchemeSettings( vgui::IScheme *pScheme ); - virtual bool AllowInvalidIPs( void ) { return true; } -}; - #endif // DIALOGADDSERVER_H diff --git a/serverbrowser/DialogGameInfo.cpp b/serverbrowser/DialogGameInfo.cpp index fc0ed36c..ce54f477 100644 --- a/serverbrowser/DialogGameInfo.cpp +++ b/serverbrowser/DialogGameInfo.cpp @@ -293,7 +293,10 @@ void CDialogGameInfo::PerformLayout() } SetControlString("PlayersText", buf); - if ( m_Server.m_NetAdr.GetIP() && m_Server.m_NetAdr.GetQueryPort() ) + SetControlString("ServerIPText", m_Server.m_NetAdr.GetConnectionAddressString() ); + m_pConnectButton->SetEnabled(true); + +/* if ( m_Server.m_NetAdr.GetIP() && m_Server.m_NetAdr.GetQueryPort() ) { SetControlString("ServerIPText", m_Server.m_NetAdr.GetConnectionAddressString() ); m_pConnectButton->SetEnabled(true); @@ -312,7 +315,7 @@ void CDialogGameInfo::PerformLayout() { SetControlString("ServerIPText", ""); m_pConnectButton->SetEnabled(false); - } + }*/ if ( m_Server.m_bHadSuccessfulResponse ) { @@ -405,7 +408,11 @@ void CDialogGameInfo::OnConnect() // need to refresh server before attempting to connect, to make sure there is enough room on the server m_iRequestRetry = 0; - RequestInfo(); + + ConnectToServer(); + + //TODO(nillerusr): restore this later + //RequestInfo(); } //----------------------------------------------------------------------------- @@ -633,17 +640,6 @@ void CDialogGameInfo::ConnectToServer() { m_bConnecting = false; - // check VAC status - if ( m_Server.m_bSecure && ServerBrowser().IsVACBannedFromGame( m_Server.m_nAppID ) ) - { - // refuse the user - CVACBannedConnRefusedDialog *pDlg = new CVACBannedConnRefusedDialog( GetVParent(), "VACBannedConnRefusedDialog" ); - pDlg->Activate(); - Close(); - return; - } - - // check to see if we need a password if ( m_Server.m_bPassword && !m_szPassword[0] ) { @@ -654,7 +650,9 @@ void CDialogGameInfo::ConnectToServer() } // check the player count - if ( m_Server.m_nPlayers >= m_Server.m_nMaxPlayers ) + + // nillerusr + /*if ( m_Server.m_nPlayers >= m_Server.m_nMaxPlayers ) { // mark why we cannot connect m_bServerFull = true; @@ -662,7 +660,7 @@ void CDialogGameInfo::ConnectToServer() m_bShowAutoRetryToggle = true; InvalidateLayout(); return; - } + }*/ // tell the engine to connect const char *gameDir = m_Server.m_szGameDir; diff --git a/serverbrowser/FavoriteGames.cpp b/serverbrowser/FavoriteGames.cpp index 0149baf1..a9306cc2 100644 --- a/serverbrowser/FavoriteGames.cpp +++ b/serverbrowser/FavoriteGames.cpp @@ -73,7 +73,7 @@ bool CFavoriteGames::SupportsItem(InterfaceItem_e item) //----------------------------------------------------------------------------- // Purpose: called when the current refresh list is complete //----------------------------------------------------------------------------- -void CFavoriteGames::RefreshComplete( HServerListRequest hReq, EMatchMakingServerResponse response ) +void CFavoriteGames::RefreshComplete( NServerResponse response ) { SetRefreshing(false); if ( steamapicontext->SteamMatchmaking() && steamapicontext->SteamMatchmaking()->GetFavoriteGameCount() == 0 ) @@ -88,7 +88,7 @@ void CFavoriteGames::RefreshComplete( HServerListRequest hReq, EMatchMakingServe } m_pGameList->SortList(); - BaseClass::RefreshComplete( hReq, response ); + BaseClass::RefreshComplete( response ); } //----------------------------------------------------------------------------- diff --git a/serverbrowser/FavoriteGames.h b/serverbrowser/FavoriteGames.h index 8355005a..242670ea 100644 --- a/serverbrowser/FavoriteGames.h +++ b/serverbrowser/FavoriteGames.h @@ -30,7 +30,7 @@ public: virtual bool SupportsItem(InterfaceItem_e item); // called when the current refresh list is complete - virtual void RefreshComplete( HServerListRequest hReq, EMatchMakingServerResponse response ); + virtual void RefreshComplete( NServerResponse response ); // passed from main server browser window instead of messages void OnConnectToGame(); diff --git a/serverbrowser/HistoryGames.cpp b/serverbrowser/HistoryGames.cpp index 565c313e..ad93e3da 100644 --- a/serverbrowser/HistoryGames.cpp +++ b/serverbrowser/HistoryGames.cpp @@ -18,16 +18,6 @@ CHistoryGames::CHistoryGames(vgui::Panel *parent) : m_pGameList->AddColumnHeader(10, "LastPlayed", "#ServerBrowser_LastPlayed", 100); m_pGameList->SetSortFunc(10, LastPlayedCompare); m_pGameList->SetSortColumn(10); - - if ( !IsSteamGameServerBrowsingEnabled() ) - { - m_pGameList->SetEmptyListText("#ServerBrowser_OfflineMode"); - m_pConnect->SetEnabled( false ); - m_pRefreshAll->SetEnabled( false ); - m_pRefreshQuick->SetEnabled( false ); - m_pAddServer->SetEnabled( false ); - m_pFilter->SetEnabled( false ); - } } //----------------------------------------------------------------------------- @@ -42,12 +32,6 @@ CHistoryGames::~CHistoryGames() //----------------------------------------------------------------------------- void CHistoryGames::LoadHistoryList() { - if ( IsSteamGameServerBrowsingEnabled() ) - { - // set empty message - m_pGameList->SetEmptyListText("#ServerBrowser_NoServersPlayed"); - } - if ( m_bRefreshOnListReload ) { m_bRefreshOnListReload = false; @@ -77,13 +61,13 @@ bool CHistoryGames::SupportsItem(InterfaceItem_e item) //----------------------------------------------------------------------------- // Purpose: called when the current refresh list is complete //----------------------------------------------------------------------------- -void CHistoryGames::RefreshComplete( HServerListRequest hReq, EMatchMakingServerResponse response ) +void CHistoryGames::RefreshComplete( NServerResponse response ) { SetRefreshing(false); m_pGameList->SetEmptyListText("#ServerBrowser_NoServersPlayed"); m_pGameList->SortList(); - BaseClass::RefreshComplete( hReq, response ); + BaseClass::RefreshComplete( response ); } //----------------------------------------------------------------------------- diff --git a/serverbrowser/HistoryGames.h b/serverbrowser/HistoryGames.h index 6dbbf447..14af807c 100644 --- a/serverbrowser/HistoryGames.h +++ b/serverbrowser/HistoryGames.h @@ -30,7 +30,7 @@ public: virtual bool SupportsItem(InterfaceItem_e item); // called when the current refresh list is complete - virtual void RefreshComplete( HServerListRequest hReq, EMatchMakingServerResponse response ); + virtual void RefreshComplete( NServerResponse response ); void SetRefreshOnReload() { m_bRefreshOnListReload = true; } diff --git a/serverbrowser/InternetGames.cpp b/serverbrowser/InternetGames.cpp index 208bea45..afe94f90 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 = !IsSteamGameServerBrowsingEnabled(); + m_bOfflineMode = false; //ro!IsSteamGameServerBrowsingEnabled(); m_bAnyServersRetrievedFromMaster = false; m_bNoServersListedOnMaster = false; @@ -124,19 +124,20 @@ void CInternetGames::OnTick() // Purpose: Handles incoming server refresh data // updates the server browser with the refreshed information from the server itself //----------------------------------------------------------------------------- -void CInternetGames::ServerResponded( HServerListRequest hReq, int iServer ) +void CInternetGames::ServerResponded( newgameserver_t &server ) { m_bDirty = true; - BaseClass::ServerResponded( hReq, iServer ); + Msg("InternetGames::ServerResponded hostname = %s\n", server.GetName()); + + BaseClass::ServerResponded( server ); m_bAnyServersRespondedToQuery = true; m_bAnyServersRetrievedFromMaster = true; } - //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- -void CInternetGames::ServerFailedToRespond( HServerListRequest hReq, int iServer ) +/*void CInternetGames::ServerFailedToRespond( HServerListRequest hReq, int iServer ) { m_bDirty = true; gameserveritem_t *pServer = steamapicontext->SteamMatchmakingServers()->GetServerDetails( hReq, iServer ); @@ -145,7 +146,7 @@ void CInternetGames::ServerFailedToRespond( HServerListRequest hReq, int iServer if ( pServer->m_bHadSuccessfulResponse ) { // if it's had a successful response in the past, leave it on - ServerResponded( hReq, iServer ); + //ServerResponded( hReq, iServer ); } else { @@ -155,24 +156,24 @@ void CInternetGames::ServerFailedToRespond( HServerListRequest hReq, int iServer // we've never had a good response from this server, remove it from the list m_iServerRefreshCount++; } -} +}*/ //----------------------------------------------------------------------------- // Purpose: Called when server refresh has been completed //----------------------------------------------------------------------------- -void CInternetGames::RefreshComplete( HServerListRequest hReq, EMatchMakingServerResponse response ) +void CInternetGames::RefreshComplete( NServerResponse response ) { SetRefreshing(false); UpdateFilterSettings(); - if ( response != eServerFailedToRespond ) + if ( response != nServerFailedToRespond ) { if ( m_bAnyServersRespondedToQuery ) { m_pGameList->SetEmptyListText( GetStringNoUnfilteredServers() ); } - else if ( response == eNoServersListedOnMasterServer ) + else if ( response == nNoServersListedOnMasterServer ) { m_pGameList->SetEmptyListText( GetStringNoUnfilteredServersOnMaster() ); } @@ -196,7 +197,7 @@ void CInternetGames::RefreshComplete( HServerListRequest hReq, EMatchMakingServe UpdateStatus(); - BaseClass::RefreshComplete( hReq, response ); + BaseClass::RefreshComplete( response ); } diff --git a/serverbrowser/InternetGames.h b/serverbrowser/InternetGames.h index 8779d1f2..3f17d296 100644 --- a/serverbrowser/InternetGames.h +++ b/serverbrowser/InternetGames.h @@ -35,9 +35,9 @@ public: MESSAGE_FUNC( GetNewServerList, "GetNewServerList" ); // serverlist refresh responses - virtual void ServerResponded( HServerListRequest hReq, int iServer ); - virtual void ServerFailedToRespond( HServerListRequest hReq, int iServer ); - virtual void RefreshComplete( HServerListRequest hReq, EMatchMakingServerResponse response ); + virtual void ServerResponded( newgameserver_t &server ); + //virtual void ServerFailedToRespond( HServerListRequest hReq, int iServer ); + virtual void RefreshComplete( NServerResponse response ); MESSAGE_FUNC_INT( OnRefreshServer, "RefreshServer", serverID ); virtual int GetRegionCodeToFilter(); diff --git a/serverbrowser/LanGames.cpp b/serverbrowser/LanGames.cpp index c375845d..131869cb 100644 --- a/serverbrowser/LanGames.cpp +++ b/serverbrowser/LanGames.cpp @@ -127,7 +127,7 @@ void CLanGames::ServerFailedToRespond( HServerListRequest hReq, int iServer ) //----------------------------------------------------------------------------- // Purpose: called when the current refresh list is complete //----------------------------------------------------------------------------- -void CLanGames::RefreshComplete( HServerListRequest hReq, EMatchMakingServerResponse response ) +void CLanGames::RefreshComplete( NServerResponse response ) { SetRefreshing( false ); m_pGameList->SortList(); @@ -135,7 +135,7 @@ void CLanGames::RefreshComplete( HServerListRequest hReq, EMatchMakingServerResp m_pGameList->SetEmptyListText("#ServerBrowser_NoLanServers"); SetEmptyListText(); - BaseClass::RefreshComplete( hReq, response ); + BaseClass::RefreshComplete( response ); } void CLanGames::SetEmptyListText() diff --git a/serverbrowser/LanGames.h b/serverbrowser/LanGames.h index f1e3afaa..8ff2233d 100644 --- a/serverbrowser/LanGames.h +++ b/serverbrowser/LanGames.h @@ -49,7 +49,7 @@ public: virtual void ServerFailedToRespond( HServerListRequest hReq, int iServer ); // called when the current refresh list is complete - virtual void RefreshComplete( HServerListRequest hReq, EMatchMakingServerResponse response ); + virtual void RefreshComplete( NServerResponse response ); // Tell the game list what to put in there when there are no games found. virtual void SetEmptyListText(); diff --git a/serverbrowser/ServerBrowser.cpp b/serverbrowser/ServerBrowser.cpp index ff66bbbf..20268a2f 100644 --- a/serverbrowser/ServerBrowser.cpp +++ b/serverbrowser/ServerBrowser.cpp @@ -19,6 +19,7 @@ CServerBrowser &ServerBrowser() } IRunGameEngine *g_pRunGameEngine = NULL; +IServersInfo *g_pServersInfo = NULL; static CSteamAPIContext g_SteamAPIContext; CSteamAPIContext *steamapicontext = &g_SteamAPIContext; @@ -79,11 +80,12 @@ bool CServerBrowser::Initialize(CreateInterfaceFn *factorylist, int factoryCount for ( int i = 0; i < factoryCount; ++i ) { if ( !g_pEngineReplay ) - { g_pEngineReplay = ( IEngineReplay * )factorylist[ i ]( ENGINE_REPLAY_INTERFACE_VERSION, NULL ); - } + if( !g_pServersInfo ) + g_pServersInfo = ( IServersInfo * )factorylist[ i ]( SERVERLIST_INTERFACE_VERSION, NULL ); } + SteamAPI_InitSafe(); SteamAPI_SetTryCatchCallbacks( false ); // We don't use exceptions, so tell steam not to use try/catch in callback handlers steamapicontext->Init(); @@ -304,7 +306,7 @@ void CServerBrowser::Shutdown() //----------------------------------------------------------------------------- bool CServerBrowser::OpenGameInfoDialog( uint64 ulSteamIDFriend, const char *pszConnectCode ) { -#if !defined( _X360 ) // X360TBD: SteamFriends() +#if 0 if ( m_hInternetDlg.Get() ) { // activate an already-existing dialog @@ -337,11 +339,11 @@ bool CServerBrowser::OpenGameInfoDialog( uint64 ulSteamIDFriend, const char *psz //----------------------------------------------------------------------------- bool CServerBrowser::JoinGame( uint64 ulSteamIDFriend, const char *pszConnectCode ) { - if ( OpenGameInfoDialog( ulSteamIDFriend, pszConnectCode ) ) +/* if ( OpenGameInfoDialog( ulSteamIDFriend, pszConnectCode ) ) { CDialogGameInfo *pDialogGameInfo = m_hInternetDlg->GetDialogGameInfoForFriend( ulSteamIDFriend ); pDialogGameInfo->Connect(); - } + }*/ return false; } @@ -362,11 +364,13 @@ bool CServerBrowser::JoinGame( uint32 unGameIP, uint16 usGamePort, const char *p //----------------------------------------------------------------------------- void CServerBrowser::CloseGameInfoDialog( uint64 ulSteamIDFriend ) { +#if 0 CDialogGameInfo *pDialogGameInfo = m_hInternetDlg->GetDialogGameInfoForFriend( ulSteamIDFriend ); if ( pDialogGameInfo ) { pDialogGameInfo->Close(); } +#endif } diff --git a/serverbrowser/ServerBrowserDialog.cpp b/serverbrowser/ServerBrowserDialog.cpp index dc2ca162..b3e9738b 100644 --- a/serverbrowser/ServerBrowserDialog.cpp +++ b/serverbrowser/ServerBrowserDialog.cpp @@ -66,20 +66,17 @@ CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent, m_pSavedData = NULL; m_pFilterData = NULL; m_pFavorites = NULL; - m_pBlacklist = NULL; m_pHistory = NULL; - // Do this before LoadUserData() so it loads the blacklist file properly - m_pBlacklist = new CBlacklistedServers(this); - LoadUserData(); - m_pInternetGames = new CCustomGames(this); + m_pInternetGames = new CInternetGames(this); m_pFavorites = new CFavoriteGames(this); m_pHistory = new CHistoryGames(this); - m_pSpectateGames = new CSpectateGames(this); + + // TODO(nillerusr): implement spectate games without steam + //m_pSpectateGames = new CSpectateGames(this); m_pLanGames = new CLanGames(this); - m_pFriendsGames = new CFriendsGames(this); SetMinimumSize( 640, 384 ); SetSize( 640, 384 ); @@ -94,13 +91,9 @@ CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent, 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_pSpectateGames, "#ServerBrowser_SpectateTab"); + //m_pTabPanel->AddPage(m_pSpectateGames, "#ServerBrowser_SpectateTab"); m_pTabPanel->AddPage(m_pLanGames, "#ServerBrowser_LanTab"); - m_pTabPanel->AddPage(m_pFriendsGames, "#ServerBrowser_FriendsTab"); - if ( m_pBlacklist ) - { - m_pTabPanel->AddPage(m_pBlacklist, "#ServerBrowser_BlacklistTab"); - } + m_pTabPanel->AddActionSignalTarget(this); m_pStatusLabel = new Label(this, "StatusLabel", ""); @@ -112,11 +105,12 @@ CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent, // load current tab const char *gameList = m_pSavedData->GetString("GameList"); - if (!Q_stricmp(gameList, "spectate")) +/* if (!Q_stricmp(gameList, "spectate")) { m_pTabPanel->SetActivePage(m_pSpectateGames); } - else if (!Q_stricmp(gameList, "favorites")) + else */ + if (!Q_stricmp(gameList, "favorites")) { m_pTabPanel->SetActivePage(m_pFavorites); } @@ -128,14 +122,6 @@ CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent, { m_pTabPanel->SetActivePage(m_pLanGames); } - else if (!Q_stricmp(gameList, "friends")) - { - m_pTabPanel->SetActivePage(m_pFriendsGames); - } - else if (!Q_stricmp(gameList, "blacklist")) - { - m_pTabPanel->SetActivePage(m_pBlacklist); - } else { m_pTabPanel->SetActivePage(m_pInternetGames); @@ -254,11 +240,6 @@ void CServerBrowserDialog::LoadUserData() m_pFavorites->StartRefresh(); } - if ( m_pBlacklist ) - { - m_pBlacklist->LoadBlacklistedList(); - } - InvalidateLayout(); Repaint(); } @@ -272,11 +253,12 @@ void CServerBrowserDialog::SaveUserData() m_pSavedData->LoadFromFile( g_pFullFileSystem, "ServerBrowser.vdf", "CONFIG"); // set the current tab - if (m_pGameList == m_pSpectateGames) + /*if (m_pGameList == m_pSpectateGames) { m_pSavedData->SetString("GameList", "spectate"); } - else if (m_pGameList == m_pFavorites) + else */ + if (m_pGameList == m_pFavorites) { m_pSavedData->SetString("GameList", "favorites"); } @@ -284,10 +266,6 @@ void CServerBrowserDialog::SaveUserData() { m_pSavedData->SetString("GameList", "lan"); } - else if (m_pGameList == m_pFriendsGames) - { - m_pSavedData->SetString("GameList", "friends"); - } else if (m_pGameList == m_pHistory) { m_pSavedData->SetString("GameList", "history"); @@ -301,11 +279,6 @@ void CServerBrowserDialog::SaveUserData() m_pSavedData->AddSubKey( m_pFilterData->MakeCopy() ); m_pSavedData->SaveToFile( g_pFullFileSystem, "ServerBrowser.vdf", "CONFIG"); - if ( m_pBlacklist ) - { - m_pBlacklist->SaveBlacklistedList(); - } - // save per-page config SaveUserConfig(); } @@ -321,14 +294,6 @@ void CServerBrowserDialog::RefreshCurrentPage() } } -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -void CServerBrowserDialog::BlacklistsChanged() -{ - m_pInternetGames->ApplyGameFilters(); -} - //----------------------------------------------------------------------------- // Purpose: Updates status test at bottom of window //----------------------------------------------------------------------------- @@ -409,38 +374,9 @@ void CServerBrowserDialog::AddServerToFavorites(gameserveritem_t &server) server.m_NetAdr.GetQueryPort(), k_unFavoriteFlagFavorite, time( NULL ) ); - - if ( GameSupportsReplay() ) - { - // send command to propagate to the client so the client can send it on to the GC - char command[ 256 ]; - Q_snprintf( command, Q_ARRAYSIZE( command ), "rfgc %s\n", server.m_NetAdr.GetConnectionAddressString() ); - g_pRunGameEngine->AddTextCommand( command ); - } } } -//----------------------------------------------------------------------------- -// Purpose: Adds a server to our list of blacklisted servers -//----------------------------------------------------------------------------- -void CServerBrowserDialog::AddServerToBlacklist(gameserveritem_t &server) -{ - if ( m_pBlacklist ) - { - m_pBlacklist->AddServer( server ); - } -} - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -bool CServerBrowserDialog::IsServerBlacklisted(gameserveritem_t &server) -{ - if ( m_pBlacklist ) - return m_pBlacklist->IsServerBlacklisted( server ); - return false; -} - //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -469,10 +405,10 @@ CServerContextMenu *CServerBrowserDialog::GetContextMenu(vgui::Panel *pPanel) // Purpose: begins the process of joining a server from a game list // the game info dialog it opens will also update the game list //----------------------------------------------------------------------------- -CDialogGameInfo *CServerBrowserDialog::JoinGame(IGameList *gameList, unsigned int serverIndex) +CDialogGameInfo *CServerBrowserDialog::JoinGame(IGameList *gameList, newgameserver_t *pServer) { // open the game info dialog, then mark it to attempt to connect right away - CDialogGameInfo *gameDialog = OpenGameInfoDialog(gameList, serverIndex); + CDialogGameInfo *gameDialog = OpenGameInfoDialog(gameList, pServer); // set the dialog name to be the server name gameDialog->Connect(); @@ -497,16 +433,12 @@ CDialogGameInfo *CServerBrowserDialog::JoinGame(int serverIP, int serverPort, co //----------------------------------------------------------------------------- // Purpose: opens a game info dialog from a game list //----------------------------------------------------------------------------- -CDialogGameInfo *CServerBrowserDialog::OpenGameInfoDialog( IGameList *gameList, unsigned int serverIndex ) +CDialogGameInfo *CServerBrowserDialog::OpenGameInfoDialog( IGameList *gameList, newgameserver_t *pServer ) { - gameserveritem_t *pServer = gameList->GetServer( serverIndex ); - if ( !pServer ) - return NULL; - - CDialogGameInfo *gameDialog = new CDialogGameInfo( NULL, pServer->m_NetAdr.GetIP(), pServer->m_NetAdr.GetQueryPort(), pServer->m_NetAdr.GetConnectionPort(), gameList->GetConnectCode() ); + CDialogGameInfo *gameDialog = new CDialogGameInfo( NULL, pServer->m_NetAdr.GetIPHostByteOrder(), 0, pServer->m_NetAdr.GetPort(), gameList->GetConnectCode() ); gameDialog->SetParent(GetVParent()); gameDialog->AddActionSignalTarget(this); - gameDialog->Run( pServer->GetName() ); + gameDialog->Run( "Test" /*pServer->GetName()*/ ); int i = m_GameInfoDialogs.AddToTail(); m_GameInfoDialogs[i] = gameDialog; return gameDialog; @@ -541,23 +473,6 @@ void CServerBrowserDialog::CloseAllGameInfoDialogs() } } - -//----------------------------------------------------------------------------- -// Purpose: finds a dialog -//----------------------------------------------------------------------------- -CDialogGameInfo *CServerBrowserDialog::GetDialogGameInfoForFriend( uint64 ulSteamIDFriend ) -{ - FOR_EACH_VEC( m_GameInfoDialogs, i ) - { - CDialogGameInfo *pDlg = m_GameInfoDialogs[i]; - if ( pDlg && pDlg->GetAssociatedFriend() == ulSteamIDFriend ) - { - return pDlg; - } - } - return NULL; -} - //----------------------------------------------------------------------------- // Purpose: accessor to the filter save data //----------------------------------------------------------------------------- @@ -612,10 +527,9 @@ void CServerBrowserDialog::OnActiveGameName( KeyValues *pKV ) void CServerBrowserDialog::ReloadFilterSettings() { m_pInternetGames->LoadFilterSettings(); - m_pSpectateGames->LoadFilterSettings(); + //m_pSpectateGames->LoadFilterSettings(); m_pFavorites->LoadFilterSettings(); m_pLanGames->LoadFilterSettings(); - m_pFriendsGames->LoadFilterSettings(); m_pHistory->LoadFilterSettings(); } @@ -659,27 +573,19 @@ void CServerBrowserDialog::OnConnectToGame( KeyValues *pMessageValues ) // forward to favorites m_pFavorites->OnConnectToGame(); - if ( m_pBlacklist ) - { - m_pBlacklist->OnConnectToGame(); - } m_bCurrentlyConnected = true; // Now we want to track which tabs have the quick list button checked int iQuickListBitField = 0; - if ( m_pFriendsGames && m_pFriendsGames->IsQuickListButtonChecked() ) - { - iQuickListBitField |= ( 1 << 0 ); - } if ( m_pLanGames && m_pLanGames->IsQuickListButtonChecked() ) { iQuickListBitField |= ( 1 << 1 ); } - if ( m_pSpectateGames && m_pSpectateGames->IsQuickListButtonChecked() ) +/* if ( m_pSpectateGames && m_pSpectateGames->IsQuickListButtonChecked() ) { iQuickListBitField |= ( 1 << 2 ); - } + }*/ if ( m_pHistory && m_pHistory->IsQuickListButtonChecked() ) { iQuickListBitField |= ( 1 << 3 ); @@ -720,10 +626,6 @@ void CServerBrowserDialog::OnDisconnectFromGame( void ) // forward to favorites m_pFavorites->OnDisconnectFromGame(); - if ( m_pBlacklist ) - { - m_pBlacklist->OnDisconnectFromGame(); - } } //----------------------------------------------------------------------------- @@ -732,10 +634,9 @@ void CServerBrowserDialog::OnDisconnectFromGame( void ) void CServerBrowserDialog::OnLoadingStarted( void ) { m_pInternetGames->OnLoadingStarted(); - m_pSpectateGames->OnLoadingStarted(); +// m_pSpectateGames->OnLoadingStarted(); m_pFavorites->OnLoadingStarted(); m_pLanGames->OnLoadingStarted(); - m_pFriendsGames->OnLoadingStarted(); m_pHistory->OnLoadingStarted(); } diff --git a/serverbrowser/ServerBrowserDialog.h b/serverbrowser/ServerBrowserDialog.h index 2b251867..8180a9f1 100644 --- a/serverbrowser/ServerBrowserDialog.h +++ b/serverbrowser/ServerBrowserDialog.h @@ -50,26 +50,22 @@ public: // Adds a server to the list of favorites void AddServerToFavorites(gameserveritem_t &server); - // Adds a server to our list of blacklisted servers - void AddServerToBlacklist(gameserveritem_t &server); - bool IsServerBlacklisted(gameserveritem_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 - CDialogGameInfo *JoinGame(IGameList *gameList, unsigned int serverIndex); + CDialogGameInfo *JoinGame(IGameList *gameList, newgameserver_t *pServer); // joins a game by a specified IP, not attached to any game list CDialogGameInfo *JoinGame(int serverIP, int serverPort, const char *pszConnectCode); // opens a game info dialog from a game list - CDialogGameInfo *OpenGameInfoDialog(IGameList *gameList, unsigned int serverIndex); + CDialogGameInfo *OpenGameInfoDialog(IGameList *gameList, newgameserver_t *pServer); // opens a game info dialog by a specified IP, not attached to any game list CDialogGameInfo *OpenGameInfoDialog( int serverIP, uint16 connPort, uint16 queryPort, const char *pszConnectCode ); // closes all the game info dialogs void CloseAllGameInfoDialogs(); - CDialogGameInfo *GetDialogGameInfoForFriend( uint64 ulSteamIDFriend ); // accessor to the filter save data KeyValues *GetFilterSaveData(const char *filterSet); @@ -91,9 +87,6 @@ public: return &m_CurrentConnection; } - void BlacklistsChanged(); - CBlacklistedServers *GetBlacklistPage( void ) { return m_pBlacklist; } - private: // current game list change @@ -126,12 +119,10 @@ private: // property sheet vgui::PropertySheet *m_pTabPanel; CFavoriteGames *m_pFavorites; - CBlacklistedServers *m_pBlacklist; CHistoryGames *m_pHistory; CInternetGames *m_pInternetGames; - CSpectateGames *m_pSpectateGames; + //CSpectateGames *m_pSpectateGames; CLanGames *m_pLanGames; - CFriendsGames *m_pFriendsGames; KeyValues *m_pSavedData; KeyValues *m_pFilterData; diff --git a/serverbrowser/pch_serverbrowser.h b/serverbrowser/pch_serverbrowser.h index 575382e4..8e44f2ba 100644 --- a/serverbrowser/pch_serverbrowser.h +++ b/serverbrowser/pch_serverbrowser.h @@ -57,15 +57,11 @@ // game list #include "BaseGamesPage.h" -#include "BlacklistedServers.h" #include "InternetGames.h" #include "FavoriteGames.h" -#include "SpectateGames.h" +//#include "SpectateGames.h" #include "LanGames.h" -#include "FriendsGames.h" #include "HistoryGames.h" -#include "SpectateGames.h" -#include "CustomGames.h" #include "ServerBrowserDialog.h" #include "QuickListPanel.h" #include "vgui_controls/PanelListPanel.h" diff --git a/serverbrowser/BlacklistedServers.cpp b/serverbrowser/unused/BlacklistedServers.cpp similarity index 100% rename from serverbrowser/BlacklistedServers.cpp rename to serverbrowser/unused/BlacklistedServers.cpp diff --git a/serverbrowser/BlacklistedServers.h b/serverbrowser/unused/BlacklistedServers.h similarity index 100% rename from serverbrowser/BlacklistedServers.h rename to serverbrowser/unused/BlacklistedServers.h diff --git a/serverbrowser/CustomGames.cpp b/serverbrowser/unused/CustomGames.cpp similarity index 100% rename from serverbrowser/CustomGames.cpp rename to serverbrowser/unused/CustomGames.cpp diff --git a/serverbrowser/CustomGames.h b/serverbrowser/unused/CustomGames.h similarity index 100% rename from serverbrowser/CustomGames.h rename to serverbrowser/unused/CustomGames.h diff --git a/serverbrowser/FriendsGames.cpp b/serverbrowser/unused/FriendsGames.cpp similarity index 100% rename from serverbrowser/FriendsGames.cpp rename to serverbrowser/unused/FriendsGames.cpp diff --git a/serverbrowser/FriendsGames.h b/serverbrowser/unused/FriendsGames.h similarity index 100% rename from serverbrowser/FriendsGames.h rename to serverbrowser/unused/FriendsGames.h diff --git a/serverbrowser/SpectateGames.cpp b/serverbrowser/unused/SpectateGames.cpp similarity index 100% rename from serverbrowser/SpectateGames.cpp rename to serverbrowser/unused/SpectateGames.cpp diff --git a/serverbrowser/SpectateGames.h b/serverbrowser/unused/SpectateGames.h similarity index 100% rename from serverbrowser/SpectateGames.h rename to serverbrowser/unused/SpectateGames.h diff --git a/serverbrowser/wscript b/serverbrowser/wscript index 755ae062..abeb6297 100755 --- a/serverbrowser/wscript +++ b/serverbrowser/wscript @@ -21,13 +21,13 @@ def configure(conf): def build(bld): source = [ 'BaseGamesPage.cpp', - 'BlacklistedServers.cpp', - 'CustomGames.cpp', +# 'BlacklistedServers.cpp', +# 'CustomGames.cpp', 'DialogAddServer.cpp', 'DialogGameInfo.cpp', 'DialogServerPassword.cpp', 'FavoriteGames.cpp', - 'FriendsGames.cpp', +# 'FriendsGames.cpp', 'HistoryGames.cpp', 'InternetGames.cpp', 'LanGames.cpp', @@ -36,7 +36,7 @@ def build(bld): 'ServerBrowserDialog.cpp', 'ServerContextMenu.cpp', 'ServerListCompare.cpp', - 'SpectateGames.cpp', +# 'SpectateGames.cpp', 'VACBannedConnRefusedDialog.cpp', 'QuickListPanel.cpp', '../public/vgui_controls/vgui_controls.cpp',