summaryrefslogtreecommitdiffstats
path: root/source/ChunkMap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/ChunkMap.cpp')
-rw-r--r--source/ChunkMap.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/source/ChunkMap.cpp b/source/ChunkMap.cpp
index 610b293b5..f5cbacdc7 100644
--- a/source/ChunkMap.cpp
+++ b/source/ChunkMap.cpp
@@ -13,6 +13,7 @@
#include "PluginManager.h"
#include "Entities/TNTEntity.h"
#include "MobCensus.h"
+#include "MobSpawner.h"
#ifndef _WIN32
#include <cstdlib> // abs
@@ -2167,6 +2168,19 @@ void cChunkMap::CollectMobCensus(cMobCensus& a_ToFill)
+void cChunkMap::SpawnMobs(cMobSpawner& a_MobSpawner)
+{
+ cCSLock Lock(m_CSLayers);
+ for (cChunkLayerList::iterator itr = m_Layers.begin(); itr != m_Layers.end(); ++itr)
+ {
+ (*itr)->SpawnMobs(a_MobSpawner);
+ } // for itr - m_Layers
+}
+
+
+
+
+
void cChunkMap::Tick(float a_Dt)
{
cCSLock Lock(m_CSLayers);
@@ -2343,6 +2357,20 @@ void cChunkMap::cChunkLayer::CollectMobCensus(cMobCensus& a_ToFill)
+void cChunkMap::cChunkLayer::SpawnMobs(cMobSpawner& a_MobSpawner)
+{
+ for (int i = 0; i < ARRAYCOUNT(m_Chunks); i++)
+ {
+ // We only spawn close to players
+ if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid() && m_Chunks[i]->HasAnyClients())
+ {
+ m_Chunks[i]->SpawnMobs(a_MobSpawner);
+ }
+ } // for i - m_Chunks[]
+}
+
+
+
void cChunkMap::cChunkLayer::Tick(float a_Dt)
{
for (int i = 0; i < ARRAYCOUNT(m_Chunks); i++)