Skip to content

Commit 2b2ca63

Browse files
committed
serverbrowser: rewrite according my expectations
1 parent efbcaf7 commit 2b2ca63

File tree

10 files changed

+154
-373
lines changed

10 files changed

+154
-373
lines changed

serverbrowser/BaseGamesPage.cpp

Lines changed: 72 additions & 252 deletions
Large diffs are not rendered by default.

serverbrowser/BaseGamesPage.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,10 @@ class CCheckBoxWithStatus : public vgui::CheckButton
6666
virtual void OnCursorExited();
6767
};
6868

69-
struct servermaps_t
69+
struct serverping_t
7070
{
71-
const char *pOriginalName;
72-
const char *pFriendlyName;
73-
int iPanelIndex;
74-
bool bOnDisk;
71+
int m_nPing;
72+
int iPanelIndex;
7573
};
7674

7775
struct gametypes_t
@@ -120,7 +118,7 @@ class CBaseGamesPage : public vgui::PropertyPage, public IGameList, public IServ
120118
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
121119

122120
// gets information about specified server
123-
virtual gameserveritem_t *GetServer(unsigned int serverID);
121+
virtual newgameserver_t *GetServer(unsigned int serverID);
124122
virtual const char *GetConnectCode();
125123

126124
uint32 GetServerFilters( MatchMakingKeyValuePair_t **pFilters );
@@ -144,7 +142,7 @@ class CBaseGamesPage : public vgui::PropertyPage, public IGameList, public IServ
144142

145143
virtual void UpdateDerivedLayouts( void );
146144

147-
void PrepareQuickListMap( const char *pMapName, int iListID );
145+
void PrepareQuickListMap( newgameserver_t *server, int iListID );
148146
void SelectQuickListServers( void );
149147
vgui::Panel *GetActiveList( void );
150148
virtual bool IsQuickListButtonChecked()
@@ -242,7 +240,7 @@ class CBaseGamesPage : public vgui::PropertyPage, public IGameList, public IServ
242240
CUtlVector<MatchMakingKeyValuePair_t> m_vecServerFilters;
243241
CUtlDict< CQuickListMapServerList, int > m_quicklistserverlist;
244242
int m_iServerRefreshCount;
245-
CUtlVector< servermaps_t > m_vecMapNamesFound;
243+
CUtlVector<serverping_t> m_vecServersFound;
246244

247245

248246
EPageType m_eMatchMakingType;

serverbrowser/DialogAddServer.cpp

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,13 @@ void CDialogAddServer::OnOK()
177177

178178
if ( AllowInvalidIPs() || netaddr.IsValid() )
179179
{
180-
gameserveritem_t server;
180+
newgameserver_t server;
181181
memset(&server, 0, sizeof(server));
182-
server.SetName( address );
182+
strncpy( server.m_szServerName, address, sizeof(server.m_szServerName) );
183183

184184
// We assume here that the query and connection ports are the same. This is why it's much
185185
// better if they click "Servers" and choose a server in there.
186-
server.m_NetAdr.Init( netaddr.GetIPHostByteOrder(), netaddr.GetPort(), netaddr.GetPort() );
187-
188-
server.m_nAppID = 0;
186+
server.m_NetAdr = netaddr;
189187
FinishAddServer( server );
190188
}
191189
else
@@ -257,43 +255,31 @@ void CDialogAddServer::TestServers()
257255
m_pTabPanel->AddPage( m_pDiscoveredGames, str );
258256
m_pTabPanel->InvalidateLayout();
259257

260-
FOR_EACH_VEC( vecAdress, iAddress )
258+
/* FOR_EACH_VEC( vecAdress, iAddress )
261259
{
262260
m_Queries.AddToTail( steamapicontext->SteamMatchmakingServers()->PingServer( vecAdress[ iAddress ].GetIPHostByteOrder(), vecAdress[ iAddress ].GetPort(), this ) );
263-
}
261+
}*/
264262
}
265263

266264

