summaryrefslogtreecommitdiffstats
path: root/src/MobSpawner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/MobSpawner.cpp')
-rw-r--r--src/MobSpawner.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp
index e3f5298e4..1e0db5175 100644
--- a/src/MobSpawner.cpp
+++ b/src/MobSpawner.cpp
@@ -342,13 +342,12 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
cMonster * cMobSpawner::TryToSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, EMCSBiome a_Biome, int & a_MaxPackSize)
{
- cMonster * toReturn = nullptr;
if (m_NewPack)
{
m_MobType = ChooseMobType(a_Biome);
if (m_MobType == mtInvalidType)
{
- return toReturn;
+ return nullptr;
}
if (m_MobType == mtWolf)
{
@@ -366,14 +365,16 @@ cMonster * cMobSpawner::TryToSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY,
if ((m_AllowedTypes.find(m_MobType) != m_AllowedTypes.end()) && CanSpawnHere(a_Chunk, a_RelX, a_RelY, a_RelZ, m_MobType, a_Biome))
{
- cMonster * newMob = cMonster::NewMonsterFromType(m_MobType);
+ auto newMob = cMonster::NewMonsterFromType(m_MobType);
+ auto NewMobPtr = newMob.get();
if (newMob)
{
- m_Spawned.insert(newMob);
+ m_Spawned.insert(std::move(newMob));
}
- toReturn = newMob;
+ return NewMobPtr;
}
- return toReturn;
+
+ return nullptr;
}