summaryrefslogtreecommitdiff
path: root/src/net/tmwa/messageout.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-02-07 16:18:13 +0300
committerAndrei Karas <akaras@inbox.ru>2016-02-07 16:18:13 +0300
commit9fe21fcd8883b37bdc30224822e6e42afb35b8f0 (patch)
tree798117abd4dc7e610997d59d530a96ddc1509f53 /src/net/tmwa/messageout.cpp
parent4429cb14e9e187edef27aba692a4266733f79c17 (diff)
downloadplus-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.tar.gz
plus-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.tar.bz2
plus-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.tar.xz
plus-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.zip
Replace most static_cast<Type> to shorter versions from defines.
Diffstat (limited to 'src/net/tmwa/messageout.cpp')
-rw-r--r--src/net/tmwa/messageout.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp
index a2c0770b7..c0ac1ef03 100644
--- a/src/net/tmwa/messageout.cpp
+++ b/src/net/tmwa/messageout.cpp
@@ -40,26 +40,26 @@ MessageOut::MessageOut(const int16_t id) :
mNetwork(TmwAthena::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)
{
- DEBUGLOG2("writeInt16: " + toStringPrint(static_cast<unsigned int>(
- static_cast<uint16_t>(value))),
+ DEBUGLOG2("writeInt16: " + toStringPrint(CAST_U32(
+ CAST_U16(value))),
mPos, 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
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)) >> 8U))
+#define LOBYTE(w) (CAST_U8(w))
+#define HIBYTE(w) (CAST_U8(( \
+CAST_U16(w)) >> 8U))
void MessageOut::writeCoordinates(const uint16_t x,
const uint16_t y,
@@ -95,10 +95,10 @@ 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), static_cast<unsigned>(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;
@@ -108,7 +108,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);