1
0

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
This commit is contained in:
madmaxoft@gmail.com
2012-02-21 15:18:02 +00:00
parent da4afc0cf3
commit f0145ee9fa
8 changed files with 146 additions and 38 deletions

View File

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