mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Read server port from CNetServer but not from app config
This commit is contained in:
parent
38e583f2f0
commit
cec8bf2195
|
@ -67,7 +67,7 @@ void CRegister::RegisterSendFwcheckresponse(NETADDR *pAddr, SECURITY_TOKEN Respo
|
|||
void CRegister::RegisterSendHeartbeat(NETADDR Addr, SECURITY_TOKEN ResponseToken)
|
||||
{
|
||||
static unsigned char aData[sizeof(SERVERBROWSE_HEARTBEAT) + 2];
|
||||
unsigned short Port = g_Config.m_SvPort;
|
||||
unsigned short Port = m_pNetServer->Address().port;
|
||||
CNetChunk Packet;
|
||||
|
||||
mem_copy(aData, SERVERBROWSE_HEARTBEAT, sizeof(SERVERBROWSE_HEARTBEAT));
|
||||
|
@ -312,7 +312,7 @@ int CRegister::RegisterProcessPacket(CNetChunk *pPacket, SECURITY_TOKEN Response
|
|||
{
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, m_pName, "ERROR: the master server reports that clients can not connect to this server.");
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "ERROR: configure your firewall/nat to let through udp on port %d.", g_Config.m_SvPort);
|
||||
str_format(aBuf, sizeof(aBuf), "ERROR: configure your firewall/nat to let through udp on port %d.", m_pNetServer->Address().port);
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, m_pName, aBuf);
|
||||
//RegisterNewState(REGISTERSTATE_ERROR);
|
||||
return 1;
|
||||
|
|
|
@ -2232,7 +2232,7 @@ int CServer::LoadMap(const char *pMapName)
|
|||
if(i < MAX_CLIENTS)
|
||||
{
|
||||
char aPath[256];
|
||||
str_format(aPath, sizeof(aPath), "demos/%s_%d_%d_tmp.demo", m_aCurrentMap, g_Config.m_SvPort, i);
|
||||
str_format(aPath, sizeof(aPath), "demos/%s_%d_%d_tmp.demo", m_aCurrentMap, m_NetServer.Address().port, i);
|
||||
Storage()->RemoveFile(aPath, IStorage::TYPE_SAVE);
|
||||
}
|
||||
}
|
||||
|
@ -2351,16 +2351,17 @@ int CServer::Run()
|
|||
|
||||
BindAddr.type = NetType;
|
||||
|
||||
for(BindAddr.port = g_Config.m_SvPort != 0 ? g_Config.m_SvPort : 8303; !m_NetServer.Open(BindAddr, &m_ServerBan, g_Config.m_SvMaxClients, g_Config.m_SvMaxClientsPerIP, 0); BindAddr.port++)
|
||||
int Port = g_Config.m_SvPort;
|
||||
for(BindAddr.port = Port != 0 ? Port : 8303; !m_NetServer.Open(BindAddr, &m_ServerBan, g_Config.m_SvMaxClients, g_Config.m_SvMaxClientsPerIP, 0); BindAddr.port++)
|
||||
{
|
||||
if(g_Config.m_SvPort != 0 || BindAddr.port >= 8310)
|
||||
if(Port != 0 || BindAddr.port >= 8310)
|
||||
{
|
||||
dbg_msg("server", "couldn't open socket. port %d might already be in use", BindAddr.port);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(g_Config.m_SvPort == 0)
|
||||
if(Port == 0)
|
||||
dbg_msg("server", "using port %d", BindAddr.port);
|
||||
|
||||
#if defined(CONF_UPNP)
|
||||
|
@ -3020,7 +3021,7 @@ void CServer::SaveDemo(int ClientID, float Time)
|
|||
// rename the demo
|
||||
char aOldFilename[256];
|
||||
char aNewFilename[256];
|
||||
str_format(aOldFilename, sizeof(aOldFilename), "demos/%s_%d_%d_tmp.demo", m_aCurrentMap, g_Config.m_SvPort, ClientID);
|
||||
str_format(aOldFilename, sizeof(aOldFilename), "demos/%s_%d_%d_tmp.demo", m_aCurrentMap, m_NetServer.Address().port, ClientID);
|
||||
str_format(aNewFilename, sizeof(aNewFilename), "demos/%s_%s_%5.2f.demo", m_aCurrentMap, m_aClients[ClientID].m_aName, Time);
|
||||
Storage()->RenameFile(aOldFilename, aNewFilename, IStorage::TYPE_SAVE);
|
||||
}
|
||||
|
@ -3031,7 +3032,7 @@ void CServer::StartRecord(int ClientID)
|
|||
if(g_Config.m_SvPlayerDemoRecord)
|
||||
{
|
||||
char aFilename[128];
|
||||
str_format(aFilename, sizeof(aFilename), "demos/%s_%d_%d_tmp.demo", m_aCurrentMap, g_Config.m_SvPort, ClientID);
|
||||
str_format(aFilename, sizeof(aFilename), "demos/%s_%d_%d_tmp.demo", m_aCurrentMap, m_NetServer.Address().port, ClientID);
|
||||
m_aDemoRecorder[ClientID].Start(Storage(), Console(), aFilename, GameServer()->NetVersion(), m_aCurrentMap, &m_aCurrentMapSha256[SIX], m_aCurrentMapCrc[SIX], "server", m_aCurrentMapSize[SIX], m_apCurrentMapData[SIX]);
|
||||
}
|
||||
}
|
||||
|
@ -3043,7 +3044,7 @@ void CServer::StopRecord(int ClientID)
|
|||
m_aDemoRecorder[ClientID].Stop();
|
||||
|
||||
char aFilename[128];
|
||||
str_format(aFilename, sizeof(aFilename), "demos/%s_%d_%d_tmp.demo", m_aCurrentMap, g_Config.m_SvPort, ClientID);
|
||||
str_format(aFilename, sizeof(aFilename), "demos/%s_%d_%d_tmp.demo", m_aCurrentMap, m_NetServer.Address().port, ClientID);
|
||||
Storage()->RemoveFile(aFilename, IStorage::TYPE_SAVE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -309,6 +309,7 @@ class CNetServer
|
|||
int m_Conns;
|
||||
};
|
||||
|
||||
NETADDR m_Address;
|
||||
NETSOCKET m_Socket;
|
||||
MMSGS m_MMSGS;
|
||||
class CNetBan *m_pNetBan;
|
||||
|
@ -367,6 +368,7 @@ public:
|
|||
// status requests
|
||||
const NETADDR *ClientAddr(int ClientID) const { return m_aSlots[ClientID].m_Connection.PeerAddress(); }
|
||||
bool HasSecurityToken(int ClientID) const { return m_aSlots[ClientID].m_Connection.SecurityToken() != NET_SECURITY_TOKEN_UNSUPPORTED; }
|
||||
NETADDR Address() const { return m_Address; }
|
||||
NETSOCKET Socket() const { return m_Socket; }
|
||||
class CNetBan *NetBan() const { return m_pNetBan; }
|
||||
int NetType() const { return m_Socket.type; }
|
||||
|
|
|
@ -57,6 +57,7 @@ bool CNetServer::Open(NETADDR BindAddr, CNetBan *pNetBan, int MaxClients, int Ma
|
|||
if(!m_Socket.type)
|
||||
return false;
|
||||
|
||||
m_Address = BindAddr;
|
||||
m_pNetBan = pNetBan;
|
||||
|
||||
// clamp clients
|
||||
|
|
Loading…
Reference in a new issue