mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Make simple CNetAdr methods inline
Should be inline for their simplicity to improve performance.
This commit is contained in:
parent
4ed2e7a12a
commit
8e1019a265
@ -15,29 +15,28 @@ enum class netadrtype_t
|
||||
class CNetAdr
|
||||
{
|
||||
public:
|
||||
CNetAdr(void);
|
||||
CNetAdr(const char* pch);
|
||||
CNetAdr(void) { Clear(); }
|
||||
CNetAdr(const char* pch) { SetFromString(pch); }
|
||||
void Clear(void);
|
||||
|
||||
void SetIP(IN6_ADDR* inAdr);
|
||||
void SetPort(uint16_t port);
|
||||
void SetType(netadrtype_t type);
|
||||
inline void SetIP(IN6_ADDR* inAdr) { adr = *inAdr; }
|
||||
inline void SetPort(uint16_t newport) { port = newport; }
|
||||
inline void SetType(netadrtype_t newtype) { type = newtype; }
|
||||
|
||||
bool SetFromSockadr(struct sockaddr_storage* s);
|
||||
bool SetFromString(const char* pch, bool bUseDNS = false);
|
||||
|
||||
netadrtype_t GetType(void) const;
|
||||
uint16_t GetPort(void) const;
|
||||
inline netadrtype_t GetType(void) const { return type; }
|
||||
inline uint16_t GetPort(void) const { return port; }
|
||||
|
||||
bool CompareAdr(const CNetAdr& other) const;
|
||||
bool ComparePort(const CNetAdr& other) const;
|
||||
bool CompareAdr(const CNetAdr& other) const;
|
||||
inline bool ComparePort(const CNetAdr& other) const { return port == other.port; }
|
||||
inline bool IsLoopback(void) const { return type == netadrtype_t::NA_LOOPBACK; } // true if engine loopback buffers are used.
|
||||
|
||||
const char* ToString(bool onlyBase = false) const;
|
||||
void ToString(char* pchBuffer, size_t unBufferSize, bool onlyBase = false) const;
|
||||
void ToAdrinfo(addrinfo* pHint) const;
|
||||
|
||||
void ToSockadr(struct sockaddr_storage* s) const;
|
||||
bool IsLoopback(void) const; // true if engine loopback buffers are used.
|
||||
const char* ToString(bool onlyBase = false) const;
|
||||
void ToString(char* pchBuffer, size_t unBufferSize, bool onlyBase = false) const;
|
||||
void ToAdrinfo(addrinfo* pHint) const;
|
||||
void ToSockadr(struct sockaddr_storage* s) const;
|
||||
|
||||
private:
|
||||
netadrtype_t type;
|
||||
|
@ -7,22 +7,6 @@
|
||||
#include "tier1/NetAdr.h"
|
||||
#include "tier1/strtools.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Constructors.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
CNetAdr::CNetAdr(void)
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Constructors.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
CNetAdr::CNetAdr(const char* pch)
|
||||
{
|
||||
SetFromString(pch);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Clears IP.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@ -34,46 +18,6 @@ void CNetAdr::Clear(void)
|
||||
type = netadrtype_t::NA_NULL;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Sets IP.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
void CNetAdr::SetIP(IN6_ADDR* inAdr)
|
||||
{
|
||||
adr = *inAdr;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Sets the address type.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
void CNetAdr::SetType(netadrtype_t newtype)
|
||||
{
|
||||
type = newtype;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Returns the address type.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
netadrtype_t CNetAdr::GetType(void) const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Sets the port (must be network byte order, use 'htons' to flip).
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
void CNetAdr::SetPort(uint16_t newport)
|
||||
{
|
||||
port = newport;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Returns the port in network byte order (use 'ntohs' to flip).
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
uint16_t CNetAdr::GetPort(void) const
|
||||
{
|
||||
return port;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Compares two addresses.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@ -95,14 +39,6 @@ bool CNetAdr::CompareAdr(const CNetAdr& other) const
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Compares two ports.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
bool CNetAdr::ComparePort(const CNetAdr& other) const
|
||||
{
|
||||
return port == other.port;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Convert address to string.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@ -217,14 +153,6 @@ bool CNetAdr::SetFromSockadr(struct sockaddr_storage* s)
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Returns true if we use the loopback buffers.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
bool CNetAdr::IsLoopback(void) const
|
||||
{
|
||||
return type == netadrtype_t::NA_LOOPBACK;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user