diff options
author | Max Luchterhand <52720531+maxluchterhand1@users.noreply.github.com> | 2020-03-18 18:17:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-18 18:17:59 +0100 |
commit | 384ba1881237bbefd03488d7de3e4eaae80d9d27 (patch) | |
tree | b3470142fc1b47645925bcb4ba345e6bd2992291 | |
parent | Blocks only drop pickups when using correct tool (#4505) (diff) | |
download | cuberite-384ba1881237bbefd03488d7de3e4eaae80d9d27.tar cuberite-384ba1881237bbefd03488d7de3e4eaae80d9d27.tar.gz cuberite-384ba1881237bbefd03488d7de3e4eaae80d9d27.tar.bz2 cuberite-384ba1881237bbefd03488d7de3e4eaae80d9d27.tar.lz cuberite-384ba1881237bbefd03488d7de3e4eaae80d9d27.tar.xz cuberite-384ba1881237bbefd03488d7de3e4eaae80d9d27.tar.zst cuberite-384ba1881237bbefd03488d7de3e4eaae80d9d27.zip |
Diffstat (limited to '')
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | src/Chunk.cpp | 16 | ||||
-rw-r--r-- | src/Chunk.h | 3 |
3 files changed, 20 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore index 220134226..32184b02c 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ cloc.xsl /UploadLuaAPI.cmd GPUCache AllFiles.lst +GPUCache # IDE Stuff ## Sublime Text diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 52464f4da..574c00132 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -194,10 +194,25 @@ void cChunk::MarkRegenerating(void) +bool cChunk::HasPlayerEntities() +{ + return std::any_of(m_Entities.begin(), m_Entities.end(), + [](std::unique_ptr<cEntity>& Entity) + { + return Entity->IsPlayer(); + } + ); +} + + + + + bool cChunk::CanUnload(void) { return m_LoadedByClient.empty() && // The chunk is not used by any client + !HasPlayerEntities() && // Ensure not only the absence of ClientHandlers, but also of cPlayer objects !m_IsDirty && // The chunk has been saved properly or hasn't been touched since the load / gen (m_StayCount == 0) && // The chunk is not in a ChunkStay (m_Presence != cpQueued) ; // The chunk is not queued for loading / generating (otherwise multi-load / multi-gen could occur) @@ -211,6 +226,7 @@ bool cChunk::CanUnloadAfterSaving(void) { return m_LoadedByClient.empty() && // The chunk is not used by any client + !HasPlayerEntities() && // Ensure not only the absence of ClientHandlers, but also of cPlayer objects m_IsDirty && // The chunk is dirty (m_StayCount == 0) && // The chunk is not in a ChunkStay (m_Presence != cpQueued) ; // The chunk is not queued for loading / generating (otherwise multi-load / multi-gen could occur) diff --git a/src/Chunk.h b/src/Chunk.h index f6e38dc81..9aa963fae 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -683,6 +683,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(OwnedEntity a_Entity); + + /** Check m_Entities for cPlayer objects. */ + bool HasPlayerEntities(); }; typedef cChunk * cChunkPtr; |