diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-04-09 01:14:05 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-04-09 01:14:05 +0300 |
commit | 8d1a43609fcf67bbffb26ab52fdb07f095f602b8 (patch) | |
tree | 7a9e548023cdf4f705a3a042aefb66d47645f74a /src/net/tmwa | |
parent | d9c62405db9a3f8bffaa5789bd63f59a65e29e3a (diff) | |
download | mv-8d1a43609fcf67bbffb26ab52fdb07f095f602b8.tar.gz mv-8d1a43609fcf67bbffb26ab52fdb07f095f602b8.tar.bz2 mv-8d1a43609fcf67bbffb26ab52fdb07f095f602b8.tar.xz mv-8d1a43609fcf67bbffb26ab52fdb07f095f602b8.zip |
improve messageout class.
Diffstat (limited to 'src/net/tmwa')
-rw-r--r-- | src/net/tmwa/messageout.cpp | 18 | ||||
-rw-r--r-- | src/net/tmwa/messageout.h | 11 |
2 files changed, 15 insertions, 14 deletions
diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp index 1caa53d0d..d520b407e 100644 --- a/src/net/tmwa/messageout.cpp +++ b/src/net/tmwa/messageout.cpp @@ -39,7 +39,7 @@ namespace TmwAthena { -MessageOut::MessageOut(short id): +MessageOut::MessageOut(const short id): Net::MessageOut(id), mNetwork(TmwAthena::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", @@ -97,8 +98,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/tmwa/messageout.h b/src/net/tmwa/messageout.h index 370651659..285e333d0 100644 --- a/src/net/tmwa/messageout.h +++ b/src/net/tmwa/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; }; |