summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actormanager.cpp21
-rw-r--r--src/being/localplayer.cpp1
-rw-r--r--src/being/localplayer.h7
-rw-r--r--src/net/eathena/mercenaryhandler.cpp3
4 files changed, 27 insertions, 5 deletions
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<const Being*>(*it);
+ const Being *const being = static_cast<const Being*>(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)
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 30e323d7e..062a06678 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -153,6 +153,7 @@ LocalPlayer::LocalPlayer(const int id, const uint16_t subtype) :
mTestParticleName(),
mTestParticleTime(0),
mTestParticleHash(0L),
+ mMercenaryId(0),
mWalkingDir(0),
mUpdateName(true),
mBlockAdvert(false),
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
index ed2b42b53..d90e94dc1 100644
--- a/src/being/localplayer.h
+++ b/src/being/localplayer.h
@@ -403,6 +403,12 @@ class LocalPlayer final : public Being,
AwayListener *getAwayListener() const A_WARN_UNUSED
{ return mAwayListener; }
+ void setMercenary(const int id)
+ { mMercenaryId = id; }
+
+ int getMercenary() const
+ { return mMercenaryId; }
+
protected:
void updateCoords() override final;
@@ -484,6 +490,7 @@ class LocalPlayer final : public Being,
std::string mTestParticleName;
int mTestParticleTime;
unsigned long mTestParticleHash;
+ int mMercenaryId;
unsigned char mWalkingDir; // The direction the player is walking in.
/** Whether or not the name settings have changed */
bool mUpdateName;
diff --git a/src/net/eathena/mercenaryhandler.cpp b/src/net/eathena/mercenaryhandler.cpp
index 2a44e86ca..63c43f093 100644
--- a/src/net/eathena/mercenaryhandler.cpp
+++ b/src/net/eathena/mercenaryhandler.cpp
@@ -24,6 +24,7 @@
#include "logger.h"
#include "being/being.h"
+#include "being/localplayer.h"
#include "being/playerinfo.h"
#include "gui/windows/skilldialog.h"
@@ -110,6 +111,8 @@ void MercenaryHandler::processMercenaryInfo(Net::MessageIn &msg)
dstBeing->setName(name);
dstBeing->setLevel(level);
dstBeing->setAttackRange(range);
+ if (localPlayer)
+ localPlayer->setMercenary(dstBeing->getId());
}
}