From 4ef47aed62364f9cf1474864e5cf94232b4477af Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 19 Dec 2016 20:12:23 +0000 Subject: Changed entity ownership model to use smart pointers --- src/Mobs/Ghast.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/Mobs/Ghast.cpp') 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(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; } -- cgit v1.2.3