Skip to content

Commit ec3ab23

Browse files
authored
Merge pull request #198 from nillerusr/serverbrowser
Serverbrowser support
2 parents e9af8c6 + 2aa14bb commit ec3ab23

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1274
-690
lines changed

common/proto_oob.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// This is used, unless overridden in the registry
1717
#define VALVE_MASTER_ADDRESS "207.173.177.10:27011"
1818

19+
#define HB_TIMEOUT 15
20+
1921
#define PORT_RCON 27015 // defualt RCON port, TCP
2022
#define PORT_MASTER 27011 // Default master port, UDP
2123
#define PORT_CLIENT 27005 // Default client port, UDP/TCP
@@ -29,6 +31,8 @@
2931
#endif // ENABLE_RPT
3032
#define PORT_REPLAY 27040 // Default replay port
3133

34+
#define PORT_SERVERSINFO 27069 // Default matchmaking port
35+
3236
// out of band message id bytes
3337

3438
// M = master, S = server, C = client, A = any
@@ -80,16 +84,17 @@
8084

8185

8286
// A user is requesting the list of master servers, auth servers, and titan dir servers from the Client Master server
83-
#define A2M_GETMASTERSERVERS 'v' // + byte (type of request, TYPE_CLIENT_MASTER or TYPE_SERVER_MASTER)
8487

8588
// Master server list response
86-
#define M2A_MASTERSERVERS 'w' // + byte type + 6 byte IP/Port List
87-
88-
#define A2M_GETACTIVEMODS 'x' // + string Request to master to provide mod statistics ( current usage ). "1" for first mod.
89+
#define S2M_GETCHALLENGE 'w' // + dword challenge
90+
#define S2M_HEARTBEAT 'y'
91+
#define S2M_SHUTDOWN 'z' // Master peering message
92+
#define M2S_CHALLENGE 'x' // + dword challenge
93+
#define M2C_QUERY 'J' // request module from master
94+
#define C2M_CLIENTQUERY '1' // New style server query
8995

90-
#define M2A_ACTIVEMODS 'y' // response: modname\r\nusers\r\nservers
91-
92-
#define M2M_MSG 'z' // Master peering message
96+
#define C2S_INFOREQUEST 'v'
97+
#define S2C_INFOREPLY 'K'
9398

9499
// SERVER TO CLIENT/ANY
95100

@@ -106,9 +111,6 @@
106111
#define S2A_INFO_SRC 'I' // + Address, hostname, map, gamedir, gamedescription, active players, maxplayers, protocol
107112
#define S2A_INFO_GOLDSRC 'm' // Reserved for use by goldsrc servers
108113

109-
#define S2M_GETFILE 'J' // request module from master
110-
#define M2S_SENDFILE 'K' // send module to server
111-
112114
#define S2C_REDIRECT 'L' // + IP x.x.x.x:port, redirect client to other server/proxy
113115

114116
#define C2M_CHECKMD5 'M' // player client asks secure master if Module MD5 is valid
@@ -133,8 +135,6 @@
133135

134136
#define A2S_KEY_STRING "Source Engine Query" // required postfix to a A2S_INFO query
135137

136-
#define A2M_GET_SERVERS_BATCH2 '1' // New style server query
137-
138138
#define A2M_GETACTIVEMODS2 '2' // New style mod info query
139139

140140
#define C2S_AUTHREQUEST1 '3' //

engine/baseclient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,7 @@ void CBaseClient::UpdateUserSettings()
14311431
SetRate( rate, false );
14321432

14331433
// set server to client update rate
1434-
SetUpdateRate( m_ConVars->GetInt( "cl_updaterate", 20), false );
1434+
SetUpdateRate( m_ConVars->GetInt( "cl_updaterate", 60), false );
14351435

14361436
SetMaxRoutablePayloadSize( m_ConVars->GetInt( "net_maxroutable", MAX_ROUTABLE_PAYLOAD ) );
14371437

engine/baseclientstate.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "sv_plugin.h"
3838
#include "sys_dll.h"
3939
#include "host.h"
40+
#include "master.h"
4041
#if defined( REPLAY_ENABLED )
4142
#include "replay_internal.h"
4243
#include "replayserver.h"
@@ -875,6 +876,8 @@ bool CBaseClientState::ProcessConnectionlessPacket( netpacket_t *packet )
875876

876877
Assert( packet );
877878

