diff options
author | Mattes D <github@xoft.cz> | 2016-09-05 15:05:54 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2016-09-05 15:05:54 +0200 |
commit | f7029eddd4120f672c59a4b3a4395832f4de8863 (patch) | |
tree | 81c93ca7c5c03ebdde2401e86dd8c02665710384 /src/ChunkMap.cpp | |
parent | PluginLua: Removed unneeded assignment. (diff) | |
parent | Configurable dirty unused chunk cap to avoid RAM overuse (#3359) (diff) | |
download | cuberite-f7029eddd4120f672c59a4b3a4395832f4de8863.tar cuberite-f7029eddd4120f672c59a4b3a4395832f4de8863.tar.gz cuberite-f7029eddd4120f672c59a4b3a4395832f4de8863.tar.bz2 cuberite-f7029eddd4120f672c59a4b3a4395832f4de8863.tar.lz cuberite-f7029eddd4120f672c59a4b3a4395832f4de8863.tar.xz cuberite-f7029eddd4120f672c59a4b3a4395832f4de8863.tar.zst cuberite-f7029eddd4120f672c59a4b3a4395832f4de8863.zip |
Diffstat (limited to '')
-rw-r--r-- | src/ChunkMap.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 7c4162b25..a16b08f15 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -2704,11 +2704,28 @@ void cChunkMap::SaveAllChunks(void) -int cChunkMap::GetNumChunks(void) +size_t cChunkMap::GetNumChunks(void) { cCSLock Lock(m_CSChunks); - return static_cast<int>(m_Chunks.size()); // TODO: change return value to unsigned type + return m_Chunks.size(); +} + + + + +size_t cChunkMap::GetNumUnusedDirtyChunks(void) +{ + cCSLock Lock(m_CSChunks); + size_t res = 0; + for (const auto & Chunk : m_Chunks) + { + if (Chunk.second->IsValid() && Chunk.second->CanUnloadAfterSaving()) + { + res += 1; + } + } + return res; } |