diff options
author | HaoTNN <haotnn@gmail.com> | 2015-06-03 01:08:57 +0200 |
---|---|---|
committer | HaoTNN <haotnn@gmail.com> | 2015-06-03 01:08:57 +0200 |
commit | 3142598dee31acc23c738a1a728638665c8940b8 (patch) | |
tree | 2eb837ed785678d536d677ff5020fabca089f2e5 /src/SpawnPrepare.h | |
parent | Merge remote-tracking branch 'upstream/master' (diff) | |
parent | Merge pull request #2182 from birkett/master (diff) | |
download | cuberite-3142598dee31acc23c738a1a728638665c8940b8.tar cuberite-3142598dee31acc23c738a1a728638665c8940b8.tar.gz cuberite-3142598dee31acc23c738a1a728638665c8940b8.tar.bz2 cuberite-3142598dee31acc23c738a1a728638665c8940b8.tar.lz cuberite-3142598dee31acc23c738a1a728638665c8940b8.tar.xz cuberite-3142598dee31acc23c738a1a728638665c8940b8.tar.zst cuberite-3142598dee31acc23c738a1a728638665c8940b8.zip |
Diffstat (limited to '')
-rw-r--r-- | src/SpawnPrepare.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/SpawnPrepare.h b/src/SpawnPrepare.h new file mode 100644 index 000000000..cc0da504e --- /dev/null +++ b/src/SpawnPrepare.h @@ -0,0 +1,49 @@ + +#pragma once + +class cWorld; + + + +/** Generates and lights the spawn area of the world. Runs as a separate thread. */ +class cSpawnPrepare +{ + +public: + static void PrepareChunks(cWorld & a_World, int a_SpawnChunkX, int a_SpawnChunkZ, int a_PrepareDistance); + +protected: + cWorld & m_World; + int m_SpawnChunkX; + int m_SpawnChunkZ; + int m_PrepareDistance; + + /** The index of the next chunk to be queued in the lighting thread. */ + int m_NextIdx; + + /** The maximum index of the prepared chunks. Queueing stops when m_NextIdx reaches this number. */ + int m_MaxIdx; + + /** Total number of chunks already finished preparing. Preparation finishes when this number reaches m_MaxIdx. */ + int m_NumPrepared; + + /** Event used to signal that the preparation is finished. */ + cEvent m_EvtFinished; + + /** The timestamp of the last progress report emitted. */ + std::chrono::steady_clock::time_point m_LastReportTime; + + /** Number of chunks prepared when the last progress report was emitted. */ + int m_LastReportChunkCount; + + cSpawnPrepare(cWorld & a_World, int a_SpawnChunkX, int a_SpawnChunkZ, int a_PrepareDistance, int a_FirstIdx); + + void PreparedChunkCallback(int a_ChunkX, int a_ChunkZ); + + /** Decodes the index into chunk coords. Provides the specific chunk ordering. */ + void DecodeChunkCoords(int a_Idx, int & a_ChunkX, int & a_ChunkZ); + + friend class cSpawnPrepareCallback; + +}; + |