1
0
Fork 0
cuberite-2a/src/SpawnPrepare.h

53 lines
1.5 KiB
C
Raw Normal View History

#pragma once
class cWorld;
2016-02-05 21:45:45 +00:00
/** Generates and lights the spawn area of the world. Runs as a separate thread. */
2017-08-22 12:34:43 +00:00
class cSpawnPrepare:
public std::enable_shared_from_this<cSpawnPrepare>
{
2017-08-22 12:34:43 +00:00
/** Private tag allows public constructors that can only be used with private access. */
struct sMakeSharedTag {};
public:
2017-08-22 12:34:43 +00:00
cSpawnPrepare(cWorld & a_World, int a_SpawnChunkX, int a_SpawnChunkZ, int a_PrepareDistance, int a_FirstIdx, sMakeSharedTag);
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. */
2015-12-19 21:48:19 +00:00
std::atomic<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;
2015-05-30 10:11:17 +00:00
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);
2015-05-30 10:11:17 +00:00
friend class cSpawnPrepareCallback;
};