summaryrefslogtreecommitdiff
path: root/src/net
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
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')
-rw-r--r--src/net/adminhandler.h6
-rw-r--r--src/net/beinghandler.h4
-rw-r--r--src/net/charserverhandler.h2
-rw-r--r--src/net/ea/beinghandler.cpp30
-rw-r--r--src/net/ea/beinghandler.h4
-rw-r--r--src/net/ea/buysellhandler.cpp6
-rw-r--r--src/net/ea/buysellhandler.h4
-rw-r--r--src/net/ea/chathandler.cpp2
-rw-r--r--src/net/ea/gamehandler.cpp6
-rw-r--r--src/net/ea/gamehandler.h4
-rw-r--r--src/net/ea/guildhandler.cpp4
-rw-r--r--src/net/ea/inventoryhandler.h4
-rw-r--r--src/net/ea/itemhandler.cpp4
-rw-r--r--src/net/ea/loginhandler.cpp2
-rw-r--r--src/net/ea/npchandler.cpp14
-rw-r--r--src/net/ea/partyhandler.cpp4
-rw-r--r--src/net/ea/token.h5
-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
-rw-r--r--src/net/homunculushandler.h4
-rw-r--r--src/net/mercenaryhandler.h4
-rw-r--r--src/net/messagein.h4
-rw-r--r--src/net/messageout.h9
-rw-r--r--src/net/npchandler.h27
-rw-r--r--src/net/playerhandler.h4
-rw-r--r--src/net/skillhandler.h13
-rw-r--r--src/net/tmwa/adminhandler.cpp4
-rw-r--r--src/net/tmwa/adminhandler.h2
-rw-r--r--src/net/tmwa/beinghandler.cpp62
-rw-r--r--src/net/tmwa/beinghandler.h2
-rw-r--r--src/net/tmwa/charserverhandler.cpp8
-rw-r--r--src/net/tmwa/charserverhandler.h2
-rw-r--r--src/net/tmwa/chathandler.cpp2
-rw-r--r--src/net/tmwa/gamehandler.cpp6
-rw-r--r--src/net/tmwa/guildhandler.cpp12
-rw-r--r--src/net/tmwa/guildmanager.cpp3
-rw-r--r--src/net/tmwa/homunculushandler.cpp2
-rw-r--r--src/net/tmwa/homunculushandler.h3
-rw-r--r--src/net/tmwa/inventoryhandler.cpp4
-rw-r--r--src/net/tmwa/itemhandler.cpp2
-rw-r--r--src/net/tmwa/mercenaryhandler.cpp2
-rw-r--r--src/net/tmwa/mercenaryhandler.h3
-rw-r--r--src/net/tmwa/messagein.cpp5
-rw-r--r--src/net/tmwa/messagein.h2
-rw-r--r--src/net/tmwa/messageout.cpp5
-rw-r--r--src/net/tmwa/messageout.h3
-rw-r--r--src/net/tmwa/npchandler.cpp47
-rw-r--r--src/net/tmwa/npchandler.h24
-rw-r--r--src/net/tmwa/partyhandler.cpp18
-rw-r--r--src/net/tmwa/playerhandler.cpp7
-rw-r--r--src/net/tmwa/playerhandler.h3
-rw-r--r--src/net/tmwa/skillhandler.cpp4
-rw-r--r--src/net/tmwa/skillhandler.h11
-rw-r--r--src/net/tmwa/tradehandler.cpp2
87 files changed, 494 insertions, 388 deletions
diff --git a/src/net/adminhandler.h b/src/net/adminhandler.h
index 70e683769..77f0508a8 100644
--- a/src/net/adminhandler.h
+++ b/src/net/adminhandler.h
@@ -23,10 +23,12 @@
#ifndef NET_ADMINHANDLER_H
#define NET_ADMINHANDLER_H
-#include "localconsts.h"
+#include "enums/simpletypes/beingid.h"
#include <string>
+#include "localconsts.h"
+
class Being;
namespace Net
@@ -44,7 +46,7 @@ class AdminHandler notfinal
virtual void hide(const bool hide) const = 0;
- virtual void kick(const int playerId) const = 0;
+ virtual void kick(const BeingId playerId) const = 0;
virtual void kickName(const std::string &name) const = 0;
diff --git a/src/net/beinghandler.h b/src/net/beinghandler.h
index af6b05b8b..a99b0377c 100644
--- a/src/net/beinghandler.h
+++ b/src/net/beinghandler.h
@@ -26,6 +26,8 @@
#include "enums/being/rank.h"
+#include "enums/simpletypes/beingid.h"
+
#include "net/messagein.h"
namespace Net
@@ -39,7 +41,7 @@ class BeingHandler notfinal
virtual void handleMessage(Net::MessageIn &msg) = 0;
- virtual void requestNameById(const int id) const = 0;
+ virtual void requestNameById(const BeingId id) const = 0;
virtual void undress(Being *const being) const = 0;
diff --git a/src/net/charserverhandler.h b/src/net/charserverhandler.h
index 445545436..925346594 100644
--- a/src/net/charserverhandler.h
+++ b/src/net/charserverhandler.h
@@ -65,7 +65,7 @@ class CharServerHandler notfinal
virtual void deleteCharacter(Net::Character *const character,
const std::string &email) = 0;
- virtual void renameCharacter(const int id,
+ virtual void renameCharacter(const BeingId id,
const std::string &newName) = 0;
virtual void switchCharacter() const = 0;
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 51771fb30..ab32a3f84 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -43,16 +43,17 @@
namespace Ea
{
-int BeingHandler::mSpawnId = 0;
+BeingId BeingHandler::mSpawnId = BeingId_zero;
bool BeingHandler::mSync = false;
BeingHandler::BeingHandler(const bool enableSync)
{
mSync = enableSync;
- mSpawnId = 0;
+ mSpawnId = BeingId_zero;
}
-Being *BeingHandler::createBeing(const int id, const int16_t job)
+Being *BeingHandler::createBeing(const BeingId id,
+ const int16_t job)
{
if (!actorManager)
return nullptr;
@@ -93,7 +94,7 @@ void BeingHandler::processBeingRemove(Net::MessageIn &msg)
// A being should be removed or has died
- const int id = msg.readInt32("being id");
+ const BeingId id = msg.readBeingId("being id");
Being *const dstBeing = actorManager->findBeing(id);
if (!dstBeing)
{
@@ -140,9 +141,9 @@ void BeingHandler::processSkillDamage(Net::MessageIn &msg)
const int id = msg.readInt16("skill id");
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");
msg.readInt32("src speed");
msg.readInt32("dst speed");
@@ -167,9 +168,9 @@ void BeingHandler::processBeingAction(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");
@@ -253,7 +254,8 @@ void BeingHandler::processBeingEmotion(Net::MessageIn &msg)
return;
}
- Being *const dstBeing = actorManager->findBeing(msg.readInt32("being id"));
+ Being *const dstBeing = actorManager->findBeing(
+ msg.readBeingId("being id"));
if (!dstBeing)
{
BLOCK_END("BeingHandler::processBeingEmotion")
@@ -283,7 +285,7 @@ void BeingHandler::processNameResponse(Net::MessageIn &msg)
return;
}
- const int beingId = msg.readInt32("being id");
+ const BeingId beingId = msg.readBeingId("being id");
Being *const dstBeing = actorManager->findBeing(beingId);
if (dstBeing)
@@ -344,7 +346,7 @@ void BeingHandler::processPlayerStop(Net::MessageIn &msg)
return;
}
- const int id = msg.readInt32("account id");
+ const BeingId id = msg.readBeingId("account id");
if (mSync || id != localPlayer->getId())
{
@@ -409,7 +411,7 @@ void BeingHandler::processPvpMapMode(Net::MessageIn &msg)
void BeingHandler::processPvpSet(Net::MessageIn &msg)
{
BLOCK_START("BeingHandler::processPvpSet")
- const int id = msg.readInt32("being id");
+ const BeingId id = msg.readBeingId("being id");
const int rank = msg.readInt32("rank");
msg.readInt32("num");
if (actorManager)
@@ -431,7 +433,7 @@ void BeingHandler::processNameResponse2(Net::MessageIn &msg)
}
const int len = msg.readInt16("len");
- const int beingId = msg.readInt32("account ic");
+ const BeingId beingId = msg.readBeingId("account ic");
const std::string str = msg.readString(len - 8, "name");
Being *const dstBeing = actorManager->findBeing(beingId);
if (dstBeing)
@@ -481,7 +483,7 @@ void BeingHandler::processBeingMove3(Net::MessageIn &msg)
const int len = msg.readInt16("len") - 14;
Being *const dstBeing = actorManager->findBeing(
- msg.readInt32("being id"));
+ msg.readBeingId("being id"));
if (!dstBeing)
{
BLOCK_END("BeingHandler::processBeingMove3")
diff --git a/src/net/ea/beinghandler.h b/src/net/ea/beinghandler.h
index ca575e506..632381fb3 100644
--- a/src/net/ea/beinghandler.h
+++ b/src/net/ea/beinghandler.h
@@ -36,7 +36,7 @@ class BeingHandler notfinal : public Net::BeingHandler
protected:
explicit BeingHandler(const bool enableSync);
- static Being *createBeing(const int id,
+ static Being *createBeing(const BeingId id,
const int16_t job) A_WARN_UNUSED;
static void setSprite(Being *const being, const unsigned int slot,
@@ -71,7 +71,7 @@ class BeingHandler notfinal : public Net::BeingHandler
static void processBeingMove3(Net::MessageIn &msg);
// Should we honor server "Stop Walking" packets
- static int mSpawnId;
+ static BeingId mSpawnId;
static bool mSync;
};
diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp
index e0f686cad..0e939c217 100644
--- a/src/net/ea/buysellhandler.cpp
+++ b/src/net/ea/buysellhandler.cpp
@@ -42,12 +42,12 @@
namespace Ea
{
-int BuySellHandler::mNpcId = 0;
+BeingId BuySellHandler::mNpcId = BeingId_zero;
BuyDialog *BuySellHandler::mBuyDialog = nullptr;
BuySellHandler::BuySellHandler()
{
- mNpcId = 0;
+ mNpcId = BeingId_zero;
mBuyDialog = nullptr;
}
@@ -55,7 +55,7 @@ void BuySellHandler::processNpcBuySellChoice(Net::MessageIn &msg)
{
if (!BuySellDialog::isActive())
{
- mNpcId = msg.readInt32("npc id");
+ mNpcId = msg.readBeingId("npc id");
BuySellDialog *const dialog = new BuySellDialog(mNpcId);
dialog->postInit();
}
diff --git a/src/net/ea/buysellhandler.h b/src/net/ea/buysellhandler.h
index e972b1208..1667332bb 100644
--- a/src/net/ea/buysellhandler.h
+++ b/src/net/ea/buysellhandler.h
@@ -23,6 +23,8 @@
#ifndef NET_EA_BUYSELLHANDLER_H
#define NET_EA_BUYSELLHANDLER_H
+#include "enums/simpletypes/beingid.h"
+
#include "net/buysellhandler.h"
class BuyDialog;
@@ -44,7 +46,7 @@ class BuySellHandler notfinal : public Net::BuySellHandler
static void processNpcBuyResponse(Net::MessageIn &msg);
- static int mNpcId;
+ static BeingId mNpcId;
static BuyDialog *mBuyDialog;
};
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index a08b2b9e6..554276d17 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -148,7 +148,7 @@ void ChatHandler::processMVPEffect(Net::MessageIn &msg)
{
BLOCK_START("ChatHandler::processMVPEffect")
// Display MVP player
- const int id = msg.readInt32("being id");
+ const BeingId id = msg.readBeingId("being id");
if (localChatTab && actorManager && config.getBoolValue("showMVP"))
{
const Being *const being = actorManager->findBeing(id);
diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp
index 31c487921..583ef3409 100644
--- a/src/net/ea/gamehandler.cpp
+++ b/src/net/ea/gamehandler.cpp
@@ -42,13 +42,13 @@ namespace Ea
{
std::string GameHandler::mMap;
-int GameHandler::mCharID = 0;
+BeingId GameHandler::mCharID = BeingId_zero;
GameHandler::GameHandler() :
Net::GameHandler()
{
mMap.clear();
- mCharID = 0;
+ mCharID = BeingId_zero;
}
void GameHandler::who() const
@@ -92,7 +92,7 @@ void GameHandler::processMapQuitResponse(Net::MessageIn &msg)
void GameHandler::clear()
{
mMap.clear();
- mCharID = 0;
+ mCharID = BeingId_zero;
}
void GameHandler::initEngines() const
diff --git a/src/net/ea/gamehandler.h b/src/net/ea/gamehandler.h
index 4ecc85692..7ff3a5ca9 100644
--- a/src/net/ea/gamehandler.h
+++ b/src/net/ea/gamehandler.h
@@ -23,6 +23,8 @@
#ifndef NET_EA_GAMEHANDLER_H
#define NET_EA_GAMEHANDLER_H
+#include "enums/simpletypes/beingid.h"
+
#include "net/gamehandler.h"
namespace Net
@@ -62,7 +64,7 @@ class GameHandler notfinal : public Net::GameHandler
protected:
static std::string mMap;
- static int mCharID; // < Saved for map-server switching
+ static BeingId mCharID; // < Saved for map-server switching
};
} // namespace Ea
diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp
index 13317699b..96956b2d9 100644
--- a/src/net/ea/guildhandler.cpp
+++ b/src/net/ea/guildhandler.cpp
@@ -186,7 +186,7 @@ void GuildHandler::processGuildMemberList(Net::MessageIn &msg)
int totalNum = 0;
for (int i = 0; i < count; i++)
{
- const int id = msg.readInt32("account id");
+ const BeingId id = msg.readBeingId("account id");
const int charId = msg.readInt32("char id");
msg.readInt16("hair");
msg.readInt16("hair color");
@@ -290,7 +290,7 @@ void GuildHandler::processGuildPositionChanged(Net::MessageIn &msg)
void GuildHandler::processGuildMemberPosChange(Net::MessageIn &msg)
{
msg.readInt16("len");
- const int accountId = msg.readInt32("account id");
+ const BeingId accountId = msg.readBeingId("account id");
const int charId = msg.readInt32("char id");
const int pos = msg.readInt32("position");
if (taGuild)
diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h
index 26d74d56a..6050baaff 100644
--- a/src/net/ea/inventoryhandler.h
+++ b/src/net/ea/inventoryhandler.h
@@ -41,7 +41,7 @@ namespace Ea
{
typedef std::vector<InventoryItem> InventoryItems;
-typedef std::queue<int> PickupQueue;
+typedef std::queue<BeingId> PickupQueue;
class InventoryHandler notfinal : public Net::InventoryHandler
{
@@ -65,7 +65,7 @@ class InventoryHandler notfinal : public Net::InventoryHandler
size_t getSize(const int type) const override final A_WARN_UNUSED;
- void pushPickup(const int floorId)
+ void pushPickup(const BeingId floorId)
{ mSentPickups.push(floorId); }
static int getSlot(const int eAthenaSlot) A_WARN_UNUSED;
diff --git a/src/net/ea/itemhandler.cpp b/src/net/ea/itemhandler.cpp
index a4c1a164b..2c297f69f 100644
--- a/src/net/ea/itemhandler.cpp
+++ b/src/net/ea/itemhandler.cpp
@@ -41,7 +41,7 @@ ItemHandler::~ItemHandler()
void ItemHandler::processItemVisible(Net::MessageIn &msg)
{
- const int id = msg.readInt32("item object id");
+ const BeingId id = msg.readBeingId("item object id");
const int itemId = msg.readInt16("item id");
const uint8_t identify = msg.readUInt8("identify");
const int x = msg.readInt16("x");
@@ -62,7 +62,7 @@ void ItemHandler::processItemRemove(Net::MessageIn &msg)
if (actorManager)
{
if (FloorItem *const item = actorManager
- ->findItem(msg.readInt32("floor item id")))
+ ->findItem(msg.readBeingId("floor item id")))
{
actorManager->destroy(item);
}
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
index 8b8077cde..396eb1480 100644
--- a/src/net/ea/loginhandler.cpp
+++ b/src/net/ea/loginhandler.cpp
@@ -163,7 +163,7 @@ void LoginHandler::processLoginData(Net::MessageIn &msg)
const int worldCount = (msg.getLength() - 47) / 32;
mToken.session_ID1 = msg.readInt32("session id1");
- mToken.account_ID = msg.readInt32("accound id");
+ mToken.account_ID = msg.readBeingId("accound id");
mToken.session_ID2 = msg.readInt32("session id2");
msg.readInt32("old ip");
loginData.lastLogin = msg.readString(24, "last login");
diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp
index a88025b7f..bfa3c3f81 100644
--- a/src/net/ea/npchandler.cpp
+++ b/src/net/ea/npchandler.cpp
@@ -104,7 +104,7 @@ void NpcHandler::processNpcIntInput(Net::MessageIn &msg)
void NpcHandler::processNpcStrInput(Net::MessageIn &msg)
{
// Request for a string
- int npcId = npcHandler->getNpc(msg);
+ BeingId npcId = npcHandler->getNpc(msg);
if (mRequestLang)
{
mRequestLang = false;
@@ -118,11 +118,11 @@ void NpcHandler::processNpcStrInput(Net::MessageIn &msg)
void NpcHandler::processNpcCommand(Net::MessageIn &msg)
{
- const int npcId = npcHandler->getNpc(msg);
+ const BeingId npcId = npcHandler->getNpc(msg);
mRequestLang = false;
const int cmd = msg.readInt16("cmd");
- const int id = msg.readInt32("id");
+ const BeingId id = msg.readBeingId("id");
const int x = msg.readInt16("x");
const int y = msg.readInt16("y");
switch (cmd)
@@ -139,7 +139,7 @@ void NpcHandler::processNpcCommand(Net::MessageIn &msg)
case 2:
if (viewport)
{
- if (!id)
+ if (id == BeingId_zero)
viewport->moveCameraToPosition(x, y);
else
viewport->moveCameraToActor(id, x, y);
@@ -165,7 +165,7 @@ void NpcHandler::processNpcCommand(Net::MessageIn &msg)
case 6: // show avatar
if (mDialog)
{
- mDialog->showAvatar(static_cast<uint16_t>(id));
+ mDialog->showAvatar(id);
}
break;
case 7: // set avatar direction
@@ -178,7 +178,7 @@ void NpcHandler::processNpcCommand(Net::MessageIn &msg)
break;
case 8: // set avatar action
if (mDialog)
- mDialog->setAvatarAction(id);
+ mDialog->setAvatarAction(toInt(id, int));
break;
case 9: // clear npc dialog
if (mDialog)
@@ -186,7 +186,7 @@ void NpcHandler::processNpcCommand(Net::MessageIn &msg)
break;
case 10: // send selected item id
{
- int invSize = id;
+ int invSize = toInt(id, int);
if (!invSize)
invSize = 1;
if (mDialog)
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp
index f30a0a83f..1af9ba7ef 100644
--- a/src/net/ea/partyhandler.cpp
+++ b/src/net/ea/partyhandler.cpp
@@ -140,7 +140,7 @@ void PartyHandler::processPartySettingsContinue(Net::MessageIn &msg,
void PartyHandler::processPartyLeave(Net::MessageIn &msg)
{
- const int id = msg.readInt32("account id");
+ const BeingId id = msg.readBeingId("account id");
const std::string nick = msg.readString(24, "nick");
const int reason = msg.readUInt8("flag");
if (!localPlayer)
@@ -224,7 +224,7 @@ void PartyHandler::processPartyLeave(Net::MessageIn &msg)
void PartyHandler::processPartyUpdateCoords(Net::MessageIn &msg)
{
- const int id = msg.readInt32("id");
+ const BeingId id = msg.readBeingId("account id");
PartyMember *m = nullptr;
if (Ea::taParty)
m = Ea::taParty->getMember(id);
diff --git a/src/net/ea/token.h b/src/net/ea/token.h
index 65368b6e2..a62136aee 100644
--- a/src/net/ea/token.h
+++ b/src/net/ea/token.h
@@ -20,6 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "enums/simpletypes/beingid.h"
#include "enums/being/gender.h"
#ifndef NET_EA_TOKEN_H
@@ -27,14 +28,14 @@
struct Token final
{
- int account_ID;
+ BeingId account_ID;
int session_ID1;
int session_ID2;
Gender::Type sex;
void clear()
{
- account_ID = 0;
+ account_ID = BeingId_zero;
session_ID1 = 0;
session_ID2 = 0;
sex = Gender::UNSPECIFIED;
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");
diff --git a/src/net/homunculushandler.h b/src/net/homunculushandler.h
index c63ed8bba..346fcef49 100644
--- a/src/net/homunculushandler.h
+++ b/src/net/homunculushandler.h
@@ -23,6 +23,7 @@
#ifdef EATHENA_SUPPORT
+#include "enums/simpletypes/beingid.h"
#include "enums/simpletypes/keep.h"
#include <string>
@@ -44,7 +45,8 @@ class HomunculusHandler notfinal
virtual void move(const int x, const int y) const = 0;
- virtual void attack(const int targetId, const Keep keep) const = 0;
+ virtual void attack(const BeingId targetId,
+ const Keep keep) const = 0;
virtual void feed() const = 0;
diff --git a/src/net/mercenaryhandler.h b/src/net/mercenaryhandler.h
index 5c1517975..d39267c5f 100644
--- a/src/net/mercenaryhandler.h
+++ b/src/net/mercenaryhandler.h
@@ -23,6 +23,7 @@
#ifdef EATHENA_SUPPORT
+#include "enums/simpletypes/beingid.h"
#include "enums/simpletypes/keep.h"
#include <string>
@@ -46,7 +47,8 @@ class MercenaryHandler notfinal
virtual void move(const int x, const int y) const = 0;
- virtual void attack(const int targetId, const Keep keep) const = 0;
+ virtual void attack(const BeingId targetId,
+ const Keep keep) const = 0;
virtual void talk(const std::string &restrict text) const = 0;
diff --git a/src/net/messagein.h b/src/net/messagein.h
index cb25a3fde..154b55b3e 100644
--- a/src/net/messagein.h
+++ b/src/net/messagein.h
@@ -23,6 +23,8 @@
#ifndef NET_MESSAGEIN_H
#define NET_MESSAGEIN_H
+#include "enums/simpletypes/beingid.h"
+
#include <string>
#include "localconsts.h"
@@ -74,6 +76,8 @@ class MessageIn notfinal
virtual int64_t readInt64(const char *const str) = 0;
+ virtual BeingId readBeingId(const char *const str) = 0;
+
/**
* Reads a special 3 byte block used by eAthena, containing x and y
* coordinates and direction.
diff --git a/src/net/messageout.h b/src/net/messageout.h
index 13a4eae1b..048afc70c 100644
--- a/src/net/messageout.h
+++ b/src/net/messageout.h
@@ -23,6 +23,8 @@
#ifndef NET_MESSAGEOUT_H
#define NET_MESSAGEOUT_H
+#include "enums/simpletypes/beingid.h"
+
#include <string>
#include "localconsts.h"
@@ -47,13 +49,16 @@ class MessageOut notfinal
const char *const str);
/**< Writes a short. */
- virtual void writeInt16(int16_t value,
+ virtual void writeInt16(const int16_t value,
const char *const str) = 0;
/**< Writes a long. */
- virtual void writeInt32(int32_t value,
+ virtual void writeInt32(const int32_t value,
const char *const str) = 0;
+ virtual void writeBeingId(const BeingId value,
+ const char *const str) = 0;
+
/**
* Writes a string. If a fixed length is not given (-1), it is stored
* as a short at the start of the string.
diff --git a/src/net/npchandler.h b/src/net/npchandler.h
index 42eaabb00..83c896d1c 100644
--- a/src/net/npchandler.h
+++ b/src/net/npchandler.h
@@ -27,6 +27,8 @@
#include "enums/being/cookingtype.h"
+#include "enums/simpletypes/beingid.h"
+
#include "localconsts.h"
namespace Net
@@ -40,31 +42,34 @@ class NpcHandler notfinal
virtual ~NpcHandler()
{ }
- virtual int getNpc(Net::MessageIn &msg) = 0;
+ virtual BeingId getNpc(Net::MessageIn &msg) = 0;
- virtual void talk(const int npcId) const = 0;
+ virtual void talk(const BeingId npcId) const = 0;
- virtual void nextDialog(const int npcId) const = 0;
+ virtual void nextDialog(const BeingId npcId) const = 0;
- virtual void closeDialog(const int npcId) = 0;
+ virtual void closeDialog(const BeingId npcId) = 0;
- virtual void listInput(const int npcId,
+ virtual void listInput(const BeingId npcId,
const unsigned char value) const = 0;
- virtual void integerInput(const int npcId, const int value) const = 0;
+ virtual void integerInput(const BeingId npcId,
+ const int value) const = 0;
- virtual void stringInput(const int npcId,
+ virtual void stringInput(const BeingId npcId,
const std::string &value) const = 0;
- virtual void buy(const int beingId) const = 0;
+ virtual void buy(const BeingId beingId) const = 0;
- virtual void sell(const int beingId) const = 0;
+ virtual void sell(const BeingId beingId) const = 0;
- virtual void buyItem(const int beingId, const int itemId,
+ virtual void buyItem(const BeingId beingId,
+ const int itemId,
const unsigned char color,
const int amount) const = 0;
- virtual void sellItem(const int beingId, const int itemId,
+ virtual void sellItem(const BeingId beingId,
+ const int itemId,
const int amount) const = 0;
virtual void completeProgressBar() const = 0;
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index 44001e7c4..5fde7db54 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -27,6 +27,7 @@
#include "enums/being/beingaction.h"
+#include "enums/simpletypes/beingid.h"
#include "enums/simpletypes/keep.h"
#include "enums/simpletypes/notify.h"
@@ -41,7 +42,8 @@ class PlayerHandler notfinal
virtual ~PlayerHandler()
{ }
- virtual void attack(const int id, const Keep keep) const = 0;
+ virtual void attack(const BeingId id,
+ const Keep keep) const = 0;
virtual void stopAttack() const = 0;
diff --git a/src/net/skillhandler.h b/src/net/skillhandler.h
index 9c9318c66..996101149 100644
--- a/src/net/skillhandler.h
+++ b/src/net/skillhandler.h
@@ -23,6 +23,8 @@
#ifndef NET_SKILLHANDLER_H
#define NET_SKILLHANDLER_H
+#include "enums/simpletypes/beingid.h"
+
#include <iosfwd>
#include "localconsts.h"
@@ -35,13 +37,16 @@ class SkillHandler notfinal
virtual ~SkillHandler()
{ }
- virtual void useBeing(const int id, const int level,
- const int beingId) const = 0;
+ virtual void useBeing(const int id,
+ const int level,
+ const BeingId beingId) const = 0;
- virtual void usePos(const int id, const int level,
+ virtual void usePos(const int id,
+ const int level,
const int x, const int y) const = 0;
- virtual void usePos(const int id, const int level,
+ virtual void usePos(const int id,
+ const int level,
const int x, const int y,
const std::string &text) const = 0;
diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp
index 216a33cb7..64638ad46 100644
--- a/src/net/tmwa/adminhandler.cpp
+++ b/src/net/tmwa/adminhandler.cpp
@@ -86,10 +86,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
diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h
index 35a4ccead..a98d6d850 100644
--- a/src/net/tmwa/adminhandler.h
+++ b/src/net/tmwa/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/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index 20ab2cffa..0191953a4 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -101,10 +101,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)
@@ -267,7 +267,7 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg)
}
Being *const dstBeing = actorManager->findBeing(
- msg.readInt32("being id"));
+ msg.readBeingId("being id"));
const uint8_t type = msg.readUInt8("type");
const int16_t id = static_cast<int16_t>(msg.readUInt8("id"));
@@ -292,7 +292,7 @@ void BeingHandler::processBeingChangeLook2(Net::MessageIn &msg)
}
Being *const dstBeing = actorManager->findBeing(
- msg.readInt32("being id"));
+ msg.readBeingId("being id"));
const uint8_t type = msg.readUInt8("type");
int id2 = 0;
@@ -427,7 +427,7 @@ void BeingHandler::processPlayerUpdate1(Net::MessageIn &msg)
}
// An update about a player, potentially including movement.
- const int id = msg.readInt32("account id");
+ const BeingId id = msg.readBeingId("account id");
const int16_t speed = msg.readInt16("speed");
const uint16_t stunMode = msg.readInt16("opt1");
uint32_t statusEffects = msg.readInt16("opt2");
@@ -435,7 +435,7 @@ void BeingHandler::processPlayerUpdate1(Net::MessageIn &msg)
<< 16;
const int16_t job = msg.readInt16("job");
int disguiseId = 0;
- if (id < 110000000 && job >= 1000)
+ if (toInt(id, int) < 110000000 && job >= 1000)
disguiseId = job;
Being *dstBeing = actorManager->findBeing(id);
@@ -579,7 +579,7 @@ void BeingHandler::processPlayerUpdate2(Net::MessageIn &msg)
}
// An update about a player, potentially including movement.
- const int id = msg.readInt32("account id");
+ const BeingId id = msg.readBeingId("account id");
const int16_t speed = msg.readInt16("speed");
const uint16_t stunMode = msg.readInt16("opt1");
uint32_t statusEffects = msg.readInt16("opt2");
@@ -587,7 +587,7 @@ void BeingHandler::processPlayerUpdate2(Net::MessageIn &msg)
<< 16;
const int16_t job = msg.readInt16("job");
int disguiseId = 0;
- if (id < 110000000 && job >= 1000)
+ if (toInt(id, int) < 110000000 && job >= 1000)
disguiseId = job;
Being *dstBeing = actorManager->findBeing(id);
@@ -727,7 +727,7 @@ void BeingHandler::processPlayerMove(Net::MessageIn &msg)
}
// An update about a player, potentially including movement.
- const int id = msg.readInt32("account id");
+ const BeingId id = msg.readBeingId("account id");
const int16_t speed = msg.readInt16("speed");
const uint16_t stunMode = msg.readInt16("opt1");
uint32_t statusEffects = msg.readInt16("opt2");
@@ -735,7 +735,7 @@ void BeingHandler::processPlayerMove(Net::MessageIn &msg)
<< 16;
const int16_t job = msg.readInt16("job");
int disguiseId = 0;
- if (id < 110000000 && job >= 1000)
+ if (toInt(id, int) < 110000000 && job >= 1000)
disguiseId = job;
Being *dstBeing = actorManager->findBeing(id);
@@ -904,15 +904,15 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
return;
}
- int spawnId;
+ BeingId spawnId;
// Information about a being in range
- const int id = msg.readInt32("being id");
+ const BeingId id = msg.readBeingId("being id");
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");
uint32_t statusEffects = msg.readInt16("opt2");
@@ -936,7 +936,7 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
{
// Being with id >= 110000000 and job 0 are better
// known as ghosts, so don't create those.
- if (job == 0 && id >= 110000000)
+ if (job == 0 && toInt(id, int) >= 110000000)
{
BLOCK_END("BeingHandler::processBeingVisibleOrMove")
return;
@@ -969,7 +969,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);
}
@@ -1111,15 +1111,15 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
return;
}
- int spawnId;
+ BeingId spawnId;
// Information about a being in range
- const int id = msg.readInt32("being id");
+ const BeingId id = msg.readBeingId("being id");
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");
uint32_t statusEffects = msg.readInt16("opt2");
@@ -1143,7 +1143,7 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
{
// Being with id >= 110000000 and job 0 are better
// known as ghosts, so don't create those.
- if (job == 0 && id >= 110000000)
+ if (job == 0 && toInt(id, int) >= 110000000)
{
BLOCK_END("BeingHandler::processBeingVisibleOrMove")
return;
@@ -1176,7 +1176,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
@@ -1296,7 +1296,7 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg)
{
BLOCK_START("BeingHandler::processBeingSpawn")
// skipping this packet
- mSpawnId = msg.readInt32("being id");
+ mSpawnId = msg.readBeingId("being id");
msg.readInt16("speed");
msg.readInt16("opt1");
msg.readInt16("opt2");
@@ -1328,7 +1328,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);
@@ -1352,7 +1352,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"));
/*
* This packet doesn't have enough info to actually
@@ -1387,7 +1387,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"));
if (!dstBeing)
{
@@ -1470,7 +1470,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;
@@ -1499,7 +1499,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");
Being *const dstBeing = actorManager->findBeing(id);
if (!dstBeing)
{
@@ -1525,7 +1525,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)
{
@@ -1562,7 +1562,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)
{
@@ -1598,7 +1598,7 @@ void BeingHandler::processIpResponse(Net::MessageIn &msg)
return;
}
- Being *const dstBeing = actorManager->findBeing(msg.readInt32("being id"));
+ Being *const dstBeing = actorManager->findBeing(msg.readBeingId("being id"));
if (dstBeing)
dstBeing->setIp(ipToString(msg.readInt32("ip address")));
BLOCK_END("BeingHandler::processIpResponse")
diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h
index 64678939b..20badffe0 100644
--- a/src/net/tmwa/beinghandler.h
+++ b/src/net/tmwa/beinghandler.h
@@ -39,7 +39,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;
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index 970d6a9c6..f3a8ab0c6 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -141,7 +141,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
static_cast<LoginHandler*>(loginHandler)->getToken();
LocalPlayer *const tempPlayer = new LocalPlayer(
- msg.readInt32("account id"), 0);
+ msg.readBeingId("account id"), 0);
tempPlayer->setGender(token.sex);
PlayerInfoBackend &data = character->data;
@@ -288,7 +288,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?");
outMsg.writeString("a@a.com", 40, "email");
}
@@ -310,7 +310,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");
// [Fate] The next word is unused by the old char server, so we squeeze in
@@ -502,7 +502,7 @@ void CharServerHandler::processCharCreate2(Net::MessageIn &msg)
BLOCK_END("CharServerHandler::processCharCreate2")
}
-void CharServerHandler::renameCharacter(const int id A_UNUSED,
+void CharServerHandler::renameCharacter(const BeingId id A_UNUSED,
const std::string &newName A_UNUSED)
{
}
diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h
index 20a162eb1..2d73d5a22 100644
--- a/src/net/tmwa/charserverhandler.h
+++ b/src/net/tmwa/charserverhandler.h
@@ -57,7 +57,7 @@ class CharServerHandler final : public MessageHandler,
void deleteCharacter(Net::Character *const character,
const std::string &email) override final;
- void renameCharacter(const int id,
+ void renameCharacter(const BeingId id,
const std::string &newName) override final;
void switchCharacter() const override final;
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index ab8036c8c..ed3a1318f 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -615,7 +615,7 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg)
BLOCK_START("ChatHandler::processBeingChat")
const bool channels = msg.getId() == SMSG_BEING_CHAT2;
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 (!being)
{
BLOCK_END("ChatHandler::processBeingChat")
diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp
index f804b61f2..83bc6e966 100644
--- a/src/net/tmwa/gamehandler.cpp
+++ b/src/net/tmwa/gamehandler.cpp
@@ -113,14 +113,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 id1");
outMsg.writeInt32(token.session_ID2, "session id2");
outMsg.writeInt8(Being::genderToInt(token.sex), "gender");
diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp
index f58f873a4..c552cfaef 100644
--- a/src/net/tmwa/guildhandler.cpp
+++ b/src/net/tmwa/guildhandler.cpp
@@ -222,7 +222,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");
}
@@ -234,7 +234,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");
}
@@ -255,7 +255,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");
}
@@ -268,7 +268,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");
}
@@ -318,7 +318,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, "position");
}
@@ -379,7 +379,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");
if (Ea::taGuild)
diff --git a/src/net/tmwa/guildmanager.cpp b/src/net/tmwa/guildmanager.cpp
index 7931087a9..9b584f14a 100644
--- a/src/net/tmwa/guildmanager.cpp
+++ b/src/net/tmwa/guildmanager.cpp
@@ -201,7 +201,8 @@ void GuildManager::updateList()
const int status = atoi(name.substr(sz - 1).c_str());
name = name.substr(0, sz - 1);
- GuildMember *const m = guild->addMember(i, 0, name);
+ GuildMember *const m = guild->addMember(
+ fromInt(i, BeingId), 0, name);
if (m)
{
m->setOnline(status & 1);
diff --git a/src/net/tmwa/homunculushandler.cpp b/src/net/tmwa/homunculushandler.cpp
index 8ffbb6ed4..1a0a89077 100644
--- a/src/net/tmwa/homunculushandler.cpp
+++ b/src/net/tmwa/homunculushandler.cpp
@@ -54,7 +54,7 @@ void HomunculusHandler::move(const int x A_UNUSED, const int y A_UNUSED) const
{
}
-void HomunculusHandler::attack(const int targetId A_UNUSED,
+void HomunculusHandler::attack(const BeingId targetId A_UNUSED,
const Keep keep A_UNUSED) const
{
}
diff --git a/src/net/tmwa/homunculushandler.h b/src/net/tmwa/homunculushandler.h
index 9aec1eed6..a54079382 100644
--- a/src/net/tmwa/homunculushandler.h
+++ b/src/net/tmwa/homunculushandler.h
@@ -46,7 +46,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/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index 28db6fa69..d1b7014f3 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -348,10 +348,10 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
const ItemInfo &itemInfo = ItemDB::get(itemId);
const unsigned char err = msg.readUInt8("status");
- int floorId;
+ BeingId floorId;
if (mSentPickups.empty())
{
- floorId = 0;
+ floorId = BeingId_zero;
}
else
{
diff --git a/src/net/tmwa/itemhandler.cpp b/src/net/tmwa/itemhandler.cpp
index 0e74172db..7ad3f733a 100644
--- a/src/net/tmwa/itemhandler.cpp
+++ b/src/net/tmwa/itemhandler.cpp
@@ -70,7 +70,7 @@ void ItemHandler::handleMessage(Net::MessageIn &msg)
void ItemHandler::processItemDropped(Net::MessageIn &msg)
{
- const int id = msg.readInt32("item object id");
+ const BeingId id = msg.readBeingId("item object id");
const int itemId = msg.readInt16("item id");
const uint8_t identify = msg.readUInt8("identify");
const int x = msg.readInt16("x");
diff --git a/src/net/tmwa/mercenaryhandler.cpp b/src/net/tmwa/mercenaryhandler.cpp
index aa71c7f69..7b39823f3 100644
--- a/src/net/tmwa/mercenaryhandler.cpp
+++ b/src/net/tmwa/mercenaryhandler.cpp
@@ -58,7 +58,7 @@ void MercenaryHandler::move(const int x A_UNUSED, const int y A_UNUSED) const
{
}
-void MercenaryHandler::attack(const int targetId A_UNUSED,
+void MercenaryHandler::attack(const BeingId targetId A_UNUSED,
const Keep keep A_UNUSED) const
{
}
diff --git a/src/net/tmwa/mercenaryhandler.h b/src/net/tmwa/mercenaryhandler.h
index f2fe3ecae..eea2a19a2 100644
--- a/src/net/tmwa/mercenaryhandler.h
+++ b/src/net/tmwa/mercenaryhandler.h
@@ -48,7 +48,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/tmwa/messagein.cpp b/src/net/tmwa/messagein.cpp
index b200729f6..3bb66c6f2 100644
--- a/src/net/tmwa/messagein.cpp
+++ b/src/net/tmwa/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/tmwa/messagein.h b/src/net/tmwa/messagein.h
index ef542bab2..7d27b1188 100644
--- a/src/net/tmwa/messagein.h
+++ b/src/net/tmwa/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/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp
index 66379ffda..c0cc0321d 100644
--- a/src/net/tmwa/messageout.cpp
+++ b/src/net/tmwa/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)) >> 8U))
diff --git a/src/net/tmwa/messageout.h b/src/net/tmwa/messageout.h
index c6aa522cc..c83643c38 100644
--- a/src/net/tmwa/messageout.h
+++ b/src/net/tmwa/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/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index 3fd1fed60..b3187687c 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -106,23 +106,23 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
BLOCK_END("NpcHandler::handleMessage")
}
-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())
@@ -136,45 +136,50 @@ 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 id");
+ 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,
- const unsigned char color, const int amount) const
+void NpcHandler::buyItem(const BeingId beingId A_UNUSED,
+ const int itemId,
+ const unsigned char color,
+ const int amount) const
{
createOutPacket(CMSG_NPC_BUY_REQUEST);
if (serverFeatures->haveItemColors())
@@ -193,7 +198,7 @@ void NpcHandler::buyItem(const int beingId A_UNUSED, const int itemId,
}
}
-void NpcHandler::sellItem(const int beingId A_UNUSED,
+void NpcHandler::sellItem(const BeingId beingId A_UNUSED,
const int itemId,
const int amount) const
{
@@ -242,7 +247,7 @@ void NpcHandler::selectAutoSpell(const int skillId A_UNUSED) const
{
}
-int NpcHandler::getNpc(Net::MessageIn &msg)
+BeingId NpcHandler::getNpc(Net::MessageIn &msg)
{
if (msg.getId() == SMSG_NPC_CHOICE
|| msg.getId() == SMSG_NPC_MESSAGE
@@ -251,7 +256,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;
diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h
index f8baff5d3..c4880ac15 100644
--- a/src/net/tmwa/npchandler.h
+++ b/src/net/tmwa/npchandler.h
@@ -39,35 +39,37 @@ 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;
- int getNpc(Net::MessageIn &msg) override final;
+ BeingId getNpc(Net::MessageIn &msg) override final;
void produceMix(const int nameId,
const int materialId1,
diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp
index 6f8787be4..8bb143d75 100644
--- a/src/net/tmwa/partyhandler.cpp
+++ b/src/net/tmwa/partyhandler.cpp
@@ -128,7 +128,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");
}
}
@@ -139,7 +139,7 @@ void PartyHandler::inviteResponse(const std::string &inviter A_UNUSED,
if (localPlayer)
{
createOutPacket(CMSG_PARTY_INVITED);
- outMsg.writeInt32(localPlayer->getId(), "account id");
+ outMsg.writeBeingId(localPlayer->getId(), "account id");
outMsg.writeInt32(accept ? 1 : 0, "accept");
}
}
@@ -154,7 +154,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("", 24, "unused");
}
}
@@ -172,7 +172,7 @@ void PartyHandler::kick(const std::string &name) const
}
createOutPacket(CMSG_PARTY_KICK);
- outMsg.writeInt32(m->getID(), "member id");
+ outMsg.writeBeingId(m->getID(), "member id");
outMsg.writeString(name, 24, "unused");
}
@@ -265,7 +265,7 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg)
for (int i = 0; i < count; i++)
{
- const int id = msg.readInt32("id");
+ const BeingId id = msg.readBeingId("id");
std::string nick = msg.readString(24, "nick");
std::string map = msg.readString(16, "map");
const bool leader = msg.readUInt8("leader") == 0U;
@@ -329,7 +329,7 @@ void PartyHandler::processPartyMessage(Net::MessageIn &msg)
if (msgLength <= 0)
return;
- const int id = msg.readInt32("id");
+ const BeingId id = msg.readBeingId("id");
const std::string chatMsg = msg.readString(msgLength, "message");
if (Ea::taParty && partyTab)
@@ -386,7 +386,7 @@ void PartyHandler::allowInvite(const bool allow A_UNUSED) const
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;
@@ -406,7 +406,7 @@ void PartyHandler::processPartyInvited(Net::MessageIn &msg)
void PartyHandler::processPartyMove(Net::MessageIn &msg)
{
- const int id = msg.readInt32("id");
+ const BeingId id = msg.readBeingId("id");
PartyMember *m = nullptr;
if (Ea::taParty)
m = Ea::taParty->getMember(id);
@@ -437,7 +437,7 @@ void PartyHandler::processPartyMove(Net::MessageIn &msg)
void PartyHandler::processPartyUpdateHp(Net::MessageIn &msg)
{
- const int id = msg.readInt32("id");
+ const BeingId id = msg.readBeingId("id");
const int hp = msg.readInt16("hp");
const int maxhp = msg.readInt16("max hp");
PartyMember *m = nullptr;
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index c78382f27..95b157c00 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -124,10 +124,11 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
BLOCK_END("PlayerHandler::handleMessage")
}
-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
@@ -170,7 +171,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");
TmwAthena::InventoryHandler *const handler =
static_cast<TmwAthena::InventoryHandler*>(inventoryHandler);
if (handler)
diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h
index f0162c8f2..d8f159e8b 100644
--- a/src/net/tmwa/playerhandler.h
+++ b/src/net/tmwa/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/tmwa/skillhandler.cpp b/src/net/tmwa/skillhandler.cpp
index 1b8678682..5e8dd9729 100644
--- a/src/net/tmwa/skillhandler.cpp
+++ b/src/net/tmwa/skillhandler.cpp
@@ -82,12 +82,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>(id), "skill id");
outMsg.writeInt16(static_cast<int16_t>(level), "level");
- outMsg.writeInt32(beingId, "target id");
+ outMsg.writeBeingId(beingId, "target id");
}
void SkillHandler::usePos(const int id, const int level,
diff --git a/src/net/tmwa/skillhandler.h b/src/net/tmwa/skillhandler.h
index 047ae6330..62bab67d4 100644
--- a/src/net/tmwa/skillhandler.h
+++ b/src/net/tmwa/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/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp
index 5962ff89a..4ad803640 100644
--- a/src/net/tmwa/tradehandler.cpp
+++ b/src/net/tmwa/tradehandler.cpp
@@ -118,7 +118,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