summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Chunk.cpp2
-rw-r--r--src/ChunkSender.cpp44
-rw-r--r--src/ChunkSender.h4
-rw-r--r--src/ClientHandle.cpp2
4 files changed, 45 insertions, 7 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 35a16edec..a0224322a 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -1742,7 +1742,7 @@ void cChunk::SetAreaBiome(int a_MinRelX, int a_MaxRelX, int a_MinRelZ, int a_Max
// Re-send the chunk to all clients:
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
- m_World->ForceSendChunkTo(m_PosX, m_PosZ, cChunkSender::E_CHUNK_PRIORITY_HIGH, (*itr));
+ m_World->ForceSendChunkTo(m_PosX, m_PosZ, cChunkSender::E_CHUNK_PRIORITY_MEDIUM, (*itr));
} // for itr - m_LoadedByClient[]
}
diff --git a/src/ChunkSender.cpp b/src/ChunkSender.cpp
index 7e2301eab..ef2be167b 100644
--- a/src/ChunkSender.cpp
+++ b/src/ChunkSender.cpp
@@ -100,6 +100,7 @@ void cChunkSender::QueueSendChunkTo(int a_ChunkX, int a_ChunkZ, eChunkPriority a
cCSLock Lock(m_CS);
if (
std::find(m_SendChunksLowPriority.begin(), m_SendChunksLowPriority.end(), Chunk) != m_SendChunksLowPriority.end() ||
+ std::find(m_SendChunksMediumPriority.begin(), m_SendChunksMediumPriority.end(), Chunk) != m_SendChunksMediumPriority.end() ||
std::find(m_SendChunksHighPriority.begin(), m_SendChunksHighPriority.end(), Chunk) != m_SendChunksHighPriority.end()
)
{
@@ -107,10 +108,27 @@ void cChunkSender::QueueSendChunkTo(int a_ChunkX, int a_ChunkZ, eChunkPriority a
return;
}
- if (a_Priority == E_CHUNK_PRIORITY_LOW) {
- m_SendChunksLowPriority.push_back(Chunk);
- } else if (a_Priority == E_CHUNK_PRIORITY_HIGH) {
- m_SendChunksHighPriority.push_back(Chunk);
+ switch (a_Priority)
+ {
+ case E_CHUNK_PRIORITY_LOW:
+ {
+ m_SendChunksLowPriority.push_back(Chunk);
+ break;
+ }
+ case E_CHUNK_PRIORITY_MEDIUM:
+ {
+ m_SendChunksMediumPriority.push_back(Chunk);
+ break;
+ }
+ case E_CHUNK_PRIORITY_HIGH:
+ {
+ m_SendChunksHighPriority.push_back(Chunk);
+ break;
+ }
+ default:
+ {
+ ASSERT(!"Unknown chunk priority!");
+ }
}
}
m_evtQueue.Set();
@@ -133,6 +151,15 @@ void cChunkSender::RemoveClient(cClientHandle * a_Client)
}
++itr;
} // for itr - m_SendChunksLowPriority[]
+ for (sSendChunkList::iterator itr = m_SendChunksMediumPriority.begin(); itr != m_SendChunksMediumPriority.end();)
+ {
+ if (itr->m_Client == a_Client)
+ {
+ itr = m_SendChunksMediumPriority.erase(itr);
+ continue;
+ }
+ ++itr;
+ } // for itr - m_SendChunksMediumPriority[]
for (sSendChunkList::iterator itr = m_SendChunksHighPriority.begin(); itr != m_SendChunksHighPriority.end();)
{
if (itr->m_Client == a_Client)
@@ -191,6 +218,15 @@ void cChunkSender::Execute(void)
SendChunk(Coords.m_ChunkX, Coords.m_ChunkZ, nullptr);
}
+ else if (!m_SendChunksMediumPriority.empty())
+ {
+ // Take one from the queue:
+ sSendChunk Chunk(m_SendChunksMediumPriority.front());
+ m_SendChunksMediumPriority.pop_front();
+ Lock.Unlock();
+
+ SendChunk(Chunk.m_ChunkX, Chunk.m_ChunkZ, Chunk.m_Client);
+ }
else
{
// Take one from the queue:
diff --git a/src/ChunkSender.h b/src/ChunkSender.h
index 585d50914..7cd7ddd86 100644
--- a/src/ChunkSender.h
+++ b/src/ChunkSender.h
@@ -79,7 +79,8 @@ public:
enum eChunkPriority
{
E_CHUNK_PRIORITY_HIGH = 0,
- E_CHUNK_PRIORITY_LOW = 1,
+ E_CHUNK_PRIORITY_MEDIUM = 1,
+ E_CHUNK_PRIORITY_LOW = 2,
};
bool Start(cWorld * a_World);
@@ -143,6 +144,7 @@ protected:
cCriticalSection m_CS;
cChunkCoordsList m_ChunksReady;
sSendChunkList m_SendChunksLowPriority;
+ sSendChunkList m_SendChunksMediumPriority;
sSendChunkList m_SendChunksHighPriority;
cEvent m_evtQueue; // Set when anything is added to m_ChunksReady
cEvent m_evtRemoved; // Set when removed clients are safe to be deleted
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index dc360861e..faee05450 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -463,7 +463,7 @@ bool cClientHandle::StreamNextChunk(void)
// Unloaded chunk found -> Send it to the client.
Lock.Unlock();
- StreamChunk(ChunkX, ChunkZ, cChunkSender::E_CHUNK_PRIORITY_HIGH);
+ StreamChunk(ChunkX, ChunkZ, ((Range <= 2) ? cChunkSender::E_CHUNK_PRIORITY_HIGH : cChunkSender::E_CHUNK_PRIORITY_MEDIUM));
return false;
}
}