summaryrefslogtreecommitdiff
path: root/src/net/eathena
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/eathena')
-rw-r--r--src/net/eathena/adminhandler.cpp22
-rw-r--r--src/net/eathena/auctionhandler.cpp6
-rw-r--r--src/net/eathena/bankrecv.cpp6
-rw-r--r--src/net/eathena/battlegroundhandler.cpp4
-rw-r--r--src/net/eathena/beinghandler.cpp2
-rw-r--r--src/net/eathena/beingrecv.cpp62
-rw-r--r--src/net/eathena/buyingstorehandler.cpp12
-rw-r--r--src/net/eathena/cashshophandler.cpp6
-rw-r--r--src/net/eathena/charserverhandler.cpp16
-rw-r--r--src/net/eathena/charserverrecv.cpp6
-rw-r--r--src/net/eathena/chathandler.cpp44
-rw-r--r--src/net/eathena/generalrecv.cpp2
-rw-r--r--src/net/eathena/guildhandler.cpp8
-rw-r--r--src/net/eathena/guildrecv.cpp4
-rw-r--r--src/net/eathena/homunculushandler.cpp10
-rw-r--r--src/net/eathena/inventoryhandler.cpp26
-rw-r--r--src/net/eathena/inventoryrecv.cpp2
-rw-r--r--src/net/eathena/itemrecv.cpp16
-rw-r--r--src/net/eathena/mailhandler.cpp12
-rw-r--r--src/net/eathena/markethandler.cpp16
-rw-r--r--src/net/eathena/mercenaryhandler.cpp10
-rw-r--r--src/net/eathena/messagein.cpp24
-rw-r--r--src/net/eathena/messageout.cpp36
-rw-r--r--src/net/eathena/network.cpp4
-rw-r--r--src/net/eathena/npchandler.cpp48
-rw-r--r--src/net/eathena/partyhandler.cpp16
-rw-r--r--src/net/eathena/pethandler.cpp4
-rw-r--r--src/net/eathena/playerhandler.cpp18
-rw-r--r--src/net/eathena/playerrecv.cpp2
-rw-r--r--src/net/eathena/questhandler.cpp2
-rw-r--r--src/net/eathena/searchstorehandler.cpp6
-rw-r--r--src/net/eathena/skillhandler.cpp22
-rw-r--r--src/net/eathena/skillrecv.cpp10
-rw-r--r--src/net/eathena/tradehandler.cpp4
-rw-r--r--src/net/eathena/vendinghandler.cpp16
35 files changed, 252 insertions, 252 deletions
diff --git a/src/net/eathena/adminhandler.cpp b/src/net/eathena/adminhandler.cpp
index 14afde54c..6c7914a32 100644
--- a/src/net/eathena/adminhandler.cpp
+++ b/src/net/eathena/adminhandler.cpp
@@ -45,15 +45,15 @@ AdminHandler::AdminHandler() :
void AdminHandler::announce(const std::string &text) const
{
createOutPacket(CMSG_ADMIN_ANNOUNCE);
- outMsg.writeInt16(static_cast<int16_t>(text.length() + 4), "len");
- outMsg.writeString(text, static_cast<int>(text.length()), "message");
+ outMsg.writeInt16(CAST_S16(text.length() + 4), "len");
+ outMsg.writeString(text, CAST_S32(text.length()), "message");
}
void AdminHandler::localAnnounce(const std::string &text) const
{
createOutPacket(CMSG_ADMIN_LOCAL_ANNOUNCE);
- outMsg.writeInt16(static_cast<int16_t>(text.length() + 4), "len");
- outMsg.writeString(text, static_cast<int>(text.length()), "message");
+ outMsg.writeInt16(CAST_S16(text.length() + 4), "len");
+ outMsg.writeString(text, CAST_S32(text.length()), "message");
}
void AdminHandler::hide(const bool h A_UNUSED) const
@@ -77,8 +77,8 @@ void AdminHandler::warp(const std::string &map, const int x, const int y) const
{
createOutPacket(CMSG_PLAYER_MAPMOVE);
outMsg.writeString(map, 16, "map");
- outMsg.writeInt16(static_cast<int16_t>(x), "x");
- outMsg.writeInt16(static_cast<int16_t>(y), "y");
+ outMsg.writeInt16(CAST_S16(x), "x");
+ outMsg.writeInt16(CAST_S16(y), "y");
}
void AdminHandler::resetStats() const
@@ -114,8 +114,8 @@ void AdminHandler::mute(const Being *const being,
createOutPacket(CMSG_ADMIN_MUTE);
outMsg.writeBeingId(being->getId(), "account id");
- outMsg.writeInt8(static_cast<int8_t>(type), "type");
- outMsg.writeInt16(static_cast<int16_t>(limit), "value");
+ outMsg.writeInt8(CAST_S8(type), "type");
+ outMsg.writeInt16(CAST_S16(limit), "value");
}
void AdminHandler::muteName(const std::string &name) const
@@ -137,9 +137,9 @@ void AdminHandler::setTileType(const int x, const int y,
const int type) const
{
createOutPacket(CMSG_ADMIN_SET_TILE_TYPE);
- outMsg.writeInt16(static_cast<int16_t>(x), "x");
- outMsg.writeInt16(static_cast<int16_t>(y), "y");
- outMsg.writeInt16(static_cast<int16_t>(type), "type");
+ outMsg.writeInt16(CAST_S16(x), "x");
+ outMsg.writeInt16(CAST_S16(y), "y");
+ outMsg.writeInt16(CAST_S16(type), "type");
}
void AdminHandler::unequipAll(const Being *const being) const
diff --git a/src/net/eathena/auctionhandler.cpp b/src/net/eathena/auctionhandler.cpp
index fdd5e901f..fb9731c95 100644
--- a/src/net/eathena/auctionhandler.cpp
+++ b/src/net/eathena/auctionhandler.cpp
@@ -51,7 +51,7 @@ void AuctionHandler::setItem(const Item *const item,
if (!item)
return;
createOutPacket(CMSG_AUCTION_SET_ITEM);
- outMsg.writeInt16(static_cast<int16_t>(
+ outMsg.writeInt16(CAST_S16(
item->getInvIndex() + INVENTORY_OFFSET), "index");
outMsg.writeInt32(amount, "amount"); // always 1
}
@@ -92,10 +92,10 @@ void AuctionHandler::search(const AuctionSearchTypeT type,
const int page) const
{
createOutPacket(CMSG_AUCTION_SEARCH);
- outMsg.writeInt16(static_cast<int16_t>(type), "search type");
+ outMsg.writeInt16(CAST_S16(type), "search type");
outMsg.writeInt32(auctionId, "auction id");
outMsg.writeString(text, 24, "search text");
- outMsg.writeInt16(static_cast<int16_t>(page), "page");
+ outMsg.writeInt16(CAST_S16(page), "page");
}
void AuctionHandler::buy() const
diff --git a/src/net/eathena/bankrecv.cpp b/src/net/eathena/bankrecv.cpp
index 6a0670229..bea7a01df 100644
--- a/src/net/eathena/bankrecv.cpp
+++ b/src/net/eathena/bankrecv.cpp
@@ -35,7 +35,7 @@ namespace EAthena
void BankRecv::processBankStatus(Net::MessageIn &msg)
{
- const int money = static_cast<int>(msg.readInt64("money"));
+ const int money = CAST_S32(msg.readInt64("money"));
msg.readInt16("reason");
BankListener::distributeEvent(money);
}
@@ -43,7 +43,7 @@ void BankRecv::processBankStatus(Net::MessageIn &msg)
void BankRecv::processBankDeposit(Net::MessageIn &msg)
{
const int reason = msg.readInt16("reason");
- const int money = static_cast<int>(msg.readInt64("money"));
+ const int money = CAST_S32(msg.readInt64("money"));
msg.readInt32("balance");
BankListener::distributeEvent(money);
if (reason)
@@ -53,7 +53,7 @@ void BankRecv::processBankDeposit(Net::MessageIn &msg)
void BankRecv::processBankWithdraw(Net::MessageIn &msg)
{
const int reason = msg.readInt16("reason");
- const int money = static_cast<int>(msg.readInt64("money"));
+ const int money = CAST_S32(msg.readInt64("money"));
msg.readInt32("balance");
BankListener::distributeEvent(money);
if (reason)
diff --git a/src/net/eathena/battlegroundhandler.cpp b/src/net/eathena/battlegroundhandler.cpp
index fa3c2d337..723ab3bfe 100644
--- a/src/net/eathena/battlegroundhandler.cpp
+++ b/src/net/eathena/battlegroundhandler.cpp
@@ -39,7 +39,7 @@ void BattleGroundHandler::registerBg(const BattleGroundTypeT &type,
const std::string &name) const
{
createOutPacket(CMSG_BATTLE_REGISTER);
- outMsg.writeInt16(static_cast<int16_t>(type), "type");
+ outMsg.writeInt16(CAST_S16(type), "type");
outMsg.writeString(name, 24, "bg name");
}
@@ -54,7 +54,7 @@ void BattleGroundHandler::beginAck(const bool result,
const std::string &gameName) const
{
createOutPacket(CMSG_BATTLE_BEGIN_ACK);
- outMsg.writeInt8(static_cast<int8_t>(result ? 1 : 0), "result");
+ outMsg.writeInt8(CAST_S8(result ? 1 : 0), "result");
outMsg.writeString(bgName, 24, "bg name");
outMsg.writeString(gameName, 24, "game name");
}
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index bfb72e911..143d7dc9e 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -69,7 +69,7 @@ void BeingHandler::undress(Being *const being) const
void BeingHandler::requestRanks(const RankT rank) const
{
createOutPacket(CMSG_REQUEST_RANKS);
- outMsg.writeInt16(static_cast<int16_t>(rank), "type");
+ outMsg.writeInt16(CAST_S16(rank), "type");
}
void BeingHandler::viewPlayerEquipment(const Being *const being)
diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp
index 816b8913b..88db63c8f 100644
--- a/src/net/eathena/beingrecv.cpp
+++ b/src/net/eathena/beingrecv.cpp
@@ -189,7 +189,7 @@ void BeingRecv::processBeingChangeLookContinue(Net::MessageIn &msg,
fromInt(id, ItemColor)));
break;
case 7: // Clothes color. Now used as look
- dstBeing->setLook(static_cast<uint8_t>(id));
+ dstBeing->setLook(CAST_U8(id));
break;
case 8: // eAthena LOOK_SHIELD
dstBeing->setSprite(SPRITE_FLOOR, id, color, itemColor);
@@ -271,7 +271,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
const uint16_t stunMode = msg.readInt16("opt1");
// probably wrong effect usage
uint32_t statusEffects = msg.readInt16("opt2");
- statusEffects |= (static_cast<uint32_t>(msg.readInt32("option"))) << 16;
+ statusEffects |= (CAST_U32(msg.readInt32("option"))) << 16;
const int16_t job = msg.readInt16("class");
Being *dstBeing = actorManager->findBeing(id);
@@ -324,7 +324,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
localPlayer->checkNewName(dstBeing);
const int hairStyle = msg.readInt16("hair style");
- const uint32_t weapon = static_cast<uint32_t>(msg.readInt32("weapon"));
+ const uint32_t weapon = CAST_U32(msg.readInt32("weapon"));
const uint16_t headBottom = msg.readInt16("head bottom");
const uint16_t headTop = msg.readInt16("head top");
@@ -339,10 +339,10 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
msg.readInt32("guild id");
msg.readInt16("guild emblem");
dstBeing->setManner(msg.readInt16("manner"));
- dstBeing->setStatusEffectBlock(32, static_cast<uint16_t>(
+ dstBeing->setStatusEffectBlock(32, CAST_U16(
msg.readInt32("opt3")));
dstBeing->setKarma(msg.readUInt8("karma"));
- uint8_t gender = static_cast<uint8_t>(msg.readUInt8("gender") & 3);
+ uint8_t gender = CAST_U8(msg.readUInt8("gender") & 3);
if (dstBeing->getType() == ActorType::Player)
{
@@ -390,7 +390,7 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
dstBeing->setDirection(dir);
- const int level = static_cast<int>(msg.readInt16("level"));
+ const int level = CAST_S32(msg.readInt16("level"));
if (level)
dstBeing->setLevel(level);
msg.readInt16("font");
@@ -405,9 +405,9 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg)
msg.readInt16("body2");
dstBeing->setStunMode(stunMode);
- dstBeing->setStatusEffectBlock(0, static_cast<uint16_t>(
+ dstBeing->setStatusEffectBlock(0, CAST_U16(
(statusEffects >> 16) & 0xffffU));
- dstBeing->setStatusEffectBlock(16, static_cast<uint16_t>(
+ dstBeing->setStatusEffectBlock(16, CAST_U16(
statusEffects & 0xffffU));
}
@@ -443,7 +443,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
// msg.readInt16("body state");
// msg.readInt16("health state");
// }
- statusEffects |= (static_cast<uint32_t>(msg.readInt32("option"))) << 16;
+ statusEffects |= (CAST_U32(msg.readInt32("option"))) << 16;
const int16_t job = msg.readInt16("class");
Being *dstBeing = actorManager->findBeing(id);
@@ -488,7 +488,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
localPlayer->checkNewName(dstBeing);
const int hairStyle = msg.readInt16("hair style");
- const uint32_t weapon = static_cast<uint32_t>(msg.readInt32("weapon"));
+ const uint32_t weapon = CAST_U32(msg.readInt32("weapon"));
const uint16_t headBottom = msg.readInt16("head bottom");
msg.readInt32("tick");
@@ -505,10 +505,10 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
msg.readInt32("guild id");
msg.readInt16("guild emblem");
dstBeing->setManner(msg.readInt16("manner"));
- dstBeing->setStatusEffectBlock(32, static_cast<uint16_t>(
+ dstBeing->setStatusEffectBlock(32, CAST_U16(
msg.readInt32("opt3")));
dstBeing->setKarma(msg.readUInt8("karma"));
- uint8_t gender = static_cast<uint8_t>(msg.readUInt8("gender") & 3);
+ uint8_t gender = CAST_U8(msg.readUInt8("gender") & 3);
if (dstBeing->getType() == ActorType::Player)
{
@@ -568,7 +568,7 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
if (d && dstBeing->getDirection() != d)
dstBeing->setDirection(d);
- const int level = static_cast<int>(msg.readInt16("level"));
+ const int level = CAST_S32(msg.readInt16("level"));
if (level)
dstBeing->setLevel(level);
msg.readInt16("font");
@@ -583,9 +583,9 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg)
msg.readInt16("body2");
dstBeing->setStunMode(stunMode);
- dstBeing->setStatusEffectBlock(0, static_cast<uint16_t>(
+ dstBeing->setStatusEffectBlock(0, CAST_U16(
(statusEffects >> 16) & 0xffffU));
- dstBeing->setStatusEffectBlock(16, static_cast<uint16_t>(
+ dstBeing->setStatusEffectBlock(16, CAST_U16(
statusEffects & 0xffffU));
}
@@ -617,7 +617,7 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg)
// msg.readInt16("body state");
// msg.readInt16("health state");
// }
- statusEffects |= (static_cast<uint32_t>(msg.readInt32("option"))) << 16;
+ statusEffects |= (CAST_U32(msg.readInt32("option"))) << 16;
const int16_t job = msg.readInt16("class");
Being *dstBeing = actorManager->findBeing(id);
@@ -662,7 +662,7 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg)
localPlayer->checkNewName(dstBeing);
const int hairStyle = msg.readInt16("hair style");
- const uint32_t weapon = static_cast<uint32_t>(msg.readInt32("weapon"));
+ const uint32_t weapon = CAST_U32(msg.readInt32("weapon"));
const uint16_t headBottom = msg.readInt16("head bottom");
const uint16_t headTop = msg.readInt16("head top");
@@ -676,10 +676,10 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg)
msg.readInt32("guild id");
msg.readInt16("guild emblem");
dstBeing->setManner(msg.readInt16("manner"));
- dstBeing->setStatusEffectBlock(32, static_cast<uint16_t>(
+ dstBeing->setStatusEffectBlock(32, CAST_U16(
msg.readInt32("opt3")));
dstBeing->setKarma(msg.readUInt8("karma"));
- uint8_t gender = static_cast<uint8_t>(msg.readUInt8("gender") & 3);
+ uint8_t gender = CAST_U8(msg.readUInt8("gender") & 3);
if (dstBeing->getType() == ActorType::Player)
{
@@ -726,7 +726,7 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg)
dstBeing->setDirection(dir);
- const int level = static_cast<int>(msg.readInt16("level"));
+ const int level = CAST_S32(msg.readInt16("level"));
if (level)
dstBeing->setLevel(level);
msg.readInt16("font");
@@ -741,9 +741,9 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg)
msg.readInt16("body2");
dstBeing->setStunMode(stunMode);
- dstBeing->setStatusEffectBlock(0, static_cast<uint16_t>(
+ dstBeing->setStatusEffectBlock(0, CAST_U16(
(statusEffects >> 16) & 0xffffU));
- dstBeing->setStatusEffectBlock(16, static_cast<uint16_t>(
+ dstBeing->setStatusEffectBlock(16, CAST_U16(
statusEffects & 0xffffU));
}
@@ -755,7 +755,7 @@ void BeingRecv::processMapTypeProperty(Net::MessageIn &msg)
{
// +++ need get other flags from here
MapTypeProperty2 props;
- props.data = static_cast<uint32_t>(flags);
+ props.data = CAST_U32(flags);
Game *const game = Game::instance();
if (!game)
return;
@@ -1103,7 +1103,7 @@ void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg)
msg.readInt16("head direction");
const uint8_t dir = Net::MessageIn::fromServerDirection(
- static_cast<uint8_t>(msg.readUInt8("player direction") & 0x0FU));
+ CAST_U8(msg.readUInt8("player direction") & 0x0FU));
if (!dstBeing)
{
@@ -1207,13 +1207,13 @@ void BeingRecv::processPlaterStatusChange(Net::MessageIn &msg)
const uint16_t stunMode = msg.readInt16("stun mode");
uint32_t statusEffects = msg.readInt16("status effect");
- statusEffects |= (static_cast<uint32_t>(msg.readInt32("option"))) << 16;
+ statusEffects |= (CAST_U32(msg.readInt32("option"))) << 16;
dstBeing->setKarma(msg.readUInt8("karma"));
dstBeing->setStunMode(stunMode);
- dstBeing->setStatusEffectBlock(0, static_cast<uint16_t>(
+ dstBeing->setStatusEffectBlock(0, CAST_U16(
(statusEffects >> 16) & 0xffff));
- dstBeing->setStatusEffectBlock(16, static_cast<uint16_t>(
+ dstBeing->setStatusEffectBlock(16, CAST_U16(
statusEffects & 0xffff));
BLOCK_END("BeingRecv::processPlayerStop")
}
@@ -1234,9 +1234,9 @@ void BeingRecv::processPlaterStatusChange2(Net::MessageIn &msg)
dstBeing->setLevel(msg.readInt32("level"));
msg.readInt32("showEFST");
- dstBeing->setStatusEffectBlock(0, static_cast<uint16_t>(
+ dstBeing->setStatusEffectBlock(0, CAST_U16(
(statusEffects >> 16) & 0xffff));
- dstBeing->setStatusEffectBlock(16, static_cast<uint16_t>(
+ dstBeing->setStatusEffectBlock(16, CAST_U16(
statusEffects & 0xffff));
}
@@ -1698,14 +1698,14 @@ Being *BeingRecv::createBeing2(Net::MessageIn &msg,
case BeingType::ITEM:
case BeingType::ELEMENTAL:
logger->log("not supported object type: %d, job: %d",
- static_cast<int>(beingType), static_cast<int>(job));
+ CAST_S32(beingType), CAST_S32(job));
break;
case BeingType::CHAT:
default:
UNIMPLIMENTEDPACKET;
type = ActorType::Monster;
logger->log("not supported object type: %d, job: %d",
- static_cast<int>(beingType), static_cast<int>(job));
+ CAST_S32(beingType), CAST_S32(job));
break;
}
if (job == 45 && beingType == BeingType::NPC_EVENT)
diff --git a/src/net/eathena/buyingstorehandler.cpp b/src/net/eathena/buyingstorehandler.cpp
index a850a8785..5fcc9c4aa 100644
--- a/src/net/eathena/buyingstorehandler.cpp
+++ b/src/net/eathena/buyingstorehandler.cpp
@@ -48,15 +48,15 @@ void BuyingStoreHandler::create(const std::string &name,
std::vector<ShopItem*> &items) const
{
createOutPacket(CMSG_BUYINGSTORE_CREATE);
- outMsg.writeInt16(static_cast<int16_t>(89 + items.size() * 8), "len");
+ outMsg.writeInt16(CAST_S16(89 + items.size() * 8), "len");
outMsg.writeInt32(maxMoney, "limit money");
outMsg.writeInt8(flag, "flag");
outMsg.writeString(name, 80, "store name");
FOR_EACH (std::vector<ShopItem*>::const_iterator, it, items)
{
const ShopItem *const item = *it;
- outMsg.writeInt16(static_cast<int16_t>(item->getId()), "item id");
- outMsg.writeInt16(static_cast<int16_t>(item->getQuantity()), "amount");
+ outMsg.writeInt16(CAST_S16(item->getId()), "item id");
+ outMsg.writeInt16(CAST_S16(item->getQuantity()), "amount");
outMsg.writeInt32(item->getPrice(), "price");
}
}
@@ -87,11 +87,11 @@ void BuyingStoreHandler::sell(const Being *const being,
outMsg.writeInt16(18, "len");
outMsg.writeBeingId(being->getId(), "account id");
outMsg.writeInt32(storeId, "store id");
- outMsg.writeInt16(static_cast<int16_t>(
+ outMsg.writeInt16(CAST_S16(
item->getInvIndex() + INVENTORY_OFFSET),
"index");
- outMsg.writeInt16(static_cast<int16_t>(item->getId()), "item id");
- outMsg.writeInt16(static_cast<int16_t>(amount), "amount");
+ outMsg.writeInt16(CAST_S16(item->getId()), "item id");
+ outMsg.writeInt16(CAST_S16(amount), "amount");
}
} // namespace EAthena
diff --git a/src/net/eathena/cashshophandler.cpp b/src/net/eathena/cashshophandler.cpp
index 53b9d90e2..026297673 100644
--- a/src/net/eathena/cashshophandler.cpp
+++ b/src/net/eathena/cashshophandler.cpp
@@ -46,8 +46,8 @@ void CashShopHandler::buyItem(const int points,
outMsg.writeInt16(10 + 4, "len");
outMsg.writeInt32(points, "points");
outMsg.writeInt16(1, "count");
- outMsg.writeInt16(static_cast<int16_t>(amount), "amount");
- outMsg.writeInt16(static_cast<int16_t>(itemId), "item id");
+ outMsg.writeInt16(CAST_S16(amount), "amount");
+ outMsg.writeInt16(CAST_S16(itemId), "item id");
}
void CashShopHandler::buyItems(std::vector<ShopItem*> &items A_UNUSED) const
@@ -68,7 +68,7 @@ void CashShopHandler::requestPoints() const
void CashShopHandler::requestTab(const int tab) const
{
createOutPacket(CMSG_NPC_CASH_SHOP_REQUEST_TAB);
- outMsg.writeInt16(static_cast<int16_t>(tab), "tab");
+ outMsg.writeInt16(CAST_S16(tab), "tab");
}
void CashShopHandler::schedule() const
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
index 37e2e72ea..ce84840ca 100644
--- a/src/net/eathena/charserverhandler.cpp
+++ b/src/net/eathena/charserverhandler.cpp
@@ -66,7 +66,7 @@ void CharServerHandler::chooseCharacter(Net::Character *const character)
mCharSelectDialog = nullptr;
createOutPacket(CMSG_CHAR_SELECT);
- outMsg.writeInt8(static_cast<unsigned char>(
+ outMsg.writeInt8(CAST_U8(
mSelectedCharacter->slot), "slot");
}
@@ -81,11 +81,11 @@ void CharServerHandler::newCharacter(const std::string &name, const int slot,
createOutPacket(CMSG_CHAR_CREATE);
outMsg.writeString(name, 24, "login");
- outMsg.writeInt8(static_cast<unsigned char>(slot), "slot");
- outMsg.writeInt16(static_cast<int16_t>(hairColor), "hair color");
- outMsg.writeInt16(static_cast<int16_t>(hairstyle), "hair style");
+ outMsg.writeInt8(CAST_U8(slot), "slot");
+ outMsg.writeInt16(CAST_S16(hairColor), "hair color");
+ outMsg.writeInt16(CAST_S16(hairstyle), "hair style");
if (serverFeatures->haveRaceSelection())
- outMsg.writeInt16(static_cast<int16_t>(race), "race");
+ outMsg.writeInt16(CAST_S16(race), "race");
if (serverFeatures->haveCreateCharGender())
{
uint8_t sex = 0;
@@ -96,7 +96,7 @@ void CharServerHandler::newCharacter(const std::string &name, const int slot,
outMsg.writeInt8(sex, "gender");
}
if (serverFeatures->haveLookSelection())
- outMsg.writeInt16(static_cast<int16_t>(look), "look");
+ outMsg.writeInt16(CAST_S16(look), "look");
}
void CharServerHandler::deleteCharacter(Net::Character *const character,
@@ -180,8 +180,8 @@ void CharServerHandler::renameCharacter(const BeingId id,
void CharServerHandler::changeSlot(const int oldSlot, const int newSlot)
{
createOutPacket(CMSG_CHAR_CHANGE_SLOT);
- outMsg.writeInt16(static_cast<int16_t>(oldSlot), "old slot");
- outMsg.writeInt16(static_cast<int16_t>(newSlot), "new slot");
+ outMsg.writeInt16(CAST_S16(oldSlot), "old slot");
+ outMsg.writeInt16(CAST_S16(newSlot), "new slot");
outMsg.writeInt16(0, "unused");
}
diff --git a/src/net/eathena/charserverrecv.cpp b/src/net/eathena/charserverrecv.cpp
index e2b7567e3..03ca40aaa 100644
--- a/src/net/eathena/charserverrecv.cpp
+++ b/src/net/eathena/charserverrecv.cpp
@@ -166,7 +166,7 @@ void CharServerRecv::readPlayerData(Net::MessageIn &msg,
msg.readInt32("slot change");
tempPlayer->setRename(msg.readInt32("rename (inverse)"));
- const uint8_t gender = static_cast<uint8_t>(msg.readUInt8("gender"));
+ const uint8_t gender = CAST_U8(msg.readUInt8("gender"));
if (gender != 99)
tempPlayer->setGender(Being::intToGender(gender));
}
@@ -177,7 +177,7 @@ void CharServerRecv::processCharLogin(Net::MessageIn &msg)
const int slots = msg.readInt8("MAX_CHARS");
msg.readInt8("sd->char_slots");
msg.readInt8("MAX_CHARS");
- loginData.characterSlots = static_cast<uint16_t>(slots);
+ loginData.characterSlots = CAST_U16(slots);
msg.skip(20, "unused 0");
@@ -290,7 +290,7 @@ void CharServerRecv::processPincodeStatus(Net::MessageIn &msg)
{
mPinSeed = msg.readInt32("pincode seed");
mPinAccountId = msg.readBeingId("account id");
- const uint16_t state = static_cast<uint16_t>(msg.readInt16("state"));
+ const uint16_t state = CAST_U16(msg.readInt16("state"));
switch (state)
{
case 0: // pin ok
diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp
index 236fd5895..353a82b0e 100644
--- a/src/net/eathena/chathandler.cpp
+++ b/src/net/eathena/chathandler.cpp
@@ -60,24 +60,24 @@ void ChatHandler::talk(const std::string &restrict text,
createOutPacket(CMSG_CHAT_MESSAGE);
// Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4 + 1), "len");
- outMsg.writeString(mes, static_cast<int>(mes.length() + 1), "message");
+ outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len");
+ outMsg.writeString(mes, CAST_S32(mes.length() + 1), "message");
}
void ChatHandler::talkRaw(const std::string &mes) const
{
createOutPacket(CMSG_CHAT_MESSAGE);
- outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4), "len");
- outMsg.writeString(mes, static_cast<int>(mes.length()), "message");
+ outMsg.writeInt16(CAST_S16(mes.length() + 4), "len");
+ outMsg.writeString(mes, CAST_S32(mes.length()), "message");
}
void ChatHandler::privateMessage(const std::string &restrict recipient,
const std::string &restrict text)
{
createOutPacket(CMSG_CHAT_WHISPER);
- outMsg.writeInt16(static_cast<int16_t>(text.length() + 28 + 1), "len");
+ outMsg.writeInt16(CAST_S16(text.length() + 28 + 1), "len");
outMsg.writeString(recipient, 24, "recipient nick");
- outMsg.writeString(text, static_cast<int>(text.length()), "message");
+ outMsg.writeString(text, CAST_S32(text.length()), "message");
outMsg.writeInt8(0, "null char");
Ea::ChatRecv::mSentWhispers.push(recipient);
}
@@ -107,7 +107,7 @@ void ChatHandler::sendRaw(const std::string &args) const
{
str = line.substr(0, pos);
- const int16_t id = static_cast<int16_t>(parseNumber(str));
+ const int16_t id = CAST_S16(parseNumber(str));
outMsg = new MessageOut(id);
outMsg->writeInt16(id, "packet id");
line = line.substr(pos + 1);
@@ -115,7 +115,7 @@ void ChatHandler::sendRaw(const std::string &args) const
}
else
{
- const int16_t id = static_cast<int16_t>(parseNumber(line));
+ const int16_t id = CAST_S16(parseNumber(line));
outMsg = new MessageOut(id);
outMsg->writeInt16(id, "packet id");
delete outMsg;
@@ -145,17 +145,17 @@ void ChatHandler::processRaw(MessageOut &restrict outMsg,
{
case 'b':
{
- outMsg.writeInt8(static_cast<unsigned char>(i), "raw");
+ outMsg.writeInt8(CAST_U8(i), "raw");
break;
}
case 'w':
{
- outMsg.writeInt16(static_cast<int16_t>(i), "raw");
+ outMsg.writeInt16(CAST_S16(i), "raw");
break;
}
case 'l':
{
- outMsg.writeInt32(static_cast<int32_t>(i), "raw");
+ outMsg.writeInt32(CAST_S32(i), "raw");
break;
}
default:
@@ -201,10 +201,10 @@ void ChatHandler::createChatRoom(const std::string &title,
const bool isPublic)
{
createOutPacket(CMSG_CREAYE_CHAT_ROOM);
- outMsg.writeInt16(static_cast<int16_t>(
+ outMsg.writeInt16(CAST_S16(
7 + 8 + 36), "len");
- outMsg.writeInt16(static_cast<int16_t>(limit), "limit");
- outMsg.writeInt8(static_cast<int8_t>(isPublic ? 1 : 0), "public");
+ outMsg.writeInt16(CAST_S16(limit), "limit");
+ outMsg.writeInt8(CAST_S8(isPublic ? 1 : 0), "public");
outMsg.writeString(password, 8, "password");
outMsg.writeString(title, 36, "title");
ChatRecv::mChatRoom = title;
@@ -220,8 +220,8 @@ void ChatHandler::battleTalk(const std::string &text) const
createOutPacket(CMSG_BATTLE_CHAT_MESSAGE);
// Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4 + 1), "len");
- outMsg.writeString(mes, static_cast<int>(mes.length() + 1), "message");
+ outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len");
+ outMsg.writeString(mes, CAST_S32(mes.length() + 1), "message");
}
void ChatHandler::joinChat(const ChatObject *const chat,
@@ -268,8 +268,8 @@ void ChatHandler::talkPet(const std::string &restrict text,
const size_t sz = msg.size();
createOutPacket(CMSG_PET_TALK);
- outMsg.writeInt16(static_cast<int16_t>(sz + 4 + 1), "len");
- outMsg.writeString(msg, static_cast<int>(sz), "message");
+ outMsg.writeInt16(CAST_S16(sz + 4 + 1), "len");
+ outMsg.writeString(msg, CAST_S32(sz), "message");
outMsg.writeInt8(0, "zero byte");
}
@@ -284,10 +284,10 @@ void ChatHandler::setChatRoomOptions(const int limit,
const std::string &title) const
{
createOutPacket(CMSG_SET_CHAT_ROOM_OPTIONS);
- const int sz = static_cast<int>(title.size());
- outMsg.writeInt16(static_cast<int16_t>(15 + sz), "len");
- outMsg.writeInt16(static_cast<int16_t>(limit), "limit");
- outMsg.writeInt8(static_cast<int8_t>(isPublic ? 1 : 0), "type");
+ const int sz = CAST_S32(title.size());
+ outMsg.writeInt16(CAST_S16(15 + sz), "len");
+ outMsg.writeInt16(CAST_S16(limit), "limit");
+ outMsg.writeInt8(CAST_S8(isPublic ? 1 : 0), "type");
outMsg.writeString(password, 8, "password");
outMsg.writeString(title, sz, "title");
}
diff --git a/src/net/eathena/generalrecv.cpp b/src/net/eathena/generalrecv.cpp
index 48e079d09..1bba1cc3e 100644
--- a/src/net/eathena/generalrecv.cpp
+++ b/src/net/eathena/generalrecv.cpp
@@ -40,7 +40,7 @@ ServerInfo mapServer;
void GeneralRecv::processConnectionProblem(Net::MessageIn &msg)
{
const uint8_t code = msg.readUInt8("flag");
- logger->log("Connection problem: %u", static_cast<unsigned int>(code));
+ logger->log("Connection problem: %u", CAST_U32(code));
switch (code)
{
diff --git a/src/net/eathena/guildhandler.cpp b/src/net/eathena/guildhandler.cpp
index 99cf1f3f9..bc4d70f57 100644
--- a/src/net/eathena/guildhandler.cpp
+++ b/src/net/eathena/guildhandler.cpp
@@ -125,8 +125,8 @@ void GuildHandler::chat(const std::string &text) const
const std::string str = std::string(localPlayer->getName()).append(
" : ").append(text);
createOutPacket(CMSG_GUILD_MESSAGE);
- outMsg.writeInt16(static_cast<uint16_t>(str.size() + 4 + 1), "len");
- outMsg.writeString(str, static_cast<int>(str.length()), "message");
+ outMsg.writeInt16(CAST_U16(str.size() + 4 + 1), "len");
+ outMsg.writeString(str, CAST_S32(str.length()), "message");
outMsg.writeInt8(0, "zero byte");
}
@@ -245,8 +245,8 @@ void GuildHandler::changeEmblem(std::string emblem) const
createOutPacket(CMSG_GUILD_CHANGE_EMBLEM);
if (emblem.size() > 200)
emblem = emblem.substr(0, 200);
- const int sz = static_cast<int>(emblem.size());
- outMsg.writeInt16(static_cast<int16_t>(sz + 4), "len");
+ const int sz = CAST_S32(emblem.size());
+ outMsg.writeInt16(CAST_S16(sz + 4), "len");
outMsg.writeString(emblem, sz, "emblem");
}
diff --git a/src/net/eathena/guildrecv.cpp b/src/net/eathena/guildrecv.cpp
index d8c0193fb..7adfdfb27 100644
--- a/src/net/eathena/guildrecv.cpp
+++ b/src/net/eathena/guildrecv.cpp
@@ -68,7 +68,7 @@ void GuildRecv::processGuildPositionInfo(Net::MessageIn &msg)
msg.readInt32("unused");
std::string guildName = msg.readString(24, "guild name");
- Guild *const g = Guild::getGuild(static_cast<int16_t>(guildId));
+ Guild *const g = Guild::getGuild(CAST_S16(guildId));
if (!g)
return;
@@ -98,7 +98,7 @@ void GuildRecv::processGuildMemberLogin(Net::MessageIn &msg)
const BeingId accountId = msg.readBeingId("account id");
const int charId = msg.readInt32("char id");
const int online = msg.readInt32("flag");
- const GenderT gender = Being::intToGender(static_cast<uint8_t>(
+ const GenderT gender = Being::intToGender(CAST_U8(
msg.readInt16("sex")));
msg.readInt16("hair");
msg.readInt16("hair color");
diff --git a/src/net/eathena/homunculushandler.cpp b/src/net/eathena/homunculushandler.cpp
index 26b7ed618..9837eccb5 100644
--- a/src/net/eathena/homunculushandler.cpp
+++ b/src/net/eathena/homunculushandler.cpp
@@ -61,8 +61,8 @@ void HomunculusHandler::move(const int x, const int y) const
return;
createOutPacket(CMSG_HOMMERC_MOVE_TO);
outMsg.writeBeingId(id, "homunculus id");
- outMsg.writeCoordinates(static_cast<uint16_t>(x),
- static_cast<uint16_t>(y),
+ outMsg.writeCoordinates(CAST_U16(x),
+ CAST_U16(y),
0U, "position");
}
@@ -75,7 +75,7 @@ void HomunculusHandler::attack(const BeingId targetId,
createOutPacket(CMSG_HOMMERC_ATTACK);
outMsg.writeBeingId(id, "homunculus id");
outMsg.writeBeingId(targetId, "target id");
- outMsg.writeInt8(static_cast<int8_t>(keep == Keep_true ? 1 : 0), "keep");
+ outMsg.writeInt8(CAST_S8(keep == Keep_true ? 1 : 0), "keep");
}
void HomunculusHandler::feed() const
@@ -104,8 +104,8 @@ void HomunculusHandler::talk(const std::string &restrict text) const
const size_t sz = msg.size();
createOutPacket(CMSG_HOMMERC_TALK);
- outMsg.writeInt16(static_cast<int16_t>(sz + 4 + 1), "len");
- outMsg.writeString(msg, static_cast<int>(sz), "message");
+ outMsg.writeInt16(CAST_S16(sz + 4 + 1), "len");
+ outMsg.writeString(msg, CAST_S32(sz), "message");
outMsg.writeInt8(0, "zero byte");
}
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
index fa2905c28..ce87e5660 100644
--- a/src/net/eathena/inventoryhandler.cpp
+++ b/src/net/eathena/inventoryhandler.cpp
@@ -80,7 +80,7 @@ void InventoryHandler::equipItem(const Item *const item) const
return;
createOutPacket(CMSG_PLAYER_EQUIP);
- outMsg.writeInt16(static_cast<int16_t>(
+ outMsg.writeInt16(CAST_S16(
item->getInvIndex() + INVENTORY_OFFSET), "index");
// here we set flag for any slots,
// probably better set to slot from item properties
@@ -93,7 +93,7 @@ void InventoryHandler::unequipItem(const Item *const item) const
return;
createOutPacket(CMSG_PLAYER_UNEQUIP);
- outMsg.writeInt16(static_cast<int16_t>(
+ outMsg.writeInt16(CAST_S16(
item->getInvIndex() + INVENTORY_OFFSET), "index");
}
@@ -103,7 +103,7 @@ void InventoryHandler::useItem(const Item *const item) const
return;
createOutPacket(CMSG_PLAYER_INVENTORY_USE);
- outMsg.writeInt16(static_cast<int16_t>(
+ outMsg.writeInt16(CAST_S16(
item->getInvIndex() + INVENTORY_OFFSET), "index");
outMsg.writeInt32(item->getId(), "unused");
}
@@ -114,9 +114,9 @@ void InventoryHandler::dropItem(const Item *const item, const int amount) const
return;
createOutPacket(CMSG_PLAYER_INVENTORY_DROP);
- outMsg.writeInt16(static_cast<int16_t>(
+ outMsg.writeInt16(CAST_S16(
item->getInvIndex() + INVENTORY_OFFSET), "index");
- outMsg.writeInt16(static_cast<int16_t>(amount), "amount");
+ outMsg.writeInt16(CAST_S16(amount), "amount");
}
void InventoryHandler::closeStorage() const
@@ -157,7 +157,7 @@ void InventoryHandler::moveItem2(const InventoryTypeT source,
if (packet)
{
createOutPacket(packet);
- outMsg.writeInt16(static_cast<int16_t>(slot + offset), "index");
+ outMsg.writeInt16(CAST_S16(slot + offset), "index");
outMsg.writeInt32(amount, "amount");
}
}
@@ -169,7 +169,7 @@ void InventoryHandler::useCard(const Item *const item)
mItemIndex = item->getInvIndex();
createOutPacket(CMSG_PLAYER_USE_CARD);
- outMsg.writeInt16(static_cast<int16_t>(
+ outMsg.writeInt16(CAST_S16(
mItemIndex + INVENTORY_OFFSET), "index");
}
@@ -177,9 +177,9 @@ void InventoryHandler::insertCard(const int cardIndex,
const int itemIndex) const
{
createOutPacket(CMSG_PLAYER_INSERT_CARD);
- outMsg.writeInt16(static_cast<int16_t>(cardIndex + INVENTORY_OFFSET),
+ outMsg.writeInt16(CAST_S16(cardIndex + INVENTORY_OFFSET),
"card index");
- outMsg.writeInt16(static_cast<int16_t>(itemIndex + INVENTORY_OFFSET),
+ outMsg.writeInt16(CAST_S16(itemIndex + INVENTORY_OFFSET),
"item index");
}
@@ -189,7 +189,7 @@ void InventoryHandler::favoriteItem(const Item *const item,
if (!item)
return;
createOutPacket(CMSG_PLAYER_FAVORITE_ITEM);
- outMsg.writeInt16(static_cast<int16_t>(item->getInvIndex()
+ outMsg.writeInt16(CAST_S16(item->getInvIndex()
+ INVENTORY_OFFSET),
"item index");
outMsg.writeInt8(favorite, "favorite flag");
@@ -200,7 +200,7 @@ void InventoryHandler::selectEgg(const Item *const item) const
if (!item)
return;
createOutPacket(CMSG_PET_SELECT_EGG);
- outMsg.writeInt16(static_cast<int16_t>(
+ outMsg.writeInt16(CAST_S16(
item->getInvIndex() + INVENTORY_OFFSET), "index");
menu = MenuType::Unknown;
}
@@ -210,7 +210,7 @@ int InventoryHandler::convertFromServerSlot(const int serverSlot) const
if (serverSlot < 0 || serverSlot > 15)
return 0;
- return static_cast<int>(EQUIP_CONVERT[serverSlot]);
+ return CAST_S32(EQUIP_CONVERT[serverSlot]);
}
void InventoryHandler::selectCart(const BeingId accountId,
@@ -224,7 +224,7 @@ void InventoryHandler::selectCart(const BeingId accountId,
void InventoryHandler::identifyItem(const Item *const item) const
{
createOutPacket(CMSG_QUICK_IDENTIFY_ITEM);
- outMsg.writeInt16(static_cast<int16_t>(item->getInvIndex()),
+ outMsg.writeInt16(CAST_S16(item->getInvIndex()),
"item index");
}
diff --git a/src/net/eathena/inventoryrecv.cpp b/src/net/eathena/inventoryrecv.cpp
index fcaada26a..d3b969143 100644
--- a/src/net/eathena/inventoryrecv.cpp
+++ b/src/net/eathena/inventoryrecv.cpp
@@ -97,7 +97,7 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg)
const int itemType = msg.readUInt8("item type");
msg.readInt32("location");
const int equipType = msg.readInt32("wear state");
- const uint8_t refine = static_cast<uint8_t>(msg.readInt8("refine"));
+ const uint8_t refine = CAST_U8(msg.readInt8("refine"));
int cards[maxCards];
for (int f = 0; f < maxCards; f++)
cards[f] = msg.readInt16("card");
diff --git a/src/net/eathena/itemrecv.cpp b/src/net/eathena/itemrecv.cpp
index 79892ebf7..822b4684d 100644
--- a/src/net/eathena/itemrecv.cpp
+++ b/src/net/eathena/itemrecv.cpp
@@ -44,8 +44,8 @@ void ItemRecv::processItemDropped(Net::MessageIn &msg)
msg.readUInt8("identify"), Identified);
const int x = msg.readInt16("x");
const int y = msg.readInt16("y");
- const int subX = static_cast<int>(msg.readInt8("subx"));
- const int subY = static_cast<int>(msg.readInt8("suby"));
+ const int subX = CAST_S32(msg.readInt8("subx"));
+ const int subY = CAST_S32(msg.readInt8("suby"));
const int amount = msg.readInt16("count");
if (actorManager)
@@ -79,8 +79,8 @@ void ItemRecv::processItemDropped2(Net::MessageIn &msg)
const int x = msg.readInt16("x");
const int y = msg.readInt16("y");
const int amount = msg.readInt16("amount");
- const int subX = static_cast<int>(msg.readInt8("subx"));
- const int subY = static_cast<int>(msg.readInt8("suby"));
+ const int subX = CAST_S32(msg.readInt8("subx"));
+ const int subY = CAST_S32(msg.readInt8("suby"));
if (actorManager)
{
@@ -119,8 +119,8 @@ void ItemRecv::processItemVisible(Net::MessageIn &msg)
const int x = msg.readInt16("x");
const int y = msg.readInt16("y");
const int amount = msg.readInt16("amount");
- const int subX = static_cast<int>(msg.readInt8("sub x"));
- const int subY = static_cast<int>(msg.readInt8("sub y"));
+ const int subX = CAST_S32(msg.readInt8("sub x"));
+ const int subY = CAST_S32(msg.readInt8("sub y"));
if (actorManager)
{
@@ -153,8 +153,8 @@ void ItemRecv::processItemVisible2(Net::MessageIn &msg)
const int x = msg.readInt16("x");
const int y = msg.readInt16("y");
const int amount = msg.readInt16("amount");
- const int subX = static_cast<int>(msg.readInt8("sub x"));
- const int subY = static_cast<int>(msg.readInt8("sub y"));
+ const int subX = CAST_S32(msg.readInt8("sub x"));
+ const int subY = CAST_S32(msg.readInt8("sub y"));
if (actorManager)
{
diff --git a/src/net/eathena/mailhandler.cpp b/src/net/eathena/mailhandler.cpp
index d1ab80005..7bcc53088 100644
--- a/src/net/eathena/mailhandler.cpp
+++ b/src/net/eathena/mailhandler.cpp
@@ -70,21 +70,21 @@ void MailHandler::returnMessage(const int msgId) const
void MailHandler::setAttach(const int index, const int amount) const
{
createOutPacket(CMSG_MAIL_SET_ATTACH);
- outMsg.writeInt16(static_cast<int16_t>(index + INVENTORY_OFFSET), "index");
+ outMsg.writeInt16(CAST_S16(index + INVENTORY_OFFSET), "index");
outMsg.writeInt32(amount, "amount");
}
void MailHandler::setAttachMoney(const int money) const
{
createOutPacket(CMSG_MAIL_SET_ATTACH);
- outMsg.writeInt16(static_cast<int16_t>(0), "index");
+ outMsg.writeInt16(CAST_S16(0), "index");
outMsg.writeInt32(money, "money");
}
void MailHandler::resetAttach(const int flag) const
{
createOutPacket(CMSG_MAIL_RESET_ATTACH);
- outMsg.writeInt16(static_cast<int16_t>(flag), "flag");
+ outMsg.writeInt16(CAST_S16(flag), "flag");
}
void MailHandler::send(const std::string &name,
@@ -93,13 +93,13 @@ void MailHandler::send(const std::string &name,
{
if (message.size() > 255)
message = message.substr(0, 255);
- const int sz = static_cast<int>(message.size());
+ const int sz = CAST_S32(message.size());
createOutPacket(CMSG_MAIL_SEND);
- outMsg.writeInt16(static_cast<int16_t>(69 + sz), "len");
+ outMsg.writeInt16(CAST_S16(69 + sz), "len");
outMsg.writeString(name, 24, "name");
outMsg.writeString(title, 40, "title");
- outMsg.writeInt8(static_cast<int8_t>(sz), "message size");
+ outMsg.writeInt8(CAST_S8(sz), "message size");
outMsg.writeString(message, sz, "message");
}
diff --git a/src/net/eathena/markethandler.cpp b/src/net/eathena/markethandler.cpp
index de0e31345..b055d574a 100644
--- a/src/net/eathena/markethandler.cpp
+++ b/src/net/eathena/markethandler.cpp
@@ -56,11 +56,11 @@ void MarketHandler::buyItem(const int itemId,
cnt = 100;
createOutPacket(CMSG_NPC_MARKET_BUY);
- outMsg.writeInt16(static_cast<int16_t>(4 + 6 * cnt), "len");
+ outMsg.writeInt16(CAST_S16(4 + 6 * cnt), "len");
for (int f = 0; f < cnt; f ++)
{
- outMsg.writeInt16(static_cast<int16_t>(itemId), "item id");
- outMsg.writeInt32(static_cast<int16_t>(amount2), "amount");
+ outMsg.writeInt16(CAST_S16(itemId), "item id");
+ outMsg.writeInt32(CAST_S16(amount2), "amount");
}
}
@@ -86,7 +86,7 @@ void MarketHandler::buyItems(std::vector<ShopItem*> &items) const
return;
createOutPacket(CMSG_NPC_MARKET_BUY);
- outMsg.writeInt16(static_cast<int16_t>(4 + pairSize * cnt), "len");
+ outMsg.writeInt16(CAST_S16(4 + pairSize * cnt), "len");
FOR_EACH (std::vector<ShopItem*>::iterator, it, items)
{
ShopItem *const item = *it;
@@ -101,15 +101,15 @@ void MarketHandler::buyItems(std::vector<ShopItem*> &items) const
{
for (int f = 0; f < usedQuantity; f ++)
{
- outMsg.writeInt16(static_cast<int16_t>(item->getId()),
+ outMsg.writeInt16(CAST_S16(item->getId()),
"item id");
- outMsg.writeInt32(static_cast<int16_t>(1), "amount");
+ outMsg.writeInt32(CAST_S16(1), "amount");
}
}
else
{
- outMsg.writeInt16(static_cast<int16_t>(item->getId()), "item id");
- outMsg.writeInt32(static_cast<int16_t>(usedQuantity), "amount");
+ outMsg.writeInt16(CAST_S16(item->getId()), "item id");
+ outMsg.writeInt32(CAST_S16(usedQuantity), "amount");
}
}
}
diff --git a/src/net/eathena/mercenaryhandler.cpp b/src/net/eathena/mercenaryhandler.cpp
index a14eac0ac..84eb5671c 100644
--- a/src/net/eathena/mercenaryhandler.cpp
+++ b/src/net/eathena/mercenaryhandler.cpp
@@ -61,8 +61,8 @@ void MercenaryHandler::move(const int x, const int y) const
return;
createOutPacket(CMSG_HOMMERC_MOVE_TO);
outMsg.writeBeingId(id, "mercenary id");
- outMsg.writeCoordinates(static_cast<uint16_t>(x),
- static_cast<uint16_t>(y),
+ outMsg.writeCoordinates(CAST_U16(x),
+ CAST_U16(y),
0U, "position");
}
@@ -75,7 +75,7 @@ void MercenaryHandler::attack(const BeingId targetId,
createOutPacket(CMSG_HOMMERC_ATTACK);
outMsg.writeBeingId(id, "mercenary id");
outMsg.writeBeingId(targetId, "target id");
- outMsg.writeInt8(static_cast<int8_t>(keep == Keep_true ? 1 : 0), "keep");
+ outMsg.writeInt8(CAST_S8(keep == Keep_true ? 1 : 0), "keep");
}
void MercenaryHandler::talk(const std::string &restrict text) const
@@ -90,8 +90,8 @@ void MercenaryHandler::talk(const std::string &restrict text) const
const size_t sz = msg.size();
createOutPacket(CMSG_HOMMERC_TALK);
- outMsg.writeInt16(static_cast<int16_t>(sz + 4 + 1), "len");
- outMsg.writeString(msg, static_cast<int>(sz), "message");
+ outMsg.writeInt16(CAST_S16(sz + 4 + 1), "len");
+ outMsg.writeString(msg, CAST_S32(sz), "message");
outMsg.writeInt8(0, "zero byte");
}
diff --git a/src/net/eathena/messagein.cpp b/src/net/eathena/messagein.cpp
index 324666e86..fa19465a3 100644
--- a/src/net/eathena/messagein.cpp
+++ b/src/net/eathena/messagein.cpp
@@ -56,10 +56,10 @@ uint16_t MessageIn::readId()
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int16_t swap;
- memcpy(&swap, mData + static_cast<size_t>(mPos), sizeof(int16_t));
+ memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int16_t));
value = SDL_Swap16(swap);
#else
- memcpy(&value, mData + static_cast<size_t>(mPos), sizeof(int16_t));
+ memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int16_t));
#endif
}
return value;
@@ -72,14 +72,14 @@ int16_t MessageIn::readInt16(const char *const str)
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int16_t swap;
- memcpy(&swap, mData + static_cast<size_t>(mPos), sizeof(int16_t));
+ memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int16_t));
value = SDL_Swap16(swap);
#else
- memcpy(&value, mData + static_cast<size_t>(mPos), sizeof(int16_t));
+ memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int16_t));
#endif
}
- DEBUGLOG2("readInt16: " + toStringPrint(static_cast<unsigned int>(
- static_cast<uint16_t>(value))),
+ DEBUGLOG2("readInt16: " + toStringPrint(CAST_U32(
+ CAST_U16(value))),
mPos, str);
mPos += 2;
PacketCounters::incInBytes(2);
@@ -93,13 +93,13 @@ int32_t MessageIn::readInt32(const char *const str)
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int32_t swap;
- memcpy(&swap, mData + static_cast<size_t>(mPos), sizeof(int32_t));
+ memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int32_t));
value = SDL_Swap32(swap);
#else
- memcpy(&value, mData + static_cast<size_t>(mPos), sizeof(int32_t));
+ memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int32_t));
#endif
}
- DEBUGLOG2("readInt32: " + toStringPrint(static_cast<unsigned int>(value)),
+ DEBUGLOG2("readInt32: " + toStringPrint(CAST_U32(value)),
mPos, str);
mPos += 4;
PacketCounters::incInBytes(4);
@@ -118,13 +118,13 @@ int64_t MessageIn::readInt64(const char *const str)
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int64_t swap;
- memcpy(&swap, mData + static_cast<size_t>(mPos), sizeof(int64_t));
+ memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int64_t));
value = SDL_Swap64(swap);
#else
- memcpy(&value, mData + static_cast<size_t>(mPos), sizeof(int64_t));
+ memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int64_t));
#endif
}
- DEBUGLOG2("readInt64: " + toStringPrint(static_cast<unsigned int>(value)),
+ DEBUGLOG2("readInt64: " + toStringPrint(CAST_U32(value)),
mPos, str);
mPos += 8;
PacketCounters::incInBytes(8);
diff --git a/src/net/eathena/messageout.cpp b/src/net/eathena/messageout.cpp
index f97cc97d5..83be120e5 100644
--- a/src/net/eathena/messageout.cpp
+++ b/src/net/eathena/messageout.cpp
@@ -40,13 +40,13 @@ MessageOut::MessageOut(const int16_t id) :
mNetwork(EAthena::Network::instance())
{
mNetwork->fixSendBuffer();
- mData = mNetwork->mOutBuffer + static_cast<size_t>(mNetwork->mOutSize);
+ mData = mNetwork->mOutBuffer + CAST_SIZE(mNetwork->mOutSize);
}
void MessageOut::expand(const size_t bytes)
{
- mNetwork->mOutSize += static_cast<unsigned>(bytes);
- PacketCounters::incOutBytes(static_cast<int>(bytes));
+ mNetwork->mOutSize += CAST_U32(bytes);
+ PacketCounters::incOutBytes(CAST_S32(bytes));
}
void MessageOut::writeInt16(const int16_t value, const char *const str)
@@ -54,12 +54,12 @@ void MessageOut::writeInt16(const int16_t value, const char *const str)
expand(2);
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int16_t swap = SDL_Swap16(value);
- memcpy(mData + static_cast<size_t>(mPos), &swap, sizeof(int16_t));
+ memcpy(mData + CAST_SIZE(mPos), &swap, sizeof(int16_t));
#else
- memcpy(mData + static_cast<size_t>(mPos), &value, sizeof(int16_t));
+ memcpy(mData + CAST_SIZE(mPos), &value, sizeof(int16_t));
#endif
- DEBUGLOG2("writeInt16: " + toStringPrint(static_cast<unsigned int>(
- static_cast<uint16_t>(value))),
+ DEBUGLOG2("writeInt16: " + toStringPrint(CAST_U32(
+ CAST_U16(value))),
mPos, str);
mPos += 2;
PacketCounters::incOutBytes(2);
@@ -67,14 +67,14 @@ void MessageOut::writeInt16(const int16_t value, const char *const str)
void MessageOut::writeInt32(const int32_t value, const char *const str)
{
- DEBUGLOG2("writeInt32: " + toStringPrint(static_cast<unsigned int>(value)),
+ DEBUGLOG2("writeInt32: " + toStringPrint(CAST_U32(value)),
mPos, str);
expand(4);
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int32_t swap = SDL_Swap32(value);
- memcpy(mData + static_cast<size_t>(mPos), &swap, sizeof(int32_t));
+ memcpy(mData + CAST_SIZE(mPos), &swap, sizeof(int32_t));
#else
- memcpy(mData + static_cast<size_t>(mPos), &value, sizeof(int32_t));
+ memcpy(mData + CAST_SIZE(mPos), &value, sizeof(int32_t));
#endif
mPos += 4;
PacketCounters::incOutBytes(4);
@@ -85,9 +85,9 @@ 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))
+#define LOBYTE(w) (CAST_U8(w))
+#define HIBYTE(w) (CAST_U8(( \
+CAST_U16(w)) >> 8))
void MessageOut::writeCoordinates(const uint16_t x,
const uint16_t y,
@@ -95,11 +95,11 @@ void MessageOut::writeCoordinates(const uint16_t x,
const char *const str)
{
DEBUGLOG2(strprintf("writeCoordinates: %u,%u %u",
- static_cast<unsigned>(x),
- static_cast<unsigned>(y),
- static_cast<unsigned>(direction)), mPos, str);
+ CAST_U32(x),
+ CAST_U32(y),
+ CAST_U32(direction)), mPos, str);
unsigned char *const data = reinterpret_cast<unsigned char*>(mData)
- + static_cast<size_t>(mPos);
+ + CAST_SIZE(mPos);
mNetwork->mOutSize += 3;
mPos += 3;
@@ -109,7 +109,7 @@ void MessageOut::writeCoordinates(const uint16_t x,
data[1] = 1;
data[2] = 2;
data[0] = HIBYTE(temp);
- data[1] = static_cast<unsigned char>(temp);
+ data[1] = CAST_U8(temp);
temp = y;
temp <<= 4;
data[1] |= HIBYTE(temp);
diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp
index 5d8bb6c24..934afe9f8 100644
--- a/src/net/eathena/network.cpp
+++ b/src/net/eathena/network.cpp
@@ -169,7 +169,7 @@ bool Network::messageReady()
{
const int msgId = readWord(0);
if (msgId >= 0 &&
- static_cast<unsigned int>(msgId) < packet_lengths_size)
+ CAST_U32(msgId) < packet_lengths_size)
{
len = mPackets[msgId].len;
}
@@ -178,7 +178,7 @@ bool Network::messageReady()
len = readWord(2);
}
- const bool ret = (mInSize >= static_cast<unsigned int>(len));
+ const bool ret = (mInSize >= CAST_U32(len));
SDL_mutexV(mMutexIn);
return ret;
diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp
index 07cce2351..7d0a65abc 100644
--- a/src/net/eathena/npchandler.cpp
+++ b/src/net/eathena/npchandler.cpp
@@ -102,9 +102,9 @@ 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.writeInt16(CAST_S16(value.length() + 9), "len");
outMsg.writeBeingId(npcId, "npc id");
- outMsg.writeString(value, static_cast<int>(value.length()), "value");
+ outMsg.writeString(value, CAST_S32(value.length()), "value");
outMsg.writeInt8(0, "null byte");
}
@@ -129,8 +129,8 @@ void NpcHandler::buyItem(const BeingId beingId A_UNUSED,
{
createOutPacket(CMSG_NPC_BUY_REQUEST);
outMsg.writeInt16(8, "len");
- outMsg.writeInt16(static_cast<int16_t>(amount), "amount");
- outMsg.writeInt16(static_cast<int16_t>(itemId), "item id");
+ outMsg.writeInt16(CAST_S16(amount), "amount");
+ outMsg.writeInt16(CAST_S16(itemId), "item id");
}
void NpcHandler::buyItems(std::vector<ShopItem*> &items) const
@@ -155,7 +155,7 @@ void NpcHandler::buyItems(std::vector<ShopItem*> &items) const
return;
createOutPacket(CMSG_NPC_BUY_REQUEST);
- outMsg.writeInt16(static_cast<int16_t>(4 + pairSize * cnt), "len");
+ outMsg.writeInt16(CAST_S16(4 + pairSize * cnt), "len");
FOR_EACH (std::vector<ShopItem*>::iterator, it, items)
{
ShopItem *const item = *it;
@@ -169,15 +169,15 @@ void NpcHandler::buyItems(std::vector<ShopItem*> &items) const
{
for (int f = 0; f < usedQuantity; f ++)
{
- outMsg.writeInt16(static_cast<int16_t>(1), "amount");
- outMsg.writeInt16(static_cast<int16_t>(item->getId()),
+ outMsg.writeInt16(CAST_S16(1), "amount");
+ outMsg.writeInt16(CAST_S16(item->getId()),
"item id");
}
}
else
{
- outMsg.writeInt16(static_cast<int16_t>(usedQuantity), "amount");
- outMsg.writeInt16(static_cast<int16_t>(item->getId()), "item id");
+ outMsg.writeInt16(CAST_S16(usedQuantity), "amount");
+ outMsg.writeInt16(CAST_S16(item->getId()), "item id");
}
}
}
@@ -187,9 +187,9 @@ void NpcHandler::sellItem(const BeingId beingId A_UNUSED,
{
createOutPacket(CMSG_NPC_SELL_REQUEST);
outMsg.writeInt16(8, "len");
- outMsg.writeInt16(static_cast<int16_t>(itemId + INVENTORY_OFFSET),
+ outMsg.writeInt16(CAST_S16(itemId + INVENTORY_OFFSET),
"item index");
- outMsg.writeInt16(static_cast<int16_t>(amount), "amount");
+ outMsg.writeInt16(CAST_S16(amount), "amount");
}
void NpcHandler::sellItems(std::vector<ShopItem*> &items) const
@@ -207,7 +207,7 @@ void NpcHandler::sellItems(std::vector<ShopItem*> &items) const
}
createOutPacket(CMSG_NPC_SELL_REQUEST);
- outMsg.writeInt16(static_cast<int16_t>(4 + pairSize * cnt), "len");
+ outMsg.writeInt16(CAST_S16(4 + pairSize * cnt), "len");
FOR_EACH (std::vector<ShopItem*>::iterator, it, items)
{
ShopItem *const item = *it;
@@ -216,10 +216,10 @@ void NpcHandler::sellItems(std::vector<ShopItem*> &items) const
continue;
item->increaseUsedQuantity(-usedQuantity);
item->update();
- outMsg.writeInt16(static_cast<int16_t>(
+ outMsg.writeInt16(CAST_S16(
item->getCurrentInvIndex() + INVENTORY_OFFSET),
"item index");
- outMsg.writeInt16(static_cast<int16_t>(usedQuantity), "amount");
+ outMsg.writeInt16(CAST_S16(usedQuantity), "amount");
}
}
@@ -234,24 +234,24 @@ void NpcHandler::produceMix(const int nameId,
const int materialId3) const
{
createOutPacket(CMSG_NPC_PRODUCE_MIX);
- outMsg.writeInt16(static_cast<int16_t>(nameId), "name id");
- outMsg.writeInt16(static_cast<int16_t>(materialId1), "material 1");
- outMsg.writeInt16(static_cast<int16_t>(materialId2), "material 2");
- outMsg.writeInt16(static_cast<int16_t>(materialId3), "material 3");
+ outMsg.writeInt16(CAST_S16(nameId), "name id");
+ outMsg.writeInt16(CAST_S16(materialId1), "material 1");
+ outMsg.writeInt16(CAST_S16(materialId2), "material 2");
+ outMsg.writeInt16(CAST_S16(materialId3), "material 3");
}
void NpcHandler::cooking(const CookingTypeT type,
const int nameId) const
{
createOutPacket(CMSG_NPC_COOKING);
- outMsg.writeInt16(static_cast<int16_t>(type), "type");
- outMsg.writeInt16(static_cast<int16_t>(nameId), "name id");
+ outMsg.writeInt16(CAST_S16(type), "type");
+ outMsg.writeInt16(CAST_S16(nameId), "name id");
}
void NpcHandler::repair(const int index) const
{
createOutPacket(CMSG_NPC_REPAIR);
- outMsg.writeInt16(static_cast<int16_t>(index), "index");
+ outMsg.writeInt16(CAST_S16(index), "index");
}
void NpcHandler::refine(const int index) const
@@ -263,19 +263,19 @@ void NpcHandler::refine(const int index) const
void NpcHandler::identify(const int index) const
{
createOutPacket(CMSG_NPC_IDENTIFY);
- outMsg.writeInt16(static_cast<int16_t>(index), "index");
+ outMsg.writeInt16(CAST_S16(index), "index");
}
void NpcHandler::selectArrow(const int nameId) const
{
createOutPacket(CMSG_NPC_SELECT_ARROW);
- outMsg.writeInt16(static_cast<int16_t>(nameId), "name id");
+ outMsg.writeInt16(CAST_S16(nameId), "name id");
}
void NpcHandler::selectAutoSpell(const int skillId) const
{
createOutPacket(CMSG_NPC_SELECT_AUTO_SPELL);
- outMsg.writeInt32(static_cast<int16_t>(skillId), "skill id");
+ outMsg.writeInt32(CAST_S16(skillId), "skill id");
}
BeingId NpcHandler::getNpc(Net::MessageIn &msg,
diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp
index d41b7914d..3aa26b1b5 100644
--- a/src/net/eathena/partyhandler.cpp
+++ b/src/net/eathena/partyhandler.cpp
@@ -83,7 +83,7 @@ void PartyHandler::inviteResponse(const int partyId,
{
createOutPacket(CMSG_PARTY_INVITED2);
outMsg.writeInt32(partyId, "party id");
- outMsg.writeInt8(static_cast<int8_t>(accept ? 1 : 0), "accept");
+ outMsg.writeInt8(CAST_S8(accept ? 1 : 0), "accept");
}
}
@@ -125,8 +125,8 @@ void PartyHandler::chat(const std::string &text) const
const std::string mes = std::string(localPlayer->getName()).append(
" : ").append(text);
- outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4 + 1), "len");
- outMsg.writeString(mes, static_cast<int>(mes.length()), "nick : message");
+ outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len");
+ outMsg.writeString(mes, CAST_S32(mes.length()), "nick : message");
outMsg.writeInt8(0, "null char");
}
@@ -137,8 +137,8 @@ void PartyHandler::setShareExperience(const PartyShareT share) const
return;
createOutPacket(CMSG_PARTY_SETTINGS);
- outMsg.writeInt16(static_cast<int16_t>(share), "share exp");
- outMsg.writeInt16(static_cast<int16_t>(Ea::PartyRecv::mShareItems),
+ outMsg.writeInt16(CAST_S16(share), "share exp");
+ outMsg.writeInt16(CAST_S16(Ea::PartyRecv::mShareItems),
"share items");
}
@@ -149,9 +149,9 @@ void PartyHandler::setShareItems(const PartyShareT share) const
return;
createOutPacket(CMSG_PARTY_SETTINGS);
- outMsg.writeInt16(static_cast<int16_t>(Ea::PartyRecv::mShareExp),
+ outMsg.writeInt16(CAST_S16(Ea::PartyRecv::mShareExp),
"share exp");
- outMsg.writeInt16(static_cast<int16_t>(share), "share items");
+ outMsg.writeInt16(CAST_S16(share), "share items");
}
void PartyHandler::changeLeader(const std::string &name) const
@@ -167,7 +167,7 @@ void PartyHandler::changeLeader(const std::string &name) const
void PartyHandler::allowInvite(const bool allow) const
{
createOutPacket(CMSG_PARTY_ALLOW_INVITES);
- outMsg.writeInt8(static_cast<int8_t>(allow ? 1 : 0), "allow");
+ outMsg.writeInt8(CAST_S8(allow ? 1 : 0), "allow");
}
} // namespace EAthena
diff --git a/src/net/eathena/pethandler.cpp b/src/net/eathena/pethandler.cpp
index b7a2a3b34..55f285dc1 100644
--- a/src/net/eathena/pethandler.cpp
+++ b/src/net/eathena/pethandler.cpp
@@ -46,8 +46,8 @@ void PetHandler::move(const int petId A_UNUSED,
return;
createOutPacket(CMSG_PET_MOVE_TO);
outMsg.writeInt32(0, "pet id");
- outMsg.writeInt16(static_cast<int16_t>(x), "x");
- outMsg.writeInt16(static_cast<int16_t>(y), "y");
+ outMsg.writeInt16(CAST_S16(x), "x");
+ outMsg.writeInt16(CAST_S16(y), "y");
}
void PetHandler::spawn(const Being *const being A_UNUSED,
diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp
index c319c6e8d..c07fa4d13 100644
--- a/src/net/eathena/playerhandler.cpp
+++ b/src/net/eathena/playerhandler.cpp
@@ -69,7 +69,7 @@ void PlayerHandler::increaseAttribute(const AttributesT attr) const
if (attr >= Attributes::STR && attr <= Attributes::LUK)
{
createOutPacket(CMSG_STAT_UPDATE_REQUEST);
- outMsg.writeInt16(static_cast<int16_t>(attr), "attribute id");
+ outMsg.writeInt16(CAST_S16(attr), "attribute id");
outMsg.writeInt8(1, "increase");
}
}
@@ -109,9 +109,9 @@ void PlayerHandler::setDestination(const int x, const int y,
const int direction) const
{
createOutPacket(CMSG_PLAYER_CHANGE_DEST);
- outMsg.writeCoordinates(static_cast<uint16_t>(x),
- static_cast<uint16_t>(y),
- static_cast<unsigned char>(direction), "destination");
+ outMsg.writeCoordinates(CAST_U16(x),
+ CAST_U16(y),
+ CAST_U8(direction), "destination");
}
void PlayerHandler::changeAction(const BeingActionT &action) const
@@ -165,10 +165,10 @@ void PlayerHandler::setShortcut(const int idx,
const int level) const
{
createOutPacket(CMSG_SET_SHORTCUTS);
- outMsg.writeInt16(static_cast<int16_t>(idx), "index");
- outMsg.writeInt8(static_cast<int8_t>(type), "type");
+ outMsg.writeInt16(CAST_S16(idx), "index");
+ outMsg.writeInt8(CAST_S8(type), "type");
outMsg.writeInt32(id, "id");
- outMsg.writeInt16(static_cast<int16_t>(level), "level");
+ outMsg.writeInt16(CAST_S16(level), "level");
}
void PlayerHandler::shortcutShiftRow(const int row) const
@@ -176,7 +176,7 @@ void PlayerHandler::shortcutShiftRow(const int row) const
if (serverVersion != 0 && serverVersion < 11)
return;
createOutPacket(CMSG_SHORTCUTS_ROW_SHIFT);
- outMsg.writeInt8(static_cast<int8_t>(row), "row");
+ outMsg.writeInt8(CAST_S8(row), "row");
}
void PlayerHandler::removeOption() const
@@ -187,7 +187,7 @@ void PlayerHandler::removeOption() const
void PlayerHandler::changeCart(const int type) const
{
createOutPacket(CMSG_CHANGE_CART);
- outMsg.writeInt16(static_cast<int16_t>(type), "type");
+ outMsg.writeInt16(CAST_S16(type), "type");
}
void PlayerHandler::setMemo() const
diff --git a/src/net/eathena/playerrecv.cpp b/src/net/eathena/playerrecv.cpp
index 6aa71870a..928faf45b 100644
--- a/src/net/eathena/playerrecv.cpp
+++ b/src/net/eathena/playerrecv.cpp
@@ -389,7 +389,7 @@ void PlayerRecv::processOnlineList(Net::MessageIn &msg)
int addVal = 3;
while (buf - start + 1 < size
- && *(buf + static_cast<size_t>(addVal)))
+ && *(buf + CAST_SIZE(addVal)))
{
unsigned char status = *buf;
buf ++;
diff --git a/src/net/eathena/questhandler.cpp b/src/net/eathena/questhandler.cpp
index 35a903a31..452448101 100644
--- a/src/net/eathena/questhandler.cpp
+++ b/src/net/eathena/questhandler.cpp
@@ -39,7 +39,7 @@ void QuestHandler::setQeustActiveState(const int questId,
{
createOutPacket(CMSG_QUEST_ACTIVATE);
outMsg.writeInt32(questId, "quest id");
- outMsg.writeInt8(static_cast<int8_t>(active ? 1 : 0), "activate");
+ outMsg.writeInt8(CAST_S8(active ? 1 : 0), "activate");
}
} // namespace EAthena
diff --git a/src/net/eathena/searchstorehandler.cpp b/src/net/eathena/searchstorehandler.cpp
index 64eb824cd..93e199286 100644
--- a/src/net/eathena/searchstorehandler.cpp
+++ b/src/net/eathena/searchstorehandler.cpp
@@ -42,12 +42,12 @@ void SearchStoreHandler::search(const StoreSearchTypeT type,
{
createOutPacket(CMSG_SEARCHSTORE_SEARCH);
outMsg.writeInt16(23, "len");
- outMsg.writeInt8(static_cast<uint8_t>(type), "search type");
+ outMsg.writeInt8(CAST_U8(type), "search type");
outMsg.writeInt32(maxPrice, "max price");
outMsg.writeInt32(minPrice, "min price");
outMsg.writeInt32(1, "items count");
outMsg.writeInt32(0, "cards count");
- outMsg.writeInt16(static_cast<int16_t>(itemId), "item id");
+ outMsg.writeInt16(CAST_S16(itemId), "item id");
}
void SearchStoreHandler::nextPage() const
@@ -67,7 +67,7 @@ void SearchStoreHandler::select(const int accountId,
createOutPacket(CMSG_SEARCHSTORE_CLICK);
outMsg.writeInt32(accountId, "account id");
outMsg.writeInt32(storeId, "store id");
- outMsg.writeInt16(static_cast<int16_t>(itemId), "item id");
+ outMsg.writeInt16(CAST_S16(itemId), "item id");
}
} // namespace EAthena
diff --git a/src/net/eathena/skillhandler.cpp b/src/net/eathena/skillhandler.cpp
index 9fbaab265..fb56fae4b 100644
--- a/src/net/eathena/skillhandler.cpp
+++ b/src/net/eathena/skillhandler.cpp
@@ -42,8 +42,8 @@ void SkillHandler::useBeing(const int id, const int level,
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.writeInt16(CAST_S16(level), "skill level");
+ outMsg.writeInt16(CAST_S16(id), "skill id");
outMsg.writeInt32(toInt(beingId, int), "target id");
}
@@ -51,10 +51,10 @@ void SkillHandler::usePos(const int id, const int level,
const int x, const int y) const
{
createOutPacket(CMSG_SKILL_USE_POSITION);
- outMsg.writeInt16(static_cast<int16_t>(level), "skill level");
- outMsg.writeInt16(static_cast<int16_t>(id), "skill id");
- outMsg.writeInt16(static_cast<int16_t>(x), "x");
- outMsg.writeInt16(static_cast<int16_t>(y), "y");
+ outMsg.writeInt16(CAST_S16(level), "skill level");
+ outMsg.writeInt16(CAST_S16(id), "skill id");
+ outMsg.writeInt16(CAST_S16(x), "x");
+ outMsg.writeInt16(CAST_S16(y), "y");
}
void SkillHandler::usePos(const int id, const int level,
@@ -62,17 +62,17 @@ void SkillHandler::usePos(const int id, const int level,
const std::string &text) const
{
createOutPacket(CMSG_SKILL_USE_POSITION_MORE);
- outMsg.writeInt16(static_cast<int16_t>(level), "level");
- outMsg.writeInt16(static_cast<int16_t>(id), "id");
- outMsg.writeInt16(static_cast<int16_t>(x), "x");
- outMsg.writeInt16(static_cast<int16_t>(y), "y");
+ outMsg.writeInt16(CAST_S16(level), "level");
+ outMsg.writeInt16(CAST_S16(id), "id");
+ outMsg.writeInt16(CAST_S16(x), "x");
+ outMsg.writeInt16(CAST_S16(y), "y");
outMsg.writeString(text, 80, "text");
}
void SkillHandler::useMap(const int id, const std::string &map) const
{
createOutPacket(CMSG_SKILL_USE_MAP);
- outMsg.writeInt16(static_cast<int16_t>(id), "skill id");
+ outMsg.writeInt16(CAST_S16(id), "skill id");
outMsg.writeString(map, 16, "map name");
}
diff --git a/src/net/eathena/skillrecv.cpp b/src/net/eathena/skillrecv.cpp
index 214cd88d9..d67620e4c 100644
--- a/src/net/eathena/skillrecv.cpp
+++ b/src/net/eathena/skillrecv.cpp
@@ -203,17 +203,17 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg)
const int bskill = msg.readInt32("btype");
const signed char success = msg.readUInt8("success");
const signed char reason = msg.readUInt8("reason");
- if (success != static_cast<int>(SKILL_FAILED)
- && bskill == static_cast<int>(BSKILL_EMOTE))
+ if (success != CAST_S32(SKILL_FAILED)
+ && bskill == CAST_S32(BSKILL_EMOTE))
{
logger->log("Action: %d/%d", bskill, success);
}
std::string txt;
- if (success == static_cast<int>(SKILL_FAILED) && bskill != 0)
+ if (success == CAST_S32(SKILL_FAILED) && bskill != 0)
{
- if (localPlayer && bskill == static_cast<int>(BSKILL_EMOTE)
- && reason == static_cast<int>(RFAIL_SKILLDEP))
+ if (localPlayer && bskill == CAST_S32(BSKILL_EMOTE)
+ && reason == CAST_S32(RFAIL_SKILLDEP))
{
localPlayer->stopAdvert();
}
diff --git a/src/net/eathena/tradehandler.cpp b/src/net/eathena/tradehandler.cpp
index 52ceb0d10..417d19de4 100644
--- a/src/net/eathena/tradehandler.cpp
+++ b/src/net/eathena/tradehandler.cpp
@@ -61,7 +61,7 @@ void TradeHandler::respond(const bool accept) const
PlayerInfo::setTrading(Trading_false);
createOutPacket(CMSG_TRADE_RESPONSE);
- outMsg.writeInt8(static_cast<int8_t>(accept ? 3 : 4), "accept");
+ outMsg.writeInt8(CAST_S8(accept ? 3 : 4), "accept");
}
void TradeHandler::addItem(const Item *const item, const int amount) const
@@ -72,7 +72,7 @@ void TradeHandler::addItem(const Item *const item, const int amount) const
TradeRecv::mItemIndex = item->getInvIndex();
TradeRecv::mQuantity = amount;
createOutPacket(CMSG_TRADE_ITEM_ADD_REQUEST);
- outMsg.writeInt16(static_cast<int16_t>(
+ outMsg.writeInt16(CAST_S16(
TradeRecv::mItemIndex + INVENTORY_OFFSET),
"index");
outMsg.writeInt32(amount, "amount");
diff --git a/src/net/eathena/vendinghandler.cpp b/src/net/eathena/vendinghandler.cpp
index 4d0d75ca1..ce2b8d384 100644
--- a/src/net/eathena/vendinghandler.cpp
+++ b/src/net/eathena/vendinghandler.cpp
@@ -69,8 +69,8 @@ void VendingHandler::buy(const Being *const being,
createOutPacket(CMSG_VENDING_BUY);
outMsg.writeInt16(12, "len");
outMsg.writeBeingId(being->getId(), "account id");
- outMsg.writeInt16(static_cast<int16_t>(amount), "amount");
- outMsg.writeInt16(static_cast<int16_t>(index), "index");
+ outMsg.writeInt16(CAST_S16(amount), "amount");
+ outMsg.writeInt16(CAST_S16(index), "index");
}
void VendingHandler::buy2(const Being *const being,
@@ -85,8 +85,8 @@ void VendingHandler::buy2(const Being *const being,
outMsg.writeInt16(16, "len");
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");
+ outMsg.writeInt16(CAST_S16(amount), "amount");
+ outMsg.writeInt16(CAST_S16(index), "index");
}
void VendingHandler::createShop(const std::string &name,
@@ -94,15 +94,15 @@ void VendingHandler::createShop(const std::string &name,
std::vector<ShopItem*> &items) const
{
createOutPacket(CMSG_VENDING_CREATE_SHOP);
- outMsg.writeInt16(static_cast<int16_t>(85 + items.size() * 8), "len");
+ outMsg.writeInt16(CAST_S16(85 + items.size() * 8), "len");
outMsg.writeString(name, 80, "shop name");
- outMsg.writeInt8(static_cast<int8_t>(flag ? 1 : 0), "flag");
+ outMsg.writeInt8(CAST_S8(flag ? 1 : 0), "flag");
FOR_EACH (std::vector<ShopItem*>::const_iterator, it, items)
{
const ShopItem *const item = *it;
- outMsg.writeInt16(static_cast<int16_t>(
+ outMsg.writeInt16(CAST_S16(
item->getInvIndex() + INVENTORY_OFFSET), "index");
- outMsg.writeInt16(static_cast<int16_t>(item->getQuantity()), "amount");
+ outMsg.writeInt16(CAST_S16(item->getQuantity()), "amount");
outMsg.writeInt32(item->getPrice(), "price");
}
}