Skip to content

Commit 727b894

Browse files
committed
Plumbing changes to be compatible with Steamworks SDK.
In Steamworks, we want to keep the number of odinary DLL imports to an absolute minimum, because those come from steam_api.dll, which we do not update. (The developer needs to take a new one to update their SDK.) The functions in the interface come from steamclient.dll, which we do update frequently. This resulted in the following changes: * Printing and parsing of SteamNetworkingIPAddr and SteamNetworkingIdentity were moved to ISteamNetworkingUtils functions. Most C++ code will still access them through the inline class methods, so they won't really care where they are implemented. * Deleted some hashing functions. This is not hard to write, and the definition of operator= gives you an example of what to do. * SteamNetworkingMessage::Release will happen through a pointer, so that it can be dynamiclaly linked. Other changes: * Renamed an old name "STEAMDATAGRAMLIB" to "STEAMNETWORKINGSOCKETS" in a few places. * Use STEAMNETWORKINGSOCKETS_ENABLE_SDR in a few places, to remove SDR-specific functionality. (We might opensource the SDR support code in the future.)
1 parent 59868d3 commit 727b894

12 files changed

+116
-69
lines changed

include/steam/isteamnetworkingutils.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ class ISteamNetworkingUtils
112112
/// Return the lowest numbered configuration value available in the current environment.
113113
virtual ESteamNetworkingConfigValue GetFirstConfigValue() = 0;
114114

