summaryrefslogtreecommitdiffstats
path: root/source/World.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-10-20 14:00:45 +0200
committermadmaxoft <github@xoft.cz>2013-10-20 14:00:45 +0200
commit6075f7cecd7c1a1f283c98eb0feeb746402a7c00 (patch)
tree2721948dd7d5308d96ddf380a1e2540caa50b55b /source/World.cpp
parentFixed binary search in StringToMobType(). (diff)
downloadcuberite-6075f7cecd7c1a1f283c98eb0feeb746402a7c00.tar
cuberite-6075f7cecd7c1a1f283c98eb0feeb746402a7c00.tar.gz
cuberite-6075f7cecd7c1a1f283c98eb0feeb746402a7c00.tar.bz2
cuberite-6075f7cecd7c1a1f283c98eb0feeb746402a7c00.tar.lz
cuberite-6075f7cecd7c1a1f283c98eb0feeb746402a7c00.tar.xz
cuberite-6075f7cecd7c1a1f283c98eb0feeb746402a7c00.tar.zst
cuberite-6075f7cecd7c1a1f283c98eb0feeb746402a7c00.zip
Diffstat (limited to 'source/World.cpp')
-rw-r--r--source/World.cpp39
1 files changed, 19 insertions, 20 deletions
diff --git a/source/World.cpp b/source/World.cpp
index 901337879..dad36ead4 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -744,32 +744,31 @@ void cWorld::TickMobs(float a_Dt)
// before every Mob action, we have to "counts" them depending on the distance to players, on their megatype ...
cMobCensus MobCensus;
m_ChunkMap->CollectMobCensus(MobCensus);
- for(cMobFamilyCollecter::tMobFamilyList::const_iterator itr = cMobFamilyCollecter::m_AllFamilies().begin(); itr != cMobFamilyCollecter::m_AllFamilies().end(); itr++)
+ if (m_bAnimals)
{
- cMobCensus::tMobSpawnRate::const_iterator spawnrate = cMobCensus::m_SpawnRate().find(*itr);
- // hostile mobs are spawned more often
- if ((spawnrate != cMobCensus::m_SpawnRate().end()) && (m_LastSpawnMonster[*itr] < m_WorldAge - spawnrate->second))
+ for (cMobFamilyCollecter::tMobFamilyList::const_iterator itr = cMobFamilyCollecter::m_AllFamilies().begin(); itr != cMobFamilyCollecter::m_AllFamilies().end(); itr++)
{
+ int spawnrate = cMonster::GetSpawnRate(*itr);
+ if (
+ (m_LastSpawnMonster[*itr] > m_WorldAge - spawnrate) || // Not reached the needed tiks before the next round
+ MobCensus.IsCapped(*itr)
+ )
+ {
+ continue;
+ }
m_LastSpawnMonster[*itr] = m_WorldAge;
- // each megatype of mob has it's own cap
- if (!(MobCensus.IsCapped(*itr)))
+ cMobSpawner Spawner(*itr, m_AllowedMobs);
+ if (Spawner.CanSpawnAnything())
{
- if (m_bAnimals)
+ m_ChunkMap->SpawnMobs(Spawner);
+ // do the spawn
+ for(cMobSpawner::tSpawnedContainer::const_iterator itr2 = Spawner.getSpawned().begin(); itr2 != Spawner.getSpawned().end(); itr2++)
{
- cMobSpawner Spawner(*itr,m_AllowedMobs);
- if (Spawner.CanSpawnAnything())
- {
- m_ChunkMap->SpawnMobs(Spawner);
- // do the spawn
- for(cMobSpawner::tSpawnedContainer::const_iterator itr2 = Spawner.getSpawned().begin(); itr2 != Spawner.getSpawned().end(); itr2++)
- {
- SpawnMobFinalize(*itr2);
- }
- }
+ SpawnMobFinalize(*itr2);
}
- }
- }
- }
+ }
+ } // for itr - Families[]
+ } // if (Spawning enabled)
// move close mobs
cMobProximityCounter::sIterablePair allCloseEnoughToMoveMobs = MobCensus.GetProximityCounter().getMobWithinThosesDistances(-1, 64 * 16);// MG TODO : deal with this magic number (the 16 is the size of a block)