summaryrefslogtreecommitdiffstats
path: root/src/SpawnPrepare.cpp
diff options
context:
space:
mode:
authortycho <work.tycho@gmail.com>2015-05-30 12:11:17 +0200
committertycho <work.tycho@gmail.com>2015-05-30 12:11:17 +0200
commit06a74e45e247a2d23c6b5a238a3c1b9b17b6c341 (patch)
tree965c54b25acc4a3b7dee194f9194f885299e5656 /src/SpawnPrepare.cpp
parentClean up Spawn Prepare (diff)
downloadcuberite-06a74e45e247a2d23c6b5a238a3c1b9b17b6c341.tar
cuberite-06a74e45e247a2d23c6b5a238a3c1b9b17b6c341.tar.gz
cuberite-06a74e45e247a2d23c6b5a238a3c1b9b17b6c341.tar.bz2
cuberite-06a74e45e247a2d23c6b5a238a3c1b9b17b6c341.tar.lz
cuberite-06a74e45e247a2d23c6b5a238a3c1b9b17b6c341.tar.xz
cuberite-06a74e45e247a2d23c6b5a238a3c1b9b17b6c341.tar.zst
cuberite-06a74e45e247a2d23c6b5a238a3c1b9b17b6c341.zip
Diffstat (limited to 'src/SpawnPrepare.cpp')
-rw-r--r--src/SpawnPrepare.cpp26
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;
}