From f0145ee9fa09ce2c27b8149fee37c6f5fce7e1da Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Tue, 21 Feb 2012 15:18:02 +0000 Subject: Fixed heightmap optimization from rev 302; removed a few more cChunkPtrs git-svn-id: http://mc-server.googlecode.com/svn/trunk@303 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cClientHandle.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'source/cClientHandle.cpp') diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index 51cd31433..6db6a2501 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -408,10 +408,8 @@ void cClientHandle::StreamChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) cWorld * World = m_Player->GetWorld(); ASSERT(World != NULL); - cChunkPtr Chunk = World->GetChunk(a_ChunkX, 0, a_ChunkZ); - if (!Chunk->HasClient(this)) + if (World->AddChunkClient(a_ChunkX, a_ChunkY, a_ChunkZ, this)) { - Chunk->AddClient(this); cCSLock Lock(m_CSChunkLists); m_LoadedChunks.push_back(cChunkCoords(a_ChunkX, a_ChunkY, a_ChunkZ)); m_ChunksToSend.push_back(cChunkCoords(a_ChunkX, a_ChunkY, a_ChunkZ)); @@ -429,10 +427,7 @@ void cClientHandle::RemoveFromAllChunks() cWorld * World = m_Player->GetWorld(); if (World != NULL) { - for (cChunkCoordsList::iterator itr = m_LoadedChunks.begin(); itr != m_LoadedChunks.end(); ++itr) - { - World->GetChunk(itr->m_ChunkX, itr->m_ChunkY, itr->m_ChunkZ)->RemoveClient(this); - } + World->RemoveClientFromChunks(this, m_LoadedChunks); } m_LoadedChunks.clear(); m_ChunksToSend.clear(); @@ -1657,14 +1652,11 @@ void cClientHandle::Tick(float a_Dt) int NumSent = 0; for (cChunkCoordsList::iterator itr = m_ChunksToSend.begin(); itr != m_ChunksToSend.end();) { - cChunkPtr Chunk = World->GetChunk(itr->m_ChunkX, itr->m_ChunkY, itr->m_ChunkZ); - if (!Chunk->IsValid()) + if (!World->SendChunkTo(itr->m_ChunkX, itr->m_ChunkY, itr->m_ChunkZ, this)) { ++itr; continue; } - // The chunk has become valid, send it and remove it from the list: - Chunk->Send(this); itr = m_ChunksToSend.erase(itr); NumSent++; if (NumSent > 10) -- cgit v1.2.3