summaryrefslogtreecommitdiff
path: root/src/net/eathena
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
parent01773c71a4698c6f01fe70d864f922bda65506cb (diff)
downloadplus-0f9ec2061c4ad6157c3186f1cab9c4d8558980b5.tar.gz
plus-0f9ec2061c4ad6157c3186f1cab9c4d8558980b5.tar.bz2
plus-0f9ec2061c4ad6157c3186f1cab9c4d8558980b5.tar.xz
plus-0f9ec2061c4ad6157c3186f1cab9c4d8558980b5.zip
Add strong typed int type BeingId.
Diffstat (limited to 'src/net/eathena')
-rw-r--r--src/net/eathena/adminhandler.cpp12
-rw-r--r--src/net/eathena/adminhandler.h2
-rw-r--r--src/net/eathena/battlegroundhandler.cpp4
-rw-r--r--src/net/eathena/beinghandler.cpp102
-rw-r--r--src/net/eathena/beinghandler.h4
-rw-r--r--src/net/eathena/buyingstorehandler.cpp12
-rw-r--r--src/net/eathena/cashshophandler.cpp2
-rw-r--r--src/net/eathena/charserverhandler.cpp24
-rw-r--r--src/net/eathena/charserverhandler.h6
-rw-r--r--src/net/eathena/chathandler.cpp12
-rw-r--r--src/net/eathena/familyhandler.cpp2
-rw-r--r--src/net/eathena/friendshandler.cpp10
-rw-r--r--src/net/eathena/gamehandler.cpp8
-rw-r--r--src/net/eathena/guildhandler.cpp20
-rw-r--r--src/net/eathena/homunculushandler.cpp25
-rw-r--r--src/net/eathena/homunculushandler.h3
-rw-r--r--src/net/eathena/inventoryhandler.cpp6
-rw-r--r--src/net/eathena/itemhandler.cpp2
-rw-r--r--src/net/eathena/markethandler.cpp2
-rw-r--r--src/net/eathena/mercenaryhandler.cpp25
-rw-r--r--src/net/eathena/mercenaryhandler.h3
-rw-r--r--src/net/eathena/messagein.cpp5
-rw-r--r--src/net/eathena/messagein.h2
-rw-r--r--src/net/eathena/messageout.cpp5
-rw-r--r--src/net/eathena/messageout.h3
-rw-r--r--src/net/eathena/npchandler.cpp46
-rw-r--r--src/net/eathena/npchandler.h24
-rw-r--r--src/net/eathena/partyhandler.cpp36
-rw-r--r--src/net/eathena/pethandler.cpp6
-rw-r--r--src/net/eathena/playerhandler.cpp11
-rw-r--r--src/net/eathena/playerhandler.h3
-rw-r--r--src/net/eathena/skillhandler.cpp10
-rw-r--r--src/net/eathena/skillhandler.h11
-rw-r--r--src/net/eathena/tradehandler.cpp2
-rw-r--r--src/net/eathena/vendinghandler.cpp12
35 files changed, 251 insertions, 211 deletions
diff --git a/src/net/eathena/adminhandler.cpp b/src/net/eathena/adminhandler.cpp
index 75250d2b7..92e158a8e 100644
--- a/src/net/eathena/adminhandler.cpp
+++ b/src/net/eathena/adminhandler.cpp
@@ -95,10 +95,10 @@ void AdminHandler::hide(const bool h A_UNUSED) const
outMsg.writeInt32(0, "unused");
}
-void AdminHandler::kick(const int playerId) const
+void AdminHandler::kick(const BeingId playerId) const
{
createOutPacket(CMSG_ADMIN_KICK);
- outMsg.writeInt32(playerId, "account id");
+ outMsg.writeBeingId(playerId, "account id");
}
void AdminHandler::kickAll() const
@@ -146,7 +146,7 @@ void AdminHandler::mute(const Being *const being,
return;
createOutPacket(CMSG_ADMIN_MUTE);
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
outMsg.writeInt8(static_cast<int8_t>(type), "type");
outMsg.writeInt16(static_cast<int16_t>(limit), "value");
}
@@ -163,7 +163,7 @@ void AdminHandler::requestLogin(const Being *const being) const
return;
createOutPacket(CMSG_ADMIN_ID_TO_LOGIN);
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
}
void AdminHandler::setTileType(const int x, const int y,
@@ -181,13 +181,13 @@ void AdminHandler::unequipAll(const Being *const being) const
return;
createOutPacket(CMSG_ADMIN_UNEQUIP_ALL);
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
}
void AdminHandler::processAdminGetLoginAck(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("account id");
+ msg.readBeingId("account id");
msg.readString(24, "login");
}
diff --git a/src/net/eathena/adminhandler.h b/src/net/eathena/adminhandler.h
index 7faf9b383..e1e76f75f 100644
--- a/src/net/eathena/adminhandler.h
+++ b/src/net/eathena/adminhandler.h
@@ -45,7 +45,7 @@ class AdminHandler final : public MessageHandler, public Ea::AdminHandler
void hide(const bool h) const override final;
- void kick(const int playerId) const override final;
+ void kick(const BeingId playerId) const override final;
void kickAll() const override final;
diff --git a/src/net/eathena/battlegroundhandler.cpp b/src/net/eathena/battlegroundhandler.cpp
index 3444c9434..dd1f6bfe9 100644
--- a/src/net/eathena/battlegroundhandler.cpp
+++ b/src/net/eathena/battlegroundhandler.cpp
@@ -95,7 +95,7 @@ void BattleGroundHandler::handleMessage(Net::MessageIn &msg)
void BattleGroundHandler::processBattleEmblem(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("account id");
+ msg.readBeingId("account id");
msg.readString(24, "name");
msg.readInt16("camp");
}
@@ -110,7 +110,7 @@ void BattleGroundHandler::processBattleUpdateScore(Net::MessageIn &msg)
void BattleGroundHandler::processBattleUpdateCoords(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("account id");
+ msg.readBeingId("account id");
msg.readString(24, "name");
msg.readInt16("class");
msg.readInt16("x");
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index 29b7a2578..9bc79c407 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -142,10 +142,10 @@ BeingHandler::BeingHandler(const bool enableSync) :
beingHandler = this;
}
-void BeingHandler::requestNameById(const int id) const
+void BeingHandler::requestNameById(const BeingId id) const
{
createOutPacket(CMSG_NAME_REQUEST);
- outMsg.writeInt32(id, "being id");
+ outMsg.writeBeingId(id, "being id");
}
void BeingHandler::handleMessage(Net::MessageIn &msg)
@@ -414,7 +414,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
}
Being *BeingHandler::createBeing2(Net::MessageIn &msg,
- const int id,
+ const BeingId id,
const int16_t job,
const BeingType::BeingType beingType)
{
@@ -497,7 +497,7 @@ void BeingHandler::processBeingChangeLook2(Net::MessageIn &msg)
return;
Being *const dstBeing = actorManager->findBeing(
- msg.readInt32("being id"));
+ msg.readBeingId("being id"));
const uint8_t type = msg.readUInt8("type");
const int id = msg.readInt16("id1");
@@ -627,13 +627,13 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
msg.readUInt8("object type"));
// Information about a being in range
- const int id = msg.readInt32("being id");
- int spawnId;
+ const BeingId id = msg.readBeingId("being id");
+ BeingId spawnId;
if (id == mSpawnId)
spawnId = mSpawnId;
else
- spawnId = 0;
- mSpawnId = 0;
+ spawnId = BeingId_zero;
+ mSpawnId = BeingId_zero;
int16_t speed = msg.readInt16("speed");
const uint16_t stunMode = msg.readInt16("opt1");
@@ -673,7 +673,7 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
if (dstBeing->getType() == ActorType::Player)
dstBeing->setMoveTime();
- if (spawnId)
+ if (spawnId != BeingId_zero)
{
dstBeing->setAction(BeingAction::SPAWN, 0);
}
@@ -787,13 +787,13 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
msg.readUInt8("object type"));
// Information about a being in range
- const int id = msg.readInt32("being id");
- int spawnId;
+ const BeingId id = msg.readBeingId("being id");
+ BeingId spawnId;
if (id == mSpawnId)
spawnId = mSpawnId;
else
- spawnId = 0;
- mSpawnId = 0;
+ spawnId = BeingId_zero;
+ mSpawnId = BeingId_zero;
int16_t speed = msg.readInt16("speed");
// if (visible)
// {
@@ -841,7 +841,7 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
if (dstBeing->getType() == ActorType::Player)
dstBeing->setMoveTime();
- if (spawnId)
+ if (spawnId != BeingId_zero)
dstBeing->setAction(BeingAction::SPAWN, 0);
// Prevent division by 0 when calculating frame
@@ -961,9 +961,9 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg)
msg.readUInt8("object type"));
// Information about a being in range
- const int id = msg.readInt32("being id");
+ const BeingId id = msg.readBeingId("being id");
mSpawnId = id;
- const int spawnId = id;
+ const BeingId spawnId = id;
int16_t speed = msg.readInt16("speed");
// if (visible)
// {
@@ -1011,10 +1011,8 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg)
if (dstBeing->getType() == ActorType::Player)
dstBeing->setMoveTime();
- if (spawnId)
- {
+ if (spawnId != BeingId_zero)
dstBeing->setAction(BeingAction::SPAWN, 0);
- }
// Prevent division by 0 when calculating frame
if (speed == 0)
@@ -1138,8 +1136,8 @@ void BeingHandler::processSkillCasting(Net::MessageIn &msg)
{
// +++ need use other parameters
- const int srcId = msg.readInt32("src id");
- const int dstId = msg.readInt32("dst id");
+ const BeingId srcId = msg.readBeingId("src id");
+ const BeingId dstId = msg.readBeingId("dst id");
const int dstX = msg.readInt16("dst x");
const int dstY = msg.readInt16("dst y");
const int skillId = msg.readInt16("skill id");
@@ -1150,12 +1148,12 @@ void BeingHandler::processSkillCasting(Net::MessageIn &msg)
if (!effectManager)
return;
- if (srcId == 0)
+ if (srcId == BeingId_zero)
{
UNIMPLIMENTEDPACKET;
return;
}
- else if (dstId != 0)
+ else if (dstId != BeingId_zero)
{ // being to being
Being *const srcBeing = actorManager->findBeing(srcId);
Being *const dstBeing = actorManager->findBeing(dstId);
@@ -1179,7 +1177,7 @@ void BeingHandler::processBeingStatusChange(Net::MessageIn &msg)
// Status change
const uint16_t status = msg.readInt16("status");
- const int id = msg.readInt32("being id");
+ const BeingId id = msg.readBeingId("being id");
const Enable flag = fromBool(
msg.readUInt8("flag: 0: stop, 1: start"), Enable);
msg.readInt32("total");
@@ -1205,7 +1203,7 @@ void BeingHandler::processBeingStatusChange2(Net::MessageIn &msg)
// Status change
const uint16_t status = msg.readInt16("status");
- const int id = msg.readInt32("being id");
+ const BeingId id = msg.readBeingId("being id");
const Enable flag = fromBool(
msg.readUInt8("flag: 0: stop, 1: start"), Enable);
msg.readInt32("left");
@@ -1233,7 +1231,7 @@ void BeingHandler::processBeingMove2(Net::MessageIn &msg)
* later versions of eAthena for both mobs and
* players
*/
- Being *const dstBeing = actorManager->findBeing(msg.readInt32("being id"));
+ Being *const dstBeing = actorManager->findBeing(msg.readBeingId("being id"));
uint16_t srcX, srcY, dstX, dstY;
msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
@@ -1272,9 +1270,9 @@ void BeingHandler::processBeingAction2(Net::MessageIn &msg)
}
Being *const srcBeing = actorManager->findBeing(
- msg.readInt32("src being id"));
+ msg.readBeingId("src being id"));
Being *const dstBeing = actorManager->findBeing(
- msg.readInt32("dst being id"));
+ msg.readBeingId("dst being id"));
msg.readInt32("tick");
const int srcSpeed = msg.readInt32("src speed");
@@ -1356,7 +1354,7 @@ void BeingHandler::processBeingAction2(Net::MessageIn &msg)
void BeingHandler::processMonsterHp(Net::MessageIn &msg)
{
Being *const dstBeing = actorManager->findBeing(
- msg.readInt32("monster id"));
+ msg.readBeingId("monster id"));
const int hp = msg.readInt32("hp");
const int maxHP = msg.readInt32("max hp");
if (dstBeing)
@@ -1440,7 +1438,7 @@ void BeingHandler::processBeingChangeDirection(Net::MessageIn &msg)
return;
}
- Being *const dstBeing = actorManager->findBeing(msg.readInt32("being id"));
+ Being *const dstBeing = actorManager->findBeing(msg.readBeingId("being id"));
msg.readInt16("head direction");
@@ -1464,7 +1462,7 @@ void BeingHandler::processBeingSpecialEffect(Net::MessageIn &msg)
if (!effectManager || !actorManager)
return;
- const int id = static_cast<uint32_t>(msg.readInt32("being id"));
+ const BeingId id = msg.readBeingId("being id");
Being *const being = actorManager->findBeing(id);
if (!being)
return;
@@ -1487,7 +1485,7 @@ void BeingHandler::processBeingSpecialEffectNum(Net::MessageIn &msg)
UNIMPLIMENTEDPACKET;
// +++ need somhow show this effects.
// type is not same with self/misc effect.
- msg.readInt32("account id");
+ msg.readBeingId("account id");
msg.readInt32("effect type");
msg.readInt32("num"); // effect variable
}
@@ -1539,7 +1537,7 @@ void BeingHandler::viewPlayerEquipment(const Being *const being)
return;
createOutPacket(CMSG_PLAYER_VIEW_EQUIPMENT);
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
}
void BeingHandler::processSkillGroundNoDamage(Net::MessageIn &msg)
@@ -1577,7 +1575,7 @@ void BeingHandler::processPlaterStatusChange(Net::MessageIn &msg)
}
// Change in players' flags
- const int id = msg.readInt32("account id");
+ const BeingId id = msg.readBeingId("account id");
Being *const dstBeing = actorManager->findBeing(id);
if (!dstBeing)
return;
@@ -1600,7 +1598,7 @@ void BeingHandler::processPlaterStatusChange2(Net::MessageIn &msg)
if (!actorManager)
return;
- const int id = msg.readInt32("account id");
+ const BeingId id = msg.readBeingId("account id");
Being *const dstBeing = actorManager->findBeing(id);
if (!dstBeing)
return;
@@ -1618,7 +1616,7 @@ void BeingHandler::processPlaterStatusChange2(Net::MessageIn &msg)
void BeingHandler::processPlaterStatusChangeNoTick(Net::MessageIn &msg)
{
const uint16_t status = msg.readInt16("index");
- const int id = msg.readInt32("account id");
+ const BeingId id = msg.readBeingId("account id");
const Enable flag = fromBool(msg.readUInt8("state")
? true : false, Enable);
@@ -1640,7 +1638,7 @@ void BeingHandler::processBeingResurrect(Net::MessageIn &msg)
// A being changed mortality status
- const int id = msg.readInt32("being id");
+ const BeingId id = msg.readBeingId("being id");
msg.readInt16("unused");
Being *const dstBeing = actorManager->findBeing(id);
if (!dstBeing)
@@ -1666,7 +1664,7 @@ void BeingHandler::processPlayerGuilPartyInfo(Net::MessageIn &msg)
return;
}
- Being *const dstBeing = actorManager->findBeing(msg.readInt32("being id"));
+ Being *const dstBeing = actorManager->findBeing(msg.readBeingId("being id"));
if (dstBeing)
{
@@ -1690,7 +1688,7 @@ void BeingHandler::processBeingFakeName(Net::MessageIn &msg)
{
const BeingType::BeingType type = static_cast<BeingType::BeingType>(
msg.readUInt8("object type"));
- const int id = msg.readInt32("npc id");
+ const BeingId id = msg.readBeingId("npc id");
msg.skip(8, "unused");
const uint16_t job = msg.readInt16("class?"); // 111
msg.skip(30, "unused");
@@ -1709,7 +1707,7 @@ void BeingHandler::processBeingFakeName(Net::MessageIn &msg)
void BeingHandler::processBeingStatUpdate1(Net::MessageIn &msg)
{
- const int id = msg.readInt32("account id");
+ const BeingId id = msg.readBeingId("account id");
const int type = msg.readInt16("type");
const int value = msg.readInt32("value");
@@ -1734,7 +1732,7 @@ void BeingHandler::processBeingSelfEffect(Net::MessageIn &msg)
return;
}
- const int id = static_cast<uint32_t>(msg.readInt32("being id"));
+ const BeingId id = msg.readBeingId("being id");
Being *const being = actorManager->findBeing(id);
if (!being)
{
@@ -1755,7 +1753,7 @@ void BeingHandler::processMobInfo(Net::MessageIn &msg)
if (len < 12)
return;
Being *const dstBeing = actorManager->findBeing(
- msg.readInt32("monster id"));
+ msg.readBeingId("monster id"));
const int attackRange = msg.readInt32("range");
if (dstBeing)
dstBeing->setAttackRange(attackRange);
@@ -1767,7 +1765,7 @@ void BeingHandler::processBeingAttrs(Net::MessageIn &msg)
if (len < 12)
return;
Being *const dstBeing = actorManager->findBeing(
- msg.readInt32("player id"));
+ msg.readBeingId("player id"));
const int gmLevel = msg.readInt32("gm level");
if (dstBeing && gmLevel)
{
@@ -1802,7 +1800,7 @@ void BeingHandler::processClassChange(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("being id");
+ msg.readBeingId("being id");
msg.readUInt8("type");
msg.readInt32("class");
}
@@ -1811,7 +1809,7 @@ void BeingHandler::processSpiritBalls(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("being id");
+ msg.readBeingId("being id");
msg.readInt16("spirits amount");
}
@@ -1819,7 +1817,7 @@ void BeingHandler::processSpiritBallSingle(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("being id");
+ msg.readBeingId("being id");
msg.readInt16("spirits amount");
}
@@ -1836,7 +1834,7 @@ void BeingHandler::processComboDelay(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("being id");
+ msg.readBeingId("being id");
msg.readInt32("wait");
}
@@ -1844,14 +1842,14 @@ void BeingHandler::processWddingEffect(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("being id");
+ msg.readBeingId("being id");
}
void BeingHandler::processBeingSlide(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("being id");
+ msg.readBeingId("being id");
msg.readInt16("x");
msg.readInt16("y");
}
@@ -1891,7 +1889,7 @@ void BeingHandler::processBeingFont(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("account id");
+ msg.readBeingId("account id");
msg.readInt16("font");
}
@@ -1899,7 +1897,7 @@ void BeingHandler::processBeingMilleniumShield(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("account id");
+ msg.readBeingId("account id");
msg.readInt16("shields");
msg.readInt16("unused");
}
@@ -1908,7 +1906,7 @@ void BeingHandler::processBeingCharm(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("account id");
+ msg.readBeingId("account id");
msg.readInt16("charm type");
msg.readInt16("charm count");
}
diff --git a/src/net/eathena/beinghandler.h b/src/net/eathena/beinghandler.h
index f6fb1df78..e60318314 100644
--- a/src/net/eathena/beinghandler.h
+++ b/src/net/eathena/beinghandler.h
@@ -40,7 +40,7 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler
void handleMessage(Net::MessageIn &msg) override final;
- void requestNameById(const int id) const override final;
+ void requestNameById(const BeingId id) const override final;
void undress(Being *const being) const override final;
@@ -48,7 +48,7 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler
protected:
static Being *createBeing2(Net::MessageIn &msg,
- const int id,
+ const BeingId id,
const int16_t job,
const BeingType::BeingType beingType);
diff --git a/src/net/eathena/buyingstorehandler.cpp b/src/net/eathena/buyingstorehandler.cpp
index a68111dc1..baaee1aca 100644
--- a/src/net/eathena/buyingstorehandler.cpp
+++ b/src/net/eathena/buyingstorehandler.cpp
@@ -150,7 +150,7 @@ void BuyingStoreHandler::processBuyingStoreCreateFailed(Net::MessageIn &msg)
void BuyingStoreHandler::processBuyingStoreOwnItems(Net::MessageIn &msg)
{
const int count = (msg.readInt16("len") - 12) / 9;
- msg.readInt32("account id");
+ msg.readBeingId("account id");
msg.readInt32("money limit");
for (int f = 0; f < count; f ++)
{
@@ -165,7 +165,7 @@ void BuyingStoreHandler::processBuyingStoreOwnItems(Net::MessageIn &msg)
void BuyingStoreHandler::processBuyingStoreShowBoard(Net::MessageIn &msg)
{
- const int id = msg.readInt32("owner id");
+ const BeingId id = msg.readBeingId("owner id");
const std::string shopName = msg.readString(80, "shop name");
Being *const dstBeing = actorManager->findBeing(id);
if (dstBeing)
@@ -174,7 +174,7 @@ void BuyingStoreHandler::processBuyingStoreShowBoard(Net::MessageIn &msg)
void BuyingStoreHandler::processBuyingStoreHideBoard(Net::MessageIn &msg)
{
- const int id = msg.readInt32("owner id");
+ const BeingId id = msg.readBeingId("owner id");
Being *const dstBeing = actorManager->findBeing(id);
if (dstBeing)
dstBeing->setBuyBoard(std::string());
@@ -188,7 +188,7 @@ void BuyingStoreHandler::processBuyingStoreHideBoard(Net::MessageIn &msg)
void BuyingStoreHandler::processBuyingStoreItemsList(Net::MessageIn &msg)
{
const int count = (msg.readInt16("len") - 16) / 9;
- const int id = msg.readInt32("account id");
+ const BeingId id = msg.readBeingId("account id");
const int storeId = msg.readInt32("store id");
// +++ in future need use it too
msg.readInt32("money limit");
@@ -321,7 +321,7 @@ void BuyingStoreHandler::open(const Being *const being) const
if (!being)
return;
createOutPacket(CMSG_BUYINGSTORE_OPEN);
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
}
void BuyingStoreHandler::sell(const Being *const being,
@@ -334,7 +334,7 @@ void BuyingStoreHandler::sell(const Being *const being,
createOutPacket(CMSG_BUYINGSTORE_SELL);
outMsg.writeInt16(18, "len");
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
outMsg.writeInt32(storeId, "store id");
outMsg.writeInt16(static_cast<int16_t>(
item->getInvIndex() + INVENTORY_OFFSET),
diff --git a/src/net/eathena/cashshophandler.cpp b/src/net/eathena/cashshophandler.cpp
index 90eb1b2af..c2b872eca 100644
--- a/src/net/eathena/cashshophandler.cpp
+++ b/src/net/eathena/cashshophandler.cpp
@@ -95,7 +95,7 @@ void CashShopHandler::processCashShopOpen(Net::MessageIn &msg)
{
const int count = (msg.readInt16("len") - 12) / 11;
- mBuyDialog = new BuyDialog(BuyDialog::Cash);
+ mBuyDialog = new BuyDialog(fromInt(BuyDialog::Cash, BeingId));
mBuyDialog->postInit();
mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
index 0a634c80f..f94e3a34f 100644
--- a/src/net/eathena/charserverhandler.cpp
+++ b/src/net/eathena/charserverhandler.cpp
@@ -64,8 +64,8 @@ extern ServerInfo mapServer;
std::string CharServerHandler::mNewName;
uint32_t CharServerHandler::mPinSeed = 0;
-uint32_t CharServerHandler::mPinAccountId = 0;
-uint32_t CharServerHandler::mRenameId = 0;
+BeingId CharServerHandler::mPinAccountId = BeingId_zero;
+BeingId CharServerHandler::mRenameId = BeingId_zero;
bool CharServerHandler::mNeedCreatePin = false;
CharServerHandler::CharServerHandler() :
@@ -74,8 +74,8 @@ CharServerHandler::CharServerHandler() :
{
mNewName.clear();
mPinSeed = 0;
- mPinAccountId = 0;
- mRenameId = 0;
+ mPinAccountId = BeingId_zero;
+ mRenameId = BeingId_zero;
mNeedCreatePin = false;
static const uint16_t _messages[] =
@@ -201,7 +201,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
static_cast<LoginHandler*>(loginHandler)->getToken();
LocalPlayer *const tempPlayer = new LocalPlayer(
- msg.readInt32("player id"), 0);
+ msg.readBeingId("player id"), 0);
tempPlayer->setGender(token.sex);
PlayerInfoBackend &data = character->data;
@@ -337,7 +337,7 @@ void CharServerHandler::deleteCharacter(Net::Character *const character,
mSelectedCharacter = character;
createOutPacket(CMSG_CHAR_DELETE);
- outMsg.writeInt32(mSelectedCharacter->dummy->getId(), "id?");
+ outMsg.writeBeingId(mSelectedCharacter->dummy->getId(), "id?");
if (email.empty())
outMsg.writeString("a@a.com", 40, "email");
else
@@ -362,7 +362,7 @@ void CharServerHandler::connect()
mNetwork->disconnect();
mNetwork->connect(charServer);
createOutPacket(CMSG_CHAR_SERVER_CONNECT);
- outMsg.writeInt32(token.account_ID, "account id");
+ outMsg.writeBeingId(token.account_ID, "account id");
outMsg.writeInt32(token.session_ID1, "session id1");
outMsg.writeInt32(token.session_ID2, "session id2");
outMsg.writeInt16(CLIENT_PROTOCOL_VERSION, "client protocol version");
@@ -497,7 +497,7 @@ void CharServerHandler::processChangeMapServer(Net::MessageIn &msg)
void CharServerHandler::processPincodeStatus(Net::MessageIn &msg)
{
mPinSeed = msg.readInt32("pincode seed");
- mPinAccountId = msg.readInt32("account id");
+ mPinAccountId = msg.readBeingId("account id");
const uint16_t state = static_cast<uint16_t>(msg.readInt16("state"));
switch (state)
{
@@ -532,7 +532,7 @@ void CharServerHandler::setNewPincode(const std::string &pin A_UNUSED)
// here need ecript pin with mPinSeed and pin values.
// createOutPacket(CMSG_CHAR_CREATE_PIN);
-// outMsg.writeInt32(mPinAccountId, "account id");
+// outMsg.writeBeingId(mPinAccountId, "account id");
// outMsg.writeString(pin, 4, "encrypted pin");
}
@@ -554,13 +554,13 @@ void CharServerHandler::processCharCreate(Net::MessageIn &msg)
BLOCK_END("CharServerHandler::processCharCreate")
}
-void CharServerHandler::renameCharacter(const int id,
+void CharServerHandler::renameCharacter(const BeingId id,
const std::string &newName)
{
createOutPacket(CMSG_CHAR_CHECK_RENAME);
mRenameId = id;
mNewName = newName;
- outMsg.writeInt32(id, "char id");
+ outMsg.writeBeingId(id, "char id");
outMsg.writeString(newName, 24, "name");
}
@@ -569,7 +569,7 @@ void CharServerHandler::processCharCheckRename(Net::MessageIn &msg)
if (msg.readInt16("flag"))
{
createOutPacket(CMSG_CHAR_RENAME);
- outMsg.writeInt32(mRenameId, "char id");
+ outMsg.writeBeingId(mRenameId, "char id");
}
else
{
diff --git a/src/net/eathena/charserverhandler.h b/src/net/eathena/charserverhandler.h
index 6254f9d2c..64968cee4 100644
--- a/src/net/eathena/charserverhandler.h
+++ b/src/net/eathena/charserverhandler.h
@@ -54,7 +54,7 @@ class CharServerHandler final : public MessageHandler,
const uint16_t look,
const std::vector<int> &stats) const override final;
- void renameCharacter(const int id,
+ void renameCharacter(const BeingId id,
const std::string &newName) override final;
void deleteCharacter(Net::Character *const character,
@@ -123,8 +123,8 @@ class CharServerHandler final : public MessageHandler,
private:
static std::string mNewName;
static uint32_t mPinSeed;
- static uint32_t mPinAccountId;
- static uint32_t mRenameId;
+ static BeingId mPinAccountId;
+ static BeingId mRenameId;
static bool mNeedCreatePin;
};
diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp
index 9db670080..d31afa3c9 100644
--- a/src/net/eathena/chathandler.cpp
+++ b/src/net/eathena/chathandler.cpp
@@ -663,7 +663,7 @@ void ChatHandler::processChatDisplay(Net::MessageIn &msg)
{
const int len = msg.readInt16("len") - 17;
ChatObject *const obj = new ChatObject;
- obj->ownerId = msg.readInt32("owner account id");
+ obj->ownerId = msg.readBeingId("owner account id");
obj->chatId = msg.readInt32("chat id");
obj->maxUsers = msg.readInt16("max users");
obj->currentUsers = msg.readInt16("current users");
@@ -839,7 +839,7 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg)
BLOCK_START("ChatHandler::processBeingChat")
int chatMsgLength = msg.readInt16("len") - 8;
- Being *const being = actorManager->findBeing(msg.readInt32("being id"));
+ Being *const being = actorManager->findBeing(msg.readBeingId("being id"));
if (chatMsgLength <= 0)
{
@@ -992,7 +992,7 @@ void ChatHandler::processChatRoomAddMember(Net::MessageIn &msg)
void ChatHandler::processChatRoomSettings(Net::MessageIn &msg)
{
const int sz = msg.readInt16("len") - 17;
- const int ownerId = msg.readInt32("owner id");
+ const BeingId ownerId = msg.readBeingId("owner id");
const int chatId = msg.readInt32("chat id");
const uint16_t limit = msg.readInt16("limit");
msg.readInt16("users");
@@ -1086,7 +1086,7 @@ void ChatHandler::processChatSilence(Net::MessageIn &msg)
void ChatHandler::processChatTalkieBox(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("being id");
+ msg.readBeingId("being id");
msg.readString(80, "message");
}
@@ -1094,7 +1094,7 @@ void ChatHandler::processBattleChatMessage(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
const int sz = msg.readInt16("len") - 24 - 8;
- msg.readInt32("account id");
+ msg.readBeingId("account id");
msg.readString(24, "nick");
msg.readString(sz, "message");
}
@@ -1103,7 +1103,7 @@ void ChatHandler::processScriptMessage(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
const int sz = msg.readInt16("len") - 8;
- msg.readInt32("being id");
+ msg.readBeingId("being id");
msg.readString(sz, "message");
}
diff --git a/src/net/eathena/familyhandler.cpp b/src/net/eathena/familyhandler.cpp
index 5b482639f..a21de5ec2 100644
--- a/src/net/eathena/familyhandler.cpp
+++ b/src/net/eathena/familyhandler.cpp
@@ -86,7 +86,7 @@ void FamilyHandler::askForChild(const Being *const being)
return;
createOutPacket(CMSG_FAMILY_ASK_FOR_CHILD);
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
}
void FamilyHandler::processAskForChild(Net::MessageIn &msg)
diff --git a/src/net/eathena/friendshandler.cpp b/src/net/eathena/friendshandler.cpp
index 91f08a205..43634d9fc 100644
--- a/src/net/eathena/friendshandler.cpp
+++ b/src/net/eathena/friendshandler.cpp
@@ -80,7 +80,7 @@ void FriendsHandler::handleMessage(Net::MessageIn &msg)
void FriendsHandler::processPlayerOnline(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("account id");
+ msg.readBeingId("account id");
msg.readInt32("char id");
msg.readUInt8("flag"); // 0 - online, 1 - offline
}
@@ -91,7 +91,7 @@ void FriendsHandler::processFriendsList(Net::MessageIn &msg)
const int count = (msg.readInt16("size") - 4) / 32;
for (int f = 0; f < count; f ++)
{
- msg.readInt32("account id");
+ msg.readBeingId("account id");
msg.readInt32("char id");
msg.readString(24, "name");
}
@@ -101,7 +101,7 @@ void FriendsHandler::processRequestAck(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
msg.readInt16("type");
- msg.readInt32("account id");
+ msg.readBeingId("account id");
msg.readInt32("char id");
msg.readString(24, "name");
}
@@ -109,7 +109,7 @@ void FriendsHandler::processRequestAck(Net::MessageIn &msg)
void FriendsHandler::processRequest(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("account id");
+ msg.readBeingId("account id");
msg.readInt32("char id");
msg.readString(24, "name");
}
@@ -140,7 +140,7 @@ void FriendsHandler::remove(const int accountId, const int charId) const
void FriendsHandler::processDeletePlayer(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("account id");
+ msg.readBeingId("account id");
msg.readInt32("char id");
}
diff --git a/src/net/eathena/gamehandler.cpp b/src/net/eathena/gamehandler.cpp
index 2f425b52c..7fa94ab48 100644
--- a/src/net/eathena/gamehandler.cpp
+++ b/src/net/eathena/gamehandler.cpp
@@ -125,14 +125,14 @@ void GameHandler::connect()
}
else
{
- mCharID = 0;
+ mCharID = BeingId_zero;
}
}
// Send login infos
createOutPacket(CMSG_MAP_SERVER_CONNECT);
- outMsg.writeInt32(token.account_ID, "account id");
- outMsg.writeInt32(mCharID, "char id");
+ outMsg.writeBeingId(token.account_ID, "account id");
+ outMsg.writeBeingId(mCharID, "char id");
outMsg.writeInt32(token.session_ID1, "session key1");
outMsg.writeInt32(0, "tick");
outMsg.writeInt8(Being::genderToInt(token.sex), "sex");
@@ -180,7 +180,7 @@ void GameHandler::disconnect2() const
void GameHandler::processMapAccountId(Net::MessageIn &msg)
{
// ignored, because we already know local player account id.
- msg.readInt32("account id");
+ msg.readBeingId("account id");
}
void GameHandler::processMapLogin(Net::MessageIn &msg)
diff --git a/src/net/eathena/guildhandler.cpp b/src/net/eathena/guildhandler.cpp
index 1a6c29b80..85609581b 100644
--- a/src/net/eathena/guildhandler.cpp
+++ b/src/net/eathena/guildhandler.cpp
@@ -210,7 +210,7 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
void GuildHandler::processGuildUpdateCoords(Net::MessageIn &msg)
{
- const int id = msg.readInt32("account id");
+ const BeingId id = msg.readBeingId("account id");
const int x = msg.readInt16("x");
const int y = msg.readInt16("y");
if (Ea::taGuild)
@@ -241,7 +241,7 @@ void GuildHandler::invite(const std::string &name) const
if (being)
{
createOutPacket(CMSG_GUILD_INVITE);
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
outMsg.writeInt32(0, "unused");
outMsg.writeInt32(0, "unused");
}
@@ -253,7 +253,7 @@ void GuildHandler::invite(const Being *const being) const
return;
createOutPacket(CMSG_GUILD_INVITE);
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
outMsg.writeInt32(0, "unused");
outMsg.writeInt32(0, "unused");
}
@@ -275,7 +275,7 @@ void GuildHandler::leave(const int guildId) const
createOutPacket(CMSG_GUILD_LEAVE);
outMsg.writeInt32(guildId, "guild id");
- outMsg.writeInt32(localPlayer->getId(), "account id");
+ outMsg.writeBeingId(localPlayer->getId(), "account id");
outMsg.writeInt32(PlayerInfo::getCharId(), "char id");
outMsg.writeString("", 40, "message");
}
@@ -288,7 +288,7 @@ void GuildHandler::kick(const GuildMember *restrict const member,
createOutPacket(CMSG_GUILD_EXPULSION);
outMsg.writeInt32(member->getGuild()->getId(), "guild id");
- outMsg.writeInt32(member->getID(), "account id");
+ outMsg.writeBeingId(member->getID(), "account id");
outMsg.writeInt32(member->getCharId(), "char id");
outMsg.writeString(reason, 40, "message");
}
@@ -339,7 +339,7 @@ void GuildHandler::changeMemberPostion(const GuildMember *const member,
createOutPacket(CMSG_GUILD_CHANGE_MEMBER_POS);
outMsg.writeInt16(16, "len");
- outMsg.writeInt32(member->getID(), "account id");
+ outMsg.writeBeingId(member->getID(), "account id");
outMsg.writeInt32(member->getCharId(), "char id");
outMsg.writeInt32(level, "pos");
}
@@ -396,7 +396,7 @@ void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg)
void GuildHandler::processGuildMemberLogin(Net::MessageIn &msg)
{
- const int accountId = msg.readInt32("account id");
+ const BeingId accountId = msg.readBeingId("account id");
const int charId = msg.readInt32("char id");
const int online = msg.readInt32("flag");
const Gender::Type gender = Being::intToGender(static_cast<uint8_t>(
@@ -445,7 +445,7 @@ void GuildHandler::processGuildExpulsionList(Net::MessageIn &msg)
void GuildHandler::processGuildEmblem(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("being id");
+ msg.readBeingId("being id");
msg.readInt32("guild id");
msg.readInt16("emblem id");
}
@@ -456,7 +456,7 @@ void GuildHandler::requestAlliance(const Being *const being) const
return;
createOutPacket(CMSG_GUILD_ALLIANCE_REQUEST);
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
outMsg.writeInt32(0, "inviter account id");
outMsg.writeInt32(0, "inviter char id");
}
@@ -498,7 +498,7 @@ void GuildHandler::requestOpposition(const Being *const being) const
return;
createOutPacket(CMSG_GUILD_OPPOSITION);
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
}
void GuildHandler::breakGuild(const std::string &name) const
diff --git a/src/net/eathena/homunculushandler.cpp b/src/net/eathena/homunculushandler.cpp
index 2bfe358c2..e2441ac14 100644
--- a/src/net/eathena/homunculushandler.cpp
+++ b/src/net/eathena/homunculushandler.cpp
@@ -127,7 +127,7 @@ void HomunculusHandler::processHomunculusData(Net::MessageIn &msg)
{
msg.readUInt8("unused");
const int cmd = msg.readUInt8("state");
- const int id = msg.readInt32("homunculus id");
+ const BeingId id = msg.readBeingId("homunculus id");
Being *const dstBeing = actorManager->findBeing(id);
const int data = msg.readInt32("data");
if (!cmd) // pre init
@@ -243,33 +243,34 @@ void HomunculusHandler::setName(const std::string &name) const
void HomunculusHandler::moveToMaster() const
{
- const int id = PlayerInfo::getHomunculusId();
- if (!id)
+ const BeingId id = PlayerInfo::getHomunculusId();
+ if (id == BeingId_zero)
return;
createOutPacket(CMSG_HOMMERC_MOVE_TO_MASTER);
- outMsg.writeInt32(id, "homunculus id");
+ outMsg.writeBeingId(id, "homunculus id");
}
void HomunculusHandler::move(const int x, const int y) const
{
- const int id = PlayerInfo::getHomunculusId();
- if (!id)
+ const BeingId id = PlayerInfo::getHomunculusId();
+ if (id == BeingId_zero)
return;
createOutPacket(CMSG_HOMMERC_MOVE_TO);
- outMsg.writeInt32(id, "homunculus id");
+ outMsg.writeBeingId(id, "homunculus id");
outMsg.writeCoordinates(static_cast<uint16_t>(x),
static_cast<uint16_t>(y),
0U, "position");
}
-void HomunculusHandler::attack(const int targetId, const Keep keep) const
+void HomunculusHandler::attack(const BeingId targetId,
+ const Keep keep) const
{
- const int id = PlayerInfo::getHomunculusId();
- if (!id)
+ const BeingId id = PlayerInfo::getHomunculusId();
+ if (id == BeingId_zero)
return;
createOutPacket(CMSG_HOMMERC_ATTACK);
- outMsg.writeInt32(id, "homunculus id");
- outMsg.writeInt32(targetId, "target id");
+ outMsg.writeBeingId(id, "homunculus id");
+ outMsg.writeBeingId(targetId, "target id");
outMsg.writeInt8(static_cast<int8_t>(keep == Keep_true ? 1 : 0), "keep");
}
diff --git a/src/net/eathena/homunculushandler.h b/src/net/eathena/homunculushandler.h
index 5b288eeb6..35955b0ba 100644
--- a/src/net/eathena/homunculushandler.h
+++ b/src/net/eathena/homunculushandler.h
@@ -45,7 +45,8 @@ class HomunculusHandler final : public MessageHandler,
void move(const int x, const int y) const override final;
- void attack(const int targetId, const Keep keep) const override final;
+ void attack(const BeingId targetId,
+ const Keep keep) const override final;
void feed() const override final;
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
index 3781678cd..186bb5fc5 100644
--- a/src/net/eathena/inventoryhandler.cpp
+++ b/src/net/eathena/inventoryhandler.cpp
@@ -489,10 +489,10 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
msg.readInt16("bind on equip");
const ItemInfo &itemInfo = ItemDB::get(itemId);
- int floorId;
+ BeingId floorId;
if (mSentPickups.empty())
{
- floorId = 0;
+ floorId = BeingId_zero;
}
else
{
@@ -1107,7 +1107,7 @@ void InventoryHandler::processItemDamaged(Net::MessageIn &msg)
UNIMPLIMENTEDPACKET;
msg.readInt16("position");
- msg.readInt32("account id");
+ msg.readBeingId("account id");
}
void InventoryHandler::processFavoriteItem(Net::MessageIn &msg)
diff --git a/src/net/eathena/itemhandler.cpp b/src/net/eathena/itemhandler.cpp
index 0a1629517..ce5dfadfb 100644
--- a/src/net/eathena/itemhandler.cpp
+++ b/src/net/eathena/itemhandler.cpp
@@ -79,7 +79,7 @@ void ItemHandler::handleMessage(Net::MessageIn &msg)
void ItemHandler::processItemDropped(Net::MessageIn &msg)
{
- const int id = msg.readInt32("id");
+ const BeingId id = msg.readBeingId("id");
const int itemId = msg.readInt16("item id");
msg.readInt16("type");
const uint8_t identify = msg.readUInt8("identify");
diff --git a/src/net/eathena/markethandler.cpp b/src/net/eathena/markethandler.cpp
index 175429cda..12beafd98 100644
--- a/src/net/eathena/markethandler.cpp
+++ b/src/net/eathena/markethandler.cpp
@@ -77,7 +77,7 @@ void MarketHandler::processMarketOpen(Net::MessageIn &msg)
{
const int len = (msg.readInt16("len") - 4) / 13;
- mBuyDialog = new BuyDialog(BuyDialog::Market);
+ mBuyDialog = new BuyDialog(fromInt(BuyDialog::Market, BeingId));
mBuyDialog->postInit();
mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
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<uint16_t>(x),
static_cast<uint16_t>(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<int8_t>(keep == Keep_true ? 1 : 0), "keep");
}
diff --git a/src/net/eathena/mercenaryhandler.h b/src/net/eathena/mercenaryhandler.h
index a24f414ff..643f4ec74 100644
--- a/src/net/eathena/mercenaryhandler.h
+++ b/src/net/eathena/mercenaryhandler.h
@@ -45,7 +45,8 @@ class MercenaryHandler final : public MessageHandler,
void move(const int x, const int y) const override final;
- void attack(const int targetId, const Keep keep) const override final;
+ void attack(const BeingId targetId,
+ const Keep keep) const override final;
void talk(const std::string &restrict text) const override final;
diff --git a/src/net/eathena/messagein.cpp b/src/net/eathena/messagein.cpp
index fda86254a..03b8ddd3a 100644
--- a/src/net/eathena/messagein.cpp
+++ b/src/net/eathena/messagein.cpp
@@ -105,6 +105,11 @@ int32_t MessageIn::readInt32(const char *const str)
return value;
}
+BeingId MessageIn::readBeingId(const char *const str)
+{
+ return fromInt(readInt32(str), BeingId);
+}
+
int64_t MessageIn::readInt64(const char *const str)
{
int64_t value = -1;
diff --git a/src/net/eathena/messagein.h b/src/net/eathena/messagein.h
index 1a674e129..fb20b6db7 100644
--- a/src/net/eathena/messagein.h
+++ b/src/net/eathena/messagein.h
@@ -54,6 +54,8 @@ class MessageIn final : public Net::MessageIn
int64_t readInt64(const char *const str) override final;
+ BeingId readBeingId(const char *const str) override final;
+
uint16_t readId();
};
diff --git a/src/net/eathena/messageout.cpp b/src/net/eathena/messageout.cpp
index 084db9418..8ecf8e863 100644
--- a/src/net/eathena/messageout.cpp
+++ b/src/net/eathena/messageout.cpp
@@ -83,6 +83,11 @@ void MessageOut::writeInt32(const int32_t value, const char *const str)
PacketCounters::incOutBytes(4);
}
+void MessageOut::writeBeingId(const BeingId value, const char *const str)
+{
+ writeInt32(toInt(value, int32_t), str);
+}
+
#define LOBYTE(w) (static_cast<unsigned char>(w))
#define HIBYTE(w) (static_cast<unsigned char>(( \
static_cast<uint16_t>(w)) >> 8))
diff --git a/src/net/eathena/messageout.h b/src/net/eathena/messageout.h
index 11b124e26..4c0074767 100644
--- a/src/net/eathena/messageout.h
+++ b/src/net/eathena/messageout.h
@@ -56,6 +56,9 @@ class MessageOut final : public Net::MessageOut
void writeInt32(const int32_t value,
const char *const str) override final;
+ void writeBeingId(const BeingId value,
+ const char *const str) override final;
+
/**
* Encodes coordinates and direction in 3 bytes.
*/
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);
diff --git a/src/net/eathena/npchandler.h b/src/net/eathena/npchandler.h
index 16e656497..e69366c09 100644
--- a/src/net/eathena/npchandler.h
+++ b/src/net/eathena/npchandler.h
@@ -39,30 +39,32 @@ class NpcHandler final : public MessageHandler, public Ea::NpcHandler
void handleMessage(Net::MessageIn &msg) override final;
- void talk(const int npcId) const override final;
+ void talk(const BeingId npcId) const override final;
- void nextDialog(const int npcId) const override final;
+ void nextDialog(const BeingId npcId) const override final;
- void closeDialog(const int npcId) override final;
+ void closeDialog(const BeingId npcId) override final;
- void listInput(const int npcId,
+ void listInput(const BeingId npcId,
const unsigned char value) const override final;
- void integerInput(const int npcId,
+ void integerInput(const BeingId npcId,
const int value) const override final;
- void stringInput(const int npcId,
+ void stringInput(const BeingId npcId,
const std::string &value) const override final;
- void buy(const int beingId) const override final;
+ void buy(const BeingId beingId) const override final;
- void sell(const int beingId) const override final;
+ void sell(const BeingId beingId) const override final;
- void buyItem(const int beingId, const int itemId,
+ void buyItem(const BeingId beingId,
+ const int itemId,
const unsigned char color,
const int amount) const override final;
- void sellItem(const int beingId, const int itemId,
+ void sellItem(const BeingId beingId,
+ const int itemId,
const int amount) const override final;
void completeProgressBar() const override final;
@@ -79,7 +81,7 @@ class NpcHandler final : public MessageHandler, public Ea::NpcHandler
void refine(const int index) const override final;
- int getNpc(Net::MessageIn &msg) override final;
+ BeingId getNpc(Net::MessageIn &msg) override final;
void identify(const int index) const override final;
diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp
index 5f859d12e..d886270ae 100644
--- a/src/net/eathena/partyhandler.cpp
+++ b/src/net/eathena/partyhandler.cpp
@@ -134,7 +134,7 @@ void PartyHandler::invite(const std::string &name) const
if (being)
{
createOutPacket(CMSG_PARTY_INVITE);
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
}
else
{
@@ -165,7 +165,7 @@ void PartyHandler::kick(const Being *const being) const
if (being)
{
createOutPacket(CMSG_PARTY_KICK);
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
outMsg.writeString(being->getName(), 24, "player name");
}
}
@@ -183,7 +183,7 @@ void PartyHandler::kick(const std::string &name) const
}
createOutPacket(CMSG_PARTY_KICK);
- outMsg.writeInt32(m->getID(), "account id");
+ outMsg.writeBeingId(m->getID(), "account id");
outMsg.writeString(name, 24, "player name");
}
@@ -228,7 +228,7 @@ void PartyHandler::processPartyInvitationStats(Net::MessageIn &msg)
void PartyHandler::processPartyMemberInfo(Net::MessageIn &msg)
{
- const int id = msg.readInt32("account id");
+ const BeingId id = msg.readBeingId("account id");
const bool leader = msg.readInt32("leader") == 0U;
const int x = msg.readInt16("x");
const int y = msg.readInt16("y");
@@ -320,7 +320,7 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg)
for (int i = 0; i < count; i++)
{
- const int id = msg.readInt32("account id");
+ const BeingId id = msg.readBeingId("account id");
std::string nick = msg.readString(24, "nick");
std::string map = msg.readString(16, "map name");
const bool leader = msg.readUInt8("leader") == 0U;
@@ -384,7 +384,7 @@ void PartyHandler::processPartyMessage(Net::MessageIn &msg)
if (msgLength <= 0)
return;
- const int id = msg.readInt32("id");
+ const BeingId id = msg.readBeingId("id");
std::string chatMsg = msg.readString(msgLength, "message");
const size_t pos = chatMsg.find(" : ", 0);
@@ -455,7 +455,7 @@ void PartyHandler::changeLeader(const std::string &name) const
if (!being)
return;
createOutPacket(CMSG_PARTY_CHANGE_LEADER);
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
}
void PartyHandler::allowInvite(const bool allow) const
@@ -469,7 +469,7 @@ void PartyHandler::processPartyItemPickup(Net::MessageIn &msg)
UNIMPLIMENTEDPACKET;
// +++ probably need add option to show pickup notifications
// in party tab
- msg.readInt32("account id");
+ msg.readBeingId("account id");
msg.readInt16("item id");
msg.readUInt8("identify");
msg.readUInt8("attribute");
@@ -483,9 +483,9 @@ void PartyHandler::processPartyItemPickup(Net::MessageIn &msg)
void PartyHandler::processPartyLeader(Net::MessageIn &msg)
{
PartyMember *const oldMember = Ea::taParty->getMember(
- msg.readInt32("old leder id"));
+ msg.readBeingId("old leder id"));
PartyMember *const newMember = Ea::taParty->getMember(
- msg.readInt32("new leder id"));
+ msg.readBeingId("new leder id"));
if (oldMember)
oldMember->setLeader(false);
if (newMember)
@@ -494,11 +494,23 @@ void PartyHandler::processPartyLeader(Net::MessageIn &msg)
void PartyHandler::processPartyInvited(Net::MessageIn &msg)
{
- const int id = msg.readInt32("account id");
+ const BeingId id = msg.readBeingId("account id");
const std::string partyName = msg.readString(24, "party name");
+ std::string nick;
+
+ if (actorManager)
+ {
+ const Being *const being = actorManager->findBeing(id);
+ if (being)
+ {
+ if (being->getType() == ActorType::Player)
+ nick = being->getName();
+ }
+ }
+
if (socialWindow)
- socialWindow->showPartyInvite(partyName, "", id);
+ socialWindow->showPartyInvite(partyName, nick, 0);
}
} // namespace EAthena
diff --git a/src/net/eathena/pethandler.cpp b/src/net/eathena/pethandler.cpp
index 71d4d17f2..32f902e80 100644
--- a/src/net/eathena/pethandler.cpp
+++ b/src/net/eathena/pethandler.cpp
@@ -143,7 +143,7 @@ void PetHandler::catchPet(const Being *const being) const
return;
createOutPacket(CMSG_PET_CATCH);
- outMsg.writeInt32(being->getId(), "monster id");
+ outMsg.writeBeingId(being->getId(), "monster id");
}
void PetHandler::sendPetMessage(const int data) const
@@ -160,7 +160,7 @@ void PetHandler::setName(const std::string &name) const
void PetHandler::processPetMessage(Net::MessageIn &msg)
{
- const int id = msg.readInt32("pet id");
+ const BeingId id = msg.readBeingId("pet id");
const int data = msg.readInt32("param");
Being *const dstBeing = actorManager->findBeing(id);
if (!dstBeing)
@@ -228,7 +228,7 @@ void PetHandler::processEggsList(Net::MessageIn &msg)
void PetHandler::processPetData(Net::MessageIn &msg)
{
const int cmd = msg.readUInt8("type");
- const int id = msg.readInt32("pet id");
+ const BeingId id = msg.readBeingId("pet id");
Being *const dstBeing = actorManager->findBeing(id);
const int data = msg.readInt32("data");
if (!cmd) // pre init
diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp
index a2bb8b83e..a4e4586f2 100644
--- a/src/net/eathena/playerhandler.cpp
+++ b/src/net/eathena/playerhandler.cpp
@@ -205,10 +205,11 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
}
}
-void PlayerHandler::attack(const int id, const Keep keep) const
+void PlayerHandler::attack(const BeingId id,
+ const Keep keep) const
{
createOutPacket(CMSG_PLAYER_CHANGE_ACT);
- outMsg.writeInt32(id, "target id");
+ outMsg.writeBeingId(id, "target id");
if (keep == Keep_true)
outMsg.writeInt8(7, "action");
else
@@ -251,7 +252,7 @@ void PlayerHandler::pickUp(const FloorItem *const floorItem) const
return;
createOutPacket(CMSG_ITEM_PICKUP);
- outMsg.writeInt32(floorItem->getId(), "object id");
+ outMsg.writeBeingId(floorItem->getId(), "object id");
EAthena::InventoryHandler *const handler =
static_cast<EAthena::InventoryHandler*>(inventoryHandler);
if (handler)
@@ -484,7 +485,7 @@ void PlayerHandler::processPlayerGetExp(Net::MessageIn &msg)
{
if (!localPlayer)
return;
- const int id = msg.readInt32("player id");
+ const BeingId id = msg.readBeingId("player id");
const int exp = msg.readInt32("exp amount");
const int stat = msg.readInt16("exp type");
const bool fromQuest = msg.readInt16("is from quest");
@@ -538,7 +539,7 @@ void PlayerHandler::processPvpInfo(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
msg.readInt32("char id");
- msg.readInt32("account id");
+ msg.readBeingId("account id");
msg.readInt32("pvp won");
msg.readInt32("pvp lost");
msg.readInt32("pvp point");
diff --git a/src/net/eathena/playerhandler.h b/src/net/eathena/playerhandler.h
index 6d7d6a9e1..fc84db326 100644
--- a/src/net/eathena/playerhandler.h
+++ b/src/net/eathena/playerhandler.h
@@ -39,7 +39,8 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler
void handleMessage(Net::MessageIn &msg) override final;
- void attack(const int id, const Keep keep) const override final;
+ void attack(const BeingId id,
+ const Keep keep) const override final;
void stopAttack() const override final;
void emote(const uint8_t emoteId) const override final;
diff --git a/src/net/eathena/skillhandler.cpp b/src/net/eathena/skillhandler.cpp
index 27f4b136a..fb8cf39e7 100644
--- a/src/net/eathena/skillhandler.cpp
+++ b/src/net/eathena/skillhandler.cpp
@@ -159,12 +159,12 @@ void SkillHandler::handleMessage(Net::MessageIn &msg)
}
void SkillHandler::useBeing(const int id, const int level,
- const int beingId) const
+ const BeingId beingId) const
{
createOutPacket(CMSG_SKILL_USE_BEING);
outMsg.writeInt16(static_cast<int16_t>(level), "skill level");
outMsg.writeInt16(static_cast<int16_t>(id), "skill id");
- outMsg.writeInt32(beingId, "target id");
+ outMsg.writeInt32(toInt(beingId, int), "target id");
}
void SkillHandler::usePos(const int id, const int level,
@@ -424,7 +424,7 @@ void SkillHandler::processSkillFailed(Net::MessageIn &msg)
void SkillHandler::processSkillSnap(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("being id");
+ msg.readBeingId("being id");
msg.readInt16("x");
msg.readInt16("y");
}
@@ -470,7 +470,7 @@ void SkillHandler::processSkillUnitUpdate(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("being id");
+ msg.readBeingId("being id");
}
void SkillHandler::processSkillArrowCreateList(Net::MessageIn &msg)
@@ -496,7 +496,7 @@ void SkillHandler::processSkillDevotionEffect(Net::MessageIn &msg)
{
UNIMPLIMENTEDPACKET;
- msg.readInt32("being id");
+ msg.readBeingId("being id");
for (int f = 0; f < 5; f ++)
msg.readInt32("devotee id");
msg.readInt16("range");
diff --git a/src/net/eathena/skillhandler.h b/src/net/eathena/skillhandler.h
index 2cfb4b89f..2cef21777 100644
--- a/src/net/eathena/skillhandler.h
+++ b/src/net/eathena/skillhandler.h
@@ -39,13 +39,16 @@ class SkillHandler final : public MessageHandler, public Ea::SkillHandler
void handleMessage(Net::MessageIn &msg) override final;
- void useBeing(const int id, const int level,
- const int beingId) const override final;
+ void useBeing(const int id,
+ const int level,
+ const BeingId beingId) const override final;
- void usePos(const int id, const int level,
+ void usePos(const int id,
+ const int level,
const int x, const int y) const override final;
- void usePos(const int id, const int level,
+ void usePos(const int id,
+ const int level,
const int x, const int y,
const std::string &text) const override final;
diff --git a/src/net/eathena/tradehandler.cpp b/src/net/eathena/tradehandler.cpp
index 5b1c92ac1..4f036d09b 100644
--- a/src/net/eathena/tradehandler.cpp
+++ b/src/net/eathena/tradehandler.cpp
@@ -116,7 +116,7 @@ void TradeHandler::request(const Being *const being) const
return;
createOutPacket(CMSG_TRADE_REQUEST);
- outMsg.writeInt32(being->getId(), "player id");
+ outMsg.writeBeingId(being->getId(), "player id");
}
void TradeHandler::respond(const bool accept) const
diff --git a/src/net/eathena/vendinghandler.cpp b/src/net/eathena/vendinghandler.cpp
index 9ba6bfc7b..1bbe491cf 100644
--- a/src/net/eathena/vendinghandler.cpp
+++ b/src/net/eathena/vendinghandler.cpp
@@ -116,7 +116,7 @@ void VendingHandler::processOpenReq(Net::MessageIn &msg)
void VendingHandler::processShowBoard(Net::MessageIn &msg)
{
- const int id = msg.readInt32("owner id");
+ const BeingId id = msg.readBeingId("owner id");
const std::string shopName = msg.readString(80, "shop name");
Being *const dstBeing = actorManager->findBeing(id);
if (dstBeing)
@@ -125,7 +125,7 @@ void VendingHandler::processShowBoard(Net::MessageIn &msg)
void VendingHandler::processHideBoard(Net::MessageIn &msg)
{
- const int id = msg.readInt32("owner id");
+ const BeingId id = msg.readBeingId("owner id");
Being *const dstBeing = actorManager->findBeing(id);
if (dstBeing)
dstBeing->setSellBoard(std::string());
@@ -139,7 +139,7 @@ void VendingHandler::processHideBoard(Net::MessageIn &msg)
void VendingHandler::processItemsList(Net::MessageIn &msg)
{
const int count = (msg.readInt16("len") - 12) / 22;
- const int id = msg.readInt32("id");
+ const BeingId id = msg.readBeingId("id");
Being *const being = actorManager->findBeing(id);
if (!being)
return;
@@ -223,7 +223,7 @@ void VendingHandler::open(const Being *const being) const
return;
createOutPacket(CMSG_VENDING_LIST_REQ);
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
}
void VendingHandler::buy(const Being *const being,
@@ -235,7 +235,7 @@ void VendingHandler::buy(const Being *const being,
createOutPacket(CMSG_VENDING_BUY);
outMsg.writeInt16(12, "len");
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
outMsg.writeInt16(static_cast<int16_t>(amount), "amount");
outMsg.writeInt16(static_cast<int16_t>(index), "index");
}
@@ -250,7 +250,7 @@ void VendingHandler::buy2(const Being *const being,
createOutPacket(CMSG_VENDING_BUY2);
outMsg.writeInt16(16, "len");
- outMsg.writeInt32(being->getId(), "account id");
+ outMsg.writeBeingId(being->getId(), "account id");
outMsg.writeInt32(vendId, "vend id");
outMsg.writeInt16(static_cast<int16_t>(amount), "amount");
outMsg.writeInt16(static_cast<int16_t>(index), "index");