diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-18 18:53:22 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-18 18:53:22 +0100 |
commit | 499745c1c7a865941b3c102532777c19dfb92ca4 (patch) | |
tree | deccb8ffdafe6dbb85e8e630eaca0a6e5a66c5ed /source/cChunkMap.cpp | |
parent | Logging: added thread ID to the log output in debug builds (diff) | |
download | cuberite-499745c1c7a865941b3c102532777c19dfb92ca4.tar cuberite-499745c1c7a865941b3c102532777c19dfb92ca4.tar.gz cuberite-499745c1c7a865941b3c102532777c19dfb92ca4.tar.bz2 cuberite-499745c1c7a865941b3c102532777c19dfb92ca4.tar.lz cuberite-499745c1c7a865941b3c102532777c19dfb92ca4.tar.xz cuberite-499745c1c7a865941b3c102532777c19dfb92ca4.tar.zst cuberite-499745c1c7a865941b3c102532777c19dfb92ca4.zip |
Diffstat (limited to 'source/cChunkMap.cpp')
-rw-r--r-- | source/cChunkMap.cpp | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp index 7adaebf90..96d3b14e0 100644 --- a/source/cChunkMap.cpp +++ b/source/cChunkMap.cpp @@ -235,7 +235,7 @@ void cChunkMap::ChunkDataLoaded(int a_ChunkX, int a_ChunkY, int a_ChunkZ, const -void cChunkMap::SetChunkData(int a_ChunkX, int a_ChunkY, int a_ChunkZ, const char * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities)
+void cChunkMap::ChunkDataGenerated(int a_ChunkX, int a_ChunkY, int a_ChunkZ, const char * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities)
{
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, a_ChunkY, a_ChunkZ);
@@ -244,6 +244,12 @@ void cChunkMap::SetChunkData(int a_ChunkX, int a_ChunkY, int a_ChunkZ, const cha return;
}
Chunk->SetAllData(a_BlockData, a_Entities, a_BlockEntities);
+
+ // TODO: This has to go - lighting takes way too long to execute in a locked ChunkMap!
+ Chunk->CalculateLighting();
+
+ Chunk->SetValid();
+ Chunk->MarkDirty();
}
@@ -287,6 +293,48 @@ bool cChunkMap::HasChunkAnyClients(int a_ChunkX, int a_ChunkY, int a_ChunkZ) +void cChunkMap::SpreadChunkLighting(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
+{
+ cCSLock Lock(m_CSLayers);
+ cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, a_ChunkY, a_ChunkZ);
+ if ((Chunk != NULL) && Chunk->IsValid())
+ {
+ // TODO: Rewrite this to call Chunk's lighting without any parameters
+ Chunk->SpreadLight( Chunk->pGetSkyLight() );
+ Chunk->SpreadLight( Chunk->pGetLight() );
+ }
+}
+
+
+
+
+
+int cChunkMap::GetHeight(int a_BlockX, int a_BlockZ)
+{
+ cCSLock Lock(m_CSLayers);
+ int ChunkX, ChunkZ, BlockY = 0;
+ AbsoluteToRelative(a_BlockX, BlockY, a_BlockZ, ChunkX, ChunkZ);
+ cChunkPtr Chunk = GetChunk(ChunkX, ZERO_CHUNK_Y, ChunkZ);
+ if (Chunk == NULL)
+ {
+ return 0;
+ }
+
+ // Wait for the chunk to become valid:
+ while (!Chunk->IsValid())
+ {
+ GetChunk(ChunkX, ZERO_CHUNK_Y, ChunkZ); // Re-queue (in case it managed to get unloaded before we caught it
+ cCSUnlock Unlock(Lock);
+ m_evtChunkValid.Wait();
+ }
+
+ return Chunk->GetHeight(a_BlockX, a_BlockZ);
+}
+
+
+
+
+
void cChunkMap::Tick( float a_Dt, MTRand & a_TickRandom )
{
cCSLock Lock(m_CSLayers);
@@ -445,3 +493,12 @@ int cChunkMap::GetNumChunks(void) +
+void cChunkMap::ChunkValidated(void)
+{
+ m_evtChunkValid.Set();
+}
+
+
+
+
|