Skip to content

Commit

Permalink
Fixed client kick/crash if many block changes happend
Browse files Browse the repository at this point in the history
  • Loading branch information
Howaner committed Mar 9, 2015
1 parent 5b74987 commit ce62195
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Chunk.cpp
Expand Up @@ -776,10 +776,22 @@ void cChunk::BroadcastPendingBlockChanges(void)
{
return;
}

for (cClientHandleList::iterator itr = m_LoadedByClient.begin(), end = m_LoadedByClient.end(); itr != end; ++itr)

if (m_PendingSendBlocks.size() >= 10240)
{
// Resend the full chunk
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(), end = m_LoadedByClient.end(); itr != end; ++itr)
{
m_World->ForceSendChunkTo(m_PosX, m_PosZ, cChunkSender::E_CHUNK_PRIORITY_MEDIUM, (*itr));
}
}
else
{
(*itr)->SendBlockChanges(m_PosX, m_PosZ, m_PendingSendBlocks);
// Only send block changes
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(), end = m_LoadedByClient.end(); itr != end; ++itr)
{
(*itr)->SendBlockChanges(m_PosX, m_PosZ, m_PendingSendBlocks);
}
}
m_PendingSendBlocks.clear();
}
Expand Down

0 comments on commit ce62195

Please sign in to comment.