summaryrefslogtreecommitdiffstats
path: root/source/World.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-10-20 14:16:21 +0200
committermadmaxoft <github@xoft.cz>2013-10-20 14:16:21 +0200
commitb6741865f2bb541699d04f128a5389d7b8a4babe (patch)
treec9671f34b5def39dab2589a04a44302ad3d5aabc /source/World.cpp
parentReimplemented cMonster::FamilyFromType() as a simple switch (duh!) (diff)
downloadcuberite-b6741865f2bb541699d04f128a5389d7b8a4babe.tar
cuberite-b6741865f2bb541699d04f128a5389d7b8a4babe.tar.gz
cuberite-b6741865f2bb541699d04f128a5389d7b8a4babe.tar.bz2
cuberite-b6741865f2bb541699d04f128a5389d7b8a4babe.tar.lz
cuberite-b6741865f2bb541699d04f128a5389d7b8a4babe.tar.xz
cuberite-b6741865f2bb541699d04f128a5389d7b8a4babe.tar.zst
cuberite-b6741865f2bb541699d04f128a5389d7b8a4babe.zip
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