115+
// String conversions. You'll usually access these using the respective
116+
// inline methods.
117+
virtual void SteamNetworkingIPAddr_ToString( const SteamNetworkingIPAddr &addr, char *buf, size_t cbBuf, bool bWithPort ) = 0;
118+
virtual bool SteamNetworkingIPAddr_ParseString( SteamNetworkingIPAddr *pAddr, const char *pszStr ) = 0;
119+
virtual void SteamNetworkingIdentity_ToString( const SteamNetworkingIdentity &identity, char *buf, size_t cbBuf ) = 0;
120+
virtual bool SteamNetworkingIdentity_ParseString( SteamNetworkingIdentity *pIdentity, const char *pszStr ) = 0;
121+
115122
protected:
116123
~ISteamNetworkingUtils(); // Silence some warnings
117124
};
@@ -141,4 +148,11 @@ inline bool ISteamNetworkingUtils::SetConnectionConfigValueInt32( HSteamNetConne
141148
inline bool ISteamNetworkingUtils::SetConnectionConfigValueFloat( HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, float val ) { return SetConfigValue( eValue, k_ESteamNetworkingConfig_Connection, hConn, k_ESteamNetworkingConfig_Float, &val ); }
142149
inline bool ISteamNetworkingUtils::SetConnectionConfigValueString( HSteamNetConnection hConn, ESteamNetworkingConfigValue eValue, const char *val ) { return SetConfigValue( eValue, k_ESteamNetworkingConfig_Connection, hConn, k_ESteamNetworkingConfig_String, val ); }
143150

151+
#if !defined( STEAMNETWORKINGSOCKETS_STATIC_LINK ) && defined( STEAMNETWORKINGSOCKETS_STEAM )
152+
inline void SteamNetworkingIPAddr::ToString( char *buf, size_t cbBuf, bool bWithPort ) const { SteamNetworkingUtils()->SteamNetworkingIPAddr_ToString( *this, buf, cbBuf, bWithPort ); }
153+
inline bool SteamNetworkingIPAddr::ParseString( const char *pszStr ) { return SteamNetworkingUtils()->SteamNetworkingIPAddr_ParseString( this, pszStr ); }
154+
inline void SteamNetworkingIdentity::ToString( char *buf, size_t cbBuf ) const { SteamNetworkingUtils()->SteamNetworkingIdentity_ToString( *this, buf, cbBuf ); }
155+
inline bool SteamNetworkingIdentity::ParseString( const char *pszStr ) { return SteamNetworkingUtils()->SteamNetworkingIdentity_ParseString( this, pszStr ); }
156+
#endif
157+
144158
#endif // ISTEAMNETWORKINGUTILS

include/steam/steamnetworkingsockets_flat.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extern "C" {
1818

1919
STEAMNETWORKINGSOCKETS_INTERFACE HSteamListenSocket SteamAPI_ISteamNetworkingSockets_CreateListenSocketIP( intptr_t instancePtr, const SteamNetworkingIPAddr *pAddress );
2020
STEAMNETWORKINGSOCKETS_INTERFACE HSteamNetConnection SteamAPI_ISteamNetworkingSockets_ConnectByIPAddress( intptr_t instancePtr, const SteamNetworkingIPAddr *pAddress );
21-
#ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
21+
#ifdef STEAMNETWORKINGSOCKETS_ENABLE_SDR
2222
STEAMNETWORKINGSOCKETS_INTERFACE HSteamNetConnection SteamAPI_ISteamNetworkingSockets_CreateListenSocketP2P( intptr_t instancePtr, int nVirtualPort );
2323
STEAMNETWORKINGSOCKETS_INTERFACE HSteamNetConnection SteamAPI_ISteamNetworkingSockets_ConnectP2P( intptr_t instancePtr, const SteamNetworkingIdentity *pIdentity, int nVirtualPort );
2424
#endif
@@ -40,7 +40,7 @@ STEAMNETWORKINGSOCKETS_INTERFACE bool SteamAPI_ISteamNetworkingSockets_GetListen
4040

4141
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamAPI_ISteamNetworkingSockets_CreateSocketPair( intptr_t instancePtr, HSteamNetConnection *pOutConnection1, HSteamNetConnection *pOutConnection2, bool bUseNetworkLoopback, const SteamNetworkingIdentity *pIdentity1, const SteamNetworkingIdentity *pIdentity2 );
4242

43-
#ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE
43+
#ifdef STEAMNETWORKINGSOCKETS_ENABLE_SDR
4444

4545
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamAPI_ISteamNetworkingSockets_ReceivedRelayAuthTicket( intptr_t instancePtr, const void *pvTicket, int cbTicket, SteamDatagramRelayAuthTicket *pOutParsedTicket );
4646
STEAMNETWORKINGSOCKETS_INTERFACE int SteamAPI_ISteamNetworkingSockets_FindRelayAuthTicketForServer( intptr_t instancePtr, const SteamNetworkingIdentity *pIdentityGameserver, int nVirtualPort, SteamDatagramRelayAuthTicket *pOutParsedTicket );
@@ -115,6 +115,8 @@ STEAMNETWORKINGSOCKETS_INTERFACE ESteamNetworkingGetConfigValueResult SteamAPI_I
115115
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamAPI_ISteamNetworkingUtils_GetConfigValueInfo( intptr_t instancePtr, ESteamNetworkingConfigValue eValue, const char **pOutName, ESteamNetworkingConfigDataType *pOutDataType, ESteamNetworkingConfigScope *pOutScope, ESteamNetworkingConfigValue *pOutNextValue );
116116
STEAMNETWORKINGSOCKETS_INTERFACE ESteamNetworkingConfigValue SteamAPI_ISteamNetworkingUtils_GetFirstConfigValue( intptr_t instancePtr );
117117

118+
STEAMNETWORKINGSOCKETS_INTERFACE void SteamAPI_SteamNetworkingMessage_t_Release( SteamNetworkingMessage_t *pIMsg );
119+
118120
}
119121

120122
#endif // ISTEAMNETWORKINGSOCKETS

include/steam/steamnetworkingtypes.h

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
#include "steamtypes.h"
2727
#include "steamclientpublic.h"
2828

29-
#if defined( STEAMDATAGRAMLIB_STATIC_LINK )
29+
#if defined( STEAMNETWORKINGSOCKETS_STATIC_LINK )
3030
#define STEAMNETWORKINGSOCKETS_INTERFACE extern "C"
31-
#elif defined( STEAMDATAGRAMLIB_FOREXPORT )
31+
#elif defined( STEAMNETWORKINGSOCKETS_FOREXPORT )
3232
#define STEAMNETWORKINGSOCKETS_INTERFACE DLL_EXPORT
3333
#else
3434
#define STEAMNETWORKINGSOCKETS_INTERFACE DLL_IMPORT
@@ -126,11 +126,11 @@ struct SteamNetworkingIPAddr
126126
/// form according to RFC5952. If you include the port, IPv6 will be surrounded by
127127
/// brackets, e.g. [::1:2]:80. Your buffer should be at least k_cchMaxString bytes
128128
/// to avoid truncation
129-
void ToString( char *buf, size_t cbBuf, bool bWithPort ) const;
129+
inline void ToString( char *buf, size_t cbBuf, bool bWithPort ) const;
130130

131131
/// Parse an IP address and optional port. If a port is not present, it is set to 0.
132132
/// (This means that you cannot tell if a zero port was explicitly specified.)
133-
bool ParseString( const char *pszStr );
133+
inline bool ParseString( const char *pszStr );
134134

135135
union
136136
{
@@ -181,11 +181,6 @@ struct SteamNetworkingIdentity
181181
/// See if two identities are identical
182182
bool operator==(const SteamNetworkingIdentity &x ) const;
183183

184-
/// Calculate hash of identity. NOTE: This is just a reference implementation.
185-
/// There is no "official" hash calculation that must be used, and these values
186-
/// should never be persisted or used outside of the current process.
187-
struct Hash { uint32 operator()( const SteamNetworkingIdentity &x ) const; };
188-
189184
/// Print to a human-readable string. This is suitable for debug messages
190185
/// or any other time you need to encode the identity as a string. It has a
191186
/// URL-like format (type:<type-data>). Your buffer should be at least
@@ -499,6 +494,11 @@ typedef struct _SteamNetworkingMessage_t
499494
/// free( pMsg->m_pData );
500495
void (*m_pfnFreeData)( struct _SteamNetworkingMessage_t *msg );
501496

497+
/// Function to used to decrement reference count and, if it's zero, release
498+
/// the message. You should not normally need to access this directly.
499+
/// (Use Release(), and don't set this.)
500+
void (*m_pfnRelease)( struct _SteamNetworkingMessage_t *msg );
501+
502502
/// The channel number the message was received on.
503503
/// (Not used for messages received on "connections")
504504
int m_nChannel;
@@ -1048,13 +1048,6 @@ typedef void (*FSteamNetworkingSocketsDebugOutput)( ESteamNetworkingSocketsDebug
10481048
typedef SteamNetworkingMessage_t ISteamNetworkingMessage;
10491049
typedef SteamNetworkingErrMsg SteamDatagramErrMsg;
10501050

1051-
STEAMNETWORKINGSOCKETS_INTERFACE void SteamAPI_SteamNetworkingIPAddr_ToString( const SteamNetworkingIPAddr *pAddr, char *buf, size_t cbBuf, bool bWithPort );
1052-
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamAPI_SteamNetworkingIPAddr_ParseString( SteamNetworkingIPAddr *pAddr, const char *pszStr );
1053-
STEAMNETWORKINGSOCKETS_INTERFACE void SteamAPI_SteamNetworkingIdentity_ToString( const SteamNetworkingIdentity &identity, char *buf, size_t cbBuf );
1054-
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamAPI_SteamNetworkingIdentity_ParseString( SteamNetworkingIdentity *pIdentity, size_t sizeofIdentity, const char *pszStr );
1055-
STEAMNETWORKINGSOCKETS_INTERFACE uint32 SteamAPI_GenericHash( const void *data, size_t len );
1056-
STEAMNETWORKINGSOCKETS_INTERFACE void SteamAPI_SteamNetworkingMessage_t_Release( SteamNetworkingMessage_t *pMsg );
1057-
10581051
inline void SteamNetworkingIPAddr::Clear() { memset( this, 0, sizeof(*this) ); }
10591052
inline bool SteamNetworkingIPAddr::IsIPv6AllZeros() const { const uint64 *q = (const uint64 *)m_ipv6; return q[0] == 0 && q[1] == 0; }
10601053
inline void SteamNetworkingIPAddr::SetIPv6( const uint8 *ipv6, uint16 nPort ) { memcpy( m_ipv6, ipv6, 16 ); m_port = nPort; }
@@ -1063,8 +1056,6 @@ inline bool SteamNetworkingIPAddr::IsIPv4() const { return m_ipv4.m_8zeros == 0
10631056
inline uint32 SteamNetworkingIPAddr::GetIPv4() const { return IsIPv4() ? ( (uint32(m_ipv4.m_ip[0])<<24) | (uint32(m_ipv4.m_ip[1])<<16) | (uint32(m_ipv4.m_ip[2])<<8) | uint32(m_ipv4.m_ip[3]) ) : 0; }
10641057
inline void SteamNetworkingIPAddr::SetIPv6LocalHost( uint16 nPort ) { m_ipv4.m_8zeros = 0; m_ipv4.m_0000 = 0; m_ipv4.m_ffff = 0; m_ipv6[12] = 0; m_ipv6[13] = 0; m_ipv6[14] = 0; m_ipv6[15] = 1; m_port = nPort; }
10651058
inline bool SteamNetworkingIPAddr::IsLocalHost() const { return ( m_ipv4.m_8zeros == 0 && m_ipv4.m_0000 == 0 && m_ipv4.m_ffff == 0 && m_ipv6[12] == 0 && m_ipv6[13] == 0 && m_ipv6[14] == 0 && m_ipv6[15] == 1 ) || ( GetIPv4() == 0x7f000001 ); }
1066-
inline void SteamNetworkingIPAddr::ToString( char *buf, size_t cbBuf, bool bWithPort ) const { SteamAPI_SteamNetworkingIPAddr_ToString( this, buf, cbBuf, bWithPort ); }
1067-
inline bool SteamNetworkingIPAddr::ParseString( const char *pszStr ) { return SteamAPI_SteamNetworkingIPAddr_ParseString( this, pszStr ); }
10681059

10691060
inline void SteamNetworkingIdentity::Clear() { memset( this, 0, sizeof(*this) ); }
10701061
inline bool SteamNetworkingIdentity::IsInvalid() const { return m_eType == k_ESteamNetworkingIdentityType_Invalid; }
@@ -1084,10 +1075,17 @@ inline bool SteamNetworkingIdentity::SetGenericBytes( const void *data, size_t c
10841075
inline const uint8 *SteamNetworkingIdentity::GetGenericBytes( int &cbLen ) const { if ( m_eType != k_ESteamNetworkingIdentityType_GenericBytes ) return nullptr;
10851076
cbLen = m_cbSize; return m_genericBytes; }
10861077
inline bool SteamNetworkingIdentity::operator==(const SteamNetworkingIdentity &x ) const { return m_eType == x.m_eType && m_cbSize == x.m_cbSize && memcmp( m_genericBytes, x.m_genericBytes, m_cbSize ) == 0; }
1078+
inline void SteamNetworkingMessage_t::Release() { (*m_pfnRelease)( this ); }
1079+
1080+
#if defined( STEAMNETWORKINGSOCKETS_STATIC_LINK ) || !defined( STEAMNETWORKINGSOCKETS_STEAM )
1081+
STEAMNETWORKINGSOCKETS_INTERFACE void SteamAPI_SteamNetworkingIPAddr_ToString( const SteamNetworkingIPAddr *pAddr, char *buf, size_t cbBuf, bool bWithPort );
1082+
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamAPI_SteamNetworkingIPAddr_ParseString( SteamNetworkingIPAddr *pAddr, const char *pszStr );
1083+
STEAMNETWORKINGSOCKETS_INTERFACE void SteamAPI_SteamNetworkingIdentity_ToString( const SteamNetworkingIdentity &identity, char *buf, size_t cbBuf );
1084+
STEAMNETWORKINGSOCKETS_INTERFACE bool SteamAPI_SteamNetworkingIdentity_ParseString( SteamNetworkingIdentity *pIdentity, size_t sizeofIdentity, const char *pszStr );
1085+
inline void SteamNetworkingIPAddr::ToString( char *buf, size_t cbBuf, bool bWithPort ) const { SteamAPI_SteamNetworkingIPAddr_ToString( this, buf, cbBuf, bWithPort ); }
1086+
inline bool SteamNetworkingIPAddr::ParseString( const char *pszStr ) { return SteamAPI_SteamNetworkingIPAddr_ParseString( this, pszStr ); }
10871087
inline void SteamNetworkingIdentity::ToString( char *buf, size_t cbBuf ) const { SteamAPI_SteamNetworkingIdentity_ToString( *this, buf, cbBuf ); }
10881088
inline bool SteamNetworkingIdentity::ParseString( const char *pszStr ) { return SteamAPI_SteamNetworkingIdentity_ParseString( this, sizeof(*this), pszStr ); }
1089-
inline uint32 SteamNetworkingIdentity::Hash::operator()( const SteamNetworkingIdentity &x ) const { return SteamAPI_GenericHash( &x, sizeof( x.m_eType ) + sizeof( x.m_cbSize ) + x.m_cbSize ); }
1090-
1091-
inline void SteamNetworkingMessage_t::Release() { SteamAPI_SteamNetworkingMessage_t_Release( this ); }
1089+
#endif
10921090

10931091
#endif // #ifndef STEAMNETWORKINGTYPES

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ macro(gamenetworkingsockets_common GNS_TARGET)
170170
endif()
171171

172172
target_compile_definitions(${GNS_TARGET} PRIVATE
173-
STEAMDATAGRAMLIB_FOREXPORT
173+
STEAMNETWORKINGSOCKETS_FOREXPORT
174174
ENABLE_OPENSSLCONNECTION
175175
CRYPTO_DISABLE_ENCRYPT_WITH_PASSWORD
176176
GOOGLE_PROTOBUF_NO_RTTI
@@ -273,7 +273,7 @@ add_sanitizers(GameNetworkingSockets)
273273

274274
add_library(GameNetworkingSockets_s STATIC "")
275275
add_library(GameNetworkingSockets::static ALIAS GameNetworkingSockets_s)
276-
target_compile_definitions(GameNetworkingSockets_s INTERFACE STEAMDATAGRAMLIB_STATIC_LINK)
276+
target_compile_definitions(GameNetworkingSockets_s INTERFACE STEAMNETWORKINGSOCKETS_STATIC_LINK)
277277
gamenetworkingsockets_common(GameNetworkingSockets_s)
278278
add_sanitizers(GameNetworkingSockets_s)
279279

src/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ dependencies += [
6060
incdirs = include_directories('.', '../include', 'common', 'public')
6161

6262
cpp_flags = [
63-
'-DSTEAMDATAGRAMLIB_FOREXPORT',
63+
'-DSTEAMNETWORKINGSOCKETS_FOREXPORT',
6464
'-DENABLE_OPENSSLCONNECTION',
6565
'-DCRYPTO_DISABLE_ENCRYPT_WITH_PASSWORD',
6666
'-DGOOGLE_PROTOBUF_NO_RTTI',
@@ -137,7 +137,7 @@ GameNetworkingSockets_static = static_library('GameNetworkingSockets',
137137

138138
dep_GameNetworkingSockets_static = declare_dependency(
139139
include_directories: include_directories( '../include', '.' ),
140-
compile_args: ['-DSTEAMDATAGRAMLIB_STATIC_LINK'],
140+
compile_args: ['-DSTEAMNETWORKINGSOCKETS_STATIC_LINK'],
141141
link_with: GameNetworkingSockets_static )
142142

143143
GameNetworkingSockets_so = library('GameNetworkingSockets',

src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//====== Copyright Valve Corporation, All rights reserved. ====================
22

33
#include "csteamnetworkingsockets.h"
4-
#include <steam/steamnetworkingsockets.h>
54
#include "steamnetworkingsockets_lowlevel.h"
65
#include "steamnetworkingsockets_connections.h"
76
#include "steamnetworkingsockets_udp.h"
@@ -1204,6 +1203,27 @@ ESteamNetworkingConfigValue CSteamNetworkingUtils::GetFirstConfigValue()
12041203
return s_vecConfigValueTable[0]->m_eValue;
12051204
}
12061205

1206+
1207+
void CSteamNetworkingUtils::SteamNetworkingIPAddr_ToString( const SteamNetworkingIPAddr &addr, char *buf, size_t cbBuf, bool bWithPort )
1208+
{
1209+
SteamAPI_SteamNetworkingIPAddr_ToString( &addr, buf, cbBuf, bWithPort );
1210+
}
1211+
1212+
bool CSteamNetworkingUtils::SteamNetworkingIPAddr_ParseString( SteamNetworkingIPAddr *pAddr, const char *pszStr )
1213+
{
1214+
return SteamAPI_SteamNetworkingIPAddr_ParseString( pAddr, pszStr );
1215+
}
1216+
1217+
void CSteamNetworkingUtils::SteamNetworkingIdentity_ToString( const SteamNetworkingIdentity &identity, char *buf, size_t cbBuf )
1218+
{
1219+
return SteamAPI_SteamNetworkingIdentity_ToString( identity, buf, cbBuf );
1220+
}
1221+
1222+
bool CSteamNetworkingUtils::SteamNetworkingIdentity_ParseString( SteamNetworkingIdentity *pIdentity, const char *pszStr )
1223+
{
1224+
return SteamAPI_SteamNetworkingIdentity_ParseString( pIdentity, sizeof(SteamNetworkingIdentity), pszStr );
1225+
}
1226+
12071227
} // namespace SteamNetworkingSocketsLib
12081228
using namespace SteamNetworkingSocketsLib;
12091229

src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#pragma once
66

77
#include <time.h>
8-
#include <steam/steamnetworkingsockets.h>
8+
#include <steam/isteamnetworkingsockets.h>
99
#include <steam/isteamnetworkingutils.h>
1010

1111
#ifdef STEAMNETWORKINGSOCKETS_STEAM
@@ -140,6 +140,11 @@ class CSteamNetworkingUtils : public IClientNetworkingUtils
140140
ESteamNetworkingConfigScope *pOutScope, ESteamNetworkingConfigValue *pOutNextValue ) override;
141141

142142
virtual ESteamNetworkingConfigValue GetFirstConfigValue() override;
143+
144+
virtual void SteamNetworkingIPAddr_ToString( const SteamNetworkingIPAddr &addr, char *buf, size_t cbBuf, bool bWithPort ) override;
145+
virtual bool SteamNetworkingIPAddr_ParseString( SteamNetworkingIPAddr *pAddr, const char *pszStr ) override;
146+
virtual void SteamNetworkingIdentity_ToString( const SteamNetworkingIdentity &identity, char *buf, size_t cbBuf ) override;
147+
virtual bool SteamNetworkingIdentity_ParseString( SteamNetworkingIdentity *pIdentity, const char *pszStr ) override;
143148
};
144149

145150
} // namespace SteamNetworkingSocketsLib

src/steamnetworkingsockets/clientlib/steamnetworkingsockets_connections.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,32 @@ void CSteamNetworkingMessage::DefaultFreeData( SteamNetworkingMessage_t *pMsg )
9797
free( pMsg->m_pData );
9898
}
9999

100+
101+
void SteamNetworkingMessage_t_Release( SteamNetworkingMessage_t *pIMsg )
102+
{
103+
CSteamNetworkingMessage *pMsg = static_cast<CSteamNetworkingMessage *>( pIMsg );
104+
105+
// Free up the buffer, if we have one
106+
if ( pMsg->m_pData )
107+
{
108+
(*pMsg->m_pfnFreeData)( pMsg );
109+
pMsg->m_pData = nullptr;
110+
}
111+
112+
// We must not currently be in any queue. In fact, our parent
113+
// might have been destroyed.
114+
Assert( !pMsg->m_linksSameConnection.m_pQueue );
115+
Assert( !pMsg->m_linksSameConnection.m_pPrev );
116+
Assert( !pMsg->m_linksSameConnection.m_pNext );
117+
Assert( !pMsg->m_linksSecondaryQueue.m_pQueue );
118+
Assert( !pMsg->m_linksSecondaryQueue.m_pPrev );
119+
Assert( !pMsg->m_linksSecondaryQueue.m_pNext );
120+
121+
// Self destruct
122+
// FIXME Should avoid this dynamic memory call with some sort of pooling
123+
delete pMsg;
124+
}
125+
100126
CSteamNetworkingMessage *CSteamNetworkingMessage::New( CSteamNetworkConnectionBase *pParent, uint32 cbSize, int64 nMsgNum, SteamNetworkingMicroseconds usecNow )
101127
{
102128
// FIXME Should avoid this dynamic memory call with some sort of pooling
@@ -120,6 +146,7 @@ CSteamNetworkingMessage *CSteamNetworkingMessage::New( CSteamNetworkConnectionBa
120146
pMsg->m_usecTimeReceived = usecNow;
121147
pMsg->m_nMessageNumber = nMsgNum;
122148
pMsg->m_pfnFreeData = CSteamNetworkingMessage::DefaultFreeData;
149+
pMsg->m_pfnRelease = SteamNetworkingMessage_t_Release;
123150
return pMsg;
124151
}
125152

@@ -2278,30 +2305,3 @@ void CSteamNetworkConnectionBase::ValidateStatics( CValidator &validator )
22782305
#endif
22792306

22802307
} // namespace SteamNetworkingSocketsLib
2281-
2282-
using namespace SteamNetworkingSocketsLib;
2283-
2284-
STEAMNETWORKINGSOCKETS_INTERFACE void SteamAPI_SteamNetworkingMessage_t_Release( SteamNetworkingMessage_t *pIMsg )
2285-
{
2286-
CSteamNetworkingMessage *pMsg = static_cast<CSteamNetworkingMessage *>( pIMsg );
2287-
2288-
// Free up the buffer, if we have one
2289-
if ( pMsg->m_pData )
2290-
{
2291-
(*pMsg->m_pfnFreeData)( pMsg );
2292-
pMsg->m_pData = nullptr;
2293-
}
2294-
2295-
// We must not currently be in any queue. In fact, our parent
2296-
// might have been destroyed.
2297-
Assert( !pMsg->m_linksSameConnection.m_pQueue );
2298-
Assert( !pMsg->m_linksSameConnection.m_pPrev );
2299-
Assert( !pMsg->m_linksSameConnection.m_pNext );
2300-
Assert( !pMsg->m_linksSecondaryQueue.m_pQueue );
2301-
Assert( !pMsg->m_linksSecondaryQueue.m_pPrev );
2302-
Assert( !pMsg->m_linksSecondaryQueue.m_pNext );
2303-
2304-
// Self destruct
2305-
// FIXME Should avoid this dynamic memory call with some sort of pooling
2306-
delete pMsg;
2307-
}

src/steamnetworkingsockets/clientlib/steamnetworkingsockets_connections.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct RemoteConnectionKey_t
6666
// protect against malicious clients we might have to include
6767
// some random private data so that they don't know how our hash
6868
// function works. We'll assume for now that this isn't a problem
69-
struct Hash { uint32 operator()( const RemoteConnectionKey_t &x ) const { return SteamNetworkingIdentity::Hash{}( x.m_identity ) ^ x.m_unConnectionID; } };
69+
struct Hash { uint32 operator()( const RemoteConnectionKey_t &x ) const { return SteamNetworkingIdentityHash{}( x.m_identity ) ^ x.m_unConnectionID; } };
7070
inline bool operator ==( const RemoteConnectionKey_t &x ) const
7171
{
7272
return m_unConnectionID == x.m_unConnectionID && m_identity == x.m_identity;

0 commit comments

Comments
 (0)