From 5179588b6539cf13cb68ef19d5d49d520ed39490 Mon Sep 17 00:00:00 2001 From: faketruth Date: Fri, 2 Mar 2012 13:58:31 +0000 Subject: Chunk light and metadata are also sent now, should take a load off of the client git-svn-id: http://mc-server.googlecode.com/svn/trunk@353 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/packets/cPacket_MapChunk.cpp | 43 ++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/packets/cPacket_MapChunk.cpp b/source/packets/cPacket_MapChunk.cpp index e9ebf8355..24d7b8d88 100644 --- a/source/packets/cPacket_MapChunk.cpp +++ b/source/packets/cPacket_MapChunk.cpp @@ -41,18 +41,51 @@ cPacket_MapChunk::cPacket_MapChunk(cChunk * a_Chunk) memset( AllData, 0, DataSize ); unsigned int iterator = 0; - for( int i = 0; i < 8; ++i ) // Old world is only 8 high + for( int i = 0; i < 8; ++i ) // Old world is only 8*16 high (should be 16*16) { - m_BitMap1 |= (1 << i); + m_BitMap1 |= (1 << i); // This tells what chunks are sent. Use this to NOT send air only chunks (right now everything is sent) for( int y = 0; y < 16; ++y ) for( int z = 0; z < 16; ++z ) for( int x = 0; x < 16; ++x ) { AllData[iterator] = a_Chunk->GetBlock( x, y+i*16, z ); ++iterator; } } - //TODO: Send block metadata - //TODO: Send block light - //TODO: Send sky light + //Send block metadata + for( int i = 0; i < 8; ++i ) + { + for( int y = 0; y < 16; ++y ) for( int z = 0; z < 16; ++z ) + { + for( int x = 0; x < 8; ++x ) + { + AllData[iterator] = a_Chunk->GetLight( a_Chunk->pGetMeta(), x*2+0, y+i*16, z ) | a_Chunk->GetLight( a_Chunk->pGetMeta(), x*2+1, y+i*16, z ) << 4; + ++iterator; + } + } + } + //Send block light + for( int i = 0; i < 8; ++i ) + { + for( int y = 0; y < 16; ++y ) for( int z = 0; z < 16; ++z ) + { + for( int x = 0; x < 8; ++x ) + { + AllData[iterator] = a_Chunk->GetLight( a_Chunk->pGetLight(), x*2+0, y+i*16, z ) | a_Chunk->GetLight( a_Chunk->pGetLight(), x*2+1, y+i*16, z ) << 4; + ++iterator; + } + } + } + //Send sky light + for( int i = 0; i < 8; ++i ) + { + for( int y = 0; y < 16; ++y ) for( int z = 0; z < 16; ++z ) + { + for( int x = 0; x < 8; ++x ) + { + AllData[iterator] = a_Chunk->GetLight( a_Chunk->pGetSkyLight(), x*2+0, y+i*16, z ) | a_Chunk->GetLight( a_Chunk->pGetSkyLight(), x*2+1, y+i*16, z ) << 4; + ++iterator; + } + } + } uLongf CompressedSize = compressBound( DataSize ); char * CompressedBlockData = new char[CompressedSize]; -- cgit v1.2.3