From ebd21ed95b475d7a411bc6d341fb287b0c125509 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 20 Sep 2014 19:12:19 +0300 Subject: Remove mercenary skills if mercenary was removed. --- src/actormanager.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/actormanager.cpp') diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 2b91a30df..c025d9f44 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -38,6 +38,7 @@ #include "gui/windows/botcheckerwindow.h" #include "gui/windows/chatwindow.h" #include "gui/windows/equipmentwindow.h" +#include "gui/windows/skilldialog.h" #include "gui/windows/socialwindow.h" #include "gui/windows/questswindow.h" @@ -800,21 +801,31 @@ void ActorManager::logic() BLOCK_START("ActorManager::logic 1") FOR_EACH (ActorSpritesConstIterator, it, mDeleteActors) { - if (!*it) + const ActorSprite *const actor = *it; + if (!actor) continue; - if ((*it) && (*it)->getType() == ActorType::Player) + const ActorType::Type &type = actor->getType(); + if (type == ActorType::Player) { - const Being *const being = static_cast(*it); + const Being *const being = static_cast(actor); being->addToCache(); if (beingEquipmentWindow) beingEquipmentWindow->resetBeing(being); } + else if (localPlayer && type == ActorType::Mercenary) + { + if (actor->getId() == localPlayer->getMercenary()) + { + localPlayer->setMercenary(0); + skillDialog->hideSkills(SkillOwner::Mercenary); + } + } if (localPlayer) { - if (localPlayer->getTarget() == *it) + if (localPlayer->getTarget() == actor) localPlayer->setTarget(nullptr); - if (localPlayer->getPickUpTarget() == *it) + if (localPlayer->getPickUpTarget() == actor) localPlayer->unSetPickUpTarget(); } if (viewport) -- cgit v1.2.3-60-g2f50