diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2016-12-19 21:12:23 +0100 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2017-08-07 20:24:16 +0200 |
commit | 4ef47aed62364f9cf1474864e5cf94232b4477af (patch) | |
tree | 28ca15247c2437b91e9aada48c2da4a1a3c00c17 /src/Mobs/Ghast.cpp | |
parent | Removed unneeded includes (#3902) (diff) | |
download | cuberite-4ef47aed62364f9cf1474864e5cf94232b4477af.tar cuberite-4ef47aed62364f9cf1474864e5cf94232b4477af.tar.gz cuberite-4ef47aed62364f9cf1474864e5cf94232b4477af.tar.bz2 cuberite-4ef47aed62364f9cf1474864e5cf94232b4477af.tar.lz cuberite-4ef47aed62364f9cf1474864e5cf94232b4477af.tar.xz cuberite-4ef47aed62364f9cf1474864e5cf94232b4477af.tar.zst cuberite-4ef47aed62364f9cf1474864e5cf94232b4477af.zip |
Diffstat (limited to 'src/Mobs/Ghast.cpp')
-rw-r--r-- | src/Mobs/Ghast.cpp | 13 |
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; } |