diff options
author | Samuel Barney <samjbarney@gmail.com> | 2013-10-14 19:12:12 +0200 |
---|---|---|
committer | Samuel Barney <samjbarney@gmail.com> | 2013-10-14 19:12:12 +0200 |
commit | 210cd4eb50bd9470611e772dfb1ae20997996710 (patch) | |
tree | 7fd5fbff18624db334da0dd56e809cbf58a607f0 | |
parent | Merge branch 'MobSpawning' of https://github.com/mgueydan/MCServer into MobSpawning (diff) | |
download | cuberite-210cd4eb50bd9470611e772dfb1ae20997996710.tar cuberite-210cd4eb50bd9470611e772dfb1ae20997996710.tar.gz cuberite-210cd4eb50bd9470611e772dfb1ae20997996710.tar.bz2 cuberite-210cd4eb50bd9470611e772dfb1ae20997996710.tar.lz cuberite-210cd4eb50bd9470611e772dfb1ae20997996710.tar.xz cuberite-210cd4eb50bd9470611e772dfb1ae20997996710.tar.zst cuberite-210cd4eb50bd9470611e772dfb1ae20997996710.zip |
Diffstat (limited to '')
-rw-r--r-- | source/World.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/source/World.cpp b/source/World.cpp index 7a9bf46af..3a4469c99 100644 --- a/source/World.cpp +++ b/source/World.cpp @@ -444,6 +444,12 @@ void cWorld::Start(void) m_SpawnY = cChunkDef::Height; m_SpawnZ = (double)((m_TickRand.randInt() % 1000) - 500); m_GameMode = eGameMode_Creative; + static AString SettingsName = "settings.ini"; + cIniFile Settings(SettingsName); + if (!Settings.ReadFile()) + { + LOGWARNING("Cannot read world settings from \"%s\", defaults will be used.", SettingsName.c_str()); + } cIniFile IniFile(m_IniFileName); if (!IniFile.ReadFile()) @@ -489,8 +495,11 @@ void cWorld::Start(void) m_GameMode = (eGameMode)IniFile.GetValueSetI("GameMode", "GameMode", m_GameMode); - m_bAnimals = IniFile.GetValueB("Monsters", "AnimalsOn", true); + m_bAnimals = Settings.GetValueB("Monsters", "AnimalsOn", true); + m_bAnimals = IniFile.GetValueB("Monsters", "AnimalsOn", m_bAnimals); AString sAllMonsters = IniFile.GetValue("Monsters", "Types"); + if (!sAllMonsters.size()) + sAllMonsters = Settings.GetValue("Monsters", "Types"); AStringVector SplitList = StringSplit(sAllMonsters, ","); for (unsigned int i = 0; i < SplitList.size(); ++i) { @@ -728,7 +737,6 @@ 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++) { cMobCensus::tMobSpawnRate::const_iterator spawnrate = cMobCensus::m_SpawnRate().find(*itr); @@ -741,6 +749,7 @@ void cWorld::TickMobs(float a_Dt) { if (m_bAnimals) { + cMobSpawner Spawner(*itr,m_AllowedMobs); if (Spawner.CanSpawnSomething()) { @@ -2511,11 +2520,11 @@ int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eTyp int SlSize = GetTickRandomNumber(2) + 1; // 1 .. 3 - Slime int ShColor = GetTickRandomNumber(15); // 0 .. 15 - Sheep - bool SkType = GetDimension() == biNether; // Skeleton - - cMobTypesManager::NewMonsterFromType(a_MonsterType); - Monster->SetPosition(a_PosX, a_PosY, a_PosZ); + bool SkType = GetDimension() == dimNether ; // Skeleton + Monster = cMobTypesManager::NewMonsterFromType(a_MonsterType); + if (Monster) + Monster->SetPosition(a_PosX, a_PosY, a_PosZ); return SpawnMobFinalize(Monster); } @@ -2524,6 +2533,8 @@ int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eTyp int cWorld::SpawnMobFinalize(cMonster* a_Monster) { + if (!a_Monster) + return -1; a_Monster->SetHealth(a_Monster->GetMaxHealth()); if (cPluginManager::Get()->CallHookSpawningMonster(*this, *a_Monster)) { |