From 0f9ec2061c4ad6157c3186f1cab9c4d8558980b5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 29 May 2015 14:30:20 +0300 Subject: Add strong typed int type BeingId. --- src/net/eathena/mercenaryhandler.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/net/eathena/mercenaryhandler.cpp') diff --git a/src/net/eathena/mercenaryhandler.cpp b/src/net/eathena/mercenaryhandler.cpp index ebdba730e..82f7b59c2 100644 --- a/src/net/eathena/mercenaryhandler.cpp +++ b/src/net/eathena/mercenaryhandler.cpp @@ -90,7 +90,7 @@ void MercenaryHandler::processMercenaryUpdate(Net::MessageIn &msg) void MercenaryHandler::processMercenaryInfo(Net::MessageIn &msg) { // +++ need create if need mercenary being and update stats - Being *const dstBeing = actorManager->findBeing(msg.readInt32("being id")); + Being *const dstBeing = actorManager->findBeing(msg.readBeingId("being id")); msg.readInt16("atk"); msg.readInt16("matk"); msg.readInt16("hit"); @@ -188,33 +188,34 @@ void MercenaryHandler::fire() void MercenaryHandler::moveToMaster() const { - const int id = PlayerInfo::getMercenaryId(); - if (!id) + const BeingId id = PlayerInfo::getMercenaryId(); + if (id == BeingId_zero) return; createOutPacket(CMSG_HOMMERC_MOVE_TO_MASTER); - outMsg.writeInt32(id, "mercenary id"); + outMsg.writeBeingId(id, "mercenary id"); } void MercenaryHandler::move(const int x, const int y) const { - const int id = PlayerInfo::getMercenaryId(); - if (!id) + const BeingId id = PlayerInfo::getMercenaryId(); + if (id == BeingId_zero) return; createOutPacket(CMSG_HOMMERC_MOVE_TO); - outMsg.writeInt32(id, "mercenary id"); + outMsg.writeBeingId(id, "mercenary id"); outMsg.writeCoordinates(static_cast(x), static_cast(y), 0U, "position"); } -void MercenaryHandler::attack(const int targetId, const Keep keep) const +void MercenaryHandler::attack(const BeingId targetId, + const Keep keep) const { - const int id = PlayerInfo::getMercenaryId(); - if (!id) + const BeingId id = PlayerInfo::getMercenaryId(); + if (id == BeingId_zero) return; createOutPacket(CMSG_HOMMERC_ATTACK); - outMsg.writeInt32(id, "mercenary id"); - outMsg.writeInt32(targetId, "target id"); + outMsg.writeBeingId(id, "mercenary id"); + outMsg.writeBeingId(targetId, "target id"); outMsg.writeInt8(static_cast(keep == Keep_true ? 1 : 0), "keep"); } -- cgit v1.2.3-70-g09d2