summaryrefslogtreecommitdiffstats
path: root/source/World.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/World.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/source/World.cpp b/source/World.cpp
index dad36ead4..d1ddb0e6e 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -736,38 +736,42 @@ void cWorld::TickWeather(float a_Dt)
void cWorld::TickMobs(float a_Dt)
{
- if (!m_bAnimals)
- {
- return;
- }
-
- // before every Mob action, we have to "counts" them depending on the distance to players, on their megatype ...
+ // before every Mob action, we have to count them depending on the distance to players, on their family ...
cMobCensus MobCensus;
m_ChunkMap->CollectMobCensus(MobCensus);
if (m_bAnimals)
{
- for (cMobFamilyCollecter::tMobFamilyList::const_iterator itr = cMobFamilyCollecter::m_AllFamilies().begin(); itr != cMobFamilyCollecter::m_AllFamilies().end(); itr++)
+ // Spawning is enabled, spawn now:
+ static const cMonster::eFamily AllFamilies[] =
+ {
+ cMonster::mfHostile,
+ cMonster::mfPassive,
+ cMonster::mfAmbient,
+ cMonster::mfWater,
+ } ;
+ for (int i = 0; i < ARRAYCOUNT(AllFamilies); i++)
{
- int spawnrate = cMonster::GetSpawnRate(*itr);
+ cMonster::eFamily Family = AllFamilies[i];
+ int spawnrate = cMonster::GetSpawnRate(Family);
if (
- (m_LastSpawnMonster[*itr] > m_WorldAge - spawnrate) || // Not reached the needed tiks before the next round
- MobCensus.IsCapped(*itr)
+ (m_LastSpawnMonster[Family] > m_WorldAge - spawnrate) || // Not reached the needed tiks before the next round
+ MobCensus.IsCapped(Family)
)
{
continue;
}
- m_LastSpawnMonster[*itr] = m_WorldAge;
- cMobSpawner Spawner(*itr, m_AllowedMobs);
+ m_LastSpawnMonster[Family] = m_WorldAge;
+ cMobSpawner Spawner(Family, 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++)
+ for (cMobSpawner::tSpawnedContainer::const_iterator itr2 = Spawner.getSpawned().begin(); itr2 != Spawner.getSpawned().end(); itr2++)
{
SpawnMobFinalize(*itr2);
}
}
- } // for itr - Families[]
+ } // for i - AllFamilies[]
} // if (Spawning enabled)
// move close mobs