summaryrefslogtreecommitdiff
path: root/src/net/eathena/npchandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-29 14:30:20 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-29 14:30:20 +0300
commit0f9ec2061c4ad6157c3186f1cab9c4d8558980b5 (patch)
tree6259593b8436178ad8d981a96a8fd71eab9e04cc /src/net/eathena/npchandler.cpp
parent01773c71a4698c6f01fe70d864f922bda65506cb (diff)
downloadmanaplus-0f9ec2061c4ad6157c3186f1cab9c4d8558980b5.tar.gz
manaplus-0f9ec2061c4ad6157c3186f1cab9c4d8558980b5.tar.bz2
manaplus-0f9ec2061c4ad6157c3186f1cab9c4d8558980b5.tar.xz
manaplus-0f9ec2061c4ad6157c3186f1cab9c4d8558980b5.zip
Add strong typed int type BeingId.
Diffstat (limited to 'src/net/eathena/npchandler.cpp')
-rw-r--r--src/net/eathena/npchandler.cpp46
1 files changed, 25 insertions, 21 deletions
diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp
index e5ff89cfb..2c018dad9 100644
--- a/src/net/eathena/npchandler.cpp
+++ b/src/net/eathena/npchandler.cpp
@@ -138,23 +138,23 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
mDialog = nullptr;
}
-void NpcHandler::talk(const int npcId) const
+void NpcHandler::talk(const BeingId npcId) const
{
createOutPacket(CMSG_NPC_TALK);
- outMsg.writeInt32(npcId, "npc id");
+ outMsg.writeBeingId(npcId, "npc id");
outMsg.writeInt8(0, "unused");
}
-void NpcHandler::nextDialog(const int npcId) const
+void NpcHandler::nextDialog(const BeingId npcId) const
{
createOutPacket(CMSG_NPC_NEXT_REQUEST);
- outMsg.writeInt32(npcId, "npc id");
+ outMsg.writeBeingId(npcId, "npc id");
}
-void NpcHandler::closeDialog(const int npcId)
+void NpcHandler::closeDialog(const BeingId npcId)
{
createOutPacket(CMSG_NPC_CLOSE);
- outMsg.writeInt32(npcId, "npc id");
+ outMsg.writeBeingId(npcId, "npc id");
const NpcDialogs::iterator it = NpcDialog::mNpcDialogs.find(npcId);
if (it != NpcDialog::mNpcDialogs.end())
@@ -168,44 +168,48 @@ void NpcHandler::closeDialog(const int npcId)
}
}
-void NpcHandler::listInput(const int npcId, const unsigned char value) const
+void NpcHandler::listInput(const BeingId npcId,
+ const unsigned char value) const
{
createOutPacket(CMSG_NPC_LIST_CHOICE);
- outMsg.writeInt32(npcId, "npc id");
+ outMsg.writeBeingId(npcId, "npc id");
outMsg.writeInt8(value, "value");
}
-void NpcHandler::integerInput(const int npcId, const int value) const
+void NpcHandler::integerInput(const BeingId npcId,
+ const int value) const
{
createOutPacket(CMSG_NPC_INT_RESPONSE);
- outMsg.writeInt32(npcId, "npc id");
+ outMsg.writeBeingId(npcId, "npc id");
outMsg.writeInt32(value, "value");
}
-void NpcHandler::stringInput(const int npcId, const std::string &value) const
+void NpcHandler::stringInput(const BeingId npcId,
+ const std::string &value) const
{
createOutPacket(CMSG_NPC_STR_RESPONSE);
outMsg.writeInt16(static_cast<int16_t>(value.length() + 9), "len");
- outMsg.writeInt32(npcId, "npc ud");
+ outMsg.writeBeingId(npcId, "npc id");
outMsg.writeString(value, static_cast<int>(value.length()), "value");
outMsg.writeInt8(0, "null byte");
}
-void NpcHandler::buy(const int beingId) const
+void NpcHandler::buy(const BeingId beingId) const
{
createOutPacket(CMSG_NPC_BUY_SELL_REQUEST);
- outMsg.writeInt32(beingId, "npc id");
+ outMsg.writeBeingId(beingId, "npc id");
outMsg.writeInt8(0, "action");
}
-void NpcHandler::sell(const int beingId) const
+void NpcHandler::sell(const BeingId beingId) const
{
createOutPacket(CMSG_NPC_BUY_SELL_REQUEST);
- outMsg.writeInt32(beingId, "npc id");
+ outMsg.writeBeingId(beingId, "npc id");
outMsg.writeInt8(1, "action");
}
-void NpcHandler::buyItem(const int beingId A_UNUSED, const int itemId,
+void NpcHandler::buyItem(const BeingId beingId A_UNUSED,
+ const int itemId,
const unsigned char color A_UNUSED,
const int amount) const
{
@@ -215,7 +219,7 @@ void NpcHandler::buyItem(const int beingId A_UNUSED, const int itemId,
outMsg.writeInt16(static_cast<int16_t>(itemId), "item id");
}
-void NpcHandler::sellItem(const int beingId A_UNUSED,
+void NpcHandler::sellItem(const BeingId beingId A_UNUSED,
const int itemId, const int amount) const
{
createOutPacket(CMSG_NPC_SELL_REQUEST);
@@ -280,7 +284,7 @@ void NpcHandler::selectAutoSpell(const int skillId) const
outMsg.writeInt32(static_cast<int16_t>(skillId), "skill id");
}
-int NpcHandler::getNpc(Net::MessageIn &msg)
+BeingId NpcHandler::getNpc(Net::MessageIn &msg)
{
if (msg.getId() == SMSG_NPC_CHOICE
|| msg.getId() == SMSG_NPC_MESSAGE
@@ -289,7 +293,7 @@ int NpcHandler::getNpc(Net::MessageIn &msg)
msg.readInt16("len");
}
- const int npcId = msg.readInt32("npc id");
+ const BeingId npcId = msg.readBeingId("npc id");
const NpcDialogs::const_iterator diag = NpcDialog::mNpcDialogs.find(npcId);
mDialog = nullptr;
@@ -378,7 +382,7 @@ void NpcHandler::processArea(Net::MessageIn &msg)
if (len < 12)
return;
Being *const dstBeing = actorManager->findBeing(
- msg.readInt32("npc id"));
+ msg.readBeingId("npc id"));
const int area = msg.readInt32("area size");
if (dstBeing)
dstBeing->setAreaSize(area);