2013-09-07 16:19:56 -04:00
|
|
|
|
|
|
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
|
|
|
|
|
|
|
#include "MobCensus.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-18 14:02:53 -04:00
|
|
|
|
|
|
|
|
|
|
|
void cMobCensus::CollectMob(cMonster & a_Monster, cChunk & a_Chunk, double a_Distance)
|
2013-09-07 16:19:56 -04:00
|
|
|
{
|
2013-10-20 08:00:45 -04:00
|
|
|
m_ProximityCounter.CollectMob(a_Monster, a_Chunk, a_Distance);
|
2013-09-07 16:19:56 -04:00
|
|
|
m_MobFamilyCollecter.CollectMob(a_Monster);
|
|
|
|
}
|
|
|
|
|
2013-10-18 14:02:53 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool cMobCensus::IsCapped(cMonster::eFamily a_MobFamily)
|
2013-09-07 16:19:56 -04:00
|
|
|
{
|
2015-05-09 03:25:09 -04:00
|
|
|
const int ratio = 319; // This should be 256 as we are only supposed to take account from chunks that are in 17 x 17 from a player
|
|
|
|
// but for now, we use all chunks loaded by players. that means 19 x 19 chunks. That's why we use 256 * (19 * 19) / (17 * 17) = 319
|
2014-07-17 10:33:09 -04:00
|
|
|
// MG TODO : code the correct count
|
2013-10-20 08:00:45 -04:00
|
|
|
if ((GetCapMultiplier(a_MobFamily) * GetNumChunks()) / ratio >= m_MobFamilyCollecter.GetNumberOfCollectedMobs(a_MobFamily))
|
2013-09-07 16:19:56 -04:00
|
|
|
{
|
2013-10-18 14:02:53 -04:00
|
|
|
return false;
|
2013-09-07 16:19:56 -04:00
|
|
|
}
|
2013-10-18 14:02:53 -04:00
|
|
|
return true;
|
2013-09-07 16:19:56 -04:00
|
|
|
}
|
|
|
|
|
2013-10-18 14:02:53 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-20 08:00:45 -04:00
|
|
|
int cMobCensus::GetCapMultiplier(cMonster::eFamily a_MobFamily)
|
|
|
|
{
|
|
|
|
switch (a_MobFamily)
|
|
|
|
{
|
|
|
|
case cMonster::mfHostile: return 79;
|
|
|
|
case cMonster::mfPassive: return 11;
|
|
|
|
case cMonster::mfAmbient: return 16;
|
|
|
|
case cMonster::mfWater: return 5;
|
2015-05-19 14:32:10 -04:00
|
|
|
case cMonster::mfNoSpawn:
|
|
|
|
case cMonster::mfUnhandled:
|
2013-12-20 10:22:16 -05:00
|
|
|
{
|
|
|
|
ASSERT(!"Unhandled mob family");
|
|
|
|
return -1;
|
|
|
|
}
|
2013-10-20 08:00:45 -04:00
|
|
|
}
|
2015-06-02 06:51:43 -04:00
|
|
|
#if !defined(__clang__)
|
|
|
|
ASSERT(!"Unknown mob family");
|
|
|
|
return -1;
|
|
|
|
#endif
|
2013-10-20 08:00:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-18 14:02:53 -04:00
|
|
|
void cMobCensus::CollectSpawnableChunk(cChunk & a_Chunk)
|
2013-09-07 16:19:56 -04:00
|
|
|
{
|
|
|
|
m_EligibleForSpawnChunks.insert(&a_Chunk);
|
|
|
|
}
|
|
|
|
|
2013-10-18 14:02:53 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int cMobCensus::GetNumChunks(void)
|
2013-09-07 16:19:56 -04:00
|
|
|
{
|
2015-05-24 07:56:56 -04:00
|
|
|
return static_cast<int>(m_EligibleForSpawnChunks.size());
|
2013-09-07 16:19:56 -04:00
|
|
|
}
|
|
|
|
|
2013-10-18 14:02:53 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cMobProximityCounter & cMobCensus::GetProximityCounter(void)
|
2013-09-07 16:19:56 -04:00
|
|
|
{
|
|
|
|
return m_ProximityCounter;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-18 14:02:53 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cMobCensus::Logd()
|
2013-09-07 16:19:56 -04:00
|
|
|
{
|
2013-10-18 14:02:53 -04:00
|
|
|
LOGD("Hostile mobs : %d %s", m_MobFamilyCollecter.GetNumberOfCollectedMobs(cMonster::mfHostile), IsCapped(cMonster::mfHostile) ? "(capped)" : "");
|
|
|
|
LOGD("Ambient mobs : %d %s", m_MobFamilyCollecter.GetNumberOfCollectedMobs(cMonster::mfAmbient), IsCapped(cMonster::mfAmbient) ? "(capped)" : "");
|
|
|
|
LOGD("Water mobs : %d %s", m_MobFamilyCollecter.GetNumberOfCollectedMobs(cMonster::mfWater), IsCapped(cMonster::mfWater) ? "(capped)" : "");
|
|
|
|
LOGD("Passive mobs : %d %s", m_MobFamilyCollecter.GetNumberOfCollectedMobs(cMonster::mfPassive), IsCapped(cMonster::mfPassive) ? "(capped)" : "");
|
2013-09-07 16:19:56 -04:00
|
|
|
}
|
2013-10-18 14:02:53 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-20 08:00:45 -04:00
|
|
|
|