mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-12 19:18:20 +00:00
net_addr_str only once
This commit is contained in:
parent
076bfc68b0
commit
3cb390c6e6
|
@ -2285,7 +2285,7 @@ void CServer::FillAntibot(CAntibotRoundData *pData)
|
||||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||||
{
|
{
|
||||||
CAntibotPlayerData *pPlayer = &pData->m_aPlayers[i];
|
CAntibotPlayerData *pPlayer = &pData->m_aPlayers[i];
|
||||||
net_addr_str(m_NetServer.ClientAddr(i), pPlayer->m_aAddress, sizeof(pPlayer->m_aAddress), true);
|
str_copy(pPlayer->m_aAddress, m_NetServer.ClientAddrString(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,6 +238,8 @@ private:
|
||||||
NETSOCKET m_Socket;
|
NETSOCKET m_Socket;
|
||||||
NETSTATS m_Stats;
|
NETSTATS m_Stats;
|
||||||
|
|
||||||
|
char m_aPeerAddrStr[NETADDR_MAXSTRSIZE];
|
||||||
|
|
||||||
//
|
//
|
||||||
void ResetStats();
|
void ResetStats();
|
||||||
void SetError(const char *pString);
|
void SetError(const char *pString);
|
||||||
|
@ -268,6 +270,7 @@ public:
|
||||||
void SignalResend();
|
void SignalResend();
|
||||||
int State() const { return m_State; }
|
int State() const { return m_State; }
|
||||||
const NETADDR *PeerAddress() const { return &m_PeerAddr; }
|
const NETADDR *PeerAddress() const { return &m_PeerAddr; }
|
||||||
|
const char *PeerAddressString() const { return m_aPeerAddrStr; }
|
||||||
void ConnectAddresses(const NETADDR **ppAddrs, int *pNumAddrs) const
|
void ConnectAddresses(const NETADDR **ppAddrs, int *pNumAddrs) const
|
||||||
{
|
{
|
||||||
*ppAddrs = m_aConnectAddrs;
|
*ppAddrs = m_aConnectAddrs;
|
||||||
|
@ -417,6 +420,7 @@ public:
|
||||||
|
|
||||||
// status requests
|
// status requests
|
||||||
const NETADDR *ClientAddr(int ClientId) const { return m_aSlots[ClientId].m_Connection.PeerAddress(); }
|
const NETADDR *ClientAddr(int ClientId) const { return m_aSlots[ClientId].m_Connection.PeerAddress(); }
|
||||||
|
const char *ClientAddrString(int ClientID) const { return m_aSlots[ClientID].m_Connection.PeerAddressString(); }
|
||||||
bool HasSecurityToken(int ClientId) const { return m_aSlots[ClientId].m_Connection.SecurityToken() != NET_SECURITY_TOKEN_UNSUPPORTED; }
|
bool HasSecurityToken(int ClientId) const { return m_aSlots[ClientId].m_Connection.SecurityToken() != NET_SECURITY_TOKEN_UNSUPPORTED; }
|
||||||
NETADDR Address() const { return m_Address; }
|
NETADDR Address() const { return m_Address; }
|
||||||
NETSOCKET Socket() const { return m_Socket; }
|
NETSOCKET Socket() const { return m_Socket; }
|
||||||
|
|
|
@ -41,6 +41,7 @@ void CNetConnection::Reset(bool Rejoin)
|
||||||
m_Buffer.Init();
|
m_Buffer.Init();
|
||||||
|
|
||||||
mem_zero(&m_Construct, sizeof(m_Construct));
|
mem_zero(&m_Construct, sizeof(m_Construct));
|
||||||
|
m_aPeerAddrStr[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *CNetConnection::ErrorString()
|
const char *CNetConnection::ErrorString()
|
||||||
|
@ -240,6 +241,7 @@ void CNetConnection::DirectInit(const NETADDR &Addr, SECURITY_TOKEN SecurityToke
|
||||||
m_State = NET_CONNSTATE_ONLINE;
|
m_State = NET_CONNSTATE_ONLINE;
|
||||||
|
|
||||||
m_PeerAddr = Addr;
|
m_PeerAddr = Addr;
|
||||||
|
net_addr_str(&Addr, m_aPeerAddrStr, sizeof(m_aPeerAddrStr), false);
|
||||||
mem_zero(m_aErrorString, sizeof(m_aErrorString));
|
mem_zero(m_aErrorString, sizeof(m_aErrorString));
|
||||||
|
|
||||||
int64_t Now = time_get();
|
int64_t Now = time_get();
|
||||||
|
@ -353,6 +355,7 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr, SECURITY_
|
||||||
Reset();
|
Reset();
|
||||||
m_State = NET_CONNSTATE_PENDING;
|
m_State = NET_CONNSTATE_PENDING;
|
||||||
m_PeerAddr = *pAddr;
|
m_PeerAddr = *pAddr;
|
||||||
|
net_addr_str(pAddr, m_aPeerAddrStr, sizeof(m_aPeerAddrStr), false);
|
||||||
mem_zero(m_aErrorString, sizeof(m_aErrorString));
|
mem_zero(m_aErrorString, sizeof(m_aErrorString));
|
||||||
m_LastSendTime = Now;
|
m_LastSendTime = Now;
|
||||||
m_LastRecvTime = Now;
|
m_LastRecvTime = Now;
|
||||||
|
@ -380,6 +383,7 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr, SECURITY_
|
||||||
if(CtrlMsg == NET_CTRLMSG_CONNECTACCEPT)
|
if(CtrlMsg == NET_CTRLMSG_CONNECTACCEPT)
|
||||||
{
|
{
|
||||||
m_PeerAddr = *pAddr;
|
m_PeerAddr = *pAddr;
|
||||||
|
net_addr_str(pAddr, m_aPeerAddrStr, sizeof(m_aPeerAddrStr), false);
|
||||||
if(m_SecurityToken == NET_SECURITY_TOKEN_UNKNOWN && pPacket->m_DataSize >= (int)(1 + sizeof(SECURITY_TOKEN_MAGIC) + sizeof(m_SecurityToken)) && !mem_comp(&pPacket->m_aChunkData[1], SECURITY_TOKEN_MAGIC, sizeof(SECURITY_TOKEN_MAGIC)))
|
if(m_SecurityToken == NET_SECURITY_TOKEN_UNKNOWN && pPacket->m_DataSize >= (int)(1 + sizeof(SECURITY_TOKEN_MAGIC) + sizeof(m_SecurityToken)) && !mem_comp(&pPacket->m_aChunkData[1], SECURITY_TOKEN_MAGIC, sizeof(SECURITY_TOKEN_MAGIC)))
|
||||||
{
|
{
|
||||||
m_SecurityToken = ToSecurityToken(&pPacket->m_aChunkData[1 + sizeof(SECURITY_TOKEN_MAGIC)]);
|
m_SecurityToken = ToSecurityToken(&pPacket->m_aChunkData[1 + sizeof(SECURITY_TOKEN_MAGIC)]);
|
||||||
|
|
Loading…
Reference in a new issue