summaryrefslogtreecommitdiffstats
path: root/source/Chunk.h
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-08-18 22:44:22 +0200
committermadmaxoft <github@xoft.cz>2013-08-18 22:44:22 +0200
commit7b10068370e42def4e28785d2e49acba52bad1fd (patch)
tree7cd6f4a961981f934127f097798317611946285a /source/Chunk.h
parentRemoved SetServerBlock griefing. (diff)
downloadcuberite-7b10068370e42def4e28785d2e49acba52bad1fd.tar
cuberite-7b10068370e42def4e28785d2e49acba52bad1fd.tar.gz
cuberite-7b10068370e42def4e28785d2e49acba52bad1fd.tar.bz2
cuberite-7b10068370e42def4e28785d2e49acba52bad1fd.tar.lz
cuberite-7b10068370e42def4e28785d2e49acba52bad1fd.tar.xz
cuberite-7b10068370e42def4e28785d2e49acba52bad1fd.tar.zst
cuberite-7b10068370e42def4e28785d2e49acba52bad1fd.zip
Diffstat (limited to 'source/Chunk.h')
-rw-r--r--source/Chunk.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/source/Chunk.h b/source/Chunk.h
index c4eeab6ae..cba39f7ee 100644
--- a/source/Chunk.h
+++ b/source/Chunk.h
@@ -136,6 +136,9 @@ public:
// SetBlock() does a lot of work (heightmap, tickblocks, blockentities) so a BlockIdx version doesn't make sense
void SetBlock( const Vector3i & a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) { SetBlock( a_RelBlockPos.x, a_RelBlockPos.y, a_RelBlockPos.z, a_BlockType, a_BlockMeta ); }
+ /// Queues a block change till the specified world tick
+ void QueueSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick);
+
/// Queues block for ticking (m_ToTickQueue)
void QueueTickBlock(int a_RelX, int a_RelY, int a_RelZ);
@@ -319,6 +322,22 @@ private:
friend class cChunkMap;
+ struct sSetBlockQueueItem
+ {
+ int m_RelX, m_RelY, m_RelZ;
+ BLOCKTYPE m_BlockType;
+ NIBBLETYPE m_BlockMeta;
+ Int64 m_Tick;
+
+ sSetBlockQueueItem(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Int64 a_Tick) :
+ m_RelX(a_RelX), m_RelY(a_RelY), m_RelZ(a_RelZ)
+ {
+ }
+ } ;
+
+ typedef std::vector<sSetBlockQueueItem> sSetBlockQueueVector;
+
+
bool m_IsValid; // True if the chunk is loaded / generated
bool m_IsLightValid; // True if the blocklight and skylight are calculated
bool m_IsDirty; // True if the chunk has changed since it was last saved
@@ -329,6 +348,8 @@ private:
std::vector<unsigned int> m_ToTickBlocks;
sSetBlockVector m_PendingSendBlocks; ///< Blocks that have changed and need to be sent to all clients
+ sSetBlockQueueVector m_SetBlockQueue; ///< Block changes that are queued to a specific tick
+
// A critical section is not needed, because all chunk access is protected by its parent ChunkMap's csLayers
cClientHandleList m_LoadedByClient;
cClientHandleList m_UnloadQuery;
@@ -405,6 +426,9 @@ private:
/// Called by Tick() when an entity moves out of this chunk into a neighbor; moves the entity and sends spawn / despawn packet to clients
void MoveEntityToNewChunk(cEntity * a_Entity);
+
+ /// Processes all blocks that have been scheduled for replacement by the QueueSetBlock() function
+ void ProcessQueuedSetBlocks(void);
};
typedef cChunk * cChunkPtr;