summaryrefslogtreecommitdiffstats
path: root/source/ChunkMap.cpp
diff options
context:
space:
mode:
authormgueydan <gueydan.mathieuÃ@gmail.com>2013-09-07 22:19:56 +0200
committermgueydan <gueydan.mathieuÃ@gmail.com>2013-09-07 22:19:56 +0200
commitd2eb58f27780a3c65fedd0d21d152ee8866ebb86 (patch)
tree05160377f78b97b4916956eebfd07f8a830a8916 /source/ChunkMap.cpp
parentAdding a getType in Monster that return an enum instead of an int or char (diff)
downloadcuberite-d2eb58f27780a3c65fedd0d21d152ee8866ebb86.tar
cuberite-d2eb58f27780a3c65fedd0d21d152ee8866ebb86.tar.gz
cuberite-d2eb58f27780a3c65fedd0d21d152ee8866ebb86.tar.bz2
cuberite-d2eb58f27780a3c65fedd0d21d152ee8866ebb86.tar.lz
cuberite-d2eb58f27780a3c65fedd0d21d152ee8866ebb86.tar.xz
cuberite-d2eb58f27780a3c65fedd0d21d152ee8866ebb86.tar.zst
cuberite-d2eb58f27780a3c65fedd0d21d152ee8866ebb86.zip
Diffstat (limited to '')
-rw-r--r--source/ChunkMap.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/source/ChunkMap.cpp b/source/ChunkMap.cpp
index a15f3aed1..610b293b5 100644
--- a/source/ChunkMap.cpp
+++ b/source/ChunkMap.cpp
@@ -12,6 +12,7 @@
#include "BlockArea.h"
#include "PluginManager.h"
#include "Entities/TNTEntity.h"
+#include "MobCensus.h"
#ifndef _WIN32
#include <cstdlib> // abs
@@ -2152,6 +2153,19 @@ void cChunkMap::SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ)
+void cChunkMap::CollectMobCensus(cMobCensus& a_ToFill)
+{
+ cCSLock Lock(m_CSLayers);
+ for (cChunkLayerList::iterator itr = m_Layers.begin(); itr != m_Layers.end(); ++itr)
+ {
+ (*itr)->CollectMobCensus(a_ToFill);
+ } // for itr - m_Layers
+}
+
+
+
+
+
void cChunkMap::Tick(float a_Dt)
{
@@ -2310,6 +2324,24 @@ cChunk * cChunkMap::cChunkLayer::FindChunk(int a_ChunkX, int a_ChunkZ)
+void cChunkMap::cChunkLayer::CollectMobCensus(cMobCensus& a_ToFill)
+{
+ for (int i = 0; i < ARRAYCOUNT(m_Chunks); i++)
+ {
+ // We do count every Mobs in the world. But we are assuming that every chunk not loaded by any client
+ // doesn't affect us. Normally they should not have mobs because every "too far" mobs despawn
+ // If they have (f.i. when player disconnect) we assume we don't have to make them live or despawn
+ if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid() && m_Chunks[i]->HasAnyClients())
+ {
+ m_Chunks[i]->CollectMobCensus(a_ToFill);
+ }
+ } // for i - m_Chunks[]
+}
+
+
+
+
+
void cChunkMap::cChunkLayer::Tick(float a_Dt)
{