Streamline ClientHandle chunk send a little
- Removed RemoveFromAllChunks. On destruction cWorld::RemovePlayer calls RemoveClientFromChunks already, and there's no need to manually clear the chunk lists.
This commit is contained in:
@@ -127,7 +127,6 @@ cClientHandle::~cClientHandle()
|
||||
cWorld * World = m_Player->GetWorld();
|
||||
if (World != nullptr)
|
||||
{
|
||||
RemoveFromAllChunks();
|
||||
m_Player->GetWorld()->RemoveClientFromChunkSender(this);
|
||||
}
|
||||
// Send the Offline PlayerList packet:
|
||||
@@ -634,32 +633,6 @@ void cClientHandle::StreamChunk(int a_ChunkX, int a_ChunkZ, cChunkSender::Priori
|
||||
|
||||
|
||||
|
||||
void cClientHandle::RemoveFromAllChunks()
|
||||
{
|
||||
cWorld * World = m_Player->GetWorld();
|
||||
if (World != nullptr)
|
||||
{
|
||||
World->RemoveClientFromChunks(this);
|
||||
}
|
||||
|
||||
{
|
||||
// Reset all chunk lists:
|
||||
cCSLock Lock(m_CSChunkLists);
|
||||
m_LoadedChunks.clear();
|
||||
m_ChunksToSend.clear();
|
||||
m_SentChunks.clear();
|
||||
|
||||
// Also reset the LastStreamedChunk coords to bogus coords,
|
||||
// so that all chunks are streamed in subsequent StreamChunks() call (FS #407)
|
||||
m_LastStreamedChunkX = 0x7fffffff;
|
||||
m_LastStreamedChunkZ = 0x7fffffff;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cClientHandle::HandleNPCTrade(int a_SlotNum)
|
||||
{
|
||||
// TODO
|
||||
@@ -2047,16 +2020,14 @@ void cClientHandle::SendData(const char * a_Data, size_t a_Size)
|
||||
void cClientHandle::RemoveFromWorld(void)
|
||||
{
|
||||
// Remove all associated chunks:
|
||||
decltype(m_LoadedChunks) Chunks;
|
||||
{
|
||||
cCSLock Lock(m_CSChunkLists);
|
||||
std::swap(Chunks, m_LoadedChunks);
|
||||
m_LoadedChunks.clear();
|
||||
m_ChunksToSend.clear();
|
||||
m_SentChunks.clear();
|
||||
}
|
||||
for (auto && Chunk : Chunks)
|
||||
{
|
||||
SendUnloadChunk(Chunk.m_ChunkX, Chunk.m_ChunkZ);
|
||||
} // for itr - Chunks[]
|
||||
|
||||
// No need to send Unload Chunk packets, the client unloads automatically.
|
||||
|
||||
// Here, we set last streamed values to bogus ones so everything is resent
|
||||
m_LastStreamedChunkX = 0x7fffffff;
|
||||
|
||||
Reference in New Issue
Block a user