diff options
author | worktycho <work.tycho@gmail.com> | 2015-05-30 11:59:52 +0200 |
---|---|---|
committer | worktycho <work.tycho@gmail.com> | 2015-05-30 11:59:52 +0200 |
commit | b371208526d9ff3b6a5638f8db3d3746be09fa82 (patch) | |
tree | 2bc8a829eb2d2a20d9e3d846d26315f3765b3860 /src/SpawnPrepare.h | |
parent | Merge pull request #2169 from linnemannr/master (diff) | |
parent | Clean up Spawn Prepare (diff) | |
download | cuberite-b371208526d9ff3b6a5638f8db3d3746be09fa82.tar cuberite-b371208526d9ff3b6a5638f8db3d3746be09fa82.tar.gz cuberite-b371208526d9ff3b6a5638f8db3d3746be09fa82.tar.bz2 cuberite-b371208526d9ff3b6a5638f8db3d3746be09fa82.tar.lz cuberite-b371208526d9ff3b6a5638f8db3d3746be09fa82.tar.xz cuberite-b371208526d9ff3b6a5638f8db3d3746be09fa82.tar.zst cuberite-b371208526d9ff3b6a5638f8db3d3746be09fa82.zip |
Diffstat (limited to 'src/SpawnPrepare.h')
-rw-r--r-- | src/SpawnPrepare.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/SpawnPrepare.h b/src/SpawnPrepare.h new file mode 100644 index 000000000..bd5c0e0c6 --- /dev/null +++ b/src/SpawnPrepare.h @@ -0,0 +1,47 @@ + +#pragma once + +class cWorld; + + + +/** Generates and lights the spawn area of the world. Runs as a separate thread. */ +class cSpawnPrepare: + public cChunkCoordCallback +{ + +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); + + virtual void Call(int a_ChunkX, int a_ChunkZ) override; + + /** Decodes the index into chunk coords. Provides the specific chunk ordering. */ + void DecodeChunkCoords(int a_Idx, int & a_ChunkX, int & a_ChunkZ); +}; + |