Move rendering helpers.

When linking with Steam, these call ISteamNetworkingUtils functions, and
GCC complains if it hasn't seen that class.  Even if you don't ever call
any of these functions, GCC doesn't like the fact it could not generate the
code if you were to do so.  Not sure what the spec says, but it feels like
Visual Studio's approach makes more sense here.
This commit is contained in:
Fletcher Dunn
2020-05-02 13:17:32 -07:00
parent 65a52e7470
commit 3db36c63ca
3 changed files with 20 additions and 19 deletions
+19
View File
@@ -180,6 +180,25 @@ protected:
)
#endif
/// Utility class for printing a SteamNetworkingIdentity.
/// E.g. printf( "Identity is '%s'\n", SteamNetworkingIdentityRender( identity ).c_str() );
struct SteamNetworkingIdentityRender
{
SteamNetworkingIdentityRender( const SteamNetworkingIdentity &x ) { x.ToString( buf, sizeof(buf) ); }
inline const char *c_str() const { return buf; }
private:
char buf[ SteamNetworkingIdentity::k_cchMaxString ];
};
/// Utility class for printing a SteamNetworkingIPAddrRender.
struct SteamNetworkingIPAddrRender
{
SteamNetworkingIPAddrRender( const SteamNetworkingIPAddr &x, bool bWithPort = true ) { x.ToString( buf, sizeof(buf), bWithPort ); }
inline const char *c_str() const { return buf; }
private:
char buf[ SteamNetworkingIPAddr::k_cchMaxString ];
};
///////////////////////////////////////////////////////////////////////////////
//
// Internal stuff
-19
View File
@@ -1300,25 +1300,6 @@ inline void GetSteamNetworkingLocationPOPStringFromID( SteamNetworkingPOPID id,
/// The POPID "dev" is used in non-production environments for testing.
const SteamNetworkingPOPID k_SteamDatagramPOPID_dev = ( (uint32)'d' << 16U ) | ( (uint32)'e' << 8U ) | (uint32)'v';
/// Utility class for printing a SteamNetworkingIdentity.
/// E.g. printf( "Identity is '%s'\n", SteamNetworkingIdentityRender( identity ).c_str() );
struct SteamNetworkingIdentityRender
{
SteamNetworkingIdentityRender( const SteamNetworkingIdentity &x ) { x.ToString( buf, sizeof(buf) ); }
inline const char *c_str() const { return buf; }
private:
char buf[ SteamNetworkingIdentity::k_cchMaxString ];
};
/// Utility class for printing a SteamNetworkingIPAddrRender.
struct SteamNetworkingIPAddrRender
{
SteamNetworkingIPAddrRender( const SteamNetworkingIPAddr &x, bool bWithPort = true ) { x.ToString( buf, sizeof(buf), bWithPort ); }
inline const char *c_str() const { return buf; }
private:
char buf[ SteamNetworkingIPAddr::k_cchMaxString ];
};
/// Utility class for printing a SteamNetworkingPOPID.
struct SteamNetworkingPOPIDRender
{
@@ -57,6 +57,7 @@
#include "keypair.h"
#include <tier0/memdbgoff.h>
#include <steamnetworkingsockets_messages_certs.pb.h>
#include <steam/isteamnetworkingutils.h> // for the rendering helpers
// Running against Steam? Then we have some default signaling.
// Otherwise, we don't