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:
oy 2012-03-04 12:47:16 +01:00
parent 9fee99b2f6
commit 314978a87f
6 changed files with 18 additions and 4 deletions

View file

@ -1740,14 +1740,19 @@ void CClient::Run()
// open socket
{
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));
BindAddr.type = NETTYPE_ALL;
}
if(!m_NetClient.Open(BindAddr, 0))
{
dbg_msg("client", "couldn't start network");
dbg_msg("client", "couldn't open socket");
return;
}
}

View file

@ -482,7 +482,7 @@ void CServerBrowser::Refresh(int Type)
/* do the broadcast version */
Packet.m_ClientID = -1;
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_DataSize = sizeof(Buffer);
Packet.m_pData = Buffer;

View file

@ -1274,6 +1274,7 @@ int CServer::Run()
if(g_Config.m_Bindaddr[0] && net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) == 0)
{
// sweet!
BindAddr.type = NETTYPE_ALL;
BindAddr.port = g_Config.m_SvPort;
}
else

View file

@ -75,7 +75,11 @@ void CEcon::Init(IConsole *pConsole, CNetBan *pNetBan)
NETADDR BindAddr;
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;
}
else
{
mem_zero(&BindAddr, sizeof(BindAddr));

View file

@ -353,7 +353,7 @@ public:
int ResetErrorString();
// error and state
int NetType() { return m_Socket.type; }
int NetType() const { return m_Socket.type; }
int State();
int GotProblems();
const char *ErrorString();

View file

@ -348,7 +348,11 @@ int main(int argc, const char **argv) // 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)
{
// got bindaddr
BindAddr.type = NETTYPE_ALL;
BindAddr.port = MASTERSERVER_PORT;
}
else
{
mem_zero(&BindAddr, sizeof(BindAddr));