mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
fixed used nettype in server browser and try to use ipv4 and ipv6 socket when using a bindaddr. Closes #940
This commit is contained in:
parent
9fee99b2f6
commit
314978a87f
|
@ -1740,14 +1740,19 @@ void CClient::Run()
|
||||||
// open socket
|
// open socket
|
||||||
{
|
{
|
||||||
NETADDR BindAddr;
|
NETADDR BindAddr;
|
||||||
if(g_Config.m_Bindaddr[0] == 0 || net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) != 0)
|
if(g_Config.m_Bindaddr[0] && net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) == 0)
|
||||||
|
{
|
||||||
|
// got bindaddr
|
||||||
|
BindAddr.type = NETTYPE_ALL;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
mem_zero(&BindAddr, sizeof(BindAddr));
|
mem_zero(&BindAddr, sizeof(BindAddr));
|
||||||
BindAddr.type = NETTYPE_ALL;
|
BindAddr.type = NETTYPE_ALL;
|
||||||
}
|
}
|
||||||
if(!m_NetClient.Open(BindAddr, 0))
|
if(!m_NetClient.Open(BindAddr, 0))
|
||||||
{
|
{
|
||||||
dbg_msg("client", "couldn't start network");
|
dbg_msg("client", "couldn't open socket");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -482,7 +482,7 @@ void CServerBrowser::Refresh(int Type)
|
||||||
/* do the broadcast version */
|
/* do the broadcast version */
|
||||||
Packet.m_ClientID = -1;
|
Packet.m_ClientID = -1;
|
||||||
mem_zero(&Packet, sizeof(Packet));
|
mem_zero(&Packet, sizeof(Packet));
|
||||||
Packet.m_Address.type = NETTYPE_ALL|NETTYPE_LINK_BROADCAST;
|
Packet.m_Address.type = m_pNetClient->NetType()|NETTYPE_LINK_BROADCAST;
|
||||||
Packet.m_Flags = NETSENDFLAG_CONNLESS;
|
Packet.m_Flags = NETSENDFLAG_CONNLESS;
|
||||||
Packet.m_DataSize = sizeof(Buffer);
|
Packet.m_DataSize = sizeof(Buffer);
|
||||||
Packet.m_pData = Buffer;
|
Packet.m_pData = Buffer;
|
||||||
|
|
|
@ -1274,6 +1274,7 @@ int CServer::Run()
|
||||||
if(g_Config.m_Bindaddr[0] && net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) == 0)
|
if(g_Config.m_Bindaddr[0] && net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) == 0)
|
||||||
{
|
{
|
||||||
// sweet!
|
// sweet!
|
||||||
|
BindAddr.type = NETTYPE_ALL;
|
||||||
BindAddr.port = g_Config.m_SvPort;
|
BindAddr.port = g_Config.m_SvPort;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -75,7 +75,11 @@ void CEcon::Init(IConsole *pConsole, CNetBan *pNetBan)
|
||||||
|
|
||||||
NETADDR BindAddr;
|
NETADDR BindAddr;
|
||||||
if(g_Config.m_EcBindaddr[0] && net_host_lookup(g_Config.m_EcBindaddr, &BindAddr, NETTYPE_ALL) == 0)
|
if(g_Config.m_EcBindaddr[0] && net_host_lookup(g_Config.m_EcBindaddr, &BindAddr, NETTYPE_ALL) == 0)
|
||||||
|
{
|
||||||
|
// got bindaddr
|
||||||
|
BindAddr.type = NETTYPE_ALL;
|
||||||
BindAddr.port = g_Config.m_EcPort;
|
BindAddr.port = g_Config.m_EcPort;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mem_zero(&BindAddr, sizeof(BindAddr));
|
mem_zero(&BindAddr, sizeof(BindAddr));
|
||||||
|
|
|
@ -353,7 +353,7 @@ public:
|
||||||
int ResetErrorString();
|
int ResetErrorString();
|
||||||
|
|
||||||
// error and state
|
// error and state
|
||||||
int NetType() { return m_Socket.type; }
|
int NetType() const { return m_Socket.type; }
|
||||||
int State();
|
int State();
|
||||||
int GotProblems();
|
int GotProblems();
|
||||||
const char *ErrorString();
|
const char *ErrorString();
|
||||||
|
|
|
@ -348,7 +348,11 @@ int main(int argc, const char **argv) // ignore_convention
|
||||||
m_pConsole->ParseArguments(argc-1, &argv[1]); // ignore_convention
|
m_pConsole->ParseArguments(argc-1, &argv[1]); // ignore_convention
|
||||||
|
|
||||||
if(g_Config.m_Bindaddr[0] && net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) == 0)
|
if(g_Config.m_Bindaddr[0] && net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) == 0)
|
||||||
|
{
|
||||||
|
// got bindaddr
|
||||||
|
BindAddr.type = NETTYPE_ALL;
|
||||||
BindAddr.port = MASTERSERVER_PORT;
|
BindAddr.port = MASTERSERVER_PORT;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mem_zero(&BindAddr, sizeof(BindAddr));
|
mem_zero(&BindAddr, sizeof(BindAddr));
|
||||||
|
|
Loading…
Reference in a new issue