267265
//-----------------------------------------------------------------------------
268266
// Purpose: A server answered our ping
269267
//-----------------------------------------------------------------------------
270-
void CDialogAddServer::ServerResponded( gameserveritem_t &server )
268+
void CDialogAddServer::ServerResponded( newgameserver_t &server )
271269
{
272270
KeyValues *kv = new KeyValues( "Server" );
273271

274-
kv->SetString( "name", server.GetName() );
272+
kv->SetString( "name", server.m_szServerName );
275273
kv->SetString( "map", server.m_szMap );
276274
kv->SetString( "GameDir", server.m_szGameDir );
277275
kv->SetString( "GameDesc", server.m_szGameDescription );
278276
kv->SetString( "GameTags", server.m_szGameTags );
279277
kv->SetInt( "password", server.m_bPassword ? 1 : 0);
280278
kv->SetInt( "bots", server.m_nBotPlayers ? 2 : 0);
281279
kv->SetInt( "Replay", IsReplayServer( server ) ? 5 : 0 );
280+
kv->SetInt("secure", 0);
282281

283-
if ( server.m_bSecure )
284-
{
285-
// show the denied icon if banned from secure servers, the secure icon otherwise
286-
kv->SetInt("secure", ServerBrowser().IsVACBannedFromGame( server.m_nAppID ) ? 4 : 3);
287-
}
288-
else
289-
{
290-
kv->SetInt("secure", 0);
291-
}
292-
293-
netadr_t reportedIPAddr;
294-
reportedIPAddr.SetIP( server.m_NetAdr.GetIP() );
295-
reportedIPAddr.SetPort( server.m_NetAdr.GetConnectionPort() );
296-
kv->SetString("IPAddr", reportedIPAddr.ToString() );
282+
kv->SetString("IPAddr", server.m_NetAdr.ToString() );
297283

298284
char buf[32];
299285
Q_snprintf(buf, sizeof(buf), "%d / %d", server.m_nPlayers, server.m_nMaxPlayers);
@@ -366,7 +352,7 @@ void CDialogAddServer::OnItemSelected()
366352
//-----------------------------------------------------------------------------
367353
// Purpose:
368354
//-----------------------------------------------------------------------------
369-
void CDialogAddServer::FinishAddServer( gameserveritem_t &pServer )
355+
void CDialogAddServer::FinishAddServer( newgameserver_t &pServer )
370356
{
371357
ServerBrowserDialog().AddServerToFavorites( pServer );
372358
}

serverbrowser/DialogAddServer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class IGameList;
1717
//-----------------------------------------------------------------------------
1818
// Purpose: Dialog which lets the user add a server by IP address
1919
//-----------------------------------------------------------------------------
20-
class CDialogAddServer : public vgui::Frame, public ISteamMatchmakingPingResponse
20+
class CDialogAddServer : public vgui::Frame //, public ISteamMatchmakingPingResponse
2121
{
2222
DECLARE_CLASS_SIMPLE( CDialogAddServer, vgui::Frame );
2323
friend class CAddServerGameList;
@@ -26,7 +26,7 @@ class CDialogAddServer : public vgui::Frame, public ISteamMatchmakingPingRespons
2626
CDialogAddServer(vgui::Panel *parent, IGameList *gameList);
2727
~CDialogAddServer();
2828

29-
void ServerResponded( gameserveritem_t &server );
29+
void ServerResponded( newgameserver_t &server );
3030
void ServerFailedToRespond();
3131

3232
void ApplySchemeSettings( vgui::IScheme *pScheme );
@@ -40,7 +40,7 @@ class CDialogAddServer : public vgui::Frame, public ISteamMatchmakingPingRespons
4040
void TestServers();
4141
MESSAGE_FUNC( OnTextChanged, "TextChanged" );
4242

43-
virtual void FinishAddServer( gameserveritem_t &pServer );
43+
virtual void FinishAddServer( newgameserver_t &pServer );
4444
virtual bool AllowInvalidIPs( void ) { return false; }
4545

4646
protected:
@@ -54,7 +54,7 @@ class CDialogAddServer : public vgui::Frame, public ISteamMatchmakingPingRespons
5454
vgui::TextEntry *m_pTextEntry;
5555
vgui::ListPanel *m_pDiscoveredGames;
5656
int m_OriginalHeight;
57-
CUtlVector<gameserveritem_t> m_Servers;
57+
CUtlVector<newgameserver_t> m_Servers;
5858
CUtlVector<HServerQuery> m_Queries;
5959
};
6060

serverbrowser/InternetGames.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ CInternetGames::CInternetGames(vgui::Panel *parent, const char *panelName, EPage
2323
m_fLastSort = 0.0f;
2424
m_bDirty = false;
2525
m_bRequireUpdate = true;
26-
m_bOfflineMode = false; //ro!IsSteamGameServerBrowsingEnabled();
26+
m_bOfflineMode = false;
2727

2828
m_bAnyServersRetrievedFromMaster = false;
2929
m_bNoServersListedOnMaster = false;
@@ -311,7 +311,7 @@ int CInternetGames::GetRegionCodeToFilter()
311311
bool CInternetGames::CheckTagFilter( gameserveritem_t &server )
312312
{
313313
// Servers without tags go in the official games, servers with tags go in custom games
314-
bool bOfficialServer = !( server.m_szGameTags && server.m_szGameTags[0] );
314+
bool bOfficialServer = !server.m_szGameTags[0];
315315
if ( !bOfficialServer )
316316
return false;
317317

serverbrowser/ServerBrowserDialog.cpp

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ void GetMostCommonQueryPorts( CUtlVector<uint16> &ports )
5959
//-----------------------------------------------------------------------------
6060
CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent, "CServerBrowserDialog")
6161
{
62+
SetProportional( NeedProportional() );
6263
s_InternetDlg = this;
6364

6465
m_szGameName[0] = 0;
@@ -67,19 +68,25 @@ CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent,
6768
m_pFilterData = NULL;
6869
m_pFavorites = NULL;
6970
m_pHistory = NULL;
71+
m_pLanGames = NULL;
7072

7173
LoadUserData();
7274

7375
m_pInternetGames = new CInternetGames(this);
76+
/*
7477
m_pFavorites = new CFavoriteGames(this);
7578
m_pHistory = new CHistoryGames(this);
76-
77-
// TODO(nillerusr): implement spectate games without steam
78-
//m_pSpectateGames = new CSpectateGames(this);
79+
m_pSpectateGames = new CSpectateGames(this);
7980
m_pLanGames = new CLanGames(this);
81+
*/
82+
83+
int w = 640; int h = 384;
8084

81-
SetMinimumSize( 640, 384 );
82-
SetSize( 640, 384 );
85+
w = IsProportional() ? vgui::scheme()->GetProportionalScaledValue(w) : w;
86+
h = IsProportional() ? vgui::scheme()->GetProportionalScaledValue(h) : h;
87+
88+
SetMinimumSize( w, h );
89+
SetSize( w, h );
8390

8491
m_pGameList = m_pInternetGames;
8592

@@ -89,10 +96,10 @@ CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent,
8996
m_pTabPanel = new PropertySheet(this, "GameTabs");
9097
m_pTabPanel->SetTabWidth(72);
9198
m_pTabPanel->AddPage(m_pInternetGames, "#ServerBrowser_InternetTab");
92-
m_pTabPanel->AddPage(m_pFavorites, "#ServerBrowser_FavoritesTab");
93-
m_pTabPanel->AddPage(m_pHistory, "#ServerBrowser_HistoryTab");
99+
//m_pTabPanel->AddPage(m_pFavorites, "#ServerBrowser_FavoritesTab");
100+
//m_pTabPanel->AddPage(m_pHistory, "#ServerBrowser_HistoryTab");
94101
//m_pTabPanel->AddPage(m_pSpectateGames, "#ServerBrowser_SpectateTab");
95-
m_pTabPanel->AddPage(m_pLanGames, "#ServerBrowser_LanTab");
102+
//m_pTabPanel->AddPage(m_pLanGames, "#ServerBrowser_LanTab");
96103

97104
m_pTabPanel->AddActionSignalTarget(this);
98105

@@ -109,7 +116,7 @@ CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent,
109116
{
110117
m_pTabPanel->SetActivePage(m_pSpectateGames);
111118
}
112-
else */
119+
else
113120
if (!Q_stricmp(gameList, "favorites"))
114121
{
115122
m_pTabPanel->SetActivePage(m_pFavorites);
@@ -122,7 +129,7 @@ CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent,
122129
{
123130
m_pTabPanel->SetActivePage(m_pLanGames);
124131
}
125-
else
132+
else*/
126133
{
127134
m_pTabPanel->SetActivePage(m_pInternetGames);
128135
}
@@ -160,7 +167,7 @@ void CServerBrowserDialog::Initialize()
160167
//-----------------------------------------------------------------------------
161168
// Purpose: returns a server in the list
162169
//-----------------------------------------------------------------------------
163-
gameserveritem_t *CServerBrowserDialog::GetServer( unsigned int serverID )
170+
newgameserver_t *CServerBrowserDialog::GetServer( unsigned int serverID )
164171
{
165172
if (m_pGameList)
166173
return m_pGameList->GetServer( serverID );
@@ -257,7 +264,7 @@ void CServerBrowserDialog::SaveUserData()
257264
{
258265
m_pSavedData->SetString("GameList", "spectate");
259266
}
260-
else */
267+
else
261268
if (m_pGameList == m_pFavorites)
262269
{
263270
m_pSavedData->SetString("GameList", "favorites");
@@ -270,7 +277,7 @@ void CServerBrowserDialog::SaveUserData()
270277
{
271278
m_pSavedData->SetString("GameList", "history");
272279
}
273-
else
280+
else*/
274281
{
275282
m_pSavedData->SetString("GameList", "internet");
276283
}
@@ -363,9 +370,9 @@ CServerBrowserDialog *CServerBrowserDialog::GetInstance()
363370
//-----------------------------------------------------------------------------
364371
// Purpose: Adds a server to the list of favorites
365372
//-----------------------------------------------------------------------------
366-
void CServerBrowserDialog::AddServerToFavorites(gameserveritem_t &server)
373+
void CServerBrowserDialog::AddServerToFavorites(newgameserver_t &server)
367374
{
368-
if ( steamapicontext->SteamMatchmaking() )
375+
/* if ( steamapicontext->SteamMatchmaking() )
369376
{
370377
steamapicontext->SteamMatchmaking()->AddFavoriteGame(
371378
server.m_nAppID,
@@ -374,7 +381,7 @@ void CServerBrowserDialog::AddServerToFavorites(gameserveritem_t &server)
374381
server.m_NetAdr.GetQueryPort(),
375382
k_unFavoriteFlagFavorite,
376383
time( NULL ) );
377-
}
384+
}*/
378385
}
379386

380387
//-----------------------------------------------------------------------------
@@ -527,10 +534,10 @@ void CServerBrowserDialog::OnActiveGameName( KeyValues *pKV )
527534
void CServerBrowserDialog::ReloadFilterSettings()
528535
{
529536
m_pInternetGames->LoadFilterSettings();
530-
//m_pSpectateGames->LoadFilterSettings();
537+
/*m_pSpectateGames->LoadFilterSettings();
531538
m_pFavorites->LoadFilterSettings();
532539
m_pLanGames->LoadFilterSettings();
533-
m_pHistory->LoadFilterSettings();
540+
m_pHistory->LoadFilterSettings();*/
534541
}
535542

536543
//-----------------------------------------------------------------------------
@@ -572,7 +579,7 @@ void CServerBrowserDialog::OnConnectToGame( KeyValues *pMessageValues )
572579
}
573580

574581
// forward to favorites
575-
m_pFavorites->OnConnectToGame();
582+
//m_pFavorites->OnConnectToGame();
576583

577584
m_bCurrentlyConnected = true;
578585

@@ -582,7 +589,7 @@ void CServerBrowserDialog::OnConnectToGame( KeyValues *pMessageValues )
582589
{
583590
iQuickListBitField |= ( 1 << 1 );
584591
}
585-
/* if ( m_pSpectateGames && m_pSpectateGames->IsQuickListButtonChecked() )
592+
/*if ( m_pSpectateGames && m_pSpectateGames->IsQuickListButtonChecked() )
586593
{
587594
iQuickListBitField |= ( 1 << 2 );
588595
}*/
@@ -625,7 +632,7 @@ void CServerBrowserDialog::OnDisconnectFromGame( void )
625632
memset( &m_CurrentConnection, 0, sizeof(gameserveritem_t) );
626633

627634
// forward to favorites
628-
m_pFavorites->OnDisconnectFromGame();
635+
//m_pFavorites->OnDisconnectFromGame();
629636
}
630637

631638
//-----------------------------------------------------------------------------
@@ -634,10 +641,10 @@ void CServerBrowserDialog::OnDisconnectFromGame( void )
634641
void CServerBrowserDialog::OnLoadingStarted( void )
635642
{
636643
m_pInternetGames->OnLoadingStarted();
637-
// m_pSpectateGames->OnLoadingStarted();
644+
/* m_pSpectateGames->OnLoadingStarted();
638645
m_pFavorites->OnLoadingStarted();
639646
m_pLanGames->OnLoadingStarted();
640-
m_pHistory->OnLoadingStarted();
647+
m_pHistory->OnLoadingStarted();*/
641648
}
642649

643650
//-----------------------------------------------------------------------------

serverbrowser/ServerBrowserDialog.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CServerBrowserDialog : public vgui::Frame
3131
void Open( void );
3232

3333
// gets server info
34-
gameserveritem_t *GetServer(unsigned int serverID);
34+
newgameserver_t *GetServer(unsigned int serverID);
3535
// called every frame
3636
virtual void OnTick();
3737

@@ -49,7 +49,7 @@ class CServerBrowserDialog : public vgui::Frame
4949
static CServerBrowserDialog *GetInstance();
5050

5151
// Adds a server to the list of favorites
52-
void AddServerToFavorites(gameserveritem_t &server);
52+
void AddServerToFavorites(newgameserver_t &server);
5353

5454
// begins the process of joining a server from a game list
5555
// the game info dialog it opens will also update the game list
@@ -118,11 +118,12 @@ class CServerBrowserDialog : public vgui::Frame
118118

119119
// property sheet
120120
vgui::PropertySheet *m_pTabPanel;
121-
CFavoriteGames *m_pFavorites;
122-
CHistoryGames *m_pHistory;
121+
123122
CInternetGames *m_pInternetGames;
124123
//CSpectateGames *m_pSpectateGames;
125124
CLanGames *m_pLanGames;
125+
CFavoriteGames *m_pFavorites;
126+
CHistoryGames *m_pHistory;
126127

127128
KeyValues *m_pSavedData;
128129
KeyValues *m_pFilterData;

0 commit comments

Comments
 (0)