summaryrefslogtreecommitdiffstats
path: root/source/ChunkSender.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-05-25 09:18:52 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-05-25 09:18:52 +0200
commita4a418a679f1ac760a8763edd856f0178cfc6dde (patch)
tree85300ca3a2b3a942998a0c864ae90894857ebf5f /source/ChunkSender.cpp
parentFixed output directory structure in the "Release profiled" configuration (diff)
downloadcuberite-a4a418a679f1ac760a8763edd856f0178cfc6dde.tar
cuberite-a4a418a679f1ac760a8763edd856f0178cfc6dde.tar.gz
cuberite-a4a418a679f1ac760a8763edd856f0178cfc6dde.tar.bz2
cuberite-a4a418a679f1ac760a8763edd856f0178cfc6dde.tar.lz
cuberite-a4a418a679f1ac760a8763edd856f0178cfc6dde.tar.xz
cuberite-a4a418a679f1ac760a8763edd856f0178cfc6dde.tar.zst
cuberite-a4a418a679f1ac760a8763edd856f0178cfc6dde.zip
Diffstat (limited to '')
-rw-r--r--source/ChunkSender.cpp57
1 files changed, 54 insertions, 3 deletions
diff --git a/source/ChunkSender.cpp b/source/ChunkSender.cpp
index 232ce423c..8c65eece6 100644
--- a/source/ChunkSender.cpp
+++ b/source/ChunkSender.cpp
@@ -18,11 +18,27 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cNotifyChunkSender:
+
+void cNotifyChunkSender::Call(int a_ChunkX, int a_ChunkZ)
+{
+ m_ChunkSender->ChunkReady(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cChunkSender:
+
cChunkSender::cChunkSender(void) :
super("ChunkSender"),
- m_World(NULL)
+ m_World(NULL),
+ m_Notify(NULL)
{
- memset(m_BiomeData, biPlains, sizeof(m_BiomeData));
+ m_Notify.SetChunkSender(this);
}
@@ -182,18 +198,32 @@ void cChunkSender::SendChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cClientHa
}
}
+ // If the chunk has no clients, no need to packetize it:
if (!m_World->HasChunkAnyClients(a_ChunkX, a_ChunkY, a_ChunkZ))
{
return;
}
+ // If the chunk is not valid, do nothing - whoever needs it has queued it for loading / generating
+ if (!m_World->IsChunkValid(a_ChunkX, a_ChunkY, a_ChunkZ))
+ {
+ return;
+ }
+
+ // If the chunk is not lighted, queue it for relighting and get notified when it's ready:
+ if (!m_World->IsChunkLighted(a_ChunkX, a_ChunkZ))
+ {
+ m_World->QueueLightChunk(a_ChunkX, a_ChunkZ, &m_Notify);
+ return;
+ }
+
// Prepare MapChunk packets:
if( !m_World->GetChunkData(a_ChunkX, a_ChunkY, a_ChunkZ, *this) )
{
return;
}
cPacket_PreChunk PreChunk(a_ChunkX, a_ChunkZ, true);
- cPacket_MapChunk MapChunk(a_ChunkX, a_ChunkY, a_ChunkZ, m_BlockData, m_BiomeData);
+ cPacket_MapChunk MapChunk(a_ChunkX, a_ChunkY, a_ChunkZ, m_BlockData, m_BiomeMap);
// Send:
if (a_Client == NULL)
@@ -247,3 +277,24 @@ void cChunkSender::Entity(cEntity * a_Entity)
+
+void cChunkSender::BiomeData(const cChunkDef::BiomeMap * a_BiomeMap)
+{
+ for (int i = 0; i < ARRAYCOUNT(m_BiomeMap); i++)
+ {
+ if ((*a_BiomeMap)[i] < 255)
+ {
+ // Normal MC biome, copy as-is:
+ m_BiomeMap[i] = (unsigned char)((*a_BiomeMap)[i]);
+ }
+ else
+ {
+ // TODO: MCS-specific biome, need to map to some basic MC biome:
+ ASSERT(!"Unimplemented MCS-specific biome");
+ }
+ } // for i - m_BiomeMap[]
+}
+
+
+
+