mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
send ahead window for maps downloading. works with vanilla client.
This commit is contained in:
parent
50b722b2b4
commit
cae8c68d87
|
@ -748,8 +748,13 @@ int CServer::DelClientCallback(int ClientID, const char *pReason, void *pUser)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int lastsent[MAX_CLIENTS];
|
||||||
|
static int lastask[MAX_CLIENTS];
|
||||||
|
|
||||||
void CServer::SendMap(int ClientID)
|
void CServer::SendMap(int ClientID)
|
||||||
{
|
{
|
||||||
|
lastsent[ClientID] = 0;
|
||||||
|
lastask[ClientID] = 0;
|
||||||
CMsgPacker Msg(NETMSG_MAP_CHANGE);
|
CMsgPacker Msg(NETMSG_MAP_CHANGE);
|
||||||
Msg.AddString(GetMapName(), 0);
|
Msg.AddString(GetMapName(), 0);
|
||||||
Msg.AddInt(m_CurrentMapCrc);
|
Msg.AddInt(m_CurrentMapCrc);
|
||||||
|
@ -876,6 +881,12 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
||||||
int Offset = Chunk * ChunkSize;
|
int Offset = Chunk * ChunkSize;
|
||||||
int Last = 0;
|
int Last = 0;
|
||||||
|
|
||||||
|
lastask[ClientID] = Chunk;
|
||||||
|
if (Chunk == 0)
|
||||||
|
{
|
||||||
|
lastsent[ClientID] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// drop faulty map data requests
|
// drop faulty map data requests
|
||||||
if(Chunk < 0 || Offset > m_CurrentMapSize)
|
if(Chunk < 0 || Offset > m_CurrentMapSize)
|
||||||
return;
|
return;
|
||||||
|
@ -888,6 +899,9 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
|
||||||
Last = 1;
|
Last = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lastsent[ClientID]+ChunkSize < m_CurrentMapSize && lastsent[ClientID] < Chunk+g_Config.m_SvMapWindow)
|
||||||
|
return;
|
||||||
|
|
||||||
CMsgPacker Msg(NETMSG_MAP_DATA);
|
CMsgPacker Msg(NETMSG_MAP_DATA);
|
||||||
Msg.AddInt(Last);
|
Msg.AddInt(Last);
|
||||||
Msg.AddInt(m_CurrentMapCrc);
|
Msg.AddInt(m_CurrentMapCrc);
|
||||||
|
@ -1208,6 +1222,45 @@ void CServer::PumpNetwork()
|
||||||
ProcessClientPacket(&Packet);
|
ProcessClientPacket(&Packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i=0;i<MAX_CLIENTS;i++)
|
||||||
|
{
|
||||||
|
if (m_aClients[i].m_State != CClient::STATE_CONNECTING)
|
||||||
|
continue;
|
||||||
|
if (lastask[i]<lastsent[i]-g_Config.m_SvMapWindow)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int Chunk = lastsent[i]++;
|
||||||
|
int ChunkSize = 1024-128;
|
||||||
|
int Offset = Chunk * ChunkSize;
|
||||||
|
int Last = 0;
|
||||||
|
|
||||||
|
// drop faulty map data requests
|
||||||
|
if(Chunk < 0 || Offset > m_CurrentMapSize)
|
||||||
|
continue;
|
||||||
|
if(Offset+ChunkSize >= m_CurrentMapSize)
|
||||||
|
{
|
||||||
|
ChunkSize = m_CurrentMapSize-Offset;
|
||||||
|
if(ChunkSize < 0)
|
||||||
|
ChunkSize = 0;
|
||||||
|
Last = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
CMsgPacker Msg(NETMSG_MAP_DATA);
|
||||||
|
Msg.AddInt(Last);
|
||||||
|
Msg.AddInt(m_CurrentMapCrc);
|
||||||
|
Msg.AddInt(Chunk);
|
||||||
|
Msg.AddInt(ChunkSize);
|
||||||
|
Msg.AddRaw(&m_pCurrentMapData[Offset], ChunkSize);
|
||||||
|
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, i, true);
|
||||||
|
|
||||||
|
if(g_Config.m_Debug)
|
||||||
|
{
|
||||||
|
char aBuf[256];
|
||||||
|
str_format(aBuf, sizeof(aBuf), "sending chunk %d with size %d", Chunk, ChunkSize);
|
||||||
|
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_ServerBan.Update();
|
m_ServerBan.Update();
|
||||||
m_Econ.Update();
|
m_Econ.Update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,8 @@ MACRO_CONFIG_INT(SvRconBantime, sv_rcon_bantime, 5, 0, 1440, CFGFLAG_SERVER, "Th
|
||||||
MACRO_CONFIG_INT(SvAutoDemoRecord, sv_auto_demo_record, 0, 0, 1, CFGFLAG_SERVER, "Automatically record demos")
|
MACRO_CONFIG_INT(SvAutoDemoRecord, sv_auto_demo_record, 0, 0, 1, CFGFLAG_SERVER, "Automatically record demos")
|
||||||
MACRO_CONFIG_INT(SvAutoDemoMax, sv_auto_demo_max, 10, 0, 1000, CFGFLAG_SERVER, "Maximum number of automatically recorded demos (0 = no limit)")
|
MACRO_CONFIG_INT(SvAutoDemoMax, sv_auto_demo_max, 10, 0, 1000, CFGFLAG_SERVER, "Maximum number of automatically recorded demos (0 = no limit)")
|
||||||
|
|
||||||
|
MACRO_CONFIG_INT(SvMapWindow, sv_map_window, 15, 0, 100, CFGFLAG_SERVER, "Map downloading send-ahead window")
|
||||||
|
|
||||||
MACRO_CONFIG_STR(EcBindaddr, ec_bindaddr, 128, "localhost", CFGFLAG_ECON, "Address to bind the external console to. Anything but 'localhost' is dangerous")
|
MACRO_CONFIG_STR(EcBindaddr, ec_bindaddr, 128, "localhost", CFGFLAG_ECON, "Address to bind the external console to. Anything but 'localhost' is dangerous")
|
||||||
MACRO_CONFIG_INT(EcPort, ec_port, 0, 0, 0, CFGFLAG_ECON, "Port to use for the external console")
|
MACRO_CONFIG_INT(EcPort, ec_port, 0, 0, 0, CFGFLAG_ECON, "Port to use for the external console")
|
||||||
MACRO_CONFIG_STR(EcPassword, ec_password, 32, "", CFGFLAG_ECON, "External console password")
|
MACRO_CONFIG_STR(EcPassword, ec_password, 32, "", CFGFLAG_ECON, "External console password")
|
||||||
|
|
|
@ -232,7 +232,7 @@ int CNetServer::Send(CNetChunk *pChunk)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Drop(pChunk->m_ClientID, "Error sending data");
|
// Drop(pChunk->m_ClientID, "Error sending data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue