From 868cd94ee9a5a0638c014a4cc42224f01ff234c8 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 5 Mar 2021 13:03:55 +0000 Subject: Prepare ChunkData for BlockState storage (#5105) * Rename ChunkData Creatable test * Add missing Y-check in RedstoneWireHandler * Remove ChunkDef.h dependency in Scoreboard * Prepare ChunkData for BlockState storage + Split chunk block, meta, block & sky light storage + Load the height map from disk - Reduce duplicated code in ChunkData - Remove saving MCSBiomes, there aren't any - Remove the allocation pool, ref #4315, #3864 * fixed build * fixed test * fixed the debug compile Co-authored-by: 12xx12 <44411062+12xx12@users.noreply.github.com> --- src/World.h | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'src/World.h') diff --git a/src/World.h b/src/World.h index 9d68ff47d..ec114cedc 100644 --- a/src/World.h +++ b/src/World.h @@ -49,14 +49,12 @@ class cHopperEntity; class cNoteEntity; class cMobHeadEntity; class cCompositeChat; -class cSetChunkData; class cDeadlockDetect; class cUUID; -typedef std::list< cPlayer * > cPlayerList; +struct SetChunkData; -typedef std::unique_ptr cSetChunkDataPtr; -typedef std::vector cSetChunkDataPtrs; +typedef std::list< cPlayer * > cPlayerList; @@ -240,8 +238,8 @@ public: void MarkChunkSaved (int a_ChunkX, int a_ChunkZ); /** Puts the chunk data into a queue to be set into the chunkmap in the tick thread. - If the chunk data doesn't contain valid biomes, the biomes are calculated before adding the data into the queue. */ - void QueueSetChunkData(cSetChunkDataPtr a_SetChunkData); + Modifies the a_SetChunkData - moves the entities contained in it into the queue. */ + void QueueSetChunkData(SetChunkData && a_SetChunkData); void ChunkLighted( int a_ChunkX, int a_ChunkZ, @@ -253,9 +251,6 @@ public: Returns true if the chunk was reported successfully, false if not (chunk not present or callback failed). */ bool GetChunkData(cChunkCoords a_Coords, cChunkDataCallback & a_Callback) const; - /** Gets the chunk's blocks, only the block types */ - bool GetChunkBlockTypes(int a_ChunkX, int a_ChunkZ, BLOCKTYPE * a_BlockTypes); - /** Returns true iff the chunk is in the loader / generator queue. */ bool IsChunkQueued(int a_ChunkX, int a_ChunkZ) const; @@ -1263,7 +1258,7 @@ private: cCriticalSection m_CSSetChunkDataQueue; /** Queue for the chunk data to be set into m_ChunkMap by the tick thread. Protected by m_CSSetChunkDataQueue */ - cSetChunkDataPtrs m_SetChunkDataQueue; + std::vector m_SetChunkDataQueue; void Tick(std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec); @@ -1273,6 +1268,9 @@ private: /** Handles the mob spawning / moving / destroying each tick */ void TickMobs(std::chrono::milliseconds a_Dt); + /** Sets the chunk data queued in the m_SetChunkDataQueue queue into their chunk. */ + void TickQueuedChunkDataSets(); + /** Adds the entities queued in the m_EntitiesToAdd queue into their chunk. If the entity was a player, he is also added to the m_Players list. */ void TickQueuedEntityAdditions(void); @@ -1307,10 +1305,6 @@ private: /** Sets mob spawning values if nonexistant to their dimension specific defaults */ void InitializeAndLoadMobSpawningValues(cIniFile & a_IniFile); - /** Sets the specified chunk data into the chunkmap. Called in the tick thread. - Modifies the a_SetChunkData - moves the entities contained in it into the chunk. */ - void SetChunkData(cSetChunkData & a_SetChunkData); - /** Checks if the sapling at the specified block coord is a part of a large-tree sapling (2x2). If so, adjusts the coords so that they point to the northwest (XM ZM) corner of the sapling area and returns true. Returns false if not a part of large-tree sapling. */ -- cgit v1.2.3