879+
master->ProcessConnectionlessPacket( packet );
880+
878881
bf_read &msg = packet->message; // handy shortcut
879882

880883
int c = msg.ReadByte();

engine/baseserver.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#include "sv_ipratelimit.h"
5757
#include "cl_steamauth.h"
5858
#include "sv_filter.h"
59+
#include "master.h"
5960

6061
#if defined( _X360 )
6162
#include "xbox/xbox_win32stubs.h"
@@ -663,6 +664,8 @@ bool CBaseServer::ValidInfoChallenge( netadr_t & adr, const char *nugget )
663664

664665
bool CBaseServer::ProcessConnectionlessPacket(netpacket_t * packet)
665666
{
667+
master->ProcessConnectionlessPacket( packet );
668+
666669
bf_read msg = packet->message; // handy shortcut
667670

668671
char c = msg.ReadChar();

engine/host.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "steam/steam_api.h"
4141
#include "LoadScreenUpdate.h"
4242
#include "datacache/idatacache.h"
43+
#include "master.h"
4344

4445
#if !defined SWDS
4546
#include "voice.h"
@@ -1820,6 +1821,8 @@ void Host_ShutdownServer( void )
18201821
if ( !sv.IsActive() )
18211822
return;
18221823

1824+
master->ShutdownConnection();
1825+
18231826
Host_AllowQueuedMaterialSystem( false );
18241827
// clear structures
18251828
#if !defined( SWDS )
@@ -4951,7 +4954,7 @@ void Host_Shutdown(void)
49514954
TRACESHUTDOWN( HLTV_Shutdown() );
49524955

49534956
TRACESHUTDOWN( g_Log.Shutdown() );
4954-
4957+
49554958
TRACESHUTDOWN( g_GameEventManager.Shutdown() );
49564959

49574960
TRACESHUTDOWN( sv.Shutdown() );

engine/master.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//======== (C) Copyright 1999, 2000 Valve, L.L.C. All rights reserved. ========
2+
//
3+
// The copyright to the contents herein is the property of Valve, L.L.C.
4+
// The contents may be used and/or copied only with the written permission of
5+
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
6+
// the agreement/contract under which the contents have been supplied.
7+
//
8+
// Purpose:
9+
//
10+
// $Workfile: $
11+
// $Date: $
12+
//
13+
//-----------------------------------------------------------------------------
14+
// $Log: $
15+
//
16+
// $NoKeywords: $
17+
//=============================================================================
18+
#ifndef MASTER_H
19+
#define MASTER_H
20+
#ifdef _WIN32
21+
#pragma once
22+
#endif
23+
24+
#include "engine/iserversinfo.h"
25+
26+
//-----------------------------------------------------------------------------
27+
// Purpose: Implements a master server interface.
28+
//-----------------------------------------------------------------------------
29+
class IMaster
30+
{
31+
public:
32+
// Allow master server to register cvars/commands
33+
virtual void Init( void ) = 0;
34+
// System is shutting down
35+
virtual void Shutdown( void ) = 0;
36+
// Server is shutting down
37+
virtual void ShutdownConnection( void ) = 0;
38+
// Sends the actual heartbeat to the master ( after challenge value is parsed )
39+
virtual void SendHeartbeat( struct adrlist_s *p ) = 0;
40+
// Add server to global master list
41+
virtual void AddServer( struct netadr_s *adr ) = 0;
42+
// If parsing for server, etc. fails, always have at least one server around to use.
43+
virtual void UseDefault ( void ) = 0;
44+
// See if it's time to send the next heartbeat
45+
virtual void CheckHeartbeat( void ) = 0;
46+
// Master sent back a challenge value, read it and send the actual heartbeat
47+
virtual void RespondToHeartbeatChallenge( netadr_t &from, bf_read &msg ) = 0;
48+
// Console command to set/remove master server
49+
virtual void AddMaster_f( const CCommand &args ) = 0;
50+
// Force a heartbeat to be issued right away
51+
virtual void Heartbeat_f( void ) = 0;
52+
53+
virtual void ProcessConnectionlessPacket( netpacket_t *packet ) = 0;
54+
55+
virtual void RunFrame( void ) = 0;
56+
};
57+
58+
extern IMaster *master;
59+
extern IServersInfo *g_pServersInfo;
60+
61+
#endif // MASTER_H

0 commit comments

Comments
 (0)