mirror of
https://github.com/ValveSoftware/GameNetworkingSockets.git
synced 2026-05-29 16:20:34 +00:00
protobuf: eliminate deprecation warning breaking Fedora rawhide builds
- Abstracted difference between ByteSize() and ByteSizeLong() to use only the non-deprecated version where available. - Remove check which disables C++ static_assert() on macOS; pretty sure it is supported in Apple Clang these days Signed-off-by: Andrew Simpson <andy@aiusepsi.co.uk>
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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) );
|
||||
|
||||
@@ -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" );
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user