diff --git a/src/public/minbase/minbase_macros.h b/src/public/minbase/minbase_macros.h index 0292535..efa2c5d 100644 --- a/src/public/minbase/minbase_macros.h +++ b/src/public/minbase/minbase_macros.h @@ -32,7 +32,7 @@ // If available use static_assert instead of weird language tricks. This // leads to much more readable messages when compile time assert constraints // are violated. -#if !defined(OSX) && (_MSC_VER > 1500 || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined(__clang__) ) +#if (_MSC_VER > 1500 || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined(__clang__) ) #define PLAT_COMPILE_TIME_ASSERT( pred ) static_assert( pred, "Compile time assert constraint is not true: " #pred ) #else #define PLAT_COMPILE_TIME_ASSERT( pred ) typedef int UNIQUE_ID[ (pred) ? 1 : -1] diff --git a/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp b/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp index 69e4050..fab97e8 100644 --- a/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp +++ b/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp @@ -425,7 +425,7 @@ bool CSteamNetworkingSockets::GetCertificateRequest( int *pcbBlob, void *pBlob, } // Check size - int cb = msgRequest.ByteSize(); + ProtoMsgSize cb = msgRequest.ProtoByteSize(); if ( !pBlob ) { *pcbBlob = cb; diff --git a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_connections.h b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_connections.h index b5c1fef..e59c72d 100644 --- a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_connections.h +++ b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_connections.h @@ -97,13 +97,13 @@ struct SendPacketContext : SendPacketContext_t uint32 m_nFlags; // Message flags that we need to set. TStatsMsg msg; // Type-specific stats message - int m_cbMsgSize; // Size of message - int m_cbTotalSize; // Size needed in the header, including the serialized size field + ProtoMsgSize m_cbMsgSize; // Size of message + ProtoMsgSize m_cbTotalSize; // Size needed in the header, including the serialized size field void SlamFlagsAndCalcSize() { SetStatsMsgFlagsIfNotImplied( msg, m_nFlags ); - m_cbTotalSize = m_cbMsgSize = msg.ByteSize(); + m_cbTotalSize = m_cbMsgSize = msg.ProtoByteSize(); if ( m_cbMsgSize > 0 ) m_cbTotalSize += VarIntSerializedSize( (uint32)m_cbMsgSize ); } diff --git a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_udp.cpp b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_udp.cpp index 8a91703..2c0a483 100644 --- a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_udp.cpp +++ b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_udp.cpp @@ -492,10 +492,10 @@ void CSteamNetworkListenSocketDirectUDP::SendMsg( uint8 nMsgID, const google::pr uint8 pkt[ k_cbSteamNetworkingSocketsMaxUDPMsgLen ]; pkt[0] = nMsgID; - int cbPkt = msg.ByteSize()+1; + ProtoMsgSize cbPkt = msg.ProtoByteSize()+1; if ( cbPkt > sizeof(pkt) ) { - AssertMsg3( false, "Msg type %d is %d bytes, larger than MTU of %d bytes", int( nMsgID ), cbPkt, (int)sizeof(pkt) ); + AssertMsg3( false, "Msg type %d is %d bytes, larger than MTU of %d bytes", int( nMsgID ), int( cbPkt ), (int)sizeof(pkt) ); return; } uint8 *pEnd = msg.SerializeWithCachedSizesToArray( pkt+1 ); @@ -511,7 +511,7 @@ void CSteamNetworkListenSocketDirectUDP::SendPaddedMsg( uint8 nMsgID, const goog uint8 pkt[ k_cbSteamNetworkingSocketsMaxUDPMsgLen ]; memset( pkt, 0, sizeof(pkt) ); // don't send random bits from our process memory over the wire! UDPPaddedMessageHdr *hdr = (UDPPaddedMessageHdr *)pkt; - int nMsgLength = msg.ByteSize(); + ProtoMsgSize nMsgLength = msg.ProtoByteSize(); hdr->m_nMsgID = nMsgID; hdr->m_nMsgLength = LittleWord( uint16( nMsgLength ) ); uint8 *pEnd = msg.SerializeWithCachedSizesToArray( pkt + sizeof(*hdr) ); @@ -1017,10 +1017,10 @@ void CConnectionTransportUDP::SendMsg( uint8 nMsgID, const google::protobuf::Mes uint8 pkt[ k_cbSteamNetworkingSocketsMaxUDPMsgLen ]; pkt[0] = nMsgID; - int cbPkt = msg.ByteSize()+1; + ProtoMsgSize cbPkt = msg.ProtoByteSize()+1; if ( cbPkt > sizeof(pkt) ) { - AssertMsg3( false, "Msg type %d is %d bytes, larger than MTU of %d bytes", int( nMsgID ), cbPkt, (int)sizeof(pkt) ); + AssertMsg3( false, "Msg type %d is %d bytes, larger than MTU of %d bytes", int( nMsgID ), int( cbPkt ), (int)sizeof(pkt) ); return; } uint8 *pEnd = msg.SerializeWithCachedSizesToArray( pkt+1 ); @@ -1035,7 +1035,7 @@ void CConnectionTransportUDP::SendPaddedMsg( uint8 nMsgID, const google::protobu uint8 pkt[ k_cbSteamNetworkingSocketsMaxUDPMsgLen ]; V_memset( pkt, 0, sizeof(pkt) ); // don't send random bits from our process memory over the wire! UDPPaddedMessageHdr *hdr = (UDPPaddedMessageHdr *)pkt; - int nMsgLength = msg.ByteSize(); + ProtoMsgSize nMsgLength = msg.ProtoByteSize(); if ( nMsgLength + sizeof(*hdr) > k_cbSteamNetworkingSocketsMaxUDPMsgLen ) { AssertMsg3( false, "Msg type %d is %d bytes, larger than MTU of %d bytes", int( nMsgID ), int( nMsgLength + sizeof(*hdr) ), (int)sizeof(pkt) ); diff --git a/src/steamnetworkingsockets/steamnetworkingsockets_certs.cpp b/src/steamnetworkingsockets/steamnetworkingsockets_certs.cpp index 0dc6c60..3ffc686 100644 --- a/src/steamnetworkingsockets/steamnetworkingsockets_certs.cpp +++ b/src/steamnetworkingsockets/steamnetworkingsockets_certs.cpp @@ -93,7 +93,7 @@ bool BSteamNetworkingIdentityFromLegacyBinaryProtobuf( SteamNetworkingIdentity & { V_sprintf_safe( errMsg, "Unrecognized identity format. (%d unknown field(s), first ID=%d)", msgIdentity.unknown_fields().field_count(), msgIdentity.unknown_fields().field(0).number() ); } - else if ( msgIdentity.ByteSize() == 0 ) + else if ( msgIdentity.ProtoByteSize() == 0 ) { V_strcpy_safe( errMsg, "Empty identity msg" ); } diff --git a/src/steamnetworkingsockets/steamnetworkingsockets_internal.h b/src/steamnetworkingsockets/steamnetworkingsockets_internal.h index 1f05742..e5d9bb5 100644 --- a/src/steamnetworkingsockets/steamnetworkingsockets_internal.h +++ b/src/steamnetworkingsockets/steamnetworkingsockets_internal.h @@ -110,6 +110,14 @@ struct iovec; // Internal stuff goes in a private namespace namespace SteamNetworkingSocketsLib { +#if GOOGLE_PROTOBUF_VERSION < 3004000 +using ProtoMsgSize = int; +#define ProtoByteSize ByteSize +#else +using ProtoMsgSize = size_t; +#define ProtoByteSize ByteSizeLong +#endif + struct SteamDatagramLinkStats; struct SteamDatagramLinkLifetimeStats; struct SteamDatagramLinkInstantaneousStats;