mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
changes for auto port
This commit is contained in:
parent
beaadca6a9
commit
f7eda384ea
|
@ -14,10 +14,7 @@
|
|||
|
||||
# Server port (only port range 8303-8310 show up in LAN tab)
|
||||
# - "Automatically selecting free port from range 8303-8310" for 0
|
||||
sv_port 8303
|
||||
|
||||
# Find free port automatically (range from 8303-8310)
|
||||
sv_find_free_port 1
|
||||
sv_port 0
|
||||
|
||||
# Server name
|
||||
sv_name "My DDNet server"
|
||||
|
|
|
@ -2308,7 +2308,7 @@ int CServer::Run()
|
|||
m_PrintCBIndex = Console()->RegisterPrintCallback(g_Config.m_ConsoleOutputLevel, SendRconLineAuthed, this);
|
||||
|
||||
// load map
|
||||
if (!LoadMap(g_Config.m_SvMap))
|
||||
if(!LoadMap(g_Config.m_SvMap))
|
||||
{
|
||||
dbg_msg("server", "failed to load map. mapname='%s'", g_Config.m_SvMap);
|
||||
return -1;
|
||||
|
@ -2317,27 +2317,28 @@ int CServer::Run()
|
|||
// start server
|
||||
NETADDR BindAddr;
|
||||
int NetType = g_Config.m_SvIpv4Only ? NETTYPE_IPV4 : NETTYPE_ALL;
|
||||
int Port = (g_Config.m_SvPort == 0) ? 8303 : g_Config.m_SvPort;
|
||||
|
||||
if (g_Config.m_Bindaddr[0] && net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NetType) == 0)
|
||||
if(g_Config.m_Bindaddr[0] && net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NetType) == 0)
|
||||
{
|
||||
// sweet!
|
||||
BindAddr.type = NetType;
|
||||
BindAddr.port = g_Config.m_SvPort == 0 ? 8303 : g_Config.m_SvPort;
|
||||
BindAddr.port = Port;
|
||||
}
|
||||
else
|
||||
{
|
||||
mem_zero(&BindAddr, sizeof(BindAddr));
|
||||
BindAddr.type = NetType;
|
||||
BindAddr.port = g_Config.m_SvPort == 0 ? 8303 : g_Config.m_SvPort;
|
||||
BindAddr.port = Port;
|
||||
}
|
||||
|
||||
#if defined(CONF_UPNP)
|
||||
m_UPnP.Open(BindAddr);
|
||||
#endif
|
||||
|
||||
if(!g_Config.m_SvFindFreePort && (g_Config.m_SvPort != 0))
|
||||
if(g_Config.m_SvPort != 0)
|
||||
{
|
||||
if (!m_NetServer.Open(BindAddr, &m_ServerBan, g_Config.m_SvMaxClients, g_Config.m_SvMaxClientsPerIP, 0))
|
||||
if(!m_NetServer.Open(BindAddr, &m_ServerBan, g_Config.m_SvMaxClients, g_Config.m_SvMaxClientsPerIP, 0))
|
||||
{
|
||||
dbg_msg("server", "couldn't open socket. port %d might already be in use", g_Config.m_SvPort);
|
||||
return -1;
|
||||
|
@ -2345,24 +2346,18 @@ int CServer::Run()
|
|||
}
|
||||
else
|
||||
{
|
||||
while (!m_NetServer.Open(BindAddr, &m_ServerBan, g_Config.m_SvMaxClients, g_Config.m_SvMaxClientsPerIP, 0))
|
||||
while(!m_NetServer.Open(BindAddr, &m_ServerBan, g_Config.m_SvMaxClients, g_Config.m_SvMaxClientsPerIP, 0))
|
||||
{
|
||||
if (((int)(BindAddr.port - 8303)) < 7) //ugly af
|
||||
if(BindAddr.port < 8310)
|
||||
{
|
||||
dbg_msg("server", "couldn't open socket. port %d might already be in use. checking for next port.", BindAddr.port);
|
||||
BindAddr.port++;
|
||||
}
|
||||
else if (g_Config.m_SvFindFreePortM)
|
||||
else
|
||||
{
|
||||
dbg_msg("server", "couldn't open socket. port %d might already be in use", BindAddr.port);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Do one more cycle to be sure all ports used
|
||||
g_Config.m_SvFindFreePortM = 1;
|
||||
BindAddr.port = 8303;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -140,8 +140,6 @@ MACRO_CONFIG_STR(SvDnsblKey, sv_dnsbl_key, 128, "", CFGFLAG_SERVER|CFGFLAG_NONTE
|
|||
MACRO_CONFIG_INT(SvDnsblVote, sv_dnsbl_vote, 0, 0, 1, CFGFLAG_SERVER, "Block votes by blacklisted addresses")
|
||||
MACRO_CONFIG_INT(SvDnsblBan, sv_dnsbl_ban, 0, 0, 1, CFGFLAG_SERVER, "Automatically ban blacklisted addresses")
|
||||
MACRO_CONFIG_INT(SvRconVote, sv_rcon_vote, 0, 0, 1, CFGFLAG_SERVER, "Only allow authed clients to call votes")
|
||||
MACRO_CONFIG_INT(SvFindFreePort, sv_find_free_port, 1, 0, 1, CFGFLAG_SERVER, "Enables automatically searching for next available port (8303-8310)")
|
||||
MACRO_CONFIG_INT(SvFindFreePortM, sv_find_free_port_m, 0, 0, 1, CFGFLAG_SERVER, "")
|
||||
|
||||
MACRO_CONFIG_INT(SvPlayerDemoRecord, sv_player_demo_record, 0, 0, 1, CFGFLAG_SERVER, "Automatically record demos for each player")
|
||||
MACRO_CONFIG_INT(SvDemoChat, sv_demo_chat, 0, 0, 1, CFGFLAG_SERVER, "Record chat for demos")
|
||||
|
|
Loading…
Reference in a new issue