summaryrefslogtreecommitdiffstats
path: root/src/ChunkMap.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2016-09-05 15:05:54 +0200
committerMattes D <github@xoft.cz>2016-09-05 15:05:54 +0200
commitf7029eddd4120f672c59a4b3a4395832f4de8863 (patch)
tree81c93ca7c5c03ebdde2401e86dd8c02665710384 /src/ChunkMap.cpp
parentPluginLua: Removed unneeded assignment. (diff)
parentConfigurable dirty unused chunk cap to avoid RAM overuse (#3359) (diff)
downloadcuberite-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 'src/ChunkMap.cpp')
-rw-r--r--src/ChunkMap.cpp21
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;
}