Rise
The Vieneo Province
Loading...
Searching...
No Matches
matchmakingtypes.h
Go to the documentation of this file.
1//========= Copyright � 1996-2008, Valve LLC, All rights reserved. ============
2//
3// Purpose:
4//
5// $NoKeywords: $
6//=============================================================================
7
8#ifndef MATCHMAKINGTYPES_H
9#define MATCHMAKINGTYPES_H
10
11#include <stdio.h>
12#include <string.h>
13
14//
15// Max size (in bytes of UTF-8 data, not in characters) of server fields, including null terminator.
16// WARNING: These cannot be changed easily, without breaking clients using old interfaces.
17//
21const int k_cbMaxGameServerName = 64;
22const int k_cbMaxGameServerTags = 128;
24
31{
33 MatchMakingKeyValuePair_t( const char *pchKey, const char *pchValue )
34 {
35 strncpy( m_szKey, pchKey, sizeof(m_szKey) ); // this is a public header, use basic c library string funcs only!
36 m_szKey[ sizeof( m_szKey ) - 1 ] = '\0';
37 strncpy( m_szValue, pchValue, sizeof(m_szValue) );
38 m_szValue[ sizeof( m_szValue ) - 1 ] = '\0';
39 }
40 char m_szKey[ 256 ];
41 char m_szValue[ 256 ];
42};
43
44
46{
49 eNoServersListedOnMasterServer // for the Internet query type, returned in response callback if no servers of this type match
50};
51
52// servernetadr_t is all the addressing info the serverbrowser needs to know about a game server,
53// namely: its IP, its connection port, and its query port.
55{
56public:
57
59
60 void Init( unsigned int ip, uint16 usQueryPort, uint16 usConnectionPort );
61
62 // Access the query port.
63 uint16 GetQueryPort() const;
64 void SetQueryPort( uint16 usPort );
65
66 // Access the connection port.
68 void SetConnectionPort( uint16 usPort );
69
70 // Access the IP
71 uint32 GetIP() const;
72 void SetIP( uint32 unIP );
73
74 // This gets the 'a.b.c.d:port' string with the connection port (instead of the query port).
75 const char *GetConnectionAddressString() const;
76 const char *GetQueryAddressString() const;
77
78 // Comparison operators and functions.
79 bool operator<(const servernetadr_t &netadr) const;
80 void operator=( const servernetadr_t &that )
81 {
84 m_unIP = that.m_unIP;
85 }
86 bool operator==( const servernetadr_t &rhs ) const
87 {
88 return
91 m_unIP == rhs.m_unIP;
92 }
93
94
95private:
96 const char *ToString( uint32 unIP, uint16 usPort ) const;
97 uint16 m_usConnectionPort; // (in HOST byte order)
100};
101
102
103inline void servernetadr_t::Init( unsigned int ip, uint16 usQueryPort, uint16 usConnectionPort )
104{
105 m_unIP = ip;
106 m_usQueryPort = usQueryPort;
107 m_usConnectionPort = usConnectionPort;
108}
109
111{
112 return m_usQueryPort;
113}
114
116{
117 m_usQueryPort = usPort;
118}
119
124
126{
127 m_usConnectionPort = usPort;
128}
129
131{
132 return m_unIP;
133}
134
135inline void servernetadr_t::SetIP( uint32 unIP )
136{
137 m_unIP = unIP;
138}
139
140inline const char *servernetadr_t::ToString( uint32 unIP, uint16 usPort ) const
141{
142 static char s[4][64];
143 static int nBuf = 0;
144 unsigned char *ipByte = (unsigned char *)&unIP;
145#ifdef VALVE_BIG_ENDIAN
146 snprintf(s[nBuf], sizeof( s[nBuf] ), "%u.%u.%u.%u:%i", (int)(ipByte[0]), (int)(ipByte[1]), (int)(ipByte[2]), (int)(ipByte[3]), usPort );
147#else
148 snprintf(s[nBuf], sizeof( s[nBuf] ), "%u.%u.%u.%u:%i", (int)(ipByte[3]), (int)(ipByte[2]), (int)(ipByte[1]), (int)(ipByte[0]), usPort );
149#endif
150 const char *pchRet = s[nBuf];
151 ++nBuf;
152 nBuf %= ( (sizeof(s)/sizeof(s[0])) );
153 return pchRet;
154}
155
157{
159}
160
162{
163 return ToString( m_unIP, m_usQueryPort );
164}
165
166inline bool servernetadr_t::operator<(const servernetadr_t &netadr) const
167{
168 return ( m_unIP < netadr.m_unIP ) || ( m_unIP == netadr.m_unIP && m_usQueryPort < netadr.m_usQueryPort );
169}
170
171//-----------------------------------------------------------------------------
172// Purpose: Data describing a single server
173//-----------------------------------------------------------------------------
175{
176public:
178
179 const char* GetName() const;
180 void SetName( const char *pName );
181
182public:
198
199private:
200
203
204 // For data added after SteamMatchMaking001 add it here
205public:
206 bool operator==( const gameserveritem_t &rhs ) const
207 {
208 return m_NetAdr == rhs.m_NetAdr;
209 }
210
213
218};
219
220
230
231inline const char* gameserveritem_t::GetName() const
232{
233 // Use the IP address as the name if nothing is set yet.
234 if ( m_szServerName[0] == 0 )
236 else
237 return m_szServerName;
238}
239
240inline void gameserveritem_t::SetName( const char *pName )
241{
242 strncpy( m_szServerName, pName, sizeof( m_szServerName ) );
243 m_szServerName[ sizeof( m_szServerName ) - 1 ] = '\0';
244}
245
246
247#endif // MATCHMAKINGTYPES_H
char m_szGameDescription[k_cbMaxGameServerGameDescription]
game description
const char * GetName() const
char m_szGameTags[k_cbMaxGameServerTags]
the tags this server exposes
uint32 m_nAppID
Steam App ID of this server.
int m_nPing
current ping time in milliseconds
int m_nServerVersion
server version as reported to Steam
uint32 m_ulTimeLastPlayed
time (in unix time) when this server was last played on (for favorite/history servers)
bool m_bPassword
true if this server needs a password to join
CSteamID m_steamID
steamID of the game server - invalid if it's doesn't have one (old server, or not connected to Steam)
servernetadr_t m_NetAdr
IP/Query Port/Connection Port for this server.
bool m_bSecure
Is this server protected by VAC.
int m_nCurrentFriendCount
count of friends currently on server
int m_nTotalFriendCount
total count of friends who have played on server
bool operator==(const gameserveritem_t &rhs) const
char m_szGameDir[k_cbMaxGameServerGameDir]
current game directory
bool m_bDoNotRefresh
server is marked as not responding and should no longer be refreshed
char m_szServerName[k_cbMaxGameServerName]
Game server name.
void SetName(const char *pName)
int m_nBotPlayers
Number of bots (i.e simulated players) on this server.
int m_nPlayers
total number of players currently on the server. INCLUDES BOTS!!
int m_nMaxPlayers
Maximum players that can join this server.
char m_szMap[k_cbMaxGameServerMapName]
current map
bool m_bHadSuccessfulResponse
server has responded successfully in the past
void Init(unsigned int ip, uint16 usQueryPort, uint16 usConnectionPort)
void SetQueryPort(uint16 usPort)
uint16 GetQueryPort() const
uint32 GetIP() const
const char * ToString(uint32 unIP, uint16 usPort) const
bool operator==(const servernetadr_t &rhs) const
const char * GetQueryAddressString() const
bool operator<(const servernetadr_t &netadr) const
const char * GetConnectionAddressString() const
void operator=(const servernetadr_t &that)
uint16 GetConnectionPort() const
void SetConnectionPort(uint16 usPort)
void SetIP(uint32 unIP)
EMatchMakingServerResponse
@ eServerFailedToRespond
@ eServerResponded
@ eNoServersListedOnMasterServer
const int k_cbMaxGameServerGameDir
const int k_cbMaxGameServerName
const int k_cbMaxGameServerGameDescription
const int k_cbMaxGameServerGameData
const int k_cbMaxGameServerMapName
const int k_cbMaxGameServerTags
const char *typedef uint32(S_CALLTYPE *SteamAPI_CheckCallbackRegistered_t)(int iCallbackNum)
unsigned short uint16
Definition steamtypes.h:56
MatchMakingKeyValuePair_t(const char *pchKey, const char *pchValue)