diff options
author | Mattes D <github@xoft.cz> | 2015-06-01 15:02:42 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-06-01 15:02:42 +0200 |
commit | a54fa15bc6326d5482fae27b5fbcd42c8a34427a (patch) | |
tree | 5b2bb45d000c25554b45cdd1aeea59a96734534a /src/SpawnPrepare.cpp | |
parent | Merge pull request #2178 from jammet/patch-7 (diff) | |
parent | Made cLightingThread own its callbacks (diff) | |
download | cuberite-a54fa15bc6326d5482fae27b5fbcd42c8a34427a.tar cuberite-a54fa15bc6326d5482fae27b5fbcd42c8a34427a.tar.gz cuberite-a54fa15bc6326d5482fae27b5fbcd42c8a34427a.tar.bz2 cuberite-a54fa15bc6326d5482fae27b5fbcd42c8a34427a.tar.lz cuberite-a54fa15bc6326d5482fae27b5fbcd42c8a34427a.tar.xz cuberite-a54fa15bc6326d5482fae27b5fbcd42c8a34427a.tar.zst cuberite-a54fa15bc6326d5482fae27b5fbcd42c8a34427a.zip |
Diffstat (limited to 'src/SpawnPrepare.cpp')
-rw-r--r-- | src/SpawnPrepare.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/SpawnPrepare.cpp b/src/SpawnPrepare.cpp index 80d2c52a1..74dcb3ecd 100644 --- a/src/SpawnPrepare.cpp +++ b/src/SpawnPrepare.cpp @@ -8,6 +8,26 @@ +class cSpawnPrepareCallback : + public cChunkCoordCallback +{ +public: + cSpawnPrepareCallback(cSpawnPrepare & a_SpawnPrepare) : + m_SpawnPrepare(a_SpawnPrepare) + { + } +protected: + + cSpawnPrepare & m_SpawnPrepare; + + virtual void Call(int a_ChunkX, int a_ChunkZ) override + { + m_SpawnPrepare.PreparedChunkCallback(a_ChunkX, a_ChunkZ); + } +}; + + + cSpawnPrepare::cSpawnPrepare(cWorld & a_World, int a_SpawnChunkX, int a_SpawnChunkZ, int a_PrepareDistance, int a_FirstIdx): @@ -40,7 +60,7 @@ void cSpawnPrepare::PrepareChunks(cWorld & a_World, int a_SpawnChunkX, int a_Spa { int chunkX, chunkZ; prep.DecodeChunkCoords(i, chunkX, chunkZ); - a_World.PrepareChunk(chunkX, chunkZ, &prep); + a_World.PrepareChunk(chunkX, chunkZ, cpp14::make_unique<cSpawnPrepareCallback>(prep)); } // for i // Wait for the lighting thread to prepare everything. Event is set in the Call() callback: @@ -69,7 +89,7 @@ void cSpawnPrepare::DecodeChunkCoords(int a_Idx, int & a_ChunkX, int & a_ChunkZ) -void cSpawnPrepare::Call(int a_ChunkX, int a_ChunkZ) +void cSpawnPrepare::PreparedChunkCallback(int a_ChunkX, int a_ChunkZ) { // Check if this was the last chunk: m_NumPrepared += 1; @@ -85,7 +105,7 @@ void cSpawnPrepare::Call(int a_ChunkX, int a_ChunkZ) { int chunkX, chunkZ; DecodeChunkCoords(m_NextIdx, chunkX, chunkZ); - m_World.GetLightingThread().QueueChunk(chunkX, chunkZ, this); + m_World.GetLightingThread().QueueChunk(chunkX, chunkZ, cpp14::make_unique<cSpawnPrepareCallback>(*this)); m_NextIdx += 1; } |