Merge pull request #203 from eeeee/fastdl-fix

turns out that Drop was needed after all :S
This commit is contained in:
Shereef Marzouk 2012-12-23 09:16:21 -08:00
commit 02036bc876
2 changed files with 12 additions and 4 deletions

View file

@ -750,11 +750,13 @@ int CServer::DelClientCallback(int ClientID, const char *pReason, void *pUser)
static int lastsent[MAX_CLIENTS]; static int lastsent[MAX_CLIENTS];
static int lastask[MAX_CLIENTS]; static int lastask[MAX_CLIENTS];
static int lastasktick[MAX_CLIENTS];
void CServer::SendMap(int ClientID) void CServer::SendMap(int ClientID)
{ {
lastsent[ClientID] = 0; lastsent[ClientID] = 0;
lastask[ClientID] = 0; lastask[ClientID] = 0;
lastasktick[ClientID] = Tick();
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);
@ -882,6 +884,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
int Last = 0; int Last = 0;
lastask[ClientID] = Chunk; lastask[ClientID] = Chunk;
lastasktick[ClientID] = Tick();
if (Chunk == 0) if (Chunk == 0)
{ {
lastsent[ClientID] = 0; lastsent[ClientID] = 0;
@ -899,7 +902,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
Last = 1; Last = 1;
} }
if (lastsent[ClientID]+ChunkSize < m_CurrentMapSize && lastsent[ClientID] < Chunk+g_Config.m_SvMapWindow && g_Config.m_SvFastDownload) if (lastsent[ClientID] < Chunk+g_Config.m_SvMapWindow && g_Config.m_SvFastDownload)
return; return;
CMsgPacker Msg(NETMSG_MAP_DATA); CMsgPacker Msg(NETMSG_MAP_DATA);
@ -908,7 +911,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
Msg.AddInt(Chunk); Msg.AddInt(Chunk);
Msg.AddInt(ChunkSize); Msg.AddInt(ChunkSize);
Msg.AddRaw(&m_pCurrentMapData[Offset], ChunkSize); Msg.AddRaw(&m_pCurrentMapData[Offset], ChunkSize);
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID, true); SendMsgEx(&Msg, MSGFLAG_FLUSH, ClientID, true);
if(g_Config.m_Debug) if(g_Config.m_Debug)
{ {
@ -1227,6 +1230,11 @@ void CServer::PumpNetwork()
{ {
if (m_aClients[i].m_State != CClient::STATE_CONNECTING) if (m_aClients[i].m_State != CClient::STATE_CONNECTING)
continue; continue;
if (lastasktick[i] < Tick()-TickSpeed())
{
lastsent[i] = lastask[i];
lastasktick[i] = Tick();
}
if (lastask[i]<lastsent[i]-g_Config.m_SvMapWindow) if (lastask[i]<lastsent[i]-g_Config.m_SvMapWindow)
continue; continue;
@ -1252,7 +1260,7 @@ void CServer::PumpNetwork()
Msg.AddInt(Chunk); Msg.AddInt(Chunk);
Msg.AddInt(ChunkSize); Msg.AddInt(ChunkSize);
Msg.AddRaw(&m_pCurrentMapData[Offset], ChunkSize); Msg.AddRaw(&m_pCurrentMapData[Offset], ChunkSize);
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, i, true); SendMsgEx(&Msg, MSGFLAG_FLUSH, i, true);
if(g_Config.m_Debug) if(g_Config.m_Debug)
{ {

View file

@ -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;