Merge pull request #198 from nillerusr/serverbrowser
Serverbrowser support
This commit is contained in:
commit
ec3ab23a0e
45 changed files with 1275 additions and 691 deletions
|
@ -16,6 +16,8 @@
|
||||||
// This is used, unless overridden in the registry
|
// This is used, unless overridden in the registry
|
||||||
#define VALVE_MASTER_ADDRESS "207.173.177.10:27011"
|
#define VALVE_MASTER_ADDRESS "207.173.177.10:27011"
|
||||||
|
|
||||||
|
#define HB_TIMEOUT 15
|
||||||
|
|
||||||
#define PORT_RCON 27015 // defualt RCON port, TCP
|
#define PORT_RCON 27015 // defualt RCON port, TCP
|
||||||
#define PORT_MASTER 27011 // Default master port, UDP
|
#define PORT_MASTER 27011 // Default master port, UDP
|
||||||
#define PORT_CLIENT 27005 // Default client port, UDP/TCP
|
#define PORT_CLIENT 27005 // Default client port, UDP/TCP
|
||||||
|
@ -29,6 +31,8 @@
|
||||||
#endif // ENABLE_RPT
|
#endif // ENABLE_RPT
|
||||||
#define PORT_REPLAY 27040 // Default replay port
|
#define PORT_REPLAY 27040 // Default replay port
|
||||||
|
|
||||||
|
#define PORT_SERVERSINFO 27069 // Default matchmaking port
|
||||||
|
|
||||||
// out of band message id bytes
|
// out of band message id bytes
|
||||||
|
|
||||||
// M = master, S = server, C = client, A = any
|
// M = master, S = server, C = client, A = any
|
||||||
|
@ -80,16 +84,17 @@
|
||||||
|
|
||||||
|
|
||||||
// A user is requesting the list of master servers, auth servers, and titan dir servers from the Client Master server
|
// A user is requesting the list of master servers, auth servers, and titan dir servers from the Client Master server
|
||||||
#define A2M_GETMASTERSERVERS 'v' // + byte (type of request, TYPE_CLIENT_MASTER or TYPE_SERVER_MASTER)
|
|
||||||
|
|
||||||
// Master server list response
|
// Master server list response
|
||||||
#define M2A_MASTERSERVERS 'w' // + byte type + 6 byte IP/Port List
|
#define S2M_GETCHALLENGE 'w' // + dword challenge
|
||||||
|
#define S2M_HEARTBEAT 'y'
|
||||||
|
#define S2M_SHUTDOWN 'z' // Master peering message
|
||||||
|
#define M2S_CHALLENGE 'x' // + dword challenge
|
||||||
|
#define M2C_QUERY 'J' // request module from master
|
||||||
|
#define C2M_CLIENTQUERY '1' // New style server query
|
||||||
|
|
||||||
#define A2M_GETACTIVEMODS 'x' // + string Request to master to provide mod statistics ( current usage ). "1" for first mod.
|
#define C2S_INFOREQUEST 'v'
|
||||||
|
#define S2C_INFOREPLY 'K'
|
||||||
#define M2A_ACTIVEMODS 'y' // response: modname\r\nusers\r\nservers
|
|
||||||
|
|
||||||
#define M2M_MSG 'z' // Master peering message
|
|
||||||
|
|
||||||
// SERVER TO CLIENT/ANY
|
// SERVER TO CLIENT/ANY
|
||||||
|
|
||||||
|
@ -106,9 +111,6 @@
|
||||||
#define S2A_INFO_SRC 'I' // + Address, hostname, map, gamedir, gamedescription, active players, maxplayers, protocol
|
#define S2A_INFO_SRC 'I' // + Address, hostname, map, gamedir, gamedescription, active players, maxplayers, protocol
|
||||||
#define S2A_INFO_GOLDSRC 'm' // Reserved for use by goldsrc servers
|
#define S2A_INFO_GOLDSRC 'm' // Reserved for use by goldsrc servers
|
||||||
|
|
||||||
#define S2M_GETFILE 'J' // request module from master
|
|
||||||
#define M2S_SENDFILE 'K' // send module to server
|
|
||||||
|
|
||||||
#define S2C_REDIRECT 'L' // + IP x.x.x.x:port, redirect client to other server/proxy
|
#define S2C_REDIRECT 'L' // + IP x.x.x.x:port, redirect client to other server/proxy
|
||||||
|
|
||||||
#define C2M_CHECKMD5 'M' // player client asks secure master if Module MD5 is valid
|
#define C2M_CHECKMD5 'M' // player client asks secure master if Module MD5 is valid
|
||||||
|
@ -133,8 +135,6 @@
|
||||||
|
|
||||||
#define A2S_KEY_STRING "Source Engine Query" // required postfix to a A2S_INFO query
|
#define A2S_KEY_STRING "Source Engine Query" // required postfix to a A2S_INFO query
|
||||||
|
|
||||||
#define A2M_GET_SERVERS_BATCH2 '1' // New style server query
|
|
||||||
|
|
||||||
#define A2M_GETACTIVEMODS2 '2' // New style mod info query
|
#define A2M_GETACTIVEMODS2 '2' // New style mod info query
|
||||||
|
|
||||||
#define C2S_AUTHREQUEST1 '3' //
|
#define C2S_AUTHREQUEST1 '3' //
|
||||||
|
|
|
@ -1431,7 +1431,7 @@ void CBaseClient::UpdateUserSettings()
|
||||||
SetRate( rate, false );
|
SetRate( rate, false );
|
||||||
|
|
||||||
// set server to client update rate
|
// set server to client update rate
|
||||||
SetUpdateRate( m_ConVars->GetInt( "cl_updaterate", 20), false );
|
SetUpdateRate( m_ConVars->GetInt( "cl_updaterate", 60), false );
|
||||||
|
|
||||||
SetMaxRoutablePayloadSize( m_ConVars->GetInt( "net_maxroutable", MAX_ROUTABLE_PAYLOAD ) );
|
SetMaxRoutablePayloadSize( m_ConVars->GetInt( "net_maxroutable", MAX_ROUTABLE_PAYLOAD ) );
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "sv_plugin.h"
|
#include "sv_plugin.h"
|
||||||
#include "sys_dll.h"
|
#include "sys_dll.h"
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
|
#include "master.h"
|
||||||
#if defined( REPLAY_ENABLED )
|
#if defined( REPLAY_ENABLED )
|
||||||
#include "replay_internal.h"
|
#include "replay_internal.h"
|
||||||
#include "replayserver.h"
|
#include "replayserver.h"
|
||||||
|
@ -875,6 +876,8 @@ bool CBaseClientState::ProcessConnectionlessPacket( netpacket_t *packet )
|
||||||
|
|
||||||
Assert( packet );
|
Assert( packet );
|
||||||
|
|
||||||
|
master->ProcessConnectionlessPacket( packet );
|
||||||
|
|
||||||
bf_read &msg = packet->message; // handy shortcut
|
bf_read &msg = packet->message; // handy shortcut
|
||||||
|
|
||||||
int c = msg.ReadByte();
|
int c = msg.ReadByte();
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
#include "sv_ipratelimit.h"
|
#include "sv_ipratelimit.h"
|
||||||
#include "cl_steamauth.h"
|
#include "cl_steamauth.h"
|
||||||
#include "sv_filter.h"
|
#include "sv_filter.h"
|
||||||
|
#include "master.h"
|
||||||
|
|
||||||
#if defined( _X360 )
|
#if defined( _X360 )
|
||||||
#include "xbox/xbox_win32stubs.h"
|
#include "xbox/xbox_win32stubs.h"
|
||||||
|
@ -663,6 +664,8 @@ bool CBaseServer::ValidInfoChallenge( netadr_t & adr, const char *nugget )
|
||||||
|
|
||||||
bool CBaseServer::ProcessConnectionlessPacket(netpacket_t * packet)
|
bool CBaseServer::ProcessConnectionlessPacket(netpacket_t * packet)
|
||||||
{
|
{
|
||||||
|
master->ProcessConnectionlessPacket( packet );
|
||||||
|
|
||||||
bf_read msg = packet->message; // handy shortcut
|
bf_read msg = packet->message; // handy shortcut
|
||||||
|
|
||||||
char c = msg.ReadChar();
|
char c = msg.ReadChar();
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "steam/steam_api.h"
|
#include "steam/steam_api.h"
|
||||||
#include "LoadScreenUpdate.h"
|
#include "LoadScreenUpdate.h"
|
||||||
#include "datacache/idatacache.h"
|
#include "datacache/idatacache.h"
|
||||||
|
#include "master.h"
|
||||||
|
|
||||||
#if !defined SWDS
|
#if !defined SWDS
|
||||||
#include "voice.h"
|
#include "voice.h"
|
||||||
|
@ -1820,6 +1821,8 @@ void Host_ShutdownServer( void )
|
||||||
if ( !sv.IsActive() )
|
if ( !sv.IsActive() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
master->ShutdownConnection();
|
||||||
|
|
||||||
Host_AllowQueuedMaterialSystem( false );
|
Host_AllowQueuedMaterialSystem( false );
|
||||||
// clear structures
|
// clear structures
|
||||||
#if !defined( SWDS )
|
#if !defined( SWDS )
|
||||||
|
@ -4951,7 +4954,7 @@ void Host_Shutdown(void)
|
||||||
TRACESHUTDOWN( HLTV_Shutdown() );
|
TRACESHUTDOWN( HLTV_Shutdown() );
|
||||||
|
|
||||||
TRACESHUTDOWN( g_Log.Shutdown() );
|
TRACESHUTDOWN( g_Log.Shutdown() );
|
||||||
|
|
||||||
TRACESHUTDOWN( g_GameEventManager.Shutdown() );
|
TRACESHUTDOWN( g_GameEventManager.Shutdown() );
|
||||||
|
|
||||||
TRACESHUTDOWN( sv.Shutdown() );
|
TRACESHUTDOWN( sv.Shutdown() );
|
||||||
|
|
61
engine/master.h
Normal file
61
engine/master.h
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
//======== (C) Copyright 1999, 2000 Valve, L.L.C. All rights reserved. ========
|
||||||
|
//
|
||||||
|
// The copyright to the contents herein is the property of Valve, L.L.C.
|
||||||
|
// The contents may be used and/or copied only with the written permission of
|
||||||
|
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
||||||
|
// the agreement/contract under which the contents have been supplied.
|
||||||
|
//
|
||||||
|
// Purpose:
|
||||||
|
//
|
||||||
|
// $Workfile: $
|
||||||
|
// $Date: $
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// $Log: $
|
||||||
|
//
|
||||||
|
// $NoKeywords: $
|
||||||
|
//=============================================================================
|
||||||
|
#ifndef MASTER_H
|
||||||
|
#define MASTER_H
|
||||||
|
#ifdef _WIN32
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "engine/iserversinfo.h"
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Implements a master server interface.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
class IMaster
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Allow master server to register cvars/commands
|
||||||
|
virtual void Init( void ) = 0;
|
||||||
|
// System is shutting down
|
||||||
|
virtual void Shutdown( void ) = 0;
|
||||||
|
// Server is shutting down
|
||||||
|
virtual void ShutdownConnection( void ) = 0;
|
||||||
|
// Sends the actual heartbeat to the master ( after challenge value is parsed )
|
||||||
|
virtual void SendHeartbeat( struct adrlist_s *p ) = 0;
|
||||||
|
// Add server to global master list
|
||||||
|
virtual void AddServer( struct netadr_s *adr ) = 0;
|
||||||
|
// If parsing for server, etc. fails, always have at least one server around to use.
|
||||||
|
virtual void UseDefault ( void ) = 0;
|
||||||
|
// See if it's time to send the next heartbeat
|
||||||
|
virtual void CheckHeartbeat( void ) = 0;
|
||||||
|
// Master sent back a challenge value, read it and send the actual heartbeat
|
||||||
|
virtual void RespondToHeartbeatChallenge( netadr_t &from, bf_read &msg ) = 0;
|
||||||
|
// Console command to set/remove master server
|
||||||
|
virtual void AddMaster_f( const CCommand &args ) = 0;
|
||||||
|
// Force a heartbeat to be issued right away
|
||||||
|
virtual void Heartbeat_f( void ) = 0;
|
||||||
|
|
||||||
|
virtual void ProcessConnectionlessPacket( netpacket_t *packet ) = 0;
|
||||||
|
|
||||||
|
virtual void RunFrame( void ) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern IMaster *master;
|
||||||
|
extern IServersInfo *g_pServersInfo;
|
||||||
|
|
||||||
|
#endif // MASTER_H
|
715
engine/masterserver.cpp
Normal file
715
engine/masterserver.cpp
Normal file
|
@ -0,0 +1,715 @@
|
||||||
|
//======177== (C) Copyright 1999, 2000 Valve, L.L.C. All rights reserved. ========
|
||||||
|
//
|
||||||
|
// The copyright to the contents herein is the property of Valve, L.L.C.
|
||||||
|
// The contents may be used and/or copied only with the written permission of
|
||||||
|
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
||||||
|
// the agreement/contract under which the contents have been supplied.
|
||||||
|
//
|
||||||
|
// Purpose:
|
||||||
|
//
|
||||||
|
// $Workfile: $
|
||||||
|
// $Date: $
|
||||||
|
// $NoKeywords: $
|
||||||
|
//=============================================================================
|
||||||
|
#include "quakedef.h"
|
||||||
|
#include "server.h"
|
||||||
|
#include "master.h"
|
||||||
|
#include "proto_oob.h"
|
||||||
|
#include "host.h"
|
||||||
|
#include "eiface.h"
|
||||||
|
#include "server.h"
|
||||||
|
#include "utlmap.h"
|
||||||
|
|
||||||
|
extern ConVar sv_tags;
|
||||||
|
extern ConVar sv_lan;
|
||||||
|
|
||||||
|
#define S2A_EXTRA_DATA_HAS_GAMETAG_DATA 0x01 // Next bytes are the game tag string
|
||||||
|
#define RETRY_INFO_REQUEST_TIME 0.4 // seconds
|
||||||
|
#define MASTER_RESPONSE_TIMEOUT 1.5 // seconds
|
||||||
|
#define INFO_REQUEST_TIMEOUT 5.0 // seconds
|
||||||
|
|
||||||
|
static char g_MasterServers[][64] =
|
||||||
|
{
|
||||||
|
"185.192.97.130:27010",
|
||||||
|
"168.138.92.21:27016"
|
||||||
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: List of master servers and some state info about them
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
typedef struct adrlist_s
|
||||||
|
{
|
||||||
|
// Next master in chain
|
||||||
|
struct adrlist_s *next;
|
||||||
|
// Challenge request sent to master
|
||||||
|
qboolean heartbeatwaiting;
|
||||||
|
// Challenge request send time
|
||||||
|
float heartbeatwaitingtime;
|
||||||
|
// Last one is Main master
|
||||||
|
int heartbeatchallenge;
|
||||||
|
// Time we sent last heartbeat
|
||||||
|
double last_heartbeat;
|
||||||
|
// Master server address
|
||||||
|
netadr_t adr;
|
||||||
|
} adrlist_t;
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Implements the master server interface
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
class CMaster : public IMaster, public IServersInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CMaster( void );
|
||||||
|
virtual ~CMaster( void );
|
||||||
|
|
||||||
|
// Heartbeat functions.
|
||||||
|
void Init( void );
|
||||||
|
void Shutdown( void );
|
||||||
|
// Sets up master address
|
||||||
|
void ShutdownConnection(void);
|
||||||
|
void SendHeartbeat( struct adrlist_s *p );
|
||||||
|
void AddServer( struct netadr_s *adr );
|
||||||
|
void UseDefault ( void );
|
||||||
|
void CheckHeartbeat (void);
|
||||||
|
void RespondToHeartbeatChallenge( netadr_t &from, bf_read &msg );
|
||||||
|
void PingServer( netadr_t &svadr );
|
||||||
|
|
||||||
|
void ProcessConnectionlessPacket( netpacket_t *packet );
|
||||||
|
|
||||||
|
void AddMaster_f( const CCommand &args );
|
||||||
|
void Heartbeat_f( void );
|
||||||
|
|
||||||
|
void RunFrame();
|
||||||
|
void RetryServersInfoRequest();
|
||||||
|
|
||||||
|
void ReplyInfo( const netadr_t &adr, uint sequence );
|
||||||
|
newgameserver_t &ProcessInfo( bf_read &buf );
|
||||||
|
|
||||||
|
// SeversInfo
|
||||||
|
void RequestInternetServerList( const char *gamedir, IServerListResponse *response );
|
||||||
|
void RequestLANServerList( const char *gamedir, IServerListResponse *response );
|
||||||
|
void AddServerAddresses( netadr_t **adr, int count );
|
||||||
|
void RequestServerInfo( const netadr_t &adr );
|
||||||
|
void StopRefresh();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// List of known master servers
|
||||||
|
adrlist_t *m_pMasterAddresses;
|
||||||
|
|
||||||
|
bool m_bInitialized;
|
||||||
|
bool m_bRefreshing;
|
||||||
|
|
||||||
|
int m_iServersResponded;
|
||||||
|
|
||||||
|
double m_flStartRequestTime;
|
||||||
|
double m_flRetryRequestTime;
|
||||||
|
double m_flMasterRequestTime;
|
||||||
|
|
||||||
|
uint m_iInfoSequence;
|
||||||
|
char m_szGameDir[256];
|
||||||
|
|
||||||
|
// If nomaster is true, the server will not send heartbeats to the master server
|
||||||
|
bool m_bNoMasters;
|
||||||
|
|
||||||
|
CUtlMap<netadr_t, bool> m_serverAddresses;
|
||||||
|
CUtlMap<uint, double> m_serversRequestTime;
|
||||||
|
|
||||||
|
IServerListResponse *m_serverListResponse;
|
||||||
|
};
|
||||||
|
|
||||||
|
static CMaster s_MasterServer;
|
||||||
|
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
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Constructor
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
CMaster::CMaster( void )
|
||||||
|
{
|
||||||
|
m_pMasterAddresses = NULL;
|
||||||
|
m_bNoMasters = false;
|
||||||
|
m_bInitialized = false;
|
||||||
|
m_iServersResponded = 0;
|
||||||
|
|
||||||
|
m_serverListResponse = NULL;
|
||||||
|
SetDefLessFunc( m_serverAddresses );
|
||||||
|
SetDefLessFunc( m_serversRequestTime );
|
||||||
|
m_bRefreshing = false;
|
||||||
|
m_iInfoSequence = 1;
|
||||||
|
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
CMaster::~CMaster( void )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMaster::RunFrame()
|
||||||
|
{
|
||||||
|
CheckHeartbeat();
|
||||||
|
|
||||||
|
if( !m_bRefreshing )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( m_serverListResponse &&
|
||||||
|
m_flStartRequestTime < Plat_FloatTime()-INFO_REQUEST_TIMEOUT )
|
||||||
|
{
|
||||||
|
StopRefresh();
|
||||||
|
m_serverListResponse->RefreshComplete( NServerResponse::nServerFailedToRespond );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_iServersResponded > 0 &&
|
||||||
|
m_iServersResponded >= m_serverAddresses.Count() &&
|
||||||
|
m_flMasterRequestTime < Plat_FloatTime() - MASTER_RESPONSE_TIMEOUT )
|
||||||
|
{
|
||||||
|
StopRefresh();
|
||||||
|
m_serverListResponse->RefreshComplete( NServerResponse::nServerResponded );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_flRetryRequestTime < Plat_FloatTime() - RETRY_INFO_REQUEST_TIME )
|
||||||
|
{
|
||||||
|
m_flRetryRequestTime = Plat_FloatTime();
|
||||||
|
|
||||||
|
if( m_serverAddresses.Count() == 0 ) // Retry masterserver request
|
||||||
|
{
|
||||||
|
g_pServersInfo->RequestInternetServerList(m_szGameDir, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_iServersResponded < m_serverAddresses.Count() )
|
||||||
|
RetryServersInfoRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMaster::StopRefresh()
|
||||||
|
{
|
||||||
|
if( !m_bRefreshing )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_iServersResponded = 0;
|
||||||
|
m_bRefreshing = false;
|
||||||
|
m_serverAddresses.RemoveAll();
|
||||||
|
m_serversRequestTime.RemoveAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMaster::ReplyInfo( const netadr_t &adr, uint sequence )
|
||||||
|
{
|
||||||
|
static char gamedir[MAX_OSPATH];
|
||||||
|
Q_FileBase( com_gamedir, gamedir, sizeof( gamedir ) );
|
||||||
|
|
||||||
|
CUtlBuffer buf;
|
||||||
|
buf.EnsureCapacity( 2048 );
|
||||||
|
|
||||||
|
buf.PutUnsignedInt( LittleDWord( CONNECTIONLESS_HEADER ) );
|
||||||
|
buf.PutUnsignedChar( S2C_INFOREPLY );
|
||||||
|
|
||||||
|
buf.PutUnsignedInt(sequence);
|
||||||
|
buf.PutUnsignedChar( PROTOCOL_VERSION ); // Hardcoded protocol version number
|
||||||
|
buf.PutString( sv.GetName() );
|
||||||
|
buf.PutString( sv.GetMapName() );
|
||||||
|
buf.PutString( gamedir );
|
||||||
|
buf.PutString( serverGameDLL->GetGameDescription() );
|
||||||
|
|
||||||
|
// player info
|
||||||
|
buf.PutUnsignedChar( sv.GetNumClients() );
|
||||||
|
buf.PutUnsignedChar( sv.GetMaxClients() );
|
||||||
|
buf.PutUnsignedChar( sv.GetNumFakeClients() );
|
||||||
|
|
||||||
|
// Password?
|
||||||
|
buf.PutUnsignedChar( sv.GetPassword() != NULL ? 1 : 0 );
|
||||||
|
|
||||||
|
// Write a byte with some flags that describe what is to follow.
|
||||||
|
const char *pchTags = sv_tags.GetString();
|
||||||
|
int nFlags = 0;
|
||||||
|
|
||||||
|
if ( pchTags && pchTags[0] != '\0' )
|
||||||
|
nFlags |= S2A_EXTRA_DATA_HAS_GAMETAG_DATA;
|
||||||
|
|
||||||
|
buf.PutUnsignedInt( nFlags );
|
||||||
|
|
||||||
|
if ( nFlags & S2A_EXTRA_DATA_HAS_GAMETAG_DATA )
|
||||||
|
buf.PutString( pchTags );
|
||||||
|
|
||||||
|
NET_SendPacket( NULL, NS_SERVER, adr, (unsigned char *)buf.Base(), buf.TellPut() );
|
||||||
|
}
|
||||||
|
|
||||||
|
newgameserver_t &CMaster::ProcessInfo(bf_read &buf)
|
||||||
|
{
|
||||||
|
static newgameserver_t s;
|
||||||
|
memset( &s, 0, sizeof(s) );
|
||||||
|
|
||||||
|
s.m_nProtocolVersion = buf.ReadByte();
|
||||||
|
|
||||||
|
buf.ReadString( s.m_szServerName, sizeof(s.m_szServerName) );
|
||||||
|
buf.ReadString( s.m_szMap, sizeof(s.m_szMap) );
|
||||||
|
buf.ReadString( s.m_szGameDir, sizeof(s.m_szGameDir) );
|
||||||
|
|
||||||
|
buf.ReadString( s.m_szGameDescription, sizeof(s.m_szGameDescription) );
|
||||||
|
|
||||||
|
// player info
|
||||||
|
s.m_nPlayers = buf.ReadByte();
|
||||||
|
s.m_nMaxPlayers = buf.ReadByte();
|
||||||
|
s.m_nBotPlayers = buf.ReadByte();
|
||||||
|
|
||||||
|
// Password?
|
||||||
|
s.m_bPassword = buf.ReadByte();
|
||||||
|
s.m_iFlags = buf.ReadLong();
|
||||||
|
|
||||||
|
if( s.m_iFlags & S2A_EXTRA_DATA_HAS_GAMETAG_DATA )
|
||||||
|
{
|
||||||
|
buf.ReadString( s.m_szGameTags, sizeof(s.m_szGameTags) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMaster::ProcessConnectionlessPacket( netpacket_t *packet )
|
||||||
|
{
|
||||||
|
static ALIGN4 char string[2048] ALIGN4_POST; // Buffer for sending heartbeat
|
||||||
|
|
||||||
|
uint ip; uint16 port;
|
||||||
|
|
||||||
|
bf_read msg = packet->message;
|
||||||
|
char c = msg.ReadChar();
|
||||||
|
|
||||||
|
if ( c == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch( c )
|
||||||
|
{
|
||||||
|
case M2S_CHALLENGE:
|
||||||
|
{
|
||||||
|
RespondToHeartbeatChallenge( packet->from, msg );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case M2C_QUERY:
|
||||||
|
{
|
||||||
|
if( !m_bRefreshing )
|
||||||
|
break;
|
||||||
|
|
||||||
|
ip = msg.ReadLong();
|
||||||
|
port = msg.ReadShort();
|
||||||
|
|
||||||
|
while( ip != 0 && port != 0 )
|
||||||
|
{
|
||||||
|
netadr_t adr(ip, port);
|
||||||
|
|
||||||
|
unsigned short index = m_serverAddresses.Find(adr);
|
||||||
|
if( index != m_serverAddresses.InvalidIndex() )
|
||||||
|
{
|
||||||
|
ip = msg.ReadLong();
|
||||||
|
port = msg.ReadShort();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_serverAddresses.Insert(adr, false);
|
||||||
|
RequestServerInfo(adr);
|
||||||
|
|
||||||
|
ip = msg.ReadLong();
|
||||||
|
port = msg.ReadShort();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case C2S_INFOREQUEST:
|
||||||
|
{
|
||||||
|
ReplyInfo(packet->from, msg.ReadLong());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case S2C_INFOREPLY:
|
||||||
|
{
|
||||||
|
if( !m_bRefreshing )
|
||||||
|
break;
|
||||||
|
|
||||||
|
uint sequence = msg.ReadLong();
|
||||||
|
newgameserver_t &s = ProcessInfo( msg );
|
||||||
|
|
||||||
|
unsigned short index = m_serverAddresses.Find(packet->from);
|
||||||
|
unsigned short rindex = m_serversRequestTime.Find(sequence);
|
||||||
|
|
||||||
|
if( index == m_serverAddresses.InvalidIndex() ||
|
||||||
|
rindex == m_serversRequestTime.InvalidIndex() )
|
||||||
|
break;
|
||||||
|
|
||||||
|
double requestTime = m_serversRequestTime[rindex];
|
||||||
|
|
||||||
|
if( m_serverAddresses[index] ) // shit happens
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_serverAddresses[index] = true;
|
||||||
|
s.m_nPing = (Plat_FloatTime()-requestTime)*1000.0;
|
||||||
|
s.m_NetAdr = packet->from;
|
||||||
|
m_serverListResponse->ServerResponded( s );
|
||||||
|
|
||||||
|
m_iServersResponded++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMaster::RequestServerInfo( const netadr_t &adr )
|
||||||
|
{
|
||||||
|
static ALIGN4 char string[256] ALIGN4_POST; // Buffer for sending heartbeat
|
||||||
|
bf_write msg( string, sizeof(string) );
|
||||||
|
|
||||||
|
msg.WriteLong( CONNECTIONLESS_HEADER );
|
||||||
|
msg.WriteByte( C2S_INFOREQUEST );
|
||||||
|
msg.WriteLong( m_iInfoSequence );
|
||||||
|
m_serversRequestTime.Insert(m_iInfoSequence, Plat_FloatTime());
|
||||||
|
|
||||||
|
m_iInfoSequence++;
|
||||||
|
NET_SendPacket( NULL, NS_CLIENT, adr, msg.GetData(), msg.GetNumBytesWritten() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMaster::RetryServersInfoRequest()
|
||||||
|
{
|
||||||
|
FOR_EACH_MAP_FAST( m_serverAddresses, i )
|
||||||
|
{
|
||||||
|
bool bResponded = m_serverAddresses.Element(i);
|
||||||
|
if( bResponded )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const netadr_t adr = m_serverAddresses.Key(i);
|
||||||
|
RequestServerInfo( adr );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Sends a heartbeat to the master server
|
||||||
|
// Input : *p - x00\x00\x00\x00\x00\x00
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CMaster::SendHeartbeat ( adrlist_t *p )
|
||||||
|
{
|
||||||
|
static ALIGN4 char string[256] ALIGN4_POST; // Buffer for sending heartbeat
|
||||||
|
char szGD[ MAX_OSPATH ];
|
||||||
|
|
||||||
|
if ( !p )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Still waiting on challenge response?
|
||||||
|
if ( p->heartbeatwaiting )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Waited too long
|
||||||
|
if ( (realtime - p->heartbeatwaitingtime ) >= HB_TIMEOUT )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Send to master
|
||||||
|
Q_FileBase( com_gamedir, szGD, sizeof( szGD ) );
|
||||||
|
|
||||||
|
bf_write buf( string, sizeof(string) );
|
||||||
|
buf.WriteByte( S2M_HEARTBEAT );
|
||||||
|
buf.WriteLong( p->heartbeatchallenge );
|
||||||
|
buf.WriteShort( PROTOCOL_VERSION );
|
||||||
|
buf.WriteString( szGD );
|
||||||
|
|
||||||
|
NET_SendPacket( NULL, NS_SERVER, p->adr, buf.GetData(), buf.GetNumBytesWritten() );
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Requests a challenge so we can then send a heartbeat
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CMaster::CheckHeartbeat (void)
|
||||||
|
{
|
||||||
|
adrlist_t *p;
|
||||||
|
ALIGN4 char buf[256] ALIGN4_POST;
|
||||||
|
|
||||||
|
if ( m_bNoMasters || // We are ignoring heartbeats
|
||||||
|
sv_lan.GetInt() || // Lan servers don't heartbeat
|
||||||
|
(sv.GetMaxClients() <= 1) || // not a multiplayer server.
|
||||||
|
!sv.IsActive() ) // only heartbeat if a server is running.
|
||||||
|
return;
|
||||||
|
|
||||||
|
p = m_pMasterAddresses;
|
||||||
|
while ( p )
|
||||||
|
{
|
||||||
|
// Time for another try?
|
||||||
|
if ( ( realtime - p->last_heartbeat) < HEARTBEAT_SECONDS) // not time to send yet
|
||||||
|
{
|
||||||
|
p = p->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Should we resend challenge request?
|
||||||
|
if ( p->heartbeatwaiting &&
|
||||||
|
( ( realtime - p->heartbeatwaitingtime ) < HB_TIMEOUT ) )
|
||||||
|
{
|
||||||
|
p = p->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 challenge = RandomInt( 0, INT_MAX );
|
||||||
|
|
||||||
|
p->heartbeatwaiting = true;
|
||||||
|
p->heartbeatwaitingtime = realtime;
|
||||||
|
|
||||||
|
p->last_heartbeat = realtime; // Flag at start so we don't just keep trying for hb's when
|
||||||
|
p->heartbeatchallenge = challenge;
|
||||||
|
|
||||||
|
bf_write msg("Master Join", buf, sizeof(buf));
|
||||||
|
|
||||||
|
msg.WriteByte( S2M_GETCHALLENGE );
|
||||||
|
msg.WriteLong( challenge );
|
||||||
|
|
||||||
|
// Send to master asking for a challenge #
|
||||||
|
NET_SendPacket( NULL, NS_SERVER, p->adr, msg.GetData(), msg.GetNumBytesWritten() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Server is shutting down, unload master servers list, tell masters that we are closing the server
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CMaster::ShutdownConnection( void )
|
||||||
|
{
|
||||||
|
adrlist_t *p;
|
||||||
|
|
||||||
|
if ( !host_initialized )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( m_bNoMasters || // We are ignoring heartbeats
|
||||||
|
sv_lan.GetInt() || // Lan servers don't heartbeat
|
||||||
|
(sv.GetMaxClients() <= 1) ) // not a multiplayer server.
|
||||||
|
return;
|
||||||
|
|
||||||
|
const char packet = S2M_SHUTDOWN;
|
||||||
|
|
||||||
|
p = m_pMasterAddresses;
|
||||||
|
while ( p )
|
||||||
|
{
|
||||||
|
NET_SendPacket( NULL, NS_SERVER, p->adr, (unsigned char*)&packet, 1);
|
||||||
|
p->last_heartbeat = -99999.0;
|
||||||
|
p = p->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Add server to the master list
|
||||||
|
// Input : *adr -
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CMaster::AddServer( netadr_t *adr )
|
||||||
|
{
|
||||||
|
adrlist_t *n;
|
||||||
|
|
||||||
|
// See if it's there
|
||||||
|
n = m_pMasterAddresses;
|
||||||
|
while ( n )
|
||||||
|
{
|
||||||
|
if ( n->adr.CompareAdr( *adr ) )
|
||||||
|
break;
|
||||||
|
n = n->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Found it in the list.
|
||||||
|
if ( n )
|
||||||
|
return;
|
||||||
|
|
||||||
|
n = ( adrlist_t * ) malloc ( sizeof( adrlist_t ) );
|
||||||
|
if ( !n )
|
||||||
|
Sys_Error( "Error allocating %zd bytes for master address.", sizeof( adrlist_t ) );
|
||||||
|
|
||||||
|
memset( n, 0, sizeof( adrlist_t ) );
|
||||||
|
|
||||||
|
n->adr = *adr;
|
||||||
|
|
||||||
|
// Queue up a full heartbeat to all master servers.
|
||||||
|
n->last_heartbeat = -99999.0;
|
||||||
|
|
||||||
|
// Link it in.
|
||||||
|
n->next = m_pMasterAddresses;
|
||||||
|
m_pMasterAddresses = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Add built-in default master if woncomm.lst doesn't parse
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CMaster::UseDefault ( void )
|
||||||
|
{
|
||||||
|
netadr_t adr;
|
||||||
|
|
||||||
|
for( int i = 0; i < ARRAYSIZE(g_MasterServers);i++ )
|
||||||
|
{
|
||||||
|
// Convert to netadr_t
|
||||||
|
if ( NET_StringToAdr ( g_MasterServers[i], &adr ) )
|
||||||
|
{
|
||||||
|
// Add to master list
|
||||||
|
AddServer( &adr );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CMaster::RespondToHeartbeatChallenge( netadr_t &from, bf_read &msg )
|
||||||
|
{
|
||||||
|
adrlist_t *p;
|
||||||
|
uint challenge, challenge2;
|
||||||
|
|
||||||
|
// No masters, just ignore.
|
||||||
|
if ( !m_pMasterAddresses )
|
||||||
|
return;
|
||||||
|
|
||||||
|
p = m_pMasterAddresses;
|
||||||
|
while ( p )
|
||||||
|
{
|
||||||
|
if ( from.CompareAdr( p->adr ) )
|
||||||
|
break;
|
||||||
|
|
||||||
|
p = p->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not a known master server.
|
||||||
|
if ( !p )
|
||||||
|
return;
|
||||||
|
|
||||||
|
challenge = msg.ReadLong();
|
||||||
|
challenge2 = msg.ReadLong();
|
||||||
|
|
||||||
|
if( p->heartbeatchallenge != challenge2 )
|
||||||
|
{
|
||||||
|
Warning("unexpected master server info query packet (wrong challenge!)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kill timer
|
||||||
|
p->heartbeatwaiting = false;
|
||||||
|
p->heartbeatchallenge = challenge;
|
||||||
|
|
||||||
|
// Send the actual heartbeat request to this master server.
|
||||||
|
SendHeartbeat( p );
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Add/remove master servers
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CMaster::AddMaster_f ( const CCommand &args )
|
||||||
|
{
|
||||||
|
CUtlString cmd( ( args.ArgC() > 1 ) ? args[ 1 ] : "" );
|
||||||
|
|
||||||
|
netadr_t adr;
|
||||||
|
|
||||||
|
if( !NET_StringToAdr(cmd.String(), &adr) )
|
||||||
|
{
|
||||||
|
Warning("Invalid address\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->AddServer(&adr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Send a new heartbeat to the master
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CMaster::Heartbeat_f (void)
|
||||||
|
{
|
||||||
|
adrlist_t *p;
|
||||||
|
|
||||||
|
p = m_pMasterAddresses;
|
||||||
|
while ( p )
|
||||||
|
{
|
||||||
|
// Queue up a full hearbeat
|
||||||
|
p->last_heartbeat = -9999.0;
|
||||||
|
p->heartbeatwaitingtime = -9999.0;
|
||||||
|
p = p->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void AddMaster_f( const CCommand &args )
|
||||||
|
{
|
||||||
|
master->AddMaster_f( args );
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void Heartbeat1_f( void )
|
||||||
|
{
|
||||||
|
master->Heartbeat_f();
|
||||||
|
}
|
||||||
|
|
||||||
|
static ConCommand setmaster("addmaster", AddMaster_f );
|
||||||
|
static ConCommand heartbeat("heartbeat", Heartbeat1_f, "Force heartbeat of master servers" );
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Adds master server console commands
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CMaster::Init( void )
|
||||||
|
{
|
||||||
|
// Already able to initialize at least once?
|
||||||
|
if ( m_bInitialized )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// So we don't do this a send time.sv_mas
|
||||||
|
m_bInitialized = true;
|
||||||
|
|
||||||
|
UseDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CMaster::Shutdown(void)
|
||||||
|
{
|
||||||
|
adrlist_t *p, *n;
|
||||||
|
|
||||||
|
// Free the master list now.
|
||||||
|
p = m_pMasterAddresses;
|
||||||
|
while ( p )
|
||||||
|
{
|
||||||
|
n = p->next;
|
||||||
|
free( p );
|
||||||
|
p = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pMasterAddresses = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServersInfo
|
||||||
|
void CMaster::RequestInternetServerList(const char *gamedir, IServerListResponse *response)
|
||||||
|
{
|
||||||
|
if( m_bNoMasters ) return;
|
||||||
|
strncpy( m_szGameDir, gamedir, sizeof(m_szGameDir) );
|
||||||
|
|
||||||
|
if( response )
|
||||||
|
{
|
||||||
|
StopRefresh();
|
||||||
|
m_bRefreshing = true;
|
||||||
|
m_serverListResponse = response;
|
||||||
|
m_flRetryRequestTime = m_flStartRequestTime = m_flMasterRequestTime = Plat_FloatTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
ALIGN4 char buf[256] ALIGN4_POST;
|
||||||
|
bf_write msg(buf, sizeof(buf));
|
||||||
|
|
||||||
|
msg.WriteByte( C2M_CLIENTQUERY );
|
||||||
|
msg.WriteString(gamedir);
|
||||||
|
|
||||||
|
adrlist_t *p;
|
||||||
|
|
||||||
|
p = m_pMasterAddresses;
|
||||||
|
while ( p )
|
||||||
|
{
|
||||||
|
NET_SendPacket(NULL, NS_CLIENT, p->adr, msg.GetData(), msg.GetNumBytesWritten() );
|
||||||
|
p = p->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMaster::RequestLANServerList(const char *gamedir, IServerListResponse *response)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMaster::AddServerAddresses( netadr_t **adr, int count )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -64,9 +64,6 @@ extern int NET_ReceiveStream( int nSock, char * buf, int len, int flags );
|
||||||
// We only need to checksum packets on the PC and only when we're actually sending them over the network.
|
// We only need to checksum packets on the PC and only when we're actually sending them over the network.
|
||||||
static bool ShouldChecksumPackets()
|
static bool ShouldChecksumPackets()
|
||||||
{
|
{
|
||||||
if ( !IsPC() )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return NET_IsMultiplayer();
|
return NET_IsMultiplayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "net_ws_headers.h"
|
#include "net_ws_headers.h"
|
||||||
#include "net_ws_queued_packet_sender.h"
|
#include "net_ws_queued_packet_sender.h"
|
||||||
#include "fmtstr.h"
|
#include "fmtstr.h"
|
||||||
|
#include "master.h"
|
||||||
|
|
||||||
// memdbgon must be the last include file in a .cpp file!!!
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
#include "tier0/memdbgon.h"
|
#include "tier0/memdbgon.h"
|
||||||
|
@ -44,7 +45,7 @@ static ConVar droppackets ( "net_droppackets", "0", FCVAR_CHEAT, "Drops next n p
|
||||||
static ConVar fakejitter ( "net_fakejitter", "0", FCVAR_CHEAT, "Jitter fakelag packet time" );
|
static ConVar fakejitter ( "net_fakejitter", "0", FCVAR_CHEAT, "Jitter fakelag packet time" );
|
||||||
|
|
||||||
static ConVar net_compressvoice( "net_compressvoice", "0", 0, "Attempt to compress out of band voice payloads (360 only)." );
|
static ConVar net_compressvoice( "net_compressvoice", "0", 0, "Attempt to compress out of band voice payloads (360 only)." );
|
||||||
ConVar net_usesocketsforloopback( "net_usesocketsforloopback", "1", 0, "Use network sockets layer even for listen server local player's packets (multiplayer only)." );
|
ConVar net_usesocketsforloopback( "net_usesocketsforloopback", "0", 0, "Use network sockets layer even for listen server local player's packets (multiplayer only)." );
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
static ConVar fakenoise ( "net_fakenoise", "0", FCVAR_CHEAT, "Simulate corrupt network packets (changes n bits per packet randomly)" );
|
static ConVar fakenoise ( "net_fakenoise", "0", FCVAR_CHEAT, "Simulate corrupt network packets (changes n bits per packet randomly)" );
|
||||||
|
@ -1644,7 +1645,7 @@ netpacket_t *NET_GetPacket (int sock, byte *scratch )
|
||||||
// Check loopback first
|
// Check loopback first
|
||||||
if ( !NET_GetLoopPacket( &inpacket ) )
|
if ( !NET_GetLoopPacket( &inpacket ) )
|
||||||
{
|
{
|
||||||
if ( !NET_IsMultiplayer() )
|
if ( !NET_IsMultiplayer() && sock != NS_CLIENT )
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2351,7 +2352,7 @@ int NET_SendPacket ( INetChannel *chan, int sock, const netadr_t &to, const uns
|
||||||
Msg("UDP -> %s: sz=%i OOB '%c'\n", to.ToString(), length, data[4] );
|
Msg("UDP -> %s: sz=%i OOB '%c'\n", to.ToString(), length, data[4] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !NET_IsMultiplayer() || to.type == NA_LOOPBACK || ( to.IsLocalhost() && !net_usesocketsforloopback.GetBool() ) )
|
if ( (!NET_IsMultiplayer() && sock != NS_CLIENT) || to.type == NA_LOOPBACK || ( to.IsLocalhost() && !net_usesocketsforloopback.GetBool() ) )
|
||||||
{
|
{
|
||||||
Assert( !pVoicePayload );
|
Assert( !pVoicePayload );
|
||||||
|
|
||||||
|
@ -2988,6 +2989,8 @@ void NET_RunFrame( double flRealtime )
|
||||||
|
|
||||||
#endif // SWDS
|
#endif // SWDS
|
||||||
|
|
||||||
|
master->RunFrame();
|
||||||
|
|
||||||
#ifdef _X360
|
#ifdef _X360
|
||||||
if ( net_logserver.GetInt() )
|
if ( net_logserver.GetInt() )
|
||||||
{
|
{
|
||||||
|
@ -3110,7 +3113,7 @@ void NET_ListenSocket( int sock, bool bListen )
|
||||||
NET_CloseSocket( netsock->hTCP, sock );
|
NET_CloseSocket( netsock->hTCP, sock );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !NET_IsMultiplayer() || net_notcp )
|
if ( (!NET_IsMultiplayer() && sock != NS_CLIENT) || net_notcp )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( bListen )
|
if ( bListen )
|
||||||
|
@ -3296,6 +3299,11 @@ void NET_Init( bool bIsDedicated )
|
||||||
ipname.SetValue( ip ); // update the cvar right now, this will get overwritten by "stuffcmds" later
|
ipname.SetValue( ip ); // update the cvar right now, this will get overwritten by "stuffcmds" later
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int nProtocol = X360SecureNetwork() ? IPPROTO_VDP : IPPROTO_UDP;
|
||||||
|
|
||||||
|
// open client socket for masterserver
|
||||||
|
OpenSocketInternal( NS_CLIENT, clientport.GetInt(), PORT_SERVER, "client", nProtocol, true );
|
||||||
|
|
||||||
if ( bIsDedicated )
|
if ( bIsDedicated )
|
||||||
{
|
{
|
||||||
// set dedicated MP mode
|
// set dedicated MP mode
|
||||||
|
|
|
@ -41,8 +41,8 @@ static ConVar sv_timeout( "sv_timeout", "65", 0, "After this many seconds withou
|
||||||
static ConVar sv_maxrate( "sv_maxrate", "0", FCVAR_REPLICATED, "Max bandwidth rate allowed on server, 0 == unlimited" );
|
static ConVar sv_maxrate( "sv_maxrate", "0", FCVAR_REPLICATED, "Max bandwidth rate allowed on server, 0 == unlimited" );
|
||||||
static ConVar sv_minrate( "sv_minrate", "3500", FCVAR_REPLICATED, "Min bandwidth rate allowed on server, 0 == unlimited" );
|
static ConVar sv_minrate( "sv_minrate", "3500", FCVAR_REPLICATED, "Min bandwidth rate allowed on server, 0 == unlimited" );
|
||||||
|
|
||||||
ConVar sv_maxupdaterate( "sv_maxupdaterate", "66", FCVAR_REPLICATED, "Maximum updates per second that the server will allow" );
|
ConVar sv_maxupdaterate( "sv_maxupdaterate", "100", FCVAR_REPLICATED, "Maximum updates per second that the server will allow" );
|
||||||
ConVar sv_minupdaterate( "sv_minupdaterate", "10", FCVAR_REPLICATED, "Minimum updates per second that the server will allow" );
|
ConVar sv_minupdaterate( "sv_minupdaterate", "20", FCVAR_REPLICATED, "Minimum updates per second that the server will allow" );
|
||||||
|
|
||||||
ConVar sv_stressbots("sv_stressbots", "0", FCVAR_DEVELOPMENTONLY, "If set to 1, the server calculates data and fills packets to bots. Used for perf testing.");
|
ConVar sv_stressbots("sv_stressbots", "0", FCVAR_DEVELOPMENTONLY, "If set to 1, the server calculates data and fills packets to bots. Used for perf testing.");
|
||||||
static ConVar sv_allowdownload ("sv_allowdownload", "1", 0, "Allow clients to download files");
|
static ConVar sv_allowdownload ("sv_allowdownload", "1", 0, "Allow clients to download files");
|
||||||
|
|
|
@ -218,8 +218,8 @@ static ConVar sv_voicecodec( "sv_voicecodec", "vaudio_opus", 0,
|
||||||
"steam - Use Steam voice API" );
|
"steam - Use Steam voice API" );
|
||||||
|
|
||||||
|
|
||||||
ConVar sv_mincmdrate( "sv_mincmdrate", "10", FCVAR_REPLICATED, "This sets the minimum value for cl_cmdrate. 0 == unlimited." );
|
ConVar sv_mincmdrate( "sv_mincmdrate", "20", FCVAR_REPLICATED, "This sets the minimum value for cl_cmdrate. 0 == unlimited." );
|
||||||
ConVar sv_maxcmdrate( "sv_maxcmdrate", "66", FCVAR_REPLICATED, "(If sv_mincmdrate is > 0), this sets the maximum value for cl_cmdrate." );
|
ConVar sv_maxcmdrate( "sv_maxcmdrate", "100", FCVAR_REPLICATED, "(If sv_mincmdrate is > 0), this sets the maximum value for cl_cmdrate." );
|
||||||
ConVar sv_client_cmdrate_difference( "sv_client_cmdrate_difference", "20", FCVAR_REPLICATED,
|
ConVar sv_client_cmdrate_difference( "sv_client_cmdrate_difference", "20", FCVAR_REPLICATED,
|
||||||
"cl_cmdrate is moved to within sv_client_cmdrate_difference units of cl_updaterate before it "
|
"cl_cmdrate is moved to within sv_client_cmdrate_difference units of cl_updaterate before it "
|
||||||
"is clamped between sv_mincmdrate and sv_maxcmdrate." );
|
"is clamped between sv_mincmdrate and sv_maxcmdrate." );
|
||||||
|
|
|
@ -1005,7 +1005,7 @@ void Heartbeat_f()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ConCommand heartbeat( "heartbeat", Heartbeat_f, "Force heartbeat of master servers", 0 );
|
//static ConCommand heartbeat( "heartbeat", Heartbeat_f, "Force heartbeat of master servers", 0 );
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
@ -196,6 +196,7 @@ def build(bld):
|
||||||
'EngineSoundServer.cpp',
|
'EngineSoundServer.cpp',
|
||||||
'audio/voice_wavefile.cpp',
|
'audio/voice_wavefile.cpp',
|
||||||
'audio/vox.cpp',
|
'audio/vox.cpp',
|
||||||
|
'masterserver.cpp',
|
||||||
|
|
||||||
#'audio/snd_dev_xaudio.cpp',[$X360]
|
#'audio/snd_dev_xaudio.cpp',[$X360]
|
||||||
#'audio/snd_wave_mixer_xma.cpp', [$X360]
|
#'audio/snd_wave_mixer_xma.cpp', [$X360]
|
||||||
|
@ -329,7 +330,7 @@ def build(bld):
|
||||||
'vgui_texturebudgetpanel.cpp',
|
'vgui_texturebudgetpanel.cpp',
|
||||||
'vgui_vprofgraphpanel.cpp',
|
'vgui_vprofgraphpanel.cpp',
|
||||||
'vgui_vprofpanel.cpp',
|
'vgui_vprofpanel.cpp',
|
||||||
'toolframework.cpp'
|
'toolframework.cpp',
|
||||||
]
|
]
|
||||||
|
|
||||||
if bld.env.DEST_OS != 'win32':
|
if bld.env.DEST_OS != 'win32':
|
||||||
|
|
102
public/engine/iserversinfo.h
Normal file
102
public/engine/iserversinfo.h
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. =======
|
||||||
|
//
|
||||||
|
// Purpose: interface to steam managing game server/client match making
|
||||||
|
//
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
#ifndef ISERVERSINFO_H
|
||||||
|
#define ISERVERSINFO_H
|
||||||
|
#ifdef _WIN32
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MAX_GAME_DESCRIPTION 8192
|
||||||
|
#define MAX_SERVER_NAME 2048
|
||||||
|
|
||||||
|
enum NServerResponse
|
||||||
|
{
|
||||||
|
nServerResponded = 0,
|
||||||
|
nServerFailedToRespond,
|
||||||
|
nNoServersListedOnMasterServer,
|
||||||
|
};
|
||||||
|
|
||||||
|
class newgameserver_t
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
newgameserver_t() = default;
|
||||||
|
|
||||||
|
netadr_t m_NetAdr; ///< IP/Query Port/Connection Port for this server
|
||||||
|
int m_nPing; ///< current ping time in milliseconds
|
||||||
|
int m_nProtocolVersion;
|
||||||
|
bool m_bHadSuccessfulResponse; ///< server has responded successfully in the past
|
||||||
|
bool m_bDoNotRefresh; ///< server is marked as not responding and should no longer be refreshed
|
||||||
|
char m_szGameDir[MAX_PATH]; ///< current game directory
|
||||||
|
char m_szMap[MAX_PATH]; ///< current map
|
||||||
|
char m_szGameTags[MAX_PATH];
|
||||||
|
char m_szGameDescription[MAX_GAME_DESCRIPTION]; ///< game description
|
||||||
|
|
||||||
|
int m_nPlayers;
|
||||||
|
int m_nMaxPlayers; ///< Maximum players that can join this server
|
||||||
|
int m_nBotPlayers; ///< Number of bots (i.e simulated players) on this server
|
||||||
|
bool m_bPassword; ///< true if this server needs a password to join
|
||||||
|
|
||||||
|
int m_iFlags;
|
||||||
|
|
||||||
|
/// Game server name
|
||||||
|
char m_szServerName[MAX_SERVER_NAME];
|
||||||
|
};
|
||||||
|
|
||||||
|
class IServerListResponse
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Server has responded ok with updated data
|
||||||
|
virtual void ServerResponded( newgameserver_t &server ) = 0;
|
||||||
|
virtual void RefreshComplete( NServerResponse response ) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Callback interface for receiving responses after pinging an individual server
|
||||||
|
//
|
||||||
|
class IServerPingResponse
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Server has responded successfully and has updated data
|
||||||
|
virtual void ServerResponded( newgameserver_t &server ) = 0;
|
||||||
|
};
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Callback interface for receiving responses after requesting details on
|
||||||
|
// who is playing on a particular server.
|
||||||
|
//
|
||||||
|
class IServerPlayersResponse
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Got data on a new player on the server -- you'll get this callback once per player
|
||||||
|
// on the server which you have requested player data on.
|
||||||
|
virtual void AddPlayerToList( const char *pchName, int nScore, float flTimePlayed ) = 0;
|
||||||
|
|
||||||
|
// The server failed to respond to the request for player details
|
||||||
|
virtual void PlayersFailedToRespond() = 0;
|
||||||
|
|
||||||
|
// The server has finished responding to the player details request
|
||||||
|
virtual void PlayersRefreshComplete() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Functions for match making services for clients to get to game lists and details
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
class IServersInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void RequestInternetServerList( const char *gamedir, IServerListResponse *response ) = 0;
|
||||||
|
virtual void RequestLANServerList( const char *gamedir, IServerListResponse *response ) = 0;
|
||||||
|
virtual void StopRefresh() = 0;
|
||||||
|
|
||||||
|
//virtual HServerQuery PingServer( uint32 unIP, uint16 usPort, ISteamMatchmakingPingResponse *pRequestServersResponse ) = 0;
|
||||||
|
//virtual HServerQuery PlayerDetails( uint32 unIP, uint16 usPort, ISteamMatchmakingPlayersResponse *pRequestServersResponse ) = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
#define SERVERLIST_INTERFACE_VERSION "ServerList001"
|
||||||
|
|
||||||
|
extern IServersInfo *g_pServersInfo;
|
||||||
|
|
||||||
|
#endif // ISERVERSINFO_H
|
|
@ -11,15 +11,21 @@ namespace memutils
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline void copy( T *dest, const T *src, size_t n )
|
inline void copy( T *dest, const T *src, size_t n )
|
||||||
{
|
{
|
||||||
for(; n; n--)
|
do
|
||||||
*(dest++) = *(src++);
|
{
|
||||||
|
--n;
|
||||||
|
*(dest+n) = *(src+n);
|
||||||
|
} while( n );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline void set( T *dest, const T& value, size_t n )
|
inline void set( T *dest, T value, size_t n )
|
||||||
{
|
{
|
||||||
for(; n; n--)
|
do
|
||||||
*(dest++) = value;
|
{
|
||||||
|
--n;
|
||||||
|
*(dest+n) = value;
|
||||||
|
} while( n );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,13 +46,13 @@ bool GameSupportsReplay()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------
|
||||||
bool IsReplayServer( gameserveritem_t &server )
|
bool IsReplayServer( newgameserver_t &server )
|
||||||
{
|
{
|
||||||
bool bReplay = false;
|
bool bReplay = false;
|
||||||
|
|
||||||
if ( GameSupportsReplay() )
|
if ( GameSupportsReplay() )
|
||||||
{
|
{
|
||||||
if ( server.m_szGameTags && server.m_szGameTags[0] )
|
if ( server.m_szGameTags[0] )
|
||||||
{
|
{
|
||||||
CUtlVector<char*> TagList;
|
CUtlVector<char*> TagList;
|
||||||
V_SplitString( server.m_szGameTags, ",", 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 = new Button(this, "ConnectButton", "#ServerBrowser_Connect");
|
||||||
m_pConnect->SetEnabled(false);
|
m_pConnect->SetEnabled(false);
|
||||||
m_pRefreshAll = new Button(this, "RefreshButton", "#ServerBrowser_Refresh");
|
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_pAddServer = new Button(this, "AddServerButton", "#ServerBrowser_AddServer");
|
||||||
m_pAddCurrentServer = new Button(this, "AddCurrentServerButton", "#ServerBrowser_AddCurrentServer");
|
m_pAddCurrentServer = new Button(this, "AddCurrentServerButton", "#ServerBrowser_AddCurrentServer");
|
||||||
m_pGameList = new CGameListPanel(this, "gamelist");
|
m_pGameList = new CGameListPanel(this, "gamelist");
|
||||||
m_pGameList->SetAllowUserModificationOfColumns(true);
|
m_pGameList->SetAllowUserModificationOfColumns(true);
|
||||||
|
m_pRefreshQuick = new Button(this, "RefreshQuickButton", "#ServerBrowser_RefreshQuick");
|
||||||
|
|
||||||
m_pQuickList = new PanelListPanel(this, "quicklist");
|
m_pQuickList = new PanelListPanel(this, "quicklist");
|
||||||
m_pQuickList->SetFirstColumnWidth( 0 );
|
m_pQuickList->SetFirstColumnWidth( 0 );
|
||||||
|
@ -191,14 +191,14 @@ CBaseGamesPage::CBaseGamesPage( vgui::Panel *parent, const char *name, EPageType
|
||||||
300, // maxwidth
|
300, // maxwidth
|
||||||
0 // flags
|
0 // flags
|
||||||
);
|
);
|
||||||
m_pGameList->AddColumnHeader( k_nColumn_Players, "Players", "#ServerBrowser_Players", 55, 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", 40, 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,
|
m_pGameList->AddColumnHeader( k_nColumn_Map, "Map", "#ServerBrowser_Map", 90,
|
||||||
90, // minwidth
|
90, // minwidth
|
||||||
300, // maxwidth
|
300, // maxwidth
|
||||||
0 // flags
|
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_Password, "#ServerBrowser_PasswordColumn_Tooltip");
|
||||||
m_pGameList->SetColumnHeaderTooltip( k_nColumn_Bots, "#ServerBrowser_BotColumn_Tooltip");
|
m_pGameList->SetColumnHeaderTooltip( k_nColumn_Bots, "#ServerBrowser_BotColumn_Tooltip");
|
||||||
|
@ -280,12 +280,10 @@ void CBaseGamesPage::PerformLayout()
|
||||||
|
|
||||||
if (SupportsItem(IGameList::GETNEWLIST))
|
if (SupportsItem(IGameList::GETNEWLIST))
|
||||||
{
|
{
|
||||||
m_pRefreshQuick->SetVisible(true);
|
|
||||||
m_pRefreshAll->SetText("#ServerBrowser_RefreshAll");
|
m_pRefreshAll->SetText("#ServerBrowser_RefreshAll");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_pRefreshQuick->SetVisible(false);
|
|
||||||
m_pRefreshAll->SetText("#ServerBrowser_Refresh");
|
m_pRefreshAll->SetText("#ServerBrowser_Refresh");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,25 +311,8 @@ void CBaseGamesPage::PerformLayout()
|
||||||
m_pRefreshAll->SetText( "#ServerBrowser_StopRefreshingList" );
|
m_pRefreshAll->SetText( "#ServerBrowser_StopRefreshingList" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pGameList->GetItemCount() > 0)
|
m_pRefreshQuick->SetVisible( false );
|
||||||
{
|
m_pFilter->SetVisible(false);
|
||||||
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" );
|
|
||||||
}
|
|
||||||
|
|
||||||
Repaint();
|
Repaint();
|
||||||
}
|
}
|
||||||
|
@ -378,20 +359,6 @@ struct serverqualitysort_t
|
||||||
|
|
||||||
int ServerQualitySort( const serverqualitysort_t *pSQ1, const serverqualitysort_t *pSQ2 )
|
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;
|
return pSQ1->iPing - pSQ2->iPing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,156 +367,72 @@ int ServerQualitySort( const serverqualitysort_t *pSQ1, const serverqualitysort_
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CBaseGamesPage::SelectQuickListServers( void )
|
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
|
return p1->m_nPing - p2->m_nPing;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: prepares all the QuickListPanel map panels...
|
// 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 ];
|
char szMapName[ 512 ];
|
||||||
Q_snprintf( szMapName, sizeof( szMapName ), "%s", pMapName );
|
Q_snprintf( szMapName, sizeof( szMapName ), "%s", server->m_szMap );
|
||||||
|
|
||||||
Q_strlower( szMapName );
|
Q_strlower( szMapName );
|
||||||
|
|
||||||
char path[ 512 ];
|
char path[ 512 ];
|
||||||
Q_snprintf( path, sizeof( path ), "maps/%s.bsp", szMapName );
|
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;
|
serverping_t serverping;
|
||||||
iIndex = m_quicklistserverlist.Insert( szMapName, vecMapServers );
|
const char *pFriendlyName = CloneString( szFriendlyName );
|
||||||
|
const char *pOriginalName = CloneString( szMapName );
|
||||||
|
|
||||||
char szFriendlyName[MAX_MAP_NAME];
|
char path[ 512 ];
|
||||||
const char *pszFriendlyGameTypeName = ServerBrowser().GetMapFriendlyNameAndGameType( szMapName, szFriendlyName, sizeof(szFriendlyName) );
|
Q_snprintf( path, sizeof( path ), "maps/%s.bsp", szMapName );
|
||||||
|
|
||||||
//Add the map to our list of panels.
|
CQuickListPanel *pQuickListPanel = new CQuickListPanel( m_pQuickList, "QuickListPanel");
|
||||||
if ( m_pQuickList )
|
|
||||||
|
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 );
|
serverping.iPanelIndex = m_pQuickList->AddItem( NULL, pQuickListPanel );
|
||||||
servermap.pOriginalName = CloneString( szMapName );
|
|
||||||
|
|
||||||
char path[ 512 ];
|
serverping.m_nPing = server->m_nPing;
|
||||||
Q_snprintf( path, sizeof( path ), "maps/%s.bsp", szMapName );
|
|
||||||
|
|
||||||
servermap.bOnDisk = g_pFullFileSystem->FileExists( path, "MOD" );
|
m_vecServersFound.AddToTail( serverping );
|
||||||
|
m_vecServersFound.Sort( ServerPingSortFunc );
|
||||||
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 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Now make sure that list is sorted.
|
|
||||||
CUtlVector<int> *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() )
|
//Now make sure that list is sorted.
|
||||||
{
|
CUtlVector<int> *pPanelSort = m_pQuickList->GetSortedVector();
|
||||||
CQuickListMapServerList *vecMapServers = &m_quicklistserverlist[iIndex];
|
|
||||||
|
|
||||||
if ( vecMapServers )
|
if ( pPanelSort )
|
||||||
|
{
|
||||||
|
pPanelSort->RemoveAll();
|
||||||
|
|
||||||
|
for ( int i = 0; i < m_vecServersFound.Count(); i++ )
|
||||||
{
|
{
|
||||||
if ( vecMapServers->Find( iListID ) == vecMapServers->InvalidIndex() )
|
pPanelSort->AddToTail( m_vecServersFound[i].iPanelIndex );
|
||||||
{
|
|
||||||
vecMapServers->AddToTail( iListID );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -557,21 +440,10 @@ void CBaseGamesPage::PrepareQuickListMap( const char *pMapName, int iListID )
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: gets information about specified server
|
// Purpose: gets information about specified server
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
gameserveritem_t *CBaseGamesPage::GetServer( unsigned int serverID )
|
newgameserver_t *CBaseGamesPage::GetServer( unsigned int serverID )
|
||||||
{
|
{
|
||||||
if ( !steamapicontext->SteamMatchmakingServers() )
|
if( serverID >= m_serversInfo.Count() ) return NULL;
|
||||||
return NULL;
|
return &m_serversInfo[serverID];
|
||||||
|
|
||||||
// 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...
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -680,8 +552,8 @@ void CBaseGamesPage::CreateFilters()
|
||||||
int iItemID = m_pGameFilter->AddItem(ModList().GetModName(i), pkv);
|
int iItemID = m_pGameFilter->AddItem(ModList().GetModName(i), pkv);
|
||||||
m_mapGamesFilterItem.Insert( ModList().GetAppID(i).ToUint64(), iItemID );
|
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_bFilterNoEmptyServers = filter->GetInt("NoEmpty");
|
||||||
m_bFilterNoPasswordedServers = filter->GetInt("NoPassword");
|
m_bFilterNoPasswordedServers = filter->GetInt("NoPassword");
|
||||||
m_bFilterReplayServers = filter->GetInt("Replay");
|
m_bFilterReplayServers = filter->GetInt("Replay");
|
||||||
m_pQuickListCheckButton->SetSelected( filter->GetInt( "QuickList", 0 ) );
|
m_pQuickListCheckButton->SetSelected( filter->GetInt( "QuickList", IsAndroid() ) );
|
||||||
|
|
||||||
int secureFilter = filter->GetInt("Secure");
|
int secureFilter = filter->GetInt("Secure");
|
||||||
m_pSecureFilter->ActivateItem(secureFilter);
|
m_pSecureFilter->ActivateItem(secureFilter);
|
||||||
|
@ -797,19 +669,19 @@ void CBaseGamesPage::UpdateGameFilter()
|
||||||
// Purpose: Handles incoming server refresh data
|
// Purpose: Handles incoming server refresh data
|
||||||
// updates the server browser with the refreshed information from the server itself
|
// 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
|
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() )
|
while ( m_mapServers.Find( nIndex ) != m_mapServers.InvalidIndex() )
|
||||||
nIndex--;
|
nIndex--;
|
||||||
ServerResponded( nIndex, &server );
|
ServerResponded( nIndex, &server );
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Callback for ISteamMatchmakingServerListResponse
|
// 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 );
|
gameserveritem_t *pServerItem = steamapicontext->SteamMatchmakingServers()->GetServerDetails( hReq, iServer );
|
||||||
if ( !pServerItem )
|
if ( !pServerItem )
|
||||||
|
@ -825,15 +697,17 @@ void CBaseGamesPage::ServerResponded( HServerListRequest hReq, int iServer )
|
||||||
pServerItem->m_nMaxPlayers = (uint8)(int8)pServerItem->m_nMaxPlayers;
|
pServerItem->m_nMaxPlayers = (uint8)(int8)pServerItem->m_nMaxPlayers;
|
||||||
|
|
||||||
ServerResponded( iServer, pServerItem );
|
ServerResponded( iServer, pServerItem );
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Handles incoming server refresh data
|
// Purpose: Handles incoming server refresh data
|
||||||
// updates the server browser with the refreshed information from the server itself
|
// updates the server browser with the refreshed information from the server itself
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void CBaseGamesPage::ServerResponded( int iServer, gameserveritem_t *pServerItem )
|
void CBaseGamesPage::ServerResponded( int iServer, gameserveritem_t *pServerItem )
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
int iServerMap = m_mapServers.Find( iServer );
|
int iServerMap = m_mapServers.Find( iServer );
|
||||||
if ( iServerMap == m_mapServers.InvalidIndex() )
|
if ( iServerMap == m_mapServers.InvalidIndex() )
|
||||||
{
|
{
|
||||||
|
@ -988,6 +862,7 @@ void CBaseGamesPage::ServerResponded( int iServer, gameserveritem_t *pServerItem
|
||||||
PrepareQuickListMap( pServerItem->m_szMap, pServer->m_iListID );
|
PrepareQuickListMap( pServerItem->m_szMap, pServer->m_iListID );
|
||||||
UpdateStatus();
|
UpdateStatus();
|
||||||
m_iServerRefreshCount++;
|
m_iServerRefreshCount++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1002,7 +877,13 @@ void CBaseGamesPage::UpdateFilterAndQuickListVisibility()
|
||||||
|
|
||||||
int wide, tall;
|
int wide, tall;
|
||||||
GetSize( 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();
|
UpdateDerivedLayouts();
|
||||||
UpdateGameFilter();
|
UpdateGameFilter();
|
||||||
|
@ -1015,12 +896,10 @@ void CBaseGamesPage::UpdateFilterAndQuickListVisibility()
|
||||||
|
|
||||||
SetSize( wide, tall );
|
SetSize( wide, tall );
|
||||||
|
|
||||||
|
|
||||||
m_pQuickList->SetVisible( showQuickList );
|
m_pQuickList->SetVisible( showQuickList );
|
||||||
m_pGameList->SetVisible( !showQuickList );
|
m_pGameList->SetVisible( !showQuickList );
|
||||||
m_pFilter->SetVisible( !showQuickList );
|
m_pFilter->SetVisible( !showQuickList );
|
||||||
m_pFilterString->SetVisible ( !showQuickList );
|
m_pFilterString->SetVisible ( !showQuickList );
|
||||||
|
|
||||||
|
|
||||||
InvalidateLayout();
|
InvalidateLayout();
|
||||||
|
|
||||||
|
@ -1143,11 +1022,10 @@ void CBaseGamesPage::OnTextChanged(Panel *panel, const char *text)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CBaseGamesPage::ApplyGameFilters()
|
void CBaseGamesPage::ApplyGameFilters()
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if ( !steamapicontext->SteamMatchmakingServers() )
|
if ( !steamapicontext->SteamMatchmakingServers() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_iServersBlacklisted = 0;
|
|
||||||
|
|
||||||
// loop through all the servers checking filters
|
// loop through all the servers checking filters
|
||||||
FOR_EACH_MAP_FAST( m_mapServers, i )
|
FOR_EACH_MAP_FAST( m_mapServers, i )
|
||||||
{
|
{
|
||||||
|
@ -1215,6 +1093,7 @@ void CBaseGamesPage::ApplyGameFilters()
|
||||||
m_pGameList->SortList();
|
m_pGameList->SortList();
|
||||||
InvalidateLayout();
|
InvalidateLayout();
|
||||||
Repaint();
|
Repaint();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1224,14 +1103,10 @@ void CBaseGamesPage::UpdateStatus()
|
||||||
{
|
{
|
||||||
if (m_pGameList->GetItemCount() > 1)
|
if (m_pGameList->GetItemCount() > 1)
|
||||||
{
|
{
|
||||||
wchar_t header[256];
|
wchar_t msg[256];
|
||||||
wchar_t count[128];
|
|
||||||
wchar_t blacklistcount[128];
|
|
||||||
|
|
||||||
_snwprintf( count, Q_ARRAYSIZE(count), L"%d", m_pGameList->GetItemCount() );
|
_snwprintf( msg, Q_ARRAYSIZE(msg), L"%S( %d )", g_pVGuiLocalize->Find( "#ServerBrowser_Servers"), m_pGameList->GetItemCount() );
|
||||||
_snwprintf( blacklistcount, Q_ARRAYSIZE(blacklistcount), L"%d", m_iServersBlacklisted );
|
m_pGameList->SetColumnHeaderText( k_nColumn_Name, msg);
|
||||||
g_pVGuiLocalize->ConstructString( header, sizeof( header ), g_pVGuiLocalize->Find( "#ServerBrowser_ServersCountWithBlacklist"), 2, count, blacklistcount );
|
|
||||||
m_pGameList->SetColumnHeaderText( k_nColumn_Name, header);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1529,19 +1404,12 @@ void CBaseGamesPage::RecalculateFilterString()
|
||||||
// Purpose: Checks to see if the server passes the primary filters
|
// Purpose: Checks to see if the server passes the primary filters
|
||||||
// if the server fails the filters, it will not be refreshed again
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's blacklisted, we ignore it too
|
|
||||||
if ( ServerBrowserDialog().IsServerBlacklisted( server ) )
|
|
||||||
{
|
|
||||||
m_iServersBlacklisted++;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1551,7 +1419,7 @@ bool CBaseGamesPage::CheckPrimaryFilters( gameserveritem_t &server )
|
||||||
// server will be continued to be pinged if it fails the filter, since
|
// server will be continued to be pinged if it fails the filter, since
|
||||||
// the relvent server data is dynamic
|
// the relvent server data is dynamic
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CBaseGamesPage::CheckSecondaryFilters( gameserveritem_t &server )
|
bool CBaseGamesPage::CheckSecondaryFilters( newgameserver_t &server )
|
||||||
{
|
{
|
||||||
bool bFilterNoEmpty = m_bFilterNoEmptyServers;
|
bool bFilterNoEmpty = m_bFilterNoEmptyServers;
|
||||||
bool bFilterNoFull = m_bFilterNoFullServers;
|
bool bFilterNoFull = m_bFilterNoFullServers;
|
||||||
|
@ -1595,7 +1463,7 @@ bool CBaseGamesPage::CheckSecondaryFilters( gameserveritem_t &server )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( iFilterSecure == FILTER_SECURESERVERSONLY && !server.m_bSecure )
|
/*if ( iFilterSecure == FILTER_SECURESERVERSONLY && !server.m_bSecure )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1608,7 +1476,7 @@ bool CBaseGamesPage::CheckSecondaryFilters( gameserveritem_t &server )
|
||||||
if ( m_bFilterReplayServers && !IsReplayServer( server ) )
|
if ( m_bFilterReplayServers && !IsReplayServer( server ) )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if ( m_pQuickList->IsVisible() == false )
|
if ( m_pQuickList->IsVisible() == false )
|
||||||
{
|
{
|
||||||
|
@ -1646,7 +1514,6 @@ void CBaseGamesPage::SetRefreshing(bool state)
|
||||||
m_pGameList->SetEmptyListText("");
|
m_pGameList->SetEmptyListText("");
|
||||||
m_pRefreshAll->SetText("#ServerBrowser_StopRefreshingList");
|
m_pRefreshAll->SetText("#ServerBrowser_StopRefreshingList");
|
||||||
m_pRefreshAll->SetCommand("stoprefresh");
|
m_pRefreshAll->SetCommand("stoprefresh");
|
||||||
m_pRefreshQuick->SetEnabled(false);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1662,14 +1529,6 @@ void CBaseGamesPage::SetRefreshing(bool state)
|
||||||
m_pRefreshAll->SetCommand("GetNewList");
|
m_pRefreshAll->SetCommand("GetNewList");
|
||||||
|
|
||||||
// 'refresh quick' button is only enabled if there are servers in the list
|
// '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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1770,7 +1629,7 @@ int CBaseGamesPage::GetSelectedItemsCount()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CBaseGamesPage::OnAddToFavorites()
|
void CBaseGamesPage::OnAddToFavorites()
|
||||||
{
|
{
|
||||||
if ( !steamapicontext->SteamMatchmakingServers() )
|
/* if ( !steamapicontext->SteamMatchmakingServers() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// loop through all the selected favorites
|
// loop through all the selected favorites
|
||||||
|
@ -1784,40 +1643,18 @@ void CBaseGamesPage::OnAddToFavorites()
|
||||||
// add to favorites list
|
// add to favorites list
|
||||||
ServerBrowserDialog().AddServerToFavorites(*pServer);
|
ServerBrowserDialog().AddServerToFavorites(*pServer);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// 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:
|
// Purpose:
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#if 0
|
||||||
void CBaseGamesPage::ServerFailedToRespond( HServerListRequest hReq, int iServer )
|
void CBaseGamesPage::ServerFailedToRespond( HServerListRequest hReq, int iServer )
|
||||||
{
|
{
|
||||||
ServerResponded( hReq, iServer );
|
ServerResponded( hReq, iServer );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: removes the server from the UI list
|
// Purpose: removes the server from the UI list
|
||||||
|
@ -1864,41 +1701,38 @@ void CBaseGamesPage::OnRefreshServer( int serverID )
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CBaseGamesPage::StartRefresh()
|
void CBaseGamesPage::StartRefresh()
|
||||||
{
|
{
|
||||||
if ( !steamapicontext->SteamMatchmakingServers() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
ClearServerList();
|
ClearServerList();
|
||||||
MatchMakingKeyValuePair_t *pFilters;
|
MatchMakingKeyValuePair_t *pFilters;
|
||||||
int nFilters = GetServerFilters( &pFilters );
|
int nFilters = GetServerFilters( &pFilters );
|
||||||
|
|
||||||
if ( m_hRequest )
|
m_serversInfo.SetCount(0);
|
||||||
|
|
||||||
|
/* if ( m_hRequest )
|
||||||
{
|
{
|
||||||
steamapicontext->SteamMatchmakingServers()->ReleaseRequest( m_hRequest );
|
steamapicontext->SteamMatchmakingServers()->ReleaseRequest( m_hRequest );
|
||||||
m_hRequest = NULL;
|
m_hRequest = NULL;
|
||||||
}
|
}*/
|
||||||
switch ( m_eMatchMakingType )
|
switch ( m_eMatchMakingType )
|
||||||
{
|
{
|
||||||
case eFavoritesServer:
|
/* case eFavoritesServer:
|
||||||
m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestFavoritesServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this );
|
m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestFavoritesServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this );
|
||||||
break;
|
break;
|
||||||
case eHistoryServer:
|
case eHistoryServer:
|
||||||
m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestHistoryServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this );
|
m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestHistoryServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this );
|
||||||
break;
|
break;*/
|
||||||
case eInternetServer:
|
case eInternetServer:
|
||||||
m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestInternetServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this );
|
g_pServersInfo->RequestInternetServerList(COM_GetModDirectory(), this);
|
||||||
|
//m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestInternetServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this );
|
||||||
break;
|
break;
|
||||||
case eSpectatorServer:
|
/* case eSpectatorServer:
|
||||||
m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestSpectatorServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this );
|
m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestSpectatorServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this );
|
||||||
break;
|
break;
|
||||||
case eFriendsServer:
|
|
||||||
m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestFriendsServerList( GetFilterAppID().AppID(), &pFilters, nFilters, this );
|
|
||||||
break;
|
|
||||||
case eLANServer:
|
case eLANServer:
|
||||||
m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestLANServerList( GetFilterAppID().AppID(), this );
|
m_hRequest = steamapicontext->SteamMatchmakingServers()->RequestLANServerList( GetFilterAppID().AppID(), this );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Assert( !"Unknown server type" );
|
Assert( !"Unknown server type" );
|
||||||
break;
|
break;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
SetRefreshing( true );
|
SetRefreshing( true );
|
||||||
|
@ -1912,20 +1746,7 @@ void CBaseGamesPage::StartRefresh()
|
||||||
void CBaseGamesPage::ClearQuickList( void )
|
void CBaseGamesPage::ClearQuickList( void )
|
||||||
{
|
{
|
||||||
m_pQuickList->DeleteAllItems();
|
m_pQuickList->DeleteAllItems();
|
||||||
m_vecMapNamesFound.RemoveAll();
|
m_vecServersFound.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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1936,7 +1757,6 @@ void CBaseGamesPage::ClearServerList()
|
||||||
m_mapServers.RemoveAll();
|
m_mapServers.RemoveAll();
|
||||||
m_mapServerIP.RemoveAll();
|
m_mapServerIP.RemoveAll();
|
||||||
m_pGameList->RemoveAll();
|
m_pGameList->RemoveAll();
|
||||||
m_iServersBlacklisted = 0;
|
|
||||||
|
|
||||||
ClearQuickList();
|
ClearQuickList();
|
||||||
}
|
}
|
||||||
|
@ -1960,11 +1780,10 @@ void CBaseGamesPage::StopRefresh()
|
||||||
m_iServerRefreshCount = 0;
|
m_iServerRefreshCount = 0;
|
||||||
|
|
||||||
// Stop the server list refreshing
|
// Stop the server list refreshing
|
||||||
if ( steamapicontext->SteamMatchmakingServers() )
|
g_pServersInfo->StopRefresh();
|
||||||
steamapicontext->SteamMatchmakingServers()->CancelQuery( m_hRequest );
|
|
||||||
|
|
||||||
// update UI
|
// update UI
|
||||||
RefreshComplete( m_hRequest, eServerResponded );
|
RefreshComplete( nServerResponded );
|
||||||
|
|
||||||
// apply settings
|
// apply settings
|
||||||
ApplyGameFilters();
|
ApplyGameFilters();
|
||||||
|
@ -1973,9 +1792,10 @@ void CBaseGamesPage::StopRefresh()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CBaseGamesPage::RefreshComplete( HServerListRequest hRequest, EMatchMakingServerResponse response )
|
void CBaseGamesPage::RefreshComplete( NServerResponse response )
|
||||||
{
|
{
|
||||||
SelectQuickListServers();
|
//Force the connect button to recalculate its state.
|
||||||
|
OnItemSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -2116,7 +1936,7 @@ void CDialogServerWarning::OnCommand(const char *command)
|
||||||
PostMessage(this, new KeyValues("Close"));
|
PostMessage(this, new KeyValues("Close"));
|
||||||
|
|
||||||
// join the game
|
// join the game
|
||||||
ServerBrowserDialog().JoinGame( m_pGameList, m_iServerID );
|
//ServerBrowserDialog().JoinGame( m_pGameList, m_iServerID );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2142,16 +1962,16 @@ void CDialogServerWarning::OnButtonToggled(Panel *panel, int state)
|
||||||
void CBaseGamesPage::OnBeginConnect()
|
void CBaseGamesPage::OnBeginConnect()
|
||||||
{
|
{
|
||||||
KeyValues *pKV = NULL;
|
KeyValues *pKV = NULL;
|
||||||
int serverID = GetSelectedServerID( &pKV );
|
int iServerIndex = GetSelectedServerID( &pKV );
|
||||||
|
|
||||||
if ( serverID == -1 )
|
if ( iServerIndex == -1 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Stop the current refresh
|
// Stop the current refresh
|
||||||
StopRefresh();
|
StopRefresh();
|
||||||
|
|
||||||
ConVarRef sb_dontshow_maxplayer_warning( "sb_dontshow_maxplayer_warning", true );
|
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
|
// If the server is above the suggested maxplayers, warn the player
|
||||||
int iMaxP = sb_mod_suggested_maxplayers.GetInt();
|
int iMaxP = sb_mod_suggested_maxplayers.GetInt();
|
||||||
|
@ -2177,10 +1997,10 @@ void CBaseGamesPage::OnBeginConnect()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// join the game
|
// join the game
|
||||||
ServerBrowserDialog().JoinGame(this, serverID);
|
ServerBrowserDialog().JoinGame(this, &m_serversInfo[iServerIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -2197,7 +2017,7 @@ void CBaseGamesPage::OnViewGameInfo()
|
||||||
StopRefresh();
|
StopRefresh();
|
||||||
|
|
||||||
// join the game
|
// join the game
|
||||||
ServerBrowserDialog().OpenGameInfoDialog(this, serverID);
|
//ServerBrowserDialog().OpenGameInfoDialog(this, serverID);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -2222,9 +2042,6 @@ const char *CBaseGamesPage::GetConnectCode()
|
||||||
case eLANServer:
|
case eLANServer:
|
||||||
pszConnectCode = "serverbrowser_lan";
|
pszConnectCode = "serverbrowser_lan";
|
||||||
break;
|
break;
|
||||||
case eFriendsServer:
|
|
||||||
pszConnectCode = "serverbrowser_friends";
|
|
||||||
break;
|
|
||||||
case eFavoritesServer:
|
case eFavoritesServer:
|
||||||
pszConnectCode = "serverbrowser_favorites";
|
pszConnectCode = "serverbrowser_favorites";
|
||||||
break;
|
break;
|
||||||
|
@ -2239,6 +2056,73 @@ const char *CBaseGamesPage::GetConnectCode()
|
||||||
return pszConnectCode;
|
return pszConnectCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CBaseGamesPage::ServerResponded( newgameserver_t &server )
|
||||||
|
{
|
||||||
|
Assert( server.m_NetAdr.GetIPHostByteOrder() != 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->m_szServerName);
|
||||||
|
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);
|
||||||
|
kv->SetInt("bots", pServerItem->m_nBotPlayers);
|
||||||
|
|
||||||
|
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", pServerItem->m_szGameTags);
|
||||||
|
|
||||||
|
kv->SetInt("Replay", 0);
|
||||||
|
|
||||||
|
int iServerIndex = m_serversInfo.AddToTail( server );
|
||||||
|
|
||||||
|
// new server, add to list
|
||||||
|
int iListID = m_pGameList->AddItem(kv, iServerIndex, false, false);
|
||||||
|
|
||||||
|
m_pGameList->SetItemVisible( iListID, true );
|
||||||
|
kv->deleteThis();
|
||||||
|
|
||||||
|
PrepareQuickListMap( &server, iListID );
|
||||||
|
UpdateStatus();
|
||||||
|
m_iServerRefreshCount++;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Refresh if our favorites list changed
|
// Purpose: Refresh if our favorites list changed
|
||||||
|
@ -2252,8 +2136,6 @@ void CBaseGamesPage::OnFavoritesMsg( FavoritesListChanged_t *pFavListChanged )
|
||||||
case eInternetServer:
|
case eInternetServer:
|
||||||
case eLANServer:
|
case eLANServer:
|
||||||
case eSpectatorServer:
|
case eSpectatorServer:
|
||||||
case eFriendsServer:
|
|
||||||
return;
|
|
||||||
case eFavoritesServer:
|
case eFavoritesServer:
|
||||||
case eHistoryServer:
|
case eHistoryServer:
|
||||||
// check containing property sheet to see if the page is visible.
|
// check containing property sheet to see if the page is visible.
|
||||||
|
@ -2276,8 +2158,6 @@ void CBaseGamesPage::OnFavoritesMsg( FavoritesListChanged_t *pFavListChanged )
|
||||||
case eInternetServer:
|
case eInternetServer:
|
||||||
case eLANServer:
|
case eLANServer:
|
||||||
case eSpectatorServer:
|
case eSpectatorServer:
|
||||||
case eFriendsServer:
|
|
||||||
break;
|
|
||||||
case eFavoritesServer:
|
case eFavoritesServer:
|
||||||
case eHistoryServer:
|
case eHistoryServer:
|
||||||
{
|
{
|
||||||
|
@ -2286,8 +2166,10 @@ void CBaseGamesPage::OnFavoritesMsg( FavoritesListChanged_t *pFavListChanged )
|
||||||
{
|
{
|
||||||
if ( pFavListChanged->m_bAdd )
|
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
|
// ignore deletes of fav's we didn't have
|
||||||
}
|
}
|
||||||
|
@ -2295,8 +2177,8 @@ void CBaseGamesPage::OnFavoritesMsg( FavoritesListChanged_t *pFavListChanged )
|
||||||
{
|
{
|
||||||
if ( pFavListChanged->m_bAdd )
|
if ( pFavListChanged->m_bAdd )
|
||||||
{
|
{
|
||||||
if ( m_mapServerIP[ iIPServer ] > 0 )
|
// if ( m_mapServerIP[ iIPServer ] > 0 )
|
||||||
ServerResponded( m_hRequest, m_mapServerIP[ iIPServer ] );
|
// ServerResponded( m_hRequest, m_mapServerIP[ iIPServer ] );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "tier1/utldict.h"
|
#include "tier1/utldict.h"
|
||||||
|
#include "engine/iserversinfo.h"
|
||||||
|
|
||||||
class CBaseGamesPage;
|
class CBaseGamesPage;
|
||||||
|
|
||||||
|
@ -65,12 +66,10 @@ public:
|
||||||
virtual void OnCursorExited();
|
virtual void OnCursorExited();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct servermaps_t
|
struct serverping_t
|
||||||
{
|
{
|
||||||
const char *pOriginalName;
|
int m_nPing;
|
||||||
const char *pFriendlyName;
|
int iPanelIndex;
|
||||||
int iPanelIndex;
|
|
||||||
bool bOnDisk;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gametypes_t
|
struct gametypes_t
|
||||||
|
@ -82,7 +81,7 @@ struct gametypes_t
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Base property page for all the games lists (internet/favorites/lan/etc.)
|
// 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 );
|
DECLARE_CLASS_SIMPLE( CBaseGamesPage, vgui::PropertyPage );
|
||||||
|
|
||||||
|
@ -119,7 +118,7 @@ public:
|
||||||
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
|
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
|
||||||
|
|
||||||
// gets information about specified server
|
// gets information about specified server
|
||||||
virtual gameserveritem_t *GetServer(unsigned int serverID);
|
virtual newgameserver_t *GetServer(unsigned int serverID);
|
||||||
virtual const char *GetConnectCode();
|
virtual const char *GetConnectCode();
|
||||||
|
|
||||||
uint32 GetServerFilters( MatchMakingKeyValuePair_t **pFilters );
|
uint32 GetServerFilters( MatchMakingKeyValuePair_t **pFilters );
|
||||||
|
@ -138,13 +137,12 @@ public:
|
||||||
|
|
||||||
// adds a server to the favorites
|
// adds a server to the favorites
|
||||||
MESSAGE_FUNC( OnAddToFavorites, "AddToFavorites" );
|
MESSAGE_FUNC( OnAddToFavorites, "AddToFavorites" );
|
||||||
MESSAGE_FUNC( OnAddToBlacklist, "AddToBlacklist" );
|
|
||||||
|
|
||||||
virtual void StartRefresh();
|
virtual void StartRefresh();
|
||||||
|
|
||||||
virtual void UpdateDerivedLayouts( void );
|
virtual void UpdateDerivedLayouts( void );
|
||||||
|
|
||||||
void PrepareQuickListMap( const char *pMapName, int iListID );
|
void PrepareQuickListMap( newgameserver_t *server, int iListID );
|
||||||
void SelectQuickListServers( void );
|
void SelectQuickListServers( void );
|
||||||
vgui::Panel *GetActiveList( void );
|
vgui::Panel *GetActiveList( void );
|
||||||
virtual bool IsQuickListButtonChecked()
|
virtual bool IsQuickListButtonChecked()
|
||||||
|
@ -173,14 +171,14 @@ protected:
|
||||||
void UpdateStatus();
|
void UpdateStatus();
|
||||||
|
|
||||||
// ISteamMatchmakingServerListResponse callbacks
|
// ISteamMatchmakingServerListResponse callbacks
|
||||||
virtual void ServerResponded( HServerListRequest hReq, int iServer );
|
virtual void ServerResponded( newgameserver_t &server );
|
||||||
virtual void ServerResponded( int iServer, gameserveritem_t *pServerItem );
|
virtual void RefreshComplete( NServerResponse response );
|
||||||
virtual void ServerFailedToRespond( HServerListRequest hReq, int iServer );
|
|
||||||
virtual void RefreshComplete( HServerListRequest hReq, EMatchMakingServerResponse response ) = 0;
|
|
||||||
|
|
||||||
// ISteamMatchmakingPingResponse callbacks
|
// ISteamMatchmakingPingResponse callbacks
|
||||||
virtual void ServerResponded( gameserveritem_t &server );
|
//virtual void ServerResponded( gameserveritem_t &server );
|
||||||
virtual void ServerFailedToRespond() {}
|
//virtual void ServerFailedToRespond() {}
|
||||||
|
|
||||||
|
virtual void ServerResponded( int iServer, gameserveritem_t *pServerItem );
|
||||||
|
|
||||||
// Removes server from list
|
// Removes server from list
|
||||||
void RemoveServer( serverdisplay_t &server );
|
void RemoveServer( serverdisplay_t &server );
|
||||||
|
@ -190,10 +188,10 @@ protected:
|
||||||
|
|
||||||
// filtering methods
|
// filtering methods
|
||||||
// returns true if filters passed; false if failed
|
// returns true if filters passed; false if failed
|
||||||
virtual bool CheckPrimaryFilters( gameserveritem_t &server);
|
virtual bool CheckPrimaryFilters( newgameserver_t &server);
|
||||||
virtual bool CheckSecondaryFilters( gameserveritem_t &server );
|
virtual bool CheckSecondaryFilters( newgameserver_t &server );
|
||||||
virtual bool CheckTagFilter( gameserveritem_t &server ) { return true; }
|
virtual bool CheckTagFilter( newgameserver_t &server ) { return true; }
|
||||||
virtual bool CheckWorkshopFilter( gameserveritem_t &server ) { return true; }
|
virtual bool CheckWorkshopFilter( newgameserver_t &server ) { return true; }
|
||||||
virtual int GetInvalidServerListID();
|
virtual int GetInvalidServerListID();
|
||||||
|
|
||||||
virtual void OnSaveFilter(KeyValues *filter);
|
virtual void OnSaveFilter(KeyValues *filter);
|
||||||
|
@ -236,10 +234,13 @@ protected:
|
||||||
CUtlMap<uint64, int> m_mapGamesFilterItem;
|
CUtlMap<uint64, int> m_mapGamesFilterItem;
|
||||||
CUtlMap<int, serverdisplay_t> m_mapServers;
|
CUtlMap<int, serverdisplay_t> m_mapServers;
|
||||||
CUtlMap<netadr_t, int> m_mapServerIP;
|
CUtlMap<netadr_t, int> m_mapServerIP;
|
||||||
|
|
||||||
|
CUtlVector<newgameserver_t> m_serversInfo;
|
||||||
|
|
||||||
CUtlVector<MatchMakingKeyValuePair_t> m_vecServerFilters;
|
CUtlVector<MatchMakingKeyValuePair_t> m_vecServerFilters;
|
||||||
CUtlDict< CQuickListMapServerList, int > m_quicklistserverlist;
|
CUtlDict< CQuickListMapServerList, int > m_quicklistserverlist;
|
||||||
int m_iServerRefreshCount;
|
int m_iServerRefreshCount;
|
||||||
CUtlVector< servermaps_t > m_vecMapNamesFound;
|
CUtlVector<serverping_t> m_vecServersFound;
|
||||||
|
|
||||||
|
|
||||||
EPageType m_eMatchMakingType;
|
EPageType m_eMatchMakingType;
|
||||||
|
@ -316,7 +317,6 @@ private:
|
||||||
bool m_bFilterNoEmptyServers;
|
bool m_bFilterNoEmptyServers;
|
||||||
bool m_bFilterNoPasswordedServers;
|
bool m_bFilterNoPasswordedServers;
|
||||||
int m_iSecureFilter;
|
int m_iSecureFilter;
|
||||||
int m_iServersBlacklisted;
|
|
||||||
bool m_bFilterReplayServers;
|
bool m_bFilterReplayServers;
|
||||||
|
|
||||||
CGameID m_iLimitToAppID;
|
CGameID m_iLimitToAppID;
|
||||||
|
|
|
@ -177,15 +177,13 @@ void CDialogAddServer::OnOK()
|
||||||
|
|
||||||
if ( AllowInvalidIPs() || netaddr.IsValid() )
|
if ( AllowInvalidIPs() || netaddr.IsValid() )
|
||||||
{
|
{
|
||||||
gameserveritem_t server;
|
newgameserver_t server;
|
||||||
memset(&server, 0, sizeof(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
|
// 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.
|
// better if they click "Servers" and choose a server in there.
|
||||||
server.m_NetAdr.Init( netaddr.GetIPHostByteOrder(), netaddr.GetPort(), netaddr.GetPort() );
|
server.m_NetAdr = netaddr;
|
||||||
|
|
||||||
server.m_nAppID = 0;
|
|
||||||
FinishAddServer( server );
|
FinishAddServer( server );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -257,21 +255,21 @@ void CDialogAddServer::TestServers()
|
||||||
m_pTabPanel->AddPage( m_pDiscoveredGames, str );
|
m_pTabPanel->AddPage( m_pDiscoveredGames, str );
|
||||||
m_pTabPanel->InvalidateLayout();
|
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 ) );
|
m_Queries.AddToTail( steamapicontext->SteamMatchmakingServers()->PingServer( vecAdress[ iAddress ].GetIPHostByteOrder(), vecAdress[ iAddress ].GetPort(), this ) );
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: A server answered our ping
|
// Purpose: A server answered our ping
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CDialogAddServer::ServerResponded( gameserveritem_t &server )
|
void CDialogAddServer::ServerResponded( newgameserver_t &server )
|
||||||
{
|
{
|
||||||
KeyValues *kv = new KeyValues( "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( "map", server.m_szMap );
|
||||||
kv->SetString( "GameDir", server.m_szGameDir );
|
kv->SetString( "GameDir", server.m_szGameDir );
|
||||||
kv->SetString( "GameDesc", server.m_szGameDescription );
|
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( "password", server.m_bPassword ? 1 : 0);
|
||||||
kv->SetInt( "bots", server.m_nBotPlayers ? 2 : 0);
|
kv->SetInt( "bots", server.m_nBotPlayers ? 2 : 0);
|
||||||
kv->SetInt( "Replay", IsReplayServer( server ) ? 5 : 0 );
|
kv->SetInt( "Replay", IsReplayServer( server ) ? 5 : 0 );
|
||||||
|
kv->SetInt("secure", 0);
|
||||||
|
|
||||||
if ( server.m_bSecure )
|
kv->SetString("IPAddr", server.m_NetAdr.ToString() );
|
||||||
{
|
|
||||||
// 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() );
|
|
||||||
|
|
||||||
char buf[32];
|
char buf[32];
|
||||||
Q_snprintf(buf, sizeof(buf), "%d / %d", server.m_nPlayers, server.m_nMaxPlayers);
|
Q_snprintf(buf, sizeof(buf), "%d / %d", server.m_nPlayers, server.m_nMaxPlayers);
|
||||||
|
@ -366,27 +352,7 @@ void CDialogAddServer::OnItemSelected()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CDialogAddServer::FinishAddServer( gameserveritem_t &pServer )
|
void CDialogAddServer::FinishAddServer( newgameserver_t &pServer )
|
||||||
{
|
{
|
||||||
ServerBrowserDialog().AddServerToFavorites( 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" );
|
|
||||||
}
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ class IGameList;
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Dialog which lets the user add a server by IP address
|
// 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 );
|
DECLARE_CLASS_SIMPLE( CDialogAddServer, vgui::Frame );
|
||||||
friend class CAddServerGameList;
|
friend class CAddServerGameList;
|
||||||
|
@ -26,7 +26,7 @@ public:
|
||||||
CDialogAddServer(vgui::Panel *parent, IGameList *gameList);
|
CDialogAddServer(vgui::Panel *parent, IGameList *gameList);
|
||||||
~CDialogAddServer();
|
~CDialogAddServer();
|
||||||
|
|
||||||
void ServerResponded( gameserveritem_t &server );
|
void ServerResponded( newgameserver_t &server );
|
||||||
void ServerFailedToRespond();
|
void ServerFailedToRespond();
|
||||||
|
|
||||||
void ApplySchemeSettings( vgui::IScheme *pScheme );
|
void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||||
|
@ -40,7 +40,7 @@ private:
|
||||||
void TestServers();
|
void TestServers();
|
||||||
MESSAGE_FUNC( OnTextChanged, "TextChanged" );
|
MESSAGE_FUNC( OnTextChanged, "TextChanged" );
|
||||||
|
|
||||||
virtual void FinishAddServer( gameserveritem_t &pServer );
|
virtual void FinishAddServer( newgameserver_t &pServer );
|
||||||
virtual bool AllowInvalidIPs( void ) { return false; }
|
virtual bool AllowInvalidIPs( void ) { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -54,22 +54,8 @@ protected:
|
||||||
vgui::TextEntry *m_pTextEntry;
|
vgui::TextEntry *m_pTextEntry;
|
||||||
vgui::ListPanel *m_pDiscoveredGames;
|
vgui::ListPanel *m_pDiscoveredGames;
|
||||||
int m_OriginalHeight;
|
int m_OriginalHeight;
|
||||||
CUtlVector<gameserveritem_t> m_Servers;
|
CUtlVector<newgameserver_t> m_Servers;
|
||||||
CUtlVector<HServerQuery> m_Queries;
|
CUtlVector<HServerQuery> 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
|
#endif // DIALOGADDSERVER_H
|
||||||
|
|
|
@ -293,7 +293,10 @@ void CDialogGameInfo::PerformLayout()
|
||||||
}
|
}
|
||||||
SetControlString("PlayersText", buf);
|
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() );
|
SetControlString("ServerIPText", m_Server.m_NetAdr.GetConnectionAddressString() );
|
||||||
m_pConnectButton->SetEnabled(true);
|
m_pConnectButton->SetEnabled(true);
|
||||||
|
@ -312,7 +315,7 @@ void CDialogGameInfo::PerformLayout()
|
||||||
{
|
{
|
||||||
SetControlString("ServerIPText", "");
|
SetControlString("ServerIPText", "");
|
||||||
m_pConnectButton->SetEnabled(false);
|
m_pConnectButton->SetEnabled(false);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if ( m_Server.m_bHadSuccessfulResponse )
|
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
|
// need to refresh server before attempting to connect, to make sure there is enough room on the server
|
||||||
m_iRequestRetry = 0;
|
m_iRequestRetry = 0;
|
||||||
RequestInfo();
|
|
||||||
|
ConnectToServer();
|
||||||
|
|
||||||
|
//TODO(nillerusr): restore this later
|
||||||
|
//RequestInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -633,17 +640,6 @@ void CDialogGameInfo::ConnectToServer()
|
||||||
{
|
{
|
||||||
m_bConnecting = false;
|
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
|
// check to see if we need a password
|
||||||
if ( m_Server.m_bPassword && !m_szPassword[0] )
|
if ( m_Server.m_bPassword && !m_szPassword[0] )
|
||||||
{
|
{
|
||||||
|
@ -654,7 +650,9 @@ void CDialogGameInfo::ConnectToServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the player count
|
// 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
|
// mark why we cannot connect
|
||||||
m_bServerFull = true;
|
m_bServerFull = true;
|
||||||
|
@ -662,7 +660,7 @@ void CDialogGameInfo::ConnectToServer()
|
||||||
m_bShowAutoRetryToggle = true;
|
m_bShowAutoRetryToggle = true;
|
||||||
InvalidateLayout();
|
InvalidateLayout();
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// tell the engine to connect
|
// tell the engine to connect
|
||||||
const char *gameDir = m_Server.m_szGameDir;
|
const char *gameDir = m_Server.m_szGameDir;
|
||||||
|
|
|
@ -73,7 +73,7 @@ bool CFavoriteGames::SupportsItem(InterfaceItem_e item)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: called when the current refresh list is complete
|
// Purpose: called when the current refresh list is complete
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CFavoriteGames::RefreshComplete( HServerListRequest hReq, EMatchMakingServerResponse response )
|
void CFavoriteGames::RefreshComplete( NServerResponse response )
|
||||||
{
|
{
|
||||||
SetRefreshing(false);
|
SetRefreshing(false);
|
||||||
if ( steamapicontext->SteamMatchmaking() && steamapicontext->SteamMatchmaking()->GetFavoriteGameCount() == 0 )
|
if ( steamapicontext->SteamMatchmaking() && steamapicontext->SteamMatchmaking()->GetFavoriteGameCount() == 0 )
|
||||||
|
@ -88,7 +88,7 @@ void CFavoriteGames::RefreshComplete( HServerListRequest hReq, EMatchMakingServe
|
||||||
}
|
}
|
||||||
m_pGameList->SortList();
|
m_pGameList->SortList();
|
||||||
|
|
||||||
BaseClass::RefreshComplete( hReq, response );
|
BaseClass::RefreshComplete( response );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
virtual bool SupportsItem(InterfaceItem_e item);
|
virtual bool SupportsItem(InterfaceItem_e item);
|
||||||
|
|
||||||
// called when the current refresh list is complete
|
// 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
|
// passed from main server browser window instead of messages
|
||||||
void OnConnectToGame();
|
void OnConnectToGame();
|
||||||
|
|
|
@ -18,16 +18,6 @@ CHistoryGames::CHistoryGames(vgui::Panel *parent) :
|
||||||
m_pGameList->AddColumnHeader(10, "LastPlayed", "#ServerBrowser_LastPlayed", 100);
|
m_pGameList->AddColumnHeader(10, "LastPlayed", "#ServerBrowser_LastPlayed", 100);
|
||||||
m_pGameList->SetSortFunc(10, LastPlayedCompare);
|
m_pGameList->SetSortFunc(10, LastPlayedCompare);
|
||||||
m_pGameList->SetSortColumn(10);
|
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()
|
void CHistoryGames::LoadHistoryList()
|
||||||
{
|
{
|
||||||
if ( IsSteamGameServerBrowsingEnabled() )
|
|
||||||
{
|
|
||||||
// set empty message
|
|
||||||
m_pGameList->SetEmptyListText("#ServerBrowser_NoServersPlayed");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_bRefreshOnListReload )
|
if ( m_bRefreshOnListReload )
|
||||||
{
|
{
|
||||||
m_bRefreshOnListReload = false;
|
m_bRefreshOnListReload = false;
|
||||||
|
@ -77,13 +61,13 @@ bool CHistoryGames::SupportsItem(InterfaceItem_e item)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: called when the current refresh list is complete
|
// Purpose: called when the current refresh list is complete
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CHistoryGames::RefreshComplete( HServerListRequest hReq, EMatchMakingServerResponse response )
|
void CHistoryGames::RefreshComplete( NServerResponse response )
|
||||||
{
|
{
|
||||||
SetRefreshing(false);
|
SetRefreshing(false);
|
||||||
m_pGameList->SetEmptyListText("#ServerBrowser_NoServersPlayed");
|
m_pGameList->SetEmptyListText("#ServerBrowser_NoServersPlayed");
|
||||||
m_pGameList->SortList();
|
m_pGameList->SortList();
|
||||||
|
|
||||||
BaseClass::RefreshComplete( hReq, response );
|
BaseClass::RefreshComplete( response );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
virtual bool SupportsItem(InterfaceItem_e item);
|
virtual bool SupportsItem(InterfaceItem_e item);
|
||||||
|
|
||||||
// called when the current refresh list is complete
|
// 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; }
|
void SetRefreshOnReload() { m_bRefreshOnListReload = true; }
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ CInternetGames::CInternetGames(vgui::Panel *parent, const char *panelName, EPage
|
||||||
m_fLastSort = 0.0f;
|
m_fLastSort = 0.0f;
|
||||||
m_bDirty = false;
|
m_bDirty = false;
|
||||||
m_bRequireUpdate = true;
|
m_bRequireUpdate = true;
|
||||||
m_bOfflineMode = !IsSteamGameServerBrowsingEnabled();
|
m_bOfflineMode = false;
|
||||||
|
|
||||||
m_bAnyServersRetrievedFromMaster = false;
|
m_bAnyServersRetrievedFromMaster = false;
|
||||||
m_bNoServersListedOnMaster = false;
|
m_bNoServersListedOnMaster = false;
|
||||||
|
@ -124,19 +124,19 @@ void CInternetGames::OnTick()
|
||||||
// Purpose: Handles incoming server refresh data
|
// Purpose: Handles incoming server refresh data
|
||||||
// updates the server browser with the refreshed information from the server itself
|
// 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;
|
m_bDirty = true;
|
||||||
BaseClass::ServerResponded( hReq, iServer );
|
|
||||||
|
BaseClass::ServerResponded( server );
|
||||||
m_bAnyServersRespondedToQuery = true;
|
m_bAnyServersRespondedToQuery = true;
|
||||||
m_bAnyServersRetrievedFromMaster = true;
|
m_bAnyServersRetrievedFromMaster = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CInternetGames::ServerFailedToRespond( HServerListRequest hReq, int iServer )
|
/*void CInternetGames::ServerFailedToRespond( HServerListRequest hReq, int iServer )
|
||||||
{
|
{
|
||||||
m_bDirty = true;
|
m_bDirty = true;
|
||||||
gameserveritem_t *pServer = steamapicontext->SteamMatchmakingServers()->GetServerDetails( hReq, iServer );
|
gameserveritem_t *pServer = steamapicontext->SteamMatchmakingServers()->GetServerDetails( hReq, iServer );
|
||||||
|
@ -145,7 +145,7 @@ void CInternetGames::ServerFailedToRespond( HServerListRequest hReq, int iServer
|
||||||
if ( pServer->m_bHadSuccessfulResponse )
|
if ( pServer->m_bHadSuccessfulResponse )
|
||||||
{
|
{
|
||||||
// if it's had a successful response in the past, leave it on
|
// if it's had a successful response in the past, leave it on
|
||||||
ServerResponded( hReq, iServer );
|
//ServerResponded( hReq, iServer );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -155,24 +155,24 @@ void CInternetGames::ServerFailedToRespond( HServerListRequest hReq, int iServer
|
||||||
// we've never had a good response from this server, remove it from the list
|
// we've never had a good response from this server, remove it from the list
|
||||||
m_iServerRefreshCount++;
|
m_iServerRefreshCount++;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Called when server refresh has been completed
|
// Purpose: Called when server refresh has been completed
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CInternetGames::RefreshComplete( HServerListRequest hReq, EMatchMakingServerResponse response )
|
void CInternetGames::RefreshComplete( NServerResponse response )
|
||||||
{
|
{
|
||||||
SetRefreshing(false);
|
SetRefreshing(false);
|
||||||
UpdateFilterSettings();
|
UpdateFilterSettings();
|
||||||
|
|
||||||
if ( response != eServerFailedToRespond )
|
if ( response != nServerFailedToRespond )
|
||||||
{
|
{
|
||||||
if ( m_bAnyServersRespondedToQuery )
|
if ( m_bAnyServersRespondedToQuery )
|
||||||
{
|
{
|
||||||
m_pGameList->SetEmptyListText( GetStringNoUnfilteredServers() );
|
m_pGameList->SetEmptyListText( GetStringNoUnfilteredServers() );
|
||||||
}
|
}
|
||||||
else if ( response == eNoServersListedOnMasterServer )
|
else if ( response == nNoServersListedOnMasterServer )
|
||||||
{
|
{
|
||||||
m_pGameList->SetEmptyListText( GetStringNoUnfilteredServersOnMaster() );
|
m_pGameList->SetEmptyListText( GetStringNoUnfilteredServersOnMaster() );
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ void CInternetGames::RefreshComplete( HServerListRequest hReq, EMatchMakingServe
|
||||||
|
|
||||||
UpdateStatus();
|
UpdateStatus();
|
||||||
|
|
||||||
BaseClass::RefreshComplete( hReq, response );
|
BaseClass::RefreshComplete( response );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ int CInternetGames::GetRegionCodeToFilter()
|
||||||
bool CInternetGames::CheckTagFilter( gameserveritem_t &server )
|
bool CInternetGames::CheckTagFilter( gameserveritem_t &server )
|
||||||
{
|
{
|
||||||
// Servers without tags go in the official games, servers with tags go in custom games
|
// 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 )
|
if ( !bOfficialServer )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -35,9 +35,9 @@ public:
|
||||||
MESSAGE_FUNC( GetNewServerList, "GetNewServerList" );
|
MESSAGE_FUNC( GetNewServerList, "GetNewServerList" );
|
||||||
|
|
||||||
// serverlist refresh responses
|
// serverlist refresh responses
|
||||||
virtual void ServerResponded( HServerListRequest hReq, int iServer );
|
virtual void ServerResponded( newgameserver_t &server );
|
||||||
virtual void ServerFailedToRespond( HServerListRequest hReq, int iServer );
|
//virtual void ServerFailedToRespond( HServerListRequest hReq, int iServer );
|
||||||
virtual void RefreshComplete( HServerListRequest hReq, EMatchMakingServerResponse response );
|
virtual void RefreshComplete( NServerResponse response );
|
||||||
MESSAGE_FUNC_INT( OnRefreshServer, "RefreshServer", serverID );
|
MESSAGE_FUNC_INT( OnRefreshServer, "RefreshServer", serverID );
|
||||||
|
|
||||||
virtual int GetRegionCodeToFilter();
|
virtual int GetRegionCodeToFilter();
|
||||||
|
|
|
@ -127,7 +127,7 @@ void CLanGames::ServerFailedToRespond( HServerListRequest hReq, int iServer )
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: called when the current refresh list is complete
|
// Purpose: called when the current refresh list is complete
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CLanGames::RefreshComplete( HServerListRequest hReq, EMatchMakingServerResponse response )
|
void CLanGames::RefreshComplete( NServerResponse response )
|
||||||
{
|
{
|
||||||
SetRefreshing( false );
|
SetRefreshing( false );
|
||||||
m_pGameList->SortList();
|
m_pGameList->SortList();
|
||||||
|
@ -135,7 +135,7 @@ void CLanGames::RefreshComplete( HServerListRequest hReq, EMatchMakingServerResp
|
||||||
m_pGameList->SetEmptyListText("#ServerBrowser_NoLanServers");
|
m_pGameList->SetEmptyListText("#ServerBrowser_NoLanServers");
|
||||||
SetEmptyListText();
|
SetEmptyListText();
|
||||||
|
|
||||||
BaseClass::RefreshComplete( hReq, response );
|
BaseClass::RefreshComplete( response );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLanGames::SetEmptyListText()
|
void CLanGames::SetEmptyListText()
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
virtual void ServerFailedToRespond( HServerListRequest hReq, int iServer );
|
virtual void ServerFailedToRespond( HServerListRequest hReq, int iServer );
|
||||||
|
|
||||||
// called when the current refresh list is complete
|
// 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.
|
// Tell the game list what to put in there when there are no games found.
|
||||||
virtual void SetEmptyListText();
|
virtual void SetEmptyListText();
|
||||||
|
|
|
@ -165,16 +165,16 @@ void CQuickListPanel::SetMapName( const char *pMapName )
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CQuickListPanel::SetGameType( const char *pGameType )
|
void CQuickListPanel::SetGameType( const char *pGameType )
|
||||||
{
|
{
|
||||||
if ( strlen ( pGameType ) == 0 )
|
m_pGameTypeLabel->SetVisible( false );
|
||||||
{
|
|
||||||
m_pGameTypeLabel->SetVisible( false );
|
if ( strlen ( pGameType ) == 0 || !m_pMapNameLabel )
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
char gametype[ 512 ];
|
char gametype[ 512 ];
|
||||||
Q_snprintf( gametype, sizeof( gametype ), "(%s)", pGameType );
|
Q_snprintf( gametype, sizeof( gametype ), "%s (%s)", m_szMapName, pGameType );
|
||||||
|
|
||||||
m_pGameTypeLabel->SetText( gametype );
|
m_pMapNameLabel->SetText( gametype );
|
||||||
|
m_pMapNameLabel->SizeToContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
@ -19,6 +19,7 @@ CServerBrowser &ServerBrowser()
|
||||||
}
|
}
|
||||||
|
|
||||||
IRunGameEngine *g_pRunGameEngine = NULL;
|
IRunGameEngine *g_pRunGameEngine = NULL;
|
||||||
|
IServersInfo *g_pServersInfo = NULL;
|
||||||
|
|
||||||
static CSteamAPIContext g_SteamAPIContext;
|
static CSteamAPIContext g_SteamAPIContext;
|
||||||
CSteamAPIContext *steamapicontext = &g_SteamAPIContext;
|
CSteamAPIContext *steamapicontext = &g_SteamAPIContext;
|
||||||
|
@ -79,11 +80,12 @@ bool CServerBrowser::Initialize(CreateInterfaceFn *factorylist, int factoryCount
|
||||||
for ( int i = 0; i < factoryCount; ++i )
|
for ( int i = 0; i < factoryCount; ++i )
|
||||||
{
|
{
|
||||||
if ( !g_pEngineReplay )
|
if ( !g_pEngineReplay )
|
||||||
{
|
|
||||||
g_pEngineReplay = ( IEngineReplay * )factorylist[ i ]( ENGINE_REPLAY_INTERFACE_VERSION, NULL );
|
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_InitSafe();
|
||||||
SteamAPI_SetTryCatchCallbacks( false ); // We don't use exceptions, so tell steam not to use try/catch in callback handlers
|
SteamAPI_SetTryCatchCallbacks( false ); // We don't use exceptions, so tell steam not to use try/catch in callback handlers
|
||||||
steamapicontext->Init();
|
steamapicontext->Init();
|
||||||
|
@ -304,7 +306,7 @@ void CServerBrowser::Shutdown()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool CServerBrowser::OpenGameInfoDialog( uint64 ulSteamIDFriend, const char *pszConnectCode )
|
bool CServerBrowser::OpenGameInfoDialog( uint64 ulSteamIDFriend, const char *pszConnectCode )
|
||||||
{
|
{
|
||||||
#if !defined( _X360 ) // X360TBD: SteamFriends()
|
#if 0
|
||||||
if ( m_hInternetDlg.Get() )
|
if ( m_hInternetDlg.Get() )
|
||||||
{
|
{
|
||||||
// activate an already-existing dialog
|
// 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 )
|
bool CServerBrowser::JoinGame( uint64 ulSteamIDFriend, const char *pszConnectCode )
|
||||||
{
|
{
|
||||||
if ( OpenGameInfoDialog( ulSteamIDFriend, pszConnectCode ) )
|
/* if ( OpenGameInfoDialog( ulSteamIDFriend, pszConnectCode ) )
|
||||||
{
|
{
|
||||||
CDialogGameInfo *pDialogGameInfo = m_hInternetDlg->GetDialogGameInfoForFriend( ulSteamIDFriend );
|
CDialogGameInfo *pDialogGameInfo = m_hInternetDlg->GetDialogGameInfoForFriend( ulSteamIDFriend );
|
||||||
pDialogGameInfo->Connect();
|
pDialogGameInfo->Connect();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -362,11 +364,13 @@ bool CServerBrowser::JoinGame( uint32 unGameIP, uint16 usGamePort, const char *p
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CServerBrowser::CloseGameInfoDialog( uint64 ulSteamIDFriend )
|
void CServerBrowser::CloseGameInfoDialog( uint64 ulSteamIDFriend )
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
CDialogGameInfo *pDialogGameInfo = m_hInternetDlg->GetDialogGameInfoForFriend( ulSteamIDFriend );
|
CDialogGameInfo *pDialogGameInfo = m_hInternetDlg->GetDialogGameInfoForFriend( ulSteamIDFriend );
|
||||||
if ( pDialogGameInfo )
|
if ( pDialogGameInfo )
|
||||||
{
|
{
|
||||||
pDialogGameInfo->Close();
|
pDialogGameInfo->Close();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ void GetMostCommonQueryPorts( CUtlVector<uint16> &ports )
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent, "CServerBrowserDialog")
|
CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent, "CServerBrowserDialog")
|
||||||
{
|
{
|
||||||
|
SetProportional( NeedProportional() );
|
||||||
s_InternetDlg = this;
|
s_InternetDlg = this;
|
||||||
|
|
||||||
m_szGameName[0] = 0;
|
m_szGameName[0] = 0;
|
||||||
|
@ -66,23 +67,26 @@ CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent,
|
||||||
m_pSavedData = NULL;
|
m_pSavedData = NULL;
|
||||||
m_pFilterData = NULL;
|
m_pFilterData = NULL;
|
||||||
m_pFavorites = NULL;
|
m_pFavorites = NULL;
|
||||||
m_pBlacklist = NULL;
|
|
||||||
m_pHistory = NULL;
|
m_pHistory = NULL;
|
||||||
|
m_pLanGames = NULL;
|
||||||
// Do this before LoadUserData() so it loads the blacklist file properly
|
|
||||||
m_pBlacklist = new CBlacklistedServers(this);
|
|
||||||
|
|
||||||
LoadUserData();
|
LoadUserData();
|
||||||
|
|
||||||
m_pInternetGames = new CCustomGames(this);
|
m_pInternetGames = new CInternetGames(this);
|
||||||
|
/*
|
||||||
m_pFavorites = new CFavoriteGames(this);
|
m_pFavorites = new CFavoriteGames(this);
|
||||||
m_pHistory = new CHistoryGames(this);
|
m_pHistory = new CHistoryGames(this);
|
||||||
m_pSpectateGames = new CSpectateGames(this);
|
m_pSpectateGames = new CSpectateGames(this);
|
||||||
m_pLanGames = new CLanGames(this);
|
m_pLanGames = new CLanGames(this);
|
||||||
m_pFriendsGames = new CFriendsGames(this);
|
*/
|
||||||
|
|
||||||
SetMinimumSize( 640, 384 );
|
int w = 640; int h = 384;
|
||||||
SetSize( 640, 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;
|
m_pGameList = m_pInternetGames;
|
||||||
|
|
||||||
|
@ -92,15 +96,11 @@ CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent,
|
||||||
m_pTabPanel = new PropertySheet(this, "GameTabs");
|
m_pTabPanel = new PropertySheet(this, "GameTabs");
|
||||||
m_pTabPanel->SetTabWidth(72);
|
m_pTabPanel->SetTabWidth(72);
|
||||||
m_pTabPanel->AddPage(m_pInternetGames, "#ServerBrowser_InternetTab");
|
m_pTabPanel->AddPage(m_pInternetGames, "#ServerBrowser_InternetTab");
|
||||||
m_pTabPanel->AddPage(m_pFavorites, "#ServerBrowser_FavoritesTab");
|
//m_pTabPanel->AddPage(m_pFavorites, "#ServerBrowser_FavoritesTab");
|
||||||
m_pTabPanel->AddPage(m_pHistory, "#ServerBrowser_HistoryTab");
|
//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_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_pTabPanel->AddActionSignalTarget(this);
|
||||||
|
|
||||||
m_pStatusLabel = new Label(this, "StatusLabel", "");
|
m_pStatusLabel = new Label(this, "StatusLabel", "");
|
||||||
|
@ -112,11 +112,12 @@ CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent,
|
||||||
// load current tab
|
// load current tab
|
||||||
const char *gameList = m_pSavedData->GetString("GameList");
|
const char *gameList = m_pSavedData->GetString("GameList");
|
||||||
|
|
||||||
if (!Q_stricmp(gameList, "spectate"))
|
/* if (!Q_stricmp(gameList, "spectate"))
|
||||||
{
|
{
|
||||||
m_pTabPanel->SetActivePage(m_pSpectateGames);
|
m_pTabPanel->SetActivePage(m_pSpectateGames);
|
||||||
}
|
}
|
||||||
else if (!Q_stricmp(gameList, "favorites"))
|
else
|
||||||
|
if (!Q_stricmp(gameList, "favorites"))
|
||||||
{
|
{
|
||||||
m_pTabPanel->SetActivePage(m_pFavorites);
|
m_pTabPanel->SetActivePage(m_pFavorites);
|
||||||
}
|
}
|
||||||
|
@ -128,15 +129,7 @@ CServerBrowserDialog::CServerBrowserDialog(vgui::Panel *parent) : Frame(parent,
|
||||||
{
|
{
|
||||||
m_pTabPanel->SetActivePage(m_pLanGames);
|
m_pTabPanel->SetActivePage(m_pLanGames);
|
||||||
}
|
}
|
||||||
else if (!Q_stricmp(gameList, "friends"))
|
else*/
|
||||||
{
|
|
||||||
m_pTabPanel->SetActivePage(m_pFriendsGames);
|
|
||||||
}
|
|
||||||
else if (!Q_stricmp(gameList, "blacklist"))
|
|
||||||
{
|
|
||||||
m_pTabPanel->SetActivePage(m_pBlacklist);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
m_pTabPanel->SetActivePage(m_pInternetGames);
|
m_pTabPanel->SetActivePage(m_pInternetGames);
|
||||||
}
|
}
|
||||||
|
@ -174,7 +167,7 @@ void CServerBrowserDialog::Initialize()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: returns a server in the list
|
// Purpose: returns a server in the list
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
gameserveritem_t *CServerBrowserDialog::GetServer( unsigned int serverID )
|
newgameserver_t *CServerBrowserDialog::GetServer( unsigned int serverID )
|
||||||
{
|
{
|
||||||
if (m_pGameList)
|
if (m_pGameList)
|
||||||
return m_pGameList->GetServer( serverID );
|
return m_pGameList->GetServer( serverID );
|
||||||
|
@ -254,11 +247,6 @@ void CServerBrowserDialog::LoadUserData()
|
||||||
m_pFavorites->StartRefresh();
|
m_pFavorites->StartRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_pBlacklist )
|
|
||||||
{
|
|
||||||
m_pBlacklist->LoadBlacklistedList();
|
|
||||||
}
|
|
||||||
|
|
||||||
InvalidateLayout();
|
InvalidateLayout();
|
||||||
Repaint();
|
Repaint();
|
||||||
}
|
}
|
||||||
|
@ -272,11 +260,12 @@ void CServerBrowserDialog::SaveUserData()
|
||||||
m_pSavedData->LoadFromFile( g_pFullFileSystem, "ServerBrowser.vdf", "CONFIG");
|
m_pSavedData->LoadFromFile( g_pFullFileSystem, "ServerBrowser.vdf", "CONFIG");
|
||||||
|
|
||||||
// set the current tab
|
// set the current tab
|
||||||
if (m_pGameList == m_pSpectateGames)
|
/*if (m_pGameList == m_pSpectateGames)
|
||||||
{
|
{
|
||||||
m_pSavedData->SetString("GameList", "spectate");
|
m_pSavedData->SetString("GameList", "spectate");
|
||||||
}
|
}
|
||||||
else if (m_pGameList == m_pFavorites)
|
else
|
||||||
|
if (m_pGameList == m_pFavorites)
|
||||||
{
|
{
|
||||||
m_pSavedData->SetString("GameList", "favorites");
|
m_pSavedData->SetString("GameList", "favorites");
|
||||||
}
|
}
|
||||||
|
@ -284,15 +273,11 @@ void CServerBrowserDialog::SaveUserData()
|
||||||
{
|
{
|
||||||
m_pSavedData->SetString("GameList", "lan");
|
m_pSavedData->SetString("GameList", "lan");
|
||||||
}
|
}
|
||||||
else if (m_pGameList == m_pFriendsGames)
|
|
||||||
{
|
|
||||||
m_pSavedData->SetString("GameList", "friends");
|
|
||||||
}
|
|
||||||
else if (m_pGameList == m_pHistory)
|
else if (m_pGameList == m_pHistory)
|
||||||
{
|
{
|
||||||
m_pSavedData->SetString("GameList", "history");
|
m_pSavedData->SetString("GameList", "history");
|
||||||
}
|
}
|
||||||
else
|
else*/
|
||||||
{
|
{
|
||||||
m_pSavedData->SetString("GameList", "internet");
|
m_pSavedData->SetString("GameList", "internet");
|
||||||
}
|
}
|
||||||
|
@ -301,11 +286,6 @@ void CServerBrowserDialog::SaveUserData()
|
||||||
m_pSavedData->AddSubKey( m_pFilterData->MakeCopy() );
|
m_pSavedData->AddSubKey( m_pFilterData->MakeCopy() );
|
||||||
m_pSavedData->SaveToFile( g_pFullFileSystem, "ServerBrowser.vdf", "CONFIG");
|
m_pSavedData->SaveToFile( g_pFullFileSystem, "ServerBrowser.vdf", "CONFIG");
|
||||||
|
|
||||||
if ( m_pBlacklist )
|
|
||||||
{
|
|
||||||
m_pBlacklist->SaveBlacklistedList();
|
|
||||||
}
|
|
||||||
|
|
||||||
// save per-page config
|
// save per-page config
|
||||||
SaveUserConfig();
|
SaveUserConfig();
|
||||||
}
|
}
|
||||||
|
@ -321,14 +301,6 @@ void CServerBrowserDialog::RefreshCurrentPage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose:
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void CServerBrowserDialog::BlacklistsChanged()
|
|
||||||
{
|
|
||||||
m_pInternetGames->ApplyGameFilters();
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Updates status test at bottom of window
|
// Purpose: Updates status test at bottom of window
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -398,9 +370,9 @@ CServerBrowserDialog *CServerBrowserDialog::GetInstance()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Adds a server to the list of favorites
|
// 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(
|
steamapicontext->SteamMatchmaking()->AddFavoriteGame(
|
||||||
server.m_nAppID,
|
server.m_nAppID,
|
||||||
|
@ -409,36 +381,7 @@ void CServerBrowserDialog::AddServerToFavorites(gameserveritem_t &server)
|
||||||
server.m_NetAdr.GetQueryPort(),
|
server.m_NetAdr.GetQueryPort(),
|
||||||
k_unFavoriteFlagFavorite,
|
k_unFavoriteFlagFavorite,
|
||||||
time( NULL ) );
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -469,10 +412,10 @@ CServerContextMenu *CServerBrowserDialog::GetContextMenu(vgui::Panel *pPanel)
|
||||||
// Purpose: begins the process of joining a server from a game list
|
// Purpose: begins the process of joining a server from a game list
|
||||||
// the game info dialog it opens will also update the 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
|
// 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
|
// set the dialog name to be the server name
|
||||||
gameDialog->Connect();
|
gameDialog->Connect();
|
||||||
|
@ -497,16 +440,12 @@ CDialogGameInfo *CServerBrowserDialog::JoinGame(int serverIP, int serverPort, co
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: opens a game info dialog from a game list
|
// 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 );
|
CDialogGameInfo *gameDialog = new CDialogGameInfo( NULL, pServer->m_NetAdr.GetIPHostByteOrder(), 0, pServer->m_NetAdr.GetPort(), gameList->GetConnectCode() );
|
||||||
if ( !pServer )
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
CDialogGameInfo *gameDialog = new CDialogGameInfo( NULL, pServer->m_NetAdr.GetIP(), pServer->m_NetAdr.GetQueryPort(), pServer->m_NetAdr.GetConnectionPort(), gameList->GetConnectCode() );
|
|
||||||
gameDialog->SetParent(GetVParent());
|
gameDialog->SetParent(GetVParent());
|
||||||
gameDialog->AddActionSignalTarget(this);
|
gameDialog->AddActionSignalTarget(this);
|
||||||
gameDialog->Run( pServer->GetName() );
|
gameDialog->Run( "Test" /*pServer->GetName()*/ );
|
||||||
int i = m_GameInfoDialogs.AddToTail();
|
int i = m_GameInfoDialogs.AddToTail();
|
||||||
m_GameInfoDialogs[i] = gameDialog;
|
m_GameInfoDialogs[i] = gameDialog;
|
||||||
return gameDialog;
|
return gameDialog;
|
||||||
|
@ -541,23 +480,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
|
// Purpose: accessor to the filter save data
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -612,11 +534,10 @@ void CServerBrowserDialog::OnActiveGameName( KeyValues *pKV )
|
||||||
void CServerBrowserDialog::ReloadFilterSettings()
|
void CServerBrowserDialog::ReloadFilterSettings()
|
||||||
{
|
{
|
||||||
m_pInternetGames->LoadFilterSettings();
|
m_pInternetGames->LoadFilterSettings();
|
||||||
m_pSpectateGames->LoadFilterSettings();
|
/*m_pSpectateGames->LoadFilterSettings();
|
||||||
m_pFavorites->LoadFilterSettings();
|
m_pFavorites->LoadFilterSettings();
|
||||||
m_pLanGames->LoadFilterSettings();
|
m_pLanGames->LoadFilterSettings();
|
||||||
m_pFriendsGames->LoadFilterSettings();
|
m_pHistory->LoadFilterSettings();*/
|
||||||
m_pHistory->LoadFilterSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -658,28 +579,20 @@ void CServerBrowserDialog::OnConnectToGame( KeyValues *pMessageValues )
|
||||||
}
|
}
|
||||||
|
|
||||||
// forward to favorites
|
// forward to favorites
|
||||||
m_pFavorites->OnConnectToGame();
|
//m_pFavorites->OnConnectToGame();
|
||||||
if ( m_pBlacklist )
|
|
||||||
{
|
|
||||||
m_pBlacklist->OnConnectToGame();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_bCurrentlyConnected = true;
|
m_bCurrentlyConnected = true;
|
||||||
|
|
||||||
// Now we want to track which tabs have the quick list button checked
|
// Now we want to track which tabs have the quick list button checked
|
||||||
int iQuickListBitField = 0;
|
int iQuickListBitField = 0;
|
||||||
if ( m_pFriendsGames && m_pFriendsGames->IsQuickListButtonChecked() )
|
|
||||||
{
|
|
||||||
iQuickListBitField |= ( 1 << 0 );
|
|
||||||
}
|
|
||||||
if ( m_pLanGames && m_pLanGames->IsQuickListButtonChecked() )
|
if ( m_pLanGames && m_pLanGames->IsQuickListButtonChecked() )
|
||||||
{
|
{
|
||||||
iQuickListBitField |= ( 1 << 1 );
|
iQuickListBitField |= ( 1 << 1 );
|
||||||
}
|
}
|
||||||
if ( m_pSpectateGames && m_pSpectateGames->IsQuickListButtonChecked() )
|
/*if ( m_pSpectateGames && m_pSpectateGames->IsQuickListButtonChecked() )
|
||||||
{
|
{
|
||||||
iQuickListBitField |= ( 1 << 2 );
|
iQuickListBitField |= ( 1 << 2 );
|
||||||
}
|
}*/
|
||||||
if ( m_pHistory && m_pHistory->IsQuickListButtonChecked() )
|
if ( m_pHistory && m_pHistory->IsQuickListButtonChecked() )
|
||||||
{
|
{
|
||||||
iQuickListBitField |= ( 1 << 3 );
|
iQuickListBitField |= ( 1 << 3 );
|
||||||
|
@ -719,11 +632,7 @@ void CServerBrowserDialog::OnDisconnectFromGame( void )
|
||||||
memset( &m_CurrentConnection, 0, sizeof(gameserveritem_t) );
|
memset( &m_CurrentConnection, 0, sizeof(gameserveritem_t) );
|
||||||
|
|
||||||
// forward to favorites
|
// forward to favorites
|
||||||
m_pFavorites->OnDisconnectFromGame();
|
//m_pFavorites->OnDisconnectFromGame();
|
||||||
if ( m_pBlacklist )
|
|
||||||
{
|
|
||||||
m_pBlacklist->OnDisconnectFromGame();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -732,11 +641,10 @@ void CServerBrowserDialog::OnDisconnectFromGame( void )
|
||||||
void CServerBrowserDialog::OnLoadingStarted( void )
|
void CServerBrowserDialog::OnLoadingStarted( void )
|
||||||
{
|
{
|
||||||
m_pInternetGames->OnLoadingStarted();
|
m_pInternetGames->OnLoadingStarted();
|
||||||
m_pSpectateGames->OnLoadingStarted();
|
/* m_pSpectateGames->OnLoadingStarted();
|
||||||
m_pFavorites->OnLoadingStarted();
|
m_pFavorites->OnLoadingStarted();
|
||||||
m_pLanGames->OnLoadingStarted();
|
m_pLanGames->OnLoadingStarted();
|
||||||
m_pFriendsGames->OnLoadingStarted();
|
m_pHistory->OnLoadingStarted();*/
|
||||||
m_pHistory->OnLoadingStarted();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
void Open( void );
|
void Open( void );
|
||||||
|
|
||||||
// gets server info
|
// gets server info
|
||||||
gameserveritem_t *GetServer(unsigned int serverID);
|
newgameserver_t *GetServer(unsigned int serverID);
|
||||||
// called every frame
|
// called every frame
|
||||||
virtual void OnTick();
|
virtual void OnTick();
|
||||||
|
|
||||||
|
@ -49,27 +49,23 @@ public:
|
||||||
static CServerBrowserDialog *GetInstance();
|
static CServerBrowserDialog *GetInstance();
|
||||||
|
|
||||||
// Adds a server to the list of favorites
|
// Adds a server to the list of favorites
|
||||||
void AddServerToFavorites(gameserveritem_t &server);
|
void AddServerToFavorites(newgameserver_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
|
// begins the process of joining a server from a game list
|
||||||
// the game info dialog it opens will also update the 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
|
// joins a game by a specified IP, not attached to any game list
|
||||||
CDialogGameInfo *JoinGame(int serverIP, int serverPort, const char *pszConnectCode);
|
CDialogGameInfo *JoinGame(int serverIP, int serverPort, const char *pszConnectCode);
|
||||||
|
|
||||||
// opens a game info dialog from a game list
|
// 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
|
// 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 );
|
CDialogGameInfo *OpenGameInfoDialog( int serverIP, uint16 connPort, uint16 queryPort, const char *pszConnectCode );
|
||||||
|
|
||||||
// closes all the game info dialogs
|
// closes all the game info dialogs
|
||||||
void CloseAllGameInfoDialogs();
|
void CloseAllGameInfoDialogs();
|
||||||
CDialogGameInfo *GetDialogGameInfoForFriend( uint64 ulSteamIDFriend );
|
|
||||||
|
|
||||||
// accessor to the filter save data
|
// accessor to the filter save data
|
||||||
KeyValues *GetFilterSaveData(const char *filterSet);
|
KeyValues *GetFilterSaveData(const char *filterSet);
|
||||||
|
@ -91,9 +87,6 @@ public:
|
||||||
return &m_CurrentConnection;
|
return &m_CurrentConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlacklistsChanged();
|
|
||||||
CBlacklistedServers *GetBlacklistPage( void ) { return m_pBlacklist; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// current game list change
|
// current game list change
|
||||||
|
@ -125,13 +118,12 @@ private:
|
||||||
|
|
||||||
// property sheet
|
// property sheet
|
||||||
vgui::PropertySheet *m_pTabPanel;
|
vgui::PropertySheet *m_pTabPanel;
|
||||||
CFavoriteGames *m_pFavorites;
|
|
||||||
CBlacklistedServers *m_pBlacklist;
|
|
||||||
CHistoryGames *m_pHistory;
|
|
||||||
CInternetGames *m_pInternetGames;
|
CInternetGames *m_pInternetGames;
|
||||||
CSpectateGames *m_pSpectateGames;
|
//CSpectateGames *m_pSpectateGames;
|
||||||
CLanGames *m_pLanGames;
|
CLanGames *m_pLanGames;
|
||||||
CFriendsGames *m_pFriendsGames;
|
CFavoriteGames *m_pFavorites;
|
||||||
|
CHistoryGames *m_pHistory;
|
||||||
|
|
||||||
KeyValues *m_pSavedData;
|
KeyValues *m_pSavedData;
|
||||||
KeyValues *m_pFilterData;
|
KeyValues *m_pFilterData;
|
||||||
|
|
|
@ -7,15 +7,15 @@
|
||||||
|
|
||||||
#include "pch_serverbrowser.h"
|
#include "pch_serverbrowser.h"
|
||||||
|
|
||||||
bool IsReplayServer( gameserveritem_t &server );
|
bool IsReplayServer( newgameserver_t &server );
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: List password column sort function
|
// Purpose: List password column sort function
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
int __cdecl PasswordCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2)
|
int __cdecl PasswordCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2)
|
||||||
{
|
{
|
||||||
gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
||||||
gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
||||||
|
|
||||||
if ( !s1 && s2 )
|
if ( !s1 && s2 )
|
||||||
return -1;
|
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)
|
int __cdecl BotsCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2)
|
||||||
{
|
{
|
||||||
gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
||||||
gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
||||||
|
|
||||||
if ( !s1 && s2 )
|
if ( !s1 && s2 )
|
||||||
return -1;
|
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)
|
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;
|
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)
|
int __cdecl IPAddressCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2)
|
||||||
{
|
{
|
||||||
gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
||||||
gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
||||||
|
|
||||||
if ( !s1 && s2 )
|
if ( !s1 && s2 )
|
||||||
return -1;
|
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)
|
int __cdecl PingCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2)
|
||||||
{
|
{
|
||||||
gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
||||||
gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
||||||
|
|
||||||
if ( !s1 && s2 )
|
if ( !s1 && s2 )
|
||||||
return -1;
|
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)
|
int __cdecl MapCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2)
|
||||||
{
|
{
|
||||||
gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
||||||
gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
||||||
|
|
||||||
if ( !s1 && s2 )
|
if ( !s1 && s2 )
|
||||||
return -1;
|
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)
|
int __cdecl GameCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2)
|
||||||
{
|
{
|
||||||
gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
||||||
gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
||||||
|
|
||||||
if ( !s1 && s2 )
|
if ( !s1 && s2 )
|
||||||
return -1;
|
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)
|
int __cdecl ServerNameCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2)
|
||||||
{
|
{
|
||||||
gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
||||||
gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
||||||
|
|
||||||
if ( !s1 && s2 )
|
if ( !s1 && s2 )
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -181,7 +166,7 @@ int __cdecl ServerNameCompare(ListPanel *pPanel, const ListPanelItem &p1, const
|
||||||
if ( !s1 && !s2 )
|
if ( !s1 && !s2 )
|
||||||
return 0;
|
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)
|
int __cdecl PlayersCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2)
|
||||||
{
|
{
|
||||||
gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
||||||
gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
||||||
|
|
||||||
if ( !s1 && s2 )
|
if ( !s1 && s2 )
|
||||||
return -1;
|
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)
|
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;
|
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)
|
int __cdecl TagsCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2)
|
||||||
{
|
{
|
||||||
gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
||||||
gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
||||||
|
|
||||||
if ( !s1 && s2 )
|
if ( !s1 && s2 )
|
||||||
return -1;
|
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)
|
int __cdecl ReplayCompare(ListPanel *pPanel, const ListPanelItem &p1, const ListPanelItem &p2)
|
||||||
{
|
{
|
||||||
gameserveritem_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
newgameserver_t *s1 = ServerBrowserDialog().GetServer(p1.userData);
|
||||||
gameserveritem_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
newgameserver_t *s2 = ServerBrowserDialog().GetServer(p2.userData);
|
||||||
|
|
||||||
if ( !s1 && s2 )
|
if ( !s1 && s2 )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -20,7 +20,7 @@ class gameserveritem_t;
|
||||||
#include "FindSteamServers.h"
|
#include "FindSteamServers.h"
|
||||||
#endif
|
#endif
|
||||||
#include "netadr.h"
|
#include "netadr.h"
|
||||||
|
#include "engine/iserversinfo.h"
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
@ -75,7 +75,7 @@ public:
|
||||||
virtual bool IsRefreshing() = 0;
|
virtual bool IsRefreshing() = 0;
|
||||||
|
|
||||||
// gets information about specified server
|
// 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
|
// called when Connect button is pressed
|
||||||
virtual void OnBeginConnect() = 0;
|
virtual void OnBeginConnect() = 0;
|
||||||
|
|
|
@ -57,15 +57,11 @@
|
||||||
|
|
||||||
// game list
|
// game list
|
||||||
#include "BaseGamesPage.h"
|
#include "BaseGamesPage.h"
|
||||||
#include "BlacklistedServers.h"
|
|
||||||
#include "InternetGames.h"
|
#include "InternetGames.h"
|
||||||
#include "FavoriteGames.h"
|
#include "FavoriteGames.h"
|
||||||
#include "SpectateGames.h"
|
//#include "SpectateGames.h"
|
||||||
#include "LanGames.h"
|
#include "LanGames.h"
|
||||||
#include "FriendsGames.h"
|
|
||||||
#include "HistoryGames.h"
|
#include "HistoryGames.h"
|
||||||
#include "SpectateGames.h"
|
|
||||||
#include "CustomGames.h"
|
|
||||||
#include "ServerBrowserDialog.h"
|
#include "ServerBrowserDialog.h"
|
||||||
#include "QuickListPanel.h"
|
#include "QuickListPanel.h"
|
||||||
#include "vgui_controls/PanelListPanel.h"
|
#include "vgui_controls/PanelListPanel.h"
|
||||||
|
@ -73,7 +69,7 @@
|
||||||
#include "replay/ienginereplay.h"
|
#include "replay/ienginereplay.h"
|
||||||
|
|
||||||
extern bool GameSupportsReplay();
|
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
|
#pragma warning( disable: 4355 ) // warning C4355: 'this' : used in base member initializer list
|
||||||
|
|
||||||
|
|
|
@ -21,13 +21,13 @@ def configure(conf):
|
||||||
def build(bld):
|
def build(bld):
|
||||||
source = [
|
source = [
|
||||||
'BaseGamesPage.cpp',
|
'BaseGamesPage.cpp',
|
||||||
'BlacklistedServers.cpp',
|
# 'BlacklistedServers.cpp',
|
||||||
'CustomGames.cpp',
|
# 'CustomGames.cpp',
|
||||||
'DialogAddServer.cpp',
|
'DialogAddServer.cpp',
|
||||||
'DialogGameInfo.cpp',
|
'DialogGameInfo.cpp',
|
||||||
'DialogServerPassword.cpp',
|
'DialogServerPassword.cpp',
|
||||||
'FavoriteGames.cpp',
|
'FavoriteGames.cpp',
|
||||||
'FriendsGames.cpp',
|
# 'FriendsGames.cpp',
|
||||||
'HistoryGames.cpp',
|
'HistoryGames.cpp',
|
||||||
'InternetGames.cpp',
|
'InternetGames.cpp',
|
||||||
'LanGames.cpp',
|
'LanGames.cpp',
|
||||||
|
@ -36,7 +36,7 @@ def build(bld):
|
||||||
'ServerBrowserDialog.cpp',
|
'ServerBrowserDialog.cpp',
|
||||||
'ServerContextMenu.cpp',
|
'ServerContextMenu.cpp',
|
||||||
'ServerListCompare.cpp',
|
'ServerListCompare.cpp',
|
||||||
'SpectateGames.cpp',
|
# 'SpectateGames.cpp',
|
||||||
'VACBannedConnRefusedDialog.cpp',
|
'VACBannedConnRefusedDialog.cpp',
|
||||||
'QuickListPanel.cpp',
|
'QuickListPanel.cpp',
|
||||||
'../public/vgui_controls/vgui_controls.cpp',
|
'../public/vgui_controls/vgui_controls.cpp',
|
||||||
|
|
|
@ -1465,7 +1465,7 @@ void Panel::SetParent(VPANEL newParent)
|
||||||
if( ipanel()->IsProportional(GetVParent()) )
|
if( ipanel()->IsProportional(GetVParent()) )
|
||||||
SetProportional(true);
|
SetProportional(true);
|
||||||
|
|
||||||
if( IsPopup() )
|
if( !IsPopup() )
|
||||||
{
|
{
|
||||||
// most of the time KBInput == parents kbinput
|
// most of the time KBInput == parents kbinput
|
||||||
if (ipanel()->IsKeyBoardInputEnabled(GetVParent()) != IsKeyBoardInputEnabled())
|
if (ipanel()->IsKeyBoardInputEnabled(GetVParent()) != IsKeyBoardInputEnabled())
|
||||||
|
|
Loading…
Add table
Reference in a new issue