Cuberite
A lightweight, fast and extensible game server for Minecraft
SpawnPrepare.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 class cWorld;
5 
6 
7 
10  public std::enable_shared_from_this<cSpawnPrepare>
11 {
13  struct sMakeSharedTag {};
14 public:
15 
16  cSpawnPrepare(cWorld & a_World, int a_SpawnChunkX, int a_SpawnChunkZ, int a_PrepareDistance, int a_FirstIdx, sMakeSharedTag);
17 
18  static void PrepareChunks(cWorld & a_World, int a_SpawnChunkX, int a_SpawnChunkZ, int a_PrepareDistance);
19 
20 protected:
25 
27  int m_NextIdx;
28 
30  int m_MaxIdx;
31 
33  std::atomic<int> m_NumPrepared;
34 
37 
39  std::chrono::steady_clock::time_point m_LastReportTime;
40 
43 
44  void PreparedChunkCallback(int a_ChunkX, int a_ChunkZ);
45 
47  void DecodeChunkCoords(int a_Idx, int & a_ChunkX, int & a_ChunkZ);
48 
49  friend class cSpawnPrepareCallback;
50 
51 };
52 
Definition: Event.h:18
Generates and lights the spawn area of the world.
Definition: SpawnPrepare.h:11
static void PrepareChunks(cWorld &a_World, int a_SpawnChunkX, int a_SpawnChunkZ, int a_PrepareDistance)
std::chrono::steady_clock::time_point m_LastReportTime
The timestamp of the last progress report emitted.
Definition: SpawnPrepare.h:39
int m_LastReportChunkCount
Number of chunks prepared when the last progress report was emitted.
Definition: SpawnPrepare.h:42
void PreparedChunkCallback(int a_ChunkX, int a_ChunkZ)
int m_MaxIdx
The maximum index of the prepared chunks.
Definition: SpawnPrepare.h:30
std::atomic< int > m_NumPrepared
Total number of chunks already finished preparing.
Definition: SpawnPrepare.h:33
void DecodeChunkCoords(int a_Idx, int &a_ChunkX, int &a_ChunkZ)
Decodes the index into chunk coords.
cEvent m_EvtFinished
Event used to signal that the preparation is finished.
Definition: SpawnPrepare.h:36
cWorld & m_World
Definition: SpawnPrepare.h:21
int m_NextIdx
The index of the next chunk to be queued in the lighting thread.
Definition: SpawnPrepare.h:27
int m_PrepareDistance
Definition: SpawnPrepare.h:24
cSpawnPrepare(cWorld &a_World, int a_SpawnChunkX, int a_SpawnChunkZ, int a_PrepareDistance, int a_FirstIdx, sMakeSharedTag)
Private tag allows public constructors that can only be used with private access.
Definition: SpawnPrepare.h:13
Definition: World.h:53