summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Ghast.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2017-08-18 12:17:56 +0200
committerGitHub <noreply@github.com>2017-08-18 12:17:56 +0200
commit72d7027861a3b7e7e8bb5fdcbbc5a1a778fa7f82 (patch)
treec1c1a040332d4ba1f784be25c67c9800e85015eb /src/Mobs/Ghast.cpp
parentSitting cats block enderchests from opening (#3906) (diff)
parentChanged entity ownership model to use smart pointers (diff)
downloadcuberite-72d7027861a3b7e7e8bb5fdcbbc5a1a778fa7f82.tar
cuberite-72d7027861a3b7e7e8bb5fdcbbc5a1a778fa7f82.tar.gz
cuberite-72d7027861a3b7e7e8bb5fdcbbc5a1a778fa7f82.tar.bz2
cuberite-72d7027861a3b7e7e8bb5fdcbbc5a1a778fa7f82.tar.lz
cuberite-72d7027861a3b7e7e8bb5fdcbbc5a1a778fa7f82.tar.xz
cuberite-72d7027861a3b7e7e8bb5fdcbbc5a1a778fa7f82.tar.zst
cuberite-72d7027861a3b7e7e8bb5fdcbbc5a1a778fa7f82.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/Ghast.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/Mobs/Ghast.cpp b/src/Mobs/Ghast.cpp
index 6f5a93d93..2488e63b1 100644
--- a/src/Mobs/Ghast.cpp
+++ b/src/Mobs/Ghast.cpp
@@ -39,17 +39,14 @@ bool cGhast::Attack(std::chrono::milliseconds a_Dt)
// Setting this higher gives us more wiggle room for attackrate
Vector3d Speed = GetLookVector() * 20;
Speed.y = Speed.y + 1;
- cGhastFireballEntity * GhastBall = new cGhastFireballEntity(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
- if (GhastBall == nullptr)
- {
- return false;
- }
- if (!GhastBall->Initialize(*m_World))
+
+ auto GhastBall = cpp14::make_unique<cGhastFireballEntity>(this, GetPosX(), GetPosY() + 1, GetPosZ(), Speed);
+ auto GhastBallPtr = GhastBall.get();
+ if (!GhastBallPtr->Initialize(std::move(GhastBall), *m_World))
{
- delete GhastBall;
- GhastBall = nullptr;
return false;
}
+
ResetAttackCooldown();
return true;
}