summaryrefslogtreecommitdiffstats
path: root/src/Chunk.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2017-08-18 12:17:56 +0200
committerGitHub <noreply@github.com>2017-08-18 12:17:56 +0200
commit72d7027861a3b7e7e8bb5fdcbbc5a1a778fa7f82 (patch)
treec1c1a040332d4ba1f784be25c67c9800e85015eb /src/Chunk.h
parentSitting cats block enderchests from opening (#3906) (diff)
parentChanged entity ownership model to use smart pointers (diff)
downloadcuberite-72d7027861a3b7e7e8bb5fdcbbc5a1a778fa7f82.tar
cuberite-72d7027861a3b7e7e8bb5fdcbbc5a1a778fa7f82.tar.gz
cuberite-72d7027861a3b7e7e8bb5fdcbbc5a1a778fa7f82.tar.bz2
cuberite-72d7027861a3b7e7e8bb5fdcbbc5a1a778fa7f82.tar.lz
cuberite-72d7027861a3b7e7e8bb5fdcbbc5a1a778fa7f82.tar.xz
cuberite-72d7027861a3b7e7e8bb5fdcbbc5a1a778fa7f82.tar.zst
cuberite-72d7027861a3b7e7e8bb5fdcbbc5a1a778fa7f82.zip
Diffstat (limited to 'src/Chunk.h')
-rw-r--r--src/Chunk.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/Chunk.h b/src/Chunk.h
index 87f2cd568..7e399052d 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -61,6 +61,7 @@ class cChunk :
public cChunkDef // The inheritance is "misused" here only to inherit the functions and constants defined in cChunkDef
{
public:
+
/** Represents the presence state of the chunk */
enum ePresence
{
@@ -75,7 +76,7 @@ public:
cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP, // Neighbor chunks
cAllocationPool<cChunkData::sChunkSection> & a_Pool
);
- cChunk(cChunk & other);
+ cChunk(cChunk & other) = delete;
~cChunk();
/** Returns true iff the chunk block data is valid (loaded / generated) */
@@ -248,8 +249,12 @@ public:
/** Returns true if theres any client in the chunk; false otherwise */
bool HasAnyClients(void) const;
- void AddEntity(cEntity * a_Entity);
- void RemoveEntity(cEntity * a_Entity);
+ void AddEntity(OwnedEntity a_Entity);
+
+ /** Releases ownership of the given entity if it was found in this chunk.
+ Returns an owning reference to the found entity. */
+ OwnedEntity RemoveEntity(cEntity & a_Entity);
+
bool HasEntity(UInt32 a_EntityID);
/** Calls the callback for each entity; returns true if all entities processed, false if the callback aborted by returning true */
@@ -525,7 +530,7 @@ private:
// A critical section is not needed, because all chunk access is protected by its parent ChunkMap's csLayers
std::vector<cClientHandle *> m_LoadedByClient;
- cEntityList m_Entities;
+ std::vector<OwnedEntity> m_Entities;
cBlockEntities m_BlockEntities;
/** Number of times the chunk has been requested to stay (by various cChunkStay objects); if zero, the chunk can be unloaded */
@@ -602,7 +607,7 @@ private:
bool GrowMelonPumpkin(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType);
/** 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);
+ void MoveEntityToNewChunk(OwnedEntity a_Entity);
};
typedef cChunk * cChunkPtr;