diff options
author | madmaxoft <github@xoft.cz> | 2013-10-20 14:00:45 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-10-20 14:00:45 +0200 |
commit | 6075f7cecd7c1a1f283c98eb0feeb746402a7c00 (patch) | |
tree | 2721948dd7d5308d96ddf380a1e2540caa50b55b /source/World.cpp | |
parent | Fixed binary search in StringToMobType(). (diff) | |
download | cuberite-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 '')
-rw-r--r-- | source/World.cpp | 39 |
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) |