diff options
Diffstat (limited to 'src/net/eathena')
-rw-r--r-- | src/net/eathena/messageout.cpp | 18 | ||||
-rw-r--r-- | src/net/eathena/messageout.h | 11 |
2 files changed, 15 insertions, 14 deletions
diff --git a/src/net/eathena/messageout.cpp b/src/net/eathena/messageout.cpp index f25666526..734ce4057 100644 --- a/src/net/eathena/messageout.cpp +++ b/src/net/eathena/messageout.cpp @@ -39,7 +39,7 @@ namespace EAthena { -MessageOut::MessageOut(short id): +MessageOut::MessageOut(const short id): Net::MessageOut(id), mNetwork(EAthena::Network::instance()) { @@ -49,15 +49,15 @@ MessageOut::MessageOut(short id): writeInt16(id); } -void MessageOut::expand(size_t bytes) +void MessageOut::expand(const size_t bytes) { mNetwork->mOutSize += static_cast<unsigned>(bytes); PacketCounters::incOutBytes(static_cast<int>(bytes)); } -void MessageOut::writeInt16(int16_t value) +void MessageOut::writeInt16(const int16_t value) { - DEBUGLOG("writeInt16: " + toString(static_cast<int>(value))); + DEBUGLOG("writeInt16: " + toStringPrint(static_cast<int>(value))); expand(2); #if SDL_BYTEORDER == SDL_BIG_ENDIAN int16_t swap = SDL_Swap16(value); @@ -69,9 +69,9 @@ void MessageOut::writeInt16(int16_t value) PacketCounters::incOutBytes(2); } -void MessageOut::writeInt32(int32_t value) +void MessageOut::writeInt32(const int32_t value) { - DEBUGLOG("writeInt32: " + toString(value)); + DEBUGLOG("writeInt32: " + toStringPrint(value)); expand(4); #if SDL_BYTEORDER == SDL_BIG_ENDIAN int32_t swap = SDL_Swap32(value); @@ -87,7 +87,8 @@ void MessageOut::writeInt32(int32_t value) #define HIBYTE(w) (static_cast<unsigned char>(( \ static_cast<unsigned short>(w)) >> 8)) -void MessageOut::writeCoordinates(unsigned short x, unsigned short y, +void MessageOut::writeCoordinates(const unsigned short x, + const unsigned short y, unsigned char direction) { DEBUGLOG(strprintf("writeCoordinates: %u,%u %u", x, y, direction)); @@ -95,8 +96,7 @@ void MessageOut::writeCoordinates(unsigned short x, unsigned short y, mNetwork->mOutSize += 3; mPos += 3; - short temp; - temp = x; + short temp = x; temp <<= 6; data[0] = 0; data[1] = 1; diff --git a/src/net/eathena/messageout.h b/src/net/eathena/messageout.h index 7f8b6cd45..05c82b6f5 100644 --- a/src/net/eathena/messageout.h +++ b/src/net/eathena/messageout.h @@ -46,25 +46,26 @@ class MessageOut final : public Net::MessageOut /** * Constructor. */ - MessageOut(short id); + MessageOut(const short id); A_DELETE_COPY(MessageOut) - void writeInt16(int16_t value); /**< Writes a short. */ + void writeInt16(const int16_t value); /**< Writes a short. */ - void writeInt32(int32_t value); /**< Writes a long. */ + void writeInt32(const int32_t value); /**< Writes a long. */ /** * Encodes coordinates and direction in 3 bytes. */ - void writeCoordinates(unsigned short x, unsigned short y, + void writeCoordinates(const unsigned short x, + const unsigned short y, unsigned char direction); void resetPos() { mPos = 0; } private: - void expand(size_t size); + void expand(const size_t size); Network *mNetwork; }; |