summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/being/playerinfo.cpp9
-rw-r--r--src/being/playerinfo.h2
-rw-r--r--src/net/eathena/beinghandler.cpp11
-rw-r--r--src/net/eathena/mercenaryhandler.cpp16
4 files changed, 27 insertions, 11 deletions
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index 993c4d8a6..ba36d59a3 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -26,6 +26,7 @@
#include "inventory.h"
#include "being/attributes.h"
+#include "being/localplayer.h"
#include "being/mercenaryinfo.h"
#include "itemsoundmanager.h"
@@ -472,6 +473,14 @@ void setMercenary(MercenaryInfo *const info)
mMercenary = info;
}
+void setMercenaryBeing(Being *const being)
+{
+ if (!being || !mMercenary)
+ return;
+ being->setName(mMercenary->name);
+ being->setOwner(localPlayer);
+}
+
MercenaryInfo *getMercenary()
{
return mMercenary;
diff --git a/src/being/playerinfo.h b/src/being/playerinfo.h
index c01fdd237..4fcc5dfc1 100644
--- a/src/being/playerinfo.h
+++ b/src/being/playerinfo.h
@@ -58,6 +58,7 @@ struct PlayerInfoBackend final
IntMap mSkills;
};
+class Being;
class FloorItem;
class Inventory;
class Item;
@@ -240,6 +241,7 @@ namespace PlayerInfo
void setMercenary(MercenaryInfo *const info);
+ void setMercenaryBeing(Being *const being);
} // namespace PlayerInfo
#endif // BEING_PLAYERINFO_H
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index e2617dc98..9707475da 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -28,6 +28,8 @@
#include "party.h"
#include "being/localplayer.h"
+#include "being/mercenaryinfo.h"
+#include "being/playerinfo.h"
#include "input/keyboardconfig.h"
@@ -325,7 +327,14 @@ Being *BeingHandler::createBeing2(const int id,
if (job == 45 && beingType == BeingType::NPC_EVENT)
type = ActorType::Portal;
- return actorManager->createBeing(id, type, job);
+ Being *const being = actorManager->createBeing(id, type, job);
+ if (beingType == BeingType::MERSOL)
+ {
+ MercenaryInfo *const info = PlayerInfo::getMercenary();
+ if (info && info->id == id)
+ PlayerInfo::setMercenaryBeing(being);
+ }
+ return being;
}
void BeingHandler::undress(Being *const being) const
diff --git a/src/net/eathena/mercenaryhandler.cpp b/src/net/eathena/mercenaryhandler.cpp
index 0726f5281..d197b6101 100644
--- a/src/net/eathena/mercenaryhandler.cpp
+++ b/src/net/eathena/mercenaryhandler.cpp
@@ -110,19 +110,15 @@ void MercenaryHandler::processMercenaryInfo(Net::MessageIn &msg)
msg.readInt32("calls");
msg.readInt32("kills");
const int range = msg.readInt16("attack range");
- if (dstBeing)
+ if (dstBeing && localPlayer)
{
- dstBeing->setName(name);
+ MercenaryInfo *const mercenary = new MercenaryInfo;
+ mercenary->id = dstBeing->getId();
+ mercenary->name = name;
+ PlayerInfo::setMercenary(mercenary);
+ PlayerInfo::setMercenaryBeing(dstBeing);
dstBeing->setLevel(level);
dstBeing->setAttackRange(range);
- dstBeing->setOwner(localPlayer);
- if (localPlayer)
- {
- MercenaryInfo *const mercenary = new MercenaryInfo;
- mercenary->id = dstBeing->getId();
- mercenary->name = name;
- PlayerInfo::setMercenary(mercenary);
- }
}
}