summaryrefslogtreecommitdiffstats
path: root/src/MobSpawner.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2016-08-20 14:34:29 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2016-08-20 14:34:29 +0200
commit7175b9e435a54cff33914d21384625a445cc5cf0 (patch)
tree7feb44f1e8e4ed7ea4d5bf0ba1d173abd3417f34 /src/MobSpawner.cpp
parentAdded cWorld:SetSpawn() API and Lua binding (#3316) (diff)
downloadcuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar
cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.gz
cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.bz2
cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.lz
cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.xz
cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.zst
cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.zip
Diffstat (limited to '')
-rw-r--r--src/MobSpawner.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp
index 60f7cfb43..b6ad261b5 100644
--- a/src/MobSpawner.cpp
+++ b/src/MobSpawner.cpp
@@ -347,15 +347,14 @@ 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)
+std::unique_ptr<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)
{
@@ -373,14 +372,15 @@ 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);
if (newMob)
{
- m_Spawned.insert(newMob);
+ m_Spawned.insert(std::move(newMob));
}
- toReturn = newMob;
+ return newMob;
}
- return toReturn;
+
+ return nullptr;
}